FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/hevcpred_template.c
Date: 2022-01-28 07:56:06
Exec Total Coverage
Lines: 305 312 97.8%
Branches: 290 311 93.2%

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 "hevcpred.h"
27
28 #define POS(x, y) src[(x) + stride * (y)]
29
30 41214958 static av_always_inline void FUNC(intra_pred)(HEVCContext *s, int x0, int y0,
31 int log2_size, int c_idx)
32 {
33 #define PU(x) \
34 ((x) >> s->ps.sps->log2_min_pu_size)
35 #define MVF(x, y) \
36 (s->ref->tab_mvf[(x) + (y) * min_pu_width])
37 #define MVF_PU(x, y) \
38 MVF(PU(x0 + ((x) * (1 << hshift))), PU(y0 + ((y) * (1 << vshift))))
39 #define IS_INTRA(x, y) \
40 (MVF_PU(x, y).pred_flag == PF_INTRA)
41 #define MIN_TB_ADDR_ZS(x, y) \
42 s->ps.pps->min_tb_addr_zs[(y) * (s->ps.sps->tb_mask+2) + (x)]
43 #define EXTEND(ptr, val, len) \
44 do { \
45 pixel4 pix = PIXEL_SPLAT_X4(val); \
46 for (i = 0; i < (len); i += 4) \
47 AV_WN4P(ptr + i, pix); \
48 } while (0)
49
50 #define EXTEND_RIGHT_CIP(ptr, start, length) \
51 for (i = start; i < (start) + (length); i += 4) \
52 if (!IS_INTRA(i, -1)) \
53 AV_WN4P(&ptr[i], a); \
54 else \
55 a = PIXEL_SPLAT_X4(ptr[i+3])
56 #define EXTEND_LEFT_CIP(ptr, start, length) \
57 for (i = start; i > (start) - (length); i--) \
58 if (!IS_INTRA(i - 1, -1)) \
59 ptr[i - 1] = ptr[i]
60 #define EXTEND_UP_CIP(ptr, start, length) \
61 for (i = (start); i > (start) - (length); i -= 4) \
62 if (!IS_INTRA(-1, i - 3)) \
63 AV_WN4P(&ptr[i - 3], a); \
64 else \
65 a = PIXEL_SPLAT_X4(ptr[i - 3])
66 #define EXTEND_DOWN_CIP(ptr, start, length) \
67 for (i = start; i < (start) + (length); i += 4) \
68 if (!IS_INTRA(-1, i)) \
69 AV_WN4P(&ptr[i], a); \
70 else \
71 a = PIXEL_SPLAT_X4(ptr[i + 3])
72
73 41214958 HEVCLocalContext *lc = s->HEVClc;
74 int i;
75 41214958 int hshift = s->ps.sps->hshift[c_idx];
76 41214958 int vshift = s->ps.sps->vshift[c_idx];
77 41214958 int size = (1 << log2_size);
78 41214958 int size_in_luma_h = size << hshift;
79 41214958 int size_in_tbs_h = size_in_luma_h >> s->ps.sps->log2_min_tb_size;
80 41214958 int size_in_luma_v = size << vshift;
81 41214958 int size_in_tbs_v = size_in_luma_v >> s->ps.sps->log2_min_tb_size;
82 41214958 int x = x0 >> hshift;
83 41214958 int y = y0 >> vshift;
84 41214958 int x_tb = (x0 >> s->ps.sps->log2_min_tb_size) & s->ps.sps->tb_mask;
85 41214958 int y_tb = (y0 >> s->ps.sps->log2_min_tb_size) & s->ps.sps->tb_mask;
86
6/6
✓ Branch 0 taken 11019528 times.
✓ Branch 1 taken 9587951 times.
✓ Branch 2 taken 216896 times.
✓ Branch 3 taken 10802632 times.
✓ Branch 4 taken 108448 times.
✓ Branch 5 taken 108448 times.
41214958 int spin = c_idx && !size_in_tbs_v && ((2 * y0) & (1 << s->ps.sps->log2_min_tb_size));
87
88 41214958 int cur_tb_addr = MIN_TB_ADDR_ZS(x_tb, y_tb);
89
90 41214958 ptrdiff_t stride = s->frame->linesize[c_idx] / sizeof(pixel);
91 41214958 pixel *src = (pixel*)s->frame->data[c_idx] + x + y * stride;
92
93 41214958 int min_pu_width = s->ps.sps->min_pu_width;
94
95
2/2
✓ Branch 0 taken 11019528 times.
✓ Branch 1 taken 9587951 times.
41214958 enum IntraPredMode mode = c_idx ? lc->tu.intra_pred_mode_c :
96 19175902 lc->tu.intra_pred_mode;
97 pixel4 a;
98 pixel left_array[2 * MAX_TB_SIZE + 1];
99 pixel filtered_left_array[2 * MAX_TB_SIZE + 1];
100 pixel top_array[2 * MAX_TB_SIZE + 1];
101 pixel filtered_top_array[2 * MAX_TB_SIZE + 1];
102
103 41214958 pixel *left = left_array + 1;
104 41214958 pixel *top = top_array + 1;
105 41214958 pixel *filtered_left = filtered_left_array + 1;
106 41214958 pixel *filtered_top = filtered_top_array + 1;
107
4/4
✓ Branch 0 taken 17374173 times.
✓ Branch 1 taken 3233306 times.
✓ Branch 2 taken 6846585 times.
✓ Branch 3 taken 10527588 times.
41214958 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) & s->ps.sps->tb_mask);
108 41214958 int cand_left = lc->na.cand_left;
109 41214958 int cand_up_left = lc->na.cand_up_left;
110 41214958 int cand_up = lc->na.cand_up;
111
6/6
✓ Branch 0 taken 17828462 times.
✓ Branch 1 taken 2779017 times.
✓ Branch 2 taken 17747254 times.
✓ Branch 3 taken 81208 times.
✓ Branch 4 taken 13136374 times.
✓ Branch 5 taken 4610880 times.
41214958 int cand_up_right = lc->na.cand_up_right && !spin && cur_tb_addr > MIN_TB_ADDR_ZS((x_tb + size_in_tbs_h) & s->ps.sps->tb_mask, y_tb - 1);
112
113 41214958 int bottom_left_size = (FFMIN(y0 + 2 * size_in_luma_v, s->ps.sps->height) -
114 41214958 (y0 + size_in_luma_v)) >> vshift;
115 41214958 int top_right_size = (FFMIN(x0 + 2 * size_in_luma_h, s->ps.sps->width) -
116 41214958 (x0 + size_in_luma_h)) >> hshift;
117
118
2/2
✓ Branch 0 taken 135525 times.
✓ Branch 1 taken 20471954 times.
41214958 if (s->ps.pps->constrained_intra_pred_flag == 1) {
119 271050 int size_in_luma_pu_v = PU(size_in_luma_v);
120 271050 int size_in_luma_pu_h = PU(size_in_luma_h);
121 271050 int on_pu_edge_x = !av_mod_uintp2(x0, s->ps.sps->log2_min_pu_size);
122 271050 int on_pu_edge_y = !av_mod_uintp2(y0, s->ps.sps->log2_min_pu_size);
123
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 135525 times.
271050 if (!size_in_luma_pu_h)
124 size_in_luma_pu_h++;
125
3/4
✓ Branch 0 taken 42080 times.
✓ Branch 1 taken 93445 times.
✓ Branch 2 taken 42080 times.
✗ Branch 3 not taken.
271050 if (cand_bottom_left == 1 && on_pu_edge_x) {
126 84160 int x_left_pu = PU(x0 - 1);
127 84160 int y_bottom_pu = PU(y0 + size_in_luma_v);
128 84160 int max = FFMIN(size_in_luma_pu_v, s->ps.sps->min_pu_height - y_bottom_pu);
129 84160 cand_bottom_left = 0;
130
2/2
✓ Branch 0 taken 47822 times.
✓ Branch 1 taken 42080 times.
179804 for (i = 0; i < max; i += 2)
131 95644 cand_bottom_left |= (MVF(x_left_pu, y_bottom_pu + i).pred_flag == PF_INTRA);
132 }
133
3/4
✓ Branch 0 taken 133107 times.
✓ Branch 1 taken 2418 times.
✓ Branch 2 taken 133107 times.
✗ Branch 3 not taken.
271050 if (cand_left == 1 && on_pu_edge_x) {
134 266214 int x_left_pu = PU(x0 - 1);
135 266214 int y_left_pu = PU(y0);
136 266214 int max = FFMIN(size_in_luma_pu_v, s->ps.sps->min_pu_height - y_left_pu);
137 266214 cand_left = 0;
138
2/2
✓ Branch 0 taken 154329 times.
✓ Branch 1 taken 133107 times.
574872 for (i = 0; i < max; i += 2)
139 308658 cand_left |= (MVF(x_left_pu, y_left_pu + i).pred_flag == PF_INTRA);
140 }
141
2/2
✓ Branch 0 taken 129084 times.
✓ Branch 1 taken 6441 times.
271050 if (cand_up_left == 1) {
142 258168 int x_left_pu = PU(x0 - 1);
143 258168 int y_top_pu = PU(y0 - 1);
144 258168 cand_up_left = MVF(x_left_pu, y_top_pu).pred_flag == PF_INTRA;
145 }
146
3/4
✓ Branch 0 taken 131403 times.
✓ Branch 1 taken 4122 times.
✓ Branch 2 taken 131403 times.
✗ Branch 3 not taken.
271050 if (cand_up == 1 && on_pu_edge_y) {
147 262806 int x_top_pu = PU(x0);
148 262806 int y_top_pu = PU(y0 - 1);
149 262806 int max = FFMIN(size_in_luma_pu_h, s->ps.sps->min_pu_width - x_top_pu);
150 262806 cand_up = 0;
151
2/2
✓ Branch 0 taken 151449 times.
✓ Branch 1 taken 131403 times.
565704 for (i = 0; i < max; i += 2)
152 302898 cand_up |= (MVF(x_top_pu + i, y_top_pu).pred_flag == PF_INTRA);
153 }
154
3/4
✓ Branch 0 taken 87193 times.
✓ Branch 1 taken 48332 times.
✓ Branch 2 taken 87193 times.
✗ Branch 3 not taken.
271050 if (cand_up_right == 1 && on_pu_edge_y) {
155 174386 int y_top_pu = PU(y0 - 1);
156 174386 int x_right_pu = PU(x0 + size_in_luma_h);
157 174386 int max = FFMIN(size_in_luma_pu_h, s->ps.sps->min_pu_width - x_right_pu);
158 174386 cand_up_right = 0;
159
2/2
✓ Branch 0 taken 100795 times.
✓ Branch 1 taken 87193 times.
375976 for (i = 0; i < max; i += 2)
160 201590 cand_up_right |= (MVF(x_right_pu + i, y_top_pu).pred_flag == PF_INTRA);
161 }
162 271050 memset(left, 128, 2 * MAX_TB_SIZE*sizeof(pixel));
163 271050 memset(top , 128, 2 * MAX_TB_SIZE*sizeof(pixel));
164 271050 top[-1] = 128;
165 }
166
2/2
✓ Branch 0 taken 20000298 times.
✓ Branch 1 taken 607181 times.
41214958 if (cand_up_left) {
167 40000596 left[-1] = POS(-1, -1);
168 40000596 top[-1] = left[-1];
169 }
170
2/2
✓ Branch 0 taken 20232202 times.
✓ Branch 1 taken 375277 times.
41214958 if (cand_up)
171 40464404 memcpy(top, src - stride, size * sizeof(pixel));
172
2/2
✓ Branch 0 taken 13130835 times.
✓ Branch 1 taken 7476644 times.
41214958 if (cand_up_right) {
173 26261670 memcpy(top + size, src - stride + size, size * sizeof(pixel));
174
2/2
✓ Branch 0 taken 26654 times.
✓ Branch 1 taken 13130835 times.
26314978 EXTEND(top + size + top_right_size, POS(size + top_right_size - 1, -1),
175 size - top_right_size);
176 }
177
2/2
✓ Branch 0 taken 20363561 times.
✓ Branch 1 taken 243918 times.
41214958 if (cand_left)
178
2/2
✓ Branch 0 taken 122399288 times.
✓ Branch 1 taken 20363561 times.
285525698 for (i = 0; i < size; i++)
179 244798576 left[i] = POS(-1, i);
180
2/2
✓ Branch 0 taken 6843694 times.
✓ Branch 1 taken 13763785 times.
41214958 if (cand_bottom_left) {
181
2/2
✓ Branch 0 taken 39319564 times.
✓ Branch 1 taken 6843694 times.
92326516 for (i = size; i < size + bottom_left_size; i++)
182 78639128 left[i] = POS(-1, i);
183
2/2
✓ Branch 0 taken 32326 times.
✓ Branch 1 taken 6843694 times.
13752040 EXTEND(left + size + bottom_left_size, POS(-1, size + bottom_left_size - 1),
184 size - bottom_left_size);
185 }
186
187
2/2
✓ Branch 0 taken 135525 times.
✓ Branch 1 taken 20471954 times.
41214958 if (s->ps.pps->constrained_intra_pred_flag == 1) {
188
10/10
✓ Branch 0 taken 96336 times.
✓ Branch 1 taken 39189 times.
✓ Branch 2 taken 8627 times.
✓ Branch 3 taken 87709 times.
✓ Branch 4 taken 7463 times.
✓ Branch 5 taken 1164 times.
✓ Branch 6 taken 2014 times.
✓ Branch 7 taken 5449 times.
✓ Branch 8 taken 340 times.
✓ Branch 9 taken 1674 times.
271050 if (cand_bottom_left || cand_left || cand_up_left || cand_up || cand_up_right) {
189 535404 int size_max_x = x0 + ((2 * size) << hshift) < s->ps.sps->width ?
190
2/2
✓ Branch 0 taken 131755 times.
✓ Branch 1 taken 2096 times.
267702 2 * size : (s->ps.sps->width - x0) >> hshift;
191 535404 int size_max_y = y0 + ((2 * size) << vshift) < s->ps.sps->height ?
192
2/2
✓ Branch 0 taken 128041 times.
✓ Branch 1 taken 5810 times.
267702 2 * size : (s->ps.sps->height - y0) >> vshift;
193
2/2
✓ Branch 0 taken 39189 times.
✓ Branch 1 taken 94662 times.
267702 int j = size + (cand_bottom_left? bottom_left_size: 0) -1;
194
2/2
✓ Branch 0 taken 52197 times.
✓ Branch 1 taken 81654 times.
267702 if (!cand_up_right) {
195 104394 size_max_x = x0 + ((size) << hshift) < s->ps.sps->width ?
196
2/2
✓ Branch 0 taken 1115 times.
✓ Branch 1 taken 51082 times.
104394 size : (s->ps.sps->width - x0) >> hshift;
197 }
198
2/2
✓ Branch 0 taken 94662 times.
✓ Branch 1 taken 39189 times.
267702 if (!cand_bottom_left) {
199 189324 size_max_y = y0 + (( size) << vshift) < s->ps.sps->height ?
200
2/2
✓ Branch 0 taken 2915 times.
✓ Branch 1 taken 91747 times.
189324 size : (s->ps.sps->height - y0) >> vshift;
201 }
202
6/6
✓ Branch 0 taken 94662 times.
✓ Branch 1 taken 39189 times.
✓ Branch 2 taken 6953 times.
✓ Branch 3 taken 87709 times.
✓ Branch 4 taken 1164 times.
✓ Branch 5 taken 5789 times.
267702 if (cand_bottom_left || cand_left || cand_up_left) {
203
4/4
✓ Branch 0 taken 135538 times.
✓ Branch 1 taken 1164 times.
✓ Branch 2 taken 8640 times.
✓ Branch 3 taken 126898 times.
273404 while (j > -1 && !IS_INTRA(-1, j))
204 17280 j--;
205
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128062 times.
256124 if (!IS_INTRA(-1, j)) {
206 j = 0;
207 while (j < size_max_x && !IS_INTRA(j, -1))
208 j++;
209 EXTEND_LEFT_CIP(top, j, j + 1);
210 left[-1] = top[-1];
211 }
212 } else {
213 11578 j = 0;
214
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))
215 7280 j++;
216
2/2
✓ Branch 0 taken 409 times.
✓ Branch 1 taken 5380 times.
11578 if (j > 0)
217
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 409 times.
818 if (cand_up_left) {
218 EXTEND_LEFT_CIP(top, j, j + 1);
219 } else {
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 267702 left[-1] = top[-1];
226
4/4
✓ Branch 0 taken 94662 times.
✓ Branch 1 taken 39189 times.
✓ Branch 2 taken 87709 times.
✓ Branch 3 taken 6953 times.
267702 if (cand_bottom_left || cand_left) {
227 253796 a = PIXEL_SPLAT_X4(left[-1]);
228
4/4
✓ Branch 0 taken 1258 times.
✓ Branch 1 taken 223167 times.
✓ Branch 2 taken 224425 times.
✓ Branch 3 taken 126898 times.
702646 EXTEND_DOWN_CIP(left, 0, size_max_y);
229 }
230
2/2
✓ Branch 0 taken 7301 times.
✓ Branch 1 taken 126550 times.
267702 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 94662 times.
✓ Branch 1 taken 39189 times.
267702 if (!cand_bottom_left)
233
2/2
✓ Branch 0 taken 131843 times.
✓ Branch 1 taken 94662 times.
453010 EXTEND(left + size, left[size - 1], size);
234
4/4
✓ Branch 0 taken 132299 times.
✓ Branch 1 taken 1552 times.
✓ Branch 2 taken 130185 times.
✓ Branch 3 taken 2114 times.
267702 if (x0 != 0 && y0 != 0) {
235 260370 a = PIXEL_SPLAT_X4(left[size_max_y - 1]);
236
4/4
✓ Branch 0 taken 8892 times.
✓ Branch 1 taken 218280 times.
✓ Branch 2 taken 227172 times.
✓ Branch 3 taken 130185 times.
714714 EXTEND_UP_CIP(left, size_max_y - 1, size_max_y);
237
2/2
✓ Branch 0 taken 7426 times.
✓ Branch 1 taken 122759 times.
260370 if (!IS_INTRA(-1, - 1))
238 14852 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 267702 top[-1] = left[-1];
246
2/2
✓ Branch 0 taken 131737 times.
✓ Branch 1 taken 2114 times.
267702 if (y0 != 0) {
247 263474 a = PIXEL_SPLAT_X4(left[-1]);
248
4/4
✓ Branch 0 taken 8323 times.
✓ Branch 1 taken 282171 times.
✓ Branch 2 taken 290494 times.
✓ Branch 3 taken 131737 times.
844462 EXTEND_RIGHT_CIP(top, 0, size_max_x);
249 }
250 }
251 }
252 // Infer the unavailable samples
253
2/2
✓ Branch 0 taken 13763785 times.
✓ Branch 1 taken 6843694 times.
41214958 if (!cand_bottom_left) {
254
2/2
✓ Branch 0 taken 13520215 times.
✓ Branch 1 taken 243570 times.
27527570 if (cand_left) {
255
2/2
✓ Branch 0 taken 20738171 times.
✓ Branch 1 taken 13520215 times.
68516772 EXTEND(left + size, left[size - 1], size);
256
2/2
✓ Branch 0 taken 1164 times.
✓ Branch 1 taken 242406 times.
487140 } 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 231906 times.
✓ Branch 1 taken 10500 times.
484812 } else if (cand_up) {
260 463812 left[-1] = top[0];
261
2/2
✓ Branch 0 taken 1067882 times.
✓ Branch 1 taken 231906 times.
2599576 EXTEND(left, left[-1], 2 * size);
262 463812 cand_up_left = 1;
263 463812 cand_left = 1;
264
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 10160 times.
21000 } 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 20320 left[-1] = (1 << (BIT_DEPTH - 1));
273
2/2
✓ Branch 0 taken 57374 times.
✓ Branch 1 taken 10160 times.
135068 EXTEND(top, left[-1], 2 * size);
274
2/2
✓ Branch 0 taken 57374 times.
✓ Branch 1 taken 10160 times.
135068 EXTEND(left, left[-1], 2 * size);
275 }
276 }
277
278
2/2
✓ Branch 0 taken 10508 times.
✓ Branch 1 taken 20596971 times.
41214958 if (!cand_left)
279
2/2
✓ Branch 0 taken 29253 times.
✓ Branch 1 taken 10508 times.
79522 EXTEND(left, left[size], size);
280
2/2
✓ Branch 0 taken 374935 times.
✓ Branch 1 taken 20232544 times.
41214958 if (!cand_up_left) {
281 749870 left[-1] = left[0];
282 }
283
2/2
✓ Branch 0 taken 374937 times.
✓ Branch 1 taken 20232542 times.
41214958 if (!cand_up)
284
2/2
✓ Branch 0 taken 781334 times.
✓ Branch 1 taken 374937 times.
2312542 EXTEND(top, left[-1], size);
285
2/2
✓ Branch 0 taken 7476644 times.
✓ Branch 1 taken 13130835 times.
41214958 if (!cand_up_right)
286
2/2
✓ Branch 0 taken 11133757 times.
✓ Branch 1 taken 7476644 times.
37220802 EXTEND(top + size, top[size - 1], size);
287
288 41214958 top[-1] = left[-1];
289
290 // Filtering process
291
6/6
✓ Branch 0 taken 19720934 times.
✓ Branch 1 taken 886545 times.
✓ Branch 2 taken 10439800 times.
✓ Branch 3 taken 9281134 times.
✓ Branch 4 taken 532762 times.
✓ Branch 5 taken 9907038 times.
41214958 if (!s->ps.sps->intra_smoothing_disabled_flag && (c_idx == 0 || s->ps.sps->chroma_format_idc == 3)) {
292
4/4
✓ Branch 0 taken 8785031 times.
✓ Branch 1 taken 1028865 times.
✓ Branch 2 taken 3138227 times.
✓ Branch 3 taken 5646804 times.
19627792 if (mode != INTRA_DC && size != 4){
293 6276454 int intra_hor_ver_dist_thresh[] = { 7, 1, 0 };
294
4/4
✓ Branch 0 taken 747875 times.
✓ Branch 1 taken 2390352 times.
✓ Branch 2 taken 1824630 times.
✓ Branch 3 taken 1313597 times.
6276454 int min_dist_vert_hor = FFMIN(FFABS((int)(mode - 26U)),
295 FFABS((int)(mode - 10U)));
296
2/2
✓ Branch 0 taken 1284965 times.
✓ Branch 1 taken 1853262 times.
6276454 if (min_dist_vert_hor > intra_hor_ver_dist_thresh[log2_size - 3]) {
297 2569930 int threshold = 1 << (BIT_DEPTH - 5);
298
6/6
✓ Branch 0 taken 1130220 times.
✓ Branch 1 taken 154745 times.
✓ Branch 2 taken 1076330 times.
✓ Branch 3 taken 53890 times.
✓ Branch 4 taken 142745 times.
✓ Branch 5 taken 933585 times.
2569930 if (s->ps.sps->sps_strong_intra_smoothing_enable_flag && c_idx == 0 &&
299 285490 log2_size == 5 &&
300
2/2
✓ Branch 0 taken 55508 times.
✓ Branch 1 taken 87237 times.
285490 FFABS(top[-1] + top[63] - 2 * top[31]) < threshold &&
301
2/2
✓ Branch 0 taken 30460 times.
✓ Branch 1 taken 25048 times.
111016 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 60920 filtered_top[-1] = top[-1];
305 60920 filtered_top[63] = top[63];
306
2/2
✓ Branch 0 taken 1918980 times.
✓ Branch 1 taken 30460 times.
3898880 for (i = 0; i < 63; i++)
307 3837960 filtered_top[i] = ((64 - (i + 1)) * top[-1] +
308 3837960 (i + 1) * top[63] + 32) >> 6;
309
2/2
✓ Branch 0 taken 1918980 times.
✓ Branch 1 taken 30460 times.
3898880 for (i = 0; i < 63; i++)
310 3837960 left[i] = ((64 - (i + 1)) * left[-1] +
311 3837960 (i + 1) * left[63] + 32) >> 6;
312 60920 top = filtered_top;
313 } else {
314 2509010 filtered_left[2 * size - 1] = left[2 * size - 1];
315 2509010 filtered_top[2 * size - 1] = top[2 * size - 1];
316
2/2
✓ Branch 0 taken 33786135 times.
✓ Branch 1 taken 1254505 times.
70081280 for (i = 2 * size - 2; i >= 0; i--)
317 67572270 filtered_left[i] = (left[i + 1] + 2 * left[i] +
318 67572270 left[i - 1] + 2) >> 2;
319 2509010 filtered_top[-1] =
320 2509010 filtered_left[-1] = (left[0] + 2 * left[-1] + top[0] + 2) >> 2;
321
2/2
✓ Branch 0 taken 33786135 times.
✓ Branch 1 taken 1254505 times.
70081280 for (i = 2 * size - 2; i >= 0; i--)
322 67572270 filtered_top[i] = (top[i + 1] + 2 * top[i] +
323 67572270 top[i - 1] + 2) >> 2;
324 2509010 left = filtered_left;
325 2509010 top = filtered_top;
326 }
327 }
328 }
329 }
330
331
3/3
✓ Branch 0 taken 4377902 times.
✓ Branch 1 taken 2704078 times.
✓ Branch 2 taken 13525499 times.
41214958 switch (mode) {
332 8755804 case INTRA_PLANAR:
333 8755804 s->hpc.pred_planar[log2_size - 2]((uint8_t *)src, (uint8_t *)top,
334 (uint8_t *)left, stride);
335 8755804 break;
336 5408156 case INTRA_DC:
337 5408156 s->hpc.pred_dc((uint8_t *)src, (uint8_t *)top,
338 (uint8_t *)left, stride, log2_size, c_idx);
339 5408156 break;
340 27050998 default:
341 27050998 s->hpc.pred_angular[log2_size - 2]((uint8_t *)src, (uint8_t *)top,
342 (uint8_t *)left, stride, c_idx,
343 mode);
344 27050998 break;
345 }
346 }
347
348 #define INTRA_PRED(size) \
349 static void FUNC(intra_pred_ ## size)(HEVCContext *s, int x0, int y0, int c_idx) \
350 { \
351 FUNC(intra_pred)(s, x0, y0, size, c_idx); \
352 }
353
354 29224080 INTRA_PRED(2)
355 4280327 INTRA_PRED(3)
356 1432005 INTRA_PRED(4)
357 283107 INTRA_PRED(5)
358
359 #undef INTRA_PRED
360
361 8755804 static av_always_inline void FUNC(pred_planar)(uint8_t *_src, const uint8_t *_top,
362 const uint8_t *_left, ptrdiff_t stride,
363 int trafo_size)
364 {
365 int x, y;
366 8755804 pixel *src = (pixel *)_src;
367 8755804 const pixel *top = (const pixel *)_top;
368 8755804 const pixel *left = (const pixel *)_left;
369 8755804 int size = 1 << trafo_size;
370
2/2
✓ Branch 0 taken 27899616 times.
✓ Branch 1 taken 4377902 times.
64555036 for (y = 0; y < size; y++)
371
2/2
✓ Branch 0 taken 283137632 times.
✓ Branch 1 taken 27899616 times.
622074496 for (x = 0; x < size; x++)
372 566275264 POS(x, y) = ((size - 1 - x) * left[y] + (x + 1) * top[size] +
373 566275264 (size - 1 - y) * top[x] + (y + 1) * left[size] + size) >> (trafo_size + 1);
374 }
375
376 #define PRED_PLANAR(size)\
377 static void FUNC(pred_planar_ ## size)(uint8_t *src, const uint8_t *top, \
378 const uint8_t *left, ptrdiff_t stride) \
379 { \
380 FUNC(pred_planar)(src, top, left, stride, size + 2); \
381 }
382
383 5972164 PRED_PLANAR(0)
384 948533 PRED_PLANAR(1)
385 363635 PRED_PLANAR(2)
386 79652 PRED_PLANAR(3)
387
388 #undef PRED_PLANAR
389
390 5408156 static void FUNC(pred_dc)(uint8_t *_src, const uint8_t *_top,
391 const uint8_t *_left,
392 ptrdiff_t stride, int log2_size, int c_idx)
393 {
394 int i, j, x, y;
395 5408156 int size = (1 << log2_size);
396 5408156 pixel *src = (pixel *)_src;
397 5408156 const pixel *top = (const pixel *)_top;
398 5408156 const pixel *left = (const pixel *)_left;
399 5408156 int dc = size;
400 pixel4 a;
401
2/2
✓ Branch 0 taken 18928092 times.
✓ Branch 1 taken 2704078 times.
43264340 for (i = 0; i < size; i++)
402 37856184 dc += left[i] + top[i];
403
404 5408156 dc >>= log2_size + 1;
405
406 5408156 a = PIXEL_SPLAT_X4(dc);
407
408
2/2
✓ Branch 0 taken 18928092 times.
✓ Branch 1 taken 2704078 times.
43264340 for (i = 0; i < size; i++)
409
2/2
✓ Branch 0 taken 54139660 times.
✓ Branch 1 taken 18928092 times.
146135504 for (j = 0; j < size; j+=4)
410 108279320 AV_WN4P(&POS(j, i), a);
411
412
4/4
✓ Branch 0 taken 1011438 times.
✓ Branch 1 taken 1692640 times.
✓ Branch 2 taken 943379 times.
✓ Branch 3 taken 68059 times.
5408156 if (c_idx == 0 && size < 32) {
413 1886758 POS(0, 0) = (left[0] + 2 * dc + top[0] + 2) >> 2;
414
2/2
✓ Branch 0 taken 5343681 times.
✓ Branch 1 taken 943379 times.
12574120 for (x = 1; x < size; x++)
415 10687362 POS(x, 0) = (top[x] + 3 * dc + 2) >> 2;
416
2/2
✓ Branch 0 taken 5343681 times.
✓ Branch 1 taken 943379 times.
12574120 for (y = 1; y < size; y++)
417 10687362 POS(0, y) = (left[y] + 3 * dc + 2) >> 2;
418 }
419 }
420
421 27050998 static av_always_inline void FUNC(pred_angular)(uint8_t *_src,
422 const uint8_t *_top,
423 const uint8_t *_left,
424 ptrdiff_t stride, int c_idx,
425 int mode, int size)
426 {
427 int x, y;
428 27050998 pixel *src = (pixel *)_src;
429 27050998 const pixel *top = (const pixel *)_top;
430 27050998 const pixel *left = (const pixel *)_left;
431
432 static const int intra_pred_angle[] = {
433 32, 26, 21, 17, 13, 9, 5, 2, 0, -2, -5, -9, -13, -17, -21, -26, -32,
434 -26, -21, -17, -13, -9, -5, -2, 0, 2, 5, 9, 13, 17, 21, 26, 32
435 };
436 static const int inv_angle[] = {
437 -4096, -1638, -910, -630, -482, -390, -315, -256, -315, -390, -482,
438 -630, -910, -1638, -4096
439 };
440
441 27050998 int angle = intra_pred_angle[mode - 2];
442 pixel ref_array[3 * MAX_TB_SIZE + 4];
443 27050998 pixel *ref_tmp = ref_array + size;
444 const pixel *ref;
445 27050998 int last = (size * angle) >> 5;
446
447
2/2
✓ Branch 0 taken 7341967 times.
✓ Branch 1 taken 6183532 times.
27050998 if (mode >= 18) {
448 14683934 ref = top - 1;
449
4/4
✓ Branch 0 taken 2699190 times.
✓ Branch 1 taken 4642777 times.
✓ Branch 2 taken 1805193 times.
✓ Branch 3 taken 893997 times.
14683934 if (angle < 0 && last < -1) {
450
2/2
✓ Branch 0 taken 4463130 times.
✓ Branch 1 taken 1805193 times.
12536646 for (x = 0; x <= size; x += 4)
451 8926260 AV_WN4P(&ref_tmp[x], AV_RN4P(&top[x - 1]));
452
2/2
✓ Branch 0 taken 6591205 times.
✓ Branch 1 taken 1805193 times.
16792796 for (x = last; x <= -1; x++)
453 13182410 ref_tmp[x] = left[-1 + ((x * inv_angle[mode - 11] + 128) >> 8)];
454 3610386 ref = ref_tmp;
455 }
456
457
2/2
✓ Branch 0 taken 41877644 times.
✓ Branch 1 taken 7341967 times.
98439222 for (y = 0; y < size; y++) {
458 83755288 int idx = ((y + 1) * angle) >> 5;
459 83755288 int fact = ((y + 1) * angle) & 31;
460
2/2
✓ Branch 0 taken 25154353 times.
✓ Branch 1 taken 16723291 times.
83755288 if (fact) {
461
2/2
✓ Branch 0 taken 51371308 times.
✓ Branch 1 taken 25154353 times.
153051322 for (x = 0; x < size; x += 4) {
462 102742616 POS(x , y) = ((32 - fact) * ref[x + idx + 1] +
463 102742616 fact * ref[x + idx + 2] + 16) >> 5;
464 102742616 POS(x + 1, y) = ((32 - fact) * ref[x + 1 + idx + 1] +
465 102742616 fact * ref[x + 1 + idx + 2] + 16) >> 5;
466 102742616 POS(x + 2, y) = ((32 - fact) * ref[x + 2 + idx + 1] +
467 102742616 fact * ref[x + 2 + idx + 2] + 16) >> 5;
468 102742616 POS(x + 3, y) = ((32 - fact) * ref[x + 3 + idx + 1] +
469 102742616 fact * ref[x + 3 + idx + 2] + 16) >> 5;
470 }
471 } else {
472
2/2
✓ Branch 0 taken 36375600 times.
✓ Branch 1 taken 16723291 times.
106197782 for (x = 0; x < size; x += 4)
473 72751200 AV_WN4P(&POS(x, y), AV_RN4P(&ref[x + idx + 1]));
474 }
475 }
476
6/6
✓ Branch 0 taken 2223172 times.
✓ Branch 1 taken 5118795 times.
✓ Branch 2 taken 848222 times.
✓ Branch 3 taken 1374950 times.
✓ Branch 4 taken 825144 times.
✓ Branch 5 taken 23078 times.
14683934 if (mode == 26 && c_idx == 0 && size < 32) {
477
2/2
✓ Branch 0 taken 4928880 times.
✓ Branch 1 taken 825144 times.
11508048 for (y = 0; y < size; y++)
478 9857760 POS(0, y) = av_clip_pixel(top[0] + ((left[y] - left[-1]) >> 1));
479 }
480 } else {
481 12367064 ref = left - 1;
482
4/4
✓ Branch 0 taken 2020978 times.
✓ Branch 1 taken 4162554 times.
✓ Branch 2 taken 1208952 times.
✓ Branch 3 taken 812026 times.
12367064 if (angle < 0 && last < -1) {
483
2/2
✓ Branch 0 taken 3032439 times.
✓ Branch 1 taken 1208952 times.
8482782 for (x = 0; x <= size; x += 4)
484 6064878 AV_WN4P(&ref_tmp[x], AV_RN4P(&left[x - 1]));
485
2/2
✓ Branch 0 taken 4093410 times.
✓ Branch 1 taken 1208952 times.
10604724 for (x = last; x <= -1; x++)
486 8186820 ref_tmp[x] = top[-1 + ((x * inv_angle[mode - 11] + 128) >> 8)];
487 2417904 ref = ref_tmp;
488 }
489
490
2/2
✓ Branch 0 taken 35956928 times.
✓ Branch 1 taken 6183532 times.
84280920 for (x = 0; x < size; x++) {
491 71913856 int idx = ((x + 1) * angle) >> 5;
492 71913856 int fact = ((x + 1) * angle) & 31;
493
2/2
✓ Branch 0 taken 25854504 times.
✓ Branch 1 taken 10102424 times.
71913856 if (fact) {
494
2/2
✓ Branch 0 taken 223079184 times.
✓ Branch 1 taken 25854504 times.
497867376 for (y = 0; y < size; y++) {
495 446158368 POS(x, y) = ((32 - fact) * ref[y + idx + 1] +
496 446158368 fact * ref[y + idx + 2] + 16) >> 5;
497 }
498 } else {
499
2/2
✓ Branch 0 taken 90465328 times.
✓ Branch 1 taken 10102424 times.
201135504 for (y = 0; y < size; y++)
500 180930656 POS(x, y) = ref[y + idx + 1];
501 }
502 }
503
6/6
✓ Branch 0 taken 1440938 times.
✓ Branch 1 taken 4742594 times.
✓ Branch 2 taken 440416 times.
✓ Branch 3 taken 1000522 times.
✓ Branch 4 taken 427074 times.
✓ Branch 5 taken 13342 times.
12367064 if (mode == 10 && c_idx == 0 && size < 32) {
504
2/2
✓ Branch 0 taken 628725 times.
✓ Branch 1 taken 427074 times.
2111598 for (x = 0; x < size; x += 4) {
505 1257450 POS(x, 0) = av_clip_pixel(left[0] + ((top[x ] - top[-1]) >> 1));
506 1257450 POS(x + 1, 0) = av_clip_pixel(left[0] + ((top[x + 1] - top[-1]) >> 1));
507 1257450 POS(x + 2, 0) = av_clip_pixel(left[0] + ((top[x + 2] - top[-1]) >> 1));
508 1257450 POS(x + 3, 0) = av_clip_pixel(left[0] + ((top[x + 3] - top[-1]) >> 1));
509 }
510 }
511 }
512 }
513
514 19848118 static void FUNC(pred_angular_0)(uint8_t *src, const uint8_t *top,
515 const uint8_t *left,
516 ptrdiff_t stride, int c_idx, int mode)
517 {
518 19848118 FUNC(pred_angular)(src, top, left, stride, c_idx, mode, 1 << 2);
519 }
520
521 5406712 static void FUNC(pred_angular_1)(uint8_t *src, const uint8_t *top,
522 const uint8_t *left,
523 ptrdiff_t stride, int c_idx, int mode)
524 {
525 5406712 FUNC(pred_angular)(src, top, left, stride, c_idx, mode, 1 << 3);
526 }
527
528 1528400 static void FUNC(pred_angular_2)(uint8_t *src, const uint8_t *top,
529 const uint8_t *left,
530 ptrdiff_t stride, int c_idx, int mode)
531 {
532 1528400 FUNC(pred_angular)(src, top, left, stride, c_idx, mode, 1 << 4);
533 }
534
535 267768 static void FUNC(pred_angular_3)(uint8_t *src, const uint8_t *top,
536 const uint8_t *left,
537 ptrdiff_t stride, int c_idx, int mode)
538 {
539 267768 FUNC(pred_angular)(src, top, left, stride, c_idx, mode, 1 << 5);
540 }
541
542 #undef EXTEND_LEFT_CIP
543 #undef EXTEND_RIGHT_CIP
544 #undef EXTEND_UP_CIP
545 #undef EXTEND_DOWN_CIP
546 #undef IS_INTRA
547 #undef MVF_PU
548 #undef MVF
549 #undef PU
550 #undef EXTEND
551 #undef MIN_TB_ADDR_ZS
552 #undef POS
553