FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/hevc/dsp_template.c
Date: 2026-10-14 08:57:35
Exec Total Coverage
Lines: 394 394 100.0%
Functions: 213 232 91.8%
Branches: 248 258 96.1%

Line Branch Exec Source
1 /*
2 * HEVC video decoder
3 *
4 * Copyright (C) 2012 - 2013 Guillaume Martres
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/get_bits.h"
24 #include "hevcdec.h"
25
26 #include "libavcodec/bit_depth_template.c"
27 #include "dsp.h"
28 #include "libavcodec/h26x/h2656_sao_template.c"
29 #include "libavcodec/h26x/h2656_inter_template.c"
30
31 67242 static void FUNC(put_pcm)(uint8_t *_dst, ptrdiff_t stride, int width, int height,
32 GetBitContext *gb, int pcm_bit_depth)
33 {
34 int x, y;
35 67242 pixel *dst = (pixel *)_dst;
36
37 67242 stride /= sizeof(pixel);
38
39
2/2
✓ Branch 0 taken 302128 times.
✓ Branch 1 taken 33621 times.
671498 for (y = 0; y < height; y++) {
40
2/2
✓ Branch 0 taken 4141952 times.
✓ Branch 1 taken 302128 times.
8888160 for (x = 0; x < width; x++)
41 8283904 dst[x] = get_bits(gb, pcm_bit_depth) << (BIT_DEPTH - pcm_bit_depth);
42 604256 dst += stride;
43 }
44 67242 }
45
46 27700912 static av_always_inline void FUNC(add_residual)(uint8_t *restrict dst8, const int16_t *restrict res,
47 ptrdiff_t stride, int size)
48 {
49 int x, y;
50
51
2/2
✓ Branch 0 taken 116773552 times.
✓ Branch 1 taken 13850456 times.
261248016 for (y = 0; y < size; y++) {
52 233547104 pixel *restrict dst = (pixel *)dst8;
53
2/2
✓ Branch 0 taken 1676854016 times.
✓ Branch 1 taken 116773552 times.
3587255136 for (x = 0; x < size; x++) {
54 3353708032 dst[x] = av_clip_pixel(dst[x] + *res);
55 3353708032 res++;
56 }
57 233547104 dst8 += stride;
58 }
59 27700912 }
60
61 14504112 static void FUNC(add_residual4x4)(uint8_t *_dst, const int16_t *res,
62 ptrdiff_t stride)
63 {
64 14504112 FUNC(add_residual)(_dst, res, stride, 4);
65 14504112 }
66
67 7567356 static void FUNC(add_residual8x8)(uint8_t *_dst, const int16_t *res,
68 ptrdiff_t stride)
69 {
70 7567356 FUNC(add_residual)(_dst, res, stride, 8);
71 7567356 }
72
73 4071900 static void FUNC(add_residual16x16)(uint8_t *_dst, const int16_t *res,
74 ptrdiff_t stride)
75 {
76 4071900 FUNC(add_residual)(_dst, res, stride, 16);
77 4071900 }
78
79 1557544 static void FUNC(add_residual32x32)(uint8_t *_dst, const int16_t *res,
80 ptrdiff_t stride)
81 {
82 1557544 FUNC(add_residual)(_dst, res, stride, 32);
83 1557544 }
84
85 35888 static void FUNC(transform_rdpcm)(int16_t *_coeffs, int16_t log2_size, int mode)
86 {
87 35888 int16_t *coeffs = (int16_t *) _coeffs;
88 int x, y;
89 35888 int size = 1 << log2_size;
90
91
2/2
✓ Branch 0 taken 7028 times.
✓ Branch 1 taken 10916 times.
35888 if (mode) {
92 14056 coeffs += size;
93
2/2
✓ Branch 0 taken 40480 times.
✓ Branch 1 taken 7028 times.
95016 for (y = 0; y < size - 1; y++) {
94
2/2
✓ Branch 0 taken 391964 times.
✓ Branch 1 taken 40480 times.
864888 for (x = 0; x < size; x++)
95 783928 coeffs[x] += coeffs[x - size];
96 80960 coeffs += size;
97 }
98 } else {
99
2/2
✓ Branch 0 taken 79588 times.
✓ Branch 1 taken 10916 times.
181008 for (y = 0; y < size; y++) {
100
2/2
✓ Branch 0 taken 667276 times.
✓ Branch 1 taken 79588 times.
1493728 for (x = 1; x < size; x++)
101 1334552 coeffs[x] += coeffs[x - 1];
102 159176 coeffs += size;
103 }
104 }
105 35888 }
106
107 /**
108 * HEVC transform dequantization (ITU-T H.265 8.6.3)
109 *
110 * @param coeffs transform coefficient buffer (in-place)
111 * @param log2_size log2 of transform block size, range: 2..5 (4x4 to 32x32)
112 * This value comes from recursive split_transform_flag parsing
113 * in the bitstream, bounded by log2_min_tb_size (min 2) and
114 * log2_max_trafo_size (max 5) from SPS.
115 *
116 * Formula: shift = 15 - BIT_DEPTH - log2_size
117 *
118 * bit_depth | 4x4 (2) | 8x8 (3) | 16x16 (4) | 32x32 (5)
119 * ----------+---------+---------+-----------+----------
120 * 8-bit | 5 | 4 | 3 | 2 (shift right)
121 * 10-bit | 3 | 2 | 1 | 0 (shift right / no-op)
122 * 12-bit | 1 | 0 | -1 | -2 (shift right / no-op / shift left)
123 *
124 * When shift == 0, output equals input (identity transform), so we skip
125 * the loop entirely for better performance.
126 */
127 785356 static void FUNC(dequant)(int16_t *coeffs, int16_t log2_size)
128 {
129 785356 int shift = 15 - BIT_DEPTH - log2_size;
130 int x, y;
131 785356 int size = 1 << log2_size;
132
133
2/2
✓ Branch 0 taken 142141 times.
✓ Branch 1 taken 6132 times.
296546 if (BIT_DEPTH <= 9 || shift > 0) {
134 773092 int offset = 1 << (shift - 1);
135
2/2
✓ Branch 0 taken 1596524 times.
✓ Branch 1 taken 386546 times.
3966140 for (y = 0; y < size; y++) {
136
2/2
✓ Branch 0 taken 7099568 times.
✓ Branch 1 taken 1596524 times.
17392184 for (x = 0; x < size; x++) {
137 14199136 *coeffs = (*coeffs + offset) >> shift;
138 14199136 coeffs++;
139 }
140 }
141
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 6073 times.
12258 } else if (BIT_DEPTH > 10 && shift < 0) {
142
2/2
✓ Branch 0 taken 1040 times.
✓ Branch 1 taken 56 times.
2192 for (y = 0; y < size; y++) {
143
2/2
✓ Branch 0 taken 21248 times.
✓ Branch 1 taken 1040 times.
44576 for (x = 0; x < size; x++) {
144 42496 *coeffs = *(uint16_t*)coeffs << -shift;
145 42496 coeffs++;
146 }
147 }
148 }
149 /* shift == 0: no operation needed (identity transform) */
150 785356 }
151
152 #define SET(dst, x) (dst) = (x)
153 #define SCALE(dst, x) (dst) = av_clip_int16(((x) + add) >> shift)
154
155 #define TR_4x4_LUMA(dst, src, step, assign) \
156 do { \
157 int c0 = src[0 * step] + src[2 * step]; \
158 int c1 = src[2 * step] + src[3 * step]; \
159 int c2 = src[0 * step] - src[3 * step]; \
160 int c3 = 74 * src[1 * step]; \
161 \
162 assign(dst[2 * step], 74 * (src[0 * step] - \
163 src[2 * step] + \
164 src[3 * step])); \
165 assign(dst[0 * step], 29 * c0 + 55 * c1 + c3); \
166 assign(dst[1 * step], 55 * c2 - 29 * c1 + c3); \
167 assign(dst[3 * step], 55 * c0 + 29 * c2 - c3); \
168 } while (0)
169
170 6125896 static void FUNC(transform_4x4_luma)(int16_t *coeffs)
171 {
172 int i;
173 6125896 int shift = 7;
174 6125896 int add = 1 << (shift - 1);
175 6125896 int16_t *src = coeffs;
176
177
2/2
✓ Branch 0 taken 12251792 times.
✓ Branch 1 taken 3062948 times.
30629480 for (i = 0; i < 4; i++) {
178 24503584 TR_4x4_LUMA(src, src, 4, SCALE);
179 24503584 src++;
180 }
181
182 6125896 shift = 20 - BIT_DEPTH;
183 6125896 add = 1 << (shift - 1);
184
2/2
✓ Branch 0 taken 12251792 times.
✓ Branch 1 taken 3062948 times.
30629480 for (i = 0; i < 4; i++) {
185 24503584 TR_4x4_LUMA(coeffs, coeffs, 1, SCALE);
186 24503584 coeffs += 4;
187 }
188 6125896 }
189
190 #undef TR_4x4_LUMA
191
192 #define TR_4(dst, src, dstep, sstep, assign, end) \
193 do { \
194 const int e0 = 64 * src[0 * sstep] + 64 * src[2 * sstep]; \
195 const int e1 = 64 * src[0 * sstep] - 64 * src[2 * sstep]; \
196 const int o0 = 83 * src[1 * sstep] + 36 * src[3 * sstep]; \
197 const int o1 = 36 * src[1 * sstep] - 83 * src[3 * sstep]; \
198 \
199 assign(dst[0 * dstep], e0 + o0); \
200 assign(dst[1 * dstep], e1 + o1); \
201 assign(dst[2 * dstep], e1 - o1); \
202 assign(dst[3 * dstep], e0 - o0); \
203 } while (0)
204
205 #define TR_8(dst, src, dstep, sstep, assign, end) \
206 do { \
207 int i, j; \
208 int e_8[4]; \
209 int o_8[4] = { 0 }; \
210 for (i = 0; i < 4; i++) \
211 for (j = 1; j < end; j += 2) \
212 o_8[i] += transform[4 * j][i] * src[j * sstep]; \
213 TR_4(e_8, src, 1, 2 * sstep, SET, 4); \
214 \
215 for (i = 0; i < 4; i++) { \
216 assign(dst[i * dstep], e_8[i] + o_8[i]); \
217 assign(dst[(7 - i) * dstep], e_8[i] - o_8[i]); \
218 } \
219 } while (0)
220
221 #define TR_16(dst, src, dstep, sstep, assign, end) \
222 do { \
223 int i, j; \
224 int e_16[8]; \
225 int o_16[8] = { 0 }; \
226 for (i = 0; i < 8; i++) \
227 for (j = 1; j < end; j += 2) \
228 o_16[i] += transform[2 * j][i] * src[j * sstep]; \
229 TR_8(e_16, src, 1, 2 * sstep, SET, 8); \
230 \
231 for (i = 0; i < 8; i++) { \
232 assign(dst[i * dstep], e_16[i] + o_16[i]); \
233 assign(dst[(15 - i) * dstep], e_16[i] - o_16[i]); \
234 } \
235 } while (0)
236
237 #define TR_32(dst, src, dstep, sstep, assign, end) \
238 do { \
239 int i, j; \
240 int e_32[16]; \
241 int o_32[16] = { 0 }; \
242 for (i = 0; i < 16; i++) \
243 for (j = 1; j < end; j += 2) \
244 o_32[i] += transform[j][i] * src[j * sstep]; \
245 TR_16(e_32, src, 1, 2 * sstep, SET, end / 2); \
246 \
247 for (i = 0; i < 16; i++) { \
248 assign(dst[i * dstep], e_32[i] + o_32[i]); \
249 assign(dst[(31 - i) * dstep], e_32[i] - o_32[i]); \
250 } \
251 } while (0)
252
253 #define IDCT_VAR4(H) \
254 int limit2 = FFMIN(col_limit + 4, H)
255 #define IDCT_VAR8(H) \
256 int limit = FFMIN(col_limit, H); \
257 int limit2 = FFMIN(col_limit + 4, H)
258 #define IDCT_VAR16(H) IDCT_VAR8(H)
259 #define IDCT_VAR32(H) IDCT_VAR8(H)
260
261 #define IDCT(H) \
262 static void FUNC(idct_ ## H ## x ## H )(int16_t *coeffs, \
263 int col_limit) \
264 { \
265 int i; \
266 int shift = 7; \
267 int add = 1 << (shift - 1); \
268 int16_t *src = coeffs; \
269 IDCT_VAR ## H(H); \
270 \
271 for (i = 0; i < H; i++) { \
272 TR_ ## H(src, src, H, H, SCALE, limit2); \
273 if (limit2 < H && i%4 == 0 && !!i) \
274 limit2 -= 4; \
275 src++; \
276 } \
277 \
278 shift = 20 - BIT_DEPTH; \
279 add = 1 << (shift - 1); \
280 for (i = 0; i < H; i++) { \
281 TR_ ## H(coeffs, coeffs, 1, 1, SCALE, limit); \
282 coeffs += H; \
283 } \
284 }
285
286 #define IDCT_DC(H) \
287 static void FUNC(idct_ ## H ## x ## H ## _dc)(int16_t *coeffs) \
288 { \
289 int i, j; \
290 int shift = 14 - BIT_DEPTH; \
291 int add = 1 << (shift - 1); \
292 int coeff = (((coeffs[0] + 1) >> 1) + add) >> shift; \
293 \
294 for (j = 0; j < H; j++) { \
295 for (i = 0; i < H; i++) { \
296 coeffs[i + j * H] = coeff; \
297 } \
298 } \
299 }
300
301
5/10
✗ Branch 0 not taken.
✓ Branch 1 taken 9402492 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 9402492 times.
✓ Branch 7 taken 2350623 times.
✓ Branch 8 taken 9402492 times.
✓ Branch 9 taken 2350623 times.
42311214 IDCT( 4)
302
17/22
✓ Branch 0 taken 369306880 times.
✓ Branch 1 taken 92326720 times.
✓ Branch 2 taken 92326720 times.
✓ Branch 3 taken 23081680 times.
✓ Branch 4 taken 92326720 times.
✓ Branch 5 taken 23081680 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 23081680 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 23081680 times.
✓ Branch 13 taken 2885210 times.
✓ Branch 14 taken 258364544 times.
✓ Branch 15 taken 92326720 times.
✓ Branch 16 taken 92326720 times.
✓ Branch 17 taken 23081680 times.
✓ Branch 18 taken 92326720 times.
✓ Branch 19 taken 23081680 times.
✓ Branch 20 taken 23081680 times.
✓ Branch 21 taken 2885210 times.
2092053748 IDCT( 8)
303
34/34
✓ Branch 0 taken 762838784 times.
✓ Branch 1 taken 205274240 times.
✓ Branch 2 taken 205274240 times.
✓ Branch 3 taken 25659280 times.
✓ Branch 4 taken 410548480 times.
✓ Branch 5 taken 102637120 times.
✓ Branch 6 taken 102637120 times.
✓ Branch 7 taken 25659280 times.
✓ Branch 8 taken 102637120 times.
✓ Branch 9 taken 25659280 times.
✓ Branch 10 taken 205274240 times.
✓ Branch 11 taken 25659280 times.
✓ Branch 12 taken 19352224 times.
✓ Branch 13 taken 6307056 times.
✓ Branch 14 taken 4838056 times.
✓ Branch 15 taken 14514168 times.
✓ Branch 16 taken 3628542 times.
✓ Branch 17 taken 1209514 times.
✓ Branch 18 taken 25659280 times.
✓ Branch 19 taken 1603705 times.
✓ Branch 20 taken 804571392 times.
✓ Branch 21 taken 205274240 times.
✓ Branch 22 taken 205274240 times.
✓ Branch 23 taken 25659280 times.
✓ Branch 24 taken 410548480 times.
✓ Branch 25 taken 102637120 times.
✓ Branch 26 taken 102637120 times.
✓ Branch 27 taken 25659280 times.
✓ Branch 28 taken 102637120 times.
✓ Branch 29 taken 25659280 times.
✓ Branch 30 taken 205274240 times.
✓ Branch 31 taken 25659280 times.
✓ Branch 32 taken 25659280 times.
✓ Branch 33 taken 1603705 times.
7346149682 IDCT(16)
304
46/46
✓ Branch 0 taken 1161490416 times.
✓ Branch 1 taken 322672640 times.
✓ Branch 2 taken 322672640 times.
✓ Branch 3 taken 20167040 times.
✓ Branch 4 taken 282787568 times.
✓ Branch 5 taken 161336320 times.
✓ Branch 6 taken 161336320 times.
✓ Branch 7 taken 20167040 times.
✓ Branch 8 taken 322672640 times.
✓ Branch 9 taken 80668160 times.
✓ Branch 10 taken 80668160 times.
✓ Branch 11 taken 20167040 times.
✓ Branch 12 taken 80668160 times.
✓ Branch 13 taken 20167040 times.
✓ Branch 14 taken 161336320 times.
✓ Branch 15 taken 20167040 times.
✓ Branch 16 taken 322672640 times.
✓ Branch 17 taken 20167040 times.
✓ Branch 18 taken 18085728 times.
✓ Branch 19 taken 2081312 times.
✓ Branch 20 taken 4521432 times.
✓ Branch 21 taken 13564296 times.
✓ Branch 22 taken 3956253 times.
✓ Branch 23 taken 565179 times.
✓ Branch 24 taken 20167040 times.
✓ Branch 25 taken 630220 times.
✓ Branch 26 taken 1782265344 times.
✓ Branch 27 taken 322672640 times.
✓ Branch 28 taken 322672640 times.
✓ Branch 29 taken 20167040 times.
✓ Branch 30 taken 435340288 times.
✓ Branch 31 taken 161336320 times.
✓ Branch 32 taken 161336320 times.
✓ Branch 33 taken 20167040 times.
✓ Branch 34 taken 322672640 times.
✓ Branch 35 taken 80668160 times.
✓ Branch 36 taken 80668160 times.
✓ Branch 37 taken 20167040 times.
✓ Branch 38 taken 80668160 times.
✓ Branch 39 taken 20167040 times.
✓ Branch 40 taken 161336320 times.
✓ Branch 41 taken 20167040 times.
✓ Branch 42 taken 322672640 times.
✓ Branch 43 taken 20167040 times.
✓ Branch 44 taken 20167040 times.
✓ Branch 45 taken 630220 times.
13213803352 IDCT(32)
305
306
4/4
✓ Branch 0 taken 16392080 times.
✓ Branch 1 taken 4098020 times.
✓ Branch 2 taken 4098020 times.
✓ Branch 3 taken 1024505 times.
43029210 IDCT_DC( 4)
307
4/4
✓ Branch 0 taken 53524544 times.
✓ Branch 1 taken 6690568 times.
✓ Branch 2 taken 6690568 times.
✓ Branch 3 taken 836321 times.
122102866 IDCT_DC( 8)
308
4/4
✓ Branch 0 taken 106886400 times.
✓ Branch 1 taken 6680400 times.
✓ Branch 2 taken 6680400 times.
✓ Branch 3 taken 417525 times.
227968650 IDCT_DC(16)
309
4/4
✓ Branch 0 taken 149525504 times.
✓ Branch 1 taken 4672672 times.
✓ Branch 2 taken 4672672 times.
✓ Branch 3 taken 146021 times.
308688394 IDCT_DC(32)
310
311 #undef TR_4
312 #undef TR_8
313 #undef TR_16
314 #undef TR_32
315
316 #undef SET
317 #undef SCALE
318
319 ////////////////////////////////////////////////////////////////////////////////
320 //
321 ////////////////////////////////////////////////////////////////////////////////
322 #define ff_hevc_pel_filters ff_hevc_qpel_filters
323 #define DECL_HV_FILTER(f) \
324 const int8_t *hf = ff_hevc_ ## f ## _filters[mx]; \
325 const int8_t *vf = ff_hevc_ ## f ## _filters[my];
326
327 #define FW_PUT(p, f, t) \
328 static void FUNC(put_hevc_## f)(int16_t *dst, const uint8_t *src, ptrdiff_t srcstride, int height, \
329 intptr_t mx, intptr_t my, int width) \
330 { \
331 DECL_HV_FILTER(p) \
332 FUNC(put_ ## t)(dst, src, srcstride, height, hf, vf, width); \
333 }
334
335 #define FW_PUT_UNI(p, f, t) \
336 static void FUNC(put_hevc_ ## f)(uint8_t *dst, ptrdiff_t dststride, const uint8_t *src, \
337 ptrdiff_t srcstride, int height, intptr_t mx, intptr_t my, int width) \
338 { \
339 DECL_HV_FILTER(p) \
340 FUNC(put_ ## t)(dst, dststride, src, srcstride, height, hf, vf, width); \
341 }
342
343 #define FW_PUT_UNI_W(p, f, t) \
344 static void FUNC(put_hevc_ ## f)(uint8_t *dst, ptrdiff_t dststride, const uint8_t *src, \
345 ptrdiff_t srcstride,int height, int denom, int wx, int ox, \
346 intptr_t mx, intptr_t my, int width) \
347 { \
348 DECL_HV_FILTER(p) \
349 FUNC(put_ ## t)(dst, dststride, src, srcstride, height, denom, wx, ox, hf, vf, width); \
350 }
351
352 #define FW_PUT_FUNCS(f, t, dir) \
353 FW_PUT(f, f ## _ ## dir, t ## _ ## dir) \
354 FW_PUT_UNI(f, f ## _uni_ ## dir, uni_ ## t ## _ ## dir) \
355 FW_PUT_UNI_W(f, f ## _uni_w_ ## dir, uni_## t ## _w_ ## dir)
356
357 5017706 FW_PUT(pel, pel_pixels, pixels)
358 7134368 FW_PUT_UNI(pel, pel_uni_pixels, uni_pixels)
359 170270 FW_PUT_UNI_W(pel, pel_uni_w_pixels, uni_w_pixels)
360
361 3553200 FW_PUT_FUNCS(qpel, luma, h )
362 3062300 FW_PUT_FUNCS(qpel, luma, v )
363 9511972 FW_PUT_FUNCS(qpel, luma, hv )
364 5647236 FW_PUT_FUNCS(epel, chroma, h )
365 4501168 FW_PUT_FUNCS(epel, chroma, v )
366 24700032 FW_PUT_FUNCS(epel, chroma, hv )
367
368 5462980 static void FUNC(put_hevc_pel_bi_pixels)(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride,
369 const int16_t *src2,
370 int height, intptr_t mx, intptr_t my, int width)
371 {
372 int x, y;
373 5462980 const pixel *src = (const pixel *)_src;
374 5462980 ptrdiff_t srcstride = _srcstride / sizeof(pixel);
375 5462980 pixel *dst = (pixel *)_dst;
376 5462980 ptrdiff_t dststride = _dststride / sizeof(pixel);
377
378 5462980 int shift = 14 + 1 - BIT_DEPTH;
379 #if BIT_DEPTH < 14
380 5462980 int offset = 1 << (shift - 1);
381 #else
382 int offset = 0;
383 #endif
384
385
2/2
✓ Branch 0 taken 41312368 times.
✓ Branch 1 taken 2731490 times.
88087716 for (y = 0; y < height; y++) {
386
2/2
✓ Branch 0 taken 1067887176 times.
✓ Branch 1 taken 41312368 times.
2218399088 for (x = 0; x < width; x++)
387 2135774352 dst[x] = av_clip_pixel(((src[x] << (14 - BIT_DEPTH)) + src2[x] + offset) >> shift);
388 82624736 src += srcstride;
389 82624736 dst += dststride;
390 82624736 src2 += MAX_PB_SIZE;
391 }
392 5462980 }
393
394 84070 static void FUNC(put_hevc_pel_bi_w_pixels)(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride,
395 const int16_t *src2,
396 int height, int denom, int wx0, int wx1,
397 int ox, intptr_t mx, intptr_t my, int width)
398 {
399 int x, y;
400 84070 const pixel *src = (const pixel *)_src;
401 84070 ptrdiff_t srcstride = _srcstride / sizeof(pixel);
402 84070 pixel *dst = (pixel *)_dst;
403 84070 ptrdiff_t dststride = _dststride / sizeof(pixel);
404
405 84070 int shift = 14 + 1 - BIT_DEPTH;
406 84070 int log2Wd = denom + shift - 1;
407
408 84070 ox = ox * (1 << (BIT_DEPTH - 8)) + 1;
409
2/2
✓ Branch 0 taken 913548 times.
✓ Branch 1 taken 42035 times.
1911166 for (y = 0; y < height; y++) {
410
2/2
✓ Branch 0 taken 29554400 times.
✓ Branch 1 taken 913548 times.
60935896 for (x = 0; x < width; x++) {
411 59108800 dst[x] = av_clip_pixel(( (src[x] << (14 - BIT_DEPTH)) * wx1 + src2[x] * wx0 + ox * (1 << log2Wd)) >> (log2Wd + 1));
412 }
413 1827096 src += srcstride;
414 1827096 dst += dststride;
415 1827096 src2 += MAX_PB_SIZE;
416 }
417 84070 }
418
419 ////////////////////////////////////////////////////////////////////////////////
420 //
421 ////////////////////////////////////////////////////////////////////////////////
422 #define QPEL_FILTER(src, stride) \
423 (filter[0] * src[x - 3 * stride] + \
424 filter[1] * src[x - 2 * stride] + \
425 filter[2] * src[x - stride] + \
426 filter[3] * src[x ] + \
427 filter[4] * src[x + stride] + \
428 filter[5] * src[x + 2 * stride] + \
429 filter[6] * src[x + 3 * stride] + \
430 filter[7] * src[x + 4 * stride])
431
432 1362460 static void FUNC(put_hevc_qpel_bi_h)(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride,
433 const int16_t *src2,
434 int height, intptr_t mx, intptr_t my, int width)
435 {
436 int x, y;
437 1362460 const pixel *src = (const pixel*)_src;
438 1362460 ptrdiff_t srcstride = _srcstride / sizeof(pixel);
439 1362460 pixel *dst = (pixel *)_dst;
440 1362460 ptrdiff_t dststride = _dststride / sizeof(pixel);
441
442 1362460 const int8_t *filter = ff_hevc_qpel_filters[mx];
443
444 1362460 int shift = 14 + 1 - BIT_DEPTH;
445 #if BIT_DEPTH < 14
446 1362460 int offset = 1 << (shift - 1);
447 #else
448 int offset = 0;
449 #endif
450
451
2/2
✓ Branch 0 taken 15146086 times.
✓ Branch 1 taken 681230 times.
31654632 for (y = 0; y < height; y++) {
452
2/2
✓ Branch 0 taken 513269404 times.
✓ Branch 1 taken 15146086 times.
1056830980 for (x = 0; x < width; x++)
453 1026538808 dst[x] = av_clip_pixel(((QPEL_FILTER(src, 1) >> (BIT_DEPTH - 8)) + src2[x] + offset) >> shift);
454 30292172 src += srcstride;
455 30292172 dst += dststride;
456 30292172 src2 += MAX_PB_SIZE;
457 }
458 1362460 }
459
460 1073476 static void FUNC(put_hevc_qpel_bi_v)(uint8_t *_dst, ptrdiff_t _dststride,
461 const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2,
462 int height, intptr_t mx, intptr_t my, int width)
463 {
464 int x, y;
465 1073476 const pixel *src = (const pixel*)_src;
466 1073476 ptrdiff_t srcstride = _srcstride / sizeof(pixel);
467 1073476 pixel *dst = (pixel *)_dst;
468 1073476 ptrdiff_t dststride = _dststride / sizeof(pixel);
469
470 1073476 const int8_t *filter = ff_hevc_qpel_filters[my];
471
472 1073476 int shift = 14 + 1 - BIT_DEPTH;
473 #if BIT_DEPTH < 14
474 1073476 int offset = 1 << (shift - 1);
475 #else
476 int offset = 0;
477 #endif
478
479
2/2
✓ Branch 0 taken 11566838 times.
✓ Branch 1 taken 536738 times.
24207152 for (y = 0; y < height; y++) {
480
2/2
✓ Branch 0 taken 377855452 times.
✓ Branch 1 taken 11566838 times.
778844580 for (x = 0; x < width; x++)
481 755710904 dst[x] = av_clip_pixel(((QPEL_FILTER(src, srcstride) >> (BIT_DEPTH - 8)) + src2[x] + offset) >> shift);
482 23133676 src += srcstride;
483 23133676 dst += dststride;
484 23133676 src2 += MAX_PB_SIZE;
485 }
486 1073476 }
487
488 3364736 static void FUNC(put_hevc_qpel_bi_hv)(uint8_t *_dst, ptrdiff_t _dststride,
489 const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2,
490 int height, intptr_t mx, intptr_t my, int width)
491 {
492 int x, y;
493 const int8_t *filter;
494 3364736 const pixel *src = (const pixel*)_src;
495 3364736 ptrdiff_t srcstride = _srcstride / sizeof(pixel);
496 3364736 pixel *dst = (pixel *)_dst;
497 3364736 ptrdiff_t dststride = _dststride / sizeof(pixel);
498 int16_t tmp_array[(MAX_PB_SIZE + QPEL_EXTRA) * MAX_PB_SIZE];
499 3364736 int16_t *tmp = tmp_array;
500 3364736 int shift = 14 + 1 - BIT_DEPTH;
501 #if BIT_DEPTH < 14
502 3364736 int offset = 1 << (shift - 1);
503 #else
504 int offset = 0;
505 #endif
506
507 3364736 src -= QPEL_EXTRA_BEFORE * srcstride;
508 3364736 filter = ff_hevc_qpel_filters[mx];
509
2/2
✓ Branch 0 taken 48027026 times.
✓ Branch 1 taken 1682368 times.
99418788 for (y = 0; y < height + QPEL_EXTRA; y++) {
510
2/2
✓ Branch 0 taken 1425017062 times.
✓ Branch 1 taken 48027026 times.
2946088176 for (x = 0; x < width; x++)
511 2850034124 tmp[x] = QPEL_FILTER(src, 1) >> (BIT_DEPTH - 8);
512 96054052 src += srcstride;
513 96054052 tmp += MAX_PB_SIZE;
514 }
515
516 3364736 tmp = tmp_array + QPEL_EXTRA_BEFORE * MAX_PB_SIZE;
517 3364736 filter = ff_hevc_qpel_filters[my];
518
519
2/2
✓ Branch 0 taken 36250450 times.
✓ Branch 1 taken 1682368 times.
75865636 for (y = 0; y < height; y++) {
520
2/2
✓ Branch 0 taken 1174315548 times.
✓ Branch 1 taken 36250450 times.
2421131996 for (x = 0; x < width; x++)
521 2348631096 dst[x] = av_clip_pixel(((QPEL_FILTER(tmp, MAX_PB_SIZE) >> 6) + src2[x] + offset) >> shift);
522 72500900 tmp += MAX_PB_SIZE;
523 72500900 dst += dststride;
524 72500900 src2 += MAX_PB_SIZE;
525 }
526 3364736 }
527
528 25262 static void FUNC(put_hevc_qpel_bi_w_h)(uint8_t *_dst, ptrdiff_t _dststride,
529 const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2,
530 int height, int denom, int wx0, int wx1,
531 int ox, intptr_t mx, intptr_t my, int width)
532 {
533 int x, y;
534 25262 const pixel *src = (const pixel*)_src;
535 25262 ptrdiff_t srcstride = _srcstride / sizeof(pixel);
536 25262 pixel *dst = (pixel *)_dst;
537 25262 ptrdiff_t dststride = _dststride / sizeof(pixel);
538
539 25262 const int8_t *filter = ff_hevc_qpel_filters[mx];
540
541 25262 int shift = 14 + 1 - BIT_DEPTH;
542 25262 int log2Wd = denom + shift - 1;
543
544 25262 ox = ox * (1 << (BIT_DEPTH - 8)) + 1;
545
2/2
✓ Branch 0 taken 326376 times.
✓ Branch 1 taken 12631 times.
678014 for (y = 0; y < height; y++) {
546
2/2
✓ Branch 0 taken 12110160 times.
✓ Branch 1 taken 326376 times.
24873072 for (x = 0; x < width; x++)
547 24220320 dst[x] = av_clip_pixel(((QPEL_FILTER(src, 1) >> (BIT_DEPTH - 8)) * wx1 + src2[x] * wx0 +
548 ox * (1 << log2Wd)) >> (log2Wd + 1));
549 652752 src += srcstride;
550 652752 dst += dststride;
551 652752 src2 += MAX_PB_SIZE;
552 }
553 25262 }
554
555 20560 static void FUNC(put_hevc_qpel_bi_w_v)(uint8_t *_dst, ptrdiff_t _dststride,
556 const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2,
557 int height, int denom, int wx0, int wx1,
558 int ox, intptr_t mx, intptr_t my, int width)
559 {
560 int x, y;
561 20560 const pixel *src = (const pixel*)_src;
562 20560 ptrdiff_t srcstride = _srcstride / sizeof(pixel);
563 20560 pixel *dst = (pixel *)_dst;
564 20560 ptrdiff_t dststride = _dststride / sizeof(pixel);
565
566 20560 const int8_t *filter = ff_hevc_qpel_filters[my];
567
568 20560 int shift = 14 + 1 - BIT_DEPTH;
569 20560 int log2Wd = denom + shift - 1;
570
571 20560 ox = ox * (1 << (BIT_DEPTH - 8)) + 1;
572
2/2
✓ Branch 0 taken 241540 times.
✓ Branch 1 taken 10280 times.
503640 for (y = 0; y < height; y++) {
573
2/2
✓ Branch 0 taken 8232272 times.
✓ Branch 1 taken 241540 times.
16947624 for (x = 0; x < width; x++)
574 16464544 dst[x] = av_clip_pixel(((QPEL_FILTER(src, srcstride) >> (BIT_DEPTH - 8)) * wx1 + src2[x] * wx0 +
575 ox * (1 << log2Wd)) >> (log2Wd + 1));
576 483080 src += srcstride;
577 483080 dst += dststride;
578 483080 src2 += MAX_PB_SIZE;
579 }
580 20560 }
581
582 70814 static void FUNC(put_hevc_qpel_bi_w_hv)(uint8_t *_dst, ptrdiff_t _dststride,
583 const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2,
584 int height, int denom, int wx0, int wx1,
585 int ox, intptr_t mx, intptr_t my, int width)
586 {
587 int x, y;
588 const int8_t *filter;
589 70814 const pixel *src = (const pixel*)_src;
590 70814 ptrdiff_t srcstride = _srcstride / sizeof(pixel);
591 70814 pixel *dst = (pixel *)_dst;
592 70814 ptrdiff_t dststride = _dststride / sizeof(pixel);
593 int16_t tmp_array[(MAX_PB_SIZE + QPEL_EXTRA) * MAX_PB_SIZE];
594 70814 int16_t *tmp = tmp_array;
595 70814 int shift = 14 + 1 - BIT_DEPTH;
596 70814 int log2Wd = denom + shift - 1;
597
598 70814 src -= QPEL_EXTRA_BEFORE * srcstride;
599 70814 filter = ff_hevc_qpel_filters[mx];
600
2/2
✓ Branch 0 taken 1128105 times.
✓ Branch 1 taken 35407 times.
2327024 for (y = 0; y < height + QPEL_EXTRA; y++) {
601
2/2
✓ Branch 0 taken 36871784 times.
✓ Branch 1 taken 1128105 times.
75999778 for (x = 0; x < width; x++)
602 73743568 tmp[x] = QPEL_FILTER(src, 1) >> (BIT_DEPTH - 8);
603 2256210 src += srcstride;
604 2256210 tmp += MAX_PB_SIZE;
605 }
606
607 70814 tmp = tmp_array + QPEL_EXTRA_BEFORE * MAX_PB_SIZE;
608 70814 filter = ff_hevc_qpel_filters[my];
609
610 70814 ox = ox * (1 << (BIT_DEPTH - 8)) + 1;
611
2/2
✓ Branch 0 taken 880256 times.
✓ Branch 1 taken 35407 times.
1831326 for (y = 0; y < height; y++) {
612
2/2
✓ Branch 0 taken 30916688 times.
✓ Branch 1 taken 880256 times.
63593888 for (x = 0; x < width; x++)
613 61833376 dst[x] = av_clip_pixel(((QPEL_FILTER(tmp, MAX_PB_SIZE) >> 6) * wx1 + src2[x] * wx0 +
614 ox * (1 << log2Wd)) >> (log2Wd + 1));
615 1760512 tmp += MAX_PB_SIZE;
616 1760512 dst += dststride;
617 1760512 src2 += MAX_PB_SIZE;
618 }
619 70814 }
620
621 ////////////////////////////////////////////////////////////////////////////////
622 //
623 ////////////////////////////////////////////////////////////////////////////////
624 #define EPEL_FILTER(src, stride) \
625 (filter[0] * src[x - stride] + \
626 filter[1] * src[x] + \
627 filter[2] * src[x + stride] + \
628 filter[3] * src[x + 2 * stride])
629
630 2166072 static void FUNC(put_hevc_epel_bi_h)(uint8_t *_dst, ptrdiff_t _dststride,
631 const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2,
632 int height, intptr_t mx, intptr_t my, int width)
633 {
634 int x, y;
635 2166072 const pixel *src = (const pixel *)_src;
636 2166072 ptrdiff_t srcstride = _srcstride / sizeof(pixel);
637 2166072 pixel *dst = (pixel *)_dst;
638 2166072 ptrdiff_t dststride = _dststride / sizeof(pixel);
639 2166072 const int8_t *filter = ff_hevc_epel_filters[mx];
640 2166072 int shift = 14 + 1 - BIT_DEPTH;
641 #if BIT_DEPTH < 14
642 2166072 int offset = 1 << (shift - 1);
643 #else
644 int offset = 0;
645 #endif
646
647
2/2
✓ Branch 0 taken 12793712 times.
✓ Branch 1 taken 1083036 times.
27753496 for (y = 0; y < height; y++) {
648
2/2
✓ Branch 0 taken 217371272 times.
✓ Branch 1 taken 12793712 times.
460329968 for (x = 0; x < width; x++) {
649 434742544 dst[x] = av_clip_pixel(((EPEL_FILTER(src, 1) >> (BIT_DEPTH - 8)) + src2[x] + offset) >> shift);
650 }
651 25587424 dst += dststride;
652 25587424 src += srcstride;
653 25587424 src2 += MAX_PB_SIZE;
654 }
655 2166072 }
656
657 1506616 static void FUNC(put_hevc_epel_bi_v)(uint8_t *_dst, ptrdiff_t _dststride,
658 const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2,
659 int height, intptr_t mx, intptr_t my, int width)
660 {
661 int x, y;
662 1506616 const pixel *src = (const pixel *)_src;
663 1506616 ptrdiff_t srcstride = _srcstride / sizeof(pixel);
664 1506616 const int8_t *filter = ff_hevc_epel_filters[my];
665 1506616 pixel *dst = (pixel *)_dst;
666 1506616 ptrdiff_t dststride = _dststride / sizeof(pixel);
667 1506616 int shift = 14 + 1 - BIT_DEPTH;
668 #if BIT_DEPTH < 14
669 1506616 int offset = 1 << (shift - 1);
670 #else
671 int offset = 0;
672 #endif
673
674
2/2
✓ Branch 0 taken 9089736 times.
✓ Branch 1 taken 753308 times.
19686088 for (y = 0; y < height; y++) {
675
2/2
✓ Branch 0 taken 149414728 times.
✓ Branch 1 taken 9089736 times.
317008928 for (x = 0; x < width; x++)
676 298829456 dst[x] = av_clip_pixel(((EPEL_FILTER(src, srcstride) >> (BIT_DEPTH - 8)) + src2[x] + offset) >> shift);
677 18179472 dst += dststride;
678 18179472 src += srcstride;
679 18179472 src2 += MAX_PB_SIZE;
680 }
681 1506616 }
682
683 8559840 static void FUNC(put_hevc_epel_bi_hv)(uint8_t *_dst, ptrdiff_t _dststride,
684 const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2,
685 int height, intptr_t mx, intptr_t my, int width)
686 {
687 int x, y;
688 8559840 const pixel *src = (const pixel *)_src;
689 8559840 ptrdiff_t srcstride = _srcstride / sizeof(pixel);
690 8559840 pixel *dst = (pixel *)_dst;
691 8559840 ptrdiff_t dststride = _dststride / sizeof(pixel);
692 8559840 const int8_t *filter = ff_hevc_epel_filters[mx];
693 int16_t tmp_array[(MAX_PB_SIZE + EPEL_EXTRA) * MAX_PB_SIZE];
694 8559840 int16_t *tmp = tmp_array;
695 8559840 int shift = 14 + 1 - BIT_DEPTH;
696 #if BIT_DEPTH < 14
697 8559840 int offset = 1 << (shift - 1);
698 #else
699 int offset = 0;
700 #endif
701
702 8559840 src -= EPEL_EXTRA_BEFORE * srcstride;
703
704
2/2
✓ Branch 0 taken 61899220 times.
✓ Branch 1 taken 4279920 times.
132358280 for (y = 0; y < height + EPEL_EXTRA; y++) {
705
2/2
✓ Branch 0 taken 920806680 times.
✓ Branch 1 taken 61899220 times.
1965411800 for (x = 0; x < width; x++)
706 1841613360 tmp[x] = EPEL_FILTER(src, 1) >> (BIT_DEPTH - 8);
707 123798440 src += srcstride;
708 123798440 tmp += MAX_PB_SIZE;
709 }
710
711 8559840 tmp = tmp_array + EPEL_EXTRA_BEFORE * MAX_PB_SIZE;
712 8559840 filter = ff_hevc_epel_filters[my];
713
714
2/2
✓ Branch 0 taken 49059460 times.
✓ Branch 1 taken 4279920 times.
106678760 for (y = 0; y < height; y++) {
715
2/2
✓ Branch 0 taken 783260808 times.
✓ Branch 1 taken 49059460 times.
1664640536 for (x = 0; x < width; x++)
716 1566521616 dst[x] = av_clip_pixel(((EPEL_FILTER(tmp, MAX_PB_SIZE) >> 6) + src2[x] + offset) >> shift);
717 98118920 tmp += MAX_PB_SIZE;
718 98118920 dst += dststride;
719 98118920 src2 += MAX_PB_SIZE;
720 }
721 8559840 }
722
723 38276 static void FUNC(put_hevc_epel_bi_w_h)(uint8_t *_dst, ptrdiff_t _dststride,
724 const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2,
725 int height, int denom, int wx0, int wx1,
726 int ox, intptr_t mx, intptr_t my, int width)
727 {
728 int x, y;
729 38276 const pixel *src = (const pixel *)_src;
730 38276 ptrdiff_t srcstride = _srcstride / sizeof(pixel);
731 38276 pixel *dst = (pixel *)_dst;
732 38276 ptrdiff_t dststride = _dststride / sizeof(pixel);
733 38276 const int8_t *filter = ff_hevc_epel_filters[mx];
734 38276 int shift = 14 + 1 - BIT_DEPTH;
735 38276 int log2Wd = denom + shift - 1;
736
737 38276 ox = ox * (1 << (BIT_DEPTH - 8)) + 1;
738
2/2
✓ Branch 0 taken 281780 times.
✓ Branch 1 taken 19138 times.
601836 for (y = 0; y < height; y++) {
739
2/2
✓ Branch 0 taken 6354784 times.
✓ Branch 1 taken 281780 times.
13273128 for (x = 0; x < width; x++)
740 12709568 dst[x] = av_clip_pixel(((EPEL_FILTER(src, 1) >> (BIT_DEPTH - 8)) * wx1 + src2[x] * wx0 +
741 ox * (1 << log2Wd)) >> (log2Wd + 1));
742 563560 src += srcstride;
743 563560 dst += dststride;
744 563560 src2 += MAX_PB_SIZE;
745 }
746 38276 }
747
748 25028 static void FUNC(put_hevc_epel_bi_w_v)(uint8_t *_dst, ptrdiff_t _dststride,
749 const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2,
750 int height, int denom, int wx0, int wx1,
751 int ox, intptr_t mx, intptr_t my, int width)
752 {
753 int x, y;
754 25028 const pixel *src = (const pixel *)_src;
755 25028 ptrdiff_t srcstride = _srcstride / sizeof(pixel);
756 25028 const int8_t *filter = ff_hevc_epel_filters[my];
757 25028 pixel *dst = (pixel *)_dst;
758 25028 ptrdiff_t dststride = _dststride / sizeof(pixel);
759 25028 int shift = 14 + 1 - BIT_DEPTH;
760 25028 int log2Wd = denom + shift - 1;
761
762 25028 ox = ox * (1 << (BIT_DEPTH - 8)) + 1;
763
2/2
✓ Branch 0 taken 173064 times.
✓ Branch 1 taken 12514 times.
371156 for (y = 0; y < height; y++) {
764
2/2
✓ Branch 0 taken 3990848 times.
✓ Branch 1 taken 173064 times.
8327824 for (x = 0; x < width; x++)
765 7981696 dst[x] = av_clip_pixel(((EPEL_FILTER(src, srcstride) >> (BIT_DEPTH - 8)) * wx1 + src2[x] * wx0 +
766 ox * (1 << log2Wd)) >> (log2Wd + 1));
767 346128 src += srcstride;
768 346128 dst += dststride;
769 346128 src2 += MAX_PB_SIZE;
770 }
771 25028 }
772
773 166712 static void FUNC(put_hevc_epel_bi_w_hv)(uint8_t *_dst, ptrdiff_t _dststride,
774 const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2,
775 int height, int denom, int wx0, int wx1,
776 int ox, intptr_t mx, intptr_t my, int width)
777 {
778 int x, y;
779 166712 const pixel *src = (const pixel *)_src;
780 166712 ptrdiff_t srcstride = _srcstride / sizeof(pixel);
781 166712 pixel *dst = (pixel *)_dst;
782 166712 ptrdiff_t dststride = _dststride / sizeof(pixel);
783 166712 const int8_t *filter = ff_hevc_epel_filters[mx];
784 int16_t tmp_array[(MAX_PB_SIZE + EPEL_EXTRA) * MAX_PB_SIZE];
785 166712 int16_t *tmp = tmp_array;
786 166712 int shift = 14 + 1 - BIT_DEPTH;
787 166712 int log2Wd = denom + shift - 1;
788
789 166712 src -= EPEL_EXTRA_BEFORE * srcstride;
790
791
2/2
✓ Branch 0 taken 1286192 times.
✓ Branch 1 taken 83356 times.
2739096 for (y = 0; y < height + EPEL_EXTRA; y++) {
792
2/2
✓ Branch 0 taken 21663936 times.
✓ Branch 1 taken 1286192 times.
45900256 for (x = 0; x < width; x++)
793 43327872 tmp[x] = EPEL_FILTER(src, 1) >> (BIT_DEPTH - 8);
794 2572384 src += srcstride;
795 2572384 tmp += MAX_PB_SIZE;
796 }
797
798 166712 tmp = tmp_array + EPEL_EXTRA_BEFORE * MAX_PB_SIZE;
799 166712 filter = ff_hevc_epel_filters[my];
800
801 166712 ox = ox * (1 << (BIT_DEPTH - 8)) + 1;
802
2/2
✓ Branch 0 taken 1036124 times.
✓ Branch 1 taken 83356 times.
2238960 for (y = 0; y < height; y++) {
803
2/2
✓ Branch 0 taken 18669504 times.
✓ Branch 1 taken 1036124 times.
39411256 for (x = 0; x < width; x++)
804 37339008 dst[x] = av_clip_pixel(((EPEL_FILTER(tmp, MAX_PB_SIZE) >> 6) * wx1 + src2[x] * wx0 +
805 ox * (1 << log2Wd)) >> (log2Wd + 1));
806 2072248 tmp += MAX_PB_SIZE;
807 2072248 dst += dststride;
808 2072248 src2 += MAX_PB_SIZE;
809 }
810 166712 }
811
812 // line zero
813 #define P3 pix[-4 * xstride]
814 #define P2 pix[-3 * xstride]
815 #define P1 pix[-2 * xstride]
816 #define P0 pix[-1 * xstride]
817 #define Q0 pix[0 * xstride]
818 #define Q1 pix[1 * xstride]
819 #define Q2 pix[2 * xstride]
820 #define Q3 pix[3 * xstride]
821
822 // line three. used only for deblocking decision
823 #define TP3 pix[-4 * xstride + 3 * ystride]
824 #define TP2 pix[-3 * xstride + 3 * ystride]
825 #define TP1 pix[-2 * xstride + 3 * ystride]
826 #define TP0 pix[-1 * xstride + 3 * ystride]
827 #define TQ0 pix[0 * xstride + 3 * ystride]
828 #define TQ1 pix[1 * xstride + 3 * ystride]
829 #define TQ2 pix[2 * xstride + 3 * ystride]
830 #define TQ3 pix[3 * xstride + 3 * ystride]
831
832 #include "libavcodec/h26x/h2656_deblock_template.c"
833
834 81418708 static void FUNC(hevc_loop_filter_luma)(uint8_t *_pix,
835 ptrdiff_t _xstride, ptrdiff_t _ystride,
836 int beta, const int *_tc,
837 const uint8_t *_no_p, const uint8_t *_no_q)
838 {
839 81418708 ptrdiff_t xstride = _xstride / sizeof(pixel);
840 81418708 ptrdiff_t ystride = _ystride / sizeof(pixel);
841
842 81418708 beta <<= BIT_DEPTH - 8;
843
844
2/2
✓ Branch 0 taken 81418708 times.
✓ Branch 1 taken 40709354 times.
244256124 for (int j = 0; j < 2; j++) {
845 162837416 pixel* pix = (pixel*)_pix + j * 4 * ystride;
846 162837416 const int dp0 = abs(P2 - 2 * P1 + P0);
847 162837416 const int dq0 = abs(Q2 - 2 * Q1 + Q0);
848 162837416 const int dp3 = abs(TP2 - 2 * TP1 + TP0);
849 162837416 const int dq3 = abs(TQ2 - 2 * TQ1 + TQ0);
850 162837416 const int d0 = dp0 + dq0;
851 162837416 const int d3 = dp3 + dq3;
852 162837416 const int tc = _tc[j] << (BIT_DEPTH - 8);
853 162837416 const int no_p = _no_p[j];
854 162837416 const int no_q = _no_q[j];
855
856
2/2
✓ Branch 0 taken 61700334 times.
✓ Branch 1 taken 19718374 times.
162837416 if (d0 + d3 < beta) {
857 123400668 const int beta_3 = beta >> 3;
858 123400668 const int beta_2 = beta >> 2;
859 123400668 const int tc25 = ((tc * 5 + 1) >> 1);
860
861
4/4
✓ Branch 0 taken 18521613 times.
✓ Branch 1 taken 43178721 times.
✓ Branch 2 taken 18053224 times.
✓ Branch 3 taken 468389 times.
123400668 if (abs(P3 - P0) + abs(Q3 - Q0) < beta_3 && abs(P0 - Q0) < tc25 &&
862
4/4
✓ Branch 0 taken 13541257 times.
✓ Branch 1 taken 4511967 times.
✓ Branch 2 taken 13452181 times.
✓ Branch 3 taken 89076 times.
36106448 abs(TP3 - TP0) + abs(TQ3 - TQ0) < beta_3 && abs(TP0 - TQ0) < tc25 &&
863
4/4
✓ Branch 0 taken 12982939 times.
✓ Branch 1 taken 469242 times.
✓ Branch 2 taken 12680601 times.
✓ Branch 3 taken 302338 times.
52265564 (d0 << 1) < beta_2 && (d3 << 1) < beta_2) {
864 25361202 const int tc2 = tc << 1;
865 25361202 FUNC(loop_filter_luma_strong)(pix, xstride, ystride, tc2, tc2, tc2, no_p, no_q);
866 } else {
867 98039466 int nd_p = 1;
868 98039466 int nd_q = 1;
869
2/2
✓ Branch 0 taken 34207127 times.
✓ Branch 1 taken 14812606 times.
98039466 if (dp0 + dp3 < ((beta + (beta >> 1)) >> 3))
870 68414254 nd_p = 2;
871
2/2
✓ Branch 0 taken 33485174 times.
✓ Branch 1 taken 15534559 times.
98039466 if (dq0 + dq3 < ((beta + (beta >> 1)) >> 3))
872 66970348 nd_q = 2;
873 98039466 FUNC(loop_filter_luma_weak)(pix, xstride, ystride, tc, beta, no_p, no_q, nd_p, nd_q);
874 }
875 }
876 }
877 81418708 }
878
879 21411156 static void FUNC(hevc_loop_filter_chroma)(uint8_t *_pix, ptrdiff_t _xstride,
880 ptrdiff_t _ystride, const int *_tc,
881 const uint8_t *_no_p, const uint8_t *_no_q)
882 {
883 int no_p, no_q;
884 21411156 ptrdiff_t xstride = _xstride / sizeof(pixel);
885 21411156 ptrdiff_t ystride = _ystride / sizeof(pixel);
886 21411156 const int size = 4;
887
888
2/2
✓ Branch 0 taken 21411156 times.
✓ Branch 1 taken 10705578 times.
64233468 for (int j = 0; j < 2; j++) {
889 42822312 pixel *pix = (pixel *)_pix + j * size * ystride;
890 42822312 const int tc = _tc[j] << (BIT_DEPTH - 8);
891
2/2
✓ Branch 0 taken 19334838 times.
✓ Branch 1 taken 2076318 times.
42822312 if (tc > 0) {
892 38669676 no_p = _no_p[j];
893 38669676 no_q = _no_q[j];
894
895 38669676 FUNC(loop_filter_chroma_weak)(pix, xstride, ystride, size, tc, no_p, no_q);
896 }
897 }
898 21411156 }
899
900 10471706 static void FUNC(hevc_h_loop_filter_chroma)(uint8_t *pix, ptrdiff_t stride,
901 const int32_t *tc, const uint8_t *no_p,
902 const uint8_t *no_q)
903 {
904 10471706 FUNC(hevc_loop_filter_chroma)(pix, stride, sizeof(pixel), tc, no_p, no_q);
905 10471706 }
906
907 10939450 static void FUNC(hevc_v_loop_filter_chroma)(uint8_t *pix, ptrdiff_t stride,
908 const int32_t *tc, const uint8_t *no_p,
909 const uint8_t *no_q)
910 {
911 10939450 FUNC(hevc_loop_filter_chroma)(pix, sizeof(pixel), stride, tc, no_p, no_q);
912 10939450 }
913
914 41080912 static void FUNC(hevc_h_loop_filter_luma)(uint8_t *pix, ptrdiff_t stride,
915 int beta, const int32_t *tc, const uint8_t *no_p,
916 const uint8_t *no_q)
917 {
918 41080912 FUNC(hevc_loop_filter_luma)(pix, stride, sizeof(pixel),
919 beta, tc, no_p, no_q);
920 41080912 }
921
922 40337796 static void FUNC(hevc_v_loop_filter_luma)(uint8_t *pix, ptrdiff_t stride,
923 int beta, const int32_t *tc, const uint8_t *no_p,
924 const uint8_t *no_q)
925 {
926 40337796 FUNC(hevc_loop_filter_luma)(pix, sizeof(pixel), stride,
927 beta, tc, no_p, no_q);
928 40337796 }
929
930 #undef P3
931 #undef P2
932 #undef P1
933 #undef P0
934 #undef Q0
935 #undef Q1
936 #undef Q2
937 #undef Q3
938
939 #undef TP3
940 #undef TP2
941 #undef TP1
942 #undef TP0
943 #undef TQ0
944 #undef TQ1
945 #undef TQ2
946 #undef TQ3
947