/src/ffmpeg/libavcodec/hevc/pred_template.c
Line | Count | 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 | 9.90G | #define POS(x, y) src[(x) + stride * (y)] |
29 | | |
30 | | 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 | 243M | { |
35 | 243M | #define PU(x) \ |
36 | 917M | ((x) >> sps->log2_min_pu_size) |
37 | 243M | #define MVF(x, y) \ |
38 | 1.22G | (s->cur_frame->tab_mvf[(x) + (y) * min_pu_width]) |
39 | 243M | #define MVF_PU(x, y) \ |
40 | 834M | MVF(PU(x0 + ((x) * (1 << hshift))), PU(y0 + ((y) * (1 << vshift)))) |
41 | 243M | #define IS_INTRA(x, y) \ |
42 | 834M | (MVF_PU(x, y).pred_flag == PF_INTRA) |
43 | 243M | #define MIN_TB_ADDR_ZS(x, y) \ |
44 | 663M | pps->min_tb_addr_zs[(y) * (sps->tb_mask+2) + (x)] |
45 | 548M | #define EXTEND(ptr, val, len) \ |
46 | 548M | do { \ |
47 | 548M | pixel4 pix = PIXEL_SPLAT_X4(val); \ |
48 | 1.00G | for (i = 0; i < (len); i += 4) \ |
49 | 548M | AV_WN4P(ptr + i, pix); \ |
50 | 548M | } while (0) |
51 | | |
52 | 243M | #define EXTEND_RIGHT_CIP(ptr, start, length) \ |
53 | 291M | for (i = start; i < (start) + (length); i += 4) \ |
54 | 198M | if (!IS_INTRA(i, -1)) \ |
55 | 198M | AV_WN4P(&ptr[i], a); \ |
56 | 198M | else \ |
57 | 198M | a = PIXEL_SPLAT_X4(ptr[i+3]) |
58 | 243M | #define EXTEND_LEFT_CIP(ptr, start, length) \ |
59 | 243M | for (i = start; i > (start) - (length); i--) \ |
60 | 201k | if (!IS_INTRA(i - 1, -1)) \ |
61 | 201k | ptr[i - 1] = ptr[i] |
62 | 243M | #define EXTEND_UP_CIP(ptr, start, length) \ |
63 | 273M | for (i = (start); i > (start) - (length); i -= 4) \ |
64 | 180M | if (!IS_INTRA(-1, i - 3)) \ |
65 | 180M | AV_WN4P(&ptr[i - 3], a); \ |
66 | 180M | else \ |
67 | 180M | a = PIXEL_SPLAT_X4(ptr[i - 3]) |
68 | 243M | #define EXTEND_DOWN_CIP(ptr, start, length) \ |
69 | 267M | for (i = start; i < (start) + (length); i += 4) \ |
70 | 176M | if (!IS_INTRA(-1, i)) \ |
71 | 176M | AV_WN4P(&ptr[i], a); \ |
72 | 176M | else \ |
73 | 176M | a = PIXEL_SPLAT_X4(ptr[i + 3]) |
74 | | |
75 | 243M | const HEVCSPS *const sps = pps->sps; |
76 | 243M | const HEVCContext *const s = lc->parent; |
77 | 243M | int i; |
78 | 243M | int hshift = sps->hshift[c_idx]; |
79 | 243M | int vshift = sps->vshift[c_idx]; |
80 | 243M | int size = (1 << log2_size); |
81 | 243M | int size_in_luma_h = size << hshift; |
82 | 243M | int size_in_tbs_h = size_in_luma_h >> sps->log2_min_tb_size; |
83 | 243M | int size_in_luma_v = size << vshift; |
84 | 243M | int size_in_tbs_v = size_in_luma_v >> sps->log2_min_tb_size; |
85 | 243M | int x = x0 >> hshift; |
86 | 243M | int y = y0 >> vshift; |
87 | 243M | int x_tb = (x0 >> sps->log2_min_tb_size) & sps->tb_mask; |
88 | 243M | int y_tb = (y0 >> sps->log2_min_tb_size) & sps->tb_mask; |
89 | 243M | int spin = c_idx && !size_in_tbs_v && ((2 * y0) & (1 << sps->log2_min_tb_size)); |
90 | | |
91 | 243M | int cur_tb_addr = MIN_TB_ADDR_ZS(x_tb, y_tb); |
92 | | |
93 | 243M | ptrdiff_t stride = s->cur_frame->f->linesize[c_idx] / sizeof(pixel); |
94 | 243M | pixel *src = (pixel*)s->cur_frame->f->data[c_idx] + x + y * stride; |
95 | | |
96 | 243M | int min_pu_width = sps->min_pu_width; |
97 | | |
98 | 243M | enum IntraPredMode mode = c_idx ? lc->tu.intra_pred_mode_c : |
99 | 243M | lc->tu.intra_pred_mode; |
100 | 243M | pixel4 a; |
101 | 243M | pixel left_array[2 * MAX_TB_SIZE + 1]; |
102 | 243M | pixel filtered_left_array[2 * MAX_TB_SIZE + 1]; |
103 | 243M | pixel top_array[2 * MAX_TB_SIZE + 1]; |
104 | 243M | pixel filtered_top_array[2 * MAX_TB_SIZE + 1]; |
105 | | |
106 | 243M | pixel *left = left_array + 1; |
107 | 243M | pixel *top = top_array + 1; |
108 | 243M | pixel *filtered_left = filtered_left_array + 1; |
109 | 243M | pixel *filtered_top = filtered_top_array + 1; |
110 | 243M | 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 | 243M | int cand_left = lc->na.cand_left; |
112 | 243M | int cand_up_left = lc->na.cand_up_left; |
113 | 243M | int cand_up = lc->na.cand_up; |
114 | 243M | 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 | 243M | int bottom_left_size = (FFMIN(y0 + 2 * size_in_luma_v, sps->height) - |
117 | 243M | (y0 + size_in_luma_v)) >> vshift; |
118 | 243M | int top_right_size = (FFMIN(x0 + 2 * size_in_luma_h, sps->width) - |
119 | 243M | (x0 + size_in_luma_h)) >> hshift; |
120 | | |
121 | 243M | if (pps->constrained_intra_pred_flag == 1) { |
122 | 94.1M | int size_in_luma_pu_v = PU(size_in_luma_v); |
123 | 94.1M | int size_in_luma_pu_h = PU(size_in_luma_h); |
124 | 94.1M | int on_pu_edge_x = !av_zero_extend(x0, sps->log2_min_pu_size); |
125 | 94.1M | int on_pu_edge_y = !av_zero_extend(y0, sps->log2_min_pu_size); |
126 | 94.1M | if (!size_in_luma_pu_h) |
127 | 2.45M | size_in_luma_pu_h++; |
128 | 94.1M | if (cand_bottom_left == 1 && on_pu_edge_x) { |
129 | 41.3M | int x_left_pu = PU(x0 - 1); |
130 | 41.3M | int y_bottom_pu = PU(y0 + size_in_luma_v); |
131 | 41.3M | int max = FFMIN(size_in_luma_pu_v, sps->min_pu_height - y_bottom_pu); |
132 | 41.3M | cand_bottom_left = 0; |
133 | 84.2M | for (i = 0; i < max; i += 2) |
134 | 42.8M | cand_bottom_left |= (MVF(x_left_pu, y_bottom_pu + i).pred_flag == PF_INTRA); |
135 | 41.3M | } |
136 | 94.1M | if (cand_left == 1 && on_pu_edge_x) { |
137 | 91.6M | int x_left_pu = PU(x0 - 1); |
138 | 91.6M | int y_left_pu = PU(y0); |
139 | 91.6M | int max = FFMIN(size_in_luma_pu_v, sps->min_pu_height - y_left_pu); |
140 | 91.6M | cand_left = 0; |
141 | 189M | for (i = 0; i < max; i += 2) |
142 | 98.2M | cand_left |= (MVF(x_left_pu, y_left_pu + i).pred_flag == PF_INTRA); |
143 | 91.6M | } |
144 | 94.1M | if (cand_up_left == 1) { |
145 | 91.4M | int x_left_pu = PU(x0 - 1); |
146 | 91.4M | int y_top_pu = PU(y0 - 1); |
147 | 91.4M | cand_up_left = MVF(x_left_pu, y_top_pu).pred_flag == PF_INTRA; |
148 | 91.4M | } |
149 | 94.1M | if (cand_up == 1 && on_pu_edge_y) { |
150 | 90.7M | int x_top_pu = PU(x0); |
151 | 90.7M | int y_top_pu = PU(y0 - 1); |
152 | 90.7M | int max = FFMIN(size_in_luma_pu_h, sps->min_pu_width - x_top_pu); |
153 | 90.7M | cand_up = 0; |
154 | 193M | for (i = 0; i < max; i += 2) |
155 | 102M | cand_up |= (MVF(x_top_pu + i, y_top_pu).pred_flag == PF_INTRA); |
156 | 90.7M | } |
157 | 94.1M | if (cand_up_right == 1 && on_pu_edge_y) { |
158 | 49.5M | int y_top_pu = PU(y0 - 1); |
159 | 49.5M | int x_right_pu = PU(x0 + size_in_luma_h); |
160 | 49.5M | int max = FFMIN(size_in_luma_pu_h, sps->min_pu_width - x_right_pu); |
161 | 49.5M | cand_up_right = 0; |
162 | 105M | for (i = 0; i < max; i += 2) |
163 | 55.8M | cand_up_right |= (MVF(x_right_pu + i, y_top_pu).pred_flag == PF_INTRA); |
164 | 49.5M | } |
165 | 94.1M | memset(left, 128, 2 * MAX_TB_SIZE*sizeof(pixel)); |
166 | 94.1M | memset(top , 128, 2 * MAX_TB_SIZE*sizeof(pixel)); |
167 | 94.1M | top[-1] = 128; |
168 | 94.1M | } |
169 | 243M | if (cand_up_left) { |
170 | 236M | left[-1] = POS(-1, -1); |
171 | 236M | top[-1] = left[-1]; |
172 | 236M | } |
173 | 243M | if (cand_up) |
174 | 238M | memcpy(top, src - stride, size * sizeof(pixel)); |
175 | 243M | if (cand_up_right) { |
176 | 135M | memcpy(top + size, src - stride + size, size * sizeof(pixel)); |
177 | 135M | EXTEND(top + size + top_right_size, POS(size + top_right_size - 1, -1), |
178 | 135M | size - top_right_size); |
179 | 135M | } |
180 | 243M | if (cand_left) |
181 | 1.52G | for (i = 0; i < size; i++) |
182 | 1.28G | left[i] = POS(-1, i); |
183 | 243M | if (cand_bottom_left) { |
184 | 611M | for (i = size; i < size + bottom_left_size; i++) |
185 | 510M | left[i] = POS(-1, i); |
186 | 100M | EXTEND(left + size + bottom_left_size, POS(-1, size + bottom_left_size - 1), |
187 | 100M | size - bottom_left_size); |
188 | 100M | } |
189 | | |
190 | 243M | if (pps->constrained_intra_pred_flag == 1) { |
191 | 94.1M | if (cand_bottom_left || cand_left || cand_up_left || cand_up || cand_up_right) { |
192 | 93.9M | int size_max_x = x0 + ((2 * size) << hshift) < sps->width ? |
193 | 91.5M | 2 * size : (sps->width - x0) >> hshift; |
194 | 93.9M | int size_max_y = y0 + ((2 * size) << vshift) < sps->height ? |
195 | 89.9M | 2 * size : (sps->height - y0) >> vshift; |
196 | 93.9M | int j = size + (cand_bottom_left? bottom_left_size: 0) -1; |
197 | 93.9M | if (!cand_up_right) { |
198 | 43.9M | size_max_x = x0 + ((size) << hshift) < sps->width ? |
199 | 42.8M | size : (sps->width - x0) >> hshift; |
200 | 43.9M | } |
201 | 93.9M | if (!cand_bottom_left) { |
202 | 53.4M | size_max_y = y0 + (( size) << vshift) < sps->height ? |
203 | 51.3M | size : (sps->height - y0) >> vshift; |
204 | 53.4M | } |
205 | 93.9M | if (cand_bottom_left || cand_left || cand_up_left) { |
206 | 93.6M | while (j > -1 && !IS_INTRA(-1, j)) |
207 | 820k | j--; |
208 | 92.8M | if (!IS_INTRA(-1, j)) { |
209 | 0 | j = 0; |
210 | 0 | while (j < size_max_x && !IS_INTRA(j, -1)) |
211 | 0 | j++; |
212 | 0 | EXTEND_LEFT_CIP(top, j, j + 1); |
213 | 0 | left[-1] = top[-1]; |
214 | 0 | } |
215 | 92.8M | } else { |
216 | 1.10M | j = 0; |
217 | 1.30M | while (j < size_max_x && !IS_INTRA(j, -1)) |
218 | 201k | j++; |
219 | 1.10M | if (j > 0) { |
220 | 18.8k | EXTEND_LEFT_CIP(top, j, j); |
221 | 18.8k | top[-1] = top[0]; |
222 | 18.8k | } |
223 | 1.10M | left[-1] = top[-1]; |
224 | 1.10M | } |
225 | 93.9M | left[-1] = top[-1]; |
226 | 93.9M | if (cand_bottom_left || cand_left) { |
227 | 91.4M | a = PIXEL_SPLAT_X4(left[-1]); |
228 | 91.4M | EXTEND_DOWN_CIP(left, 0, size_max_y); |
229 | 91.4M | } |
230 | 93.9M | if (!cand_left) |
231 | 2.50M | EXTEND(left, left[-1], size); |
232 | 93.9M | if (!cand_bottom_left) |
233 | 53.4M | EXTEND(left + size, left[size - 1], size); |
234 | 93.9M | if (x0 != 0 && y0 != 0) { |
235 | 91.6M | a = PIXEL_SPLAT_X4(left[size_max_y - 1]); |
236 | 91.6M | EXTEND_UP_CIP(left, size_max_y - 1, size_max_y); |
237 | 91.6M | if (!IS_INTRA(-1, - 1)) |
238 | 398k | left[-1] = left[0]; |
239 | 91.6M | } else if (x0 == 0) { |
240 | 866k | EXTEND(left, 0, size_max_y); |
241 | 1.41M | } else { |
242 | 1.41M | a = PIXEL_SPLAT_X4(left[size_max_y - 1]); |
243 | 1.41M | EXTEND_UP_CIP(left, size_max_y - 1, size_max_y); |
244 | 1.41M | } |
245 | 93.9M | top[-1] = left[-1]; |
246 | 93.9M | if (y0 != 0) { |
247 | 92.5M | a = PIXEL_SPLAT_X4(left[-1]); |
248 | 92.5M | EXTEND_RIGHT_CIP(top, 0, size_max_x); |
249 | 92.5M | } |
250 | 93.9M | } |
251 | 94.1M | } |
252 | | // Infer the unavailable samples |
253 | 243M | if (!cand_bottom_left) { |
254 | 142M | if (cand_left) { |
255 | 138M | EXTEND(left + size, left[size - 1], size); |
256 | 138M | } else if (cand_up_left) { |
257 | 1.36M | EXTEND(left, left[-1], 2 * size); |
258 | 1.36M | cand_left = 1; |
259 | 2.63M | } else if (cand_up) { |
260 | 2.33M | left[-1] = top[0]; |
261 | 2.33M | EXTEND(left, left[-1], 2 * size); |
262 | 2.33M | cand_up_left = 1; |
263 | 2.33M | cand_left = 1; |
264 | 2.33M | } else if (cand_up_right) { |
265 | 17.3k | EXTEND(top, top[size], size); |
266 | 17.3k | left[-1] = top[size]; |
267 | 17.3k | EXTEND(left, left[-1], 2 * size); |
268 | 17.3k | cand_up = 1; |
269 | 17.3k | cand_up_left = 1; |
270 | 17.3k | cand_left = 1; |
271 | 280k | } else { // No samples available |
272 | 280k | left[-1] = (1 << (BIT_DEPTH - 1)); |
273 | 280k | EXTEND(top, left[-1], 2 * size); |
274 | 280k | EXTEND(left, left[-1], 2 * size); |
275 | 280k | } |
276 | 142M | } |
277 | | |
278 | 243M | if (!cand_left) |
279 | 314k | EXTEND(left, left[size], size); |
280 | 243M | if (!cand_up_left) { |
281 | 4.55M | left[-1] = left[0]; |
282 | 4.55M | } |
283 | 243M | if (!cand_up) |
284 | 4.61M | EXTEND(top, left[-1], size); |
285 | 243M | if (!cand_up_right) |
286 | 107M | EXTEND(top + size, top[size - 1], size); |
287 | | |
288 | 243M | top[-1] = left[-1]; |
289 | | |
290 | | // Filtering process |
291 | 243M | if (!sps->intra_smoothing_disabled && (c_idx == 0 || sps->chroma_format_idc == 3)) { |
292 | 114M | if (mode != INTRA_DC && size != 4){ |
293 | 34.3M | int intra_hor_ver_dist_thresh[] = { 7, 1, 0 }; |
294 | 34.3M | int min_dist_vert_hor = FFMIN(FFABS((int)(mode - 26U)), |
295 | 34.3M | FFABS((int)(mode - 10U))); |
296 | 34.3M | if (min_dist_vert_hor > intra_hor_ver_dist_thresh[log2_size - 3]) { |
297 | 25.7M | int threshold = 1 << (BIT_DEPTH - 5); |
298 | 25.7M | if (sps->strong_intra_smoothing_enabled && c_idx == 0 && |
299 | 16.2M | log2_size == 5 && |
300 | 874k | FFABS(top[-1] + top[63] - 2 * top[31]) < threshold && |
301 | 633k | 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 | 525k | filtered_top[-1] = top[-1]; |
305 | 525k | filtered_top[63] = top[63]; |
306 | 33.6M | for (i = 0; i < 63; i++) |
307 | 33.0M | filtered_top[i] = ((64 - (i + 1)) * top[-1] + |
308 | 33.0M | (i + 1) * top[63] + 32) >> 6; |
309 | 33.6M | for (i = 0; i < 63; i++) |
310 | 33.0M | left[i] = ((64 - (i + 1)) * left[-1] + |
311 | 33.0M | (i + 1) * left[63] + 32) >> 6; |
312 | 525k | top = filtered_top; |
313 | 25.2M | } else { |
314 | 25.2M | filtered_left[2 * size - 1] = left[2 * size - 1]; |
315 | 25.2M | filtered_top[2 * size - 1] = top[2 * size - 1]; |
316 | 505M | for (i = 2 * size - 2; i >= 0; i--) |
317 | 479M | filtered_left[i] = (left[i + 1] + 2 * left[i] + |
318 | 479M | left[i - 1] + 2) >> 2; |
319 | 25.2M | filtered_top[-1] = |
320 | 25.2M | filtered_left[-1] = (left[0] + 2 * left[-1] + top[0] + 2) >> 2; |
321 | 505M | for (i = 2 * size - 2; i >= 0; i--) |
322 | 479M | filtered_top[i] = (top[i + 1] + 2 * top[i] + |
323 | 479M | top[i - 1] + 2) >> 2; |
324 | 25.2M | left = filtered_left; |
325 | 25.2M | top = filtered_top; |
326 | 25.2M | } |
327 | 25.7M | } |
328 | 34.3M | } |
329 | 114M | } |
330 | | |
331 | 243M | switch (mode) { |
332 | 102M | case INTRA_PLANAR: |
333 | 102M | s->hpc.pred_planar[log2_size - 2]((uint8_t *)src, (uint8_t *)top, |
334 | 102M | (uint8_t *)left, stride); |
335 | 102M | break; |
336 | 44.0M | case INTRA_DC: |
337 | 44.0M | s->hpc.pred_dc((uint8_t *)src, (uint8_t *)top, |
338 | 44.0M | (uint8_t *)left, stride, log2_size, c_idx); |
339 | 44.0M | break; |
340 | 96.3M | default: |
341 | 96.3M | s->hpc.pred_angular[log2_size - 2]((uint8_t *)src, (uint8_t *)top, |
342 | 96.3M | (uint8_t *)left, stride, c_idx, |
343 | 96.3M | mode); |
344 | 96.3M | break; |
345 | 243M | } |
346 | 243M | } Line | Count | Source | 34 | 59.3M | { | 35 | 59.3M | #define PU(x) \ | 36 | 59.3M | ((x) >> sps->log2_min_pu_size) | 37 | 59.3M | #define MVF(x, y) \ | 38 | 59.3M | (s->cur_frame->tab_mvf[(x) + (y) * min_pu_width]) | 39 | 59.3M | #define MVF_PU(x, y) \ | 40 | 59.3M | MVF(PU(x0 + ((x) * (1 << hshift))), PU(y0 + ((y) * (1 << vshift)))) | 41 | 59.3M | #define IS_INTRA(x, y) \ | 42 | 59.3M | (MVF_PU(x, y).pred_flag == PF_INTRA) | 43 | 59.3M | #define MIN_TB_ADDR_ZS(x, y) \ | 44 | 59.3M | pps->min_tb_addr_zs[(y) * (sps->tb_mask+2) + (x)] | 45 | 59.3M | #define EXTEND(ptr, val, len) \ | 46 | 59.3M | do { \ | 47 | 59.3M | pixel4 pix = PIXEL_SPLAT_X4(val); \ | 48 | 59.3M | for (i = 0; i < (len); i += 4) \ | 49 | 59.3M | AV_WN4P(ptr + i, pix); \ | 50 | 59.3M | } while (0) | 51 | | | 52 | 59.3M | #define EXTEND_RIGHT_CIP(ptr, start, length) \ | 53 | 59.3M | for (i = start; i < (start) + (length); i += 4) \ | 54 | 59.3M | if (!IS_INTRA(i, -1)) \ | 55 | 59.3M | AV_WN4P(&ptr[i], a); \ | 56 | 59.3M | else \ | 57 | 59.3M | a = PIXEL_SPLAT_X4(ptr[i+3]) | 58 | 59.3M | #define EXTEND_LEFT_CIP(ptr, start, length) \ | 59 | 59.3M | for (i = start; i > (start) - (length); i--) \ | 60 | 59.3M | if (!IS_INTRA(i - 1, -1)) \ | 61 | 59.3M | ptr[i - 1] = ptr[i] | 62 | 59.3M | #define EXTEND_UP_CIP(ptr, start, length) \ | 63 | 59.3M | for (i = (start); i > (start) - (length); i -= 4) \ | 64 | 59.3M | if (!IS_INTRA(-1, i - 3)) \ | 65 | 59.3M | AV_WN4P(&ptr[i - 3], a); \ | 66 | 59.3M | else \ | 67 | 59.3M | a = PIXEL_SPLAT_X4(ptr[i - 3]) | 68 | 59.3M | #define EXTEND_DOWN_CIP(ptr, start, length) \ | 69 | 59.3M | for (i = start; i < (start) + (length); i += 4) \ | 70 | 59.3M | if (!IS_INTRA(-1, i)) \ | 71 | 59.3M | AV_WN4P(&ptr[i], a); \ | 72 | 59.3M | else \ | 73 | 59.3M | a = PIXEL_SPLAT_X4(ptr[i + 3]) | 74 | | | 75 | 59.3M | const HEVCSPS *const sps = pps->sps; | 76 | 59.3M | const HEVCContext *const s = lc->parent; | 77 | 59.3M | int i; | 78 | 59.3M | int hshift = sps->hshift[c_idx]; | 79 | 59.3M | int vshift = sps->vshift[c_idx]; | 80 | 59.3M | int size = (1 << log2_size); | 81 | 59.3M | int size_in_luma_h = size << hshift; | 82 | 59.3M | int size_in_tbs_h = size_in_luma_h >> sps->log2_min_tb_size; | 83 | 59.3M | int size_in_luma_v = size << vshift; | 84 | 59.3M | int size_in_tbs_v = size_in_luma_v >> sps->log2_min_tb_size; | 85 | 59.3M | int x = x0 >> hshift; | 86 | 59.3M | int y = y0 >> vshift; | 87 | 59.3M | int x_tb = (x0 >> sps->log2_min_tb_size) & sps->tb_mask; | 88 | 59.3M | int y_tb = (y0 >> sps->log2_min_tb_size) & sps->tb_mask; | 89 | 59.3M | int spin = c_idx && !size_in_tbs_v && ((2 * y0) & (1 << sps->log2_min_tb_size)); | 90 | | | 91 | 59.3M | int cur_tb_addr = MIN_TB_ADDR_ZS(x_tb, y_tb); | 92 | | | 93 | 59.3M | ptrdiff_t stride = s->cur_frame->f->linesize[c_idx] / sizeof(pixel); | 94 | 59.3M | pixel *src = (pixel*)s->cur_frame->f->data[c_idx] + x + y * stride; | 95 | | | 96 | 59.3M | int min_pu_width = sps->min_pu_width; | 97 | | | 98 | 59.3M | enum IntraPredMode mode = c_idx ? lc->tu.intra_pred_mode_c : | 99 | 59.3M | lc->tu.intra_pred_mode; | 100 | 59.3M | pixel4 a; | 101 | 59.3M | pixel left_array[2 * MAX_TB_SIZE + 1]; | 102 | 59.3M | pixel filtered_left_array[2 * MAX_TB_SIZE + 1]; | 103 | 59.3M | pixel top_array[2 * MAX_TB_SIZE + 1]; | 104 | 59.3M | pixel filtered_top_array[2 * MAX_TB_SIZE + 1]; | 105 | | | 106 | 59.3M | pixel *left = left_array + 1; | 107 | 59.3M | pixel *top = top_array + 1; | 108 | 59.3M | pixel *filtered_left = filtered_left_array + 1; | 109 | 59.3M | pixel *filtered_top = filtered_top_array + 1; | 110 | 59.3M | 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 | 59.3M | int cand_left = lc->na.cand_left; | 112 | 59.3M | int cand_up_left = lc->na.cand_up_left; | 113 | 59.3M | int cand_up = lc->na.cand_up; | 114 | 59.3M | 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 | 59.3M | int bottom_left_size = (FFMIN(y0 + 2 * size_in_luma_v, sps->height) - | 117 | 59.3M | (y0 + size_in_luma_v)) >> vshift; | 118 | 59.3M | int top_right_size = (FFMIN(x0 + 2 * size_in_luma_h, sps->width) - | 119 | 59.3M | (x0 + size_in_luma_h)) >> hshift; | 120 | | | 121 | 59.3M | if (pps->constrained_intra_pred_flag == 1) { | 122 | 47.7M | int size_in_luma_pu_v = PU(size_in_luma_v); | 123 | 47.7M | int size_in_luma_pu_h = PU(size_in_luma_h); | 124 | 47.7M | int on_pu_edge_x = !av_zero_extend(x0, sps->log2_min_pu_size); | 125 | 47.7M | int on_pu_edge_y = !av_zero_extend(y0, sps->log2_min_pu_size); | 126 | 47.7M | if (!size_in_luma_pu_h) | 127 | 908k | size_in_luma_pu_h++; | 128 | 47.7M | if (cand_bottom_left == 1 && on_pu_edge_x) { | 129 | 25.6M | int x_left_pu = PU(x0 - 1); | 130 | 25.6M | int y_bottom_pu = PU(y0 + size_in_luma_v); | 131 | 25.6M | int max = FFMIN(size_in_luma_pu_v, sps->min_pu_height - y_bottom_pu); | 132 | 25.6M | cand_bottom_left = 0; | 133 | 51.9M | for (i = 0; i < max; i += 2) | 134 | 26.2M | cand_bottom_left |= (MVF(x_left_pu, y_bottom_pu + i).pred_flag == PF_INTRA); | 135 | 25.6M | } | 136 | 47.7M | if (cand_left == 1 && on_pu_edge_x) { | 137 | 47.0M | int x_left_pu = PU(x0 - 1); | 138 | 47.0M | int y_left_pu = PU(y0); | 139 | 47.0M | int max = FFMIN(size_in_luma_pu_v, sps->min_pu_height - y_left_pu); | 140 | 47.0M | cand_left = 0; | 141 | 96.0M | for (i = 0; i < max; i += 2) | 142 | 48.9M | cand_left |= (MVF(x_left_pu, y_left_pu + i).pred_flag == PF_INTRA); | 143 | 47.0M | } | 144 | 47.7M | if (cand_up_left == 1) { | 145 | 47.1M | int x_left_pu = PU(x0 - 1); | 146 | 47.1M | int y_top_pu = PU(y0 - 1); | 147 | 47.1M | cand_up_left = MVF(x_left_pu, y_top_pu).pred_flag == PF_INTRA; | 148 | 47.1M | } | 149 | 47.7M | if (cand_up == 1 && on_pu_edge_y) { | 150 | 46.8M | int x_top_pu = PU(x0); | 151 | 46.8M | int y_top_pu = PU(y0 - 1); | 152 | 46.8M | int max = FFMIN(size_in_luma_pu_h, sps->min_pu_width - x_top_pu); | 153 | 46.8M | cand_up = 0; | 154 | 99.7M | for (i = 0; i < max; i += 2) | 155 | 52.9M | cand_up |= (MVF(x_top_pu + i, y_top_pu).pred_flag == PF_INTRA); | 156 | 46.8M | } | 157 | 47.7M | if (cand_up_right == 1 && on_pu_edge_y) { | 158 | 21.5M | int y_top_pu = PU(y0 - 1); | 159 | 21.5M | int x_right_pu = PU(x0 + size_in_luma_h); | 160 | 21.5M | int max = FFMIN(size_in_luma_pu_h, sps->min_pu_width - x_right_pu); | 161 | 21.5M | cand_up_right = 0; | 162 | 45.8M | for (i = 0; i < max; i += 2) | 163 | 24.2M | cand_up_right |= (MVF(x_right_pu + i, y_top_pu).pred_flag == PF_INTRA); | 164 | 21.5M | } | 165 | 47.7M | memset(left, 128, 2 * MAX_TB_SIZE*sizeof(pixel)); | 166 | 47.7M | memset(top , 128, 2 * MAX_TB_SIZE*sizeof(pixel)); | 167 | 47.7M | top[-1] = 128; | 168 | 47.7M | } | 169 | 59.3M | if (cand_up_left) { | 170 | 58.2M | left[-1] = POS(-1, -1); | 171 | 58.2M | top[-1] = left[-1]; | 172 | 58.2M | } | 173 | 59.3M | if (cand_up) | 174 | 58.6M | memcpy(top, src - stride, size * sizeof(pixel)); | 175 | 59.3M | if (cand_up_right) { | 176 | 28.6M | memcpy(top + size, src - stride + size, size * sizeof(pixel)); | 177 | 28.6M | EXTEND(top + size + top_right_size, POS(size + top_right_size - 1, -1), | 178 | 28.6M | size - top_right_size); | 179 | 28.6M | } | 180 | 59.3M | if (cand_left) | 181 | 370M | for (i = 0; i < size; i++) | 182 | 311M | left[i] = POS(-1, i); | 183 | 59.3M | if (cand_bottom_left) { | 184 | 176M | for (i = size; i < size + bottom_left_size; i++) | 185 | 146M | left[i] = POS(-1, i); | 186 | 29.5M | EXTEND(left + size + bottom_left_size, POS(-1, size + bottom_left_size - 1), | 187 | 29.5M | size - bottom_left_size); | 188 | 29.5M | } | 189 | | | 190 | 59.3M | if (pps->constrained_intra_pred_flag == 1) { | 191 | 47.7M | if (cand_bottom_left || cand_left || cand_up_left || cand_up || cand_up_right) { | 192 | 47.7M | int size_max_x = x0 + ((2 * size) << hshift) < sps->width ? | 193 | 47.1M | 2 * size : (sps->width - x0) >> hshift; | 194 | 47.7M | int size_max_y = y0 + ((2 * size) << vshift) < sps->height ? | 195 | 46.9M | 2 * size : (sps->height - y0) >> vshift; | 196 | 47.7M | int j = size + (cand_bottom_left? bottom_left_size: 0) -1; | 197 | 47.7M | if (!cand_up_right) { | 198 | 26.0M | size_max_x = x0 + ((size) << hshift) < sps->width ? | 199 | 25.6M | size : (sps->width - x0) >> hshift; | 200 | 26.0M | } | 201 | 47.7M | if (!cand_bottom_left) { | 202 | 22.4M | size_max_y = y0 + (( size) << vshift) < sps->height ? | 203 | 22.0M | size : (sps->height - y0) >> vshift; | 204 | 22.4M | } | 205 | 47.7M | if (cand_bottom_left || cand_left || cand_up_left) { | 206 | 47.5M | while (j > -1 && !IS_INTRA(-1, j)) | 207 | 27.4k | j--; | 208 | 47.4M | if (!IS_INTRA(-1, j)) { | 209 | 0 | j = 0; | 210 | 0 | while (j < size_max_x && !IS_INTRA(j, -1)) | 211 | 0 | j++; | 212 | 0 | EXTEND_LEFT_CIP(top, j, j + 1); | 213 | 0 | left[-1] = top[-1]; | 214 | 0 | } | 215 | 47.4M | } else { | 216 | 255k | j = 0; | 217 | 267k | while (j < size_max_x && !IS_INTRA(j, -1)) | 218 | 11.4k | j++; | 219 | 255k | if (j > 0) { | 220 | 970 | EXTEND_LEFT_CIP(top, j, j); | 221 | 970 | top[-1] = top[0]; | 222 | 970 | } | 223 | 255k | left[-1] = top[-1]; | 224 | 255k | } | 225 | 47.7M | left[-1] = top[-1]; | 226 | 47.7M | if (cand_bottom_left || cand_left) { | 227 | 46.9M | a = PIXEL_SPLAT_X4(left[-1]); | 228 | 46.9M | EXTEND_DOWN_CIP(left, 0, size_max_y); | 229 | 46.9M | } | 230 | 47.7M | if (!cand_left) | 231 | 812k | EXTEND(left, left[-1], size); | 232 | 47.7M | if (!cand_bottom_left) | 233 | 22.4M | EXTEND(left + size, left[size - 1], size); | 234 | 47.7M | if (x0 != 0 && y0 != 0) { | 235 | 47.1M | a = PIXEL_SPLAT_X4(left[size_max_y - 1]); | 236 | 47.1M | EXTEND_UP_CIP(left, size_max_y - 1, size_max_y); | 237 | 47.1M | if (!IS_INTRA(-1, - 1)) | 238 | 26.3k | left[-1] = left[0]; | 239 | 47.1M | } else if (x0 == 0) { | 240 | 232k | EXTEND(left, 0, size_max_y); | 241 | 347k | } else { | 242 | 347k | a = PIXEL_SPLAT_X4(left[size_max_y - 1]); | 243 | 347k | EXTEND_UP_CIP(left, size_max_y - 1, size_max_y); | 244 | 347k | } | 245 | 47.7M | top[-1] = left[-1]; | 246 | 47.7M | if (y0 != 0) { | 247 | 47.3M | a = PIXEL_SPLAT_X4(left[-1]); | 248 | 47.3M | EXTEND_RIGHT_CIP(top, 0, size_max_x); | 249 | 47.3M | } | 250 | 47.7M | } | 251 | 47.7M | } | 252 | | // Infer the unavailable samples | 253 | 59.3M | if (!cand_bottom_left) { | 254 | 29.8M | if (cand_left) { | 255 | 28.8M | EXTEND(left + size, left[size - 1], size); | 256 | 28.8M | } else if (cand_up_left) { | 257 | 555k | EXTEND(left, left[-1], 2 * size); | 258 | 555k | cand_left = 1; | 259 | 555k | } else if (cand_up) { | 260 | 425k | left[-1] = top[0]; | 261 | 425k | EXTEND(left, left[-1], 2 * size); | 262 | 425k | cand_up_left = 1; | 263 | 425k | cand_left = 1; | 264 | 425k | } else if (cand_up_right) { | 265 | 925 | EXTEND(top, top[size], size); | 266 | 925 | left[-1] = top[size]; | 267 | 925 | EXTEND(left, left[-1], 2 * size); | 268 | 925 | cand_up = 1; | 269 | 925 | cand_up_left = 1; | 270 | 925 | cand_left = 1; | 271 | 55.3k | } else { // No samples available | 272 | 55.3k | left[-1] = (1 << (BIT_DEPTH - 1)); | 273 | 55.3k | EXTEND(top, left[-1], 2 * size); | 274 | 55.3k | EXTEND(left, left[-1], 2 * size); | 275 | 55.3k | } | 276 | 29.8M | } | 277 | | | 278 | 59.3M | if (!cand_left) | 279 | 56.3k | EXTEND(left, left[size], size); | 280 | 59.3M | if (!cand_up_left) { | 281 | 753k | left[-1] = left[0]; | 282 | 753k | } | 283 | 59.3M | if (!cand_up) | 284 | 755k | EXTEND(top, left[-1], size); | 285 | 59.3M | if (!cand_up_right) | 286 | 30.7M | EXTEND(top + size, top[size - 1], size); | 287 | | | 288 | 59.3M | top[-1] = left[-1]; | 289 | | | 290 | | // Filtering process | 291 | 59.3M | if (!sps->intra_smoothing_disabled && (c_idx == 0 || sps->chroma_format_idc == 3)) { | 292 | 20.2M | if (mode != INTRA_DC && size != 4){ | 293 | 7.39M | int intra_hor_ver_dist_thresh[] = { 7, 1, 0 }; | 294 | 7.39M | int min_dist_vert_hor = FFMIN(FFABS((int)(mode - 26U)), | 295 | 7.39M | FFABS((int)(mode - 10U))); | 296 | 7.39M | if (min_dist_vert_hor > intra_hor_ver_dist_thresh[log2_size - 3]) { | 297 | 5.56M | int threshold = 1 << (BIT_DEPTH - 5); | 298 | 5.56M | if (sps->strong_intra_smoothing_enabled && c_idx == 0 && | 299 | 4.67M | log2_size == 5 && | 300 | 232k | FFABS(top[-1] + top[63] - 2 * top[31]) < threshold && | 301 | 167k | 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 | 140k | filtered_top[-1] = top[-1]; | 305 | 140k | filtered_top[63] = top[63]; | 306 | 8.98M | for (i = 0; i < 63; i++) | 307 | 8.84M | filtered_top[i] = ((64 - (i + 1)) * top[-1] + | 308 | 8.84M | (i + 1) * top[63] + 32) >> 6; | 309 | 8.98M | for (i = 0; i < 63; i++) | 310 | 8.84M | left[i] = ((64 - (i + 1)) * left[-1] + | 311 | 8.84M | (i + 1) * left[63] + 32) >> 6; | 312 | 140k | top = filtered_top; | 313 | 5.42M | } else { | 314 | 5.42M | filtered_left[2 * size - 1] = left[2 * size - 1]; | 315 | 5.42M | filtered_top[2 * size - 1] = top[2 * size - 1]; | 316 | 109M | for (i = 2 * size - 2; i >= 0; i--) | 317 | 103M | filtered_left[i] = (left[i + 1] + 2 * left[i] + | 318 | 103M | left[i - 1] + 2) >> 2; | 319 | 5.42M | filtered_top[-1] = | 320 | 5.42M | filtered_left[-1] = (left[0] + 2 * left[-1] + top[0] + 2) >> 2; | 321 | 109M | for (i = 2 * size - 2; i >= 0; i--) | 322 | 103M | filtered_top[i] = (top[i + 1] + 2 * top[i] + | 323 | 103M | top[i - 1] + 2) >> 2; | 324 | 5.42M | left = filtered_left; | 325 | 5.42M | top = filtered_top; | 326 | 5.42M | } | 327 | 5.56M | } | 328 | 7.39M | } | 329 | 20.2M | } | 330 | | | 331 | 59.3M | switch (mode) { | 332 | 26.2M | case INTRA_PLANAR: | 333 | 26.2M | s->hpc.pred_planar[log2_size - 2]((uint8_t *)src, (uint8_t *)top, | 334 | 26.2M | (uint8_t *)left, stride); | 335 | 26.2M | break; | 336 | 11.3M | case INTRA_DC: | 337 | 11.3M | s->hpc.pred_dc((uint8_t *)src, (uint8_t *)top, | 338 | 11.3M | (uint8_t *)left, stride, log2_size, c_idx); | 339 | 11.3M | break; | 340 | 21.8M | default: | 341 | 21.8M | s->hpc.pred_angular[log2_size - 2]((uint8_t *)src, (uint8_t *)top, | 342 | 21.8M | (uint8_t *)left, stride, c_idx, | 343 | 21.8M | mode); | 344 | 21.8M | break; | 345 | 59.3M | } | 346 | 59.3M | } |
Line | Count | Source | 34 | 75.3M | { | 35 | 75.3M | #define PU(x) \ | 36 | 75.3M | ((x) >> sps->log2_min_pu_size) | 37 | 75.3M | #define MVF(x, y) \ | 38 | 75.3M | (s->cur_frame->tab_mvf[(x) + (y) * min_pu_width]) | 39 | 75.3M | #define MVF_PU(x, y) \ | 40 | 75.3M | MVF(PU(x0 + ((x) * (1 << hshift))), PU(y0 + ((y) * (1 << vshift)))) | 41 | 75.3M | #define IS_INTRA(x, y) \ | 42 | 75.3M | (MVF_PU(x, y).pred_flag == PF_INTRA) | 43 | 75.3M | #define MIN_TB_ADDR_ZS(x, y) \ | 44 | 75.3M | pps->min_tb_addr_zs[(y) * (sps->tb_mask+2) + (x)] | 45 | 75.3M | #define EXTEND(ptr, val, len) \ | 46 | 75.3M | do { \ | 47 | 75.3M | pixel4 pix = PIXEL_SPLAT_X4(val); \ | 48 | 75.3M | for (i = 0; i < (len); i += 4) \ | 49 | 75.3M | AV_WN4P(ptr + i, pix); \ | 50 | 75.3M | } while (0) | 51 | | | 52 | 75.3M | #define EXTEND_RIGHT_CIP(ptr, start, length) \ | 53 | 75.3M | for (i = start; i < (start) + (length); i += 4) \ | 54 | 75.3M | if (!IS_INTRA(i, -1)) \ | 55 | 75.3M | AV_WN4P(&ptr[i], a); \ | 56 | 75.3M | else \ | 57 | 75.3M | a = PIXEL_SPLAT_X4(ptr[i+3]) | 58 | 75.3M | #define EXTEND_LEFT_CIP(ptr, start, length) \ | 59 | 75.3M | for (i = start; i > (start) - (length); i--) \ | 60 | 75.3M | if (!IS_INTRA(i - 1, -1)) \ | 61 | 75.3M | ptr[i - 1] = ptr[i] | 62 | 75.3M | #define EXTEND_UP_CIP(ptr, start, length) \ | 63 | 75.3M | for (i = (start); i > (start) - (length); i -= 4) \ | 64 | 75.3M | if (!IS_INTRA(-1, i - 3)) \ | 65 | 75.3M | AV_WN4P(&ptr[i - 3], a); \ | 66 | 75.3M | else \ | 67 | 75.3M | a = PIXEL_SPLAT_X4(ptr[i - 3]) | 68 | 75.3M | #define EXTEND_DOWN_CIP(ptr, start, length) \ | 69 | 75.3M | for (i = start; i < (start) + (length); i += 4) \ | 70 | 75.3M | if (!IS_INTRA(-1, i)) \ | 71 | 75.3M | AV_WN4P(&ptr[i], a); \ | 72 | 75.3M | else \ | 73 | 75.3M | a = PIXEL_SPLAT_X4(ptr[i + 3]) | 74 | | | 75 | 75.3M | const HEVCSPS *const sps = pps->sps; | 76 | 75.3M | const HEVCContext *const s = lc->parent; | 77 | 75.3M | int i; | 78 | 75.3M | int hshift = sps->hshift[c_idx]; | 79 | 75.3M | int vshift = sps->vshift[c_idx]; | 80 | 75.3M | int size = (1 << log2_size); | 81 | 75.3M | int size_in_luma_h = size << hshift; | 82 | 75.3M | int size_in_tbs_h = size_in_luma_h >> sps->log2_min_tb_size; | 83 | 75.3M | int size_in_luma_v = size << vshift; | 84 | 75.3M | int size_in_tbs_v = size_in_luma_v >> sps->log2_min_tb_size; | 85 | 75.3M | int x = x0 >> hshift; | 86 | 75.3M | int y = y0 >> vshift; | 87 | 75.3M | int x_tb = (x0 >> sps->log2_min_tb_size) & sps->tb_mask; | 88 | 75.3M | int y_tb = (y0 >> sps->log2_min_tb_size) & sps->tb_mask; | 89 | 75.3M | int spin = c_idx && !size_in_tbs_v && ((2 * y0) & (1 << sps->log2_min_tb_size)); | 90 | | | 91 | 75.3M | int cur_tb_addr = MIN_TB_ADDR_ZS(x_tb, y_tb); | 92 | | | 93 | 75.3M | ptrdiff_t stride = s->cur_frame->f->linesize[c_idx] / sizeof(pixel); | 94 | 75.3M | pixel *src = (pixel*)s->cur_frame->f->data[c_idx] + x + y * stride; | 95 | | | 96 | 75.3M | int min_pu_width = sps->min_pu_width; | 97 | | | 98 | 75.3M | enum IntraPredMode mode = c_idx ? lc->tu.intra_pred_mode_c : | 99 | 75.3M | lc->tu.intra_pred_mode; | 100 | 75.3M | pixel4 a; | 101 | 75.3M | pixel left_array[2 * MAX_TB_SIZE + 1]; | 102 | 75.3M | pixel filtered_left_array[2 * MAX_TB_SIZE + 1]; | 103 | 75.3M | pixel top_array[2 * MAX_TB_SIZE + 1]; | 104 | 75.3M | pixel filtered_top_array[2 * MAX_TB_SIZE + 1]; | 105 | | | 106 | 75.3M | pixel *left = left_array + 1; | 107 | 75.3M | pixel *top = top_array + 1; | 108 | 75.3M | pixel *filtered_left = filtered_left_array + 1; | 109 | 75.3M | pixel *filtered_top = filtered_top_array + 1; | 110 | 75.3M | 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 | 75.3M | int cand_left = lc->na.cand_left; | 112 | 75.3M | int cand_up_left = lc->na.cand_up_left; | 113 | 75.3M | int cand_up = lc->na.cand_up; | 114 | 75.3M | 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 | 75.3M | int bottom_left_size = (FFMIN(y0 + 2 * size_in_luma_v, sps->height) - | 117 | 75.3M | (y0 + size_in_luma_v)) >> vshift; | 118 | 75.3M | int top_right_size = (FFMIN(x0 + 2 * size_in_luma_h, sps->width) - | 119 | 75.3M | (x0 + size_in_luma_h)) >> hshift; | 120 | | | 121 | 75.3M | if (pps->constrained_intra_pred_flag == 1) { | 122 | 15.0M | int size_in_luma_pu_v = PU(size_in_luma_v); | 123 | 15.0M | int size_in_luma_pu_h = PU(size_in_luma_h); | 124 | 15.0M | int on_pu_edge_x = !av_zero_extend(x0, sps->log2_min_pu_size); | 125 | 15.0M | int on_pu_edge_y = !av_zero_extend(y0, sps->log2_min_pu_size); | 126 | 15.0M | if (!size_in_luma_pu_h) | 127 | 214k | size_in_luma_pu_h++; | 128 | 15.0M | if (cand_bottom_left == 1 && on_pu_edge_x) { | 129 | 5.63M | int x_left_pu = PU(x0 - 1); | 130 | 5.63M | int y_bottom_pu = PU(y0 + size_in_luma_v); | 131 | 5.63M | int max = FFMIN(size_in_luma_pu_v, sps->min_pu_height - y_bottom_pu); | 132 | 5.63M | cand_bottom_left = 0; | 133 | 11.5M | for (i = 0; i < max; i += 2) | 134 | 5.93M | cand_bottom_left |= (MVF(x_left_pu, y_bottom_pu + i).pred_flag == PF_INTRA); | 135 | 5.63M | } | 136 | 15.0M | if (cand_left == 1 && on_pu_edge_x) { | 137 | 14.6M | int x_left_pu = PU(x0 - 1); | 138 | 14.6M | int y_left_pu = PU(y0); | 139 | 14.6M | int max = FFMIN(size_in_luma_pu_v, sps->min_pu_height - y_left_pu); | 140 | 14.6M | cand_left = 0; | 141 | 30.7M | for (i = 0; i < max; i += 2) | 142 | 16.1M | cand_left |= (MVF(x_left_pu, y_left_pu + i).pred_flag == PF_INTRA); | 143 | 14.6M | } | 144 | 15.0M | if (cand_up_left == 1) { | 145 | 14.3M | int x_left_pu = PU(x0 - 1); | 146 | 14.3M | int y_top_pu = PU(y0 - 1); | 147 | 14.3M | cand_up_left = MVF(x_left_pu, y_top_pu).pred_flag == PF_INTRA; | 148 | 14.3M | } | 149 | 15.0M | if (cand_up == 1 && on_pu_edge_y) { | 150 | 14.4M | int x_top_pu = PU(x0); | 151 | 14.4M | int y_top_pu = PU(y0 - 1); | 152 | 14.4M | int max = FFMIN(size_in_luma_pu_h, sps->min_pu_width - x_top_pu); | 153 | 14.4M | cand_up = 0; | 154 | 30.6M | for (i = 0; i < max; i += 2) | 155 | 16.2M | cand_up |= (MVF(x_top_pu + i, y_top_pu).pred_flag == PF_INTRA); | 156 | 14.4M | } | 157 | 15.0M | if (cand_up_right == 1 && on_pu_edge_y) { | 158 | 8.71M | int y_top_pu = PU(y0 - 1); | 159 | 8.71M | int x_right_pu = PU(x0 + size_in_luma_h); | 160 | 8.71M | int max = FFMIN(size_in_luma_pu_h, sps->min_pu_width - x_right_pu); | 161 | 8.71M | cand_up_right = 0; | 162 | 18.4M | for (i = 0; i < max; i += 2) | 163 | 9.75M | cand_up_right |= (MVF(x_right_pu + i, y_top_pu).pred_flag == PF_INTRA); | 164 | 8.71M | } | 165 | 15.0M | memset(left, 128, 2 * MAX_TB_SIZE*sizeof(pixel)); | 166 | 15.0M | memset(top , 128, 2 * MAX_TB_SIZE*sizeof(pixel)); | 167 | 15.0M | top[-1] = 128; | 168 | 15.0M | } | 169 | 75.3M | if (cand_up_left) { | 170 | 73.3M | left[-1] = POS(-1, -1); | 171 | 73.3M | top[-1] = left[-1]; | 172 | 73.3M | } | 173 | 75.3M | if (cand_up) | 174 | 74.0M | memcpy(top, src - stride, size * sizeof(pixel)); | 175 | 75.3M | if (cand_up_right) { | 176 | 38.3M | memcpy(top + size, src - stride + size, size * sizeof(pixel)); | 177 | 38.3M | EXTEND(top + size + top_right_size, POS(size + top_right_size - 1, -1), | 178 | 38.3M | size - top_right_size); | 179 | 38.3M | } | 180 | 75.3M | if (cand_left) | 181 | 449M | for (i = 0; i < size; i++) | 182 | 375M | left[i] = POS(-1, i); | 183 | 75.3M | if (cand_bottom_left) { | 184 | 203M | for (i = size; i < size + bottom_left_size; i++) | 185 | 168M | left[i] = POS(-1, i); | 186 | 34.9M | EXTEND(left + size + bottom_left_size, POS(-1, size + bottom_left_size - 1), | 187 | 34.9M | size - bottom_left_size); | 188 | 34.9M | } | 189 | | | 190 | 75.3M | if (pps->constrained_intra_pred_flag == 1) { | 191 | 15.0M | if (cand_bottom_left || cand_left || cand_up_left || cand_up || cand_up_right) { | 192 | 15.0M | int size_max_x = x0 + ((2 * size) << hshift) < sps->width ? | 193 | 14.4M | 2 * size : (sps->width - x0) >> hshift; | 194 | 15.0M | int size_max_y = y0 + ((2 * size) << vshift) < sps->height ? | 195 | 14.1M | 2 * size : (sps->height - y0) >> vshift; | 196 | 15.0M | int j = size + (cand_bottom_left? bottom_left_size: 0) -1; | 197 | 15.0M | if (!cand_up_right) { | 198 | 6.33M | size_max_x = x0 + ((size) << hshift) < sps->width ? | 199 | 6.06M | size : (sps->width - x0) >> hshift; | 200 | 6.33M | } | 201 | 15.0M | if (!cand_bottom_left) { | 202 | 9.55M | size_max_y = y0 + (( size) << vshift) < sps->height ? | 203 | 9.12M | size : (sps->height - y0) >> vshift; | 204 | 9.55M | } | 205 | 15.0M | if (cand_bottom_left || cand_left || cand_up_left) { | 206 | 14.7M | while (j > -1 && !IS_INTRA(-1, j)) | 207 | 16.5k | j--; | 208 | 14.7M | if (!IS_INTRA(-1, j)) { | 209 | 0 | j = 0; | 210 | 0 | while (j < size_max_x && !IS_INTRA(j, -1)) | 211 | 0 | j++; | 212 | 0 | EXTEND_LEFT_CIP(top, j, j + 1); | 213 | 0 | left[-1] = top[-1]; | 214 | 0 | } | 215 | 14.7M | } else { | 216 | 285k | j = 0; | 217 | 308k | while (j < size_max_x && !IS_INTRA(j, -1)) | 218 | 23.8k | j++; | 219 | 285k | if (j > 0) { | 220 | 1.23k | EXTEND_LEFT_CIP(top, j, j); | 221 | 1.23k | top[-1] = top[0]; | 222 | 1.23k | } | 223 | 285k | left[-1] = top[-1]; | 224 | 285k | } | 225 | 15.0M | left[-1] = top[-1]; | 226 | 15.0M | if (cand_bottom_left || cand_left) { | 227 | 14.5M | a = PIXEL_SPLAT_X4(left[-1]); | 228 | 14.5M | EXTEND_DOWN_CIP(left, 0, size_max_y); | 229 | 14.5M | } | 230 | 15.0M | if (!cand_left) | 231 | 512k | EXTEND(left, left[-1], size); | 232 | 15.0M | if (!cand_bottom_left) | 233 | 9.55M | EXTEND(left + size, left[size - 1], size); | 234 | 15.0M | if (x0 != 0 && y0 != 0) { | 235 | 14.4M | a = PIXEL_SPLAT_X4(left[size_max_y - 1]); | 236 | 14.4M | EXTEND_UP_CIP(left, size_max_y - 1, size_max_y); | 237 | 14.4M | if (!IS_INTRA(-1, - 1)) | 238 | 12.2k | left[-1] = left[0]; | 239 | 14.4M | } else if (x0 == 0) { | 240 | 247k | EXTEND(left, 0, size_max_y); | 241 | 330k | } else { | 242 | 330k | a = PIXEL_SPLAT_X4(left[size_max_y - 1]); | 243 | 330k | EXTEND_UP_CIP(left, size_max_y - 1, size_max_y); | 244 | 330k | } | 245 | 15.0M | top[-1] = left[-1]; | 246 | 15.0M | if (y0 != 0) { | 247 | 14.7M | a = PIXEL_SPLAT_X4(left[-1]); | 248 | 14.7M | EXTEND_RIGHT_CIP(top, 0, size_max_x); | 249 | 14.7M | } | 250 | 15.0M | } | 251 | 15.0M | } | 252 | | // Infer the unavailable samples | 253 | 75.3M | if (!cand_bottom_left) { | 254 | 40.3M | if (cand_left) { | 255 | 39.3M | EXTEND(left + size, left[size - 1], size); | 256 | 39.3M | } else if (cand_up_left) { | 257 | 226k | EXTEND(left, left[-1], 2 * size); | 258 | 226k | cand_left = 1; | 259 | 747k | } else if (cand_up) { | 260 | 687k | left[-1] = top[0]; | 261 | 687k | EXTEND(left, left[-1], 2 * size); | 262 | 687k | cand_up_left = 1; | 263 | 687k | cand_left = 1; | 264 | 687k | } else if (cand_up_right) { | 265 | 1.15k | EXTEND(top, top[size], size); | 266 | 1.15k | left[-1] = top[size]; | 267 | 1.15k | EXTEND(left, left[-1], 2 * size); | 268 | 1.15k | cand_up = 1; | 269 | 1.15k | cand_up_left = 1; | 270 | 1.15k | cand_left = 1; | 271 | 58.4k | } else { // No samples available | 272 | 58.4k | left[-1] = (1 << (BIT_DEPTH - 1)); | 273 | 58.4k | EXTEND(top, left[-1], 2 * size); | 274 | 58.4k | EXTEND(left, left[-1], 2 * size); | 275 | 58.4k | } | 276 | 40.3M | } | 277 | | | 278 | 75.3M | if (!cand_left) | 279 | 58.9k | EXTEND(left, left[size], size); | 280 | 75.3M | if (!cand_up_left) { | 281 | 1.21M | left[-1] = left[0]; | 282 | 1.21M | } | 283 | 75.3M | if (!cand_up) | 284 | 1.21M | EXTEND(top, left[-1], size); | 285 | 75.3M | if (!cand_up_right) | 286 | 36.9M | EXTEND(top + size, top[size - 1], size); | 287 | | | 288 | 75.3M | top[-1] = left[-1]; | 289 | | | 290 | | // Filtering process | 291 | 75.3M | if (!sps->intra_smoothing_disabled && (c_idx == 0 || sps->chroma_format_idc == 3)) { | 292 | 25.6M | if (mode != INTRA_DC && size != 4){ | 293 | 6.98M | int intra_hor_ver_dist_thresh[] = { 7, 1, 0 }; | 294 | 6.98M | int min_dist_vert_hor = FFMIN(FFABS((int)(mode - 26U)), | 295 | 6.98M | FFABS((int)(mode - 10U))); | 296 | 6.98M | if (min_dist_vert_hor > intra_hor_ver_dist_thresh[log2_size - 3]) { | 297 | 5.17M | int threshold = 1 << (BIT_DEPTH - 5); | 298 | 5.17M | if (sps->strong_intra_smoothing_enabled && c_idx == 0 && | 299 | 4.42M | log2_size == 5 && | 300 | 242k | FFABS(top[-1] + top[63] - 2 * top[31]) < threshold && | 301 | 174k | 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 | 146k | filtered_top[-1] = top[-1]; | 305 | 146k | filtered_top[63] = top[63]; | 306 | 9.37M | for (i = 0; i < 63; i++) | 307 | 9.23M | filtered_top[i] = ((64 - (i + 1)) * top[-1] + | 308 | 9.23M | (i + 1) * top[63] + 32) >> 6; | 309 | 9.37M | for (i = 0; i < 63; i++) | 310 | 9.23M | left[i] = ((64 - (i + 1)) * left[-1] + | 311 | 9.23M | (i + 1) * left[63] + 32) >> 6; | 312 | 146k | top = filtered_top; | 313 | 5.02M | } else { | 314 | 5.02M | filtered_left[2 * size - 1] = left[2 * size - 1]; | 315 | 5.02M | filtered_top[2 * size - 1] = top[2 * size - 1]; | 316 | 95.9M | for (i = 2 * size - 2; i >= 0; i--) | 317 | 90.9M | filtered_left[i] = (left[i + 1] + 2 * left[i] + | 318 | 90.9M | left[i - 1] + 2) >> 2; | 319 | 5.02M | filtered_top[-1] = | 320 | 5.02M | filtered_left[-1] = (left[0] + 2 * left[-1] + top[0] + 2) >> 2; | 321 | 95.9M | for (i = 2 * size - 2; i >= 0; i--) | 322 | 90.9M | filtered_top[i] = (top[i + 1] + 2 * top[i] + | 323 | 90.9M | top[i - 1] + 2) >> 2; | 324 | 5.02M | left = filtered_left; | 325 | 5.02M | top = filtered_top; | 326 | 5.02M | } | 327 | 5.17M | } | 328 | 6.98M | } | 329 | 25.6M | } | 330 | | | 331 | 75.3M | switch (mode) { | 332 | 30.8M | case INTRA_PLANAR: | 333 | 30.8M | s->hpc.pred_planar[log2_size - 2]((uint8_t *)src, (uint8_t *)top, | 334 | 30.8M | (uint8_t *)left, stride); | 335 | 30.8M | break; | 336 | 12.7M | case INTRA_DC: | 337 | 12.7M | s->hpc.pred_dc((uint8_t *)src, (uint8_t *)top, | 338 | 12.7M | (uint8_t *)left, stride, log2_size, c_idx); | 339 | 12.7M | break; | 340 | 31.6M | default: | 341 | 31.6M | s->hpc.pred_angular[log2_size - 2]((uint8_t *)src, (uint8_t *)top, | 342 | 31.6M | (uint8_t *)left, stride, c_idx, | 343 | 31.6M | mode); | 344 | 31.6M | break; | 345 | 75.3M | } | 346 | 75.3M | } |
Line | Count | Source | 34 | 48.6M | { | 35 | 48.6M | #define PU(x) \ | 36 | 48.6M | ((x) >> sps->log2_min_pu_size) | 37 | 48.6M | #define MVF(x, y) \ | 38 | 48.6M | (s->cur_frame->tab_mvf[(x) + (y) * min_pu_width]) | 39 | 48.6M | #define MVF_PU(x, y) \ | 40 | 48.6M | MVF(PU(x0 + ((x) * (1 << hshift))), PU(y0 + ((y) * (1 << vshift)))) | 41 | 48.6M | #define IS_INTRA(x, y) \ | 42 | 48.6M | (MVF_PU(x, y).pred_flag == PF_INTRA) | 43 | 48.6M | #define MIN_TB_ADDR_ZS(x, y) \ | 44 | 48.6M | pps->min_tb_addr_zs[(y) * (sps->tb_mask+2) + (x)] | 45 | 48.6M | #define EXTEND(ptr, val, len) \ | 46 | 48.6M | do { \ | 47 | 48.6M | pixel4 pix = PIXEL_SPLAT_X4(val); \ | 48 | 48.6M | for (i = 0; i < (len); i += 4) \ | 49 | 48.6M | AV_WN4P(ptr + i, pix); \ | 50 | 48.6M | } while (0) | 51 | | | 52 | 48.6M | #define EXTEND_RIGHT_CIP(ptr, start, length) \ | 53 | 48.6M | for (i = start; i < (start) + (length); i += 4) \ | 54 | 48.6M | if (!IS_INTRA(i, -1)) \ | 55 | 48.6M | AV_WN4P(&ptr[i], a); \ | 56 | 48.6M | else \ | 57 | 48.6M | a = PIXEL_SPLAT_X4(ptr[i+3]) | 58 | 48.6M | #define EXTEND_LEFT_CIP(ptr, start, length) \ | 59 | 48.6M | for (i = start; i > (start) - (length); i--) \ | 60 | 48.6M | if (!IS_INTRA(i - 1, -1)) \ | 61 | 48.6M | ptr[i - 1] = ptr[i] | 62 | 48.6M | #define EXTEND_UP_CIP(ptr, start, length) \ | 63 | 48.6M | for (i = (start); i > (start) - (length); i -= 4) \ | 64 | 48.6M | if (!IS_INTRA(-1, i - 3)) \ | 65 | 48.6M | AV_WN4P(&ptr[i - 3], a); \ | 66 | 48.6M | else \ | 67 | 48.6M | a = PIXEL_SPLAT_X4(ptr[i - 3]) | 68 | 48.6M | #define EXTEND_DOWN_CIP(ptr, start, length) \ | 69 | 48.6M | for (i = start; i < (start) + (length); i += 4) \ | 70 | 48.6M | if (!IS_INTRA(-1, i)) \ | 71 | 48.6M | AV_WN4P(&ptr[i], a); \ | 72 | 48.6M | else \ | 73 | 48.6M | a = PIXEL_SPLAT_X4(ptr[i + 3]) | 74 | | | 75 | 48.6M | const HEVCSPS *const sps = pps->sps; | 76 | 48.6M | const HEVCContext *const s = lc->parent; | 77 | 48.6M | int i; | 78 | 48.6M | int hshift = sps->hshift[c_idx]; | 79 | 48.6M | int vshift = sps->vshift[c_idx]; | 80 | 48.6M | int size = (1 << log2_size); | 81 | 48.6M | int size_in_luma_h = size << hshift; | 82 | 48.6M | int size_in_tbs_h = size_in_luma_h >> sps->log2_min_tb_size; | 83 | 48.6M | int size_in_luma_v = size << vshift; | 84 | 48.6M | int size_in_tbs_v = size_in_luma_v >> sps->log2_min_tb_size; | 85 | 48.6M | int x = x0 >> hshift; | 86 | 48.6M | int y = y0 >> vshift; | 87 | 48.6M | int x_tb = (x0 >> sps->log2_min_tb_size) & sps->tb_mask; | 88 | 48.6M | int y_tb = (y0 >> sps->log2_min_tb_size) & sps->tb_mask; | 89 | 48.6M | int spin = c_idx && !size_in_tbs_v && ((2 * y0) & (1 << sps->log2_min_tb_size)); | 90 | | | 91 | 48.6M | int cur_tb_addr = MIN_TB_ADDR_ZS(x_tb, y_tb); | 92 | | | 93 | 48.6M | ptrdiff_t stride = s->cur_frame->f->linesize[c_idx] / sizeof(pixel); | 94 | 48.6M | pixel *src = (pixel*)s->cur_frame->f->data[c_idx] + x + y * stride; | 95 | | | 96 | 48.6M | int min_pu_width = sps->min_pu_width; | 97 | | | 98 | 48.6M | enum IntraPredMode mode = c_idx ? lc->tu.intra_pred_mode_c : | 99 | 48.6M | lc->tu.intra_pred_mode; | 100 | 48.6M | pixel4 a; | 101 | 48.6M | pixel left_array[2 * MAX_TB_SIZE + 1]; | 102 | 48.6M | pixel filtered_left_array[2 * MAX_TB_SIZE + 1]; | 103 | 48.6M | pixel top_array[2 * MAX_TB_SIZE + 1]; | 104 | 48.6M | pixel filtered_top_array[2 * MAX_TB_SIZE + 1]; | 105 | | | 106 | 48.6M | pixel *left = left_array + 1; | 107 | 48.6M | pixel *top = top_array + 1; | 108 | 48.6M | pixel *filtered_left = filtered_left_array + 1; | 109 | 48.6M | pixel *filtered_top = filtered_top_array + 1; | 110 | 48.6M | 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 | 48.6M | int cand_left = lc->na.cand_left; | 112 | 48.6M | int cand_up_left = lc->na.cand_up_left; | 113 | 48.6M | int cand_up = lc->na.cand_up; | 114 | 48.6M | 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 | 48.6M | int bottom_left_size = (FFMIN(y0 + 2 * size_in_luma_v, sps->height) - | 117 | 48.6M | (y0 + size_in_luma_v)) >> vshift; | 118 | 48.6M | int top_right_size = (FFMIN(x0 + 2 * size_in_luma_h, sps->width) - | 119 | 48.6M | (x0 + size_in_luma_h)) >> hshift; | 120 | | | 121 | 48.6M | if (pps->constrained_intra_pred_flag == 1) { | 122 | 14.1M | int size_in_luma_pu_v = PU(size_in_luma_v); | 123 | 14.1M | int size_in_luma_pu_h = PU(size_in_luma_h); | 124 | 14.1M | int on_pu_edge_x = !av_zero_extend(x0, sps->log2_min_pu_size); | 125 | 14.1M | int on_pu_edge_y = !av_zero_extend(y0, sps->log2_min_pu_size); | 126 | 14.1M | if (!size_in_luma_pu_h) | 127 | 553k | size_in_luma_pu_h++; | 128 | 14.1M | if (cand_bottom_left == 1 && on_pu_edge_x) { | 129 | 4.42M | int x_left_pu = PU(x0 - 1); | 130 | 4.42M | int y_bottom_pu = PU(y0 + size_in_luma_v); | 131 | 4.42M | int max = FFMIN(size_in_luma_pu_v, sps->min_pu_height - y_bottom_pu); | 132 | 4.42M | cand_bottom_left = 0; | 133 | 9.09M | for (i = 0; i < max; i += 2) | 134 | 4.66M | cand_bottom_left |= (MVF(x_left_pu, y_bottom_pu + i).pred_flag == PF_INTRA); | 135 | 4.42M | } | 136 | 14.1M | if (cand_left == 1 && on_pu_edge_x) { | 137 | 13.5M | int x_left_pu = PU(x0 - 1); | 138 | 13.5M | int y_left_pu = PU(y0); | 139 | 13.5M | int max = FFMIN(size_in_luma_pu_v, sps->min_pu_height - y_left_pu); | 140 | 13.5M | cand_left = 0; | 141 | 28.3M | for (i = 0; i < max; i += 2) | 142 | 14.8M | cand_left |= (MVF(x_left_pu, y_left_pu + i).pred_flag == PF_INTRA); | 143 | 13.5M | } | 144 | 14.1M | if (cand_up_left == 1) { | 145 | 13.5M | int x_left_pu = PU(x0 - 1); | 146 | 13.5M | int y_top_pu = PU(y0 - 1); | 147 | 13.5M | cand_up_left = MVF(x_left_pu, y_top_pu).pred_flag == PF_INTRA; | 148 | 13.5M | } | 149 | 14.1M | if (cand_up == 1 && on_pu_edge_y) { | 150 | 13.3M | int x_top_pu = PU(x0); | 151 | 13.3M | int y_top_pu = PU(y0 - 1); | 152 | 13.3M | int max = FFMIN(size_in_luma_pu_h, sps->min_pu_width - x_top_pu); | 153 | 13.3M | cand_up = 0; | 154 | 28.0M | for (i = 0; i < max; i += 2) | 155 | 14.7M | cand_up |= (MVF(x_top_pu + i, y_top_pu).pred_flag == PF_INTRA); | 156 | 13.3M | } | 157 | 14.1M | if (cand_up_right == 1 && on_pu_edge_y) { | 158 | 8.82M | int y_top_pu = PU(y0 - 1); | 159 | 8.82M | int x_right_pu = PU(x0 + size_in_luma_h); | 160 | 8.82M | int max = FFMIN(size_in_luma_pu_h, sps->min_pu_width - x_right_pu); | 161 | 8.82M | cand_up_right = 0; | 162 | 18.5M | for (i = 0; i < max; i += 2) | 163 | 9.77M | cand_up_right |= (MVF(x_right_pu + i, y_top_pu).pred_flag == PF_INTRA); | 164 | 8.82M | } | 165 | 14.1M | memset(left, 128, 2 * MAX_TB_SIZE*sizeof(pixel)); | 166 | 14.1M | memset(top , 128, 2 * MAX_TB_SIZE*sizeof(pixel)); | 167 | 14.1M | top[-1] = 128; | 168 | 14.1M | } | 169 | 48.6M | if (cand_up_left) { | 170 | 47.0M | left[-1] = POS(-1, -1); | 171 | 47.0M | top[-1] = left[-1]; | 172 | 47.0M | } | 173 | 48.6M | if (cand_up) | 174 | 47.5M | memcpy(top, src - stride, size * sizeof(pixel)); | 175 | 48.6M | if (cand_up_right) { | 176 | 31.1M | memcpy(top + size, src - stride + size, size * sizeof(pixel)); | 177 | 31.1M | EXTEND(top + size + top_right_size, POS(size + top_right_size - 1, -1), | 178 | 31.1M | size - top_right_size); | 179 | 31.1M | } | 180 | 48.6M | if (cand_left) | 181 | 326M | for (i = 0; i < size; i++) | 182 | 278M | left[i] = POS(-1, i); | 183 | 48.6M | if (cand_bottom_left) { | 184 | 105M | for (i = size; i < size + bottom_left_size; i++) | 185 | 89.5M | left[i] = POS(-1, i); | 186 | 16.1M | EXTEND(left + size + bottom_left_size, POS(-1, size + bottom_left_size - 1), | 187 | 16.1M | size - bottom_left_size); | 188 | 16.1M | } | 189 | | | 190 | 48.6M | if (pps->constrained_intra_pred_flag == 1) { | 191 | 14.1M | if (cand_bottom_left || cand_left || cand_up_left || cand_up || cand_up_right) { | 192 | 14.0M | int size_max_x = x0 + ((2 * size) << hshift) < sps->width ? | 193 | 13.5M | 2 * size : (sps->width - x0) >> hshift; | 194 | 14.0M | int size_max_y = y0 + ((2 * size) << vshift) < sps->height ? | 195 | 13.2M | 2 * size : (sps->height - y0) >> vshift; | 196 | 14.0M | int j = size + (cand_bottom_left? bottom_left_size: 0) -1; | 197 | 14.0M | if (!cand_up_right) { | 198 | 5.21M | size_max_x = x0 + ((size) << hshift) < sps->width ? | 199 | 4.94M | size : (sps->width - x0) >> hshift; | 200 | 5.21M | } | 201 | 14.0M | if (!cand_bottom_left) { | 202 | 9.80M | size_max_y = y0 + (( size) << vshift) < sps->height ? | 203 | 9.34M | size : (sps->height - y0) >> vshift; | 204 | 9.80M | } | 205 | 14.0M | if (cand_bottom_left || cand_left || cand_up_left) { | 206 | 14.3M | while (j > -1 && !IS_INTRA(-1, j)) | 207 | 531k | j--; | 208 | 13.7M | if (!IS_INTRA(-1, j)) { | 209 | 0 | j = 0; | 210 | 0 | while (j < size_max_x && !IS_INTRA(j, -1)) | 211 | 0 | j++; | 212 | 0 | EXTEND_LEFT_CIP(top, j, j + 1); | 213 | 0 | left[-1] = top[-1]; | 214 | 0 | } | 215 | 13.7M | } else { | 216 | 288k | j = 0; | 217 | 381k | while (j < size_max_x && !IS_INTRA(j, -1)) | 218 | 93.1k | j++; | 219 | 288k | if (j > 0) { | 220 | 8.24k | EXTEND_LEFT_CIP(top, j, j); | 221 | 8.24k | top[-1] = top[0]; | 222 | 8.24k | } | 223 | 288k | left[-1] = top[-1]; | 224 | 288k | } | 225 | 14.0M | left[-1] = top[-1]; | 226 | 14.0M | if (cand_bottom_left || cand_left) { | 227 | 13.5M | a = PIXEL_SPLAT_X4(left[-1]); | 228 | 13.5M | EXTEND_DOWN_CIP(left, 0, size_max_y); | 229 | 13.5M | } | 230 | 14.0M | if (!cand_left) | 231 | 521k | EXTEND(left, left[-1], size); | 232 | 14.0M | if (!cand_bottom_left) | 233 | 9.80M | EXTEND(left + size, left[size - 1], size); | 234 | 14.0M | if (x0 != 0 && y0 != 0) { | 235 | 13.5M | a = PIXEL_SPLAT_X4(left[size_max_y - 1]); | 236 | 13.5M | EXTEND_UP_CIP(left, size_max_y - 1, size_max_y); | 237 | 13.5M | if (!IS_INTRA(-1, - 1)) | 238 | 255k | left[-1] = left[0]; | 239 | 13.5M | } else if (x0 == 0) { | 240 | 160k | EXTEND(left, 0, size_max_y); | 241 | 370k | } else { | 242 | 370k | a = PIXEL_SPLAT_X4(left[size_max_y - 1]); | 243 | 370k | EXTEND_UP_CIP(left, size_max_y - 1, size_max_y); | 244 | 370k | } | 245 | 14.0M | top[-1] = left[-1]; | 246 | 14.0M | if (y0 != 0) { | 247 | 13.7M | a = PIXEL_SPLAT_X4(left[-1]); | 248 | 13.7M | EXTEND_RIGHT_CIP(top, 0, size_max_x); | 249 | 13.7M | } | 250 | 14.0M | } | 251 | 14.1M | } | 252 | | // Infer the unavailable samples | 253 | 48.6M | if (!cand_bottom_left) { | 254 | 32.4M | if (cand_left) { | 255 | 31.7M | EXTEND(left + size, left[size - 1], size); | 256 | 31.7M | } else if (cand_up_left) { | 257 | 207k | EXTEND(left, left[-1], 2 * size); | 258 | 207k | cand_left = 1; | 259 | 563k | } else if (cand_up) { | 260 | 487k | left[-1] = top[0]; | 261 | 487k | EXTEND(left, left[-1], 2 * size); | 262 | 487k | cand_up_left = 1; | 263 | 487k | cand_left = 1; | 264 | 487k | } else if (cand_up_right) { | 265 | 7.99k | EXTEND(top, top[size], size); | 266 | 7.99k | left[-1] = top[size]; | 267 | 7.99k | EXTEND(left, left[-1], 2 * size); | 268 | 7.99k | cand_up = 1; | 269 | 7.99k | cand_up_left = 1; | 270 | 7.99k | cand_left = 1; | 271 | 67.7k | } else { // No samples available | 272 | 67.7k | left[-1] = (1 << (BIT_DEPTH - 1)); | 273 | 67.7k | EXTEND(top, left[-1], 2 * size); | 274 | 67.7k | EXTEND(left, left[-1], 2 * size); | 275 | 67.7k | } | 276 | 32.4M | } | 277 | | | 278 | 48.6M | if (!cand_left) | 279 | 93.2k | EXTEND(left, left[size], size); | 280 | 48.6M | if (!cand_up_left) { | 281 | 1.07M | left[-1] = left[0]; | 282 | 1.07M | } | 283 | 48.6M | if (!cand_up) | 284 | 1.12M | EXTEND(top, left[-1], size); | 285 | 48.6M | if (!cand_up_right) | 286 | 17.4M | EXTEND(top + size, top[size - 1], size); | 287 | | | 288 | 48.6M | top[-1] = left[-1]; | 289 | | | 290 | | // Filtering process | 291 | 48.6M | if (!sps->intra_smoothing_disabled && (c_idx == 0 || sps->chroma_format_idc == 3)) { | 292 | 40.6M | if (mode != INTRA_DC && size != 4){ | 293 | 11.0M | int intra_hor_ver_dist_thresh[] = { 7, 1, 0 }; | 294 | 11.0M | int min_dist_vert_hor = FFMIN(FFABS((int)(mode - 26U)), | 295 | 11.0M | FFABS((int)(mode - 10U))); | 296 | 11.0M | if (min_dist_vert_hor > intra_hor_ver_dist_thresh[log2_size - 3]) { | 297 | 8.30M | int threshold = 1 << (BIT_DEPTH - 5); | 298 | 8.30M | if (sps->strong_intra_smoothing_enabled && c_idx == 0 && | 299 | 2.32M | log2_size == 5 && | 300 | 82.2k | FFABS(top[-1] + top[63] - 2 * top[31]) < threshold && | 301 | 65.5k | 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 | 57.2k | filtered_top[-1] = top[-1]; | 305 | 57.2k | filtered_top[63] = top[63]; | 306 | 3.66M | for (i = 0; i < 63; i++) | 307 | 3.60M | filtered_top[i] = ((64 - (i + 1)) * top[-1] + | 308 | 3.60M | (i + 1) * top[63] + 32) >> 6; | 309 | 3.66M | for (i = 0; i < 63; i++) | 310 | 3.60M | left[i] = ((64 - (i + 1)) * left[-1] + | 311 | 3.60M | (i + 1) * left[63] + 32) >> 6; | 312 | 57.2k | top = filtered_top; | 313 | 8.24M | } else { | 314 | 8.24M | filtered_left[2 * size - 1] = left[2 * size - 1]; | 315 | 8.24M | filtered_top[2 * size - 1] = top[2 * size - 1]; | 316 | 171M | for (i = 2 * size - 2; i >= 0; i--) | 317 | 163M | filtered_left[i] = (left[i + 1] + 2 * left[i] + | 318 | 163M | left[i - 1] + 2) >> 2; | 319 | 8.24M | filtered_top[-1] = | 320 | 8.24M | filtered_left[-1] = (left[0] + 2 * left[-1] + top[0] + 2) >> 2; | 321 | 171M | for (i = 2 * size - 2; i >= 0; i--) | 322 | 163M | filtered_top[i] = (top[i + 1] + 2 * top[i] + | 323 | 163M | top[i - 1] + 2) >> 2; | 324 | 8.24M | left = filtered_left; | 325 | 8.24M | top = filtered_top; | 326 | 8.24M | } | 327 | 8.30M | } | 328 | 11.0M | } | 329 | 40.6M | } | 330 | | | 331 | 48.6M | switch (mode) { | 332 | 19.8M | case INTRA_PLANAR: | 333 | 19.8M | s->hpc.pred_planar[log2_size - 2]((uint8_t *)src, (uint8_t *)top, | 334 | 19.8M | (uint8_t *)left, stride); | 335 | 19.8M | break; | 336 | 9.62M | case INTRA_DC: | 337 | 9.62M | s->hpc.pred_dc((uint8_t *)src, (uint8_t *)top, | 338 | 9.62M | (uint8_t *)left, stride, log2_size, c_idx); | 339 | 9.62M | break; | 340 | 19.1M | default: | 341 | 19.1M | s->hpc.pred_angular[log2_size - 2]((uint8_t *)src, (uint8_t *)top, | 342 | 19.1M | (uint8_t *)left, stride, c_idx, | 343 | 19.1M | mode); | 344 | 19.1M | break; | 345 | 48.6M | } | 346 | 48.6M | } |
Line | Count | Source | 34 | 59.8M | { | 35 | 59.8M | #define PU(x) \ | 36 | 59.8M | ((x) >> sps->log2_min_pu_size) | 37 | 59.8M | #define MVF(x, y) \ | 38 | 59.8M | (s->cur_frame->tab_mvf[(x) + (y) * min_pu_width]) | 39 | 59.8M | #define MVF_PU(x, y) \ | 40 | 59.8M | MVF(PU(x0 + ((x) * (1 << hshift))), PU(y0 + ((y) * (1 << vshift)))) | 41 | 59.8M | #define IS_INTRA(x, y) \ | 42 | 59.8M | (MVF_PU(x, y).pred_flag == PF_INTRA) | 43 | 59.8M | #define MIN_TB_ADDR_ZS(x, y) \ | 44 | 59.8M | pps->min_tb_addr_zs[(y) * (sps->tb_mask+2) + (x)] | 45 | 59.8M | #define EXTEND(ptr, val, len) \ | 46 | 59.8M | do { \ | 47 | 59.8M | pixel4 pix = PIXEL_SPLAT_X4(val); \ | 48 | 59.8M | for (i = 0; i < (len); i += 4) \ | 49 | 59.8M | AV_WN4P(ptr + i, pix); \ | 50 | 59.8M | } while (0) | 51 | | | 52 | 59.8M | #define EXTEND_RIGHT_CIP(ptr, start, length) \ | 53 | 59.8M | for (i = start; i < (start) + (length); i += 4) \ | 54 | 59.8M | if (!IS_INTRA(i, -1)) \ | 55 | 59.8M | AV_WN4P(&ptr[i], a); \ | 56 | 59.8M | else \ | 57 | 59.8M | a = PIXEL_SPLAT_X4(ptr[i+3]) | 58 | 59.8M | #define EXTEND_LEFT_CIP(ptr, start, length) \ | 59 | 59.8M | for (i = start; i > (start) - (length); i--) \ | 60 | 59.8M | if (!IS_INTRA(i - 1, -1)) \ | 61 | 59.8M | ptr[i - 1] = ptr[i] | 62 | 59.8M | #define EXTEND_UP_CIP(ptr, start, length) \ | 63 | 59.8M | for (i = (start); i > (start) - (length); i -= 4) \ | 64 | 59.8M | if (!IS_INTRA(-1, i - 3)) \ | 65 | 59.8M | AV_WN4P(&ptr[i - 3], a); \ | 66 | 59.8M | else \ | 67 | 59.8M | a = PIXEL_SPLAT_X4(ptr[i - 3]) | 68 | 59.8M | #define EXTEND_DOWN_CIP(ptr, start, length) \ | 69 | 59.8M | for (i = start; i < (start) + (length); i += 4) \ | 70 | 59.8M | if (!IS_INTRA(-1, i)) \ | 71 | 59.8M | AV_WN4P(&ptr[i], a); \ | 72 | 59.8M | else \ | 73 | 59.8M | a = PIXEL_SPLAT_X4(ptr[i + 3]) | 74 | | | 75 | 59.8M | const HEVCSPS *const sps = pps->sps; | 76 | 59.8M | const HEVCContext *const s = lc->parent; | 77 | 59.8M | int i; | 78 | 59.8M | int hshift = sps->hshift[c_idx]; | 79 | 59.8M | int vshift = sps->vshift[c_idx]; | 80 | 59.8M | int size = (1 << log2_size); | 81 | 59.8M | int size_in_luma_h = size << hshift; | 82 | 59.8M | int size_in_tbs_h = size_in_luma_h >> sps->log2_min_tb_size; | 83 | 59.8M | int size_in_luma_v = size << vshift; | 84 | 59.8M | int size_in_tbs_v = size_in_luma_v >> sps->log2_min_tb_size; | 85 | 59.8M | int x = x0 >> hshift; | 86 | 59.8M | int y = y0 >> vshift; | 87 | 59.8M | int x_tb = (x0 >> sps->log2_min_tb_size) & sps->tb_mask; | 88 | 59.8M | int y_tb = (y0 >> sps->log2_min_tb_size) & sps->tb_mask; | 89 | 59.8M | int spin = c_idx && !size_in_tbs_v && ((2 * y0) & (1 << sps->log2_min_tb_size)); | 90 | | | 91 | 59.8M | int cur_tb_addr = MIN_TB_ADDR_ZS(x_tb, y_tb); | 92 | | | 93 | 59.8M | ptrdiff_t stride = s->cur_frame->f->linesize[c_idx] / sizeof(pixel); | 94 | 59.8M | pixel *src = (pixel*)s->cur_frame->f->data[c_idx] + x + y * stride; | 95 | | | 96 | 59.8M | int min_pu_width = sps->min_pu_width; | 97 | | | 98 | 59.8M | enum IntraPredMode mode = c_idx ? lc->tu.intra_pred_mode_c : | 99 | 59.8M | lc->tu.intra_pred_mode; | 100 | 59.8M | pixel4 a; | 101 | 59.8M | pixel left_array[2 * MAX_TB_SIZE + 1]; | 102 | 59.8M | pixel filtered_left_array[2 * MAX_TB_SIZE + 1]; | 103 | 59.8M | pixel top_array[2 * MAX_TB_SIZE + 1]; | 104 | 59.8M | pixel filtered_top_array[2 * MAX_TB_SIZE + 1]; | 105 | | | 106 | 59.8M | pixel *left = left_array + 1; | 107 | 59.8M | pixel *top = top_array + 1; | 108 | 59.8M | pixel *filtered_left = filtered_left_array + 1; | 109 | 59.8M | pixel *filtered_top = filtered_top_array + 1; | 110 | 59.8M | 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 | 59.8M | int cand_left = lc->na.cand_left; | 112 | 59.8M | int cand_up_left = lc->na.cand_up_left; | 113 | 59.8M | int cand_up = lc->na.cand_up; | 114 | 59.8M | 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 | 59.8M | int bottom_left_size = (FFMIN(y0 + 2 * size_in_luma_v, sps->height) - | 117 | 59.8M | (y0 + size_in_luma_v)) >> vshift; | 118 | 59.8M | int top_right_size = (FFMIN(x0 + 2 * size_in_luma_h, sps->width) - | 119 | 59.8M | (x0 + size_in_luma_h)) >> hshift; | 120 | | | 121 | 59.8M | if (pps->constrained_intra_pred_flag == 1) { | 122 | 17.1M | int size_in_luma_pu_v = PU(size_in_luma_v); | 123 | 17.1M | int size_in_luma_pu_h = PU(size_in_luma_h); | 124 | 17.1M | int on_pu_edge_x = !av_zero_extend(x0, sps->log2_min_pu_size); | 125 | 17.1M | int on_pu_edge_y = !av_zero_extend(y0, sps->log2_min_pu_size); | 126 | 17.1M | if (!size_in_luma_pu_h) | 127 | 783k | size_in_luma_pu_h++; | 128 | 17.1M | if (cand_bottom_left == 1 && on_pu_edge_x) { | 129 | 5.66M | int x_left_pu = PU(x0 - 1); | 130 | 5.66M | int y_bottom_pu = PU(y0 + size_in_luma_v); | 131 | 5.66M | int max = FFMIN(size_in_luma_pu_v, sps->min_pu_height - y_bottom_pu); | 132 | 5.66M | cand_bottom_left = 0; | 133 | 11.6M | for (i = 0; i < max; i += 2) | 134 | 6.03M | cand_bottom_left |= (MVF(x_left_pu, y_bottom_pu + i).pred_flag == PF_INTRA); | 135 | 5.66M | } | 136 | 17.1M | if (cand_left == 1 && on_pu_edge_x) { | 137 | 16.3M | int x_left_pu = PU(x0 - 1); | 138 | 16.3M | int y_left_pu = PU(y0); | 139 | 16.3M | int max = FFMIN(size_in_luma_pu_v, sps->min_pu_height - y_left_pu); | 140 | 16.3M | cand_left = 0; | 141 | 34.7M | for (i = 0; i < max; i += 2) | 142 | 18.3M | cand_left |= (MVF(x_left_pu, y_left_pu + i).pred_flag == PF_INTRA); | 143 | 16.3M | } | 144 | 17.1M | if (cand_up_left == 1) { | 145 | 16.4M | int x_left_pu = PU(x0 - 1); | 146 | 16.4M | int y_top_pu = PU(y0 - 1); | 147 | 16.4M | cand_up_left = MVF(x_left_pu, y_top_pu).pred_flag == PF_INTRA; | 148 | 16.4M | } | 149 | 17.1M | if (cand_up == 1 && on_pu_edge_y) { | 150 | 16.1M | int x_top_pu = PU(x0); | 151 | 16.1M | int y_top_pu = PU(y0 - 1); | 152 | 16.1M | int max = FFMIN(size_in_luma_pu_h, sps->min_pu_width - x_top_pu); | 153 | 16.1M | cand_up = 0; | 154 | 34.8M | for (i = 0; i < max; i += 2) | 155 | 18.6M | cand_up |= (MVF(x_top_pu + i, y_top_pu).pred_flag == PF_INTRA); | 156 | 16.1M | } | 157 | 17.1M | if (cand_up_right == 1 && on_pu_edge_y) { | 158 | 10.4M | int y_top_pu = PU(y0 - 1); | 159 | 10.4M | int x_right_pu = PU(x0 + size_in_luma_h); | 160 | 10.4M | int max = FFMIN(size_in_luma_pu_h, sps->min_pu_width - x_right_pu); | 161 | 10.4M | cand_up_right = 0; | 162 | 22.5M | for (i = 0; i < max; i += 2) | 163 | 12.0M | cand_up_right |= (MVF(x_right_pu + i, y_top_pu).pred_flag == PF_INTRA); | 164 | 10.4M | } | 165 | 17.1M | memset(left, 128, 2 * MAX_TB_SIZE*sizeof(pixel)); | 166 | 17.1M | memset(top , 128, 2 * MAX_TB_SIZE*sizeof(pixel)); | 167 | 17.1M | top[-1] = 128; | 168 | 17.1M | } | 169 | 59.8M | if (cand_up_left) { | 170 | 57.6M | left[-1] = POS(-1, -1); | 171 | 57.6M | top[-1] = left[-1]; | 172 | 57.6M | } | 173 | 59.8M | if (cand_up) | 174 | 58.3M | memcpy(top, src - stride, size * sizeof(pixel)); | 175 | 59.8M | if (cand_up_right) { | 176 | 37.3M | memcpy(top + size, src - stride + size, size * sizeof(pixel)); | 177 | 37.3M | EXTEND(top + size + top_right_size, POS(size + top_right_size - 1, -1), | 178 | 37.3M | size - top_right_size); | 179 | 37.3M | } | 180 | 59.8M | if (cand_left) | 181 | 375M | for (i = 0; i < size; i++) | 182 | 316M | left[i] = POS(-1, i); | 183 | 59.8M | if (cand_bottom_left) { | 184 | 125M | for (i = size; i < size + bottom_left_size; i++) | 185 | 105M | left[i] = POS(-1, i); | 186 | 20.2M | EXTEND(left + size + bottom_left_size, POS(-1, size + bottom_left_size - 1), | 187 | 20.2M | size - bottom_left_size); | 188 | 20.2M | } | 189 | | | 190 | 59.8M | if (pps->constrained_intra_pred_flag == 1) { | 191 | 17.1M | if (cand_bottom_left || cand_left || cand_up_left || cand_up || cand_up_right) { | 192 | 17.0M | int size_max_x = x0 + ((2 * size) << hshift) < sps->width ? | 193 | 16.4M | 2 * size : (sps->width - x0) >> hshift; | 194 | 17.0M | int size_max_y = y0 + ((2 * size) << vshift) < sps->height ? | 195 | 15.6M | 2 * size : (sps->height - y0) >> vshift; | 196 | 17.0M | int j = size + (cand_bottom_left? bottom_left_size: 0) -1; | 197 | 17.0M | if (!cand_up_right) { | 198 | 6.43M | size_max_x = x0 + ((size) << hshift) < sps->width ? | 199 | 6.11M | size : (sps->width - x0) >> hshift; | 200 | 6.43M | } | 201 | 17.0M | if (!cand_bottom_left) { | 202 | 11.6M | size_max_y = y0 + (( size) << vshift) < sps->height ? | 203 | 10.8M | size : (sps->height - y0) >> vshift; | 204 | 11.6M | } | 205 | 17.0M | if (cand_bottom_left || cand_left || cand_up_left) { | 206 | 17.0M | while (j > -1 && !IS_INTRA(-1, j)) | 207 | 244k | j--; | 208 | 16.7M | if (!IS_INTRA(-1, j)) { | 209 | 0 | j = 0; | 210 | 0 | while (j < size_max_x && !IS_INTRA(j, -1)) | 211 | 0 | j++; | 212 | 0 | EXTEND_LEFT_CIP(top, j, j + 1); | 213 | 0 | left[-1] = top[-1]; | 214 | 0 | } | 215 | 16.7M | } else { | 216 | 278k | j = 0; | 217 | 351k | while (j < size_max_x && !IS_INTRA(j, -1)) | 218 | 72.7k | j++; | 219 | 278k | if (j > 0) { | 220 | 8.36k | EXTEND_LEFT_CIP(top, j, j); | 221 | 8.36k | top[-1] = top[0]; | 222 | 8.36k | } | 223 | 278k | left[-1] = top[-1]; | 224 | 278k | } | 225 | 17.0M | left[-1] = top[-1]; | 226 | 17.0M | if (cand_bottom_left || cand_left) { | 227 | 16.4M | a = PIXEL_SPLAT_X4(left[-1]); | 228 | 16.4M | EXTEND_DOWN_CIP(left, 0, size_max_y); | 229 | 16.4M | } | 230 | 17.0M | if (!cand_left) | 231 | 656k | EXTEND(left, left[-1], size); | 232 | 17.0M | if (!cand_bottom_left) | 233 | 11.6M | EXTEND(left + size, left[size - 1], size); | 234 | 17.0M | if (x0 != 0 && y0 != 0) { | 235 | 16.4M | a = PIXEL_SPLAT_X4(left[size_max_y - 1]); | 236 | 16.4M | EXTEND_UP_CIP(left, size_max_y - 1, size_max_y); | 237 | 16.4M | if (!IS_INTRA(-1, - 1)) | 238 | 104k | left[-1] = left[0]; | 239 | 16.4M | } else if (x0 == 0) { | 240 | 226k | EXTEND(left, 0, size_max_y); | 241 | 362k | } else { | 242 | 362k | a = PIXEL_SPLAT_X4(left[size_max_y - 1]); | 243 | 362k | EXTEND_UP_CIP(left, size_max_y - 1, size_max_y); | 244 | 362k | } | 245 | 17.0M | top[-1] = left[-1]; | 246 | 17.0M | if (y0 != 0) { | 247 | 16.6M | a = PIXEL_SPLAT_X4(left[-1]); | 248 | 16.6M | EXTEND_RIGHT_CIP(top, 0, size_max_x); | 249 | 16.6M | } | 250 | 17.0M | } | 251 | 17.1M | } | 252 | | // Infer the unavailable samples | 253 | 59.8M | if (!cand_bottom_left) { | 254 | 39.5M | if (cand_left) { | 255 | 38.3M | EXTEND(left + size, left[size - 1], size); | 256 | 38.3M | } else if (cand_up_left) { | 257 | 370k | EXTEND(left, left[-1], 2 * size); | 258 | 370k | cand_left = 1; | 259 | 839k | } else if (cand_up) { | 260 | 733k | left[-1] = top[0]; | 261 | 733k | EXTEND(left, left[-1], 2 * size); | 262 | 733k | cand_up_left = 1; | 263 | 733k | cand_left = 1; | 264 | 733k | } else if (cand_up_right) { | 265 | 7.23k | EXTEND(top, top[size], size); | 266 | 7.23k | left[-1] = top[size]; | 267 | 7.23k | EXTEND(left, left[-1], 2 * size); | 268 | 7.23k | cand_up = 1; | 269 | 7.23k | cand_up_left = 1; | 270 | 7.23k | cand_left = 1; | 271 | 98.8k | } else { // No samples available | 272 | 98.8k | left[-1] = (1 << (BIT_DEPTH - 1)); | 273 | 98.8k | EXTEND(top, left[-1], 2 * size); | 274 | 98.8k | EXTEND(left, left[-1], 2 * size); | 275 | 98.8k | } | 276 | 39.5M | } | 277 | | | 278 | 59.8M | if (!cand_left) | 279 | 105k | EXTEND(left, left[size], size); | 280 | 59.8M | if (!cand_up_left) { | 281 | 1.51M | left[-1] = left[0]; | 282 | 1.51M | } | 283 | 59.8M | if (!cand_up) | 284 | 1.52M | EXTEND(top, left[-1], size); | 285 | 59.8M | if (!cand_up_right) | 286 | 22.4M | EXTEND(top + size, top[size - 1], size); | 287 | | | 288 | 59.8M | top[-1] = left[-1]; | 289 | | | 290 | | // Filtering process | 291 | 59.8M | if (!sps->intra_smoothing_disabled && (c_idx == 0 || sps->chroma_format_idc == 3)) { | 292 | 28.1M | if (mode != INTRA_DC && size != 4){ | 293 | 8.92M | int intra_hor_ver_dist_thresh[] = { 7, 1, 0 }; | 294 | 8.92M | int min_dist_vert_hor = FFMIN(FFABS((int)(mode - 26U)), | 295 | 8.92M | FFABS((int)(mode - 10U))); | 296 | 8.92M | if (min_dist_vert_hor > intra_hor_ver_dist_thresh[log2_size - 3]) { | 297 | 6.70M | int threshold = 1 << (BIT_DEPTH - 5); | 298 | 6.70M | if (sps->strong_intra_smoothing_enabled && c_idx == 0 && | 299 | 4.85M | log2_size == 5 && | 300 | 316k | FFABS(top[-1] + top[63] - 2 * top[31]) < threshold && | 301 | 225k | 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 | 180k | filtered_top[-1] = top[-1]; | 305 | 180k | filtered_top[63] = top[63]; | 306 | 11.5M | for (i = 0; i < 63; i++) | 307 | 11.4M | filtered_top[i] = ((64 - (i + 1)) * top[-1] + | 308 | 11.4M | (i + 1) * top[63] + 32) >> 6; | 309 | 11.5M | for (i = 0; i < 63; i++) | 310 | 11.4M | left[i] = ((64 - (i + 1)) * left[-1] + | 311 | 11.4M | (i + 1) * left[63] + 32) >> 6; | 312 | 180k | top = filtered_top; | 313 | 6.52M | } else { | 314 | 6.52M | filtered_left[2 * size - 1] = left[2 * size - 1]; | 315 | 6.52M | filtered_top[2 * size - 1] = top[2 * size - 1]; | 316 | 127M | for (i = 2 * size - 2; i >= 0; i--) | 317 | 121M | filtered_left[i] = (left[i + 1] + 2 * left[i] + | 318 | 121M | left[i - 1] + 2) >> 2; | 319 | 6.52M | filtered_top[-1] = | 320 | 6.52M | filtered_left[-1] = (left[0] + 2 * left[-1] + top[0] + 2) >> 2; | 321 | 127M | for (i = 2 * size - 2; i >= 0; i--) | 322 | 121M | filtered_top[i] = (top[i + 1] + 2 * top[i] + | 323 | 121M | top[i - 1] + 2) >> 2; | 324 | 6.52M | left = filtered_left; | 325 | 6.52M | top = filtered_top; | 326 | 6.52M | } | 327 | 6.70M | } | 328 | 8.92M | } | 329 | 28.1M | } | 330 | | | 331 | 59.8M | switch (mode) { | 332 | 26.0M | case INTRA_PLANAR: | 333 | 26.0M | s->hpc.pred_planar[log2_size - 2]((uint8_t *)src, (uint8_t *)top, | 334 | 26.0M | (uint8_t *)left, stride); | 335 | 26.0M | break; | 336 | 10.2M | case INTRA_DC: | 337 | 10.2M | s->hpc.pred_dc((uint8_t *)src, (uint8_t *)top, | 338 | 10.2M | (uint8_t *)left, stride, log2_size, c_idx); | 339 | 10.2M | break; | 340 | 23.5M | default: | 341 | 23.5M | s->hpc.pred_angular[log2_size - 2]((uint8_t *)src, (uint8_t *)top, | 342 | 23.5M | (uint8_t *)left, stride, c_idx, | 343 | 23.5M | mode); | 344 | 23.5M | break; | 345 | 59.8M | } | 346 | 59.8M | } |
|
347 | | |
348 | | #define INTRA_PRED(size) \ |
349 | | static void FUNC(intra_pred_ ## size)(HEVCLocalContext *lc, const HEVCPPS *pps, \ |
350 | 243M | int x0, int y0, int c_idx) \ |
351 | 243M | { \ |
352 | 243M | FUNC(intra_pred)(lc, pps, x0, y0, size, c_idx); \ |
353 | 243M | } Line | Count | Source | 350 | 45.7M | int x0, int y0, int c_idx) \ | 351 | 45.7M | { \ | 352 | 45.7M | FUNC(intra_pred)(lc, pps, x0, y0, size, c_idx); \ | 353 | 45.7M | } |
Line | Count | Source | 350 | 10.5M | int x0, int y0, int c_idx) \ | 351 | 10.5M | { \ | 352 | 10.5M | FUNC(intra_pred)(lc, pps, x0, y0, size, c_idx); \ | 353 | 10.5M | } |
Line | Count | Source | 350 | 2.71M | int x0, int y0, int c_idx) \ | 351 | 2.71M | { \ | 352 | 2.71M | FUNC(intra_pred)(lc, pps, x0, y0, size, c_idx); \ | 353 | 2.71M | } |
Line | Count | Source | 350 | 376k | int x0, int y0, int c_idx) \ | 351 | 376k | { \ | 352 | 376k | FUNC(intra_pred)(lc, pps, x0, y0, size, c_idx); \ | 353 | 376k | } |
Line | Count | Source | 350 | 62.0M | int x0, int y0, int c_idx) \ | 351 | 62.0M | { \ | 352 | 62.0M | FUNC(intra_pred)(lc, pps, x0, y0, size, c_idx); \ | 353 | 62.0M | } |
Line | Count | Source | 350 | 10.6M | int x0, int y0, int c_idx) \ | 351 | 10.6M | { \ | 352 | 10.6M | FUNC(intra_pred)(lc, pps, x0, y0, size, c_idx); \ | 353 | 10.6M | } |
Line | Count | Source | 350 | 2.16M | int x0, int y0, int c_idx) \ | 351 | 2.16M | { \ | 352 | 2.16M | FUNC(intra_pred)(lc, pps, x0, y0, size, c_idx); \ | 353 | 2.16M | } |
Line | Count | Source | 350 | 444k | int x0, int y0, int c_idx) \ | 351 | 444k | { \ | 352 | 444k | FUNC(intra_pred)(lc, pps, x0, y0, size, c_idx); \ | 353 | 444k | } |
Line | Count | Source | 350 | 33.2M | int x0, int y0, int c_idx) \ | 351 | 33.2M | { \ | 352 | 33.2M | FUNC(intra_pred)(lc, pps, x0, y0, size, c_idx); \ | 353 | 33.2M | } |
Line | Count | Source | 350 | 12.6M | int x0, int y0, int c_idx) \ | 351 | 12.6M | { \ | 352 | 12.6M | FUNC(intra_pred)(lc, pps, x0, y0, size, c_idx); \ | 353 | 12.6M | } |
Line | Count | Source | 350 | 2.06M | int x0, int y0, int c_idx) \ | 351 | 2.06M | { \ | 352 | 2.06M | FUNC(intra_pred)(lc, pps, x0, y0, size, c_idx); \ | 353 | 2.06M | } |
Line | Count | Source | 350 | 599k | int x0, int y0, int c_idx) \ | 351 | 599k | { \ | 352 | 599k | FUNC(intra_pred)(lc, pps, x0, y0, size, c_idx); \ | 353 | 599k | } |
Line | Count | Source | 350 | 45.5M | int x0, int y0, int c_idx) \ | 351 | 45.5M | { \ | 352 | 45.5M | FUNC(intra_pred)(lc, pps, x0, y0, size, c_idx); \ | 353 | 45.5M | } |
Line | Count | Source | 350 | 11.4M | int x0, int y0, int c_idx) \ | 351 | 11.4M | { \ | 352 | 11.4M | FUNC(intra_pred)(lc, pps, x0, y0, size, c_idx); \ | 353 | 11.4M | } |
Line | Count | Source | 350 | 2.29M | int x0, int y0, int c_idx) \ | 351 | 2.29M | { \ | 352 | 2.29M | FUNC(intra_pred)(lc, pps, x0, y0, size, c_idx); \ | 353 | 2.29M | } |
Line | Count | Source | 350 | 537k | int x0, int y0, int c_idx) \ | 351 | 537k | { \ | 352 | 537k | FUNC(intra_pred)(lc, pps, x0, y0, size, c_idx); \ | 353 | 537k | } |
|
354 | | |
355 | | INTRA_PRED(2) |
356 | | INTRA_PRED(3) |
357 | | INTRA_PRED(4) |
358 | | INTRA_PRED(5) |
359 | | |
360 | | #undef INTRA_PRED |
361 | | |
362 | | 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 | 102M | { |
366 | 102M | int x, y; |
367 | 102M | pixel *src = (pixel *)_src; |
368 | 102M | const pixel *top = (const pixel *)_top; |
369 | 102M | const pixel *left = (const pixel *)_left; |
370 | 102M | int size = 1 << trafo_size; |
371 | 678M | for (y = 0; y < size; y++) |
372 | 5.22G | for (x = 0; x < size; x++) |
373 | 4.64G | POS(x, y) = ((size - 1 - x) * left[y] + (x + 1) * top[size] + |
374 | 4.64G | (size - 1 - y) * top[x] + (y + 1) * left[size] + size) >> (trafo_size + 1); |
375 | 102M | } Line | Count | Source | 365 | 26.2M | { | 366 | 26.2M | int x, y; | 367 | 26.2M | pixel *src = (pixel *)_src; | 368 | 26.2M | const pixel *top = (const pixel *)_top; | 369 | 26.2M | const pixel *left = (const pixel *)_left; | 370 | 26.2M | int size = 1 << trafo_size; | 371 | 175M | for (y = 0; y < size; y++) | 372 | 1.37G | for (x = 0; x < size; x++) | 373 | 1.22G | POS(x, y) = ((size - 1 - x) * left[y] + (x + 1) * top[size] + | 374 | 1.22G | (size - 1 - y) * top[x] + (y + 1) * left[size] + size) >> (trafo_size + 1); | 375 | 26.2M | } |
Line | Count | Source | 365 | 30.8M | { | 366 | 30.8M | int x, y; | 367 | 30.8M | pixel *src = (pixel *)_src; | 368 | 30.8M | const pixel *top = (const pixel *)_top; | 369 | 30.8M | const pixel *left = (const pixel *)_left; | 370 | 30.8M | int size = 1 << trafo_size; | 371 | 193M | for (y = 0; y < size; y++) | 372 | 1.39G | for (x = 0; x < size; x++) | 373 | 1.22G | POS(x, y) = ((size - 1 - x) * left[y] + (x + 1) * top[size] + | 374 | 1.22G | (size - 1 - y) * top[x] + (y + 1) * left[size] + size) >> (trafo_size + 1); | 375 | 30.8M | } |
Line | Count | Source | 365 | 19.8M | { | 366 | 19.8M | int x, y; | 367 | 19.8M | pixel *src = (pixel *)_src; | 368 | 19.8M | const pixel *top = (const pixel *)_top; | 369 | 19.8M | const pixel *left = (const pixel *)_left; | 370 | 19.8M | int size = 1 << trafo_size; | 371 | 136M | for (y = 0; y < size; y++) | 372 | 1.10G | for (x = 0; x < size; x++) | 373 | 989M | POS(x, y) = ((size - 1 - x) * left[y] + (x + 1) * top[size] + | 374 | 989M | (size - 1 - y) * top[x] + (y + 1) * left[size] + size) >> (trafo_size + 1); | 375 | 19.8M | } |
Line | Count | Source | 365 | 26.0M | { | 366 | 26.0M | int x, y; | 367 | 26.0M | pixel *src = (pixel *)_src; | 368 | 26.0M | const pixel *top = (const pixel *)_top; | 369 | 26.0M | const pixel *left = (const pixel *)_left; | 370 | 26.0M | int size = 1 << trafo_size; | 371 | 172M | for (y = 0; y < size; y++) | 372 | 1.34G | for (x = 0; x < size; x++) | 373 | 1.19G | POS(x, y) = ((size - 1 - x) * left[y] + (x + 1) * top[size] + | 374 | 1.19G | (size - 1 - y) * top[x] + (y + 1) * left[size] + size) >> (trafo_size + 1); | 375 | 26.0M | } |
|
376 | | |
377 | | #define PRED_PLANAR(size)\ |
378 | | static void FUNC(pred_planar_ ## size)(uint8_t *src, const uint8_t *top, \ |
379 | 102M | const uint8_t *left, ptrdiff_t stride) \ |
380 | 102M | { \ |
381 | 102M | FUNC(pred_planar)(src, top, left, stride, size + 2); \ |
382 | 102M | } Line | Count | Source | 379 | 19.2M | const uint8_t *left, ptrdiff_t stride) \ | 380 | 19.2M | { \ | 381 | 19.2M | FUNC(pred_planar)(src, top, left, stride, size + 2); \ | 382 | 19.2M | } |
Line | Count | Source | 379 | 5.21M | const uint8_t *left, ptrdiff_t stride) \ | 380 | 5.21M | { \ | 381 | 5.21M | FUNC(pred_planar)(src, top, left, stride, size + 2); \ | 382 | 5.21M | } |
Line | Count | Source | 379 | 1.50M | const uint8_t *left, ptrdiff_t stride) \ | 380 | 1.50M | { \ | 381 | 1.50M | FUNC(pred_planar)(src, top, left, stride, size + 2); \ | 382 | 1.50M | } |
Line | Count | Source | 379 | 197k | const uint8_t *left, ptrdiff_t stride) \ | 380 | 197k | { \ | 381 | 197k | FUNC(pred_planar)(src, top, left, stride, size + 2); \ | 382 | 197k | } |
Line | Count | Source | 379 | 24.3M | const uint8_t *left, ptrdiff_t stride) \ | 380 | 24.3M | { \ | 381 | 24.3M | FUNC(pred_planar)(src, top, left, stride, size + 2); \ | 382 | 24.3M | } |
Line | Count | Source | 379 | 5.13M | const uint8_t *left, ptrdiff_t stride) \ | 380 | 5.13M | { \ | 381 | 5.13M | FUNC(pred_planar)(src, top, left, stride, size + 2); \ | 382 | 5.13M | } |
Line | Count | Source | 379 | 1.05M | const uint8_t *left, ptrdiff_t stride) \ | 380 | 1.05M | { \ | 381 | 1.05M | FUNC(pred_planar)(src, top, left, stride, size + 2); \ | 382 | 1.05M | } |
Line | Count | Source | 379 | 233k | const uint8_t *left, ptrdiff_t stride) \ | 380 | 233k | { \ | 381 | 233k | FUNC(pred_planar)(src, top, left, stride, size + 2); \ | 382 | 233k | } |
Line | Count | Source | 379 | 13.1M | const uint8_t *left, ptrdiff_t stride) \ | 380 | 13.1M | { \ | 381 | 13.1M | FUNC(pred_planar)(src, top, left, stride, size + 2); \ | 382 | 13.1M | } |
Line | Count | Source | 379 | 5.73M | const uint8_t *left, ptrdiff_t stride) \ | 380 | 5.73M | { \ | 381 | 5.73M | FUNC(pred_planar)(src, top, left, stride, size + 2); \ | 382 | 5.73M | } |
Line | Count | Source | 379 | 652k | const uint8_t *left, ptrdiff_t stride) \ | 380 | 652k | { \ | 381 | 652k | FUNC(pred_planar)(src, top, left, stride, size + 2); \ | 382 | 652k | } |
Line | Count | Source | 379 | 239k | const uint8_t *left, ptrdiff_t stride) \ | 380 | 239k | { \ | 381 | 239k | FUNC(pred_planar)(src, top, left, stride, size + 2); \ | 382 | 239k | } |
Line | Count | Source | 379 | 19.1M | const uint8_t *left, ptrdiff_t stride) \ | 380 | 19.1M | { \ | 381 | 19.1M | FUNC(pred_planar)(src, top, left, stride, size + 2); \ | 382 | 19.1M | } |
Line | Count | Source | 379 | 5.62M | const uint8_t *left, ptrdiff_t stride) \ | 380 | 5.62M | { \ | 381 | 5.62M | FUNC(pred_planar)(src, top, left, stride, size + 2); \ | 382 | 5.62M | } |
Line | Count | Source | 379 | 1.02M | const uint8_t *left, ptrdiff_t stride) \ | 380 | 1.02M | { \ | 381 | 1.02M | FUNC(pred_planar)(src, top, left, stride, size + 2); \ | 382 | 1.02M | } |
Line | Count | Source | 379 | 265k | const uint8_t *left, ptrdiff_t stride) \ | 380 | 265k | { \ | 381 | 265k | FUNC(pred_planar)(src, top, left, stride, size + 2); \ | 382 | 265k | } |
|
383 | | |
384 | | PRED_PLANAR(0) |
385 | | PRED_PLANAR(1) |
386 | | PRED_PLANAR(2) |
387 | | PRED_PLANAR(3) |
388 | | |
389 | | #undef PRED_PLANAR |
390 | | |
391 | | 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 | 44.0M | { |
395 | 44.0M | int i, j, x, y; |
396 | 44.0M | int size = (1 << log2_size); |
397 | 44.0M | pixel *src = (pixel *)_src; |
398 | 44.0M | const pixel *top = (const pixel *)_top; |
399 | 44.0M | const pixel *left = (const pixel *)_left; |
400 | 44.0M | int dc = size; |
401 | 44.0M | pixel4 a; |
402 | 279M | for (i = 0; i < size; i++) |
403 | 235M | dc += left[i] + top[i]; |
404 | | |
405 | 44.0M | dc >>= log2_size + 1; |
406 | | |
407 | 44.0M | a = PIXEL_SPLAT_X4(dc); |
408 | | |
409 | 279M | for (i = 0; i < size; i++) |
410 | 659M | for (j = 0; j < size; j+=4) |
411 | 424M | AV_WN4P(&POS(j, i), a); |
412 | | |
413 | 44.0M | if (c_idx == 0 && size < 32) { |
414 | 15.9M | POS(0, 0) = (left[0] + 2 * dc + top[0] + 2) >> 2; |
415 | 96.2M | for (x = 1; x < size; x++) |
416 | 80.2M | POS(x, 0) = (top[x] + 3 * dc + 2) >> 2; |
417 | 96.2M | for (y = 1; y < size; y++) |
418 | 80.2M | POS(0, y) = (left[y] + 3 * dc + 2) >> 2; |
419 | 15.9M | } |
420 | 44.0M | } Line | Count | Source | 394 | 11.3M | { | 395 | 11.3M | int i, j, x, y; | 396 | 11.3M | int size = (1 << log2_size); | 397 | 11.3M | pixel *src = (pixel *)_src; | 398 | 11.3M | const pixel *top = (const pixel *)_top; | 399 | 11.3M | const pixel *left = (const pixel *)_left; | 400 | 11.3M | int dc = size; | 401 | 11.3M | pixel4 a; | 402 | 71.0M | for (i = 0; i < size; i++) | 403 | 59.7M | dc += left[i] + top[i]; | 404 | | | 405 | 11.3M | dc >>= log2_size + 1; | 406 | | | 407 | 11.3M | a = PIXEL_SPLAT_X4(dc); | 408 | | | 409 | 71.0M | for (i = 0; i < size; i++) | 410 | 165M | for (j = 0; j < size; j+=4) | 411 | 105M | AV_WN4P(&POS(j, i), a); | 412 | | | 413 | 11.3M | if (c_idx == 0 && size < 32) { | 414 | 3.53M | POS(0, 0) = (left[0] + 2 * dc + top[0] + 2) >> 2; | 415 | 22.6M | for (x = 1; x < size; x++) | 416 | 19.0M | POS(x, 0) = (top[x] + 3 * dc + 2) >> 2; | 417 | 22.6M | for (y = 1; y < size; y++) | 418 | 19.0M | POS(0, y) = (left[y] + 3 * dc + 2) >> 2; | 419 | 3.53M | } | 420 | 11.3M | } |
Line | Count | Source | 394 | 12.7M | { | 395 | 12.7M | int i, j, x, y; | 396 | 12.7M | int size = (1 << log2_size); | 397 | 12.7M | pixel *src = (pixel *)_src; | 398 | 12.7M | const pixel *top = (const pixel *)_top; | 399 | 12.7M | const pixel *left = (const pixel *)_left; | 400 | 12.7M | int dc = size; | 401 | 12.7M | pixel4 a; | 402 | 78.1M | for (i = 0; i < size; i++) | 403 | 65.3M | dc += left[i] + top[i]; | 404 | | | 405 | 12.7M | dc >>= log2_size + 1; | 406 | | | 407 | 12.7M | a = PIXEL_SPLAT_X4(dc); | 408 | | | 409 | 78.1M | for (i = 0; i < size; i++) | 410 | 175M | for (j = 0; j < size; j+=4) | 411 | 110M | AV_WN4P(&POS(j, i), a); | 412 | | | 413 | 12.7M | if (c_idx == 0 && size < 32) { | 414 | 4.81M | POS(0, 0) = (left[0] + 2 * dc + top[0] + 2) >> 2; | 415 | 28.1M | for (x = 1; x < size; x++) | 416 | 23.3M | POS(x, 0) = (top[x] + 3 * dc + 2) >> 2; | 417 | 28.1M | for (y = 1; y < size; y++) | 418 | 23.3M | POS(0, y) = (left[y] + 3 * dc + 2) >> 2; | 419 | 4.81M | } | 420 | 12.7M | } |
Line | Count | Source | 394 | 9.62M | { | 395 | 9.62M | int i, j, x, y; | 396 | 9.62M | int size = (1 << log2_size); | 397 | 9.62M | pixel *src = (pixel *)_src; | 398 | 9.62M | const pixel *top = (const pixel *)_top; | 399 | 9.62M | const pixel *left = (const pixel *)_left; | 400 | 9.62M | int dc = size; | 401 | 9.62M | pixel4 a; | 402 | 64.2M | for (i = 0; i < size; i++) | 403 | 54.6M | dc += left[i] + top[i]; | 404 | | | 405 | 9.62M | dc >>= log2_size + 1; | 406 | | | 407 | 9.62M | a = PIXEL_SPLAT_X4(dc); | 408 | | | 409 | 64.2M | for (i = 0; i < size; i++) | 410 | 158M | for (j = 0; j < size; j+=4) | 411 | 104M | AV_WN4P(&POS(j, i), a); | 412 | | | 413 | 9.62M | if (c_idx == 0 && size < 32) { | 414 | 3.34M | POS(0, 0) = (left[0] + 2 * dc + top[0] + 2) >> 2; | 415 | 18.9M | for (x = 1; x < size; x++) | 416 | 15.6M | POS(x, 0) = (top[x] + 3 * dc + 2) >> 2; | 417 | 18.9M | for (y = 1; y < size; y++) | 418 | 15.6M | POS(0, y) = (left[y] + 3 * dc + 2) >> 2; | 419 | 3.34M | } | 420 | 9.62M | } |
Line | Count | Source | 394 | 10.2M | { | 395 | 10.2M | int i, j, x, y; | 396 | 10.2M | int size = (1 << log2_size); | 397 | 10.2M | pixel *src = (pixel *)_src; | 398 | 10.2M | const pixel *top = (const pixel *)_top; | 399 | 10.2M | const pixel *left = (const pixel *)_left; | 400 | 10.2M | int dc = size; | 401 | 10.2M | pixel4 a; | 402 | 66.1M | for (i = 0; i < size; i++) | 403 | 55.8M | dc += left[i] + top[i]; | 404 | | | 405 | 10.2M | dc >>= log2_size + 1; | 406 | | | 407 | 10.2M | a = PIXEL_SPLAT_X4(dc); | 408 | | | 409 | 66.1M | for (i = 0; i < size; i++) | 410 | 159M | for (j = 0; j < size; j+=4) | 411 | 104M | AV_WN4P(&POS(j, i), a); | 412 | | | 413 | 10.2M | if (c_idx == 0 && size < 32) { | 414 | 4.25M | POS(0, 0) = (left[0] + 2 * dc + top[0] + 2) >> 2; | 415 | 26.4M | for (x = 1; x < size; x++) | 416 | 22.2M | POS(x, 0) = (top[x] + 3 * dc + 2) >> 2; | 417 | 26.4M | for (y = 1; y < size; y++) | 418 | 22.2M | POS(0, y) = (left[y] + 3 * dc + 2) >> 2; | 419 | 4.25M | } | 420 | 10.2M | } |
|
421 | | |
422 | | 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 | 96.3M | { |
428 | 96.3M | int x, y; |
429 | 96.3M | pixel *src = (pixel *)_src; |
430 | 96.3M | const pixel *top = (const pixel *)_top; |
431 | 96.3M | const pixel *left = (const pixel *)_left; |
432 | | |
433 | 96.3M | static const int intra_pred_angle[] = { |
434 | 96.3M | 32, 26, 21, 17, 13, 9, 5, 2, 0, -2, -5, -9, -13, -17, -21, -26, -32, |
435 | 96.3M | -26, -21, -17, -13, -9, -5, -2, 0, 2, 5, 9, 13, 17, 21, 26, 32 |
436 | 96.3M | }; |
437 | 96.3M | static const int inv_angle[] = { |
438 | 96.3M | -4096, -1638, -910, -630, -482, -390, -315, -256, -315, -390, -482, |
439 | 96.3M | -630, -910, -1638, -4096 |
440 | 96.3M | }; |
441 | | |
442 | 96.3M | int angle = intra_pred_angle[mode - 2]; |
443 | 96.3M | pixel ref_array[3 * MAX_TB_SIZE + 4]; |
444 | 96.3M | pixel *ref_tmp = ref_array + size; |
445 | 96.3M | const pixel *ref; |
446 | 96.3M | int last = (size * angle) >> 5; |
447 | | |
448 | 96.3M | if (mode >= 18) { |
449 | 49.5M | ref = top - 1; |
450 | 49.5M | if (angle < 0 && last < -1) { |
451 | 32.2M | for (x = 0; x <= size; x += 4) |
452 | 22.7M | AV_WN4P(&ref_tmp[x], AV_RN4P(&top[x - 1])); |
453 | 44.7M | for (x = last; x <= -1; x++) |
454 | 35.2M | ref_tmp[x] = left[-1 + ((x * inv_angle[mode - 11] + 128) >> 8)]; |
455 | 9.50M | ref = ref_tmp; |
456 | 9.50M | } |
457 | | |
458 | 306M | for (y = 0; y < size; y++) { |
459 | 257M | int idx = ((y + 1) * angle) >> 5; |
460 | 257M | int fact = ((y + 1) * angle) & 31; |
461 | 257M | if (fact) { |
462 | 403M | for (x = 0; x < size; x += 4) { |
463 | 259M | POS(x , y) = ((32 - fact) * ref[x + idx + 1] + |
464 | 259M | fact * ref[x + idx + 2] + 16) >> 5; |
465 | 259M | POS(x + 1, y) = ((32 - fact) * ref[x + 1 + idx + 1] + |
466 | 259M | fact * ref[x + 1 + idx + 2] + 16) >> 5; |
467 | 259M | POS(x + 2, y) = ((32 - fact) * ref[x + 2 + idx + 1] + |
468 | 259M | fact * ref[x + 2 + idx + 2] + 16) >> 5; |
469 | 259M | POS(x + 3, y) = ((32 - fact) * ref[x + 3 + idx + 1] + |
470 | 259M | fact * ref[x + 3 + idx + 2] + 16) >> 5; |
471 | 259M | } |
472 | 143M | } else { |
473 | 338M | for (x = 0; x < size; x += 4) |
474 | 224M | AV_WN4P(&POS(x, y), AV_RN4P(&ref[x + idx + 1])); |
475 | 113M | } |
476 | 257M | } |
477 | 49.5M | if (mode == 26 && c_idx == 0 && size < 32) { |
478 | 37.7M | for (y = 0; y < size; y++) |
479 | 31.9M | POS(0, y) = av_clip_pixel(top[0] + ((left[y] - left[-1]) >> 1)); |
480 | 5.88M | } |
481 | 49.5M | } else { |
482 | 46.8M | ref = left - 1; |
483 | 46.8M | if (angle < 0 && last < -1) { |
484 | 24.2M | for (x = 0; x <= size; x += 4) |
485 | 17.1M | AV_WN4P(&ref_tmp[x], AV_RN4P(&left[x - 1])); |
486 | 32.0M | for (x = last; x <= -1; x++) |
487 | 24.9M | ref_tmp[x] = top[-1 + ((x * inv_angle[mode - 11] + 128) >> 8)]; |
488 | 7.10M | ref = ref_tmp; |
489 | 7.10M | } |
490 | | |
491 | 298M | for (x = 0; x < size; x++) { |
492 | 251M | int idx = ((x + 1) * angle) >> 5; |
493 | 251M | int fact = ((x + 1) * angle) & 31; |
494 | 251M | if (fact) { |
495 | 1.22G | for (y = 0; y < size; y++) { |
496 | 1.10G | POS(x, y) = ((32 - fact) * ref[y + idx + 1] + |
497 | 1.10G | fact * ref[y + idx + 2] + 16) >> 5; |
498 | 1.10G | } |
499 | 127M | } else { |
500 | 1.00G | for (y = 0; y < size; y++) |
501 | 875M | POS(x, y) = ref[y + idx + 1]; |
502 | 124M | } |
503 | 251M | } |
504 | 46.8M | if (mode == 10 && c_idx == 0 && size < 32) { |
505 | 1.85M | for (x = 0; x < size; x += 4) { |
506 | 1.07M | POS(x, 0) = av_clip_pixel(left[0] + ((top[x ] - top[-1]) >> 1)); |
507 | 1.07M | POS(x + 1, 0) = av_clip_pixel(left[0] + ((top[x + 1] - top[-1]) >> 1)); |
508 | 1.07M | POS(x + 2, 0) = av_clip_pixel(left[0] + ((top[x + 2] - top[-1]) >> 1)); |
509 | 1.07M | POS(x + 3, 0) = av_clip_pixel(left[0] + ((top[x + 3] - top[-1]) >> 1)); |
510 | 1.07M | } |
511 | 785k | } |
512 | 46.8M | } |
513 | 96.3M | } Line | Count | Source | 427 | 21.8M | { | 428 | 21.8M | int x, y; | 429 | 21.8M | pixel *src = (pixel *)_src; | 430 | 21.8M | const pixel *top = (const pixel *)_top; | 431 | 21.8M | const pixel *left = (const pixel *)_left; | 432 | | | 433 | 21.8M | static const int intra_pred_angle[] = { | 434 | 21.8M | 32, 26, 21, 17, 13, 9, 5, 2, 0, -2, -5, -9, -13, -17, -21, -26, -32, | 435 | 21.8M | -26, -21, -17, -13, -9, -5, -2, 0, 2, 5, 9, 13, 17, 21, 26, 32 | 436 | 21.8M | }; | 437 | 21.8M | static const int inv_angle[] = { | 438 | 21.8M | -4096, -1638, -910, -630, -482, -390, -315, -256, -315, -390, -482, | 439 | 21.8M | -630, -910, -1638, -4096 | 440 | 21.8M | }; | 441 | | | 442 | 21.8M | int angle = intra_pred_angle[mode - 2]; | 443 | 21.8M | pixel ref_array[3 * MAX_TB_SIZE + 4]; | 444 | 21.8M | pixel *ref_tmp = ref_array + size; | 445 | 21.8M | const pixel *ref; | 446 | 21.8M | int last = (size * angle) >> 5; | 447 | | | 448 | 21.8M | if (mode >= 18) { | 449 | 12.4M | ref = top - 1; | 450 | 12.4M | if (angle < 0 && last < -1) { | 451 | 8.34M | for (x = 0; x <= size; x += 4) | 452 | 5.87M | AV_WN4P(&ref_tmp[x], AV_RN4P(&top[x - 1])); | 453 | 11.5M | for (x = last; x <= -1; x++) | 454 | 9.03M | ref_tmp[x] = left[-1 + ((x * inv_angle[mode - 11] + 128) >> 8)]; | 455 | 2.47M | ref = ref_tmp; | 456 | 2.47M | } | 457 | | | 458 | 77.5M | for (y = 0; y < size; y++) { | 459 | 65.0M | int idx = ((y + 1) * angle) >> 5; | 460 | 65.0M | int fact = ((y + 1) * angle) & 31; | 461 | 65.0M | if (fact) { | 462 | 100M | for (x = 0; x < size; x += 4) { | 463 | 64.1M | POS(x , y) = ((32 - fact) * ref[x + idx + 1] + | 464 | 64.1M | fact * ref[x + idx + 2] + 16) >> 5; | 465 | 64.1M | POS(x + 1, y) = ((32 - fact) * ref[x + 1 + idx + 1] + | 466 | 64.1M | fact * ref[x + 1 + idx + 2] + 16) >> 5; | 467 | 64.1M | POS(x + 2, y) = ((32 - fact) * ref[x + 2 + idx + 1] + | 468 | 64.1M | fact * ref[x + 2 + idx + 2] + 16) >> 5; | 469 | 64.1M | POS(x + 3, y) = ((32 - fact) * ref[x + 3 + idx + 1] + | 470 | 64.1M | fact * ref[x + 3 + idx + 2] + 16) >> 5; | 471 | 64.1M | } | 472 | 36.7M | } else { | 473 | 84.4M | for (x = 0; x < size; x += 4) | 474 | 56.0M | AV_WN4P(&POS(x, y), AV_RN4P(&ref[x + idx + 1])); | 475 | 28.3M | } | 476 | 65.0M | } | 477 | 12.4M | if (mode == 26 && c_idx == 0 && size < 32) { | 478 | 10.8M | for (y = 0; y < size; y++) | 479 | 9.15M | POS(0, y) = av_clip_pixel(top[0] + ((left[y] - left[-1]) >> 1)); | 480 | 1.67M | } | 481 | 12.4M | } else { | 482 | 9.39M | ref = left - 1; | 483 | 9.39M | if (angle < 0 && last < -1) { | 484 | 5.80M | for (x = 0; x <= size; x += 4) | 485 | 4.11M | AV_WN4P(&ref_tmp[x], AV_RN4P(&left[x - 1])); | 486 | 7.74M | for (x = last; x <= -1; x++) | 487 | 6.05M | ref_tmp[x] = top[-1 + ((x * inv_angle[mode - 11] + 128) >> 8)]; | 488 | 1.69M | ref = ref_tmp; | 489 | 1.69M | } | 490 | | | 491 | 58.1M | for (x = 0; x < size; x++) { | 492 | 48.7M | int idx = ((x + 1) * angle) >> 5; | 493 | 48.7M | int fact = ((x + 1) * angle) & 31; | 494 | 48.7M | if (fact) { | 495 | 231M | for (y = 0; y < size; y++) { | 496 | 206M | POS(x, y) = ((32 - fact) * ref[y + idx + 1] + | 497 | 206M | fact * ref[y + idx + 2] + 16) >> 5; | 498 | 206M | } | 499 | 25.5M | } else { | 500 | 170M | for (y = 0; y < size; y++) | 501 | 147M | POS(x, y) = ref[y + idx + 1]; | 502 | 23.2M | } | 503 | 48.7M | } | 504 | 9.39M | if (mode == 10 && c_idx == 0 && size < 32) { | 505 | 413k | for (x = 0; x < size; x += 4) { | 506 | 238k | POS(x, 0) = av_clip_pixel(left[0] + ((top[x ] - top[-1]) >> 1)); | 507 | 238k | POS(x + 1, 0) = av_clip_pixel(left[0] + ((top[x + 1] - top[-1]) >> 1)); | 508 | 238k | POS(x + 2, 0) = av_clip_pixel(left[0] + ((top[x + 2] - top[-1]) >> 1)); | 509 | 238k | POS(x + 3, 0) = av_clip_pixel(left[0] + ((top[x + 3] - top[-1]) >> 1)); | 510 | 238k | } | 511 | 175k | } | 512 | 9.39M | } | 513 | 21.8M | } |
Line | Count | Source | 427 | 31.6M | { | 428 | 31.6M | int x, y; | 429 | 31.6M | pixel *src = (pixel *)_src; | 430 | 31.6M | const pixel *top = (const pixel *)_top; | 431 | 31.6M | const pixel *left = (const pixel *)_left; | 432 | | | 433 | 31.6M | static const int intra_pred_angle[] = { | 434 | 31.6M | 32, 26, 21, 17, 13, 9, 5, 2, 0, -2, -5, -9, -13, -17, -21, -26, -32, | 435 | 31.6M | -26, -21, -17, -13, -9, -5, -2, 0, 2, 5, 9, 13, 17, 21, 26, 32 | 436 | 31.6M | }; | 437 | 31.6M | static const int inv_angle[] = { | 438 | 31.6M | -4096, -1638, -910, -630, -482, -390, -315, -256, -315, -390, -482, | 439 | 31.6M | -630, -910, -1638, -4096 | 440 | 31.6M | }; | 441 | | | 442 | 31.6M | int angle = intra_pred_angle[mode - 2]; | 443 | 31.6M | pixel ref_array[3 * MAX_TB_SIZE + 4]; | 444 | 31.6M | pixel *ref_tmp = ref_array + size; | 445 | 31.6M | const pixel *ref; | 446 | 31.6M | int last = (size * angle) >> 5; | 447 | | | 448 | 31.6M | if (mode >= 18) { | 449 | 16.9M | ref = top - 1; | 450 | 16.9M | if (angle < 0 && last < -1) { | 451 | 9.69M | for (x = 0; x <= size; x += 4) | 452 | 6.75M | AV_WN4P(&ref_tmp[x], AV_RN4P(&top[x - 1])); | 453 | 13.3M | for (x = last; x <= -1; x++) | 454 | 10.3M | ref_tmp[x] = left[-1 + ((x * inv_angle[mode - 11] + 128) >> 8)]; | 455 | 2.93M | ref = ref_tmp; | 456 | 2.93M | } | 457 | | | 458 | 99.5M | for (y = 0; y < size; y++) { | 459 | 82.5M | int idx = ((y + 1) * angle) >> 5; | 460 | 82.5M | int fact = ((y + 1) * angle) & 31; | 461 | 82.5M | if (fact) { | 462 | 129M | for (x = 0; x < size; x += 4) { | 463 | 79.2M | POS(x , y) = ((32 - fact) * ref[x + idx + 1] + | 464 | 79.2M | fact * ref[x + idx + 2] + 16) >> 5; | 465 | 79.2M | POS(x + 1, y) = ((32 - fact) * ref[x + 1 + idx + 1] + | 466 | 79.2M | fact * ref[x + 1 + idx + 2] + 16) >> 5; | 467 | 79.2M | POS(x + 2, y) = ((32 - fact) * ref[x + 2 + idx + 1] + | 468 | 79.2M | fact * ref[x + 2 + idx + 2] + 16) >> 5; | 469 | 79.2M | POS(x + 3, y) = ((32 - fact) * ref[x + 3 + idx + 1] + | 470 | 79.2M | fact * ref[x + 3 + idx + 2] + 16) >> 5; | 471 | 79.2M | } | 472 | 49.9M | } else { | 473 | 89.6M | for (x = 0; x < size; x += 4) | 474 | 56.9M | AV_WN4P(&POS(x, y), AV_RN4P(&ref[x + idx + 1])); | 475 | 32.6M | } | 476 | 82.5M | } | 477 | 16.9M | if (mode == 26 && c_idx == 0 && size < 32) { | 478 | 11.5M | for (y = 0; y < size; y++) | 479 | 9.68M | POS(0, y) = av_clip_pixel(top[0] + ((left[y] - left[-1]) >> 1)); | 480 | 1.84M | } | 481 | 16.9M | } else { | 482 | 14.6M | ref = left - 1; | 483 | 14.6M | if (angle < 0 && last < -1) { | 484 | 7.25M | for (x = 0; x <= size; x += 4) | 485 | 5.09M | AV_WN4P(&ref_tmp[x], AV_RN4P(&left[x - 1])); | 486 | 9.51M | for (x = last; x <= -1; x++) | 487 | 7.34M | ref_tmp[x] = top[-1 + ((x * inv_angle[mode - 11] + 128) >> 8)]; | 488 | 2.16M | ref = ref_tmp; | 489 | 2.16M | } | 490 | | | 491 | 86.1M | for (x = 0; x < size; x++) { | 492 | 71.4M | int idx = ((x + 1) * angle) >> 5; | 493 | 71.4M | int fact = ((x + 1) * angle) & 31; | 494 | 71.4M | if (fact) { | 495 | 291M | for (y = 0; y < size; y++) { | 496 | 257M | POS(x, y) = ((32 - fact) * ref[y + idx + 1] + | 497 | 257M | fact * ref[y + idx + 2] + 16) >> 5; | 498 | 257M | } | 499 | 37.6M | } else { | 500 | 250M | for (y = 0; y < size; y++) | 501 | 212M | POS(x, y) = ref[y + idx + 1]; | 502 | 37.6M | } | 503 | 71.4M | } | 504 | 14.6M | if (mode == 10 && c_idx == 0 && size < 32) { | 505 | 591k | for (x = 0; x < size; x += 4) { | 506 | 333k | POS(x, 0) = av_clip_pixel(left[0] + ((top[x ] - top[-1]) >> 1)); | 507 | 333k | POS(x + 1, 0) = av_clip_pixel(left[0] + ((top[x + 1] - top[-1]) >> 1)); | 508 | 333k | POS(x + 2, 0) = av_clip_pixel(left[0] + ((top[x + 2] - top[-1]) >> 1)); | 509 | 333k | POS(x + 3, 0) = av_clip_pixel(left[0] + ((top[x + 3] - top[-1]) >> 1)); | 510 | 333k | } | 511 | 257k | } | 512 | 14.6M | } | 513 | 31.6M | } |
Line | Count | Source | 427 | 19.1M | { | 428 | 19.1M | int x, y; | 429 | 19.1M | pixel *src = (pixel *)_src; | 430 | 19.1M | const pixel *top = (const pixel *)_top; | 431 | 19.1M | const pixel *left = (const pixel *)_left; | 432 | | | 433 | 19.1M | static const int intra_pred_angle[] = { | 434 | 19.1M | 32, 26, 21, 17, 13, 9, 5, 2, 0, -2, -5, -9, -13, -17, -21, -26, -32, | 435 | 19.1M | -26, -21, -17, -13, -9, -5, -2, 0, 2, 5, 9, 13, 17, 21, 26, 32 | 436 | 19.1M | }; | 437 | 19.1M | static const int inv_angle[] = { | 438 | 19.1M | -4096, -1638, -910, -630, -482, -390, -315, -256, -315, -390, -482, | 439 | 19.1M | -630, -910, -1638, -4096 | 440 | 19.1M | }; | 441 | | | 442 | 19.1M | int angle = intra_pred_angle[mode - 2]; | 443 | 19.1M | pixel ref_array[3 * MAX_TB_SIZE + 4]; | 444 | 19.1M | pixel *ref_tmp = ref_array + size; | 445 | 19.1M | const pixel *ref; | 446 | 19.1M | int last = (size * angle) >> 5; | 447 | | | 448 | 19.1M | if (mode >= 18) { | 449 | 8.61M | ref = top - 1; | 450 | 8.61M | if (angle < 0 && last < -1) { | 451 | 6.00M | for (x = 0; x <= size; x += 4) | 452 | 4.32M | AV_WN4P(&ref_tmp[x], AV_RN4P(&top[x - 1])); | 453 | 8.59M | for (x = last; x <= -1; x++) | 454 | 6.90M | ref_tmp[x] = left[-1 + ((x * inv_angle[mode - 11] + 128) >> 8)]; | 455 | 1.68M | ref = ref_tmp; | 456 | 1.68M | } | 457 | | | 458 | 58.4M | for (y = 0; y < size; y++) { | 459 | 49.8M | int idx = ((y + 1) * angle) >> 5; | 460 | 49.8M | int fact = ((y + 1) * angle) & 31; | 461 | 49.8M | if (fact) { | 462 | 77.5M | for (x = 0; x < size; x += 4) { | 463 | 53.5M | POS(x , y) = ((32 - fact) * ref[x + idx + 1] + | 464 | 53.5M | fact * ref[x + idx + 2] + 16) >> 5; | 465 | 53.5M | POS(x + 1, y) = ((32 - fact) * ref[x + 1 + idx + 1] + | 466 | 53.5M | fact * ref[x + 1 + idx + 2] + 16) >> 5; | 467 | 53.5M | POS(x + 2, y) = ((32 - fact) * ref[x + 2 + idx + 1] + | 468 | 53.5M | fact * ref[x + 2 + idx + 2] + 16) >> 5; | 469 | 53.5M | POS(x + 3, y) = ((32 - fact) * ref[x + 3 + idx + 1] + | 470 | 53.5M | fact * ref[x + 3 + idx + 2] + 16) >> 5; | 471 | 53.5M | } | 472 | 25.8M | } else { | 473 | 84.1M | for (x = 0; x < size; x += 4) | 474 | 58.2M | AV_WN4P(&POS(x, y), AV_RN4P(&ref[x + idx + 1])); | 475 | 25.8M | } | 476 | 49.8M | } | 477 | 8.61M | if (mode == 26 && c_idx == 0 && size < 32) { | 478 | 5.26M | for (y = 0; y < size; y++) | 479 | 4.46M | POS(0, y) = av_clip_pixel(top[0] + ((left[y] - left[-1]) >> 1)); | 480 | 797k | } | 481 | 10.5M | } else { | 482 | 10.5M | ref = left - 1; | 483 | 10.5M | if (angle < 0 && last < -1) { | 484 | 4.70M | for (x = 0; x <= size; x += 4) | 485 | 3.37M | AV_WN4P(&ref_tmp[x], AV_RN4P(&left[x - 1])); | 486 | 6.20M | for (x = last; x <= -1; x++) | 487 | 4.87M | ref_tmp[x] = top[-1 + ((x * inv_angle[mode - 11] + 128) >> 8)]; | 488 | 1.32M | ref = ref_tmp; | 489 | 1.32M | } | 490 | | | 491 | 76.2M | for (x = 0; x < size; x++) { | 492 | 65.6M | int idx = ((x + 1) * angle) >> 5; | 493 | 65.6M | int fact = ((x + 1) * angle) & 31; | 494 | 65.6M | if (fact) { | 495 | 376M | for (y = 0; y < size; y++) { | 496 | 343M | POS(x, y) = ((32 - fact) * ref[y + idx + 1] + | 497 | 343M | fact * ref[y + idx + 2] + 16) >> 5; | 498 | 343M | } | 499 | 32.8M | } else { | 500 | 322M | for (y = 0; y < size; y++) | 501 | 289M | POS(x, y) = ref[y + idx + 1]; | 502 | 32.8M | } | 503 | 65.6M | } | 504 | 10.5M | if (mode == 10 && c_idx == 0 && size < 32) { | 505 | 305k | for (x = 0; x < size; x += 4) { | 506 | 179k | POS(x, 0) = av_clip_pixel(left[0] + ((top[x ] - top[-1]) >> 1)); | 507 | 179k | POS(x + 1, 0) = av_clip_pixel(left[0] + ((top[x + 1] - top[-1]) >> 1)); | 508 | 179k | POS(x + 2, 0) = av_clip_pixel(left[0] + ((top[x + 2] - top[-1]) >> 1)); | 509 | 179k | POS(x + 3, 0) = av_clip_pixel(left[0] + ((top[x + 3] - top[-1]) >> 1)); | 510 | 179k | } | 511 | 126k | } | 512 | 10.5M | } | 513 | 19.1M | } |
Line | Count | Source | 427 | 23.5M | { | 428 | 23.5M | int x, y; | 429 | 23.5M | pixel *src = (pixel *)_src; | 430 | 23.5M | const pixel *top = (const pixel *)_top; | 431 | 23.5M | const pixel *left = (const pixel *)_left; | 432 | | | 433 | 23.5M | static const int intra_pred_angle[] = { | 434 | 23.5M | 32, 26, 21, 17, 13, 9, 5, 2, 0, -2, -5, -9, -13, -17, -21, -26, -32, | 435 | 23.5M | -26, -21, -17, -13, -9, -5, -2, 0, 2, 5, 9, 13, 17, 21, 26, 32 | 436 | 23.5M | }; | 437 | 23.5M | static const int inv_angle[] = { | 438 | 23.5M | -4096, -1638, -910, -630, -482, -390, -315, -256, -315, -390, -482, | 439 | 23.5M | -630, -910, -1638, -4096 | 440 | 23.5M | }; | 441 | | | 442 | 23.5M | int angle = intra_pred_angle[mode - 2]; | 443 | 23.5M | pixel ref_array[3 * MAX_TB_SIZE + 4]; | 444 | 23.5M | pixel *ref_tmp = ref_array + size; | 445 | 23.5M | const pixel *ref; | 446 | 23.5M | int last = (size * angle) >> 5; | 447 | | | 448 | 23.5M | if (mode >= 18) { | 449 | 11.4M | ref = top - 1; | 450 | 11.4M | if (angle < 0 && last < -1) { | 451 | 8.21M | for (x = 0; x <= size; x += 4) | 452 | 5.80M | AV_WN4P(&ref_tmp[x], AV_RN4P(&top[x - 1])); | 453 | 11.3M | for (x = last; x <= -1; x++) | 454 | 8.90M | ref_tmp[x] = left[-1 + ((x * inv_angle[mode - 11] + 128) >> 8)]; | 455 | 2.41M | ref = ref_tmp; | 456 | 2.41M | } | 457 | | | 458 | 71.3M | for (y = 0; y < size; y++) { | 459 | 59.9M | int idx = ((y + 1) * angle) >> 5; | 460 | 59.9M | int fact = ((y + 1) * angle) & 31; | 461 | 59.9M | if (fact) { | 462 | 95.7M | for (x = 0; x < size; x += 4) { | 463 | 62.9M | POS(x , y) = ((32 - fact) * ref[x + idx + 1] + | 464 | 62.9M | fact * ref[x + idx + 2] + 16) >> 5; | 465 | 62.9M | POS(x + 1, y) = ((32 - fact) * ref[x + 1 + idx + 1] + | 466 | 62.9M | fact * ref[x + 1 + idx + 2] + 16) >> 5; | 467 | 62.9M | POS(x + 2, y) = ((32 - fact) * ref[x + 2 + idx + 1] + | 468 | 62.9M | fact * ref[x + 2 + idx + 2] + 16) >> 5; | 469 | 62.9M | POS(x + 3, y) = ((32 - fact) * ref[x + 3 + idx + 1] + | 470 | 62.9M | fact * ref[x + 3 + idx + 2] + 16) >> 5; | 471 | 62.9M | } | 472 | 32.8M | } else { | 473 | 80.1M | for (x = 0; x < size; x += 4) | 474 | 53.0M | AV_WN4P(&POS(x, y), AV_RN4P(&ref[x + idx + 1])); | 475 | 27.1M | } | 476 | 59.9M | } | 477 | 11.4M | if (mode == 26 && c_idx == 0 && size < 32) { | 478 | 10.1M | for (y = 0; y < size; y++) | 479 | 8.60M | POS(0, y) = av_clip_pixel(top[0] + ((left[y] - left[-1]) >> 1)); | 480 | 1.56M | } | 481 | 12.1M | } else { | 482 | 12.1M | ref = left - 1; | 483 | 12.1M | if (angle < 0 && last < -1) { | 484 | 6.49M | for (x = 0; x <= size; x += 4) | 485 | 4.57M | AV_WN4P(&ref_tmp[x], AV_RN4P(&left[x - 1])); | 486 | 8.53M | for (x = last; x <= -1; x++) | 487 | 6.62M | ref_tmp[x] = top[-1 + ((x * inv_angle[mode - 11] + 128) >> 8)]; | 488 | 1.91M | ref = ref_tmp; | 489 | 1.91M | } | 490 | | | 491 | 77.8M | for (x = 0; x < size; x++) { | 492 | 65.7M | int idx = ((x + 1) * angle) >> 5; | 493 | 65.7M | int fact = ((x + 1) * angle) & 31; | 494 | 65.7M | if (fact) { | 495 | 328M | for (y = 0; y < size; y++) { | 496 | 293M | POS(x, y) = ((32 - fact) * ref[y + idx + 1] + | 497 | 293M | fact * ref[y + idx + 2] + 16) >> 5; | 498 | 293M | } | 499 | 35.0M | } else { | 500 | 257M | for (y = 0; y < size; y++) | 501 | 226M | POS(x, y) = ref[y + idx + 1]; | 502 | 30.7M | } | 503 | 65.7M | } | 504 | 12.1M | if (mode == 10 && c_idx == 0 && size < 32) { | 505 | 544k | for (x = 0; x < size; x += 4) { | 506 | 317k | POS(x, 0) = av_clip_pixel(left[0] + ((top[x ] - top[-1]) >> 1)); | 507 | 317k | POS(x + 1, 0) = av_clip_pixel(left[0] + ((top[x + 1] - top[-1]) >> 1)); | 508 | 317k | POS(x + 2, 0) = av_clip_pixel(left[0] + ((top[x + 2] - top[-1]) >> 1)); | 509 | 317k | POS(x + 3, 0) = av_clip_pixel(left[0] + ((top[x + 3] - top[-1]) >> 1)); | 510 | 317k | } | 511 | 226k | } | 512 | 12.1M | } | 513 | 23.5M | } |
|
514 | | |
515 | | 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 | 77.6M | { |
519 | 77.6M | FUNC(pred_angular)(src, top, left, stride, c_idx, mode, 1 << 2); |
520 | 77.6M | } Line | Count | Source | 518 | 17.7M | { | 519 | 17.7M | FUNC(pred_angular)(src, top, left, stride, c_idx, mode, 1 << 2); | 520 | 17.7M | } |
Line | Count | Source | 518 | 27.4M | { | 519 | 27.4M | FUNC(pred_angular)(src, top, left, stride, c_idx, mode, 1 << 2); | 520 | 27.4M | } |
Line | Count | Source | 518 | 13.6M | { | 519 | 13.6M | FUNC(pred_angular)(src, top, left, stride, c_idx, mode, 1 << 2); | 520 | 13.6M | } |
Line | Count | Source | 518 | 18.8M | { | 519 | 18.8M | FUNC(pred_angular)(src, top, left, stride, c_idx, mode, 1 << 2); | 520 | 18.8M | } |
|
521 | | |
522 | | 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 | 14.1M | { |
526 | 14.1M | FUNC(pred_angular)(src, top, left, stride, c_idx, mode, 1 << 3); |
527 | 14.1M | } Line | Count | Source | 525 | 3.13M | { | 526 | 3.13M | FUNC(pred_angular)(src, top, left, stride, c_idx, mode, 1 << 3); | 527 | 3.13M | } |
Line | Count | Source | 525 | 3.30M | { | 526 | 3.30M | FUNC(pred_angular)(src, top, left, stride, c_idx, mode, 1 << 3); | 527 | 3.30M | } |
Line | Count | Source | 525 | 4.09M | { | 526 | 4.09M | FUNC(pred_angular)(src, top, left, stride, c_idx, mode, 1 << 3); | 527 | 4.09M | } |
Line | Count | Source | 525 | 3.60M | { | 526 | 3.60M | FUNC(pred_angular)(src, top, left, stride, c_idx, mode, 1 << 3); | 527 | 3.60M | } |
|
528 | | |
529 | | 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 | 3.77M | { |
533 | 3.77M | FUNC(pred_angular)(src, top, left, stride, c_idx, mode, 1 << 4); |
534 | 3.77M | } Line | Count | Source | 532 | 852k | { | 533 | 852k | FUNC(pred_angular)(src, top, left, stride, c_idx, mode, 1 << 4); | 534 | 852k | } |
Line | Count | Source | 532 | 794k | { | 533 | 794k | FUNC(pred_angular)(src, top, left, stride, c_idx, mode, 1 << 4); | 534 | 794k | } |
Line | Count | Source | 532 | 1.19M | { | 533 | 1.19M | FUNC(pred_angular)(src, top, left, stride, c_idx, mode, 1 << 4); | 534 | 1.19M | } |
Line | Count | Source | 532 | 939k | { | 533 | 939k | FUNC(pred_angular)(src, top, left, stride, c_idx, mode, 1 << 4); | 534 | 939k | } |
|
535 | | |
536 | | 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 | 781k | { |
540 | 781k | FUNC(pred_angular)(src, top, left, stride, c_idx, mode, 1 << 5); |
541 | 781k | } Line | Count | Source | 539 | 128k | { | 540 | 128k | FUNC(pred_angular)(src, top, left, stride, c_idx, mode, 1 << 5); | 541 | 128k | } |
Line | Count | Source | 539 | 157k | { | 540 | 157k | FUNC(pred_angular)(src, top, left, stride, c_idx, mode, 1 << 5); | 541 | 157k | } |
Line | Count | Source | 539 | 288k | { | 540 | 288k | FUNC(pred_angular)(src, top, left, stride, c_idx, mode, 1 << 5); | 541 | 288k | } |
Line | Count | Source | 539 | 207k | { | 540 | 207k | FUNC(pred_angular)(src, top, left, stride, c_idx, mode, 1 << 5); | 541 | 207k | } |
|
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 |