../../../ffmpeg/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
699 / 1079
64.8%
Branches:
412 / 548
75.2%
Functions:
48 / 78
61.5%

libavcodec/vvc/inter_template.c
Line Branch Exec Source
1 /*
2 * VVC inter prediction DSP
3 *
4 * Copyright (C) 2022 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 "libavcodec/h26x/h2656_inter_template.c"
24 #include "libavutil/imgutils.h"
25
26 #define TMP_STRIDE EDGE_EMU_BUFFER_STRIDE
27 32706 static void av_always_inline FUNC(put_scaled)(uint8_t *_dst, const ptrdiff_t _dst_stride,
28 const uint8_t *const _src, ptrdiff_t _src_stride, const int src_height,
29 const int _x, const int _y, const int dx, const int dy,
30 const int height, const int8_t *hf, const int8_t *vf, const int width, const int is_uni, const int is_chroma)
31 {
32 int16_t tmp_array[TMP_STRIDE * MAX_PB_SIZE];
33 32706 int16_t *tmp = tmp_array;
34 32706 pixel *dst = (pixel*)_dst;
35 32706 int16_t *dst16 = (int16_t*)_dst;
36 32706 const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel);
37 32706 const ptrdiff_t src_stride = _src_stride / sizeof(pixel);
38 32706 const int shift = FFMAX(2, 14 - BIT_DEPTH);
39 32706 const int offset = 1 << (shift - 1);
40
2/6
put_scaled_10:
✓ Branch 2 → 3 taken 12264 times.
✓ Branch 2 → 4 taken 20442 times.
put_scaled_12:
✗ Branch 2 → 3 not taken.
✗ Branch 2 → 4 not taken.
put_scaled_8:
✗ Branch 2 → 3 not taken.
✗ Branch 2 → 4 not taken.
32706 const int taps = is_chroma ? VVC_INTER_CHROMA_TAPS : VVC_INTER_LUMA_TAPS;
41
2/6
put_scaled_10:
✓ Branch 5 → 6 taken 12264 times.
✓ Branch 5 → 7 taken 20442 times.
put_scaled_12:
✗ Branch 5 → 6 not taken.
✗ Branch 5 → 7 not taken.
put_scaled_8:
✗ Branch 5 → 6 not taken.
✗ Branch 5 → 7 not taken.
32706 const int extra = is_chroma ? CHROMA_EXTRA : LUMA_EXTRA;
42
2/6
put_scaled_10:
✓ Branch 8 → 9 taken 12264 times.
✓ Branch 8 → 10 taken 20442 times.
put_scaled_12:
✗ Branch 8 → 9 not taken.
✗ Branch 8 → 10 not taken.
put_scaled_8:
✗ Branch 8 → 9 not taken.
✗ Branch 8 → 10 not taken.
32706 const int extra_before = is_chroma ? CHROMA_EXTRA_BEFORE : LUMA_EXTRA_BEFORE;
43 32706 const int shift1 = 6 - is_chroma;
44 32706 const int shift2 = 4 + is_chroma;
45 32706 const int x0 = SCALED_INT(_x);
46 32706 const int y0 = SCALED_INT(_y);
47
48
2/6
put_scaled_10:
✓ Branch 19 → 12 taken 191016 times.
✓ Branch 19 → 20 taken 32706 times.
put_scaled_12:
✗ Branch 19 → 12 not taken.
✗ Branch 19 → 20 not taken.
put_scaled_8:
✗ Branch 19 → 12 not taken.
✗ Branch 19 → 20 not taken.
223722 for (int i = 0; i < width; i++) {
49 191016 const int tx = _x + dx * i;
50 191016 const int x = SCALED_INT(tx) - x0;
51 191016 const int mx = av_zero_extend(tx >> shift1, shift2);
52 191016 const int8_t *filter = hf + mx * taps;
53 191016 const pixel *src = (pixel*)_src - extra_before * src_stride;
54
55
2/6
put_scaled_10:
✓ Branch 17 → 13 taken 2455548 times.
✓ Branch 17 → 18 taken 191016 times.
put_scaled_12:
✗ Branch 17 → 13 not taken.
✗ Branch 17 → 18 not taken.
put_scaled_8:
✗ Branch 17 → 13 not taken.
✗ Branch 17 → 18 not taken.
2646564 for (int j = 0; j < src_height + extra; j++) {
56
2/6
put_scaled_10:
✓ Branch 13 → 14 taken 718156 times.
✓ Branch 13 → 15 taken 1737392 times.
put_scaled_12:
✗ Branch 13 → 14 not taken.
✗ Branch 13 → 15 not taken.
put_scaled_8:
✗ Branch 13 → 14 not taken.
✗ Branch 13 → 15 not taken.
2455548 tmp[j] = (is_chroma ? CHROMA_FILTER(src, 1) : LUMA_FILTER(src, 1)) >> (BIT_DEPTH - 8);
57 2455548 src += src_stride;
58 }
59 191016 tmp += TMP_STRIDE;
60 }
61
62
2/6
put_scaled_10:
✓ Branch 34 → 21 taken 208672 times.
✓ Branch 34 → 35 taken 32706 times.
put_scaled_12:
✗ Branch 34 → 21 not taken.
✗ Branch 34 → 35 not taken.
put_scaled_8:
✗ Branch 34 → 21 not taken.
✗ Branch 34 → 35 not taken.
241378 for (int i = 0; i < height; i++) {
63 208672 const int ty = _y + dy * i;
64 208672 const int x = SCALED_INT(ty) - y0;
65 208672 const int mx = av_zero_extend(ty >> shift1, shift2);
66 208672 const int8_t *filter = vf + mx * taps;
67
68 208672 tmp = tmp_array + extra_before;
69
2/6
put_scaled_10:
✓ Branch 29 → 22 taken 2656896 times.
✓ Branch 29 → 30 taken 208672 times.
put_scaled_12:
✗ Branch 29 → 22 not taken.
✗ Branch 29 → 30 not taken.
put_scaled_8:
✗ Branch 29 → 22 not taken.
✗ Branch 29 → 30 not taken.
2865568 for (int j = 0; j < width; j++) {
70
2/6
put_scaled_10:
✓ Branch 22 → 23 taken 885632 times.
✓ Branch 22 → 24 taken 1771264 times.
put_scaled_12:
✗ Branch 22 → 23 not taken.
✗ Branch 22 → 24 not taken.
put_scaled_8:
✗ Branch 22 → 23 not taken.
✗ Branch 22 → 24 not taken.
2656896 const int val = (is_chroma ? CHROMA_FILTER(tmp, 1) : LUMA_FILTER(tmp, 1)) >> 6;
71
2/6
put_scaled_10:
✓ Branch 25 → 26 taken 1820352 times.
✓ Branch 25 → 27 taken 836544 times.
put_scaled_12:
✗ Branch 25 → 26 not taken.
✗ Branch 25 → 27 not taken.
put_scaled_8:
✗ Branch 25 → 26 not taken.
✗ Branch 25 → 27 not taken.
2656896 if (is_uni)
72 1820352 dst[j] = av_clip_pixel((val + offset) >> shift);
73 else
74 836544 dst16[j] = val;
75 2656896 tmp += TMP_STRIDE;
76 }
77
2/6
put_scaled_10:
✓ Branch 30 → 31 taken 159280 times.
✓ Branch 30 → 32 taken 49392 times.
put_scaled_12:
✗ Branch 30 → 31 not taken.
✗ Branch 30 → 32 not taken.
put_scaled_8:
✗ Branch 30 → 31 not taken.
✗ Branch 30 → 32 not taken.
208672 if (is_uni)
78 159280 dst += dst_stride;
79 else
80 49392 dst16 += dst_stride;
81 }
82 32706 }
83
84 3519 static void FUNC(put_luma_scaled)(int16_t *_dst,
85 const uint8_t *_src, ptrdiff_t _src_stride, const int src_height,
86 const int x, const int y, const int dx, const int dy,
87 const int height, const int8_t *hf, const int8_t *vf, const int width)
88 {
89 3519 FUNC(put_scaled)((uint8_t *)_dst, MAX_PB_SIZE * sizeof(pixel), _src, _src_stride, src_height, x, y, dx, dy, height, hf, vf, width, 0, 0);
90 3519 }
91
92 2430 static void FUNC(put_chroma_scaled)(int16_t *_dst,
93 const uint8_t *_src, ptrdiff_t _src_stride, const int src_height,
94 const int x, const int y, const int dx, const int dy,
95 const int height, const int8_t *hf, const int8_t *vf, const int width)
96 {
97 2430 FUNC(put_scaled)((uint8_t *)_dst, MAX_PB_SIZE * sizeof(pixel), _src, _src_stride, src_height, x, y, dx, dy, height, hf, vf, width, 0, 1);
98 2430 }
99
100 16923 static void FUNC(put_uni_luma_scaled)(uint8_t *_dst, const ptrdiff_t _dst_stride,
101 const uint8_t *_src, ptrdiff_t _src_stride, const int src_height,
102 const int x, const int y, const int dx, const int dy,
103 const int height, const int8_t *hf, const int8_t *vf, const int width)
104 {
105 16923 FUNC(put_scaled)(_dst, _dst_stride, _src, _src_stride, src_height, x, y, dx, dy, height, hf, vf, width, 1, 0);
106 16923 }
107
108 9834 static void FUNC(put_uni_chroma_scaled)(uint8_t *_dst, const ptrdiff_t _dst_stride,
109 const uint8_t *_src, ptrdiff_t _src_stride, const int src_height,
110 const int x, const int y, const int dx, const int dy,
111 const int height, const int8_t *hf, const int8_t *vf, const int width)
112 {
113 9834 FUNC(put_scaled)(_dst, _dst_stride, _src, _src_stride, src_height, x, y, dx, dy, height, hf, vf, width, 1, 1);
114 9834 }
115
116 6 static void av_always_inline FUNC(put_uni_w_scaled)(uint8_t *_dst, const ptrdiff_t _dst_stride,
117 const uint8_t *const _src, ptrdiff_t _src_stride, const int src_height,
118 const int _x, const int _y, const int dx, const int dy, const int denom, const int wx, const int _ox,
119 const int height, const int8_t *hf, const int8_t *vf, const int width, const int is_chroma)
120 {
121 int16_t tmp_array[TMP_STRIDE * MAX_PB_SIZE];
122 6 int16_t *tmp = tmp_array;
123 6 pixel *dst = (pixel*)_dst;
124 6 const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel);
125 6 const ptrdiff_t src_stride = _src_stride / sizeof(pixel);
126 6 const int shift = denom + FFMAX(2, 14 - BIT_DEPTH);
127 6 const int offset = 1 << (shift - 1);
128 6 const int ox = _ox * (1 << (BIT_DEPTH - 8));
129
2/6
put_uni_w_scaled_10:
✓ Branch 2 → 3 taken 4 times.
✓ Branch 2 → 4 taken 2 times.
put_uni_w_scaled_12:
✗ Branch 2 → 3 not taken.
✗ Branch 2 → 4 not taken.
put_uni_w_scaled_8:
✗ Branch 2 → 3 not taken.
✗ Branch 2 → 4 not taken.
6 const int taps = is_chroma ? VVC_INTER_CHROMA_TAPS : VVC_INTER_LUMA_TAPS;
130
2/6
put_uni_w_scaled_10:
✓ Branch 5 → 6 taken 4 times.
✓ Branch 5 → 7 taken 2 times.
put_uni_w_scaled_12:
✗ Branch 5 → 6 not taken.
✗ Branch 5 → 7 not taken.
put_uni_w_scaled_8:
✗ Branch 5 → 6 not taken.
✗ Branch 5 → 7 not taken.
6 const int extra = is_chroma ? CHROMA_EXTRA : LUMA_EXTRA;
131
2/6
put_uni_w_scaled_10:
✓ Branch 8 → 9 taken 4 times.
✓ Branch 8 → 10 taken 2 times.
put_uni_w_scaled_12:
✗ Branch 8 → 9 not taken.
✗ Branch 8 → 10 not taken.
put_uni_w_scaled_8:
✗ Branch 8 → 9 not taken.
✗ Branch 8 → 10 not taken.
6 const int extra_before = is_chroma ? CHROMA_EXTRA_BEFORE : LUMA_EXTRA_BEFORE;
132 6 const int shift1 = 6 - is_chroma;
133 6 const int shift2 = 4 + is_chroma;
134 6 const int x0 = SCALED_INT(_x);
135 6 const int y0 = SCALED_INT(_y);
136
137
2/6
put_uni_w_scaled_10:
✓ Branch 19 → 12 taken 32 times.
✓ Branch 19 → 20 taken 6 times.
put_uni_w_scaled_12:
✗ Branch 19 → 12 not taken.
✗ Branch 19 → 20 not taken.
put_uni_w_scaled_8:
✗ Branch 19 → 12 not taken.
✗ Branch 19 → 20 not taken.
38 for (int i = 0; i < width; i++) {
138 32 const int tx = _x + dx * i;
139 32 const int x = SCALED_INT(tx) - x0;
140 32 const int mx = av_zero_extend(tx >> shift1, shift2);
141 32 const int8_t *filter = hf + mx * taps;
142 32 const pixel *src = (pixel*)_src - extra_before * src_stride;
143
144
2/6
put_uni_w_scaled_10:
✓ Branch 17 → 13 taken 408 times.
✓ Branch 17 → 18 taken 32 times.
put_uni_w_scaled_12:
✗ Branch 17 → 13 not taken.
✗ Branch 17 → 18 not taken.
put_uni_w_scaled_8:
✗ Branch 17 → 13 not taken.
✗ Branch 17 → 18 not taken.
440 for (int j = 0; j < src_height + extra; j++) {
145
2/6
put_uni_w_scaled_10:
✓ Branch 13 → 14 taken 136 times.
✓ Branch 13 → 15 taken 272 times.
put_uni_w_scaled_12:
✗ Branch 13 → 14 not taken.
✗ Branch 13 → 15 not taken.
put_uni_w_scaled_8:
✗ Branch 13 → 14 not taken.
✗ Branch 13 → 15 not taken.
408 tmp[j] = (is_chroma ? CHROMA_FILTER(src, 1) : LUMA_FILTER(src, 1)) >> (BIT_DEPTH - 8);
146 408 src += src_stride;
147 }
148 32 tmp += TMP_STRIDE;
149 }
150
151
2/6
put_uni_w_scaled_10:
✓ Branch 28 → 21 taken 32 times.
✓ Branch 28 → 29 taken 6 times.
put_uni_w_scaled_12:
✗ Branch 28 → 21 not taken.
✗ Branch 28 → 29 not taken.
put_uni_w_scaled_8:
✗ Branch 28 → 21 not taken.
✗ Branch 28 → 29 not taken.
38 for (int i = 0; i < height; i++) {
152 32 const int ty = _y + dy * i;
153 32 const int x = SCALED_INT(ty) - y0;
154 32 const int mx = av_zero_extend(ty >> shift1, shift2);
155 32 const int8_t *filter = vf + mx * taps;
156
157 32 tmp = tmp_array + extra_before;
158
2/6
put_uni_w_scaled_10:
✓ Branch 26 → 22 taken 192 times.
✓ Branch 26 → 27 taken 32 times.
put_uni_w_scaled_12:
✗ Branch 26 → 22 not taken.
✗ Branch 26 → 27 not taken.
put_uni_w_scaled_8:
✗ Branch 26 → 22 not taken.
✗ Branch 26 → 27 not taken.
224 for (int j = 0; j < width; j++) {
159
2/6
put_uni_w_scaled_10:
✓ Branch 22 → 23 taken 64 times.
✓ Branch 22 → 24 taken 128 times.
put_uni_w_scaled_12:
✗ Branch 22 → 23 not taken.
✗ Branch 22 → 24 not taken.
put_uni_w_scaled_8:
✗ Branch 22 → 23 not taken.
✗ Branch 22 → 24 not taken.
192 const int val = (is_chroma ? CHROMA_FILTER(tmp, 1) : LUMA_FILTER(tmp, 1)) >> 6;
160 192 dst[j] = av_clip_pixel(((wx * val + offset) >> shift) + ox);
161 192 tmp += TMP_STRIDE;
162 }
163 32 dst += dst_stride;
164 }
165 6 }
166
167 2 static void FUNC(put_uni_luma_w_scaled)(uint8_t *_dst, const ptrdiff_t _dst_stride,
168 const uint8_t *_src, ptrdiff_t _src_stride, const int src_height,
169 const int x, const int y, const int dx, const int dy, const int height,
170 const int denom, const int wx, const int ox, const int8_t *hf, const int8_t *vf, const int width)
171 {
172 2 FUNC(put_uni_w_scaled)(_dst, _dst_stride, _src, _src_stride, src_height, x, y, dx, dy, denom, wx, ox, height, hf, vf, width, 0);
173 2 }
174
175 4 static void FUNC(put_uni_chroma_w_scaled)(uint8_t *_dst, const ptrdiff_t _dst_stride,
176 const uint8_t *_src, ptrdiff_t _src_stride, const int src_height,
177 const int x, const int y, const int dx, const int dy, const int height,
178 const int denom, const int wx, const int ox, const int8_t *hf, const int8_t *vf, const int width)
179 {
180 4 FUNC(put_uni_w_scaled)(_dst, _dst_stride, _src, _src_stride, src_height, x, y, dx, dy, denom, wx, ox, height, hf, vf, width, 1);
181 4 }
182
183 #undef TMP_STRIDE
184
185 6432575 static void FUNC(avg)(uint8_t *_dst, const ptrdiff_t _dst_stride,
186 const int16_t *src0, const int16_t *src1, const int width, const int height)
187 {
188 6432575 pixel *dst = (pixel*)_dst;
189 6432575 const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel);
190 6432575 const int shift = FFMAX(3, 15 - BIT_DEPTH);
191 6432575 const int offset = 1 << (shift - 1);
192
193
6/6
avg_10:
✓ Branch 7 → 3 taken 58725116 times.
✓ Branch 7 → 8 taken 6416616 times.
avg_12:
✓ Branch 7 → 3 taken 5588 times.
✓ Branch 7 → 8 taken 154 times.
avg_8:
✓ Branch 7 → 3 taken 206796 times.
✓ Branch 7 → 8 taken 15805 times.
65370075 for (int y = 0; y < height; y++) {
194
6/6
avg_10:
✓ Branch 5 → 4 taken 750395584 times.
✓ Branch 5 → 6 taken 58725116 times.
avg_12:
✓ Branch 5 → 4 taken 215392 times.
✓ Branch 5 → 6 taken 5588 times.
avg_8:
✓ Branch 5 → 4 taken 5396608 times.
✓ Branch 5 → 6 taken 206796 times.
814945084 for (int x = 0; x < width; x++)
195 756007584 dst[x] = av_clip_pixel((src0[x] + src1[x] + offset) >> shift);
196 58937500 src0 += MAX_PB_SIZE;
197 58937500 src1 += MAX_PB_SIZE;
198 58937500 dst += dst_stride;
199 }
200 6432575 }
201
202 668457 static void FUNC(w_avg)(uint8_t *_dst, const ptrdiff_t _dst_stride,
203 const int16_t *src0, const int16_t *src1, const int width, const int height,
204 const int denom, const int w0, const int w1, const int o)
205 {
206 668457 pixel *dst = (pixel*)_dst;
207 668457 const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel);
208 668457 const int shift = denom + FFMAX(3, 15 - BIT_DEPTH);
209 668457 const int offset = (o * (1 << (BIT_DEPTH - 8)) + 1) * (1 << (shift - 1));
210
211
6/6
w_avg_10:
✓ Branch 7 → 3 taken 4608992 times.
✓ Branch 7 → 8 taken 668149 times.
w_avg_12:
✓ Branch 7 → 3 taken 5588 times.
✓ Branch 7 → 8 taken 154 times.
w_avg_8:
✓ Branch 7 → 3 taken 5588 times.
✓ Branch 7 → 8 taken 154 times.
5288625 for (int y = 0; y < height; y++) {
212
6/6
w_avg_10:
✓ Branch 5 → 4 taken 124466816 times.
✓ Branch 5 → 6 taken 4608992 times.
w_avg_12:
✓ Branch 5 → 4 taken 215392 times.
✓ Branch 5 → 6 taken 5588 times.
w_avg_8:
✓ Branch 5 → 4 taken 215392 times.
✓ Branch 5 → 6 taken 5588 times.
129517768 for (int x = 0; x < width; x++)
213 124897600 dst[x] = av_clip_pixel((src0[x] * w0 + src1[x] * w1 + offset) >> shift);
214 4620168 src0 += MAX_PB_SIZE;
215 4620168 src1 += MAX_PB_SIZE;
216 4620168 dst += dst_stride;
217 }
218 668457 }
219
220 43833 static void FUNC(put_ciip)(uint8_t *_dst, const ptrdiff_t _dst_stride,
221 const int width, const int height,
222 const uint8_t *_inter, const ptrdiff_t _inter_stride, const int intra_weight)
223 {
224 43833 pixel *dst = (pixel *)_dst;
225 43833 pixel *inter = (pixel *)_inter;
226 43833 const size_t dst_stride = _dst_stride / sizeof(pixel);
227 43833 const size_t inter_stride = _inter_stride / sizeof(pixel);
228 43833 const int inter_weight = 4 - intra_weight;
229
230
2/6
put_ciip_10:
✓ Branch 7 → 3 taken 533728 times.
✓ Branch 7 → 8 taken 43833 times.
put_ciip_12:
✗ Branch 7 → 3 not taken.
✗ Branch 7 → 8 not taken.
put_ciip_8:
✗ Branch 7 → 3 not taken.
✗ Branch 7 → 8 not taken.
577561 for (int y = 0; y < height; y++) {
231
2/6
put_ciip_10:
✓ Branch 5 → 4 taken 7331040 times.
✓ Branch 5 → 6 taken 533728 times.
put_ciip_12:
✗ Branch 5 → 4 not taken.
✗ Branch 5 → 6 not taken.
put_ciip_8:
✗ Branch 5 → 4 not taken.
✗ Branch 5 → 6 not taken.
7864768 for (int x = 0; x < width; x++)
232 7331040 dst[x] = (dst[x] * intra_weight + inter[x] * inter_weight + 2) >> 2;
233 533728 dst += dst_stride;
234 533728 inter += inter_stride;
235 }
236 43833 }
237
238 78220 static void FUNC(put_gpm)(uint8_t *_dst, ptrdiff_t dst_stride,
239 const int width, const int height,
240 const int16_t *src0, const int16_t *src1,
241 const uint8_t *weights, const int step_x, const int step_y)
242 {
243 78220 const int shift = FFMAX(5, 17 - BIT_DEPTH);
244 78220 const int offset = 1 << (shift - 1);
245 78220 pixel *dst = (pixel *)_dst;
246
247 78220 dst_stride /= sizeof(pixel);
248
2/6
put_gpm_10:
✓ Branch 7 → 3 taken 998800 times.
✓ Branch 7 → 8 taken 78220 times.
put_gpm_12:
✗ Branch 7 → 3 not taken.
✗ Branch 7 → 8 not taken.
put_gpm_8:
✗ Branch 7 → 3 not taken.
✗ Branch 7 → 8 not taken.
1077020 for (int y = 0; y < height; y++) {
249
2/6
put_gpm_10:
✓ Branch 5 → 4 taken 16058944 times.
✓ Branch 5 → 6 taken 998800 times.
put_gpm_12:
✗ Branch 5 → 4 not taken.
✗ Branch 5 → 6 not taken.
put_gpm_8:
✗ Branch 5 → 4 not taken.
✗ Branch 5 → 6 not taken.
17057744 for (int x = 0; x < width; x++) {
250 16058944 const uint8_t w = weights[x * step_x];
251 16058944 dst[x] = av_clip_pixel((src0[x] * w + src1[x] * (8 - w) + offset) >> shift);
252 }
253 998800 dst += dst_stride;
254 998800 src0 += MAX_PB_SIZE;
255 998800 src1 += MAX_PB_SIZE;
256 998800 weights += step_y;
257 }
258 78220 }
259
260 //8.5.6.3.3 Luma integer sample fetching process, add one extra pad line
261 4276436 static void FUNC(bdof_fetch_samples)(int16_t *_dst, const uint8_t *_src, const ptrdiff_t _src_stride,
262 const int x_frac, const int y_frac, const int width, const int height)
263 {
264 4276436 const int x_off = (x_frac >> 3) - 1;
265 4276436 const int y_off = (y_frac >> 3) - 1;
266 4276436 const ptrdiff_t src_stride = _src_stride / sizeof(pixel);
267 4276436 const pixel *src = (pixel*)_src + (x_off) + y_off * src_stride;
268 4276436 int16_t *dst = _dst - 1 - MAX_PB_SIZE;
269 4276436 const int shift = 14 - BIT_DEPTH;
270 4276436 const int bdof_width = width + 2 * BDOF_BORDER_EXT;
271
272 // top
273
2/6
bdof_fetch_samples_10:
✓ Branch 4 → 3 taken 33924872 times.
✓ Branch 4 → 5 taken 4276436 times.
bdof_fetch_samples_12:
✗ Branch 4 → 3 not taken.
✗ Branch 4 → 5 not taken.
bdof_fetch_samples_8:
✗ Branch 4 → 3 not taken.
✗ Branch 4 → 5 not taken.
38201308 for (int i = 0; i < bdof_width; i++)
274 33924872 dst[i] = src[i] << shift;
275
276 4276436 dst += MAX_PB_SIZE;
277 4276436 src += src_stride;
278
279
2/6
bdof_fetch_samples_10:
✓ Branch 7 → 6 taken 25445120 times.
✓ Branch 7 → 8 taken 4276436 times.
bdof_fetch_samples_12:
✗ Branch 7 → 6 not taken.
✗ Branch 7 → 8 not taken.
bdof_fetch_samples_8:
✗ Branch 7 → 6 not taken.
✗ Branch 7 → 8 not taken.
29721556 for (int i = 0; i < height; i++) {
280 25445120 dst[0] = src[0] << shift;
281 25445120 dst[1 + width] = src[1 + width] << shift;
282 25445120 dst += MAX_PB_SIZE;
283 25445120 src += src_stride;
284 }
285
2/6
bdof_fetch_samples_10:
✓ Branch 10 → 9 taken 33924872 times.
✓ Branch 10 → 11 taken 4276436 times.
bdof_fetch_samples_12:
✗ Branch 10 → 9 not taken.
✗ Branch 10 → 11 not taken.
bdof_fetch_samples_8:
✗ Branch 10 → 9 not taken.
✗ Branch 10 → 11 not taken.
38201308 for (int i = 0; i < bdof_width; i++)
286 33924872 dst[i] = src[i] << shift;
287 4276436 }
288
289 //8.5.6.3.3 Luma integer sample fetching process
290 3561336 static void FUNC(fetch_samples)(int16_t *_dst, const uint8_t *_src, const ptrdiff_t _src_stride, const int x_frac, const int y_frac)
291 {
292 3561336 FUNC(bdof_fetch_samples)(_dst, _src, _src_stride, x_frac, y_frac, AFFINE_MIN_BLOCK_SIZE, AFFINE_MIN_BLOCK_SIZE);
293 3561336 }
294
295 4276508 static void FUNC(prof_grad_filter)(int16_t *gradient_h, int16_t *gradient_v, const ptrdiff_t gradient_stride,
296 const int16_t *_src, const ptrdiff_t src_stride, const int width, const int height)
297 {
298 4276508 const int shift = 6;
299 4276508 const int16_t *src = _src;
300
301
6/6
prof_grad_filter_10:
✓ Branch 7 → 3 taken 25445440 times.
✓ Branch 7 → 8 taken 4276460 times.
prof_grad_filter_12:
✓ Branch 7 → 3 taken 320 times.
✓ Branch 7 → 8 taken 24 times.
prof_grad_filter_8:
✓ Branch 7 → 3 taken 320 times.
✓ Branch 7 → 8 taken 24 times.
29722588 for (int y = 0; y < height; y++) {
302 25446080 const int16_t *p = src;
303
6/6
prof_grad_filter_10:
✓ Branch 5 → 4 taken 231142784 times.
✓ Branch 5 → 6 taken 25445440 times.
prof_grad_filter_12:
✓ Branch 5 → 4 taken 4096 times.
✓ Branch 5 → 6 taken 320 times.
prof_grad_filter_8:
✓ Branch 5 → 4 taken 4096 times.
✓ Branch 5 → 6 taken 320 times.
256597056 for (int x = 0; x < width; x++) {
304 231150976 gradient_h[x] = (p[1] >> shift) - (p[-1] >> shift);
305 231150976 gradient_v[x] = (p[src_stride] >> shift) - (p[-src_stride] >> shift);
306 231150976 p++;
307 }
308 25446080 gradient_h += gradient_stride;
309 25446080 gradient_v += gradient_stride;
310 25446080 src += src_stride;
311 }
312 4276508 }
313
314 1410496 static void FUNC(apply_prof)(int16_t *dst, const int16_t *src, const int16_t *diff_mv_x, const int16_t *diff_mv_y)
315 {
316 1410496 const int limit = (1 << FFMAX(13, BIT_DEPTH + 1)); ///< dILimit
317
318 int16_t gradient_h[AFFINE_MIN_BLOCK_SIZE * AFFINE_MIN_BLOCK_SIZE];
319 int16_t gradient_v[AFFINE_MIN_BLOCK_SIZE * AFFINE_MIN_BLOCK_SIZE];
320 1410496 FUNC(prof_grad_filter)(gradient_h, gradient_v, AFFINE_MIN_BLOCK_SIZE, src, MAX_PB_SIZE, AFFINE_MIN_BLOCK_SIZE, AFFINE_MIN_BLOCK_SIZE);
321
322
2/6
apply_prof_10:
✓ Branch 8 → 4 taken 5641984 times.
✓ Branch 8 → 9 taken 1410496 times.
apply_prof_12:
✗ Branch 8 → 4 not taken.
✗ Branch 8 → 9 not taken.
apply_prof_8:
✗ Branch 8 → 4 not taken.
✗ Branch 8 → 9 not taken.
7052480 for (int y = 0; y < AFFINE_MIN_BLOCK_SIZE; y++) {
323
2/6
apply_prof_10:
✓ Branch 6 → 5 taken 22567936 times.
✓ Branch 6 → 7 taken 5641984 times.
apply_prof_12:
✗ Branch 6 → 5 not taken.
✗ Branch 6 → 7 not taken.
apply_prof_8:
✗ Branch 6 → 5 not taken.
✗ Branch 6 → 7 not taken.
28209920 for (int x = 0; x < AFFINE_MIN_BLOCK_SIZE; x++) {
324 22567936 const int o = y * AFFINE_MIN_BLOCK_SIZE + x;
325 22567936 const int di = gradient_h[o] * diff_mv_x[o] + gradient_v[o] * diff_mv_y[o];
326 22567936 const int val = src[x] + av_clip(di, -limit, limit - 1);
327 22567936 dst[x] = val;
328
329 }
330 5641984 src += MAX_PB_SIZE;
331 5641984 dst += MAX_PB_SIZE;
332 }
333 1410496 }
334
335 2136508 static void FUNC(apply_prof_uni)(uint8_t *_dst, const ptrdiff_t _dst_stride, const int16_t *src, const int16_t *diff_mv_x, const int16_t *diff_mv_y)
336 {
337 2136508 const int limit = (1 << FFMAX(13, BIT_DEPTH + 1)); ///< dILimit
338 2136508 pixel *dst = (pixel*)_dst;
339 2136508 const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel);
340 2136508 const int shift = 14 - BIT_DEPTH;
341 #if BIT_DEPTH < 14
342 2136508 const int offset = 1 << (shift - 1);
343 #else
344 const int offset = 0;
345 #endif
346 int16_t gradient_h[AFFINE_MIN_BLOCK_SIZE * AFFINE_MIN_BLOCK_SIZE];
347 int16_t gradient_v[AFFINE_MIN_BLOCK_SIZE * AFFINE_MIN_BLOCK_SIZE];
348
349 2136508 FUNC(prof_grad_filter)(gradient_h, gradient_v, AFFINE_MIN_BLOCK_SIZE, src, MAX_PB_SIZE, AFFINE_MIN_BLOCK_SIZE, AFFINE_MIN_BLOCK_SIZE);
350
351
2/6
apply_prof_uni_10:
✓ Branch 8 → 4 taken 8546032 times.
✓ Branch 8 → 9 taken 2136508 times.
apply_prof_uni_12:
✗ Branch 8 → 4 not taken.
✗ Branch 8 → 9 not taken.
apply_prof_uni_8:
✗ Branch 8 → 4 not taken.
✗ Branch 8 → 9 not taken.
10682540 for (int y = 0; y < AFFINE_MIN_BLOCK_SIZE; y++) {
352
2/6
apply_prof_uni_10:
✓ Branch 6 → 5 taken 34184128 times.
✓ Branch 6 → 7 taken 8546032 times.
apply_prof_uni_12:
✗ Branch 6 → 5 not taken.
✗ Branch 6 → 7 not taken.
apply_prof_uni_8:
✗ Branch 6 → 5 not taken.
✗ Branch 6 → 7 not taken.
42730160 for (int x = 0; x < AFFINE_MIN_BLOCK_SIZE; x++) {
353 34184128 const int o = y * AFFINE_MIN_BLOCK_SIZE + x;
354 34184128 const int di = gradient_h[o] * diff_mv_x[o] + gradient_v[o] * diff_mv_y[o];
355 34184128 const int val = src[x] + av_clip(di, -limit, limit - 1);
356 34184128 dst[x] = av_clip_pixel((val + offset) >> shift);
357
358 }
359 8546032 src += MAX_PB_SIZE;
360 8546032 dst += dst_stride;
361 }
362 2136508 }
363
364 14332 static void FUNC(apply_prof_uni_w)(uint8_t *_dst, const ptrdiff_t _dst_stride,
365 const int16_t *src, const int16_t *diff_mv_x, const int16_t *diff_mv_y,
366 const int denom, const int wx, const int _ox)
367 {
368 14332 const int limit = (1 << FFMAX(13, BIT_DEPTH + 1)); ///< dILimit
369 14332 pixel *dst = (pixel*)_dst;
370 14332 const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel);
371 14332 const int shift = denom + FFMAX(2, 14 - BIT_DEPTH);
372 14332 const int offset = 1 << (shift - 1);
373 14332 const int ox = _ox * (1 << (BIT_DEPTH - 8));
374 int16_t gradient_h[AFFINE_MIN_BLOCK_SIZE * AFFINE_MIN_BLOCK_SIZE];
375 int16_t gradient_v[AFFINE_MIN_BLOCK_SIZE * AFFINE_MIN_BLOCK_SIZE];
376
377 14332 FUNC(prof_grad_filter)(gradient_h, gradient_v, AFFINE_MIN_BLOCK_SIZE, src, MAX_PB_SIZE, AFFINE_MIN_BLOCK_SIZE, AFFINE_MIN_BLOCK_SIZE);
378
379
2/6
apply_prof_uni_w_10:
✓ Branch 8 → 4 taken 57328 times.
✓ Branch 8 → 9 taken 14332 times.
apply_prof_uni_w_12:
✗ Branch 8 → 4 not taken.
✗ Branch 8 → 9 not taken.
apply_prof_uni_w_8:
✗ Branch 8 → 4 not taken.
✗ Branch 8 → 9 not taken.
71660 for (int y = 0; y < AFFINE_MIN_BLOCK_SIZE; y++) {
380
2/6
apply_prof_uni_w_10:
✓ Branch 6 → 5 taken 229312 times.
✓ Branch 6 → 7 taken 57328 times.
apply_prof_uni_w_12:
✗ Branch 6 → 5 not taken.
✗ Branch 6 → 7 not taken.
apply_prof_uni_w_8:
✗ Branch 6 → 5 not taken.
✗ Branch 6 → 7 not taken.
286640 for (int x = 0; x < AFFINE_MIN_BLOCK_SIZE; x++) {
381 229312 const int o = y * AFFINE_MIN_BLOCK_SIZE + x;
382 229312 const int di = gradient_h[o] * diff_mv_x[o] + gradient_v[o] * diff_mv_y[o];
383 229312 const int val = src[x] + av_clip(di, -limit, limit - 1);
384 229312 dst[x] = av_clip_pixel(((val * wx + offset) >> shift) + ox);
385 }
386 57328 src += MAX_PB_SIZE;
387 57328 dst += dst_stride;
388 }
389 14332 }
390
391 5442800 static void FUNC(derive_bdof_vx_vy)(const int16_t *_src0, const int16_t *_src1,
392 const int pad_left, const int pad_top, const int pad_right, const int pad_bottom,
393 const int16_t **gradient_h, const int16_t **gradient_v,
394 int* vx, int* vy)
395 {
396 5442800 const int shift2 = 4;
397 5442800 const int shift3 = 1;
398 5442800 const int thres = 1 << 4;
399 5442800 int sgx2 = 0, sgy2 = 0, sgxgy = 0, sgxdi = 0, sgydi = 0;
400
401
6/6
derive_bdof_vx_vy_10:
✓ Branch 32 → 3 taken 32655264 times.
✓ Branch 32 → 33 taken 5442544 times.
derive_bdof_vx_vy_12:
✓ Branch 32 → 3 taken 768 times.
✓ Branch 32 → 33 taken 128 times.
derive_bdof_vx_vy_8:
✓ Branch 32 → 3 taken 768 times.
✓ Branch 32 → 33 taken 128 times.
38099600 for (int y = -1; y < BDOF_MIN_BLOCK_SIZE + 1; y++) {
402
24/24
derive_bdof_vx_vy_10:
✓ Branch 3 → 4 taken 8345232 times.
✓ Branch 3 → 6 taken 24310032 times.
✓ Branch 4 → 5 taken 1390872 times.
✓ Branch 4 → 6 taken 6954360 times.
✓ Branch 7 → 8 taken 8345232 times.
✓ Branch 7 → 10 taken 24310032 times.
✓ Branch 8 → 9 taken 1390872 times.
✓ Branch 8 → 10 taken 6954360 times.
derive_bdof_vx_vy_12:
✓ Branch 3 → 4 taken 240 times.
✓ Branch 3 → 6 taken 528 times.
✓ Branch 4 → 5 taken 40 times.
✓ Branch 4 → 6 taken 200 times.
✓ Branch 7 → 8 taken 240 times.
✓ Branch 7 → 10 taken 528 times.
✓ Branch 8 → 9 taken 40 times.
✓ Branch 8 → 10 taken 200 times.
derive_bdof_vx_vy_8:
✓ Branch 3 → 4 taken 240 times.
✓ Branch 3 → 6 taken 528 times.
✓ Branch 4 → 5 taken 40 times.
✓ Branch 4 → 6 taken 200 times.
✓ Branch 7 → 8 taken 240 times.
✓ Branch 7 → 10 taken 528 times.
✓ Branch 8 → 9 taken 40 times.
✓ Branch 8 → 10 taken 200 times.
32656800 const int dy = y + (pad_top && y < 0) - (pad_bottom && y == BDOF_MIN_BLOCK_SIZE); // we pad for the first and last row
403 32656800 const int16_t *src0 = _src0 + dy * MAX_PB_SIZE;
404 32656800 const int16_t *src1 = _src1 + dy * MAX_PB_SIZE;
405
406
6/6
derive_bdof_vx_vy_10:
✓ Branch 30 → 12 taken 195931584 times.
✓ Branch 30 → 31 taken 32655264 times.
derive_bdof_vx_vy_12:
✓ Branch 30 → 12 taken 4608 times.
✓ Branch 30 → 31 taken 768 times.
derive_bdof_vx_vy_8:
✓ Branch 30 → 12 taken 4608 times.
✓ Branch 30 → 31 taken 768 times.
228597600 for (int x = -1; x < BDOF_MIN_BLOCK_SIZE + 1; x++) {
407
24/24
derive_bdof_vx_vy_10:
✓ Branch 12 → 13 taken 50400432 times.
✓ Branch 12 → 15 taken 145531152 times.
✓ Branch 13 → 14 taken 8400072 times.
✓ Branch 13 → 15 taken 42000360 times.
✓ Branch 16 → 17 taken 50400432 times.
✓ Branch 16 → 19 taken 145531152 times.
✓ Branch 17 → 18 taken 8400072 times.
✓ Branch 17 → 19 taken 42000360 times.
derive_bdof_vx_vy_12:
✓ Branch 12 → 13 taken 1440 times.
✓ Branch 12 → 15 taken 3168 times.
✓ Branch 13 → 14 taken 240 times.
✓ Branch 13 → 15 taken 1200 times.
✓ Branch 16 → 17 taken 1440 times.
✓ Branch 16 → 19 taken 3168 times.
✓ Branch 17 → 18 taken 240 times.
✓ Branch 17 → 19 taken 1200 times.
derive_bdof_vx_vy_8:
✓ Branch 12 → 13 taken 1440 times.
✓ Branch 12 → 15 taken 3168 times.
✓ Branch 13 → 14 taken 240 times.
✓ Branch 13 → 15 taken 1200 times.
✓ Branch 16 → 17 taken 1440 times.
✓ Branch 16 → 19 taken 3168 times.
✓ Branch 17 → 18 taken 240 times.
✓ Branch 17 → 19 taken 1200 times.
195940800 const int dx = x + (pad_left && x < 0) - (pad_right && x == BDOF_MIN_BLOCK_SIZE); // we pad for the first and last col
408 195940800 const int diff = (src0[dx] >> shift2) - (src1[dx] >> shift2);
409 195940800 const int idx = BDOF_BLOCK_SIZE * dy + dx;
410 195940800 const int temph = (gradient_h[0][idx] + gradient_h[1][idx]) >> shift3;
411 195940800 const int tempv = (gradient_v[0][idx] + gradient_v[1][idx]) >> shift3;
412
413 195940800 sgx2 += FFABS(temph);
414 195940800 sgy2 += FFABS(tempv);
415
6/6
derive_bdof_vx_vy_10:
✓ Branch 20 → 21 taken 106285777 times.
✓ Branch 20 → 22 taken 89645807 times.
derive_bdof_vx_vy_12:
✓ Branch 20 → 21 taken 2588 times.
✓ Branch 20 → 22 taken 2020 times.
derive_bdof_vx_vy_8:
✓ Branch 20 → 21 taken 2588 times.
✓ Branch 20 → 22 taken 2020 times.
195940800 sgxgy += VVC_SIGN(tempv) * temph;
416
6/6
derive_bdof_vx_vy_10:
✓ Branch 23 → 24 taken 112114330 times.
✓ Branch 23 → 25 taken 83817254 times.
derive_bdof_vx_vy_12:
✓ Branch 23 → 24 taken 2060 times.
✓ Branch 23 → 25 taken 2548 times.
derive_bdof_vx_vy_8:
✓ Branch 23 → 24 taken 2060 times.
✓ Branch 23 → 25 taken 2548 times.
195940800 sgxdi += -VVC_SIGN(temph) * diff;
417
6/6
derive_bdof_vx_vy_10:
✓ Branch 26 → 27 taken 106285777 times.
✓ Branch 26 → 28 taken 89645807 times.
derive_bdof_vx_vy_12:
✓ Branch 26 → 27 taken 2588 times.
✓ Branch 26 → 28 taken 2020 times.
derive_bdof_vx_vy_8:
✓ Branch 26 → 27 taken 2588 times.
✓ Branch 26 → 28 taken 2020 times.
195940800 sgydi += -VVC_SIGN(tempv) * diff;
418 }
419 }
420
4/6
derive_bdof_vx_vy_10:
✓ Branch 33 → 34 taken 5322771 times.
✓ Branch 33 → 35 taken 119773 times.
derive_bdof_vx_vy_12:
✓ Branch 33 → 34 taken 128 times.
✗ Branch 33 → 35 not taken.
derive_bdof_vx_vy_8:
✓ Branch 33 → 34 taken 128 times.
✗ Branch 33 → 35 not taken.
5442800 *vx = sgx2 > 0 ? av_clip((sgxdi * (1 << 2)) >> av_log2(sgx2) , -thres + 1, thres - 1) : 0;
421
4/6
derive_bdof_vx_vy_10:
✓ Branch 36 → 37 taken 5327966 times.
✓ Branch 36 → 38 taken 114578 times.
derive_bdof_vx_vy_12:
✓ Branch 36 → 37 taken 128 times.
✗ Branch 36 → 38 not taken.
derive_bdof_vx_vy_8:
✓ Branch 36 → 37 taken 128 times.
✗ Branch 36 → 38 not taken.
5442800 *vy = sgy2 > 0 ? av_clip(((sgydi * (1 << 2)) - ((*vx * sgxgy) >> 1)) >> av_log2(sgy2), -thres + 1, thres - 1) : 0;
422 5442800 }
423
424 5442800 static void FUNC(apply_bdof_min_block)(pixel* dst, const ptrdiff_t dst_stride, const int16_t *src0, const int16_t *src1,
425 const int16_t **gh, const int16_t **gv, const int vx, const int vy)
426 {
427 5442800 const int shift4 = 15 - BIT_DEPTH;
428 5442800 const int offset4 = 1 << (shift4 - 1);
429
430
6/6
apply_bdof_min_block_10:
✓ Branch 7 → 3 taken 21770176 times.
✓ Branch 7 → 8 taken 5442544 times.
apply_bdof_min_block_12:
✓ Branch 7 → 3 taken 512 times.
✓ Branch 7 → 8 taken 128 times.
apply_bdof_min_block_8:
✓ Branch 7 → 3 taken 512 times.
✓ Branch 7 → 8 taken 128 times.
27214000 for (int y = 0; y < BDOF_MIN_BLOCK_SIZE; y++) {
431
6/6
apply_bdof_min_block_10:
✓ Branch 5 → 4 taken 87080704 times.
✓ Branch 5 → 6 taken 21770176 times.
apply_bdof_min_block_12:
✓ Branch 5 → 4 taken 2048 times.
✓ Branch 5 → 6 taken 512 times.
apply_bdof_min_block_8:
✓ Branch 5 → 4 taken 2048 times.
✓ Branch 5 → 6 taken 512 times.
108856000 for (int x = 0; x < BDOF_MIN_BLOCK_SIZE; x++) {
432 87084800 const int idx = y * BDOF_BLOCK_SIZE + x;
433 87084800 const int bdof_offset = vx * (gh[0][idx] - gh[1][idx]) + vy * (gv[0][idx] - gv[1][idx]);
434 87084800 dst[x] = av_clip_pixel((src0[x] + offset4 + src1[x] + bdof_offset) >> shift4);
435 }
436 21771200 dst += dst_stride;
437 21771200 src0 += MAX_PB_SIZE;
438 21771200 src1 += MAX_PB_SIZE;
439 }
440 5442800 }
441
442 357586 static void FUNC(apply_bdof)(uint8_t *_dst, const ptrdiff_t _dst_stride, const int16_t *_src0, const int16_t *_src1,
443 const int block_w, const int block_h)
444 {
445 int16_t gradient_h[2][BDOF_BLOCK_SIZE * BDOF_BLOCK_SIZE];
446 int16_t gradient_v[2][BDOF_BLOCK_SIZE * BDOF_BLOCK_SIZE];
447 int vx, vy;
448 357586 const ptrdiff_t dst_stride = _dst_stride / sizeof(pixel);
449 357586 pixel* dst = (pixel*)_dst;
450
451 357586 FUNC(prof_grad_filter)(gradient_h[0], gradient_v[0], BDOF_BLOCK_SIZE,
452 _src0, MAX_PB_SIZE, block_w, block_h);
453 357586 FUNC(prof_grad_filter)(gradient_h[1], gradient_v[1], BDOF_BLOCK_SIZE,
454 _src1, MAX_PB_SIZE, block_w, block_h);
455
456
6/6
apply_bdof_10:
✓ Branch 11 → 5 taken 1400012 times.
✓ Branch 11 → 12 taken 357562 times.
apply_bdof_12:
✓ Branch 11 → 5 taken 40 times.
✓ Branch 11 → 12 taken 12 times.
apply_bdof_8:
✓ Branch 11 → 5 taken 40 times.
✓ Branch 11 → 12 taken 12 times.
1757678 for (int y = 0; y < block_h; y += BDOF_MIN_BLOCK_SIZE) {
457
6/6
apply_bdof_10:
✓ Branch 9 → 6 taken 5442544 times.
✓ Branch 9 → 10 taken 1400012 times.
apply_bdof_12:
✓ Branch 9 → 6 taken 128 times.
✓ Branch 9 → 10 taken 40 times.
apply_bdof_8:
✓ Branch 9 → 6 taken 128 times.
✓ Branch 9 → 10 taken 40 times.
6842892 for (int x = 0; x < block_w; x += BDOF_MIN_BLOCK_SIZE) {
458 5442800 const int16_t* src0 = _src0 + y * MAX_PB_SIZE + x;
459 5442800 const int16_t* src1 = _src1 + y * MAX_PB_SIZE + x;
460 5442800 pixel *d = dst + x;
461 5442800 const int idx = BDOF_BLOCK_SIZE * y + x;
462 5442800 const int16_t* gh[] = { gradient_h[0] + idx, gradient_h[1] + idx };
463 5442800 const int16_t* gv[] = { gradient_v[0] + idx, gradient_v[1] + idx };
464 5442800 FUNC(derive_bdof_vx_vy)(src0, src1, !x, !y, x + BDOF_MIN_BLOCK_SIZE == block_w, y + BDOF_MIN_BLOCK_SIZE == block_h, gh, gv, &vx, &vy);
465 5442800 FUNC(apply_bdof_min_block)(d, dst_stride, src0, src1, gh, gv, vx, vy);
466 }
467 1400092 dst += BDOF_MIN_BLOCK_SIZE * dst_stride;
468 }
469 357586 }
470
471 #define DMVR_FILTER(src, stride) \
472 (filter[0] * src[x] + \
473 filter[1] * src[x + stride])
474
475 #define DMVR_FILTER2(filter, src0, src1) \
476 (filter[0] * src0 + filter[1] * src1)
477
478 //8.5.3.2.2 Luma sample bilinear interpolation process
479 1292958 static void FUNC(dmvr)(int16_t *dst, const uint8_t *_src, const ptrdiff_t _src_stride,
480 const int height, const intptr_t mx, const intptr_t my, const int width)
481 {
482 #if BIT_DEPTH != 10
483 24 const pixel *src = (const pixel *)_src;
484 24 const ptrdiff_t src_stride = _src_stride / sizeof(pixel);
485 #if BIT_DEPTH > 10
486 12 const int shift4 = BIT_DEPTH - 10;
487 12 const int offset4 = 1 << (shift4 - 1);
488 #define DMVR_SHIFT(s) (((s) + offset4) >> shift4)
489 #else
490 #define DMVR_SHIFT(s) ((s) << (10 - BIT_DEPTH))
491 #endif // BIT_DEPTH > 10
492
493
4/4
dmvr_12:
✓ Branch 7 → 3 taken 208 times.
✓ Branch 7 → 8 taken 12 times.
dmvr_8:
✓ Branch 7 → 3 taken 208 times.
✓ Branch 7 → 8 taken 12 times.
440 for (int y = 0; y < height; y++) {
494
4/4
dmvr_12:
✓ Branch 5 → 4 taken 3520 times.
✓ Branch 5 → 6 taken 208 times.
dmvr_8:
✓ Branch 5 → 4 taken 3520 times.
✓ Branch 5 → 6 taken 208 times.
7456 for (int x = 0; x < width; x++)
495 7040 dst[x] = DMVR_SHIFT(src[x]);
496 416 src += src_stride;
497 416 dst += MAX_PB_SIZE;
498 }
499 #undef DMVR_SHIFT
500 #else
501 1292934 av_image_copy_plane((uint8_t*)dst, sizeof(int16_t) * MAX_PB_SIZE, _src, _src_stride,
502 width * sizeof(pixel), height);
503 #endif // BIT_DEPTH != 10
504 1292958 }
505
506 //8.5.3.2.2 Luma sample bilinear interpolation process
507 154199 static void FUNC(dmvr_h)(int16_t *dst, const uint8_t *_src, const ptrdiff_t _src_stride,
508 const int height, const intptr_t mx, const intptr_t my, const int width)
509 {
510 154199 const pixel *src = (const pixel*)_src;
511 154199 const ptrdiff_t src_stride = _src_stride / sizeof(pixel);
512 154199 const int8_t *filter = ff_vvc_inter_luma_dmvr_filters[mx];
513 154199 const int shift1 = BIT_DEPTH - 6;
514 154199 const int offset1 = 1 << (shift1 - 1);
515
516
6/6
dmvr_h_10:
✓ Branch 7 → 3 taken 3050316 times.
✓ Branch 7 → 8 taken 154175 times.
dmvr_h_12:
✓ Branch 7 → 3 taken 208 times.
✓ Branch 7 → 8 taken 12 times.
dmvr_h_8:
✓ Branch 7 → 3 taken 208 times.
✓ Branch 7 → 8 taken 12 times.
3204931 for (int y = 0; y < height; y++) {
517
6/6
dmvr_h_10:
✓ Branch 5 → 4 taken 60306320 times.
✓ Branch 5 → 6 taken 3050316 times.
dmvr_h_12:
✓ Branch 5 → 4 taken 3520 times.
✓ Branch 5 → 6 taken 208 times.
dmvr_h_8:
✓ Branch 5 → 4 taken 3520 times.
✓ Branch 5 → 6 taken 208 times.
63364092 for (int x = 0; x < width; x++)
518 60313360 dst[x] = (DMVR_FILTER(src, 1) + offset1) >> shift1;
519 3050732 src += src_stride;
520 3050732 dst += MAX_PB_SIZE;
521 }
522 154199 }
523
524 //8.5.3.2.2 Luma sample bilinear interpolation process
525 208389 static void FUNC(dmvr_v)(int16_t *dst, const uint8_t *_src, const ptrdiff_t _src_stride,
526 const int height, const intptr_t mx, const intptr_t my, const int width)
527 {
528 208389 const pixel *src = (pixel*)_src;
529 208389 const ptrdiff_t src_stride = _src_stride / sizeof(pixel);
530 208389 const int8_t *filter = ff_vvc_inter_luma_dmvr_filters[my];
531 208389 const int shift1 = BIT_DEPTH - 6;
532 208389 const int offset1 = 1 << (shift1 - 1);
533
534
6/6
dmvr_v_10:
✓ Branch 7 → 3 taken 4126524 times.
✓ Branch 7 → 8 taken 208365 times.
dmvr_v_12:
✓ Branch 7 → 3 taken 208 times.
✓ Branch 7 → 8 taken 12 times.
dmvr_v_8:
✓ Branch 7 → 3 taken 208 times.
✓ Branch 7 → 8 taken 12 times.
4335329 for (int y = 0; y < height; y++) {
535
6/6
dmvr_v_10:
✓ Branch 5 → 4 taken 81885840 times.
✓ Branch 5 → 6 taken 4126524 times.
dmvr_v_12:
✓ Branch 5 → 4 taken 3520 times.
✓ Branch 5 → 6 taken 208 times.
dmvr_v_8:
✓ Branch 5 → 4 taken 3520 times.
✓ Branch 5 → 6 taken 208 times.
86019820 for (int x = 0; x < width; x++)
536 81892880 dst[x] = (DMVR_FILTER(src, src_stride) + offset1) >> shift1;
537 4126940 src += src_stride;
538 4126940 dst += MAX_PB_SIZE;
539 }
540
541 208389 }
542
543 //8.5.3.2.2 Luma sample bilinear interpolation process
544 577186 static void FUNC(dmvr_hv)(int16_t *dst, const uint8_t *_src, const ptrdiff_t _src_stride,
545 const int height, const intptr_t mx, const intptr_t my, const int width)
546 {
547 int16_t tmp_array[MAX_PB_SIZE * 2];
548 577186 int16_t *tmp0 = tmp_array;
549 577186 int16_t *tmp1 = tmp_array + MAX_PB_SIZE;
550 577186 const pixel *src = (const pixel*)_src;
551 577186 const ptrdiff_t src_stride = _src_stride / sizeof(pixel);
552 577186 const int8_t *filter_x = ff_vvc_inter_luma_dmvr_filters[mx];
553 577186 const int8_t *filter_y = ff_vvc_inter_luma_dmvr_filters[my];
554 577186 const int shift1 = BIT_DEPTH - 6;
555 577186 const int offset1 = 1 << (shift1 - 1);
556 577186 const int shift2 = 4;
557 577186 const int offset2 = 1 << (shift2 - 1);
558
559 577186 src -= BILINEAR_EXTRA_BEFORE * src_stride;
560
6/6
dmvr_hv_10:
✓ Branch 4 → 3 taken 11382816 times.
✓ Branch 4 → 5 taken 577162 times.
dmvr_hv_12:
✓ Branch 4 → 3 taken 208 times.
✓ Branch 4 → 5 taken 12 times.
dmvr_hv_8:
✓ Branch 4 → 3 taken 208 times.
✓ Branch 4 → 5 taken 12 times.
11960418 for (int x = 0; x < width; x++)
561 11383232 tmp0[x] = (DMVR_FILTER2(filter_x, src[x], src[x + 1]) + offset1) >> shift1;
562 577186 src += src_stride;
563
564
6/6
dmvr_hv_10:
✓ Branch 10 → 6 taken 11399720 times.
✓ Branch 10 → 11 taken 577162 times.
dmvr_hv_12:
✓ Branch 10 → 6 taken 208 times.
✓ Branch 10 → 11 taken 12 times.
dmvr_hv_8:
✓ Branch 10 → 6 taken 208 times.
✓ Branch 10 → 11 taken 12 times.
11977322 for (int y = 1; y < height + BILINEAR_EXTRA; y++) {
565
6/6
dmvr_hv_10:
✓ Branch 8 → 7 taken 224785920 times.
✓ Branch 8 → 9 taken 11399720 times.
dmvr_hv_12:
✓ Branch 8 → 7 taken 3520 times.
✓ Branch 8 → 9 taken 208 times.
dmvr_hv_8:
✓ Branch 8 → 7 taken 3520 times.
✓ Branch 8 → 9 taken 208 times.
236193096 for (int x = 0; x < width; x++) {
566 224792960 tmp1[x] = (DMVR_FILTER2(filter_x, src[x], src[x + 1]) + offset1) >> shift1;
567 224792960 dst[x] = (DMVR_FILTER2(filter_y, tmp0[x], tmp1[x]) + offset2) >> shift2;
568 }
569 11400136 src += src_stride;
570 11400136 dst += MAX_PB_SIZE;
571 11400136 FFSWAP(int16_t *, tmp0, tmp1);
572 }
573 577186 }
574
575 #define PEL_FUNC(dst, C, idx1, idx2, a) \
576 do { \
577 for (int w = 0; w < 7; w++) \
578 inter->dst[C][w][idx1][idx2] = FUNC(a); \
579 } while (0) \
580
581 #define DIR_FUNCS(d, C, c) \
582 PEL_FUNC(put_##d, C, 0, 0, put_##d##_pixels); \
583 PEL_FUNC(put_##d, C, 0, 1, put_##d##_##c##_h); \
584 PEL_FUNC(put_##d, C, 1, 0, put_##d##_##c##_v); \
585 PEL_FUNC(put_##d, C, 1, 1, put_##d##_##c##_hv); \
586 PEL_FUNC(put_##d##_w, C, 0, 0, put_##d##_w_pixels); \
587 PEL_FUNC(put_##d##_w, C, 0, 1, put_##d##_##c##_w_h); \
588 PEL_FUNC(put_##d##_w, C, 1, 0, put_##d##_##c##_w_v); \
589 PEL_FUNC(put_##d##_w, C, 1, 1, put_##d##_##c##_w_hv);
590
591 #define FUNCS(C, c) \
592 PEL_FUNC(put, C, 0, 0, put_pixels); \
593 PEL_FUNC(put, C, 0, 1, put_##c##_h); \
594 PEL_FUNC(put, C, 1, 0, put_##c##_v); \
595 PEL_FUNC(put, C, 1, 1, put_##c##_hv); \
596 DIR_FUNCS(uni, C, c); \
597
598 1658 static void FUNC(ff_vvc_inter_dsp_init)(VVCInterDSPContext *const inter)
599 {
600
72/72
ff_vvc_inter_dsp_init_10:
✓ Branch 4 → 3 taken 8533 times.
✓ Branch 4 → 5 taken 1219 times.
✓ Branch 7 → 6 taken 8533 times.
✓ Branch 7 → 8 taken 1219 times.
✓ Branch 10 → 9 taken 8533 times.
✓ Branch 10 → 11 taken 1219 times.
✓ Branch 13 → 12 taken 8533 times.
✓ Branch 13 → 14 taken 1219 times.
✓ Branch 16 → 15 taken 8533 times.
✓ Branch 16 → 17 taken 1219 times.
✓ Branch 19 → 18 taken 8533 times.
✓ Branch 19 → 20 taken 1219 times.
✓ Branch 22 → 21 taken 8533 times.
✓ Branch 22 → 23 taken 1219 times.
✓ Branch 25 → 24 taken 8533 times.
✓ Branch 25 → 26 taken 1219 times.
✓ Branch 28 → 27 taken 8533 times.
✓ Branch 28 → 29 taken 1219 times.
✓ Branch 31 → 30 taken 8533 times.
✓ Branch 31 → 32 taken 1219 times.
✓ Branch 34 → 33 taken 8533 times.
✓ Branch 34 → 35 taken 1219 times.
✓ Branch 37 → 36 taken 8533 times.
✓ Branch 37 → 38 taken 1219 times.
ff_vvc_inter_dsp_init_12:
✓ Branch 4 → 3 taken 1176 times.
✓ Branch 4 → 5 taken 168 times.
✓ Branch 7 → 6 taken 1176 times.
✓ Branch 7 → 8 taken 168 times.
✓ Branch 10 → 9 taken 1176 times.
✓ Branch 10 → 11 taken 168 times.
✓ Branch 13 → 12 taken 1176 times.
✓ Branch 13 → 14 taken 168 times.
✓ Branch 16 → 15 taken 1176 times.
✓ Branch 16 → 17 taken 168 times.
✓ Branch 19 → 18 taken 1176 times.
✓ Branch 19 → 20 taken 168 times.
✓ Branch 22 → 21 taken 1176 times.
✓ Branch 22 → 23 taken 168 times.
✓ Branch 25 → 24 taken 1176 times.
✓ Branch 25 → 26 taken 168 times.
✓ Branch 28 → 27 taken 1176 times.
✓ Branch 28 → 29 taken 168 times.
✓ Branch 31 → 30 taken 1176 times.
✓ Branch 31 → 32 taken 168 times.
✓ Branch 34 → 33 taken 1176 times.
✓ Branch 34 → 35 taken 168 times.
✓ Branch 37 → 36 taken 1176 times.
✓ Branch 37 → 38 taken 168 times.
ff_vvc_inter_dsp_init_8:
✓ Branch 4 → 3 taken 1897 times.
✓ Branch 4 → 5 taken 271 times.
✓ Branch 7 → 6 taken 1897 times.
✓ Branch 7 → 8 taken 271 times.
✓ Branch 10 → 9 taken 1897 times.
✓ Branch 10 → 11 taken 271 times.
✓ Branch 13 → 12 taken 1897 times.
✓ Branch 13 → 14 taken 271 times.
✓ Branch 16 → 15 taken 1897 times.
✓ Branch 16 → 17 taken 271 times.
✓ Branch 19 → 18 taken 1897 times.
✓ Branch 19 → 20 taken 271 times.
✓ Branch 22 → 21 taken 1897 times.
✓ Branch 22 → 23 taken 271 times.
✓ Branch 25 → 24 taken 1897 times.
✓ Branch 25 → 26 taken 271 times.
✓ Branch 28 → 27 taken 1897 times.
✓ Branch 28 → 29 taken 271 times.
✓ Branch 31 → 30 taken 1897 times.
✓ Branch 31 → 32 taken 271 times.
✓ Branch 34 → 33 taken 1897 times.
✓ Branch 34 → 35 taken 271 times.
✓ Branch 37 → 36 taken 1897 times.
✓ Branch 37 → 38 taken 271 times.
140930 FUNCS(LUMA, luma);
601
72/72
ff_vvc_inter_dsp_init_10:
✓ Branch 40 → 39 taken 8533 times.
✓ Branch 40 → 41 taken 1219 times.
✓ Branch 43 → 42 taken 8533 times.
✓ Branch 43 → 44 taken 1219 times.
✓ Branch 46 → 45 taken 8533 times.
✓ Branch 46 → 47 taken 1219 times.
✓ Branch 49 → 48 taken 8533 times.
✓ Branch 49 → 50 taken 1219 times.
✓ Branch 52 → 51 taken 8533 times.
✓ Branch 52 → 53 taken 1219 times.
✓ Branch 55 → 54 taken 8533 times.
✓ Branch 55 → 56 taken 1219 times.
✓ Branch 58 → 57 taken 8533 times.
✓ Branch 58 → 59 taken 1219 times.
✓ Branch 61 → 60 taken 8533 times.
✓ Branch 61 → 62 taken 1219 times.
✓ Branch 64 → 63 taken 8533 times.
✓ Branch 64 → 65 taken 1219 times.
✓ Branch 67 → 66 taken 8533 times.
✓ Branch 67 → 68 taken 1219 times.
✓ Branch 70 → 69 taken 8533 times.
✓ Branch 70 → 71 taken 1219 times.
✓ Branch 73 → 72 taken 8533 times.
✓ Branch 73 → 74 taken 1219 times.
ff_vvc_inter_dsp_init_12:
✓ Branch 40 → 39 taken 1176 times.
✓ Branch 40 → 41 taken 168 times.
✓ Branch 43 → 42 taken 1176 times.
✓ Branch 43 → 44 taken 168 times.
✓ Branch 46 → 45 taken 1176 times.
✓ Branch 46 → 47 taken 168 times.
✓ Branch 49 → 48 taken 1176 times.
✓ Branch 49 → 50 taken 168 times.
✓ Branch 52 → 51 taken 1176 times.
✓ Branch 52 → 53 taken 168 times.
✓ Branch 55 → 54 taken 1176 times.
✓ Branch 55 → 56 taken 168 times.
✓ Branch 58 → 57 taken 1176 times.
✓ Branch 58 → 59 taken 168 times.
✓ Branch 61 → 60 taken 1176 times.
✓ Branch 61 → 62 taken 168 times.
✓ Branch 64 → 63 taken 1176 times.
✓ Branch 64 → 65 taken 168 times.
✓ Branch 67 → 66 taken 1176 times.
✓ Branch 67 → 68 taken 168 times.
✓ Branch 70 → 69 taken 1176 times.
✓ Branch 70 → 71 taken 168 times.
✓ Branch 73 → 72 taken 1176 times.
✓ Branch 73 → 74 taken 168 times.
ff_vvc_inter_dsp_init_8:
✓ Branch 40 → 39 taken 1897 times.
✓ Branch 40 → 41 taken 271 times.
✓ Branch 43 → 42 taken 1897 times.
✓ Branch 43 → 44 taken 271 times.
✓ Branch 46 → 45 taken 1897 times.
✓ Branch 46 → 47 taken 271 times.
✓ Branch 49 → 48 taken 1897 times.
✓ Branch 49 → 50 taken 271 times.
✓ Branch 52 → 51 taken 1897 times.
✓ Branch 52 → 53 taken 271 times.
✓ Branch 55 → 54 taken 1897 times.
✓ Branch 55 → 56 taken 271 times.
✓ Branch 58 → 57 taken 1897 times.
✓ Branch 58 → 59 taken 271 times.
✓ Branch 61 → 60 taken 1897 times.
✓ Branch 61 → 62 taken 271 times.
✓ Branch 64 → 63 taken 1897 times.
✓ Branch 64 → 65 taken 271 times.
✓ Branch 67 → 66 taken 1897 times.
✓ Branch 67 → 68 taken 271 times.
✓ Branch 70 → 69 taken 1897 times.
✓ Branch 70 → 71 taken 271 times.
✓ Branch 73 → 72 taken 1897 times.
✓ Branch 73 → 74 taken 271 times.
140930 FUNCS(CHROMA, chroma);
602
603
6/6
ff_vvc_inter_dsp_init_10:
✓ Branch 76 → 75 taken 8533 times.
✓ Branch 76 → 77 taken 1219 times.
ff_vvc_inter_dsp_init_12:
✓ Branch 76 → 75 taken 1176 times.
✓ Branch 76 → 77 taken 168 times.
ff_vvc_inter_dsp_init_8:
✓ Branch 76 → 75 taken 1897 times.
✓ Branch 76 → 77 taken 271 times.
13264 for (int i = 0; i < FF_ARRAY_ELEMS(inter->put_scaled[LUMA]); i++) {
604 11606 inter->put_scaled[LUMA][i] = FUNC(put_luma_scaled);
605 11606 inter->put_scaled[CHROMA][i] = FUNC(put_chroma_scaled);
606 11606 inter->put_uni_scaled[LUMA][i] = FUNC(put_uni_luma_scaled);
607 11606 inter->put_uni_scaled[CHROMA][i] = FUNC(put_uni_chroma_scaled);
608 11606 inter->put_uni_w_scaled[LUMA][i] = FUNC(put_uni_luma_w_scaled);
609 11606 inter->put_uni_w_scaled[CHROMA][i] = FUNC(put_uni_chroma_w_scaled);
610 }
611
612 1658 inter->avg = FUNC(avg);
613 1658 inter->w_avg = FUNC(w_avg);
614
615 1658 inter->dmvr[0][0] = FUNC(dmvr);
616 1658 inter->dmvr[0][1] = FUNC(dmvr_h);
617 1658 inter->dmvr[1][0] = FUNC(dmvr_v);
618 1658 inter->dmvr[1][1] = FUNC(dmvr_hv);
619
620 1658 inter->put_ciip = FUNC(put_ciip);
621 1658 inter->put_gpm = FUNC(put_gpm);
622
623 1658 inter->fetch_samples = FUNC(fetch_samples);
624 1658 inter->bdof_fetch_samples = FUNC(bdof_fetch_samples);
625 1658 inter->apply_prof = FUNC(apply_prof);
626 1658 inter->apply_prof_uni = FUNC(apply_prof_uni);
627 1658 inter->apply_prof_uni_w = FUNC(apply_prof_uni_w);
628 1658 inter->apply_bdof = FUNC(apply_bdof);
629 1658 inter->sad = vvc_sad;
630 1658 }
631
632 #undef FUNCS
633 #undef PEL_FUNC
634 #undef DMVR_FUNCS
635