FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/hevc/pred_template.c
Date: 2024-07-16 12:46:59
Exec Total Coverage
Lines: 313 319 98.1%
Functions: 48 64 75.0%
Branches: 285 301 94.7%

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 "libavutil/pixdesc.h"
24
25 #include "bit_depth_template.c"
26 #include "pred.h"
27
28 #define POS(x, y) src[(x) + stride * (y)]
29
30 41675752 static av_always_inline void FUNC(intra_pred)(HEVCLocalContext *lc,
31 const HEVCPPS *pps,
32 int x0, int y0,
33 int log2_size, int c_idx)
34 {
35 #define PU(x) \
36 ((x) >> sps->log2_min_pu_size)
37 #define MVF(x, y) \
38 (s->cur_frame->tab_mvf[(x) + (y) * min_pu_width])
39 #define MVF_PU(x, y) \
40 MVF(PU(x0 + ((x) * (1 << hshift))), PU(y0 + ((y) * (1 << vshift))))
41 #define IS_INTRA(x, y) \
42 (MVF_PU(x, y).pred_flag == PF_INTRA)
43 #define MIN_TB_ADDR_ZS(x, y) \
44 pps->min_tb_addr_zs[(y) * (sps->tb_mask+2) + (x)]
45 #define EXTEND(ptr, val, len) \
46 do { \
47 pixel4 pix = PIXEL_SPLAT_X4(val); \
48 for (i = 0; i < (len); i += 4) \
49 AV_WN4P(ptr + i, pix); \
50 } while (0)
51
52 #define EXTEND_RIGHT_CIP(ptr, start, length) \
53 for (i = start; i < (start) + (length); i += 4) \
54 if (!IS_INTRA(i, -1)) \
55 AV_WN4P(&ptr[i], a); \
56 else \
57 a = PIXEL_SPLAT_X4(ptr[i+3])
58 #define EXTEND_LEFT_CIP(ptr, start, length) \
59 for (i = start; i > (start) - (length); i--) \
60 if (!IS_INTRA(i - 1, -1)) \
61 ptr[i - 1] = ptr[i]
62 #define EXTEND_UP_CIP(ptr, start, length) \
63 for (i = (start); i > (start) - (length); i -= 4) \
64 if (!IS_INTRA(-1, i - 3)) \
65 AV_WN4P(&ptr[i - 3], a); \
66 else \
67 a = PIXEL_SPLAT_X4(ptr[i - 3])
68 #define EXTEND_DOWN_CIP(ptr, start, length) \
69 for (i = start; i < (start) + (length); i += 4) \
70 if (!IS_INTRA(-1, i)) \
71 AV_WN4P(&ptr[i], a); \
72 else \
73 a = PIXEL_SPLAT_X4(ptr[i + 3])
74
75 41675752 const HEVCSPS *const sps = pps->sps;
76 41675752 const HEVCContext *const s = lc->parent;
77 int i;
78 41675752 int hshift = sps->hshift[c_idx];
79 41675752 int vshift = sps->vshift[c_idx];
80 41675752 int size = (1 << log2_size);
81 41675752 int size_in_luma_h = size << hshift;
82 41675752 int size_in_tbs_h = size_in_luma_h >> sps->log2_min_tb_size;
83 41675752 int size_in_luma_v = size << vshift;
84 41675752 int size_in_tbs_v = size_in_luma_v >> sps->log2_min_tb_size;
85 41675752 int x = x0 >> hshift;
86 41675752 int y = y0 >> vshift;
87 41675752 int x_tb = (x0 >> sps->log2_min_tb_size) & sps->tb_mask;
88 41675752 int y_tb = (y0 >> sps->log2_min_tb_size) & sps->tb_mask;
89
6/6
✓ Branch 0 taken 11145608 times.
✓ Branch 1 taken 9692268 times.
✓ Branch 2 taken 216896 times.
✓ Branch 3 taken 10928712 times.
✓ Branch 4 taken 108448 times.
✓ Branch 5 taken 108448 times.
41675752 int spin = c_idx && !size_in_tbs_v && ((2 * y0) & (1 << sps->log2_min_tb_size));
90
91 41675752 int cur_tb_addr = MIN_TB_ADDR_ZS(x_tb, y_tb);
92
93 41675752 ptrdiff_t stride = s->cur_frame->f->linesize[c_idx] / sizeof(pixel);
94 41675752 pixel *src = (pixel*)s->cur_frame->f->data[c_idx] + x + y * stride;
95
96 41675752 int min_pu_width = sps->min_pu_width;
97
98
2/2
✓ Branch 0 taken 11145608 times.
✓ Branch 1 taken 9692268 times.
41675752 enum IntraPredMode mode = c_idx ? lc->tu.intra_pred_mode_c :
99 19384536 lc->tu.intra_pred_mode;
100 pixel4 a;
101 pixel left_array[2 * MAX_TB_SIZE + 1];
102 pixel filtered_left_array[2 * MAX_TB_SIZE + 1];
103 pixel top_array[2 * MAX_TB_SIZE + 1];
104 pixel filtered_top_array[2 * MAX_TB_SIZE + 1];
105
106 41675752 pixel *left = left_array + 1;
107 41675752 pixel *top = top_array + 1;
108 41675752 pixel *filtered_left = filtered_left_array + 1;
109 41675752 pixel *filtered_top = filtered_top_array + 1;
110
4/4
✓ Branch 0 taken 17548000 times.
✓ Branch 1 taken 3289876 times.
✓ Branch 2 taken 6915045 times.
✓ Branch 3 taken 10632955 times.
41675752 int cand_bottom_left = lc->na.cand_bottom_left && cur_tb_addr > MIN_TB_ADDR_ZS( x_tb - 1, (y_tb + size_in_tbs_v + spin) & sps->tb_mask);
111 41675752 int cand_left = lc->na.cand_left;
112 41675752 int cand_up_left = lc->na.cand_up_left;
113 41675752 int cand_up = lc->na.cand_up;
114
6/6
✓ Branch 0 taken 18021360 times.
✓ Branch 1 taken 2816516 times.
✓ Branch 2 taken 17940152 times.
✓ Branch 3 taken 81208 times.
✓ Branch 4 taken 13292756 times.
✓ Branch 5 taken 4647396 times.
41675752 int cand_up_right = lc->na.cand_up_right && !spin && cur_tb_addr > MIN_TB_ADDR_ZS((x_tb + size_in_tbs_h) & sps->tb_mask, y_tb - 1);
115
116 41675752 int bottom_left_size = (FFMIN(y0 + 2 * size_in_luma_v, sps->height) -
117 41675752 (y0 + size_in_luma_v)) >> vshift;
118 41675752 int top_right_size = (FFMIN(x0 + 2 * size_in_luma_h, sps->width) -
119 41675752 (x0 + size_in_luma_h)) >> hshift;
120
121
2/2
✓ Branch 0 taken 135573 times.
✓ Branch 1 taken 20702303 times.
41675752 if (pps->constrained_intra_pred_flag == 1) {
122 271146 int size_in_luma_pu_v = PU(size_in_luma_v);
123 271146 int size_in_luma_pu_h = PU(size_in_luma_h);
124 271146 int on_pu_edge_x = !av_zero_extend(x0, sps->log2_min_pu_size);
125 271146 int on_pu_edge_y = !av_zero_extend(y0, sps->log2_min_pu_size);
126
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 135573 times.
271146 if (!size_in_luma_pu_h)
127 size_in_luma_pu_h++;
128
3/4
✓ Branch 0 taken 42092 times.
✓ Branch 1 taken 93481 times.
✓ Branch 2 taken 42092 times.
✗ Branch 3 not taken.
271146 if (cand_bottom_left == 1 && on_pu_edge_x) {
129 84184 int x_left_pu = PU(x0 - 1);
130 84184 int y_bottom_pu = PU(y0 + size_in_luma_v);
131 84184 int max = FFMIN(size_in_luma_pu_v, sps->min_pu_height - y_bottom_pu);
132 84184 cand_bottom_left = 0;
133
2/2
✓ Branch 0 taken 47858 times.
✓ Branch 1 taken 42092 times.
179900 for (i = 0; i < max; i += 2)
134 95716 cand_bottom_left |= (MVF(x_left_pu, y_bottom_pu + i).pred_flag == PF_INTRA);
135 }
136
3/4
✓ Branch 0 taken 133155 times.
✓ Branch 1 taken 2418 times.
✓ Branch 2 taken 133155 times.
✗ Branch 3 not taken.
271146 if (cand_left == 1 && on_pu_edge_x) {
137 266310 int x_left_pu = PU(x0 - 1);
138 266310 int y_left_pu = PU(y0);
139 266310 int max = FFMIN(size_in_luma_pu_v, sps->min_pu_height - y_left_pu);
140 266310 cand_left = 0;
141
2/2
✓ Branch 0 taken 154503 times.
✓ Branch 1 taken 133155 times.
575316 for (i = 0; i < max; i += 2)
142 309006 cand_left |= (MVF(x_left_pu, y_left_pu + i).pred_flag == PF_INTRA);
143 }
144
2/2
✓ Branch 0 taken 129132 times.
✓ Branch 1 taken 6441 times.
271146 if (cand_up_left == 1) {
145 258264 int x_left_pu = PU(x0 - 1);
146 258264 int y_top_pu = PU(y0 - 1);
147 258264 cand_up_left = MVF(x_left_pu, y_top_pu).pred_flag == PF_INTRA;
148 }
149
3/4
✓ Branch 0 taken 131451 times.
✓ Branch 1 taken 4122 times.
✓ Branch 2 taken 131451 times.
✗ Branch 3 not taken.
271146 if (cand_up == 1 && on_pu_edge_y) {
150 262902 int x_top_pu = PU(x0);
151 262902 int y_top_pu = PU(y0 - 1);
152 262902 int max = FFMIN(size_in_luma_pu_h, sps->min_pu_width - x_top_pu);
153 262902 cand_up = 0;
154
2/2
✓ Branch 0 taken 151623 times.
✓ Branch 1 taken 131451 times.
566148 for (i = 0; i < max; i += 2)
155 303246 cand_up |= (MVF(x_top_pu + i, y_top_pu).pred_flag == PF_INTRA);
156 }
157
3/4
✓ Branch 0 taken 87241 times.
✓ Branch 1 taken 48332 times.
✓ Branch 2 taken 87241 times.
✗ Branch 3 not taken.
271146 if (cand_up_right == 1 && on_pu_edge_y) {
158 174482 int y_top_pu = PU(y0 - 1);
159 174482 int x_right_pu = PU(x0 + size_in_luma_h);
160 174482 int max = FFMIN(size_in_luma_pu_h, sps->min_pu_width - x_right_pu);
161 174482 cand_up_right = 0;
162
2/2
✓ Branch 0 taken 100969 times.
✓ Branch 1 taken 87241 times.
376420 for (i = 0; i < max; i += 2)
163 201938 cand_up_right |= (MVF(x_right_pu + i, y_top_pu).pred_flag == PF_INTRA);
164 }
165 271146 memset(left, 128, 2 * MAX_TB_SIZE*sizeof(pixel));
166 271146 memset(top , 128, 2 * MAX_TB_SIZE*sizeof(pixel));
167 271146 top[-1] = 128;
168 }
169
2/2
✓ Branch 0 taken 20225617 times.
✓ Branch 1 taken 612259 times.
41675752 if (cand_up_left) {
170 40451234 left[-1] = POS(-1, -1);
171 40451234 top[-1] = left[-1];
172 }
173
2/2
✓ Branch 0 taken 20459145 times.
✓ Branch 1 taken 378731 times.
41675752 if (cand_up)
174 40918290 memcpy(top, src - stride, size * sizeof(pixel));
175
2/2
✓ Branch 0 taken 13287169 times.
✓ Branch 1 taken 7550707 times.
41675752 if (cand_up_right) {
176 26574338 memcpy(top + size, src - stride + size, size * sizeof(pixel));
177
2/2
✓ Branch 0 taken 26750 times.
✓ Branch 1 taken 13287169 times.
26627838 EXTEND(top + size + top_right_size, POS(size + top_right_size - 1, -1),
178 size - top_right_size);
179 }
180
2/2
✓ Branch 0 taken 20592241 times.
✓ Branch 1 taken 245635 times.
41675752 if (cand_left)
181
2/2
✓ Branch 0 taken 124634464 times.
✓ Branch 1 taken 20592241 times.
290453410 for (i = 0; i < size; i++)
182 249268928 left[i] = POS(-1, i);
183
2/2
✓ Branch 0 taken 6912142 times.
✓ Branch 1 taken 13925734 times.
41675752 if (cand_bottom_left) {
184
2/2
✓ Branch 0 taken 39934488 times.
✓ Branch 1 taken 6912142 times.
93693260 for (i = size; i < size + bottom_left_size; i++)
185 79868976 left[i] = POS(-1, i);
186
2/2
✓ Branch 0 taken 34098 times.
✓ Branch 1 taken 6912142 times.
13892480 EXTEND(left + size + bottom_left_size, POS(-1, size + bottom_left_size - 1),
187 size - bottom_left_size);
188 }
189
190
2/2
✓ Branch 0 taken 135573 times.
✓ Branch 1 taken 20702303 times.
41675752 if (pps->constrained_intra_pred_flag == 1) {
191
10/10
✓ Branch 0 taken 96384 times.
✓ Branch 1 taken 39189 times.
✓ Branch 2 taken 8672 times.
✓ Branch 3 taken 87712 times.
✓ Branch 4 taken 7508 times.
✓ Branch 5 taken 1164 times.
✓ Branch 6 taken 2059 times.
✓ Branch 7 taken 5449 times.
✓ Branch 8 taken 340 times.
✓ Branch 9 taken 1719 times.
271146 if (cand_bottom_left || cand_left || cand_up_left || cand_up || cand_up_right) {
192 535416 int size_max_x = x0 + ((2 * size) << hshift) < sps->width ?
193
2/2
✓ Branch 0 taken 131758 times.
✓ Branch 1 taken 2096 times.
267708 2 * size : (sps->width - x0) >> hshift;
194 535416 int size_max_y = y0 + ((2 * size) << vshift) < sps->height ?
195
2/2
✓ Branch 0 taken 128041 times.
✓ Branch 1 taken 5813 times.
267708 2 * size : (sps->height - y0) >> vshift;
196
2/2
✓ Branch 0 taken 39189 times.
✓ Branch 1 taken 94665 times.
267708 int j = size + (cand_bottom_left? bottom_left_size: 0) -1;
197
2/2
✓ Branch 0 taken 52200 times.
✓ Branch 1 taken 81654 times.
267708 if (!cand_up_right) {
198 104400 size_max_x = x0 + ((size) << hshift) < sps->width ?
199
2/2
✓ Branch 0 taken 1115 times.
✓ Branch 1 taken 51085 times.
104400 size : (sps->width - x0) >> hshift;
200 }
201
2/2
✓ Branch 0 taken 94665 times.
✓ Branch 1 taken 39189 times.
267708 if (!cand_bottom_left) {
202 189330 size_max_y = y0 + (( size) << vshift) < sps->height ?
203
2/2
✓ Branch 0 taken 2915 times.
✓ Branch 1 taken 91750 times.
189330 size : (sps->height - y0) >> vshift;
204 }
205
6/6
✓ Branch 0 taken 94665 times.
✓ Branch 1 taken 39189 times.
✓ Branch 2 taken 6953 times.
✓ Branch 3 taken 87712 times.
✓ Branch 4 taken 1164 times.
✓ Branch 5 taken 5789 times.
267708 if (cand_bottom_left || cand_left || cand_up_left) {
206
4/4
✓ Branch 0 taken 135541 times.
✓ Branch 1 taken 1164 times.
✓ Branch 2 taken 8640 times.
✓ Branch 3 taken 126901 times.
273410 while (j > -1 && !IS_INTRA(-1, j))
207 17280 j--;
208
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128065 times.
256130 if (!IS_INTRA(-1, j)) {
209 j = 0;
210 while (j < size_max_x && !IS_INTRA(j, -1))
211 j++;
212 EXTEND_LEFT_CIP(top, j, j + 1);
213 left[-1] = top[-1];
214 }
215 } else {
216 11578 j = 0;
217
3/4
✓ Branch 0 taken 9429 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3640 times.
✓ Branch 3 taken 5789 times.
18858 while (j < size_max_x && !IS_INTRA(j, -1))
218 7280 j++;
219
2/2
✓ Branch 0 taken 409 times.
✓ Branch 1 taken 5380 times.
11578 if (j > 0) {
220
3/4
✓ Branch 0 taken 3640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3640 times.
✓ Branch 3 taken 409 times.
8098 EXTEND_LEFT_CIP(top, j, j);
221 818 top[-1] = top[0];
222 }
223 11578 left[-1] = top[-1];
224 }
225 267708 left[-1] = top[-1];
226
4/4
✓ Branch 0 taken 94665 times.
✓ Branch 1 taken 39189 times.
✓ Branch 2 taken 87712 times.
✓ Branch 3 taken 6953 times.
267708 if (cand_bottom_left || cand_left) {
227 253802 a = PIXEL_SPLAT_X4(left[-1]);
228
4/4
✓ Branch 0 taken 1258 times.
✓ Branch 1 taken 223183 times.
✓ Branch 2 taken 224441 times.
✓ Branch 3 taken 126901 times.
702684 EXTEND_DOWN_CIP(left, 0, size_max_y);
229 }
230
2/2
✓ Branch 0 taken 7301 times.
✓ Branch 1 taken 126553 times.
267708 if (!cand_left)
231
2/2
✓ Branch 0 taken 12154 times.
✓ Branch 1 taken 7301 times.
38910 EXTEND(left, left[-1], size);
232
2/2
✓ Branch 0 taken 94665 times.
✓ Branch 1 taken 39189 times.
267708 if (!cand_bottom_left)
233
2/2
✓ Branch 0 taken 131859 times.
✓ Branch 1 taken 94665 times.
453048 EXTEND(left + size, left[size - 1], size);
234
4/4
✓ Branch 0 taken 132302 times.
✓ Branch 1 taken 1552 times.
✓ Branch 2 taken 130188 times.
✓ Branch 3 taken 2114 times.
267708 if (x0 != 0 && y0 != 0) {
235 260376 a = PIXEL_SPLAT_X4(left[size_max_y - 1]);
236
4/4
✓ Branch 0 taken 8892 times.
✓ Branch 1 taken 218296 times.
✓ Branch 2 taken 227188 times.
✓ Branch 3 taken 130188 times.
714752 EXTEND_UP_CIP(left, size_max_y - 1, size_max_y);
237
2/2
✓ Branch 0 taken 7429 times.
✓ Branch 1 taken 122759 times.
260376 if (!IS_INTRA(-1, - 1))
238 14858 left[-1] = left[0];
239
2/2
✓ Branch 0 taken 1552 times.
✓ Branch 1 taken 2114 times.
7332 } else if (x0 == 0) {
240
2/2
✓ Branch 0 taken 2946 times.
✓ Branch 1 taken 1552 times.
8996 EXTEND(left, 0, size_max_y);
241 } else {
242 4228 a = PIXEL_SPLAT_X4(left[size_max_y - 1]);
243
4/4
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 5843 times.
✓ Branch 2 taken 5895 times.
✓ Branch 3 taken 2114 times.
16018 EXTEND_UP_CIP(left, size_max_y - 1, size_max_y);
244 }
245 267708 top[-1] = left[-1];
246
2/2
✓ Branch 0 taken 131740 times.
✓ Branch 1 taken 2114 times.
267708 if (y0 != 0) {
247 263480 a = PIXEL_SPLAT_X4(left[-1]);
248
4/4
✓ Branch 0 taken 8339 times.
✓ Branch 1 taken 282171 times.
✓ Branch 2 taken 290510 times.
✓ Branch 3 taken 131740 times.
844500 EXTEND_RIGHT_CIP(top, 0, size_max_x);
249 }
250 }
251 }
252 // Infer the unavailable samples
253
2/2
✓ Branch 0 taken 13925734 times.
✓ Branch 1 taken 6912142 times.
41675752 if (!cand_bottom_left) {
254
2/2
✓ Branch 0 taken 13680447 times.
✓ Branch 1 taken 245287 times.
27851468 if (cand_left) {
255
2/2
✓ Branch 0 taken 21141462 times.
✓ Branch 1 taken 13680447 times.
69643818 EXTEND(left + size, left[size - 1], size);
256
2/2
✓ Branch 0 taken 1164 times.
✓ Branch 1 taken 244123 times.
490574 } else if (cand_up_left) {
257
2/2
✓ Branch 0 taken 3656 times.
✓ Branch 1 taken 1164 times.
9640 EXTEND(left, left[-1], 2 * size);
258 2328 cand_left = 1;
259
2/2
✓ Branch 0 taken 233530 times.
✓ Branch 1 taken 10593 times.
488246 } else if (cand_up) {
260 467060 left[-1] = top[0];
261
2/2
✓ Branch 0 taken 1077642 times.
✓ Branch 1 taken 233530 times.
2622344 EXTEND(left, left[-1], 2 * size);
262 467060 cand_up_left = 1;
263 467060 cand_left = 1;
264
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 10253 times.
21186 } else if (cand_up_right) {
265
2/2
✓ Branch 0 taken 726 times.
✓ Branch 1 taken 340 times.
2132 EXTEND(top, top[size], size);
266 680 left[-1] = top[size];
267
2/2
✓ Branch 0 taken 1452 times.
✓ Branch 1 taken 340 times.
3584 EXTEND(left, left[-1], 2 * size);
268 680 cand_up = 1;
269 680 cand_up_left = 1;
270 680 cand_left = 1;
271 } else { // No samples available
272 20506 left[-1] = (1 << (BIT_DEPTH - 1));
273
2/2
✓ Branch 0 taken 58134 times.
✓ Branch 1 taken 10253 times.
136774 EXTEND(top, left[-1], 2 * size);
274
2/2
✓ Branch 0 taken 58134 times.
✓ Branch 1 taken 10253 times.
136774 EXTEND(left, left[-1], 2 * size);
275 }
276 }
277
278
2/2
✓ Branch 0 taken 10601 times.
✓ Branch 1 taken 20827275 times.
41675752 if (!cand_left)
279
2/2
✓ Branch 0 taken 29633 times.
✓ Branch 1 taken 10601 times.
80468 EXTEND(left, left[size], size);
280
2/2
✓ Branch 0 taken 378389 times.
✓ Branch 1 taken 20459487 times.
41675752 if (!cand_up_left) {
281 756778 left[-1] = left[0];
282 }
283
2/2
✓ Branch 0 taken 378391 times.
✓ Branch 1 taken 20459485 times.
41675752 if (!cand_up)
284
2/2
✓ Branch 0 taken 791174 times.
✓ Branch 1 taken 378391 times.
2339130 EXTEND(top, left[-1], size);
285
2/2
✓ Branch 0 taken 7550707 times.
✓ Branch 1 taken 13287169 times.
41675752 if (!cand_up_right)
286
2/2
✓ Branch 0 taken 11302230 times.
✓ Branch 1 taken 7550707 times.
37705874 EXTEND(top + size, top[size - 1], size);
287
288 41675752 top[-1] = left[-1];
289
290 // Filtering process
291
6/6
✓ Branch 0 taken 19951331 times.
✓ Branch 1 taken 886545 times.
✓ Branch 2 taken 10565880 times.
✓ Branch 3 taken 9385451 times.
✓ Branch 4 taken 532762 times.
✓ Branch 5 taken 10033118 times.
41675752 if (!sps->intra_smoothing_disabled && (c_idx == 0 || sps->chroma_format_idc == 3)) {
292
4/4
✓ Branch 0 taken 8873662 times.
✓ Branch 1 taken 1044551 times.
✓ Branch 2 taken 3175235 times.
✓ Branch 3 taken 5698427 times.
19836426 if (mode != INTRA_DC && size != 4){
293 6350470 int intra_hor_ver_dist_thresh[] = { 7, 1, 0 };
294 6350470 int min_dist_vert_hor = FFMIN(FFABS((int)(mode - 26U)),
295 FFABS((int)(mode - 10U)));
296
2/2
✓ Branch 0 taken 1303117 times.
✓ Branch 1 taken 1872118 times.
6350470 if (min_dist_vert_hor > intra_hor_ver_dist_thresh[log2_size - 3]) {
297 2606234 int threshold = 1 << (BIT_DEPTH - 5);
298
6/6
✓ Branch 0 taken 1148326 times.
✓ Branch 1 taken 154791 times.
✓ Branch 2 taken 1094436 times.
✓ Branch 3 taken 53890 times.
✓ Branch 4 taken 150584 times.
✓ Branch 5 taken 943852 times.
2606234 if (sps->strong_intra_smoothing_enabled && c_idx == 0 &&
299 301168 log2_size == 5 &&
300
2/2
✓ Branch 0 taken 62745 times.
✓ Branch 1 taken 87839 times.
301168 FFABS(top[-1] + top[63] - 2 * top[31]) < threshold &&
301
2/2
✓ Branch 0 taken 37268 times.
✓ Branch 1 taken 25477 times.
125490 FFABS(left[-1] + left[63] - 2 * left[31]) < threshold) {
302 // We can't just overwrite values in top because it could be
303 // a pointer into src
304 74536 filtered_top[-1] = top[-1];
305 74536 filtered_top[63] = top[63];
306
2/2
✓ Branch 0 taken 2347884 times.
✓ Branch 1 taken 37268 times.
4770304 for (i = 0; i < 63; i++)
307 4695768 filtered_top[i] = ((64 - (i + 1)) * top[-1] +
308 4695768 (i + 1) * top[63] + 32) >> 6;
309
2/2
✓ Branch 0 taken 2347884 times.
✓ Branch 1 taken 37268 times.
4770304 for (i = 0; i < 63; i++)
310 4695768 left[i] = ((64 - (i + 1)) * left[-1] +
311 4695768 (i + 1) * left[63] + 32) >> 6;
312 74536 top = filtered_top;
313 } else {
314 2531698 filtered_left[2 * size - 1] = left[2 * size - 1];
315 2531698 filtered_top[2 * size - 1] = top[2 * size - 1];
316
2/2
✓ Branch 0 taken 34099239 times.
✓ Branch 1 taken 1265849 times.
70730176 for (i = 2 * size - 2; i >= 0; i--)
317 68198478 filtered_left[i] = (left[i + 1] + 2 * left[i] +
318 68198478 left[i - 1] + 2) >> 2;
319 2531698 filtered_top[-1] =
320 2531698 filtered_left[-1] = (left[0] + 2 * left[-1] + top[0] + 2) >> 2;
321
2/2
✓ Branch 0 taken 34099239 times.
✓ Branch 1 taken 1265849 times.
70730176 for (i = 2 * size - 2; i >= 0; i--)
322 68198478 filtered_top[i] = (top[i + 1] + 2 * top[i] +
323 68198478 top[i - 1] + 2) >> 2;
324 2531698 left = filtered_left;
325 2531698 top = filtered_top;
326 }
327 }
328 }
329 }
330
331
3/3
✓ Branch 0 taken 4429672 times.
✓ Branch 1 taken 2746796 times.
✓ Branch 2 taken 13661408 times.
41675752 switch (mode) {
332 8859344 case INTRA_PLANAR:
333 8859344 s->hpc.pred_planar[log2_size - 2]((uint8_t *)src, (uint8_t *)top,
334 (uint8_t *)left, stride);
335 8859344 break;
336 5493592 case INTRA_DC:
337 5493592 s->hpc.pred_dc((uint8_t *)src, (uint8_t *)top,
338 (uint8_t *)left, stride, log2_size, c_idx);
339 5493592 break;
340 27322816 default:
341 27322816 s->hpc.pred_angular[log2_size - 2]((uint8_t *)src, (uint8_t *)top,
342 (uint8_t *)left, stride, c_idx,
343 mode);
344 27322816 break;
345 }
346 41675752 }
347
348 #define INTRA_PRED(size) \
349 static void FUNC(intra_pred_ ## size)(HEVCLocalContext *lc, const HEVCPPS *pps, \
350 int x0, int y0, int c_idx) \
351 { \
352 FUNC(intra_pred)(lc, pps, x0, y0, size, c_idx); \
353 }
354
355 29462288 INTRA_PRED(2)
356 8641052 INTRA_PRED(3)
357 2966110 INTRA_PRED(4)
358 606302 INTRA_PRED(5)
359
360 #undef INTRA_PRED
361
362 8859344 static av_always_inline void FUNC(pred_planar)(uint8_t *_src, const uint8_t *_top,
363 const uint8_t *_left, ptrdiff_t stride,
364 int trafo_size)
365 {
366 int x, y;
367 8859344 pixel *src = (pixel *)_src;
368 8859344 const pixel *top = (const pixel *)_top;
369 8859344 const pixel *left = (const pixel *)_left;
370 8859344 int size = 1 << trafo_size;
371
2/2
✓ Branch 0 taken 28561772 times.
✓ Branch 1 taken 4429672 times.
65982888 for (y = 0; y < size; y++)
372
2/2
✓ Branch 0 taken 295992592 times.
✓ Branch 1 taken 28561772 times.
649108728 for (x = 0; x < size; x++)
373 591985184 POS(x, y) = ((size - 1 - x) * left[y] + (x + 1) * top[size] +
374 591985184 (size - 1 - y) * top[x] + (y + 1) * left[size] + size) >> (trafo_size + 1);
375 8859344 }
376
377 #define PRED_PLANAR(size)\
378 static void FUNC(pred_planar_ ## size)(uint8_t *src, const uint8_t *top, \
379 const uint8_t *left, ptrdiff_t stride) \
380 { \
381 FUNC(pred_planar)(src, top, left, stride, size + 2); \
382 }
383
384 6006010 PRED_PLANAR(0)
385 1916770 PRED_PLANAR(1)
386 762794 PRED_PLANAR(2)
387 173770 PRED_PLANAR(3)
388
389 #undef PRED_PLANAR
390
391 5493592 static void FUNC(pred_dc)(uint8_t *_src, const uint8_t *_top,
392 const uint8_t *_left,
393 ptrdiff_t stride, int log2_size, int c_idx)
394 {
395 int i, j, x, y;
396 5493592 int size = (1 << log2_size);
397 5493592 pixel *src = (pixel *)_src;
398 5493592 const pixel *top = (const pixel *)_top;
399 5493592 const pixel *left = (const pixel *)_left;
400 5493592 int dc = size;
401 pixel4 a;
402
2/2
✓ Branch 0 taken 19529992 times.
✓ Branch 1 taken 2746796 times.
44553576 for (i = 0; i < size; i++)
403 39059984 dc += left[i] + top[i];
404
405 5493592 dc >>= log2_size + 1;
406
407 5493592 a = PIXEL_SPLAT_X4(dc);
408
409
2/2
✓ Branch 0 taken 19529992 times.
✓ Branch 1 taken 2746796 times.
44553576 for (i = 0; i < size; i++)
410
2/2
✓ Branch 0 taken 57180224 times.
✓ Branch 1 taken 19529992 times.
153420432 for (j = 0; j < size; j+=4)
411 114360448 AV_WN4P(&POS(j, i), a);
412
413
4/4
✓ Branch 0 taken 1027124 times.
✓ Branch 1 taken 1719672 times.
✓ Branch 2 taken 952092 times.
✓ Branch 3 taken 75032 times.
5493592 if (c_idx == 0 && size < 32) {
414 1904184 POS(0, 0) = (left[0] + 2 * dc + top[0] + 2) >> 2;
415
2/2
✓ Branch 0 taken 5415156 times.
✓ Branch 1 taken 952092 times.
12734496 for (x = 1; x < size; x++)
416 10830312 POS(x, 0) = (top[x] + 3 * dc + 2) >> 2;
417
2/2
✓ Branch 0 taken 5415156 times.
✓ Branch 1 taken 952092 times.
12734496 for (y = 1; y < size; y++)
418 10830312 POS(0, y) = (left[y] + 3 * dc + 2) >> 2;
419 }
420 5493592 }
421
422 27322816 static av_always_inline void FUNC(pred_angular)(uint8_t *_src,
423 const uint8_t *_top,
424 const uint8_t *_left,
425 ptrdiff_t stride, int c_idx,
426 int mode, int size)
427 {
428 int x, y;
429 27322816 pixel *src = (pixel *)_src;
430 27322816 const pixel *top = (const pixel *)_top;
431 27322816 const pixel *left = (const pixel *)_left;
432
433 static const int intra_pred_angle[] = {
434 32, 26, 21, 17, 13, 9, 5, 2, 0, -2, -5, -9, -13, -17, -21, -26, -32,
435 -26, -21, -17, -13, -9, -5, -2, 0, 2, 5, 9, 13, 17, 21, 26, 32
436 };
437 static const int inv_angle[] = {
438 -4096, -1638, -910, -630, -482, -390, -315, -256, -315, -390, -482,
439 -630, -910, -1638, -4096
440 };
441
442 27322816 int angle = intra_pred_angle[mode - 2];
443 pixel ref_array[3 * MAX_TB_SIZE + 4];
444 27322816 pixel *ref_tmp = ref_array + size;
445 const pixel *ref;
446 27322816 int last = (size * angle) >> 5;
447
448
2/2
✓ Branch 0 taken 7417997 times.
✓ Branch 1 taken 6243411 times.
27322816 if (mode >= 18) {
449 14835994 ref = top - 1;
450
4/4
✓ Branch 0 taken 2720712 times.
✓ Branch 1 taken 4697285 times.
✓ Branch 2 taken 1821342 times.
✓ Branch 3 taken 899370 times.
14835994 if (angle < 0 && last < -1) {
451
2/2
✓ Branch 0 taken 4500985 times.
✓ Branch 1 taken 1821342 times.
12644654 for (x = 0; x <= size; x += 4)
452 9001970 AV_WN4P(&ref_tmp[x], AV_RN4P(&top[x - 1]));
453
2/2
✓ Branch 0 taken 6648342 times.
✓ Branch 1 taken 1821342 times.
16939368 for (x = last; x <= -1; x++)
454 13296684 ref_tmp[x] = left[-1 + ((x * inv_angle[mode - 11] + 128) >> 8)];
455 3642684 ref = ref_tmp;
456 }
457
458
2/2
✓ Branch 0 taken 42502076 times.
✓ Branch 1 taken 7417997 times.
99840146 for (y = 0; y < size; y++) {
459 85004152 int idx = ((y + 1) * angle) >> 5;
460 85004152 int fact = ((y + 1) * angle) & 31;
461
2/2
✓ Branch 0 taken 25370124 times.
✓ Branch 1 taken 17131952 times.
85004152 if (fact) {
462
2/2
✓ Branch 0 taken 51801548 times.
✓ Branch 1 taken 25370124 times.
154343344 for (x = 0; x < size; x += 4) {
463 103603096 POS(x , y) = ((32 - fact) * ref[x + idx + 1] +
464 103603096 fact * ref[x + idx + 2] + 16) >> 5;
465 103603096 POS(x + 1, y) = ((32 - fact) * ref[x + 1 + idx + 1] +
466 103603096 fact * ref[x + 1 + idx + 2] + 16) >> 5;
467 103603096 POS(x + 2, y) = ((32 - fact) * ref[x + 2 + idx + 1] +
468 103603096 fact * ref[x + 2 + idx + 2] + 16) >> 5;
469 103603096 POS(x + 3, y) = ((32 - fact) * ref[x + 3 + idx + 1] +
470 103603096 fact * ref[x + 3 + idx + 2] + 16) >> 5;
471 }
472 } else {
473
2/2
✓ Branch 0 taken 38279016 times.
✓ Branch 1 taken 17131952 times.
110821936 for (x = 0; x < size; x += 4)
474 76558032 AV_WN4P(&POS(x, y), AV_RN4P(&ref[x + idx + 1]));
475 }
476 }
477
6/6
✓ Branch 0 taken 2254151 times.
✓ Branch 1 taken 5163846 times.
✓ Branch 2 taken 860717 times.
✓ Branch 3 taken 1393434 times.
✓ Branch 4 taken 833278 times.
✓ Branch 5 taken 27439 times.
14835994 if (mode == 26 && c_idx == 0 && size < 32) {
478
2/2
✓ Branch 0 taken 4979404 times.
✓ Branch 1 taken 833278 times.
11625364 for (y = 0; y < size; y++)
479 9958808 POS(0, y) = av_clip_pixel(top[0] + ((left[y] - left[-1]) >> 1));
480 }
481 } else {
482 12486822 ref = left - 1;
483
4/4
✓ Branch 0 taken 2041317 times.
✓ Branch 1 taken 4202094 times.
✓ Branch 2 taken 1220195 times.
✓ Branch 3 taken 821122 times.
12486822 if (angle < 0 && last < -1) {
484
2/2
✓ Branch 0 taken 3060515 times.
✓ Branch 1 taken 1220195 times.
8561420 for (x = 0; x <= size; x += 4)
485 6121030 AV_WN4P(&ref_tmp[x], AV_RN4P(&left[x - 1]));
486
2/2
✓ Branch 0 taken 4128550 times.
✓ Branch 1 taken 1220195 times.
10697490 for (x = last; x <= -1; x++)
487 8257100 ref_tmp[x] = top[-1 + ((x * inv_angle[mode - 11] + 128) >> 8)];
488 2440390 ref = ref_tmp;
489 }
490
491
2/2
✓ Branch 0 taken 36324656 times.
✓ Branch 1 taken 6243411 times.
85136134 for (x = 0; x < size; x++) {
492 72649312 int idx = ((x + 1) * angle) >> 5;
493 72649312 int fact = ((x + 1) * angle) & 31;
494
2/2
✓ Branch 0 taken 26064695 times.
✓ Branch 1 taken 10259961 times.
72649312 if (fact) {
495
2/2
✓ Branch 0 taken 224770272 times.
✓ Branch 1 taken 26064695 times.
501669934 for (y = 0; y < size; y++) {
496 449540544 POS(x, y) = ((32 - fact) * ref[y + idx + 1] +
497 449540544 fact * ref[y + idx + 2] + 16) >> 5;
498 }
499 } else {
500
2/2
✓ Branch 0 taken 92494656 times.
✓ Branch 1 taken 10259961 times.
205509234 for (y = 0; y < size; y++)
501 184989312 POS(x, y) = ref[y + idx + 1];
502 }
503 }
504
6/6
✓ Branch 0 taken 1458365 times.
✓ Branch 1 taken 4785046 times.
✓ Branch 2 taken 448201 times.
✓ Branch 3 taken 1010164 times.
✓ Branch 4 taken 433988 times.
✓ Branch 5 taken 14213 times.
12486822 if (mode == 10 && c_idx == 0 && size < 32) {
505
2/2
✓ Branch 0 taken 638610 times.
✓ Branch 1 taken 433988 times.
2145196 for (x = 0; x < size; x += 4) {
506 1277220 POS(x, 0) = av_clip_pixel(left[0] + ((top[x ] - top[-1]) >> 1));
507 1277220 POS(x + 1, 0) = av_clip_pixel(left[0] + ((top[x + 1] - top[-1]) >> 1));
508 1277220 POS(x + 2, 0) = av_clip_pixel(left[0] + ((top[x + 2] - top[-1]) >> 1));
509 1277220 POS(x + 3, 0) = av_clip_pixel(left[0] + ((top[x + 3] - top[-1]) >> 1));
510 }
511 }
512 }
513 27322816 }
514
515 20031358 static void FUNC(pred_angular_0)(uint8_t *src, const uint8_t *top,
516 const uint8_t *left,
517 ptrdiff_t stride, int c_idx, int mode)
518 {
519 20031358 FUNC(pred_angular)(src, top, left, stride, c_idx, mode, 1 << 2);
520 20031358 }
521
522 5450800 static void FUNC(pred_angular_1)(uint8_t *src, const uint8_t *top,
523 const uint8_t *left,
524 ptrdiff_t stride, int c_idx, int mode)
525 {
526 5450800 FUNC(pred_angular)(src, top, left, stride, c_idx, mode, 1 << 3);
527 5450800 }
528
529 1561214 static void FUNC(pred_angular_2)(uint8_t *src, const uint8_t *top,
530 const uint8_t *left,
531 ptrdiff_t stride, int c_idx, int mode)
532 {
533 1561214 FUNC(pred_angular)(src, top, left, stride, c_idx, mode, 1 << 4);
534 1561214 }
535
536 279444 static void FUNC(pred_angular_3)(uint8_t *src, const uint8_t *top,
537 const uint8_t *left,
538 ptrdiff_t stride, int c_idx, int mode)
539 {
540 279444 FUNC(pred_angular)(src, top, left, stride, c_idx, mode, 1 << 5);
541 279444 }
542
543 #undef EXTEND_LEFT_CIP
544 #undef EXTEND_RIGHT_CIP
545 #undef EXTEND_UP_CIP
546 #undef EXTEND_DOWN_CIP
547 #undef IS_INTRA
548 #undef MVF_PU
549 #undef MVF
550 #undef PU
551 #undef EXTEND
552 #undef MIN_TB_ADDR_ZS
553 #undef POS
554