FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/hevc/pred_template.c
Date: 2024-11-12 23:50:39
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 43928602 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 43928602 const HEVCSPS *const sps = pps->sps;
76 43928602 const HEVCContext *const s = lc->parent;
77 int i;
78 43928602 int hshift = sps->hshift[c_idx];
79 43928602 int vshift = sps->vshift[c_idx];
80 43928602 int size = (1 << log2_size);
81 43928602 int size_in_luma_h = size << hshift;
82 43928602 int size_in_tbs_h = size_in_luma_h >> sps->log2_min_tb_size;
83 43928602 int size_in_luma_v = size << vshift;
84 43928602 int size_in_tbs_v = size_in_luma_v >> sps->log2_min_tb_size;
85 43928602 int x = x0 >> hshift;
86 43928602 int y = y0 >> vshift;
87 43928602 int x_tb = (x0 >> sps->log2_min_tb_size) & sps->tb_mask;
88 43928602 int y_tb = (y0 >> sps->log2_min_tb_size) & sps->tb_mask;
89
6/6
✓ Branch 0 taken 11789144 times.
✓ Branch 1 taken 10175157 times.
✓ Branch 2 taken 216896 times.
✓ Branch 3 taken 11572248 times.
✓ Branch 4 taken 108448 times.
✓ Branch 5 taken 108448 times.
43928602 int spin = c_idx && !size_in_tbs_v && ((2 * y0) & (1 << sps->log2_min_tb_size));
90
91 43928602 int cur_tb_addr = MIN_TB_ADDR_ZS(x_tb, y_tb);
92
93 43928602 ptrdiff_t stride = s->cur_frame->f->linesize[c_idx] / sizeof(pixel);
94 43928602 pixel *src = (pixel*)s->cur_frame->f->data[c_idx] + x + y * stride;
95
96 43928602 int min_pu_width = sps->min_pu_width;
97
98
2/2
✓ Branch 0 taken 11789144 times.
✓ Branch 1 taken 10175157 times.
43928602 enum IntraPredMode mode = c_idx ? lc->tu.intra_pred_mode_c :
99 20350314 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 43928602 pixel *left = left_array + 1;
107 43928602 pixel *top = top_array + 1;
108 43928602 pixel *filtered_left = filtered_left_array + 1;
109 43928602 pixel *filtered_top = filtered_top_array + 1;
110
4/4
✓ Branch 0 taken 18421955 times.
✓ Branch 1 taken 3542346 times.
✓ Branch 2 taken 7250374 times.
✓ Branch 3 taken 11171581 times.
43928602 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 43928602 int cand_left = lc->na.cand_left;
112 43928602 int cand_up_left = lc->na.cand_up_left;
113 43928602 int cand_up = lc->na.cand_up;
114
6/6
✓ Branch 0 taken 18970002 times.
✓ Branch 1 taken 2994299 times.
✓ Branch 2 taken 18888794 times.
✓ Branch 3 taken 81208 times.
✓ Branch 4 taken 14050498 times.
✓ Branch 5 taken 4838296 times.
43928602 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 43928602 int bottom_left_size = (FFMIN(y0 + 2 * size_in_luma_v, sps->height) -
117 43928602 (y0 + size_in_luma_v)) >> vshift;
118 43928602 int top_right_size = (FFMIN(x0 + 2 * size_in_luma_h, sps->width) -
119 43928602 (x0 + size_in_luma_h)) >> hshift;
120
121
2/2
✓ Branch 0 taken 135573 times.
✓ Branch 1 taken 21828728 times.
43928602 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 21324202 times.
✓ Branch 1 taken 640099 times.
43928602 if (cand_up_left) {
170 42648404 left[-1] = POS(-1, -1);
171 42648404 top[-1] = left[-1];
172 }
173
2/2
✓ Branch 0 taken 21573216 times.
✓ Branch 1 taken 391085 times.
43928602 if (cand_up)
174 43146432 memcpy(top, src - stride, size * sizeof(pixel));
175
2/2
✓ Branch 0 taken 14044911 times.
✓ Branch 1 taken 7919390 times.
43928602 if (cand_up_right) {
176 28089822 memcpy(top + size, src - stride + size, size * sizeof(pixel));
177
2/2
✓ Branch 0 taken 26750 times.
✓ Branch 1 taken 14044911 times.
28143322 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 21702886 times.
✓ Branch 1 taken 261415 times.
43928602 if (cand_left)
181
2/2
✓ Branch 0 taken 134154024 times.
✓ Branch 1 taken 21702886 times.
311713820 for (i = 0; i < size; i++)
182 268308048 left[i] = POS(-1, i);
183
2/2
✓ Branch 0 taken 7247471 times.
✓ Branch 1 taken 14716830 times.
43928602 if (cand_bottom_left) {
184
2/2
✓ Branch 0 taken 42565144 times.
✓ Branch 1 taken 7247471 times.
99625230 for (i = size; i < size + bottom_left_size; i++)
185 85130288 left[i] = POS(-1, i);
186
2/2
✓ Branch 0 taken 34674 times.
✓ Branch 1 taken 7247471 times.
14564290 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 21828728 times.
43928602 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 14716830 times.
✓ Branch 1 taken 7247471 times.
43928602 if (!cand_bottom_left) {
254
2/2
✓ Branch 0 taken 14455763 times.
✓ Branch 1 taken 261067 times.
29433660 if (cand_left) {
255
2/2
✓ Branch 0 taken 22863112 times.
✓ Branch 1 taken 14455763 times.
74637750 EXTEND(left + size, left[size - 1], size);
256
2/2
✓ Branch 0 taken 1164 times.
✓ Branch 1 taken 259903 times.
522134 } 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 249016 times.
✓ Branch 1 taken 10887 times.
519806 } else if (cand_up) {
260 498032 left[-1] = top[0];
261
2/2
✓ Branch 0 taken 1175334 times.
✓ Branch 1 taken 249016 times.
2848700 EXTEND(left, left[-1], 2 * size);
262 498032 cand_up_left = 1;
263 498032 cand_left = 1;
264
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 10547 times.
21774 } 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 21094 left[-1] = (1 << (BIT_DEPTH - 1));
273
2/2
✓ Branch 0 taken 61042 times.
✓ Branch 1 taken 10547 times.
143178 EXTEND(top, left[-1], 2 * size);
274
2/2
✓ Branch 0 taken 61042 times.
✓ Branch 1 taken 10547 times.
143178 EXTEND(left, left[-1], 2 * size);
275 }
276 }
277
278
2/2
✓ Branch 0 taken 10895 times.
✓ Branch 1 taken 21953406 times.
43928602 if (!cand_left)
279
2/2
✓ Branch 0 taken 31087 times.
✓ Branch 1 taken 10895 times.
83964 EXTEND(left, left[size], size);
280
2/2
✓ Branch 0 taken 390743 times.
✓ Branch 1 taken 21573558 times.
43928602 if (!cand_up_left) {
281 781486 left[-1] = left[0];
282 }
283
2/2
✓ Branch 0 taken 390745 times.
✓ Branch 1 taken 21573556 times.
43928602 if (!cand_up)
284
2/2
✓ Branch 0 taken 848842 times.
✓ Branch 1 taken 390745 times.
2479174 EXTEND(top, left[-1], size);
285
2/2
✓ Branch 0 taken 7919390 times.
✓ Branch 1 taken 14044911 times.
43928602 if (!cand_up_right)
286
2/2
✓ Branch 0 taken 12087532 times.
✓ Branch 1 taken 7919390 times.
40013844 EXTEND(top + size, top[size - 1], size);
287
288 43928602 top[-1] = left[-1];
289
290 // Filtering process
291
6/6
✓ Branch 0 taken 21077756 times.
✓ Branch 1 taken 886545 times.
✓ Branch 2 taken 11209416 times.
✓ Branch 3 taken 9868340 times.
✓ Branch 4 taken 532762 times.
✓ Branch 5 taken 10676654 times.
43928602 if (!sps->intra_smoothing_disabled && (c_idx == 0 || sps->chroma_format_idc == 3)) {
292
4/4
✓ Branch 0 taken 9309368 times.
✓ Branch 1 taken 1091734 times.
✓ Branch 2 taken 3416221 times.
✓ Branch 3 taken 5893147 times.
20802204 if (mode != INTRA_DC && size != 4){
293 6832442 int intra_hor_ver_dist_thresh[] = { 7, 1, 0 };
294 6832442 int min_dist_vert_hor = FFMIN(FFABS((int)(mode - 26U)),
295 FFABS((int)(mode - 10U)));
296
2/2
✓ Branch 0 taken 1443100 times.
✓ Branch 1 taken 1973121 times.
6832442 if (min_dist_vert_hor > intra_hor_ver_dist_thresh[log2_size - 3]) {
297 2886200 int threshold = 1 << (BIT_DEPTH - 5);
298
6/6
✓ Branch 0 taken 1277708 times.
✓ Branch 1 taken 165392 times.
✓ Branch 2 taken 1223818 times.
✓ Branch 3 taken 53890 times.
✓ Branch 4 taken 192813 times.
✓ Branch 5 taken 1031005 times.
2886200 if (sps->strong_intra_smoothing_enabled && c_idx == 0 &&
299 385626 log2_size == 5 &&
300
2/2
✓ Branch 0 taken 84698 times.
✓ Branch 1 taken 108115 times.
385626 FFABS(top[-1] + top[63] - 2 * top[31]) < threshold &&
301
2/2
✓ Branch 0 taken 51873 times.
✓ Branch 1 taken 32825 times.
169396 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 103746 filtered_top[-1] = top[-1];
305 103746 filtered_top[63] = top[63];
306
2/2
✓ Branch 0 taken 3267999 times.
✓ Branch 1 taken 51873 times.
6639744 for (i = 0; i < 63; i++)
307 6535998 filtered_top[i] = ((64 - (i + 1)) * top[-1] +
308 6535998 (i + 1) * top[63] + 32) >> 6;
309
2/2
✓ Branch 0 taken 3267999 times.
✓ Branch 1 taken 51873 times.
6639744 for (i = 0; i < 63; i++)
310 6535998 left[i] = ((64 - (i + 1)) * left[-1] +
311 6535998 (i + 1) * left[63] + 32) >> 6;
312 103746 top = filtered_top;
313 } else {
314 2782454 filtered_left[2 * size - 1] = left[2 * size - 1];
315 2782454 filtered_top[2 * size - 1] = top[2 * size - 1];
316
2/2
✓ Branch 0 taken 38434853 times.
✓ Branch 1 taken 1391227 times.
79652160 for (i = 2 * size - 2; i >= 0; i--)
317 76869706 filtered_left[i] = (left[i + 1] + 2 * left[i] +
318 76869706 left[i - 1] + 2) >> 2;
319 2782454 filtered_top[-1] =
320 2782454 filtered_left[-1] = (left[0] + 2 * left[-1] + top[0] + 2) >> 2;
321
2/2
✓ Branch 0 taken 38434853 times.
✓ Branch 1 taken 1391227 times.
79652160 for (i = 2 * size - 2; i >= 0; i--)
322 76869706 filtered_top[i] = (top[i + 1] + 2 * top[i] +
323 76869706 top[i - 1] + 2) >> 2;
324 2782454 left = filtered_left;
325 2782454 top = filtered_top;
326 }
327 }
328 }
329 }
330
331
3/3
✓ Branch 0 taken 4747415 times.
✓ Branch 1 taken 2865611 times.
✓ Branch 2 taken 14351275 times.
43928602 switch (mode) {
332 9494830 case INTRA_PLANAR:
333 9494830 s->hpc.pred_planar[log2_size - 2]((uint8_t *)src, (uint8_t *)top,
334 (uint8_t *)left, stride);
335 9494830 break;
336 5731222 case INTRA_DC:
337 5731222 s->hpc.pred_dc((uint8_t *)src, (uint8_t *)top,
338 (uint8_t *)left, stride, log2_size, c_idx);
339 5731222 break;
340 28702550 default:
341 28702550 s->hpc.pred_angular[log2_size - 2]((uint8_t *)src, (uint8_t *)top,
342 (uint8_t *)left, stride, c_idx,
343 mode);
344 28702550 break;
345 }
346 43928602 }
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 30628400 INTRA_PRED(2)
356 9209938 INTRA_PRED(3)
357 3362690 INTRA_PRED(4)
358 727574 INTRA_PRED(5)
359
360 #undef INTRA_PRED
361
362 9494830 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 9494830 pixel *src = (pixel *)_src;
368 9494830 const pixel *top = (const pixel *)_top;
369 9494830 const pixel *left = (const pixel *)_left;
370 9494830 int size = 1 << trafo_size;
371
2/2
✓ Branch 0 taken 31690608 times.
✓ Branch 1 taken 4747415 times.
72876046 for (y = 0; y < size; y++)
372
2/2
✓ Branch 0 taken 346448096 times.
✓ Branch 1 taken 31690608 times.
756277408 for (x = 0; x < size; x++)
373 692896192 POS(x, y) = ((size - 1 - x) * left[y] + (x + 1) * top[size] +
374 692896192 (size - 1 - y) * top[x] + (y + 1) * left[size] + size) >> (trafo_size + 1);
375 9494830 }
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 6291588 PRED_PLANAR(0)
385 2072798 PRED_PLANAR(1)
386 908858 PRED_PLANAR(2)
387 221586 PRED_PLANAR(3)
388
389 #undef PRED_PLANAR
390
391 5731222 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 5731222 int size = (1 << log2_size);
397 5731222 pixel *src = (pixel *)_src;
398 5731222 const pixel *top = (const pixel *)_top;
399 5731222 const pixel *left = (const pixel *)_left;
400 5731222 int dc = size;
401 pixel4 a;
402
2/2
✓ Branch 0 taken 20671896 times.
✓ Branch 1 taken 2865611 times.
47075014 for (i = 0; i < size; i++)
403 41343792 dc += left[i] + top[i];
404
405 5731222 dc >>= log2_size + 1;
406
407 5731222 a = PIXEL_SPLAT_X4(dc);
408
409
2/2
✓ Branch 0 taken 20671896 times.
✓ Branch 1 taken 2865611 times.
47075014 for (i = 0; i < size; i++)
410
2/2
✓ Branch 0 taken 61747352 times.
✓ Branch 1 taken 20671896 times.
164838496 for (j = 0; j < size; j+=4)
411 123494704 AV_WN4P(&POS(j, i), a);
412
413
4/4
✓ Branch 0 taken 1074307 times.
✓ Branch 1 taken 1791304 times.
✓ Branch 2 taken 990393 times.
✓ Branch 3 taken 83914 times.
5731222 if (c_idx == 0 && size < 32) {
414 1980786 POS(0, 0) = (left[0] + 2 * dc + top[0] + 2) >> 2;
415
2/2
✓ Branch 0 taken 5667743 times.
✓ Branch 1 taken 990393 times.
13316272 for (x = 1; x < size; x++)
416 11335486 POS(x, 0) = (top[x] + 3 * dc + 2) >> 2;
417
2/2
✓ Branch 0 taken 5667743 times.
✓ Branch 1 taken 990393 times.
13316272 for (y = 1; y < size; y++)
418 11335486 POS(0, y) = (left[y] + 3 * dc + 2) >> 2;
419 }
420 5731222 }
421
422 28702550 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 28702550 pixel *src = (pixel *)_src;
430 28702550 const pixel *top = (const pixel *)_top;
431 28702550 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 28702550 int angle = intra_pred_angle[mode - 2];
443 pixel ref_array[3 * MAX_TB_SIZE + 4];
444 28702550 pixel *ref_tmp = ref_array + size;
445 const pixel *ref;
446 28702550 int last = (size * angle) >> 5;
447
448
2/2
✓ Branch 0 taken 7852848 times.
✓ Branch 1 taken 6498427 times.
28702550 if (mode >= 18) {
449 15705696 ref = top - 1;
450
4/4
✓ Branch 0 taken 2926437 times.
✓ Branch 1 taken 4926411 times.
✓ Branch 2 taken 1971571 times.
✓ Branch 3 taken 954866 times.
15705696 if (angle < 0 && last < -1) {
451
2/2
✓ Branch 0 taken 4948932 times.
✓ Branch 1 taken 1971571 times.
13841006 for (x = 0; x <= size; x += 4)
452 9897864 AV_WN4P(&ref_tmp[x], AV_RN4P(&top[x - 1]));
453
2/2
✓ Branch 0 taken 7360282 times.
✓ Branch 1 taken 1971571 times.
18663706 for (x = last; x <= -1; x++)
454 14720564 ref_tmp[x] = left[-1 + ((x * inv_angle[mode - 11] + 128) >> 8)];
455 3943142 ref = ref_tmp;
456 }
457
458
2/2
✓ Branch 0 taken 45657872 times.
✓ Branch 1 taken 7852848 times.
107021440 for (y = 0; y < size; y++) {
459 91315744 int idx = ((y + 1) * angle) >> 5;
460 91315744 int fact = ((y + 1) * angle) & 31;
461
2/2
✓ Branch 0 taken 27583411 times.
✓ Branch 1 taken 18074461 times.
91315744 if (fact) {
462
2/2
✓ Branch 0 taken 58371684 times.
✓ Branch 1 taken 27583411 times.
171910190 for (x = 0; x < size; x += 4) {
463 116743368 POS(x , y) = ((32 - fact) * ref[x + idx + 1] +
464 116743368 fact * ref[x + idx + 2] + 16) >> 5;
465 116743368 POS(x + 1, y) = ((32 - fact) * ref[x + 1 + idx + 1] +
466 116743368 fact * ref[x + 1 + idx + 2] + 16) >> 5;
467 116743368 POS(x + 2, y) = ((32 - fact) * ref[x + 2 + idx + 1] +
468 116743368 fact * ref[x + 2 + idx + 2] + 16) >> 5;
469 116743368 POS(x + 3, y) = ((32 - fact) * ref[x + 3 + idx + 1] +
470 116743368 fact * ref[x + 3 + idx + 2] + 16) >> 5;
471 }
472 } else {
473
2/2
✓ Branch 0 taken 41158164 times.
✓ Branch 1 taken 18074461 times.
118465250 for (x = 0; x < size; x += 4)
474 82316328 AV_WN4P(&POS(x, y), AV_RN4P(&ref[x + idx + 1]));
475 }
476 }
477
6/6
✓ Branch 0 taken 2345127 times.
✓ Branch 1 taken 5507721 times.
✓ Branch 2 taken 896905 times.
✓ Branch 3 taken 1448222 times.
✓ Branch 4 taken 867115 times.
✓ Branch 5 taken 29790 times.
15705696 if (mode == 26 && c_idx == 0 && size < 32) {
478
2/2
✓ Branch 0 taken 5208604 times.
✓ Branch 1 taken 867115 times.
12151438 for (y = 0; y < size; y++)
479 10417208 POS(0, y) = av_clip_pixel(top[0] + ((left[y] - left[-1]) >> 1));
480 }
481 } else {
482 12996854 ref = left - 1;
483
4/4
✓ Branch 0 taken 2134971 times.
✓ Branch 1 taken 4363456 times.
✓ Branch 2 taken 1290660 times.
✓ Branch 3 taken 844311 times.
12996854 if (angle < 0 && last < -1) {
484
2/2
✓ Branch 0 taken 3283771 times.
✓ Branch 1 taken 1290660 times.
9148862 for (x = 0; x <= size; x += 4)
485 6567542 AV_WN4P(&ref_tmp[x], AV_RN4P(&left[x - 1]));
486
2/2
✓ Branch 0 taken 4437602 times.
✓ Branch 1 taken 1290660 times.
11456524 for (x = last; x <= -1; x++)
487 8875204 ref_tmp[x] = top[-1 + ((x * inv_angle[mode - 11] + 128) >> 8)];
488 2581320 ref = ref_tmp;
489 }
490
491
2/2
✓ Branch 0 taken 38618880 times.
✓ Branch 1 taken 6498427 times.
90234614 for (x = 0; x < size; x++) {
492 77237760 int idx = ((x + 1) * angle) >> 5;
493 77237760 int fact = ((x + 1) * angle) & 31;
494
2/2
✓ Branch 0 taken 27474726 times.
✓ Branch 1 taken 11144154 times.
77237760 if (fact) {
495
2/2
✓ Branch 0 taken 245634256 times.
✓ Branch 1 taken 27474726 times.
546217964 for (y = 0; y < size; y++) {
496 491268512 POS(x, y) = ((32 - fact) * ref[y + idx + 1] +
497 491268512 fact * ref[y + idx + 2] + 16) >> 5;
498 }
499 } else {
500
2/2
✓ Branch 0 taken 105496272 times.
✓ Branch 1 taken 11144154 times.
233280852 for (y = 0; y < size; y++)
501 210992544 POS(x, y) = ref[y + idx + 1];
502 }
503 }
504
6/6
✓ Branch 0 taken 1536817 times.
✓ Branch 1 taken 4961610 times.
✓ Branch 2 taken 466987 times.
✓ Branch 3 taken 1069830 times.
✓ Branch 4 taken 450607 times.
✓ Branch 5 taken 16380 times.
12996854 if (mode == 10 && c_idx == 0 && size < 32) {
505
2/2
✓ Branch 0 taken 669421 times.
✓ Branch 1 taken 450607 times.
2240056 for (x = 0; x < size; x += 4) {
506 1338842 POS(x, 0) = av_clip_pixel(left[0] + ((top[x ] - top[-1]) >> 1));
507 1338842 POS(x + 1, 0) = av_clip_pixel(left[0] + ((top[x + 1] - top[-1]) >> 1));
508 1338842 POS(x + 2, 0) = av_clip_pixel(left[0] + ((top[x + 2] - top[-1]) >> 1));
509 1338842 POS(x + 3, 0) = av_clip_pixel(left[0] + ((top[x + 3] - top[-1]) >> 1));
510 }
511 }
512 }
513 28702550 }
514
515 20801040 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 20801040 FUNC(pred_angular)(src, top, left, stride, c_idx, mode, 1 << 2);
520 20801040 }
521
522 5804624 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 5804624 FUNC(pred_angular)(src, top, left, stride, c_idx, mode, 1 << 3);
527 5804624 }
528
529 1761750 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 1761750 FUNC(pred_angular)(src, top, left, stride, c_idx, mode, 1 << 4);
534 1761750 }
535
536 335136 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 335136 FUNC(pred_angular)(src, top, left, stride, c_idx, mode, 1 << 5);
541 335136 }
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