FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/vvc/dsp.c
Date: 2024-07-16 12:46:59
Exec Total Coverage
Lines: 37 37 100.0%
Functions: 3 3 100.0%
Branches: 11 11 100.0%

Line Branch Exec Source
1 /*
2 * VVC DSP
3 *
4 * Copyright (C) 2021 Nuo Mi
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23 #include "dsp.h"
24 #include "ctu.h"
25 #include "itx_1d.h"
26
27 #define VVC_SIGN(v) (v < 0 ? -1 : !!v)
28
29 2100858 static void av_always_inline pad_int16(int16_t *_dst, const ptrdiff_t dst_stride, const int width, const int height)
30 {
31 2100858 const int padded_width = width + 2;
32 int16_t *dst;
33
2/2
✓ Branch 0 taken 32921520 times.
✓ Branch 1 taken 2100858 times.
35022378 for (int y = 0; y < height; y++) {
34 32921520 dst = _dst + y * dst_stride;
35
2/2
✓ Branch 0 taken 511860480 times.
✓ Branch 1 taken 32921520 times.
544782000 for (int x = 0; x < width; x++) {
36 511860480 dst[-1] = dst[0];
37 511860480 dst[width] = dst[width - 1];
38 }
39 }
40
41 2100858 _dst--;
42 //top
43 2100858 memcpy(_dst - dst_stride, _dst, padded_width * sizeof(int16_t));
44 //bottom
45 2100858 _dst += dst_stride * height;
46 2100858 memcpy(_dst, _dst - dst_stride, padded_width * sizeof(int16_t));
47 2100858 }
48
49 11784599 static int vvc_sad(const int16_t *src0, const int16_t *src1, int dx, int dy,
50 const int block_w, const int block_h)
51 {
52 11784599 int sad = 0;
53 11784599 dx -= 2;
54 11784599 dy -= 2;
55 11784599 src0 += (2 + dy) * MAX_PB_SIZE + 2 + dx;
56 11784599 src1 += (2 - dy) * MAX_PB_SIZE + 2 - dx;
57
2/2
✓ Branch 0 taken 92844900 times.
✓ Branch 1 taken 11784599 times.
104629499 for (int y = 0; y < block_h; y += 2) {
58
2/2
✓ Branch 0 taken 1459492544 times.
✓ Branch 1 taken 92844900 times.
1552337444 for (int x = 0; x < block_w; x++) {
59 1459492544 sad += FFABS(src0[x] - src1[x]);
60 }
61 92844900 src0 += 2 * MAX_PB_SIZE;
62 92844900 src1 += 2 * MAX_PB_SIZE;
63 }
64 11784599 return sad;
65 }
66
67 typedef struct IntraEdgeParams {
68 uint8_t* top;
69 uint8_t* left;
70 int filter_flag;
71
72 uint16_t left_array[6 * MAX_TB_SIZE + 5];
73 uint16_t filtered_left_array[6 * MAX_TB_SIZE + 5];
74 uint16_t top_array[6 * MAX_TB_SIZE + 5];
75 uint16_t filtered_top_array[6 * MAX_TB_SIZE + 5];
76 } IntraEdgeParams;
77
78 #define PROF_BORDER_EXT 1
79 #define PROF_BLOCK_SIZE (AFFINE_MIN_BLOCK_SIZE + PROF_BORDER_EXT * 2)
80 #define BDOF_BORDER_EXT 1
81
82 #define BDOF_PADDED_SIZE (16 + BDOF_BORDER_EXT * 2)
83 #define BDOF_BLOCK_SIZE 4
84 #define BDOF_GRADIENT_SIZE (BDOF_BLOCK_SIZE + BDOF_BORDER_EXT * 2)
85
86 #define BIT_DEPTH 8
87 #include "dsp_template.c"
88 #undef BIT_DEPTH
89
90 #define BIT_DEPTH 10
91 #include "dsp_template.c"
92 #undef BIT_DEPTH
93
94 #define BIT_DEPTH 12
95 #include "dsp_template.c"
96 #undef BIT_DEPTH
97
98 1163 void ff_vvc_dsp_init(VVCDSPContext *vvcdsp, int bit_depth)
99 {
100 #undef FUNC
101 #define FUNC(a, depth) a ## _ ## depth
102
103 #define VVC_DSP(depth) \
104 FUNC(ff_vvc_inter_dsp_init, depth)(&vvcdsp->inter); \
105 FUNC(ff_vvc_intra_dsp_init, depth)(&vvcdsp->intra); \
106 FUNC(ff_vvc_itx_dsp_init, depth)(&vvcdsp->itx); \
107 FUNC(ff_vvc_lmcs_dsp_init, depth)(&vvcdsp->lmcs); \
108 FUNC(ff_vvc_lf_dsp_init, depth)(&vvcdsp->lf); \
109 FUNC(ff_vvc_sao_dsp_init, depth)(&vvcdsp->sao); \
110 FUNC(ff_vvc_alf_dsp_init, depth)(&vvcdsp->alf); \
111
112
3/3
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 978 times.
✓ Branch 2 taken 94 times.
1163 switch (bit_depth) {
113 91 case 12:
114 91 VVC_DSP(12);
115 91 break;
116 978 case 10:
117 978 VVC_DSP(10);
118 978 break;
119 94 default:
120 94 VVC_DSP(8);
121 94 break;
122 }
123
124 #if ARCH_X86
125 1163 ff_vvc_dsp_init_x86(vvcdsp, bit_depth);
126 #endif
127 1163 }
128