FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/hevcdsp_template.c
Date: 2023-10-02 11:06:47
Exec Total Coverage
Lines: 886 886 100.0%
Functions: 224 248 90.3%
Branches: 501 512 97.9%

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 "get_bits.h"
24 #include "hevcdec.h"
25
26 #include "bit_depth_template.c"
27 #include "hevcdsp.h"
28
29 74598 static void FUNC(put_pcm)(uint8_t *_dst, ptrdiff_t stride, int width, int height,
30 GetBitContext *gb, int pcm_bit_depth)
31 {
32 int x, y;
33 74598 pixel *dst = (pixel *)_dst;
34
35 74598 stride /= sizeof(pixel);
36
37
2/2
✓ Branch 0 taken 327424 times.
✓ Branch 1 taken 37299 times.
729446 for (y = 0; y < height; y++) {
38
2/2
✓ Branch 0 taken 4382080 times.
✓ Branch 1 taken 327424 times.
9419008 for (x = 0; x < width; x++)
39 8764160 dst[x] = get_bits(gb, pcm_bit_depth) << (BIT_DEPTH - pcm_bit_depth);
40 654848 dst += stride;
41 }
42 74598 }
43
44 27980362 static av_always_inline void FUNC(add_residual)(uint8_t *_dst, const int16_t *res,
45 ptrdiff_t stride, int size)
46 {
47 int x, y;
48 27980362 pixel *dst = (pixel *)_dst;
49
50 27980362 stride /= sizeof(pixel);
51
52
2/2
✓ Branch 0 taken 106549588 times.
✓ Branch 1 taken 13990181 times.
241079538 for (y = 0; y < size; y++) {
53
2/2
✓ Branch 0 taken 1377565424 times.
✓ Branch 1 taken 106549588 times.
2968230024 for (x = 0; x < size; x++) {
54 2755130848 dst[x] = av_clip_pixel(dst[x] + *res);
55 2755130848 res++;
56 }
57 213099176 dst += stride;
58 }
59 27980362 }
60
61 16228982 static void FUNC(add_residual4x4)(uint8_t *_dst, const int16_t *res,
62 ptrdiff_t stride)
63 {
64 16228982 FUNC(add_residual)(_dst, res, stride, 4);
65 16228982 }
66
67 7288426 static void FUNC(add_residual8x8)(uint8_t *_dst, const int16_t *res,
68 ptrdiff_t stride)
69 {
70 7288426 FUNC(add_residual)(_dst, res, stride, 8);
71 7288426 }
72
73 3308668 static void FUNC(add_residual16x16)(uint8_t *_dst, const int16_t *res,
74 ptrdiff_t stride)
75 {
76 3308668 FUNC(add_residual)(_dst, res, stride, 16);
77 3308668 }
78
79 1154286 static void FUNC(add_residual32x32)(uint8_t *_dst, const int16_t *res,
80 ptrdiff_t stride)
81 {
82 1154286 FUNC(add_residual)(_dst, res, stride, 32);
83 1154286 }
84
85 54126 static void FUNC(transform_rdpcm)(int16_t *_coeffs, int16_t log2_size, int mode)
86 {
87 54126 int16_t *coeffs = (int16_t *) _coeffs;
88 int x, y;
89 54126 int size = 1 << log2_size;
90
91
2/2
✓ Branch 0 taken 9989 times.
✓ Branch 1 taken 17074 times.
54126 if (mode) {
92 19978 coeffs += size;
93
2/2
✓ Branch 0 taken 56315 times.
✓ Branch 1 taken 9989 times.
132608 for (y = 0; y < size - 1; y++) {
94
2/2
✓ Branch 0 taken 523168 times.
✓ Branch 1 taken 56315 times.
1158966 for (x = 0; x < size; x++)
95 1046336 coeffs[x] += coeffs[x - size];
96 112630 coeffs += size;
97 }
98 } else {
99
2/2
✓ Branch 0 taken 124352 times.
✓ Branch 1 taken 17074 times.
282852 for (y = 0; y < size; y++) {
100
2/2
✓ Branch 0 taken 1049312 times.
✓ Branch 1 taken 124352 times.
2347328 for (x = 1; x < size; x++)
101 2098624 coeffs[x] += coeffs[x - 1];
102 248704 coeffs += size;
103 }
104 }
105 54126 }
106
107 864282 static void FUNC(dequant)(int16_t *coeffs, int16_t log2_size)
108 {
109 864282 int shift = 15 - BIT_DEPTH - log2_size;
110 int x, y;
111 864282 int size = 1 << log2_size;
112
113
2/2
✓ Branch 0 taken 422855 times.
✓ Branch 1 taken 9286 times.
864282 if (shift > 0) {
114 845710 int offset = 1 << (shift - 1);
115
2/2
✓ Branch 0 taken 1765132 times.
✓ Branch 1 taken 422855 times.
4375974 for (y = 0; y < size; y++) {
116
2/2
✓ Branch 0 taken 8083472 times.
✓ Branch 1 taken 1765132 times.
19697208 for (x = 0; x < size; x++) {
117 16166944 *coeffs = (*coeffs + offset) >> shift;
118 16166944 coeffs++;
119 }
120 }
121 } else {
122
2/2
✓ Branch 0 taken 74992 times.
✓ Branch 1 taken 9286 times.
168556 for (y = 0; y < size; y++) {
123
2/2
✓ Branch 0 taken 613504 times.
✓ Branch 1 taken 74992 times.
1376992 for (x = 0; x < size; x++) {
124 1227008 *coeffs = *(uint16_t*)coeffs << -shift;
125 1227008 coeffs++;
126 }
127 }
128 }
129 864282 }
130
131 #define SET(dst, x) (dst) = (x)
132 #define SCALE(dst, x) (dst) = av_clip_int16(((x) + add) >> shift)
133
134 #define TR_4x4_LUMA(dst, src, step, assign) \
135 do { \
136 int c0 = src[0 * step] + src[2 * step]; \
137 int c1 = src[2 * step] + src[3 * step]; \
138 int c2 = src[0 * step] - src[3 * step]; \
139 int c3 = 74 * src[1 * step]; \
140 \
141 assign(dst[2 * step], 74 * (src[0 * step] - \
142 src[2 * step] + \
143 src[3 * step])); \
144 assign(dst[0 * step], 29 * c0 + 55 * c1 + c3); \
145 assign(dst[1 * step], 55 * c2 - 29 * c1 + c3); \
146 assign(dst[3 * step], 55 * c0 + 29 * c2 - c3); \
147 } while (0)
148
149 7141354 static void FUNC(transform_4x4_luma)(int16_t *coeffs)
150 {
151 int i;
152 7141354 int shift = 7;
153 7141354 int add = 1 << (shift - 1);
154 7141354 int16_t *src = coeffs;
155
156
2/2
✓ Branch 0 taken 14282708 times.
✓ Branch 1 taken 3570677 times.
35706770 for (i = 0; i < 4; i++) {
157 28565416 TR_4x4_LUMA(src, src, 4, SCALE);
158 28565416 src++;
159 }
160
161 7141354 shift = 20 - BIT_DEPTH;
162 7141354 add = 1 << (shift - 1);
163
2/2
✓ Branch 0 taken 14282708 times.
✓ Branch 1 taken 3570677 times.
35706770 for (i = 0; i < 4; i++) {
164 28565416 TR_4x4_LUMA(coeffs, coeffs, 1, SCALE);
165 28565416 coeffs += 4;
166 }
167 7141354 }
168
169 #undef TR_4x4_LUMA
170
171 #define TR_4(dst, src, dstep, sstep, assign, end) \
172 do { \
173 const int e0 = 64 * src[0 * sstep] + 64 * src[2 * sstep]; \
174 const int e1 = 64 * src[0 * sstep] - 64 * src[2 * sstep]; \
175 const int o0 = 83 * src[1 * sstep] + 36 * src[3 * sstep]; \
176 const int o1 = 36 * src[1 * sstep] - 83 * src[3 * sstep]; \
177 \
178 assign(dst[0 * dstep], e0 + o0); \
179 assign(dst[1 * dstep], e1 + o1); \
180 assign(dst[2 * dstep], e1 - o1); \
181 assign(dst[3 * dstep], e0 - o0); \
182 } while (0)
183
184 #define TR_8(dst, src, dstep, sstep, assign, end) \
185 do { \
186 int i, j; \
187 int e_8[4]; \
188 int o_8[4] = { 0 }; \
189 for (i = 0; i < 4; i++) \
190 for (j = 1; j < end; j += 2) \
191 o_8[i] += transform[4 * j][i] * src[j * sstep]; \
192 TR_4(e_8, src, 1, 2 * sstep, SET, 4); \
193 \
194 for (i = 0; i < 4; i++) { \
195 assign(dst[i * dstep], e_8[i] + o_8[i]); \
196 assign(dst[(7 - i) * dstep], e_8[i] - o_8[i]); \
197 } \
198 } while (0)
199
200 #define TR_16(dst, src, dstep, sstep, assign, end) \
201 do { \
202 int i, j; \
203 int e_16[8]; \
204 int o_16[8] = { 0 }; \
205 for (i = 0; i < 8; i++) \
206 for (j = 1; j < end; j += 2) \
207 o_16[i] += transform[2 * j][i] * src[j * sstep]; \
208 TR_8(e_16, src, 1, 2 * sstep, SET, 8); \
209 \
210 for (i = 0; i < 8; i++) { \
211 assign(dst[i * dstep], e_16[i] + o_16[i]); \
212 assign(dst[(15 - i) * dstep], e_16[i] - o_16[i]); \
213 } \
214 } while (0)
215
216 #define TR_32(dst, src, dstep, sstep, assign, end) \
217 do { \
218 int i, j; \
219 int e_32[16]; \
220 int o_32[16] = { 0 }; \
221 for (i = 0; i < 16; i++) \
222 for (j = 1; j < end; j += 2) \
223 o_32[i] += transform[j][i] * src[j * sstep]; \
224 TR_16(e_32, src, 1, 2 * sstep, SET, end / 2); \
225 \
226 for (i = 0; i < 16; i++) { \
227 assign(dst[i * dstep], e_32[i] + o_32[i]); \
228 assign(dst[(31 - i) * dstep], e_32[i] - o_32[i]); \
229 } \
230 } while (0)
231
232 #define IDCT_VAR4(H) \
233 int limit2 = FFMIN(col_limit + 4, H)
234 #define IDCT_VAR8(H) \
235 int limit = FFMIN(col_limit, H); \
236 int limit2 = FFMIN(col_limit + 4, H)
237 #define IDCT_VAR16(H) IDCT_VAR8(H)
238 #define IDCT_VAR32(H) IDCT_VAR8(H)
239
240 #define IDCT(H) \
241 static void FUNC(idct_ ## H ## x ## H )(int16_t *coeffs, \
242 int col_limit) \
243 { \
244 int i; \
245 int shift = 7; \
246 int add = 1 << (shift - 1); \
247 int16_t *src = coeffs; \
248 IDCT_VAR ## H(H); \
249 \
250 for (i = 0; i < H; i++) { \
251 TR_ ## H(src, src, H, H, SCALE, limit2); \
252 if (limit2 < H && i%4 == 0 && !!i) \
253 limit2 -= 4; \
254 src++; \
255 } \
256 \
257 shift = 20 - BIT_DEPTH; \
258 add = 1 << (shift - 1); \
259 for (i = 0; i < H; i++) { \
260 TR_ ## H(coeffs, coeffs, 1, 1, SCALE, limit); \
261 coeffs += H; \
262 } \
263 }
264
265 #define IDCT_DC(H) \
266 static void FUNC(idct_ ## H ## x ## H ## _dc)(int16_t *coeffs) \
267 { \
268 int i, j; \
269 int shift = 14 - BIT_DEPTH; \
270 int add = 1 << (shift - 1); \
271 int coeff = (((coeffs[0] + 1) >> 1) + add) >> shift; \
272 \
273 for (j = 0; j < H; j++) { \
274 for (i = 0; i < H; i++) { \
275 coeffs[i + j * H] = coeff; \
276 } \
277 } \
278 }
279
280
5/10
✗ Branch 0 not taken.
✓ Branch 1 taken 10522240 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 10522240 times.
✓ Branch 7 taken 2630560 times.
✓ Branch 8 taken 10522240 times.
✓ Branch 9 taken 2630560 times.
47350080 IDCT( 4)
281
17/22
✓ Branch 0 taken 363635200 times.
✓ Branch 1 taken 90908800 times.
✓ Branch 2 taken 90908800 times.
✓ Branch 3 taken 22727200 times.
✓ Branch 4 taken 90908800 times.
✓ Branch 5 taken 22727200 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 22727200 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 12 taken 22727200 times.
✓ Branch 13 taken 2840900 times.
✓ Branch 14 taken 257275712 times.
✓ Branch 15 taken 90908800 times.
✓ Branch 16 taken 90908800 times.
✓ Branch 17 taken 22727200 times.
✓ Branch 18 taken 90908800 times.
✓ Branch 19 taken 22727200 times.
✓ Branch 20 taken 22727200 times.
✓ Branch 21 taken 2840900 times.
2065682824 IDCT( 8)
282
34/34
✓ Branch 0 taken 675830096 times.
✓ Branch 1 taken 177257856 times.
✓ Branch 2 taken 177257856 times.
✓ Branch 3 taken 22157232 times.
✓ Branch 4 taken 354515712 times.
✓ Branch 5 taken 88628928 times.
✓ Branch 6 taken 88628928 times.
✓ Branch 7 taken 22157232 times.
✓ Branch 8 taken 88628928 times.
✓ Branch 9 taken 22157232 times.
✓ Branch 10 taken 177257856 times.
✓ Branch 11 taken 22157232 times.
✓ Branch 12 taken 16376704 times.
✓ Branch 13 taken 5780528 times.
✓ Branch 14 taken 4094176 times.
✓ Branch 15 taken 12282528 times.
✓ Branch 16 taken 3070632 times.
✓ Branch 17 taken 1023544 times.
✓ Branch 18 taken 22157232 times.
✓ Branch 19 taken 1384827 times.
✓ Branch 20 taken 710084864 times.
✓ Branch 21 taken 177257856 times.
✓ Branch 22 taken 177257856 times.
✓ Branch 23 taken 22157232 times.
✓ Branch 24 taken 354515712 times.
✓ Branch 25 taken 88628928 times.
✓ Branch 26 taken 88628928 times.
✓ Branch 27 taken 22157232 times.
✓ Branch 28 taken 88628928 times.
✓ Branch 29 taken 22157232 times.
✓ Branch 30 taken 177257856 times.
✓ Branch 31 taken 22157232 times.
✓ Branch 32 taken 22157232 times.
✓ Branch 33 taken 1384827 times.
6408385622 IDCT(16)
283
46/46
✓ Branch 0 taken 1116340416 times.
✓ Branch 1 taken 254356480 times.
✓ Branch 2 taken 254356480 times.
✓ Branch 3 taken 15897280 times.
✓ Branch 4 taken 271424888 times.
✓ Branch 5 taken 127178240 times.
✓ Branch 6 taken 127178240 times.
✓ Branch 7 taken 15897280 times.
✓ Branch 8 taken 254356480 times.
✓ Branch 9 taken 63589120 times.
✓ Branch 10 taken 63589120 times.
✓ Branch 11 taken 15897280 times.
✓ Branch 12 taken 63589120 times.
✓ Branch 13 taken 15897280 times.
✓ Branch 14 taken 127178240 times.
✓ Branch 15 taken 15897280 times.
✓ Branch 16 taken 254356480 times.
✓ Branch 17 taken 15897280 times.
✓ Branch 18 taken 13720416 times.
✓ Branch 19 taken 2176864 times.
✓ Branch 20 taken 3430104 times.
✓ Branch 21 taken 10290312 times.
✓ Branch 22 taken 3001341 times.
✓ Branch 23 taken 428763 times.
✓ Branch 24 taken 15897280 times.
✓ Branch 25 taken 496790 times.
✓ Branch 26 taken 1638708224 times.
✓ Branch 27 taken 254356480 times.
✓ Branch 28 taken 254356480 times.
✓ Branch 29 taken 15897280 times.
✓ Branch 30 taken 399364608 times.
✓ Branch 31 taken 127178240 times.
✓ Branch 32 taken 127178240 times.
✓ Branch 33 taken 15897280 times.
✓ Branch 34 taken 254356480 times.
✓ Branch 35 taken 63589120 times.
✓ Branch 36 taken 63589120 times.
✓ Branch 37 taken 15897280 times.
✓ Branch 38 taken 63589120 times.
✓ Branch 39 taken 15897280 times.
✓ Branch 40 taken 127178240 times.
✓ Branch 41 taken 15897280 times.
✓ Branch 42 taken 254356480 times.
✓ Branch 43 taken 15897280 times.
✓ Branch 44 taken 15897280 times.
✓ Branch 45 taken 496790 times.
11494675612 IDCT(32)
284
285
4/4
✓ Branch 0 taken 17376480 times.
✓ Branch 1 taken 4344120 times.
✓ Branch 2 taken 4344120 times.
✓ Branch 3 taken 1086030 times.
45613260 IDCT_DC( 4)
286
4/4
✓ Branch 0 taken 46935552 times.
✓ Branch 1 taken 5866944 times.
✓ Branch 2 taken 5866944 times.
✓ Branch 3 taken 733368 times.
107071728 IDCT_DC( 8)
287
4/4
✓ Branch 0 taken 65159936 times.
✓ Branch 1 taken 4072496 times.
✓ Branch 2 taken 4072496 times.
✓ Branch 3 taken 254531 times.
138973926 IDCT_DC(16)
288
4/4
✓ Branch 0 taken 79552512 times.
✓ Branch 1 taken 2486016 times.
✓ Branch 2 taken 2486016 times.
✓ Branch 3 taken 77688 times.
164232432 IDCT_DC(32)
289
290 #undef TR_4
291 #undef TR_8
292 #undef TR_16
293 #undef TR_32
294
295 #undef SET
296 #undef SCALE
297
298 222676 static void FUNC(sao_band_filter)(uint8_t *_dst, const uint8_t *_src,
299 ptrdiff_t stride_dst, ptrdiff_t stride_src,
300 const int16_t *sao_offset_val, int sao_left_class,
301 int width, int height)
302 {
303 222676 pixel *dst = (pixel *)_dst;
304 222676 const pixel *src = (const pixel *)_src;
305 222676 int offset_table[32] = { 0 };
306 int k, y, x;
307 222676 int shift = BIT_DEPTH - 5;
308
309 222676 stride_dst /= sizeof(pixel);
310 222676 stride_src /= sizeof(pixel);
311
312
2/2
✓ Branch 0 taken 445352 times.
✓ Branch 1 taken 111338 times.
1113380 for (k = 0; k < 4; k++)
313 890704 offset_table[(k + sao_left_class) & 31] = sao_offset_val[k + 1];
314
2/2
✓ Branch 0 taken 4185584 times.
✓ Branch 1 taken 111338 times.
8593844 for (y = 0; y < height; y++) {
315
2/2
✓ Branch 0 taken 204816032 times.
✓ Branch 1 taken 4185584 times.
418003232 for (x = 0; x < width; x++)
316 409632064 dst[x] = av_clip_pixel(src[x] + offset_table[(src[x] >> shift) & 31]);
317 8371168 dst += stride_dst;
318 8371168 src += stride_src;
319 }
320 222676 }
321
322 #define CMP(a, b) (((a) > (b)) - ((a) < (b)))
323
324 744168 static void FUNC(sao_edge_filter)(uint8_t *_dst, const uint8_t *_src, ptrdiff_t stride_dst, const int16_t *sao_offset_val,
325 int eo, int width, int height) {
326
327 static const uint8_t edge_idx[] = { 1, 2, 0, 3, 4 };
328 static const int8_t pos[4][2][2] = {
329 { { -1, 0 }, { 1, 0 } }, // horizontal
330 { { 0, -1 }, { 0, 1 } }, // vertical
331 { { -1, -1 }, { 1, 1 } }, // 45 degree
332 { { 1, -1 }, { -1, 1 } }, // 135 degree
333 };
334 744168 pixel *dst = (pixel *)_dst;
335 744168 const pixel *src = (const pixel *)_src;
336 int a_stride, b_stride;
337 int x, y;
338 744168 ptrdiff_t stride_src = (2*MAX_PB_SIZE + AV_INPUT_BUFFER_PADDING_SIZE) / sizeof(pixel);
339 744168 stride_dst /= sizeof(pixel);
340
341 744168 a_stride = pos[eo][0][0] + pos[eo][0][1] * stride_src;
342 744168 b_stride = pos[eo][1][0] + pos[eo][1][1] * stride_src;
343
2/2
✓ Branch 0 taken 19188216 times.
✓ Branch 1 taken 372084 times.
39120600 for (y = 0; y < height; y++) {
344
2/2
✓ Branch 0 taken 1057691808 times.
✓ Branch 1 taken 19188216 times.
2153760048 for (x = 0; x < width; x++) {
345 2115383616 int diff0 = CMP(src[x], src[x + a_stride]);
346 2115383616 int diff1 = CMP(src[x], src[x + b_stride]);
347 2115383616 int offset_val = edge_idx[2 + diff0 + diff1];
348 2115383616 dst[x] = av_clip_pixel(src[x] + sao_offset_val[offset_val]);
349 }
350 38376432 src += stride_src;
351 38376432 dst += stride_dst;
352 }
353 744168 }
354
355 721060 static void FUNC(sao_edge_restore_0)(uint8_t *_dst, const uint8_t *_src,
356 ptrdiff_t stride_dst, ptrdiff_t stride_src, const SAOParams *sao,
357 const int *borders, int _width, int _height,
358 int c_idx, const uint8_t *vert_edge,
359 const uint8_t *horiz_edge, const uint8_t *diag_edge)
360 {
361 int x, y;
362 721060 pixel *dst = (pixel *)_dst;
363 721060 const pixel *src = (const pixel *)_src;
364 721060 const int16_t *sao_offset_val = sao->offset_val[c_idx];
365 721060 int sao_eo_class = sao->eo_class[c_idx];
366 721060 int init_x = 0, width = _width, height = _height;
367
368 721060 stride_dst /= sizeof(pixel);
369 721060 stride_src /= sizeof(pixel);
370
371
2/2
✓ Branch 0 taken 282668 times.
✓ Branch 1 taken 77862 times.
721060 if (sao_eo_class != SAO_EO_VERT) {
372
2/2
✓ Branch 0 taken 13321 times.
✓ Branch 1 taken 269347 times.
565336 if (borders[0]) {
373 26642 int offset_val = sao_offset_val[0];
374
2/2
✓ Branch 0 taken 657864 times.
✓ Branch 1 taken 13321 times.
1342370 for (y = 0; y < height; y++) {
375 1315728 dst[y * stride_dst] = av_clip_pixel(src[y * stride_src] + offset_val);
376 }
377 26642 init_x = 1;
378 }
379
2/2
✓ Branch 0 taken 13553 times.
✓ Branch 1 taken 269115 times.
565336 if (borders[2]) {
380 27106 int offset_val = sao_offset_val[0];
381 27106 int offset = width - 1;
382
2/2
✓ Branch 0 taken 658904 times.
✓ Branch 1 taken 13553 times.
1344914 for (x = 0; x < height; x++) {
383 1317808 dst[x * stride_dst + offset] = av_clip_pixel(src[x * stride_src + offset] + offset_val);
384 }
385 27106 width--;
386 }
387 }
388
2/2
✓ Branch 0 taken 296924 times.
✓ Branch 1 taken 63606 times.
721060 if (sao_eo_class != SAO_EO_HORIZ) {
389
2/2
✓ Branch 0 taken 18461 times.
✓ Branch 1 taken 278463 times.
593848 if (borders[1]) {
390 36922 int offset_val = sao_offset_val[0];
391
2/2
✓ Branch 0 taken 907223 times.
✓ Branch 1 taken 18461 times.
1851368 for (x = init_x; x < width; x++)
392 1814446 dst[x] = av_clip_pixel(src[x] + offset_val);
393 }
394
2/2
✓ Branch 0 taken 23393 times.
✓ Branch 1 taken 273531 times.
593848 if (borders[3]) {
395 46786 int offset_val = sao_offset_val[0];
396 46786 ptrdiff_t y_stride_dst = stride_dst * (height - 1);
397 46786 ptrdiff_t y_stride_src = stride_src * (height - 1);
398
2/2
✓ Branch 0 taken 1115478 times.
✓ Branch 1 taken 23393 times.
2277742 for (x = init_x; x < width; x++)
399 2230956 dst[x + y_stride_dst] = av_clip_pixel(src[x + y_stride_src] + offset_val);
400 46786 height--;
401 }
402 }
403 721060 }
404
405 38834 static void FUNC(sao_edge_restore_1)(uint8_t *_dst, const uint8_t *_src,
406 ptrdiff_t stride_dst, ptrdiff_t stride_src, const SAOParams *sao,
407 const int *borders, int _width, int _height,
408 int c_idx, const uint8_t *vert_edge,
409 const uint8_t *horiz_edge, const uint8_t *diag_edge)
410 {
411 int x, y;
412 38834 pixel *dst = (pixel *)_dst;
413 38834 const pixel *src = (const pixel *)_src;
414 38834 const int16_t *sao_offset_val = sao->offset_val[c_idx];
415 38834 int sao_eo_class = sao->eo_class[c_idx];
416 38834 int init_x = 0, init_y = 0, width = _width, height = _height;
417
418 38834 stride_dst /= sizeof(pixel);
419 38834 stride_src /= sizeof(pixel);
420
421
2/2
✓ Branch 0 taken 13613 times.
✓ Branch 1 taken 5804 times.
38834 if (sao_eo_class != SAO_EO_VERT) {
422
2/2
✓ Branch 0 taken 1252 times.
✓ Branch 1 taken 12361 times.
27226 if (borders[0]) {
423 2504 int offset_val = sao_offset_val[0];
424
2/2
✓ Branch 0 taken 61472 times.
✓ Branch 1 taken 1252 times.
125448 for (y = 0; y < height; y++) {
425 122944 dst[y * stride_dst] = av_clip_pixel(src[y * stride_src] + offset_val);
426 }
427 2504 init_x = 1;
428 }
429
2/2
✓ Branch 0 taken 795 times.
✓ Branch 1 taken 12818 times.
27226 if (borders[2]) {
430 1590 int offset_val = sao_offset_val[0];
431 1590 int offset = width - 1;
432
2/2
✓ Branch 0 taken 37304 times.
✓ Branch 1 taken 795 times.
76198 for (x = 0; x < height; x++) {
433 74608 dst[x * stride_dst + offset] = av_clip_pixel(src[x * stride_src + offset] + offset_val);
434 }
435 1590 width--;
436 }
437 }
438
2/2
✓ Branch 0 taken 13993 times.
✓ Branch 1 taken 5424 times.
38834 if (sao_eo_class != SAO_EO_HORIZ) {
439
2/2
✓ Branch 0 taken 1963 times.
✓ Branch 1 taken 12030 times.
27986 if (borders[1]) {
440 3926 int offset_val = sao_offset_val[0];
441
2/2
✓ Branch 0 taken 94362 times.
✓ Branch 1 taken 1963 times.
192650 for (x = init_x; x < width; x++)
442 188724 dst[x] = av_clip_pixel(src[x] + offset_val);
443 3926 init_y = 1;
444 }
445
2/2
✓ Branch 0 taken 1584 times.
✓ Branch 1 taken 12409 times.
27986 if (borders[3]) {
446 3168 int offset_val = sao_offset_val[0];
447 3168 ptrdiff_t y_stride_dst = stride_dst * (height - 1);
448 3168 ptrdiff_t y_stride_src = stride_src * (height - 1);
449
2/2
✓ Branch 0 taken 73429 times.
✓ Branch 1 taken 1584 times.
150026 for (x = init_x; x < width; x++)
450 146858 dst[x + y_stride_dst] = av_clip_pixel(src[x + y_stride_src] + offset_val);
451 3168 height--;
452 }
453 }
454
455 {
456
8/8
✓ Branch 0 taken 19253 times.
✓ Branch 1 taken 164 times.
✓ Branch 2 taken 3639 times.
✓ Branch 3 taken 15614 times.
✓ Branch 4 taken 3342 times.
✓ Branch 5 taken 297 times.
✓ Branch 6 taken 3092 times.
✓ Branch 7 taken 250 times.
38834 int save_upper_left = !diag_edge[0] && sao_eo_class == SAO_EO_135D && !borders[0] && !borders[1];
457
8/8
✓ Branch 0 taken 19205 times.
✓ Branch 1 taken 212 times.
✓ Branch 2 taken 4388 times.
✓ Branch 3 taken 14817 times.
✓ Branch 4 taken 3661 times.
✓ Branch 5 taken 727 times.
✓ Branch 6 taken 3437 times.
✓ Branch 7 taken 224 times.
38834 int save_upper_right = !diag_edge[1] && sao_eo_class == SAO_EO_45D && !borders[1] && !borders[2];
458
8/8
✓ Branch 0 taken 19103 times.
✓ Branch 1 taken 314 times.
✓ Branch 2 taken 3587 times.
✓ Branch 3 taken 15516 times.
✓ Branch 4 taken 3388 times.
✓ Branch 5 taken 199 times.
✓ Branch 6 taken 2943 times.
✓ Branch 7 taken 445 times.
38834 int save_lower_right = !diag_edge[2] && sao_eo_class == SAO_EO_135D && !borders[2] && !borders[3];
459
8/8
✓ Branch 0 taken 19155 times.
✓ Branch 1 taken 262 times.
✓ Branch 2 taken 4410 times.
✓ Branch 3 taken 14745 times.
✓ Branch 4 taken 3852 times.
✓ Branch 5 taken 558 times.
✓ Branch 6 taken 3392 times.
✓ Branch 7 taken 460 times.
38834 int save_lower_left = !diag_edge[3] && sao_eo_class == SAO_EO_45D && !borders[0] && !borders[3];
460
461 // Restore pixels that can't be modified
462
4/4
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 19371 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 8 times.
38834 if(vert_edge[0] && sao_eo_class != SAO_EO_VERT) {
463
2/2
✓ Branch 0 taken 1216 times.
✓ Branch 1 taken 38 times.
2508 for(y = init_y+save_upper_left; y< height-save_lower_left; y++)
464 2432 dst[y*stride_dst] = src[y*stride_src];
465 }
466
3/4
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 19325 times.
✓ Branch 2 taken 92 times.
✗ Branch 3 not taken.
38834 if(vert_edge[1] && sao_eo_class != SAO_EO_VERT) {
467
2/2
✓ Branch 0 taken 2812 times.
✓ Branch 1 taken 92 times.
5808 for(y = init_y+save_upper_right; y< height-save_lower_right; y++)
468 5624 dst[y*stride_dst+width-1] = src[y*stride_src+width-1];
469 }
470
471
4/4
✓ Branch 0 taken 130 times.
✓ Branch 1 taken 19287 times.
✓ Branch 2 taken 116 times.
✓ Branch 3 taken 14 times.
38834 if(horiz_edge[0] && sao_eo_class != SAO_EO_HORIZ) {
472
2/2
✓ Branch 0 taken 3700 times.
✓ Branch 1 taken 116 times.
7632 for(x = init_x+save_upper_left; x < width-save_upper_right; x++)
473 7400 dst[x] = src[x];
474 }
475
4/4
✓ Branch 0 taken 234 times.
✓ Branch 1 taken 19183 times.
✓ Branch 2 taken 180 times.
✓ Branch 3 taken 54 times.
38834 if(horiz_edge[1] && sao_eo_class != SAO_EO_HORIZ) {
476
2/2
✓ Branch 0 taken 5742 times.
✓ Branch 1 taken 180 times.
11844 for(x = init_x+save_lower_left; x < width-save_lower_right; x++)
477 11484 dst[(height-1)*stride_dst+x] = src[(height-1)*stride_src+x];
478 }
479
4/4
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 19253 times.
✓ Branch 2 taken 56 times.
✓ Branch 3 taken 108 times.
38834 if(diag_edge[0] && sao_eo_class == SAO_EO_135D)
480 112 dst[0] = src[0];
481
4/4
✓ Branch 0 taken 212 times.
✓ Branch 1 taken 19205 times.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 106 times.
38834 if(diag_edge[1] && sao_eo_class == SAO_EO_45D)
482 212 dst[width-1] = src[width-1];
483
4/4
✓ Branch 0 taken 314 times.
✓ Branch 1 taken 19103 times.
✓ Branch 2 taken 108 times.
✓ Branch 3 taken 206 times.
38834 if(diag_edge[2] && sao_eo_class == SAO_EO_135D)
484 216 dst[stride_dst*(height-1)+width-1] = src[stride_src*(height-1)+width-1];
485
4/4
✓ Branch 0 taken 262 times.
✓ Branch 1 taken 19155 times.
✓ Branch 2 taken 84 times.
✓ Branch 3 taken 178 times.
38834 if(diag_edge[3] && sao_eo_class == SAO_EO_45D)
486 168 dst[stride_dst*(height-1)] = src[stride_src*(height-1)];
487
488 }
489 38834 }
490
491 #undef CMP
492
493 ////////////////////////////////////////////////////////////////////////////////
494 //
495 ////////////////////////////////////////////////////////////////////////////////
496 4751490 static void FUNC(put_hevc_pel_pixels)(int16_t *dst,
497 const uint8_t *_src, ptrdiff_t _srcstride,
498 int height, intptr_t mx, intptr_t my, int width)
499 {
500 int x, y;
501 4751490 const pixel *src = (const pixel *)_src;
502 4751490 ptrdiff_t srcstride = _srcstride / sizeof(pixel);
503
504
2/2
✓ Branch 0 taken 35314934 times.
✓ Branch 1 taken 2375745 times.
75381358 for (y = 0; y < height; y++) {
505
2/2
✓ Branch 0 taken 898412916 times.
✓ Branch 1 taken 35314934 times.
1867455700 for (x = 0; x < width; x++)
506 1796825832 dst[x] = src[x] << (14 - BIT_DEPTH);
507 70629868 src += srcstride;
508 70629868 dst += MAX_PB_SIZE;
509 }
510 4751490 }
511
512 4783994 static void FUNC(put_hevc_pel_uni_pixels)(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride,
513 int height, intptr_t mx, intptr_t my, int width)
514 {
515 int y;
516 4783994 const pixel *src = (const pixel *)_src;
517 4783994 ptrdiff_t srcstride = _srcstride / sizeof(pixel);
518 4783994 pixel *dst = (pixel *)_dst;
519 4783994 ptrdiff_t dststride = _dststride / sizeof(pixel);
520
521
2/2
✓ Branch 0 taken 25285382 times.
✓ Branch 1 taken 2391997 times.
55354758 for (y = 0; y < height; y++) {
522 50570764 memcpy(dst, src, width * sizeof(pixel));
523 50570764 src += srcstride;
524 50570764 dst += dststride;
525 }
526 4783994 }
527
528 5198258 static void FUNC(put_hevc_pel_bi_pixels)(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride,
529 const int16_t *src2,
530 int height, intptr_t mx, intptr_t my, int width)
531 {
532 int x, y;
533 5198258 const pixel *src = (const pixel *)_src;
534 5198258 ptrdiff_t srcstride = _srcstride / sizeof(pixel);
535 5198258 pixel *dst = (pixel *)_dst;
536 5198258 ptrdiff_t dststride = _dststride / sizeof(pixel);
537
538 5198258 int shift = 14 + 1 - BIT_DEPTH;
539 #if BIT_DEPTH < 14
540 5198258 int offset = 1 << (shift - 1);
541 #else
542 int offset = 0;
543 #endif
544
545
2/2
✓ Branch 0 taken 38401358 times.
✓ Branch 1 taken 2599129 times.
82000974 for (y = 0; y < height; y++) {
546
2/2
✓ Branch 0 taken 967620084 times.
✓ Branch 1 taken 38401358 times.
2012042884 for (x = 0; x < width; x++)
547 1935240168 dst[x] = av_clip_pixel(((src[x] << (14 - BIT_DEPTH)) + src2[x] + offset) >> shift);
548 76802716 src += srcstride;
549 76802716 dst += dststride;
550 76802716 src2 += MAX_PB_SIZE;
551 }
552 5198258 }
553
554 145958 static void FUNC(put_hevc_pel_uni_w_pixels)(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride,
555 int height, int denom, int wx, int ox, intptr_t mx, intptr_t my, int width)
556 {
557 int x, y;
558 145958 const pixel *src = (const pixel *)_src;
559 145958 ptrdiff_t srcstride = _srcstride / sizeof(pixel);
560 145958 pixel *dst = (pixel *)_dst;
561 145958 ptrdiff_t dststride = _dststride / sizeof(pixel);
562 145958 int shift = denom + 14 - BIT_DEPTH;
563 #if BIT_DEPTH < 14
564 145958 int offset = 1 << (shift - 1);
565 #else
566 int offset = 0;
567 #endif
568
569 145958 ox = ox * (1 << (BIT_DEPTH - 8));
570
2/2
✓ Branch 0 taken 1640336 times.
✓ Branch 1 taken 72979 times.
3426630 for (y = 0; y < height; y++) {
571
2/2
✓ Branch 0 taken 55907336 times.
✓ Branch 1 taken 1640336 times.
115095344 for (x = 0; x < width; x++)
572 111814672 dst[x] = av_clip_pixel((((src[x] << (14 - BIT_DEPTH)) * wx + offset) >> shift) + ox);
573 3280672 src += srcstride;
574 3280672 dst += dststride;
575 }
576 145958 }
577
578 64154 static void FUNC(put_hevc_pel_bi_w_pixels)(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride,
579 const int16_t *src2,
580 int height, int denom, int wx0, int wx1,
581 int ox0, int ox1, intptr_t mx, intptr_t my, int width)
582 {
583 int x, y;
584 64154 const pixel *src = (const pixel *)_src;
585 64154 ptrdiff_t srcstride = _srcstride / sizeof(pixel);
586 64154 pixel *dst = (pixel *)_dst;
587 64154 ptrdiff_t dststride = _dststride / sizeof(pixel);
588
589 64154 int shift = 14 + 1 - BIT_DEPTH;
590 64154 int log2Wd = denom + shift - 1;
591
592 64154 ox0 = ox0 * (1 << (BIT_DEPTH - 8));
593 64154 ox1 = ox1 * (1 << (BIT_DEPTH - 8));
594
2/2
✓ Branch 0 taken 671000 times.
✓ Branch 1 taken 32077 times.
1406154 for (y = 0; y < height; y++) {
595
2/2
✓ Branch 0 taken 21890728 times.
✓ Branch 1 taken 671000 times.
45123456 for (x = 0; x < width; x++) {
596 43781456 dst[x] = av_clip_pixel(( (src[x] << (14 - BIT_DEPTH)) * wx1 + src2[x] * wx0 + (ox0 + ox1 + 1) * (1 << log2Wd)) >> (log2Wd + 1));
597 }
598 1342000 src += srcstride;
599 1342000 dst += dststride;
600 1342000 src2 += MAX_PB_SIZE;
601 }
602 64154 }
603
604 ////////////////////////////////////////////////////////////////////////////////
605 //
606 ////////////////////////////////////////////////////////////////////////////////
607 #define QPEL_FILTER(src, stride) \
608 (filter[0] * src[x - 3 * stride] + \
609 filter[1] * src[x - 2 * stride] + \
610 filter[2] * src[x - stride] + \
611 filter[3] * src[x ] + \
612 filter[4] * src[x + stride] + \
613 filter[5] * src[x + 2 * stride] + \
614 filter[6] * src[x + 3 * stride] + \
615 filter[7] * src[x + 4 * stride])
616
617 1367194 static void FUNC(put_hevc_qpel_h)(int16_t *dst,
618 const uint8_t *_src, ptrdiff_t _srcstride,
619 int height, intptr_t mx, intptr_t my, int width)
620 {
621 int x, y;
622 1367194 const pixel *src = (const pixel*)_src;
623 1367194 ptrdiff_t srcstride = _srcstride / sizeof(pixel);
624 1367194 const int8_t *filter = ff_hevc_qpel_filters[mx - 1];
625
2/2
✓ Branch 0 taken 14792996 times.
✓ Branch 1 taken 683597 times.
30953186 for (y = 0; y < height; y++) {
626
2/2
✓ Branch 0 taken 486842632 times.
✓ Branch 1 taken 14792996 times.
1003271256 for (x = 0; x < width; x++)
627 973685264 dst[x] = QPEL_FILTER(src, 1) >> (BIT_DEPTH - 8);
628 29585992 src += srcstride;
629 29585992 dst += MAX_PB_SIZE;
630 }
631 1367194 }
632
633 1070912 static void FUNC(put_hevc_qpel_v)(int16_t *dst,
634 const uint8_t *_src, ptrdiff_t _srcstride,
635 int height, intptr_t mx, intptr_t my, int width)
636 {
637 int x, y;
638 1070912 const pixel *src = (const pixel*)_src;
639 1070912 ptrdiff_t srcstride = _srcstride / sizeof(pixel);
640 1070912 const int8_t *filter = ff_hevc_qpel_filters[my - 1];
641
2/2
✓ Branch 0 taken 11550632 times.
✓ Branch 1 taken 535456 times.
24172176 for (y = 0; y < height; y++) {
642
2/2
✓ Branch 0 taken 379349896 times.
✓ Branch 1 taken 11550632 times.
781801056 for (x = 0; x < width; x++)
643 758699792 dst[x] = QPEL_FILTER(src, srcstride) >> (BIT_DEPTH - 8);
644 23101264 src += srcstride;
645 23101264 dst += MAX_PB_SIZE;
646 }
647 1070912 }
648
649 3342990 static void FUNC(put_hevc_qpel_hv)(int16_t *dst,
650 const uint8_t *_src,
651 ptrdiff_t _srcstride,
652 int height, intptr_t mx,
653 intptr_t my, int width)
654 {
655 int x, y;
656 const int8_t *filter;
657 3342990 const pixel *src = (const pixel*)_src;
658 3342990 ptrdiff_t srcstride = _srcstride / sizeof(pixel);
659 int16_t tmp_array[(MAX_PB_SIZE + QPEL_EXTRA) * MAX_PB_SIZE];
660 3342990 int16_t *tmp = tmp_array;
661
662 3342990 src -= QPEL_EXTRA_BEFORE * srcstride;
663 3342990 filter = ff_hevc_qpel_filters[mx - 1];
664
2/2
✓ Branch 0 taken 46886537 times.
✓ Branch 1 taken 1671495 times.
97116064 for (y = 0; y < height + QPEL_EXTRA; y++) {
665
2/2
✓ Branch 0 taken 1349183996 times.
✓ Branch 1 taken 46886537 times.
2792141066 for (x = 0; x < width; x++)
666 2698367992 tmp[x] = QPEL_FILTER(src, 1) >> (BIT_DEPTH - 8);
667 93773074 src += srcstride;
668 93773074 tmp += MAX_PB_SIZE;
669 }
670
671 3342990 tmp = tmp_array + QPEL_EXTRA_BEFORE * MAX_PB_SIZE;
672 3342990 filter = ff_hevc_qpel_filters[my - 1];
673
2/2
✓ Branch 0 taken 35186072 times.
✓ Branch 1 taken 1671495 times.
73715134 for (y = 0; y < height; y++) {
674
2/2
✓ Branch 0 taken 1105803656 times.
✓ Branch 1 taken 35186072 times.
2281979456 for (x = 0; x < width; x++)
675 2211607312 dst[x] = QPEL_FILTER(tmp, MAX_PB_SIZE) >> 6;
676 70372144 tmp += MAX_PB_SIZE;
677 70372144 dst += MAX_PB_SIZE;
678 }
679 3342990 }
680
681 1570408 static void FUNC(put_hevc_qpel_uni_h)(uint8_t *_dst, ptrdiff_t _dststride,
682 const uint8_t *_src, ptrdiff_t _srcstride,
683 int height, intptr_t mx, intptr_t my, int width)
684 {
685 int x, y;
686 1570408 const pixel *src = (const pixel*)_src;
687 1570408 ptrdiff_t srcstride = _srcstride / sizeof(pixel);
688 1570408 pixel *dst = (pixel *)_dst;
689 1570408 ptrdiff_t dststride = _dststride / sizeof(pixel);
690 1570408 const int8_t *filter = ff_hevc_qpel_filters[mx - 1];
691 1570408 int shift = 14 - BIT_DEPTH;
692
693 #if BIT_DEPTH < 14
694 1570408 int offset = 1 << (shift - 1);
695 #else
696 int offset = 0;
697 #endif
698
699
2/2
✓ Branch 0 taken 11363824 times.
✓ Branch 1 taken 785204 times.
24298056 for (y = 0; y < height; y++) {
700
2/2
✓ Branch 0 taken 247342760 times.
✓ Branch 1 taken 11363824 times.
517413168 for (x = 0; x < width; x++)
701 494685520 dst[x] = av_clip_pixel(((QPEL_FILTER(src, 1) >> (BIT_DEPTH - 8)) + offset) >> shift);
702 22727648 src += srcstride;
703 22727648 dst += dststride;
704 }
705 1570408 }
706
707 1287348 static void FUNC(put_hevc_qpel_bi_h)(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride,
708 const int16_t *src2,
709 int height, intptr_t mx, intptr_t my, int width)
710 {
711 int x, y;
712 1287348 const pixel *src = (const pixel*)_src;
713 1287348 ptrdiff_t srcstride = _srcstride / sizeof(pixel);
714 1287348 pixel *dst = (pixel *)_dst;
715 1287348 ptrdiff_t dststride = _dststride / sizeof(pixel);
716
717 1287348 const int8_t *filter = ff_hevc_qpel_filters[mx - 1];
718
719 1287348 int shift = 14 + 1 - BIT_DEPTH;
720 #if BIT_DEPTH < 14
721 1287348 int offset = 1 << (shift - 1);
722 #else
723 int offset = 0;
724 #endif
725
726
2/2
✓ Branch 0 taken 13936548 times.
✓ Branch 1 taken 643674 times.
29160444 for (y = 0; y < height; y++) {
727
2/2
✓ Branch 0 taken 457729096 times.
✓ Branch 1 taken 13936548 times.
943331288 for (x = 0; x < width; x++)
728 915458192 dst[x] = av_clip_pixel(((QPEL_FILTER(src, 1) >> (BIT_DEPTH - 8)) + src2[x] + offset) >> shift);
729 27873096 src += srcstride;
730 27873096 dst += dststride;
731 27873096 src2 += MAX_PB_SIZE;
732 }
733 1287348 }
734
735 1371102 static void FUNC(put_hevc_qpel_uni_v)(uint8_t *_dst, ptrdiff_t _dststride,
736 const uint8_t *_src, ptrdiff_t _srcstride,
737 int height, intptr_t mx, intptr_t my, int width)
738 {
739 int x, y;
740 1371102 const pixel *src = (const pixel*)_src;
741 1371102 ptrdiff_t srcstride = _srcstride / sizeof(pixel);
742 1371102 pixel *dst = (pixel *)_dst;
743 1371102 ptrdiff_t dststride = _dststride / sizeof(pixel);
744 1371102 const int8_t *filter = ff_hevc_qpel_filters[my - 1];
745 1371102 int shift = 14 - BIT_DEPTH;
746
747 #if BIT_DEPTH < 14
748 1371102 int offset = 1 << (shift - 1);
749 #else
750 int offset = 0;
751 #endif
752
753
2/2
✓ Branch 0 taken 10197500 times.
✓ Branch 1 taken 685551 times.
21766102 for (y = 0; y < height; y++) {
754
2/2
✓ Branch 0 taken 237113384 times.
✓ Branch 1 taken 10197500 times.
494621768 for (x = 0; x < width; x++)
755 474226768 dst[x] = av_clip_pixel(((QPEL_FILTER(src, srcstride) >> (BIT_DEPTH - 8)) + offset) >> shift);
756 20395000 src += srcstride;
757 20395000 dst += dststride;
758 }
759 1371102 }
760
761
762 1024872 static void FUNC(put_hevc_qpel_bi_v)(uint8_t *_dst, ptrdiff_t _dststride,
763 const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2,
764 int height, intptr_t mx, intptr_t my, int width)
765 {
766 int x, y;
767 1024872 const pixel *src = (const pixel*)_src;
768 1024872 ptrdiff_t srcstride = _srcstride / sizeof(pixel);
769 1024872 pixel *dst = (pixel *)_dst;
770 1024872 ptrdiff_t dststride = _dststride / sizeof(pixel);
771
772 1024872 const int8_t *filter = ff_hevc_qpel_filters[my - 1];
773
774 1024872 int shift = 14 + 1 - BIT_DEPTH;
775 #if BIT_DEPTH < 14
776 1024872 int offset = 1 << (shift - 1);
777 #else
778 int offset = 0;
779 #endif
780
781
2/2
✓ Branch 0 taken 10864452 times.
✓ Branch 1 taken 512436 times.
22753776 for (y = 0; y < height; y++) {
782
2/2
✓ Branch 0 taken 348786952 times.
✓ Branch 1 taken 10864452 times.
719302808 for (x = 0; x < width; x++)
783 697573904 dst[x] = av_clip_pixel(((QPEL_FILTER(src, srcstride) >> (BIT_DEPTH - 8)) + src2[x] + offset) >> shift);
784 21728904 src += srcstride;
785 21728904 dst += dststride;
786 21728904 src2 += MAX_PB_SIZE;
787 }
788 1024872 }
789
790 4327134 static void FUNC(put_hevc_qpel_uni_hv)(uint8_t *_dst, ptrdiff_t _dststride,
791 const uint8_t *_src, ptrdiff_t _srcstride,
792 int height, intptr_t mx, intptr_t my, int width)
793 {
794 int x, y;
795 const int8_t *filter;
796 4327134 const pixel *src = (const pixel*)_src;
797 4327134 ptrdiff_t srcstride = _srcstride / sizeof(pixel);
798 4327134 pixel *dst = (pixel *)_dst;
799 4327134 ptrdiff_t dststride = _dststride / sizeof(pixel);
800 int16_t tmp_array[(MAX_PB_SIZE + QPEL_EXTRA) * MAX_PB_SIZE];
801 4327134 int16_t *tmp = tmp_array;
802 4327134 int shift = 14 - BIT_DEPTH;
803
804 #if BIT_DEPTH < 14
805 4327134 int offset = 1 << (shift - 1);
806 #else
807 int offset = 0;
808 #endif
809
810 4327134 src -= QPEL_EXTRA_BEFORE * srcstride;
811 4327134 filter = ff_hevc_qpel_filters[mx - 1];
812
2/2
✓ Branch 0 taken 46357257 times.
✓ Branch 1 taken 2163567 times.
97041648 for (y = 0; y < height + QPEL_EXTRA; y++) {
813
2/2
✓ Branch 0 taken 871399616 times.
✓ Branch 1 taken 46357257 times.
1835513746 for (x = 0; x < width; x++)
814 1742799232 tmp[x] = QPEL_FILTER(src, 1) >> (BIT_DEPTH - 8);
815 92714514 src += srcstride;
816 92714514 tmp += MAX_PB_SIZE;
817 }
818
819 4327134 tmp = tmp_array + QPEL_EXTRA_BEFORE * MAX_PB_SIZE;
820 4327134 filter = ff_hevc_qpel_filters[my - 1];
821
822
2/2
✓ Branch 0 taken 31212288 times.
✓ Branch 1 taken 2163567 times.
66751710 for (y = 0; y < height; y++) {
823
2/2
✓ Branch 0 taken 658027688 times.
✓ Branch 1 taken 31212288 times.
1378479952 for (x = 0; x < width; x++)
824 1316055376 dst[x] = av_clip_pixel(((QPEL_FILTER(tmp, MAX_PB_SIZE) >> 6) + offset) >> shift);
825 62424576 tmp += MAX_PB_SIZE;
826 62424576 dst += dststride;
827 }
828 4327134 }
829
830 3195682 static void FUNC(put_hevc_qpel_bi_hv)(uint8_t *_dst, ptrdiff_t _dststride,
831 const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2,
832 int height, intptr_t mx, intptr_t my, int width)
833 {
834 int x, y;
835 const int8_t *filter;
836 3195682 const pixel *src = (const pixel*)_src;
837 3195682 ptrdiff_t srcstride = _srcstride / sizeof(pixel);
838 3195682 pixel *dst = (pixel *)_dst;
839 3195682 ptrdiff_t dststride = _dststride / sizeof(pixel);
840 int16_t tmp_array[(MAX_PB_SIZE + QPEL_EXTRA) * MAX_PB_SIZE];
841 3195682 int16_t *tmp = tmp_array;
842 3195682 int shift = 14 + 1 - BIT_DEPTH;
843 #if BIT_DEPTH < 14
844 3195682 int offset = 1 << (shift - 1);
845 #else
846 int offset = 0;
847 #endif
848
849 3195682 src -= QPEL_EXTRA_BEFORE * srcstride;
850 3195682 filter = ff_hevc_qpel_filters[mx - 1];
851
2/2
✓ Branch 0 taken 44950087 times.
✓ Branch 1 taken 1597841 times.
93095856 for (y = 0; y < height + QPEL_EXTRA; y++) {
852
2/2
✓ Branch 0 taken 1304439384 times.
✓ Branch 1 taken 44950087 times.
2698778942 for (x = 0; x < width; x++)
853 2608878768 tmp[x] = QPEL_FILTER(src, 1) >> (BIT_DEPTH - 8);
854 89900174 src += srcstride;
855 89900174 tmp += MAX_PB_SIZE;
856 }
857
858 3195682 tmp = tmp_array + QPEL_EXTRA_BEFORE * MAX_PB_SIZE;
859 3195682 filter = ff_hevc_qpel_filters[my - 1];
860
861
2/2
✓ Branch 0 taken 33765200 times.
✓ Branch 1 taken 1597841 times.
70726082 for (y = 0; y < height; y++) {
862
2/2
✓ Branch 0 taken 1070725512 times.
✓ Branch 1 taken 33765200 times.
2208981424 for (x = 0; x < width; x++)
863 2141451024 dst[x] = av_clip_pixel(((QPEL_FILTER(tmp, MAX_PB_SIZE) >> 6) + src2[x] + offset) >> shift);
864 67530400 tmp += MAX_PB_SIZE;
865 67530400 dst += dststride;
866 67530400 src2 += MAX_PB_SIZE;
867 }
868 3195682 }
869
870 36230 static void FUNC(put_hevc_qpel_uni_w_h)(uint8_t *_dst, ptrdiff_t _dststride,
871 const uint8_t *_src, ptrdiff_t _srcstride,
872 int height, int denom, int wx, int ox,
873 intptr_t mx, intptr_t my, int width)
874 {
875 int x, y;
876 36230 const pixel *src = (const pixel*)_src;
877 36230 ptrdiff_t srcstride = _srcstride / sizeof(pixel);
878 36230 pixel *dst = (pixel *)_dst;
879 36230 ptrdiff_t dststride = _dststride / sizeof(pixel);
880 36230 const int8_t *filter = ff_hevc_qpel_filters[mx - 1];
881 36230 int shift = denom + 14 - BIT_DEPTH;
882 #if BIT_DEPTH < 14
883 36230 int offset = 1 << (shift - 1);
884 #else
885 int offset = 0;
886 #endif
887
888 36230 ox = ox * (1 << (BIT_DEPTH - 8));
889
2/2
✓ Branch 0 taken 381616 times.
✓ Branch 1 taken 18115 times.
799462 for (y = 0; y < height; y++) {
890
2/2
✓ Branch 0 taken 12448016 times.
✓ Branch 1 taken 381616 times.
25659264 for (x = 0; x < width; x++)
891 24896032 dst[x] = av_clip_pixel((((QPEL_FILTER(src, 1) >> (BIT_DEPTH - 8)) * wx + offset) >> shift) + ox);
892 763232 src += srcstride;
893 763232 dst += dststride;
894 }
895 36230 }
896
897 22810 static void FUNC(put_hevc_qpel_bi_w_h)(uint8_t *_dst, ptrdiff_t _dststride,
898 const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2,
899 int height, int denom, int wx0, int wx1,
900 int ox0, int ox1, intptr_t mx, intptr_t my, int width)
901 {
902 int x, y;
903 22810 const pixel *src = (const pixel*)_src;
904 22810 ptrdiff_t srcstride = _srcstride / sizeof(pixel);
905 22810 pixel *dst = (pixel *)_dst;
906 22810 ptrdiff_t dststride = _dststride / sizeof(pixel);
907
908 22810 const int8_t *filter = ff_hevc_qpel_filters[mx - 1];
909
910 22810 int shift = 14 + 1 - BIT_DEPTH;
911 22810 int log2Wd = denom + shift - 1;
912
913 22810 ox0 = ox0 * (1 << (BIT_DEPTH - 8));
914 22810 ox1 = ox1 * (1 << (BIT_DEPTH - 8));
915
2/2
✓ Branch 0 taken 278600 times.
✓ Branch 1 taken 11405 times.
580010 for (y = 0; y < height; y++) {
916
2/2
✓ Branch 0 taken 9869200 times.
✓ Branch 1 taken 278600 times.
20295600 for (x = 0; x < width; x++)
917 19738400 dst[x] = av_clip_pixel(((QPEL_FILTER(src, 1) >> (BIT_DEPTH - 8)) * wx1 + src2[x] * wx0 +
918 ((ox0 + ox1 + 1) * (1 << log2Wd))) >> (log2Wd + 1));
919 557200 src += srcstride;
920 557200 dst += dststride;
921 557200 src2 += MAX_PB_SIZE;
922 }
923 22810 }
924
925 32950 static void FUNC(put_hevc_qpel_uni_w_v)(uint8_t *_dst, ptrdiff_t _dststride,
926 const uint8_t *_src, ptrdiff_t _srcstride,
927 int height, int denom, int wx, int ox,
928 intptr_t mx, intptr_t my, int width)
929 {
930 int x, y;
931 32950 const pixel *src = (const pixel*)_src;
932 32950 ptrdiff_t srcstride = _srcstride / sizeof(pixel);
933 32950 pixel *dst = (pixel *)_dst;
934 32950 ptrdiff_t dststride = _dststride / sizeof(pixel);
935 32950 const int8_t *filter = ff_hevc_qpel_filters[my - 1];
936 32950 int shift = denom + 14 - BIT_DEPTH;
937 #if BIT_DEPTH < 14
938 32950 int offset = 1 << (shift - 1);
939 #else
940 int offset = 0;
941 #endif
942
943 32950 ox = ox * (1 << (BIT_DEPTH - 8));
944
2/2
✓ Branch 0 taken 318884 times.
✓ Branch 1 taken 16475 times.
670718 for (y = 0; y < height; y++) {
945
2/2
✓ Branch 0 taken 9467248 times.
✓ Branch 1 taken 318884 times.
19572264 for (x = 0; x < width; x++)
946 18934496 dst[x] = av_clip_pixel((((QPEL_FILTER(src, srcstride) >> (BIT_DEPTH - 8)) * wx + offset) >> shift) + ox);
947 637768 src += srcstride;
948 637768 dst += dststride;
949 }
950 32950 }
951
952 20448 static void FUNC(put_hevc_qpel_bi_w_v)(uint8_t *_dst, ptrdiff_t _dststride,
953 const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2,
954 int height, int denom, int wx0, int wx1,
955 int ox0, int ox1, intptr_t mx, intptr_t my, int width)
956 {
957 int x, y;
958 20448 const pixel *src = (const pixel*)_src;
959 20448 ptrdiff_t srcstride = _srcstride / sizeof(pixel);
960 20448 pixel *dst = (pixel *)_dst;
961 20448 ptrdiff_t dststride = _dststride / sizeof(pixel);
962
963 20448 const int8_t *filter = ff_hevc_qpel_filters[my - 1];
964
965 20448 int shift = 14 + 1 - BIT_DEPTH;
966 20448 int log2Wd = denom + shift - 1;
967
968 20448 ox0 = ox0 * (1 << (BIT_DEPTH - 8));
969 20448 ox1 = ox1 * (1 << (BIT_DEPTH - 8));
970
2/2
✓ Branch 0 taken 236324 times.
✓ Branch 1 taken 10224 times.
493096 for (y = 0; y < height; y++) {
971
2/2
✓ Branch 0 taken 7942032 times.
✓ Branch 1 taken 236324 times.
16356712 for (x = 0; x < width; x++)
972 15884064 dst[x] = av_clip_pixel(((QPEL_FILTER(src, srcstride) >> (BIT_DEPTH - 8)) * wx1 + src2[x] * wx0 +
973 ((ox0 + ox1 + 1) * (1 << log2Wd))) >> (log2Wd + 1));
974 472648 src += srcstride;
975 472648 dst += dststride;
976 472648 src2 += MAX_PB_SIZE;
977 }
978 20448 }
979
980 102878 static void FUNC(put_hevc_qpel_uni_w_hv)(uint8_t *_dst, ptrdiff_t _dststride,
981 const uint8_t *_src, ptrdiff_t _srcstride,
982 int height, int denom, int wx, int ox,
983 intptr_t mx, intptr_t my, int width)
984 {
985 int x, y;
986 const int8_t *filter;
987 102878 const pixel *src = (const pixel*)_src;
988 102878 ptrdiff_t srcstride = _srcstride / sizeof(pixel);
989 102878 pixel *dst = (pixel *)_dst;
990 102878 ptrdiff_t dststride = _dststride / sizeof(pixel);
991 int16_t tmp_array[(MAX_PB_SIZE + QPEL_EXTRA) * MAX_PB_SIZE];
992 102878 int16_t *tmp = tmp_array;
993 102878 int shift = denom + 14 - BIT_DEPTH;
994 #if BIT_DEPTH < 14
995 102878 int offset = 1 << (shift - 1);
996 #else
997 int offset = 0;
998 #endif
999
1000 102878 src -= QPEL_EXTRA_BEFORE * srcstride;
1001 102878 filter = ff_hevc_qpel_filters[mx - 1];
1002
2/2
✓ Branch 0 taken 1372533 times.
✓ Branch 1 taken 51439 times.
2847944 for (y = 0; y < height + QPEL_EXTRA; y++) {
1003
2/2
✓ Branch 0 taken 37487844 times.
✓ Branch 1 taken 1372533 times.
77720754 for (x = 0; x < width; x++)
1004 74975688 tmp[x] = QPEL_FILTER(src, 1) >> (BIT_DEPTH - 8);
1005 2745066 src += srcstride;
1006 2745066 tmp += MAX_PB_SIZE;
1007 }
1008
1009 102878 tmp = tmp_array + QPEL_EXTRA_BEFORE * MAX_PB_SIZE;
1010 102878 filter = ff_hevc_qpel_filters[my - 1];
1011
1012 102878 ox = ox * (1 << (BIT_DEPTH - 8));
1013
2/2
✓ Branch 0 taken 1012460 times.
✓ Branch 1 taken 51439 times.
2127798 for (y = 0; y < height; y++) {
1014
2/2
✓ Branch 0 taken 30718032 times.
✓ Branch 1 taken 1012460 times.
63460984 for (x = 0; x < width; x++)
1015 61436064 dst[x] = av_clip_pixel((((QPEL_FILTER(tmp, MAX_PB_SIZE) >> 6) * wx + offset) >> shift) + ox);
1016 2024920 tmp += MAX_PB_SIZE;
1017 2024920 dst += dststride;
1018 }
1019 102878 }
1020
1021 71042 static void FUNC(put_hevc_qpel_bi_w_hv)(uint8_t *_dst, ptrdiff_t _dststride,
1022 const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2,
1023 int height, int denom, int wx0, int wx1,
1024 int ox0, int ox1, intptr_t mx, intptr_t my, int width)
1025 {
1026 int x, y;
1027 const int8_t *filter;
1028 71042 const pixel *src = (const pixel*)_src;
1029 71042 ptrdiff_t srcstride = _srcstride / sizeof(pixel);
1030 71042 pixel *dst = (pixel *)_dst;
1031 71042 ptrdiff_t dststride = _dststride / sizeof(pixel);
1032 int16_t tmp_array[(MAX_PB_SIZE + QPEL_EXTRA) * MAX_PB_SIZE];
1033 71042 int16_t *tmp = tmp_array;
1034 71042 int shift = 14 + 1 - BIT_DEPTH;
1035 71042 int log2Wd = denom + shift - 1;
1036
1037 71042 src -= QPEL_EXTRA_BEFORE * srcstride;
1038 71042 filter = ff_hevc_qpel_filters[mx - 1];
1039
2/2
✓ Branch 0 taken 1131207 times.
✓ Branch 1 taken 35521 times.
2333456 for (y = 0; y < height + QPEL_EXTRA; y++) {
1040
2/2
✓ Branch 0 taken 36956072 times.
✓ Branch 1 taken 1131207 times.
76174558 for (x = 0; x < width; x++)
1041 73912144 tmp[x] = QPEL_FILTER(src, 1) >> (BIT_DEPTH - 8);
1042 2262414 src += srcstride;
1043 2262414 tmp += MAX_PB_SIZE;
1044 }
1045
1046 71042 tmp = tmp_array + QPEL_EXTRA_BEFORE * MAX_PB_SIZE;
1047 71042 filter = ff_hevc_qpel_filters[my - 1];
1048
1049 71042 ox0 = ox0 * (1 << (BIT_DEPTH - 8));
1050 71042 ox1 = ox1 * (1 << (BIT_DEPTH - 8));
1051
2/2
✓ Branch 0 taken 882560 times.
✓ Branch 1 taken 35521 times.
1836162 for (y = 0; y < height; y++) {
1052
2/2
✓ Branch 0 taken 30984848 times.
✓ Branch 1 taken 882560 times.
63734816 for (x = 0; x < width; x++)
1053 61969696 dst[x] = av_clip_pixel(((QPEL_FILTER(tmp, MAX_PB_SIZE) >> 6) * wx1 + src2[x] * wx0 +
1054 ((ox0 + ox1 + 1) * (1 << log2Wd))) >> (log2Wd + 1));
1055 1765120 tmp += MAX_PB_SIZE;
1056 1765120 dst += dststride;
1057 1765120 src2 += MAX_PB_SIZE;
1058 }
1059 71042 }
1060
1061 ////////////////////////////////////////////////////////////////////////////////
1062 //
1063 ////////////////////////////////////////////////////////////////////////////////
1064 #define EPEL_FILTER(src, stride) \
1065 (filter[0] * src[x - stride] + \
1066 filter[1] * src[x] + \
1067 filter[2] * src[x + stride] + \
1068 filter[3] * src[x + 2 * stride])
1069
1070 2148602 static void FUNC(put_hevc_epel_h)(int16_t *dst,
1071 const uint8_t *_src, ptrdiff_t _srcstride,
1072 int height, intptr_t mx, intptr_t my, int width)
1073 {
1074 int x, y;
1075 2148602 const pixel *src = (const pixel *)_src;
1076 2148602 ptrdiff_t srcstride = _srcstride / sizeof(pixel);
1077 2148602 const int8_t *filter = ff_hevc_epel_filters[mx - 1];
1078
2/2
✓ Branch 0 taken 12458290 times.
✓ Branch 1 taken 1074301 times.
27065182 for (y = 0; y < height; y++) {
1079
2/2
✓ Branch 0 taken 201156308 times.
✓ Branch 1 taken 12458290 times.
427229196 for (x = 0; x < width; x++)
1080 402312616 dst[x] = EPEL_FILTER(src, 1) >> (BIT_DEPTH - 8);
1081 24916580 src += srcstride;
1082 24916580 dst += MAX_PB_SIZE;
1083 }
1084 2148602 }
1085
1086 1491966 static void FUNC(put_hevc_epel_v)(int16_t *dst,
1087 const uint8_t *_src, ptrdiff_t _srcstride,
1088 int height, intptr_t mx, intptr_t my, int width)
1089 {
1090 int x, y;
1091 1491966 const pixel *src = (const pixel *)_src;
1092 1491966 ptrdiff_t srcstride = _srcstride / sizeof(pixel);
1093 1491966 const int8_t *filter = ff_hevc_epel_filters[my - 1];
1094
1095
2/2
✓ Branch 0 taken 9097742 times.
✓ Branch 1 taken 745983 times.
19687450 for (y = 0; y < height; y++) {
1096
2/2
✓ Branch 0 taken 154103796 times.
✓ Branch 1 taken 9097742 times.
326403076 for (x = 0; x < width; x++)
1097 308207592 dst[x] = EPEL_FILTER(src, srcstride) >> (BIT_DEPTH - 8);
1098 18195484 src += srcstride;
1099 18195484 dst += MAX_PB_SIZE;
1100 }
1101 1491966 }
1102
1103 8511430 static void FUNC(put_hevc_epel_hv)(int16_t *dst,
1104 const uint8_t *_src, ptrdiff_t _srcstride,
1105 int height, intptr_t mx, intptr_t my, int width)
1106 {
1107 int x, y;
1108 8511430 const pixel *src = (const pixel *)_src;
1109 8511430 ptrdiff_t srcstride = _srcstride / sizeof(pixel);
1110 8511430 const int8_t *filter = ff_hevc_epel_filters[mx - 1];
1111 int16_t tmp_array[(MAX_PB_SIZE + EPEL_EXTRA) * MAX_PB_SIZE];
1112 8511430 int16_t *tmp = tmp_array;
1113
1114 8511430 src -= EPEL_EXTRA_BEFORE * srcstride;
1115
1116
2/2
✓ Branch 0 taken 60681831 times.
✓ Branch 1 taken 4255715 times.
129875092 for (y = 0; y < height + EPEL_EXTRA; y++) {
1117
2/2
✓ Branch 0 taken 886091878 times.
✓ Branch 1 taken 60681831 times.
1893547418 for (x = 0; x < width; x++)
1118 1772183756 tmp[x] = EPEL_FILTER(src, 1) >> (BIT_DEPTH - 8);
1119 121363662 src += srcstride;
1120 121363662 tmp += MAX_PB_SIZE;
1121 }
1122
1123 8511430 tmp = tmp_array + EPEL_EXTRA_BEFORE * MAX_PB_SIZE;
1124 8511430 filter = ff_hevc_epel_filters[my - 1];
1125
1126
2/2
✓ Branch 0 taken 47914686 times.
✓ Branch 1 taken 4255715 times.
104340802 for (y = 0; y < height; y++) {
1127
2/2
✓ Branch 0 taken 751566868 times.
✓ Branch 1 taken 47914686 times.
1598963108 for (x = 0; x < width; x++)
1128 1503133736 dst[x] = EPEL_FILTER(tmp, MAX_PB_SIZE) >> 6;
1129 95829372 tmp += MAX_PB_SIZE;
1130 95829372 dst += MAX_PB_SIZE;
1131 }
1132 8511430 }
1133
1134 2564074 static void FUNC(put_hevc_epel_uni_h)(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride,
1135 int height, intptr_t mx, intptr_t my, int width)
1136 {
1137 int x, y;
1138 2564074 const pixel *src = (const pixel *)_src;
1139 2564074 ptrdiff_t srcstride = _srcstride / sizeof(pixel);
1140 2564074 pixel *dst = (pixel *)_dst;
1141 2564074 ptrdiff_t dststride = _dststride / sizeof(pixel);
1142 2564074 const int8_t *filter = ff_hevc_epel_filters[mx - 1];
1143 2564074 int shift = 14 - BIT_DEPTH;
1144 #if BIT_DEPTH < 14
1145 2564074 int offset = 1 << (shift - 1);
1146 #else
1147 int offset = 0;
1148 #endif
1149
1150
2/2
✓ Branch 0 taken 9225530 times.
✓ Branch 1 taken 1282037 times.
21015134 for (y = 0; y < height; y++) {
1151
2/2
✓ Branch 0 taken 97805140 times.
✓ Branch 1 taken 9225530 times.
214061340 for (x = 0; x < width; x++)
1152 195610280 dst[x] = av_clip_pixel(((EPEL_FILTER(src, 1) >> (BIT_DEPTH - 8)) + offset) >> shift);
1153 18451060 src += srcstride;
1154 18451060 dst += dststride;
1155 }
1156 2564074 }
1157
1158 2020670 static void FUNC(put_hevc_epel_bi_h)(uint8_t *_dst, ptrdiff_t _dststride,
1159 const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2,
1160 int height, intptr_t mx, intptr_t my, int width)
1161 {
1162 int x, y;
1163 2020670 const pixel *src = (const pixel *)_src;
1164 2020670 ptrdiff_t srcstride = _srcstride / sizeof(pixel);
1165 2020670 pixel *dst = (pixel *)_dst;
1166 2020670 ptrdiff_t dststride = _dststride / sizeof(pixel);
1167 2020670 const int8_t *filter = ff_hevc_epel_filters[mx - 1];
1168 2020670 int shift = 14 + 1 - BIT_DEPTH;
1169 #if BIT_DEPTH < 14
1170 2020670 int offset = 1 << (shift - 1);
1171 #else
1172 int offset = 0;
1173 #endif
1174
1175
2/2
✓ Branch 0 taken 11523918 times.
✓ Branch 1 taken 1010335 times.
25068506 for (y = 0; y < height; y++) {
1176
2/2
✓ Branch 0 taken 186679348 times.
✓ Branch 1 taken 11523918 times.
396406532 for (x = 0; x < width; x++) {
1177 373358696 dst[x] = av_clip_pixel(((EPEL_FILTER(src, 1) >> (BIT_DEPTH - 8)) + src2[x] + offset) >> shift);
1178 }
1179 23047836 dst += dststride;
1180 23047836 src += srcstride;
1181 23047836 src2 += MAX_PB_SIZE;
1182 }
1183 2020670 }
1184
1185 2092498 static void FUNC(put_hevc_epel_uni_v)(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride,
1186 int height, intptr_t mx, intptr_t my, int width)
1187 {
1188 int x, y;
1189 2092498 const pixel *src = (const pixel *)_src;
1190 2092498 ptrdiff_t srcstride = _srcstride / sizeof(pixel);
1191 2092498 pixel *dst = (pixel *)_dst;
1192 2092498 ptrdiff_t dststride = _dststride / sizeof(pixel);
1193 2092498 const int8_t *filter = ff_hevc_epel_filters[my - 1];
1194 2092498 int shift = 14 - BIT_DEPTH;
1195 #if BIT_DEPTH < 14
1196 2092498 int offset = 1 << (shift - 1);
1197 #else
1198 int offset = 0;
1199 #endif
1200
1201
2/2
✓ Branch 0 taken 7802770 times.
✓ Branch 1 taken 1046249 times.
17698038 for (y = 0; y < height; y++) {
1202
2/2
✓ Branch 0 taken 89203556 times.
✓ Branch 1 taken 7802770 times.
194012652 for (x = 0; x < width; x++)
1203 178407112 dst[x] = av_clip_pixel(((EPEL_FILTER(src, srcstride) >> (BIT_DEPTH - 8)) + offset) >> shift);
1204 15605540 src += srcstride;
1205 15605540 dst += dststride;
1206 }
1207 2092498 }
1208
1209 1448070 static void FUNC(put_hevc_epel_bi_v)(uint8_t *_dst, ptrdiff_t _dststride,
1210 const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2,
1211 int height, intptr_t mx, intptr_t my, int width)
1212 {
1213 int x, y;
1214 1448070 const pixel *src = (const pixel *)_src;
1215 1448070 ptrdiff_t srcstride = _srcstride / sizeof(pixel);
1216 1448070 const int8_t *filter = ff_hevc_epel_filters[my - 1];
1217 1448070 pixel *dst = (pixel *)_dst;
1218 1448070 ptrdiff_t dststride = _dststride / sizeof(pixel);
1219 1448070 int shift = 14 + 1 - BIT_DEPTH;
1220 #if BIT_DEPTH < 14
1221 1448070 int offset = 1 << (shift - 1);
1222 #else
1223 int offset = 0;
1224 #endif
1225
1226
2/2
✓ Branch 0 taken 8683602 times.
✓ Branch 1 taken 724035 times.
18815274 for (y = 0; y < height; y++) {
1227
2/2
✓ Branch 0 taken 141364564 times.
✓ Branch 1 taken 8683602 times.
300096332 for (x = 0; x < width; x++)
1228 282729128 dst[x] = av_clip_pixel(((EPEL_FILTER(src, srcstride) >> (BIT_DEPTH - 8)) + src2[x] + offset) >> shift);
1229 17367204 dst += dststride;
1230 17367204 src += srcstride;
1231 17367204 src2 += MAX_PB_SIZE;
1232 }
1233 1448070 }
1234
1235 11438578 static void FUNC(put_hevc_epel_uni_hv)(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride,
1236 int height, intptr_t mx, intptr_t my, int width)
1237 {
1238 int x, y;
1239 11438578 const pixel *src = (const pixel *)_src;
1240 11438578 ptrdiff_t srcstride = _srcstride / sizeof(pixel);
1241 11438578 pixel *dst = (pixel *)_dst;
1242 11438578 ptrdiff_t dststride = _dststride / sizeof(pixel);
1243 11438578 const int8_t *filter = ff_hevc_epel_filters[mx - 1];
1244 int16_t tmp_array[(MAX_PB_SIZE + EPEL_EXTRA) * MAX_PB_SIZE];
1245 11438578 int16_t *tmp = tmp_array;
1246 11438578 int shift = 14 - BIT_DEPTH;
1247 #if BIT_DEPTH < 14
1248 11438578 int offset = 1 << (shift - 1);
1249 #else
1250 int offset = 0;
1251 #endif
1252
1253 11438578 src -= EPEL_EXTRA_BEFORE * srcstride;
1254
1255
2/2
✓ Branch 0 taken 58795917 times.
✓ Branch 1 taken 5719289 times.
129030412 for (y = 0; y < height + EPEL_EXTRA; y++) {
1256
2/2
✓ Branch 0 taken 563719898 times.
✓ Branch 1 taken 58795917 times.
1245031630 for (x = 0; x < width; x++)
1257 1127439796 tmp[x] = EPEL_FILTER(src, 1) >> (BIT_DEPTH - 8);
1258 117591834 src += srcstride;
1259 117591834 tmp += MAX_PB_SIZE;
1260 }
1261
1262 11438578 tmp = tmp_array + EPEL_EXTRA_BEFORE * MAX_PB_SIZE;
1263 11438578 filter = ff_hevc_epel_filters[my - 1];
1264
1265
2/2
✓ Branch 0 taken 41638050 times.
✓ Branch 1 taken 5719289 times.
94714678 for (y = 0; y < height; y++) {
1266
2/2
✓ Branch 0 taken 442624772 times.
✓ Branch 1 taken 41638050 times.
968525644 for (x = 0; x < width; x++)
1267 885249544 dst[x] = av_clip_pixel(((EPEL_FILTER(tmp, MAX_PB_SIZE) >> 6) + offset) >> shift);
1268 83276100 tmp += MAX_PB_SIZE;
1269 83276100 dst += dststride;
1270 }
1271 11438578 }
1272
1273 8135842 static void FUNC(put_hevc_epel_bi_hv)(uint8_t *_dst, ptrdiff_t _dststride,
1274 const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2,
1275 int height, intptr_t mx, intptr_t my, int width)
1276 {
1277 int x, y;
1278 8135842 const pixel *src = (const pixel *)_src;
1279 8135842 ptrdiff_t srcstride = _srcstride / sizeof(pixel);
1280 8135842 pixel *dst = (pixel *)_dst;
1281 8135842 ptrdiff_t dststride = _dststride / sizeof(pixel);
1282 8135842 const int8_t *filter = ff_hevc_epel_filters[mx - 1];
1283 int16_t tmp_array[(MAX_PB_SIZE + EPEL_EXTRA) * MAX_PB_SIZE];
1284 8135842 int16_t *tmp = tmp_array;
1285 8135842 int shift = 14 + 1 - BIT_DEPTH;
1286 #if BIT_DEPTH < 14
1287 8135842 int offset = 1 << (shift - 1);
1288 #else
1289 int offset = 0;
1290 #endif
1291
1292 8135842 src -= EPEL_EXTRA_BEFORE * srcstride;
1293
1294
2/2
✓ Branch 0 taken 58184829 times.
✓ Branch 1 taken 4067921 times.
124505500 for (y = 0; y < height + EPEL_EXTRA; y++) {
1295
2/2
✓ Branch 0 taken 848106018 times.
✓ Branch 1 taken 58184829 times.
1812581694 for (x = 0; x < width; x++)
1296 1696212036 tmp[x] = EPEL_FILTER(src, 1) >> (BIT_DEPTH - 8);
1297 116369658 src += srcstride;
1298 116369658 tmp += MAX_PB_SIZE;
1299 }
1300
1301 8135842 tmp = tmp_array + EPEL_EXTRA_BEFORE * MAX_PB_SIZE;
1302 8135842 filter = ff_hevc_epel_filters[my - 1];
1303
1304
2/2
✓ Branch 0 taken 45981066 times.
✓ Branch 1 taken 4067921 times.
100097974 for (y = 0; y < height; y++) {
1305
2/2
✓ Branch 0 taken 719577684 times.
✓ Branch 1 taken 45981066 times.
1531117500 for (x = 0; x < width; x++)
1306 1439155368 dst[x] = av_clip_pixel(((EPEL_FILTER(tmp, MAX_PB_SIZE) >> 6) + src2[x] + offset) >> shift);
1307 91962132 tmp += MAX_PB_SIZE;
1308 91962132 dst += dststride;
1309 91962132 src2 += MAX_PB_SIZE;
1310 }
1311 8135842 }
1312
1313 53580 static void FUNC(put_hevc_epel_uni_w_h)(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride,
1314 int height, int denom, int wx, int ox, intptr_t mx, intptr_t my, int width)
1315 {
1316 int x, y;
1317 53580 const pixel *src = (const pixel *)_src;
1318 53580 ptrdiff_t srcstride = _srcstride / sizeof(pixel);
1319 53580 pixel *dst = (pixel *)_dst;
1320 53580 ptrdiff_t dststride = _dststride / sizeof(pixel);
1321 53580 const int8_t *filter = ff_hevc_epel_filters[mx - 1];
1322 53580 int shift = denom + 14 - BIT_DEPTH;
1323 #if BIT_DEPTH < 14
1324 53580 int offset = 1 << (shift - 1);
1325 #else
1326 int offset = 0;
1327 #endif
1328
1329 53580 ox = ox * (1 << (BIT_DEPTH - 8));
1330
2/2
✓ Branch 0 taken 323716 times.
✓ Branch 1 taken 26790 times.
701012 for (y = 0; y < height; y++) {
1331
2/2
✓ Branch 0 taken 6563880 times.
✓ Branch 1 taken 323716 times.
13775192 for (x = 0; x < width; x++) {
1332 13127760 dst[x] = av_clip_pixel((((EPEL_FILTER(src, 1) >> (BIT_DEPTH - 8)) * wx + offset) >> shift) + ox);
1333 }
1334 647432 dst += dststride;
1335 647432 src += srcstride;
1336 }
1337 53580 }
1338
1339 33080 static void FUNC(put_hevc_epel_bi_w_h)(uint8_t *_dst, ptrdiff_t _dststride,
1340 const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2,
1341 int height, int denom, int wx0, int wx1,
1342 int ox0, int ox1, intptr_t mx, intptr_t my, int width)
1343 {
1344 int x, y;
1345 33080 const pixel *src = (const pixel *)_src;
1346 33080 ptrdiff_t srcstride = _srcstride / sizeof(pixel);
1347 33080 pixel *dst = (pixel *)_dst;
1348 33080 ptrdiff_t dststride = _dststride / sizeof(pixel);
1349 33080 const int8_t *filter = ff_hevc_epel_filters[mx - 1];
1350 33080 int shift = 14 + 1 - BIT_DEPTH;
1351 33080 int log2Wd = denom + shift - 1;
1352
1353 33080 ox0 = ox0 * (1 << (BIT_DEPTH - 8));
1354 33080 ox1 = ox1 * (1 << (BIT_DEPTH - 8));
1355
2/2
✓ Branch 0 taken 233792 times.
✓ Branch 1 taken 16540 times.
500664 for (y = 0; y < height; y++) {
1356
2/2
✓ Branch 0 taken 5306152 times.
✓ Branch 1 taken 233792 times.
11079888 for (x = 0; x < width; x++)
1357 10612304 dst[x] = av_clip_pixel(((EPEL_FILTER(src, 1) >> (BIT_DEPTH - 8)) * wx1 + src2[x] * wx0 +
1358 ((ox0 + ox1 + 1) * (1 << log2Wd))) >> (log2Wd + 1));
1359 467584 src += srcstride;
1360 467584 dst += dststride;
1361 467584 src2 += MAX_PB_SIZE;
1362 }
1363 33080 }
1364
1365 42000 static void FUNC(put_hevc_epel_uni_w_v)(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride,
1366 int height, int denom, int wx, int ox, intptr_t mx, intptr_t my, int width)
1367 {
1368 int x, y;
1369 42000 const pixel *src = (const pixel *)_src;
1370 42000 ptrdiff_t srcstride = _srcstride / sizeof(pixel);
1371 42000 pixel *dst = (pixel *)_dst;
1372 42000 ptrdiff_t dststride = _dststride / sizeof(pixel);
1373 42000 const int8_t *filter = ff_hevc_epel_filters[my - 1];
1374 42000 int shift = denom + 14 - BIT_DEPTH;
1375 #if BIT_DEPTH < 14
1376 42000 int offset = 1 << (shift - 1);
1377 #else
1378 int offset = 0;
1379 #endif
1380
1381 42000 ox = ox * (1 << (BIT_DEPTH - 8));
1382
2/2
✓ Branch 0 taken 236812 times.
✓ Branch 1 taken 21000 times.
515624 for (y = 0; y < height; y++) {
1383
2/2
✓ Branch 0 taken 4764408 times.
✓ Branch 1 taken 236812 times.
10002440 for (x = 0; x < width; x++) {
1384 9528816 dst[x] = av_clip_pixel((((EPEL_FILTER(src, srcstride) >> (BIT_DEPTH - 8)) * wx + offset) >> shift) + ox);
1385 }
1386 473624 dst += dststride;
1387 473624 src += srcstride;
1388 }
1389 42000 }
1390
1391 24552 static void FUNC(put_hevc_epel_bi_w_v)(uint8_t *_dst, ptrdiff_t _dststride,
1392 const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2,
1393 int height, int denom, int wx0, int wx1,
1394 int ox0, int ox1, intptr_t mx, intptr_t my, int width)
1395 {
1396 int x, y;
1397 24552 const pixel *src = (const pixel *)_src;
1398 24552 ptrdiff_t srcstride = _srcstride / sizeof(pixel);
1399 24552 const int8_t *filter = ff_hevc_epel_filters[my - 1];
1400 24552 pixel *dst = (pixel *)_dst;
1401 24552 ptrdiff_t dststride = _dststride / sizeof(pixel);
1402 24552 int shift = 14 + 1 - BIT_DEPTH;
1403 24552 int log2Wd = denom + shift - 1;
1404
1405 24552 ox0 = ox0 * (1 << (BIT_DEPTH - 8));
1406 24552 ox1 = ox1 * (1 << (BIT_DEPTH - 8));
1407
2/2
✓ Branch 0 taken 167956 times.
✓ Branch 1 taken 12276 times.
360464 for (y = 0; y < height; y++) {
1408
2/2
✓ Branch 0 taken 3922696 times.
✓ Branch 1 taken 167956 times.
8181304 for (x = 0; x < width; x++)
1409 7845392 dst[x] = av_clip_pixel(((EPEL_FILTER(src, srcstride) >> (BIT_DEPTH - 8)) * wx1 + src2[x] * wx0 +
1410 ((ox0 + ox1 + 1) * (1 << log2Wd))) >> (log2Wd + 1));
1411 335912 src += srcstride;
1412 335912 dst += dststride;
1413 335912 src2 += MAX_PB_SIZE;
1414 }
1415 24552 }
1416
1417 251200 static void FUNC(put_hevc_epel_uni_w_hv)(uint8_t *_dst, ptrdiff_t _dststride, const uint8_t *_src, ptrdiff_t _srcstride,
1418 int height, int denom, int wx, int ox, intptr_t mx, intptr_t my, int width)
1419 {
1420 int x, y;
1421 251200 const pixel *src = (const pixel *)_src;
1422 251200 ptrdiff_t srcstride = _srcstride / sizeof(pixel);
1423 251200 pixel *dst = (pixel *)_dst;
1424 251200 ptrdiff_t dststride = _dststride / sizeof(pixel);
1425 251200 const int8_t *filter = ff_hevc_epel_filters[mx - 1];
1426 int16_t tmp_array[(MAX_PB_SIZE + EPEL_EXTRA) * MAX_PB_SIZE];
1427 251200 int16_t *tmp = tmp_array;
1428 251200 int shift = denom + 14 - BIT_DEPTH;
1429 #if BIT_DEPTH < 14
1430 251200 int offset = 1 << (shift - 1);
1431 #else
1432 int offset = 0;
1433 #endif
1434
1435 251200 src -= EPEL_EXTRA_BEFORE * srcstride;
1436
1437
2/2
✓ Branch 0 taken 1597200 times.
✓ Branch 1 taken 125600 times.
3445600 for (y = 0; y < height + EPEL_EXTRA; y++) {
1438
2/2
✓ Branch 0 taken 22400688 times.
✓ Branch 1 taken 1597200 times.
47995776 for (x = 0; x < width; x++)
1439 44801376 tmp[x] = EPEL_FILTER(src, 1) >> (BIT_DEPTH - 8);
1440 3194400 src += srcstride;
1441 3194400 tmp += MAX_PB_SIZE;
1442 }
1443
1444 251200 tmp = tmp_array + EPEL_EXTRA_BEFORE * MAX_PB_SIZE;
1445 251200 filter = ff_hevc_epel_filters[my - 1];
1446
1447 251200 ox = ox * (1 << (BIT_DEPTH - 8));
1448
2/2
✓ Branch 0 taken 1220400 times.
✓ Branch 1 taken 125600 times.
2692000 for (y = 0; y < height; y++) {
1449
2/2
✓ Branch 0 taken 18910776 times.
✓ Branch 1 taken 1220400 times.
40262352 for (x = 0; x < width; x++)
1450 37821552 dst[x] = av_clip_pixel((((EPEL_FILTER(tmp, MAX_PB_SIZE) >> 6) * wx + offset) >> shift) + ox);
1451 2440800 tmp += MAX_PB_SIZE;
1452 2440800 dst += dststride;
1453 }
1454 251200 }
1455
1456 166916 static void FUNC(put_hevc_epel_bi_w_hv)(uint8_t *_dst, ptrdiff_t _dststride,
1457 const uint8_t *_src, ptrdiff_t _srcstride, const int16_t *src2,
1458 int height, int denom, int wx0, int wx1,
1459 int ox0, int ox1, intptr_t mx, intptr_t my, int width)
1460 {
1461 int x, y;
1462 166916 const pixel *src = (const pixel *)_src;
1463 166916 ptrdiff_t srcstride = _srcstride / sizeof(pixel);
1464 166916 pixel *dst = (pixel *)_dst;
1465 166916 ptrdiff_t dststride = _dststride / sizeof(pixel);
1466 166916 const int8_t *filter = ff_hevc_epel_filters[mx - 1];
1467 int16_t tmp_array[(MAX_PB_SIZE + EPEL_EXTRA) * MAX_PB_SIZE];
1468 166916 int16_t *tmp = tmp_array;
1469 166916 int shift = 14 + 1 - BIT_DEPTH;
1470 166916 int log2Wd = denom + shift - 1;
1471
1472 166916 src -= EPEL_EXTRA_BEFORE * srcstride;
1473
1474
2/2
✓ Branch 0 taken 1288910 times.
✓ Branch 1 taken 83458 times.
2744736 for (y = 0; y < height + EPEL_EXTRA; y++) {
1475
2/2
✓ Branch 0 taken 21782220 times.
✓ Branch 1 taken 1288910 times.
46142260 for (x = 0; x < width; x++)
1476 43564440 tmp[x] = EPEL_FILTER(src, 1) >> (BIT_DEPTH - 8);
1477 2577820 src += srcstride;
1478 2577820 tmp += MAX_PB_SIZE;
1479 }
1480
1481 166916 tmp = tmp_array + EPEL_EXTRA_BEFORE * MAX_PB_SIZE;
1482 166916 filter = ff_hevc_epel_filters[my - 1];
1483
1484 166916 ox0 = ox0 * (1 << (BIT_DEPTH - 8));
1485 166916 ox1 = ox1 * (1 << (BIT_DEPTH - 8));
1486
2/2
✓ Branch 0 taken 1038536 times.
✓ Branch 1 taken 83458 times.
2243988 for (y = 0; y < height; y++) {
1487
2/2
✓ Branch 0 taken 18780552 times.
✓ Branch 1 taken 1038536 times.
39638176 for (x = 0; x < width; x++)
1488 37561104 dst[x] = av_clip_pixel(((EPEL_FILTER(tmp, MAX_PB_SIZE) >> 6) * wx1 + src2[x] * wx0 +
1489 ((ox0 + ox1 + 1) * (1 << log2Wd))) >> (log2Wd + 1));
1490 2077072 tmp += MAX_PB_SIZE;
1491 2077072 dst += dststride;
1492 2077072 src2 += MAX_PB_SIZE;
1493 }
1494 166916 }
1495
1496 // line zero
1497 #define P3 pix[-4 * xstride]
1498 #define P2 pix[-3 * xstride]
1499 #define P1 pix[-2 * xstride]
1500 #define P0 pix[-1 * xstride]
1501 #define Q0 pix[0 * xstride]
1502 #define Q1 pix[1 * xstride]
1503 #define Q2 pix[2 * xstride]
1504 #define Q3 pix[3 * xstride]
1505
1506 // line three. used only for deblocking decision
1507 #define TP3 pix[-4 * xstride + 3 * ystride]
1508 #define TP2 pix[-3 * xstride + 3 * ystride]
1509 #define TP1 pix[-2 * xstride + 3 * ystride]
1510 #define TP0 pix[-1 * xstride + 3 * ystride]
1511 #define TQ0 pix[0 * xstride + 3 * ystride]
1512 #define TQ1 pix[1 * xstride + 3 * ystride]
1513 #define TQ2 pix[2 * xstride + 3 * ystride]
1514 #define TQ3 pix[3 * xstride + 3 * ystride]
1515
1516 69349318 static void FUNC(hevc_loop_filter_luma)(uint8_t *_pix,
1517 ptrdiff_t _xstride, ptrdiff_t _ystride,
1518 int beta, const int *_tc,
1519 const uint8_t *_no_p, const uint8_t *_no_q)
1520 {
1521 int d, j;
1522 69349318 pixel *pix = (pixel *)_pix;
1523 69349318 ptrdiff_t xstride = _xstride / sizeof(pixel);
1524 69349318 ptrdiff_t ystride = _ystride / sizeof(pixel);
1525
1526 69349318 beta <<= BIT_DEPTH - 8;
1527
1528
2/2
✓ Branch 0 taken 69349318 times.
✓ Branch 1 taken 34674659 times.
208047954 for (j = 0; j < 2; j++) {
1529 138698636 const int dp0 = abs(P2 - 2 * P1 + P0);
1530 138698636 const int dq0 = abs(Q2 - 2 * Q1 + Q0);
1531 138698636 const int dp3 = abs(TP2 - 2 * TP1 + TP0);
1532 138698636 const int dq3 = abs(TQ2 - 2 * TQ1 + TQ0);
1533 138698636 const int d0 = dp0 + dq0;
1534 138698636 const int d3 = dp3 + dq3;
1535 138698636 const int tc = _tc[j] << (BIT_DEPTH - 8);
1536 138698636 const int no_p = _no_p[j];
1537 138698636 const int no_q = _no_q[j];
1538
1539
2/2
✓ Branch 0 taken 17977241 times.
✓ Branch 1 taken 51372077 times.
138698636 if (d0 + d3 >= beta) {
1540 35954482 pix += 4 * ystride;
1541 35954482 continue;
1542 } else {
1543 102744154 const int beta_3 = beta >> 3;
1544 102744154 const int beta_2 = beta >> 2;
1545 102744154 const int tc25 = ((tc * 5 + 1) >> 1);
1546
1547
4/4
✓ Branch 0 taken 14506670 times.
✓ Branch 1 taken 36865407 times.
✓ Branch 2 taken 14057788 times.
✓ Branch 3 taken 448882 times.
102744154 if (abs(P3 - P0) + abs(Q3 - Q0) < beta_3 && abs(P0 - Q0) < tc25 &&
1548
4/4
✓ Branch 0 taken 10521946 times.
✓ Branch 1 taken 3535842 times.
✓ Branch 2 taken 10430063 times.
✓ Branch 3 taken 91883 times.
28115576 abs(TP3 - TP0) + abs(TQ3 - TQ0) < beta_3 && abs(TP0 - TQ0) < tc25 &&
1549
4/4
✓ Branch 0 taken 10072655 times.
✓ Branch 1 taken 357408 times.
✓ Branch 2 taken 9858123 times.
✓ Branch 3 taken 214532 times.
40576372 (d0 << 1) < beta_2 && (d3 << 1) < beta_2) {
1550 // strong filtering
1551 19716246 const int tc2 = tc << 1;
1552
2/2
✓ Branch 0 taken 39432492 times.
✓ Branch 1 taken 9858123 times.
98581230 for (d = 0; d < 4; d++) {
1553 78864984 const int p3 = P3;
1554 78864984 const int p2 = P2;
1555 78864984 const int p1 = P1;
1556 78864984 const int p0 = P0;
1557 78864984 const int q0 = Q0;
1558 78864984 const int q1 = Q1;
1559 78864984 const int q2 = Q2;
1560 78864984 const int q3 = Q3;
1561
2/2
✓ Branch 0 taken 39426948 times.
✓ Branch 1 taken 5544 times.
78864984 if (!no_p) {
1562 78853896 P0 = p0 + av_clip(((p2 + 2 * p1 + 2 * p0 + 2 * q0 + q1 + 4) >> 3) - p0, -tc2, tc2);
1563 78853896 P1 = p1 + av_clip(((p2 + p1 + p0 + q0 + 2) >> 2) - p1, -tc2, tc2);
1564 78853896 P2 = p2 + av_clip(((2 * p3 + 3 * p2 + p1 + p0 + q0 + 4) >> 3) - p2, -tc2, tc2);
1565 }
1566
2/2
✓ Branch 0 taken 39426820 times.
✓ Branch 1 taken 5672 times.
78864984 if (!no_q) {
1567 78853640 Q0 = q0 + av_clip(((p1 + 2 * p0 + 2 * q0 + 2 * q1 + q2 + 4) >> 3) - q0, -tc2, tc2);
1568 78853640 Q1 = q1 + av_clip(((p0 + q0 + q1 + q2 + 2) >> 2) - q1, -tc2, tc2);
1569 78853640 Q2 = q2 + av_clip(((2 * q3 + 3 * q2 + q1 + q0 + p0 + 4) >> 3) - q2, -tc2, tc2);
1570 }
1571 78864984 pix += ystride;
1572 }
1573 } else { // normal filtering
1574 83027908 int nd_p = 1;
1575 83027908 int nd_q = 1;
1576 83027908 const int tc_2 = tc >> 1;
1577
2/2
✓ Branch 0 taken 29180467 times.
✓ Branch 1 taken 12333487 times.
83027908 if (dp0 + dp3 < ((beta + (beta >> 1)) >> 3))
1578 58360934 nd_p = 2;
1579
2/2
✓ Branch 0 taken 28407550 times.
✓ Branch 1 taken 13106404 times.
83027908 if (dq0 + dq3 < ((beta + (beta >> 1)) >> 3))
1580 56815100 nd_q = 2;
1581
1582
2/2
✓ Branch 0 taken 166055816 times.
✓ Branch 1 taken 41513954 times.
415139540 for (d = 0; d < 4; d++) {
1583 332111632 const int p2 = P2;
1584 332111632 const int p1 = P1;
1585 332111632 const int p0 = P0;
1586 332111632 const int q0 = Q0;
1587 332111632 const int q1 = Q1;
1588 332111632 const int q2 = Q2;
1589 332111632 int delta0 = (9 * (q0 - p0) - 3 * (q1 - p1) + 8) >> 4;
1590
2/2
✓ Branch 0 taken 164217023 times.
✓ Branch 1 taken 1838793 times.
332111632 if (abs(delta0) < 10 * tc) {
1591 328434046 delta0 = av_clip(delta0, -tc, tc);
1592
2/2
✓ Branch 0 taken 163901706 times.
✓ Branch 1 taken 315317 times.
328434046 if (!no_p)
1593 327803412 P0 = av_clip_pixel(p0 + delta0);
1594
2/2
✓ Branch 0 taken 163899775 times.
✓ Branch 1 taken 317248 times.
328434046 if (!no_q)
1595 327799550 Q0 = av_clip_pixel(q0 - delta0);
1596
4/4
✓ Branch 0 taken 163901706 times.
✓ Branch 1 taken 315317 times.
✓ Branch 2 taken 115525206 times.
✓ Branch 3 taken 48376500 times.
328434046 if (!no_p && nd_p > 1) {
1597 231050412 const int deltap1 = av_clip((((p2 + p0 + 1) >> 1) - p1 + delta0) >> 1, -tc_2, tc_2);
1598 231050412 P1 = av_clip_pixel(p1 + deltap1);
1599 }
1600
4/4
✓ Branch 0 taken 163899775 times.
✓ Branch 1 taken 317248 times.
✓ Branch 2 taken 112455172 times.
✓ Branch 3 taken 51444603 times.
328434046 if (!no_q && nd_q > 1) {
1601 224910344 const int deltaq1 = av_clip((((q2 + q0 + 1) >> 1) - q1 - delta0) >> 1, -tc_2, tc_2);
1602 224910344 Q1 = av_clip_pixel(q1 + deltaq1);
1603 }
1604 }
1605 332111632 pix += ystride;
1606 }
1607 }
1608 }
1609 }
1610 69349318 }
1611
1612 21771428 static void FUNC(hevc_loop_filter_chroma)(uint8_t *_pix, ptrdiff_t _xstride,
1613 ptrdiff_t _ystride, const int *_tc,
1614 const uint8_t *_no_p, const uint8_t *_no_q)
1615 {
1616 int d, j, no_p, no_q;
1617 21771428 pixel *pix = (pixel *)_pix;
1618 21771428 ptrdiff_t xstride = _xstride / sizeof(pixel);
1619 21771428 ptrdiff_t ystride = _ystride / sizeof(pixel);
1620
1621
2/2
✓ Branch 0 taken 21771428 times.
✓ Branch 1 taken 10885714 times.
65314284 for (j = 0; j < 2; j++) {
1622 43542856 const int tc = _tc[j] << (BIT_DEPTH - 8);
1623
2/2
✓ Branch 0 taken 2274659 times.
✓ Branch 1 taken 19496769 times.
43542856 if (tc <= 0) {
1624 4549318 pix += 4 * ystride;
1625 4549318 continue;
1626 }
1627 38993538 no_p = _no_p[j];
1628 38993538 no_q = _no_q[j];
1629
1630
2/2
✓ Branch 0 taken 77987076 times.
✓ Branch 1 taken 19496769 times.
194967690 for (d = 0; d < 4; d++) {
1631 int delta0;
1632 155974152 const int p1 = P1;
1633 155974152 const int p0 = P0;
1634 155974152 const int q0 = Q0;
1635 155974152 const int q1 = Q1;
1636 155974152 delta0 = av_clip((((q0 - p0) * 4) + p1 - q1 + 4) >> 3, -tc, tc);
1637
2/2
✓ Branch 0 taken 77724484 times.
✓ Branch 1 taken 262592 times.
155974152 if (!no_p)
1638 155448968 P0 = av_clip_pixel(p0 + delta0);
1639
2/2
✓ Branch 0 taken 77720628 times.
✓ Branch 1 taken 266448 times.
155974152 if (!no_q)
1640 155441256 Q0 = av_clip_pixel(q0 - delta0);
1641 155974152 pix += ystride;
1642 }
1643 }
1644 21771428 }
1645
1646 10600800 static void FUNC(hevc_h_loop_filter_chroma)(uint8_t *pix, ptrdiff_t stride,
1647 const int32_t *tc, const uint8_t *no_p,
1648 const uint8_t *no_q)
1649 {
1650 10600800 FUNC(hevc_loop_filter_chroma)(pix, stride, sizeof(pixel), tc, no_p, no_q);
1651 10600800 }
1652
1653 11170628 static void FUNC(hevc_v_loop_filter_chroma)(uint8_t *pix, ptrdiff_t stride,
1654 const int32_t *tc, const uint8_t *no_p,
1655 const uint8_t *no_q)
1656 {
1657 11170628 FUNC(hevc_loop_filter_chroma)(pix, sizeof(pixel), stride, tc, no_p, no_q);
1658 11170628 }
1659
1660 35009204 static void FUNC(hevc_h_loop_filter_luma)(uint8_t *pix, ptrdiff_t stride,
1661 int beta, const int32_t *tc, const uint8_t *no_p,
1662 const uint8_t *no_q)
1663 {
1664 35009204 FUNC(hevc_loop_filter_luma)(pix, stride, sizeof(pixel),
1665 beta, tc, no_p, no_q);
1666 35009204 }
1667
1668 34340114 static void FUNC(hevc_v_loop_filter_luma)(uint8_t *pix, ptrdiff_t stride,
1669 int beta, const int32_t *tc, const uint8_t *no_p,
1670 const uint8_t *no_q)
1671 {
1672 34340114 FUNC(hevc_loop_filter_luma)(pix, sizeof(pixel), stride,
1673 beta, tc, no_p, no_q);
1674 34340114 }
1675
1676 #undef P3
1677 #undef P2
1678 #undef P1
1679 #undef P0
1680 #undef Q0
1681 #undef Q1
1682 #undef Q2
1683 #undef Q3
1684
1685 #undef TP3
1686 #undef TP2
1687 #undef TP1
1688 #undef TP0
1689 #undef TQ0
1690 #undef TQ1
1691 #undef TQ2
1692 #undef TQ3
1693