Line data Source code
1 : /*
2 : * Copyright(c) 2019 Intel Corporation
3 : * SPDX - License - Identifier: BSD - 2 - Clause - Patent
4 : */
5 :
6 : /*
7 : * Copyright (c) 2016, Alliance for Open Media. All rights reserved
8 : *
9 : * This source code is subject to the terms of the BSD 2 Clause License and
10 : * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
11 : * was not distributed with this source code in the LICENSE file, you can
12 : * obtain it at www.aomedia.org/license/software. If the Alliance for Open
13 : * Media Patent License 1.0 was not distributed with this source code in the
14 : * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
15 : */
16 :
17 : #include <stdlib.h>
18 : #include <string.h>
19 :
20 : #include "EbIntraPrediction.h"
21 : #include "EbUtility.h"
22 : #include "EbModeDecision.h"
23 : #include "EbCodingUnit.h"
24 : #include "EbModeDecisionProcess.h"
25 : #include "EbDefinitions.h"
26 : #include "EbPictureControlSet.h"
27 : #include "EbEncDecProcess.h"
28 : #include "aom_dsp_rtcd.h"
29 :
30 : void *eb_aom_memset16(void *dest, int32_t val, size_t length);
31 :
32 : int32_t is_inter_block(const BlockModeInfo *mbmi);
33 :
34 : // Some basic checks on weights for smooth predictor.
35 : #define sm_weights_sanity_checks(weights_w, weights_h, weights_scale, \
36 : pred_scale) \
37 : assert(weights_w[0] < weights_scale); \
38 : assert(weights_h[0] < weights_scale); \
39 : assert(weights_scale - weights_w[bw - 1] < weights_scale); \
40 : assert(weights_scale - weights_h[bh - 1] < weights_scale); \
41 : assert(pred_scale < 31) // ensures no overflow when calculating predictor.
42 : #define MIDRANGE_VALUE_8BIT 128
43 : #define MIDRANGE_VALUE_10BIT 512
44 : static PartitionType from_shape_to_part[] = {
45 : PARTITION_NONE,
46 : PARTITION_HORZ,
47 : PARTITION_VERT,
48 : PARTITION_HORZ_A,
49 : PARTITION_HORZ_B,
50 : PARTITION_VERT_A,
51 : PARTITION_VERT_B,
52 : PARTITION_HORZ_4,
53 : PARTITION_VERT_4,
54 : PARTITION_SPLIT
55 : };
56 49442000 : int is_smooth(const BlockModeInfo *block_mi, int plane) {
57 49442000 : if (plane == 0) {
58 33827400 : const PredictionMode mode = block_mi->mode;
59 33827400 : return (mode == SMOOTH_PRED || mode == SMOOTH_V_PRED ||
60 : mode == SMOOTH_H_PRED);
61 : }
62 : else {
63 : // uv_mode is not set for inter blocks, so need to explicitly
64 : // detect that case.
65 15614500 : if (is_inter_block(block_mi)) return 0;
66 :
67 7504420 : const UvPredictionMode uv_mode = block_mi->uv_mode;
68 7504420 : return (uv_mode == UV_SMOOTH_PRED || uv_mode == UV_SMOOTH_V_PRED ||
69 : uv_mode == UV_SMOOTH_H_PRED);
70 : }
71 : }
72 :
73 25556800 : static int get_filt_type(const MacroBlockD *xd, int plane) {
74 : int ab_sm, le_sm;
75 :
76 25556800 : if (plane == 0) {
77 17472100 : const MbModeInfo *ab = xd->above_mbmi;
78 17472100 : const MbModeInfo *le = xd->left_mbmi;
79 17472100 : ab_sm = ab ? is_smooth(&ab->block_mi, plane) : 0;
80 17473000 : le_sm = le ? is_smooth(&le->block_mi, plane) : 0;
81 : }
82 : else {
83 8084650 : const MbModeInfo *ab = xd->chroma_above_mbmi;
84 8084650 : const MbModeInfo *le = xd->chroma_left_mbmi;
85 8084650 : ab_sm = ab ? is_smooth(&ab->block_mi, plane) : 0;
86 8091190 : le_sm = le ? is_smooth(&le->block_mi, plane) : 0;
87 : }
88 :
89 25561700 : return (ab_sm || le_sm) ? 1 : 0;
90 : }
91 :
92 51107100 : int32_t use_intra_edge_upsample(int32_t bs0, int32_t bs1, int32_t delta, int32_t type) {
93 51107100 : const int32_t d = abs(delta);
94 51107100 : const int32_t blk_wh = bs0 + bs1;
95 51107100 : if (d <= 0 || d >= 40) return 0;
96 12434300 : return type ? (blk_wh <= 8) : (blk_wh <= 16);
97 : }
98 :
99 : #define INTRA_EDGE_FILT 3
100 : #define INTRA_EDGE_TAPS 5
101 0 : void eb_av1_filter_intra_edge_high_c_old(uint8_t *p, int32_t sz, int32_t strength) {
102 0 : if (!strength) return;
103 :
104 0 : const int32_t kernel[INTRA_EDGE_FILT][INTRA_EDGE_TAPS] = {
105 : { 0, 4, 8, 4, 0 }, { 0, 5, 6, 5, 0 }, { 2, 4, 4, 4, 2 }
106 : };
107 0 : const int32_t filt = strength - 1;
108 : uint8_t edge[129];
109 :
110 0 : memcpy(edge, p, sz * sizeof(*p));
111 0 : for (int32_t i = 1; i < sz; i++) {
112 0 : int32_t s = 0;
113 0 : for (int32_t j = 0; j < INTRA_EDGE_TAPS; j++) {
114 0 : int32_t k = i - 2 + j;
115 0 : k = (k < 0) ? 0 : k;
116 0 : k = (k > sz - 1) ? sz - 1 : k;
117 0 : s += edge[k] * kernel[filt][j];
118 : }
119 0 : s = (s + 8) >> 4;
120 0 : p[i] = (uint8_t)s;
121 : }
122 : }
123 0 : void eb_av1_filter_intra_edge_high_c_left(uint8_t *p, int32_t sz, int32_t strength, uint32_t size) {
124 0 : if (!strength) return;
125 0 : const uint32_t leftBlockEnd = 2 * (size);
126 :
127 0 : const int32_t kernel[INTRA_EDGE_FILT][INTRA_EDGE_TAPS] = {
128 : { 0, 4, 8, 4, 0 }, { 0, 5, 6, 5, 0 }, { 2, 4, 4, 4, 2 }
129 : };
130 0 : const int32_t filt = strength - 1;
131 : uint8_t edge[129];
132 0 : edge[0] = p[0];
133 0 : p = p - leftBlockEnd;
134 :
135 0 : memcpy(edge + 1, p, (sz - 1) * sizeof(*p));
136 :
137 0 : for (int32_t i = 1; i < sz; i++) {
138 0 : int32_t s = 0;
139 0 : for (int32_t j = 0; j < INTRA_EDGE_TAPS; j++) {
140 0 : int32_t k = i - 2 + j;
141 0 : k = (k < 0) ? 0 : k;
142 0 : k = (k > sz - 1) ? sz - 1 : k;
143 0 : s += edge[k] * kernel[filt][j];
144 : }
145 0 : s = (s + 8) >> 4;
146 0 : p[i - 1] = (uint8_t)s;
147 : }
148 : }
149 :
150 21266300 : int32_t intra_edge_filter_strength(int32_t bs0, int32_t bs1, int32_t delta, int32_t type) {
151 21266300 : const int32_t d = abs(delta);
152 21266300 : int32_t strength = 0;
153 :
154 21266300 : const int32_t blk_wh = bs0 + bs1;
155 21266300 : if (type == 0) {
156 18729500 : if (blk_wh <= 8) {
157 3389520 : if (d >= 56)
158 804906 : strength = 1;
159 : }
160 15340000 : else if (blk_wh <= 12) {
161 3569320 : if (d >= 40)
162 1570800 : strength = 1;
163 : }
164 11770700 : else if (blk_wh <= 16) {
165 2961650 : if (d >= 40)
166 1251610 : strength = 1;
167 : }
168 8809000 : else if (blk_wh <= 24) {
169 4239070 : if (d >= 8)
170 3815990 : strength = 1;
171 4239070 : if (d >= 16)
172 3394910 : strength = 2;
173 4239070 : if (d >= 32)
174 2341950 : strength = 3;
175 : }
176 4569930 : else if (blk_wh <= 32) {
177 1606120 : if (d >= 1)
178 1606120 : strength = 1;
179 1606120 : if (d >= 4)
180 1520580 : strength = 2;
181 1606120 : if (d >= 32)
182 851786 : strength = 3;
183 : }
184 : else {
185 2963810 : if (d >= 1)
186 2974560 : strength = 3;
187 : }
188 : }
189 : else {
190 2536780 : if (blk_wh <= 8) {
191 517659 : if (d >= 40)
192 232586 : strength = 1;
193 517659 : if (d >= 64)
194 98829 : strength = 2;
195 : }
196 2019120 : else if (blk_wh <= 16) {
197 905161 : if (d >= 20)
198 690122 : strength = 1;
199 905161 : if (d >= 48)
200 314008 : strength = 2;
201 : }
202 1113960 : else if (blk_wh <= 24) {
203 695083 : if (d >= 4)
204 661263 : strength = 3;
205 : }
206 : else {
207 418873 : if (d >= 1)
208 425567 : strength = 3;
209 : }
210 : }
211 21266300 : return strength;
212 : }
213 :
214 : #define MAX_UPSAMPLE_SZ 16
215 0 : void av1_upsample_intra_edge_high_c_old(uint8_t *p, int32_t sz, int32_t bd) {
216 : // interpolate half-sample positions
217 0 : assert(sz <= MAX_UPSAMPLE_SZ);
218 :
219 : uint8_t in[MAX_UPSAMPLE_SZ + 3];
220 : // copy p[-1..(sz-1)] and extend first and last samples
221 0 : in[0] = p[-1];
222 0 : in[1] = p[-1];
223 0 : for (int32_t i = 0; i < sz; i++)
224 0 : in[i + 2] = p[i];
225 0 : in[sz + 2] = p[sz - 1];
226 :
227 : // interpolate half-sample edge positions
228 0 : p[-2] = in[0];
229 0 : for (int32_t i = 0; i < sz; i++) {
230 0 : int32_t s = -in[i] + (9 * in[i + 1]) + (9 * in[i + 2]) - in[i + 3];
231 0 : s = (s + 8) >> 4;
232 0 : s = clip_pixel_highbd(s, bd);
233 0 : p[2 * i - 1] = (uint8_t)s;
234 0 : p[2 * i] = in[i + 2];
235 : }
236 0 : }
237 :
238 : const uint16_t eb_dr_intra_derivative[90] = {
239 : // More evenly spread out angles and limited to 10-bit
240 : // Values that are 0 will never be used
241 : // Approx angle
242 : 0, 0, 0, //
243 : 1023, 0, 0, // 3, ...
244 : 547, 0, 0, // 6, ...
245 : 372, 0, 0, 0, 0, // 9, ...
246 : 273, 0, 0, // 14, ...
247 : 215, 0, 0, // 17, ...
248 : 178, 0, 0, // 20, ...
249 : 151, 0, 0, // 23, ... (113 & 203 are base angles)
250 : 132, 0, 0, // 26, ...
251 : 116, 0, 0, // 29, ...
252 : 102, 0, 0, 0, // 32, ...
253 : 90, 0, 0, // 36, ...
254 : 80, 0, 0, // 39, ...
255 : 71, 0, 0, // 42, ...
256 : 64, 0, 0, // 45, ... (45 & 135 are base angles)
257 : 57, 0, 0, // 48, ...
258 : 51, 0, 0, // 51, ...
259 : 45, 0, 0, 0, // 54, ...
260 : 40, 0, 0, // 58, ...
261 : 35, 0, 0, // 61, ...
262 : 31, 0, 0, // 64, ...
263 : 27, 0, 0, // 67, ... (67 & 157 are base angles)
264 : 23, 0, 0, // 70, ...
265 : 19, 0, 0, // 73, ...
266 : 15, 0, 0, 0, 0, // 76, ...
267 : 11, 0, 0, // 81, ...
268 : 7, 0, 0, // 84, ...
269 : 3, 0, 0, // 87, ...
270 : };
271 :
272 : // Get the shift (up-scaled by 256) in Y w.r.t a unit change in X.
273 : // If angle > 0 && angle < 90, dy = 1;
274 : // If angle > 90 && angle < 180, dy = (int32_t)(256 * t);
275 : // If angle > 180 && angle < 270, dy = -((int32_t)(256 * t));
276 :
277 : #define divide_round(value, bits) (((value) + (1 << ((bits)-1))) >> (bits))
278 :
279 25559800 : static INLINE uint16_t get_dy(int32_t angle) {
280 25559800 : if (angle > 90 && angle < 180)
281 7384640 : return eb_dr_intra_derivative[angle - 90];
282 18175200 : else if (angle > 180 && angle < 270)
283 2964180 : return eb_dr_intra_derivative[270 - angle];
284 : else {
285 : // In this case, we are not really going to use dy. We may return any value.
286 15211000 : return 1;
287 : }
288 : }
289 : // Get the shift (up-scaled by 256) in X w.r.t a unit change in Y.
290 : // If angle > 0 && angle < 90, dx = -((int32_t)(256 / t));
291 : // If angle > 90 && angle < 180, dx = (int32_t)(256 / t);
292 : // If angle > 180 && angle < 270, dx = 1;
293 25559200 : static INLINE uint16_t get_dx(int32_t angle) {
294 25559200 : if (angle > 0 && angle < 90)
295 4343420 : return eb_dr_intra_derivative[angle];
296 21215700 : else if (angle > 90 && angle < 180)
297 7384590 : return eb_dr_intra_derivative[180 - angle];
298 : else {
299 : // In this case, we are not really going to use dx. We may return any value.
300 13831100 : return 1;
301 : }
302 : }
303 :
304 : // Directional prediction, zone 3: 180 < angle < 270
305 0 : void eb_av1_dr_prediction_z3_c(uint8_t *dst, ptrdiff_t stride, int32_t bw, int32_t bh,
306 : const uint8_t *above, const uint8_t *left,
307 : int32_t upsample_left, int32_t dx, int32_t dy) {
308 : int32_t r, c, y, base, shift, val;
309 :
310 : (void)above;
311 : (void)dx;
312 :
313 0 : assert(dx == 1);
314 0 : assert(dy > 0);
315 :
316 0 : const int32_t max_base_y = (bw + bh - 1) << upsample_left;
317 0 : const int32_t frac_bits = 6 - upsample_left;
318 0 : const int32_t base_inc = 1 << upsample_left;
319 0 : y = dy;
320 0 : for (c = 0; c < bw; ++c, y += dy) {
321 0 : base = y >> frac_bits;
322 0 : shift = ((y << upsample_left) & 0x3F) >> 1;
323 :
324 0 : for (r = 0; r < bh; ++r, base += base_inc) {
325 0 : if (base < max_base_y) {
326 0 : val = left[base] * (32 - shift) + left[base + 1] * shift;
327 0 : val = ROUND_POWER_OF_TWO(val, 5);
328 0 : dst[r * stride + c] = (uint8_t)clip_pixel_highbd(val, 8);
329 : }
330 : else {
331 0 : for (; r < bh; ++r) dst[r * stride + c] = left[max_base_y];
332 0 : break;
333 : }
334 : }
335 : }
336 0 : }
337 0 : void eb_av1_dr_prediction_z1_c(uint8_t *dst, ptrdiff_t stride, int32_t bw, int32_t bh,
338 : const uint8_t *above, const uint8_t *left,
339 : int32_t upsample_above, int32_t dx, int32_t dy) {
340 : int32_t r, c, x, base, shift, val;
341 :
342 : (void)left;
343 : (void)dy;
344 0 : assert(dy == 1);
345 0 : assert(dx > 0);
346 :
347 0 : const int32_t max_base_x = ((bw + bh) - 1) << upsample_above;
348 0 : const int32_t frac_bits = 6 - upsample_above;
349 0 : const int32_t base_inc = 1 << upsample_above;
350 0 : x = dx;
351 0 : for (r = 0; r < bh; ++r, dst += stride, x += dx) {
352 0 : base = x >> frac_bits;
353 0 : shift = ((x << upsample_above) & 0x3F) >> 1;
354 :
355 0 : if (base >= max_base_x) {
356 0 : for (int32_t i = r; i < bh; ++i) {
357 0 : memset(dst, above[max_base_x], bw * sizeof(dst[0]));
358 0 : dst += stride;
359 : }
360 0 : return;
361 : }
362 :
363 0 : for (c = 0; c < bw; ++c, base += base_inc) {
364 0 : if (base < max_base_x) {
365 0 : val = above[base] * (32 - shift) + above[base + 1] * shift;
366 0 : val = ROUND_POWER_OF_TWO(val, 5);
367 0 : dst[c] = (uint8_t)clip_pixel_highbd(val, 8);
368 : }
369 : else
370 0 : dst[c] = above[max_base_x];
371 : }
372 : }
373 : }
374 :
375 : // Directional prediction, zone 2: 90 < angle < 180
376 0 : void eb_av1_dr_prediction_z2_c(uint8_t *dst, ptrdiff_t stride, int32_t bw, int32_t bh,
377 : const uint8_t *above, const uint8_t *left,
378 : int32_t upsample_above, int32_t upsample_left, int32_t dx,
379 : int32_t dy) {
380 : int32_t r, c, x, y, shift1, shift2, val, base1, base2;
381 :
382 0 : assert(dx > 0);
383 0 : assert(dy > 0);
384 :
385 0 : const int32_t min_base_x = -(1 << upsample_above);
386 0 : const int32_t frac_bits_x = 6 - upsample_above;
387 0 : const int32_t frac_bits_y = 6 - upsample_left;
388 0 : const int32_t base_inc_x = 1 << upsample_above;
389 0 : x = -dx;
390 0 : for (r = 0; r < bh; ++r, x -= dx, dst += stride) {
391 0 : base1 = x >> frac_bits_x;
392 0 : y = (r << 6) - dy;
393 0 : for (c = 0; c < bw; ++c, base1 += base_inc_x, y -= dy) {
394 0 : if (base1 >= min_base_x) {
395 0 : shift1 = ((x * (1 << upsample_above)) & 0x3F) >> 1;
396 0 : val = above[base1] * (32 - shift1) + above[base1 + 1] * shift1;
397 0 : val = ROUND_POWER_OF_TWO(val, 5);
398 : }
399 : else {
400 0 : base2 = y >> frac_bits_y;
401 0 : assert(base2 >= -(1 << upsample_left));
402 0 : shift2 = ((y * (1 << upsample_left)) & 0x3F) >> 1;
403 0 : val = left[base2] * (32 - shift2) + left[base2 + 1] * shift2;
404 0 : val = ROUND_POWER_OF_TWO(val, 5);
405 : }
406 0 : dst[c] = (uint8_t)clip_pixel_highbd(val, 8);
407 : }
408 : }
409 0 : }
410 :
411 : /* clang-format on */
412 0 : void intra_mode_planar(
413 : const uint32_t size, //input parameter, denotes the size of the current PU
414 : uint8_t *ref_samples, //input parameter, pointer to the reference samples
415 : uint8_t *dst, //output parameter, pointer to the prediction
416 : const uint32_t prediction_buffer_stride, //input parameter, denotes the stride for the prediction ptr
417 : const EbBool skip) //skip half rows
418 : {
419 0 : uint32_t rowStride = skip ? 2 : 1;
420 0 : uint32_t leftOffset = 0;
421 0 : uint32_t topOffset = (size << 1) + 1;
422 :
423 0 : const uint8_t below_pred = ref_samples[leftOffset + size - 1]; // estimated by bottom-left pixel
424 0 : const uint8_t right_pred = ref_samples[topOffset + size - 1]; // estimated by top-right pixel
425 :
426 0 : const uint8_t *const sm_weights_w = sm_weight_arrays + size;
427 0 : const uint8_t *const sm_weights_h = sm_weight_arrays + size;
428 : // scale = 2 * 2^sm_weight_log2_scale
429 0 : const int32_t log2_scale = 1 + sm_weight_log2_scale;
430 0 : const uint16_t scale = (1 << sm_weight_log2_scale);
431 : // sm_weights_sanity_checks(sm_weights_w, sm_weights_h, scale, log2_scale + sizeof(*dst));
432 : uint32_t r;
433 0 : for (r = 0; r < size; ++r) {
434 : uint32_t c;
435 0 : for (c = 0; c < size; ++c) {
436 0 : const uint8_t pixels[] = { ref_samples[topOffset + c], below_pred, ref_samples[leftOffset + r], right_pred };
437 :
438 0 : const uint8_t weights[] = { sm_weights_h[r], (uint8_t)(scale - sm_weights_h[r]),
439 0 : sm_weights_w[c], (uint8_t)(scale - sm_weights_w[c]) };
440 0 : uint32_t this_pred = 0;
441 : int32_t i;
442 0 : assert(scale >= sm_weights_h[r] && scale >= sm_weights_w[c]);
443 0 : for (i = 0; i < 4; ++i)
444 0 : this_pred += weights[i] * pixels[i];
445 0 : dst[c] = (uint8_t)divide_round(this_pred, log2_scale);
446 : }
447 0 : dst += rowStride * prediction_buffer_stride;
448 : }
449 :
450 0 : return;
451 : }
452 :
453 0 : /*static INLINE*/ void smooth_v_predictor_c(uint8_t *dst, ptrdiff_t stride, int32_t bw,
454 : int32_t bh, const uint8_t *above,
455 : const uint8_t *left) {
456 0 : const uint8_t below_pred = left[bh - 1]; // estimated by bottom-left pixel
457 0 : const uint8_t *const sm_weights = sm_weight_arrays + bh;
458 : // scale = 2^sm_weight_log2_scale
459 0 : const int32_t log2_scale = sm_weight_log2_scale;
460 0 : const uint16_t scale = (1 << sm_weight_log2_scale);
461 0 : sm_weights_sanity_checks(sm_weights, sm_weights, scale,
462 : log2_scale + sizeof(*dst));
463 :
464 : int32_t r;
465 0 : for (r = 0; r < bh; r++) {
466 : int32_t c;
467 0 : for (c = 0; c < bw; ++c) {
468 0 : const uint8_t pixels[] = { above[c], below_pred };
469 0 : const uint8_t weights[] = { (uint8_t)(sm_weights[r]), (uint8_t)(scale - sm_weights[r]) };
470 0 : uint32_t this_pred = 0;
471 0 : assert(scale >= sm_weights[r]);
472 : int32_t i;
473 0 : for (i = 0; i < 2; ++i)
474 0 : this_pred += weights[i] * pixels[i];
475 0 : dst[c] = (uint8_t)divide_round(this_pred, log2_scale);
476 : }
477 0 : dst += stride;
478 : }
479 0 : }
480 :
481 0 : /*static INLINE */void smooth_h_predictor_c(uint8_t *dst, ptrdiff_t stride, int32_t bw,
482 : int32_t bh, const uint8_t *above,
483 : const uint8_t *left) {
484 0 : const uint8_t right_pred = above[bw - 1]; // estimated by top-right pixel
485 0 : const uint8_t *const sm_weights = sm_weight_arrays + bw;
486 : // scale = 2^sm_weight_log2_scale
487 0 : const int32_t log2_scale = sm_weight_log2_scale;
488 0 : const uint16_t scale = (1 << sm_weight_log2_scale);
489 0 : sm_weights_sanity_checks(sm_weights, sm_weights, scale,
490 : log2_scale + sizeof(*dst));
491 :
492 : int32_t r;
493 0 : for (r = 0; r < bh; r++) {
494 : int32_t c;
495 0 : for (c = 0; c < bw; ++c) {
496 0 : const uint8_t pixels[] = { left[r], right_pred };
497 0 : const uint8_t weights[] = { (uint8_t)(sm_weights[c]), (uint8_t)(scale - sm_weights[c]) };
498 0 : uint32_t this_pred = 0;
499 0 : assert(scale >= sm_weights[c]);
500 : int32_t i;
501 0 : for (i = 0; i < 2; ++i)
502 0 : this_pred += weights[i] * pixels[i];
503 0 : dst[c] = (uint8_t)divide_round(this_pred, log2_scale);
504 : }
505 0 : dst += stride;
506 : }
507 0 : }
508 : /* clang-format on */
509 0 : void ebav1_smooth_v_predictor(
510 : const uint32_t size, //input parameter, denotes the size of the current PU
511 : uint8_t *ref_samples, //input parameter, pointer to the reference samples
512 : uint8_t *dst, //output parameter, pointer to the prediction
513 : const uint32_t prediction_buffer_stride, //input parameter, denotes the stride for the prediction ptr
514 : const EbBool skip) //skip half rows
515 : {
516 : (void)skip;
517 :
518 0 : const uint32_t bottomLeftEnd = 1 * (size);
519 0 : const uint32_t topLeftBlockEnd = 2 * (size)+1;
520 :
521 0 : const uint8_t below_pred = ref_samples[bottomLeftEnd - 1];//left[size - 1]; // estimated by bottom-left pixel
522 0 : const uint8_t *const sm_weights = sm_weight_arrays + size;
523 : // scale = 2^sm_weight_log2_scale
524 0 : const int32_t log2_scale = sm_weight_log2_scale;
525 0 : const uint16_t scale = (1 << sm_weight_log2_scale);
526 : //sm_weights_sanity_checks(sm_weights, sm_weights, scale,
527 : // log2_scale + sizeof(*dst));
528 :
529 : uint16_t r;
530 0 : for (r = 0; r < size; r++) {
531 : uint16_t c;
532 0 : for (c = 0; c < size; ++c) {
533 0 : const uint8_t pixels[] = { ref_samples[topLeftBlockEnd + c], below_pred };
534 0 : const uint8_t weights[] = { (uint8_t)(sm_weights[r]), (uint8_t)(scale - sm_weights[r]) };
535 0 : uint32_t this_pred = 0;
536 0 : assert(scale >= sm_weights[r]);
537 : int32_t i;
538 0 : for (i = 0; i < 2; ++i)
539 0 : this_pred += weights[i] * pixels[i];
540 0 : dst[c] = (uint8_t)divide_round(this_pred, log2_scale);
541 : }
542 0 : dst += prediction_buffer_stride;
543 : }
544 0 : return;
545 : }
546 0 : void ebav1_smooth_h_predictor(
547 : const uint32_t size, //input parameter, denotes the size of the current PU
548 : uint8_t *ref_samples, //input parameter, pointer to the reference samples
549 : uint8_t *dst, //output parameter, pointer to the prediction
550 : const uint32_t prediction_buffer_stride, //input parameter, denotes the stride for the prediction ptr
551 : const EbBool skip)
552 : {
553 : (void)skip;
554 0 : const uint32_t topLeftBlockEnd = 2 * (size)+1;
555 :
556 0 : const uint8_t right_pred = ref_samples[topLeftBlockEnd + size - 1]; // estimated by top-right pixel
557 0 : const uint8_t *const sm_weights = sm_weight_arrays + size;
558 : // scale = 2^sm_weight_log2_scale
559 0 : const int32_t log2_scale = sm_weight_log2_scale;
560 0 : const uint16_t scale = (1 << sm_weight_log2_scale);
561 : //sm_weights_sanity_checks(sm_weights, sm_weights, scale,
562 : // log2_scale + sizeof(*dst));
563 :
564 : uint16_t r;
565 0 : for (r = 0; r < size; r++) {
566 : uint16_t c;
567 0 : for (c = 0; c < size; ++c) {
568 0 : const uint8_t pixels[] = { ref_samples[r], right_pred };
569 0 : const uint8_t weights[] = { (uint8_t)(sm_weights[c]), (uint8_t)(scale - scale - sm_weights[c]) };
570 0 : uint32_t this_pred = 0;
571 0 : assert(scale >= sm_weights[c]);
572 : int32_t i;
573 0 : for (i = 0; i < 2; ++i)
574 0 : this_pred += weights[i] * pixels[i];
575 0 : dst[c] = (uint8_t)divide_round(this_pred, log2_scale);
576 : }
577 0 : dst += prediction_buffer_stride;
578 : }
579 0 : return;
580 : }
581 :
582 0 : void ebav1_v_predictor(uint8_t *dst, const uint32_t stride, int32_t bw, int32_t bh,
583 : const uint8_t *ref_samples) {
584 : int32_t r;
585 : int32_t c;
586 :
587 0 : for (r = 0; r < bh; r++) {
588 0 : for (c = 0; c < bh; c++) {
589 0 : dst[c + r * stride] = ref_samples[bw + bh + 1 + c];
590 : //EB_MEMSET(dst, ref_samples[bw + bh + 1], bw);
591 : //dst += stride;
592 : }
593 : }
594 0 : }
595 :
596 0 : void ebav1_h_predictor(uint8_t *dst, const uint32_t stride, int32_t bw, int32_t bh,
597 : const uint8_t *ref_samples) {
598 : int32_t r;
599 : //(void)above;
600 :
601 0 : for (r = 0; r < bh; r++) {
602 0 : EB_MEMSET(dst, ref_samples[r], bw);
603 0 : dst += stride;
604 : }
605 :
606 0 : return;
607 : }
608 :
609 0 : void IntraModeAngular_AV1_Z1(
610 : const uint32_t size, //input parameter, denotes the size of the current PU
611 : uint8_t *ref_samples, //input parameter, pointer to the reference samples
612 : uint8_t *dst, //output parameter, pointer to the prediction
613 : const uint32_t prediction_buffer_stride, //input parameter, denotes the stride for the prediction ptr
614 : const EbBool skip,
615 : uint16_t dx, //output parameter, pointer to the prediction
616 : uint16_t dy //output parameter, pointer to the prediction
617 : )
618 :
619 : {
620 : (void)dy;
621 :
622 : // uint32_t row_index, colIndex;
623 0 : uint32_t toAboveOffset = (size << 1) + 1;
624 0 : uint32_t rowStride = skip ? 2 : 1;
625 :
626 : uint32_t r, c;
627 : int32_t x, base, shift, val;
628 0 : const int32_t max_base_x = ((size + size) - 1);
629 0 : const int32_t frac_bits = 6;
630 0 : const int32_t base_inc = 1;
631 :
632 0 : x = dx;
633 :
634 0 : for (r = 0; r < size; ++r, dst += (rowStride* prediction_buffer_stride), x += dx) {
635 0 : base = x >> frac_bits;
636 0 : shift = ((x) & 0x3F) >> 1;
637 :
638 0 : if (base >= max_base_x) {
639 0 : for (uint32_t i = r; i < size; ++i) {
640 0 : EB_MEMSET(dst, ref_samples[toAboveOffset + max_base_x], size);
641 0 : dst += rowStride * prediction_buffer_stride;
642 : }
643 0 : return;
644 : }
645 :
646 0 : for (c = 0; c < size; ++c, base += base_inc) {
647 0 : if (base < max_base_x) {
648 0 : val = ref_samples[toAboveOffset + base] * (32 - shift) + ref_samples[toAboveOffset + base + 1] * shift;
649 0 : val = ROUND_POWER_OF_TWO(val, 5);
650 :
651 0 : dst[c] = (uint8_t)clip_pixel_highbd(val, 8);
652 : }
653 : else
654 0 : dst[c] = ref_samples[toAboveOffset + max_base_x];
655 : }
656 : }
657 :
658 0 : return;
659 : }
660 0 : void IntraModeAngular_AV1_Z2(
661 : const uint32_t size, //input parameter, denotes the size of the current PU
662 : uint8_t *ref_samples, //input parameter, pointer to the reference samples
663 : uint8_t *dst, //output parameter, pointer to the prediction
664 : const uint32_t prediction_buffer_stride, //input parameter, denotes the stride for the prediction ptr
665 : const EbBool skip,
666 : uint16_t dx, //output parameter, pointer to the prediction
667 : uint16_t dy //output parameter, pointer to the prediction
668 : )
669 : {
670 : // uint32_t row_index, colIndex;
671 0 : uint32_t toAboveOffset = (size << 1) + 1;
672 0 : uint32_t toAboveLeftOffset = (size << 1);
673 0 : uint32_t shiftToAboveLeft = 0;
674 0 : uint32_t toLeftOffset = 0;
675 0 : uint32_t rowStride = skip ? 2 : 1;
676 :
677 : uint32_t r, c;
678 : int32_t x, y, shift, val, base;
679 :
680 0 : const int32_t min_base_x = -(1);
681 0 : const int32_t frac_bits_x = 6;
682 0 : const int32_t frac_bits_y = 6;
683 0 : for (r = 0; r < size; ++r) {
684 0 : for (c = 0; c < size; ++c) {
685 0 : y = r + 1;
686 0 : x = (c << 6) - y * dx;
687 0 : base = x >> frac_bits_x;
688 0 : if (base >= min_base_x) {
689 0 : shift = ((x) & 0x3F) >> 1;
690 0 : shiftToAboveLeft = (base <= -1) ? -1 - base : 0;
691 0 : val = ref_samples[toAboveOffset + base + shiftToAboveLeft] * (32 - shift) + ref_samples[toAboveOffset + base + 1] * shift;
692 0 : val = ROUND_POWER_OF_TWO(val, 5);
693 : }
694 : else {
695 0 : x = c + 1;
696 0 : y = (r << 6) - x * dy;
697 0 : base = y >> frac_bits_y;
698 0 : shiftToAboveLeft = (base <= -1) ? toAboveLeftOffset - base : 0;
699 0 : shift = ((y) & 0x3F) >> 1;
700 0 : val = ref_samples[toLeftOffset + base + shiftToAboveLeft] * (32 - shift) + ref_samples[toLeftOffset + base + 1] * shift;
701 0 : val = ROUND_POWER_OF_TWO(val, 5);
702 : }
703 :
704 0 : dst[c] = (uint8_t)clip_pixel_highbd(val, 8);
705 : }
706 0 : dst += (rowStride* prediction_buffer_stride);
707 : }
708 :
709 0 : return;
710 : }
711 0 : void IntraModeAngular_AV1_Z3(
712 : const uint32_t size, //input parameter, denotes the size of the current PU
713 : uint8_t *ref_samples, //input parameter, pointer to the reference samples
714 : uint8_t *dst, //output parameter, pointer to the prediction
715 : const uint32_t prediction_buffer_stride, //input parameter, denotes the stride for the prediction ptr
716 : const EbBool skip,
717 : uint16_t dx, //output parameter, pointer to the prediction
718 : uint16_t dy //output parameter, pointer to the prediction
719 : )
720 : {
721 : // uint32_t row_index, colIndex;
722 : // uint32_t toAboveOffset = (size << 1) + 1 ;
723 0 : uint32_t toLeftOffset = 0;
724 0 : uint32_t rowStride = skip ? 2 : 1;
725 :
726 : uint32_t r, c;
727 : int32_t y, base, shift, val;
728 :
729 : (void)dx;
730 0 : assert(dx == 1);
731 0 : assert(dy > 0);
732 :
733 0 : const int32_t max_base_y = (size + size - 1);
734 0 : const int32_t frac_bits = 6;
735 0 : const int32_t base_inc = 1;
736 0 : y = dy;
737 0 : for (c = 0; c < size; ++c, y += dy) {
738 0 : base = y >> frac_bits;
739 0 : shift = ((y) & 0x3F) >> 1;
740 :
741 0 : for (r = 0; r < size; ++r, base += base_inc) {
742 0 : if (base < max_base_y) {
743 0 : val = ref_samples[toLeftOffset + base] * (32 - shift) + ref_samples[toLeftOffset + base + 1] * shift;
744 0 : val = ROUND_POWER_OF_TWO(val, 5);
745 :
746 0 : dst[r * (rowStride* prediction_buffer_stride) + c] = (uint8_t)clip_pixel_highbd(val, 8);
747 : }
748 : else {
749 0 : for (; r < size; ++r) dst[r * (rowStride* prediction_buffer_stride) + c] = ref_samples[toLeftOffset + max_base_y];
750 0 : break;
751 : }
752 : }
753 : }
754 :
755 0 : return;
756 : }
757 :
758 0 : void highbd_dc_predictor_16bit(
759 : EbBool is_left_availble,
760 : EbBool is_above_availble,
761 : const uint32_t size, //input parameter, denotes the size of the current PU
762 : uint16_t *ref_samples, //input parameter, pointer to the reference samples
763 : uint16_t *dst, //output parameter, pointer to the prediction
764 : const uint32_t prediction_buffer_stride, //input parameter, denotes the stride for the prediction ptr
765 : const EbBool skip) //skip half rows
766 : {
767 : //uint32_t sum = 0;
768 : // uint32_t index;
769 : uint32_t columnIndex, row_index;
770 : uint32_t writeIndex;
771 0 : uint32_t leftOffset = 0;
772 0 : uint32_t topOffset = (size << 1) + 1;
773 0 : uint32_t rowStride = skip ? 2 : 1;
774 :
775 : uint32_t i;
776 0 : uint32_t expected_dc, sum = 0;
777 0 : const int32_t count = size + size;
778 :
779 0 : if (is_left_availble && !is_above_availble) {
780 0 : for (i = 0; i < size; i++)
781 0 : sum += ref_samples[leftOffset + i];
782 0 : expected_dc = (sum + (size >> 1)) / size;
783 : }
784 0 : else if (is_above_availble && !is_left_availble) {
785 0 : for (i = 0; i < size; i++)
786 0 : sum += ref_samples[topOffset + i];
787 0 : expected_dc = (sum + (size >> 1)) / size;
788 : }
789 : else {
790 0 : for (i = 0; i < size; i++)
791 0 : sum += ref_samples[topOffset + i];
792 0 : for (i = 0; i < size; i++)
793 0 : sum += ref_samples[leftOffset + i];
794 0 : expected_dc = (sum + (count >> 1)) / count;
795 : }
796 :
797 : // expected_dc = (sum + (count >> 1)) / count;
798 :
799 : /*for (r = 0; r < size; r++) {
800 : writeIndex = row_index * prediction_buffer_stride;
801 :
802 : EB_MEMSET( dst, expected_dc, size);
803 :
804 : dst += rowStride* prediction_buffer_stride;
805 : }*/
806 :
807 : // Generate the prediction
808 0 : for (row_index = 0; row_index < size; row_index += rowStride) {
809 0 : writeIndex = row_index * prediction_buffer_stride;
810 0 : for (columnIndex = 0; columnIndex < size; ++columnIndex) {
811 0 : dst[writeIndex] = (uint16_t)expected_dc;
812 0 : ++writeIndex;
813 : }
814 : }
815 :
816 0 : return;
817 : }
818 : /* clang-format on */
819 0 : void IntraModePlanar_16bit(
820 : const uint32_t size, //input parameter, denotes the size of the current PU
821 : uint16_t *ref_samples, //input parameter, pointer to the reference samples
822 : uint16_t *dst, //output parameter, pointer to the prediction
823 : const uint32_t prediction_buffer_stride, //input parameter, denotes the stride for the prediction ptr
824 : const EbBool skip) //skip half rows
825 : {
826 0 : uint32_t rowStride = skip ? 2 : 1;
827 0 : uint32_t leftOffset = 0;
828 0 : uint32_t topOffset = (size << 1) + 1;
829 :
830 0 : const uint16_t below_pred = ref_samples[leftOffset + size - 1]; // estimated by bottom-left pixel
831 0 : const uint16_t right_pred = ref_samples[topOffset + size - 1]; // estimated by top-right pixel
832 0 : const uint8_t *const sm_weights_w = sm_weight_arrays + size;
833 0 : const uint8_t *const sm_weights_h = sm_weight_arrays + size;
834 : // scale = 2 * 2^sm_weight_log2_scale
835 0 : const int32_t log2_scale = 1 + sm_weight_log2_scale;
836 0 : const uint16_t scale = (1 << sm_weight_log2_scale);
837 : // sm_weights_sanity_checks(sm_weights_w, sm_weights_h, scale, log2_scale + sizeof(*dst));
838 : uint32_t r;
839 0 : for (r = 0; r < size; ++r) {
840 : uint32_t c;
841 0 : for (c = 0; c < size; ++c) {
842 0 : const uint16_t pixels[] = { ref_samples[topOffset + c], below_pred, ref_samples[leftOffset + r], right_pred };
843 0 : const uint8_t weights[] = { sm_weights_h[r], (uint8_t)(scale - sm_weights_h[r]),
844 0 : sm_weights_w[c], (uint8_t)(scale - sm_weights_w[c]) };
845 0 : uint32_t this_pred = 0;
846 : int32_t i;
847 0 : assert(scale >= sm_weights_h[r] && scale >= sm_weights_w[c]);
848 0 : for (i = 0; i < 4; ++i)
849 0 : this_pred += weights[i] * pixels[i];
850 0 : dst[c] = (uint16_t)divide_round(this_pred, log2_scale);
851 : }
852 0 : dst += rowStride * prediction_buffer_stride;
853 : }
854 :
855 0 : return;
856 : }
857 :
858 0 : void v_predictor_16bit(uint16_t *dst, const uint32_t stride, int32_t bw, int32_t bh,
859 : const uint16_t *ref_samples) {
860 : int32_t r;
861 : int32_t c;
862 :
863 0 : for (r = 0; r < bh; r++) {
864 0 : for (c = 0; c < bh; c++) {
865 0 : dst[c + r * stride] = ref_samples[bw + bh + 1 + c];
866 : //EB_MEMSET(dst, ref_samples[bw + bh + 1], bw);
867 : //dst += stride;
868 : }
869 : }
870 0 : }
871 :
872 0 : void h_predictor_16bit(uint16_t *dst, const uint32_t stride, int32_t bw, int32_t bh,
873 : const uint16_t *ref_samples) {
874 : int32_t r;
875 : //(void)above;
876 :
877 0 : for (r = 0; r < bh; r++) {
878 0 : memset16bit(dst, ref_samples[r], bw);
879 0 : dst += stride;
880 : }
881 :
882 0 : return;
883 : }
884 :
885 0 : void intra_mode_angular_av1_z1_16bit(
886 : const uint32_t size, //input parameter, denotes the size of the current PU
887 : uint16_t *ref_samples, //input parameter, pointer to the reference samples
888 : uint16_t *dst, //output parameter, pointer to the prediction
889 : const uint32_t prediction_buffer_stride, //input parameter, denotes the stride for the prediction ptr
890 : const EbBool skip,
891 : uint16_t dx, //output parameter, pointer to the prediction
892 : uint16_t dy, //output parameter, pointer to the prediction
893 : uint16_t bd)
894 :
895 : {
896 : (void)dy;
897 : // uint32_t row_index, colIndex;
898 0 : uint32_t toAboveOffset = (size << 1) + 1;
899 0 : uint32_t rowStride = skip ? 2 : 1;
900 :
901 : uint32_t r, c;
902 : int32_t x, base, shift, val;
903 0 : const int32_t max_base_x = ((size + size) - 1);
904 0 : const int32_t frac_bits = 6;
905 0 : const int32_t base_inc = 1;
906 :
907 0 : x = dx;
908 :
909 0 : for (r = 0; r < size; ++r, dst += (rowStride* prediction_buffer_stride), x += dx) {
910 0 : base = x >> frac_bits;
911 0 : shift = ((x) & 0x3F) >> 1;
912 :
913 0 : if (base >= max_base_x) {
914 0 : for (uint32_t i = r; i < size; ++i) {
915 0 : memset16bit(dst, ref_samples[toAboveOffset + max_base_x], size);
916 0 : dst += rowStride * prediction_buffer_stride;
917 : }
918 0 : return;
919 : }
920 :
921 0 : for (c = 0; c < size; ++c, base += base_inc) {
922 0 : if (base < max_base_x) {
923 0 : val = ref_samples[toAboveOffset + base] * (32 - shift) + ref_samples[toAboveOffset + base + 1] * shift;
924 0 : val = ROUND_POWER_OF_TWO(val, 5);
925 0 : dst[c] = clip_pixel_highbd(val, bd);
926 : }
927 : else
928 0 : dst[c] = ref_samples[toAboveOffset + max_base_x];
929 : }
930 : }
931 :
932 0 : return;
933 : }
934 0 : void intra_mode_angular_av1_z2_16bit(
935 : const uint32_t size, //input parameter, denotes the size of the current PU
936 : uint16_t *ref_samples, //input parameter, pointer to the reference samples
937 : uint16_t *dst, //output parameter, pointer to the prediction
938 : const uint32_t prediction_buffer_stride, //input parameter, denotes the stride for the prediction ptr
939 : const EbBool skip,
940 : uint16_t dx, //output parameter, pointer to the prediction
941 : uint16_t dy, //output parameter, pointer to the prediction
942 : uint16_t bd)
943 : {
944 : // uint32_t row_index, colIndex;
945 0 : uint32_t toAboveOffset = (size << 1) + 1;
946 0 : uint32_t toAboveLeftOffset = (size << 1);
947 0 : uint32_t shiftToAboveLeft = 0;
948 0 : uint32_t toLeftOffset = 0;
949 0 : uint32_t rowStride = skip ? 2 : 1;
950 :
951 : uint32_t r, c;
952 : int32_t x, y, shift, val, base;
953 :
954 0 : const int32_t min_base_x = -(1);
955 0 : const int32_t frac_bits_x = 6;
956 0 : const int32_t frac_bits_y = 6;
957 :
958 0 : for (r = 0; r < size; ++r) {
959 0 : for (c = 0; c < size; ++c) {
960 0 : y = r + 1;
961 0 : x = (c << 6) - y * dx;
962 0 : base = x >> frac_bits_x;
963 0 : if (base >= min_base_x) {
964 0 : shift = ((x) & 0x3F) >> 1;
965 0 : shiftToAboveLeft = (base <= -1) ? -1 - base : 0;
966 0 : val = ref_samples[toAboveOffset + base + shiftToAboveLeft] * (32 - shift) + ref_samples[toAboveOffset + base + 1] * shift;
967 0 : val = ROUND_POWER_OF_TWO(val, 5);
968 : }
969 : else {
970 0 : x = c + 1;
971 0 : y = (r << 6) - x * dy;
972 0 : base = y >> frac_bits_y;
973 0 : shiftToAboveLeft = (base <= -1) ? toAboveLeftOffset - base : 0;
974 0 : shift = ((y) & 0x3F) >> 1;
975 0 : val = ref_samples[toLeftOffset + base + shiftToAboveLeft] * (32 - shift) + ref_samples[toLeftOffset + base + 1] * shift;
976 0 : val = ROUND_POWER_OF_TWO(val, 5);
977 : }
978 0 : dst[c] = clip_pixel_highbd(val, bd);
979 : }
980 0 : dst += (rowStride* prediction_buffer_stride);
981 : }
982 :
983 0 : return;
984 : }
985 0 : void intra_mode_angular_av1_z3_16bit(
986 : const uint32_t size, //input parameter, denotes the size of the current PU
987 : uint16_t *ref_samples, //input parameter, pointer to the reference samples
988 : uint16_t *dst, //output parameter, pointer to the prediction
989 : const uint32_t prediction_buffer_stride, //input parameter, denotes the stride for the prediction ptr
990 : const EbBool skip,
991 : uint16_t dx, //output parameter, pointer to the prediction
992 : uint16_t dy, //output parameter, pointer to the prediction
993 : uint16_t bd)
994 : {
995 : // uint32_t row_index, colIndex;
996 : // uint32_t toAboveOffset = (size << 1) + 1;
997 0 : uint32_t toLeftOffset = 0;
998 0 : uint32_t rowStride = skip ? 2 : 1;
999 :
1000 : uint32_t r, c;
1001 : int32_t y, base, shift, val;
1002 :
1003 : (void)dx;
1004 0 : assert(dx == 1);
1005 0 : assert(dy > 0);
1006 :
1007 0 : const int32_t max_base_y = (size + size - 1);
1008 0 : const int32_t frac_bits = 6;
1009 0 : const int32_t base_inc = 1;
1010 0 : y = dy;
1011 0 : for (c = 0; c < size; ++c, y += dy) {
1012 0 : base = y >> frac_bits;
1013 0 : shift = ((y) & 0x3F) >> 1;
1014 :
1015 0 : for (r = 0; r < size; ++r, base += base_inc) {
1016 0 : if (base < max_base_y) {
1017 0 : val = ref_samples[toLeftOffset + base] * (32 - shift) + ref_samples[toLeftOffset + base + 1] * shift;
1018 0 : val = ROUND_POWER_OF_TWO(val, 5);
1019 0 : dst[r * (rowStride* prediction_buffer_stride) + c] = clip_pixel_highbd(val, bd);
1020 : }
1021 : else {
1022 0 : for (; r < size; ++r) dst[r * (rowStride* prediction_buffer_stride) + c] = ref_samples[toLeftOffset + max_base_y];
1023 0 : break;
1024 : }
1025 : }
1026 : }
1027 :
1028 0 : return;
1029 : }
1030 :
1031 0 : void intra_open_loop_reference_samples_dctor(EbPtr p)
1032 : {
1033 0 : IntraReferenceSamplesOpenLoop *obj = (IntraReferenceSamplesOpenLoop*)p;
1034 0 : obj->y_intra_reference_array_reverse--;
1035 0 : EB_FREE(obj->y_intra_reference_array_reverse);
1036 0 : EB_FREE(obj->y_intra_reference_array);
1037 0 : }
1038 : /**********************************************
1039 : * Intra Reference Samples Ctor
1040 : **********************************************/
1041 0 : EbErrorType intra_open_loop_reference_samples_ctor(
1042 : IntraReferenceSamplesOpenLoop *context_ptr)
1043 : {
1044 0 : context_ptr->dctor = intra_open_loop_reference_samples_dctor;
1045 0 : EB_MALLOC(context_ptr->y_intra_reference_array, (4 * BLOCK_SIZE_64 + 1));
1046 :
1047 0 : EB_MALLOC(context_ptr->y_intra_reference_array_reverse, (4 * BLOCK_SIZE_64 + 2));
1048 :
1049 0 : context_ptr->y_intra_reference_array_reverse++;
1050 :
1051 0 : return EB_ErrorNone;
1052 : }
1053 :
1054 527345 : void cfl_luma_subsampling_420_lbd_c(
1055 : const uint8_t *input,
1056 : int32_t input_stride, int16_t *output_q3,
1057 : int32_t width, int32_t height)
1058 : {
1059 3793070 : for (int32_t j = 0; j < height; j += 2) {
1060 24921600 : for (int32_t i = 0; i < width; i += 2) {
1061 21655900 : const int32_t bot = i + input_stride;
1062 21655900 : output_q3[i >> 1] =
1063 21655900 : (input[i] + input[i + 1] + input[bot] + input[bot + 1]) << 1;
1064 : }
1065 3265730 : input += input_stride << 1;
1066 3265730 : output_q3 += CFL_BUF_LINE;
1067 : }
1068 527345 : }
1069 0 : void cfl_luma_subsampling_420_hbd_c(
1070 : const uint16_t *input,
1071 : int32_t input_stride, int16_t *output_q3,
1072 : int32_t width, int32_t height)
1073 : {
1074 0 : for (int32_t j = 0; j < height; j += 2) {
1075 0 : for (int32_t i = 0; i < width; i += 2) {
1076 0 : const int32_t bot = i + input_stride;
1077 0 : output_q3[i >> 1] =
1078 0 : (input[i] + input[i + 1] + input[bot] + input[bot + 1]) << 1;
1079 : }
1080 0 : input += input_stride << 1;
1081 0 : output_q3 += CFL_BUF_LINE;
1082 : }
1083 0 : }
1084 1055 : void eb_subtract_average_c(
1085 : int16_t *pred_buf_q3,
1086 : int32_t width,
1087 : int32_t height,
1088 : int32_t round_offset,
1089 : int32_t num_pel_log2) {
1090 1055 : int32_t sum_q3 = 0;
1091 1055 : int16_t *pred_buf = pred_buf_q3;
1092 6747 : for (int32_t j = 0; j < height; j++) {
1093 : // assert(pred_buf_q3 + tx_width <= cfl->pred_buf_q3 + CFL_BUF_SQUARE);
1094 39276 : for (int32_t i = 0; i < width; i++)
1095 33584 : sum_q3 += pred_buf[i];
1096 5692 : pred_buf += CFL_BUF_LINE;
1097 : }
1098 1055 : const int32_t avg_q3 = (sum_q3 + round_offset) >> num_pel_log2;
1099 : // Loss is never more than 1/2 (in Q3)
1100 : // assert(abs((avg_q3 * (1 << num_pel_log2)) - sum_q3) <= 1 << num_pel_log2 >>
1101 : // 1);
1102 6747 : for (int32_t j = 0; j < height; j++) {
1103 39276 : for (int32_t i = 0; i < width; i++)
1104 33584 : pred_buf_q3[i] -= (int16_t)(avg_q3);
1105 5692 : pred_buf_q3 += CFL_BUF_LINE;
1106 : }
1107 1055 : }
1108 :
1109 2110 : CFL_SUB_AVG_FN(c)
1110 :
1111 0 : void eb_cfl_predict_lbd_c(
1112 : const int16_t *pred_buf_q3,
1113 : uint8_t *pred,// AMIR ADDED
1114 : int32_t pred_stride,
1115 : uint8_t *dst,// AMIR changed to 8 bit
1116 : int32_t dst_stride,
1117 : int32_t alpha_q3,
1118 : int32_t bit_depth,
1119 : int32_t width,
1120 : int32_t height) {
1121 0 : for (int32_t j = 0; j < height; j++) {
1122 0 : for (int32_t i = 0; i < width; i++) {
1123 0 : dst[i] = (uint8_t)clip_pixel_highbd(
1124 0 : get_scaled_luma_q0(alpha_q3, pred_buf_q3[i]) + (int16_t)pred[i], bit_depth);
1125 : }
1126 0 : dst += dst_stride;
1127 0 : pred += pred_stride;
1128 0 : pred_buf_q3 += CFL_BUF_LINE;
1129 : }
1130 0 : }
1131 0 : void eb_cfl_predict_hbd_c(
1132 : const int16_t *pred_buf_q3,
1133 : uint16_t *pred,// AMIR ADDED
1134 : int32_t pred_stride,
1135 : uint16_t *dst,// AMIR changed to 8 bit
1136 : int32_t dst_stride,
1137 : int32_t alpha_q3,
1138 : int32_t bit_depth,
1139 : int32_t width,
1140 : int32_t height) {
1141 0 : for (int32_t j = 0; j < height; j++) {
1142 0 : for (int32_t i = 0; i < width; i++) {
1143 0 : dst[i] = clip_pixel_highbd(
1144 0 : get_scaled_luma_q0(alpha_q3, pred_buf_q3[i]) + (int16_t)pred[i], bit_depth);
1145 : }
1146 0 : dst += dst_stride;
1147 0 : pred += pred_stride;
1148 0 : pred_buf_q3 += CFL_BUF_LINE;
1149 : }
1150 0 : }
1151 :
1152 : const uint8_t extend_modes[INTRA_MODES] = {
1153 : NEED_ABOVE | NEED_LEFT, // DC
1154 : NEED_ABOVE, // V
1155 : NEED_LEFT, // H
1156 : NEED_ABOVE | NEED_ABOVERIGHT, // D45
1157 : NEED_LEFT | NEED_ABOVE | NEED_ABOVELEFT, // D135
1158 : NEED_LEFT | NEED_ABOVE | NEED_ABOVELEFT, // D113
1159 : NEED_LEFT | NEED_ABOVE | NEED_ABOVELEFT, // D157
1160 : NEED_LEFT | NEED_BOTTOMLEFT, // D203
1161 : NEED_ABOVE | NEED_ABOVERIGHT, // D67
1162 : NEED_LEFT | NEED_ABOVE, // SMOOTH
1163 : NEED_LEFT | NEED_ABOVE, // SMOOTH_V
1164 : NEED_LEFT | NEED_ABOVE, // SMOOTH_H
1165 : NEED_LEFT | NEED_ABOVE | NEED_ABOVELEFT, // PAETH
1166 : };
1167 :
1168 : // Tables to store if the top-right reference pixels are available. The flags
1169 : // are represented with bits, packed into 8-bit integers. E.g., for the 32x32
1170 : // blocks in a 128x128 superblock, the index of the "o" block is 10 (in raster
1171 : // order), so its flag is stored at the 3rd bit of the 2nd entry in the table,
1172 : // i.e. (table[10 / 8] >> (10 % 8)) & 1.
1173 : // . . . .
1174 : // . . . .
1175 : // . . o .
1176 : // . . . .
1177 : static uint8_t has_tr_4x4[128] = {
1178 : 255, 255, 255, 255, 85, 85, 85, 85, 119, 119, 119, 119, 85, 85, 85, 85,
1179 : 127, 127, 127, 127, 85, 85, 85, 85, 119, 119, 119, 119, 85, 85, 85, 85,
1180 : 255, 127, 255, 127, 85, 85, 85, 85, 119, 119, 119, 119, 85, 85, 85, 85,
1181 : 127, 127, 127, 127, 85, 85, 85, 85, 119, 119, 119, 119, 85, 85, 85, 85,
1182 : 255, 255, 255, 127, 85, 85, 85, 85, 119, 119, 119, 119, 85, 85, 85, 85,
1183 : 127, 127, 127, 127, 85, 85, 85, 85, 119, 119, 119, 119, 85, 85, 85, 85,
1184 : 255, 127, 255, 127, 85, 85, 85, 85, 119, 119, 119, 119, 85, 85, 85, 85,
1185 : 127, 127, 127, 127, 85, 85, 85, 85, 119, 119, 119, 119, 85, 85, 85, 85,
1186 : };
1187 : static uint8_t has_tr_4x8[64] = {
1188 : 255, 255, 255, 255, 119, 119, 119, 119, 127, 127, 127, 127, 119,
1189 : 119, 119, 119, 255, 127, 255, 127, 119, 119, 119, 119, 127, 127,
1190 : 127, 127, 119, 119, 119, 119, 255, 255, 255, 127, 119, 119, 119,
1191 : 119, 127, 127, 127, 127, 119, 119, 119, 119, 255, 127, 255, 127,
1192 : 119, 119, 119, 119, 127, 127, 127, 127, 119, 119, 119, 119,
1193 : };
1194 : static uint8_t has_tr_8x4[64] = {
1195 : 255, 255, 0, 0, 85, 85, 0, 0, 119, 119, 0, 0, 85, 85, 0, 0,
1196 : 127, 127, 0, 0, 85, 85, 0, 0, 119, 119, 0, 0, 85, 85, 0, 0,
1197 : 255, 127, 0, 0, 85, 85, 0, 0, 119, 119, 0, 0, 85, 85, 0, 0,
1198 : 127, 127, 0, 0, 85, 85, 0, 0, 119, 119, 0, 0, 85, 85, 0, 0,
1199 : };
1200 : static uint8_t has_tr_8x8[32] = {
1201 : 255, 255, 85, 85, 119, 119, 85, 85, 127, 127, 85, 85, 119, 119, 85, 85,
1202 : 255, 127, 85, 85, 119, 119, 85, 85, 127, 127, 85, 85, 119, 119, 85, 85,
1203 : };
1204 : static uint8_t has_tr_8x16[16] = {
1205 : 255, 255, 119, 119, 127, 127, 119, 119,
1206 : 255, 127, 119, 119, 127, 127, 119, 119,
1207 : };
1208 : static uint8_t has_tr_16x8[16] = {
1209 : 255, 0, 85, 0, 119, 0, 85, 0, 127, 0, 85, 0, 119, 0, 85, 0,
1210 : };
1211 : static uint8_t has_tr_16x16[8] = {
1212 : 255, 85, 119, 85, 127, 85, 119, 85,
1213 : };
1214 : static uint8_t has_tr_16x32[4] = { 255, 119, 127, 119 };
1215 : static uint8_t has_tr_32x16[4] = { 15, 5, 7, 5 };
1216 : static uint8_t has_tr_32x32[2] = { 95, 87 };
1217 : static uint8_t has_tr_32x64[1] = { 127 };
1218 : static uint8_t has_tr_64x32[1] = { 19 };
1219 : static uint8_t has_tr_64x64[1] = { 7 };
1220 : static uint8_t has_tr_64x128[1] = { 3 };
1221 : static uint8_t has_tr_128x64[1] = { 1 };
1222 : static uint8_t has_tr_128x128[1] = { 1 };
1223 : static uint8_t has_tr_4x16[32] = {
1224 : 255, 255, 255, 255, 127, 127, 127, 127, 255, 127, 255,
1225 : 127, 127, 127, 127, 127, 255, 255, 255, 127, 127, 127,
1226 : 127, 127, 255, 127, 255, 127, 127, 127, 127, 127,
1227 : };
1228 : static uint8_t has_tr_16x4[32] = {
1229 : 255, 0, 0, 0, 85, 0, 0, 0, 119, 0, 0, 0, 85, 0, 0, 0,
1230 : 127, 0, 0, 0, 85, 0, 0, 0, 119, 0, 0, 0, 85, 0, 0, 0,
1231 : };
1232 : static uint8_t has_tr_8x32[8] = {
1233 : 255, 255, 127, 127, 255, 127, 127, 127,
1234 : };
1235 : static uint8_t has_tr_32x8[8] = {
1236 : 15, 0, 5, 0, 7, 0, 5, 0,
1237 : };
1238 : static uint8_t has_tr_16x64[2] = { 255, 127 };
1239 : static uint8_t has_tr_64x16[2] = { 3, 1 };
1240 :
1241 : const uint8_t *const has_tr_tables[BlockSizeS_ALL] = {
1242 : // 4X4
1243 : has_tr_4x4,
1244 : // 4X8, 8X4, 8X8
1245 : has_tr_4x8, has_tr_8x4, has_tr_8x8,
1246 : // 8X16, 16X8, 16X16
1247 : has_tr_8x16, has_tr_16x8, has_tr_16x16,
1248 : // 16X32, 32X16, 32X32
1249 : has_tr_16x32, has_tr_32x16, has_tr_32x32,
1250 : // 32X64, 64X32, 64X64
1251 : has_tr_32x64, has_tr_64x32, has_tr_64x64,
1252 : // 64x128, 128x64, 128x128
1253 : has_tr_64x128, has_tr_128x64, has_tr_128x128,
1254 : // 4x16, 16x4, 8x32
1255 : has_tr_4x16, has_tr_16x4, has_tr_8x32,
1256 : // 32x8, 16x64, 64x16
1257 : has_tr_32x8, has_tr_16x64, has_tr_64x16
1258 : };
1259 :
1260 : static uint8_t has_tr_vert_8x8[32] = {
1261 : 255, 255, 0, 0, 119, 119, 0, 0, 127, 127, 0, 0, 119, 119, 0, 0,
1262 : 255, 127, 0, 0, 119, 119, 0, 0, 127, 127, 0, 0, 119, 119, 0, 0,
1263 : };
1264 : static uint8_t has_tr_vert_16x16[8] = {
1265 : 255, 0, 119, 0, 127, 0, 119, 0,
1266 : };
1267 : static uint8_t has_tr_vert_32x32[2] = { 15, 7 };
1268 : static uint8_t has_tr_vert_64x64[1] = { 3 };
1269 :
1270 : // The _vert_* tables are like the ordinary tables above, but describe the
1271 : // order we visit square blocks when doing a PARTITION_VERT_A or
1272 : // PARTITION_VERT_B. This is the same order as normal except for on the last
1273 : // split where we go vertically (TL, BL, TR, BR). We treat the rectangular block
1274 : // as a pair of squares, which means that these tables work correctly for both
1275 : // mixed vertical partition types.
1276 : //
1277 : // There are tables for each of the square sizes. Vertical rectangles (like
1278 : // BLOCK_16X32) use their respective "non-vert" table
1279 : const uint8_t *const has_tr_vert_tables[BlockSizeS] = {
1280 : // 4X4
1281 : NULL,
1282 : // 4X8, 8X4, 8X8
1283 : has_tr_4x8, NULL, has_tr_vert_8x8,
1284 : // 8X16, 16X8, 16X16
1285 : has_tr_8x16, NULL, has_tr_vert_16x16,
1286 : // 16X32, 32X16, 32X32
1287 : has_tr_16x32, NULL, has_tr_vert_32x32,
1288 : // 32X64, 64X32, 64X64
1289 : has_tr_32x64, NULL, has_tr_vert_64x64,
1290 : // 64x128, 128x64, 128x128
1291 : has_tr_64x128, NULL, has_tr_128x128
1292 : };
1293 :
1294 26333000 : static const uint8_t *get_has_tr_table(PartitionType partition,
1295 : BlockSize bsize) {
1296 26333000 : const uint8_t *ret = NULL;
1297 : // If this is a mixed vertical partition, look up bsize in orders_vert.
1298 26333000 : if (partition == PARTITION_VERT_A || partition == PARTITION_VERT_B) {
1299 5524070 : assert(bsize < BlockSizeS);
1300 5524070 : ret = has_tr_vert_tables[bsize];
1301 : }
1302 : else
1303 20809000 : ret = has_tr_tables[bsize];
1304 26333000 : assert(ret);
1305 26333000 : return ret;
1306 : }
1307 :
1308 45971200 : int32_t intra_has_top_right(BlockSize sb_size, BlockSize bsize, int32_t mi_row,
1309 : int32_t mi_col, int32_t top_available, int32_t right_available,
1310 : PartitionType partition, TxSize txsz, int32_t row_off,
1311 : int32_t col_off, int32_t ss_x, int32_t ss_y) {
1312 45971200 : if (!top_available || !right_available) return 0;
1313 :
1314 42659600 : const int32_t bw_unit = block_size_wide[bsize] >> tx_size_wide_log2[0];
1315 42659600 : const int32_t plane_bw_unit = AOMMAX(bw_unit >> ss_x, 1);
1316 42659600 : const int32_t top_right_count_unit = tx_size_wide_unit[txsz];
1317 :
1318 42659600 : if (row_off > 0) { // Just need to check if enough pixels on the right.
1319 590170 : if (block_size_wide[bsize] > block_size_wide[BLOCK_64X64]) {
1320 : // Special case: For 128x128 blocks, the transform unit whose
1321 : // top-right corner is at the center of the block does in fact have
1322 : // pixels available at its top-right corner.
1323 0 : if (row_off == mi_size_high[BLOCK_64X64] >> ss_y &&
1324 0 : col_off + top_right_count_unit == mi_size_wide[BLOCK_64X64] >> ss_x) {
1325 0 : return 1;
1326 : }
1327 0 : const int32_t plane_bw_unit_64 = mi_size_wide[BLOCK_64X64] >> ss_x;
1328 0 : const int32_t col_off_64 = col_off % plane_bw_unit_64;
1329 0 : return col_off_64 + top_right_count_unit < plane_bw_unit_64;
1330 : }
1331 590170 : return col_off + top_right_count_unit < plane_bw_unit;
1332 : }
1333 : else {
1334 : // All top-right pixels are in the block above, which is already available.
1335 42069400 : if (col_off + top_right_count_unit < plane_bw_unit) return 1;
1336 :
1337 41628800 : const int32_t bw_in_mi_log2 = mi_size_wide_log2[bsize];
1338 41628800 : const int32_t bh_in_mi_log2 = mi_size_high_log2[bsize];
1339 41628800 : const int32_t sb_mi_size = mi_size_high[sb_size];
1340 41628800 : const int32_t blk_row_in_sb = (mi_row & (sb_mi_size - 1)) >> bh_in_mi_log2;
1341 41628800 : const int32_t blk_col_in_sb = (mi_col & (sb_mi_size - 1)) >> bw_in_mi_log2;
1342 :
1343 : // Top row of superblock: so top-right pixels are in the top and/or
1344 : // top-right superblocks, both of which are already available.
1345 41628800 : if (blk_row_in_sb == 0) return 1;
1346 :
1347 : // Rightmost column of superblock (and not the top row): so top-right pixels
1348 : // fall in the right superblock, which is not available yet.
1349 32032900 : if (((blk_col_in_sb + 1) << bw_in_mi_log2) >= sb_mi_size)
1350 5722120 : return 0;
1351 : // General case (neither top row nor rightmost column): check if the
1352 : // top-right block is coded before the current block.
1353 26310800 : const int32_t this_blk_index =
1354 26310800 : ((blk_row_in_sb + 0) << (MAX_MIB_SIZE_LOG2 - bw_in_mi_log2)) +
1355 : blk_col_in_sb + 0;
1356 26310800 : const int32_t idx1 = this_blk_index / 8;
1357 26310800 : const int32_t idx2 = this_blk_index % 8;
1358 26310800 : const uint8_t *has_tr_table = get_has_tr_table(partition, bsize);
1359 26333400 : return (has_tr_table[idx1] >> idx2) & 1;
1360 : }
1361 : }
1362 :
1363 : // Similar to the has_tr_* tables, but store if the bottom-left reference
1364 : // pixels are available.
1365 : static uint8_t has_bl_4x4[128] = {
1366 : 84, 85, 85, 85, 16, 17, 17, 17, 84, 85, 85, 85, 0, 1, 1, 1, 84, 85, 85,
1367 : 85, 16, 17, 17, 17, 84, 85, 85, 85, 0, 0, 1, 0, 84, 85, 85, 85, 16, 17,
1368 : 17, 17, 84, 85, 85, 85, 0, 1, 1, 1, 84, 85, 85, 85, 16, 17, 17, 17, 84,
1369 : 85, 85, 85, 0, 0, 0, 0, 84, 85, 85, 85, 16, 17, 17, 17, 84, 85, 85, 85,
1370 : 0, 1, 1, 1, 84, 85, 85, 85, 16, 17, 17, 17, 84, 85, 85, 85, 0, 0, 1,
1371 : 0, 84, 85, 85, 85, 16, 17, 17, 17, 84, 85, 85, 85, 0, 1, 1, 1, 84, 85,
1372 : 85, 85, 16, 17, 17, 17, 84, 85, 85, 85, 0, 0, 0, 0,
1373 : };
1374 : static uint8_t has_bl_4x8[64] = {
1375 : 16, 17, 17, 17, 0, 1, 1, 1, 16, 17, 17, 17, 0, 0, 1, 0,
1376 : 16, 17, 17, 17, 0, 1, 1, 1, 16, 17, 17, 17, 0, 0, 0, 0,
1377 : 16, 17, 17, 17, 0, 1, 1, 1, 16, 17, 17, 17, 0, 0, 1, 0,
1378 : 16, 17, 17, 17, 0, 1, 1, 1, 16, 17, 17, 17, 0, 0, 0, 0,
1379 : };
1380 : static uint8_t has_bl_8x4[64] = {
1381 : 254, 255, 84, 85, 254, 255, 16, 17, 254, 255, 84, 85, 254, 255, 0, 1,
1382 : 254, 255, 84, 85, 254, 255, 16, 17, 254, 255, 84, 85, 254, 255, 0, 0,
1383 : 254, 255, 84, 85, 254, 255, 16, 17, 254, 255, 84, 85, 254, 255, 0, 1,
1384 : 254, 255, 84, 85, 254, 255, 16, 17, 254, 255, 84, 85, 254, 255, 0, 0,
1385 : };
1386 : static uint8_t has_bl_8x8[32] = {
1387 : 84, 85, 16, 17, 84, 85, 0, 1, 84, 85, 16, 17, 84, 85, 0, 0,
1388 : 84, 85, 16, 17, 84, 85, 0, 1, 84, 85, 16, 17, 84, 85, 0, 0,
1389 : };
1390 : static uint8_t has_bl_8x16[16] = {
1391 : 16, 17, 0, 1, 16, 17, 0, 0, 16, 17, 0, 1, 16, 17, 0, 0,
1392 : };
1393 : static uint8_t has_bl_16x8[16] = {
1394 : 254, 84, 254, 16, 254, 84, 254, 0, 254, 84, 254, 16, 254, 84, 254, 0,
1395 : };
1396 : static uint8_t has_bl_16x16[8] = {
1397 : 84, 16, 84, 0, 84, 16, 84, 0,
1398 : };
1399 : static uint8_t has_bl_16x32[4] = { 16, 0, 16, 0 };
1400 : static uint8_t has_bl_32x16[4] = { 78, 14, 78, 14 };
1401 : static uint8_t has_bl_32x32[2] = { 4, 4 };
1402 : static uint8_t has_bl_32x64[1] = { 0 };
1403 : static uint8_t has_bl_64x32[1] = { 34 };
1404 : static uint8_t has_bl_64x64[1] = { 0 };
1405 : static uint8_t has_bl_64x128[1] = { 0 };
1406 : static uint8_t has_bl_128x64[1] = { 0 };
1407 : static uint8_t has_bl_128x128[1] = { 0 };
1408 : static uint8_t has_bl_4x16[32] = {
1409 : 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0,
1410 : 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0,
1411 : };
1412 : static uint8_t has_bl_16x4[32] = {
1413 : 254, 254, 254, 84, 254, 254, 254, 16, 254, 254, 254, 84, 254, 254, 254, 0,
1414 : 254, 254, 254, 84, 254, 254, 254, 16, 254, 254, 254, 84, 254, 254, 254, 0,
1415 : };
1416 : static uint8_t has_bl_8x32[8] = {
1417 : 0, 1, 0, 0, 0, 1, 0, 0,
1418 : };
1419 : static uint8_t has_bl_32x8[8] = {
1420 : 238, 78, 238, 14, 238, 78, 238, 14,
1421 : };
1422 : static uint8_t has_bl_16x64[2] = { 0, 0 };
1423 : static uint8_t has_bl_64x16[2] = { 42, 42 };
1424 :
1425 : const uint8_t *const has_bl_tables[BlockSizeS_ALL] = {
1426 : // 4X4
1427 : has_bl_4x4,
1428 : // 4X8, 8X4, 8X8
1429 : has_bl_4x8, has_bl_8x4, has_bl_8x8,
1430 : // 8X16, 16X8, 16X16
1431 : has_bl_8x16, has_bl_16x8, has_bl_16x16,
1432 : // 16X32, 32X16, 32X32
1433 : has_bl_16x32, has_bl_32x16, has_bl_32x32,
1434 : // 32X64, 64X32, 64X64
1435 : has_bl_32x64, has_bl_64x32, has_bl_64x64,
1436 : // 64x128, 128x64, 128x128
1437 : has_bl_64x128, has_bl_128x64, has_bl_128x128,
1438 : // 4x16, 16x4, 8x32
1439 : has_bl_4x16, has_bl_16x4, has_bl_8x32,
1440 : // 32x8, 16x64, 64x16
1441 : has_bl_32x8, has_bl_16x64, has_bl_64x16
1442 : };
1443 :
1444 : static uint8_t has_bl_vert_8x8[32] = {
1445 : 254, 255, 16, 17, 254, 255, 0, 1, 254, 255, 16, 17, 254, 255, 0, 0,
1446 : 254, 255, 16, 17, 254, 255, 0, 1, 254, 255, 16, 17, 254, 255, 0, 0,
1447 : };
1448 : static uint8_t has_bl_vert_16x16[8] = {
1449 : 254, 16, 254, 0, 254, 16, 254, 0,
1450 : };
1451 : static uint8_t has_bl_vert_32x32[2] = { 14, 14 };
1452 : static uint8_t has_bl_vert_64x64[1] = { 2 };
1453 :
1454 : // The _vert_* tables are like the ordinary tables above, but describe the
1455 : // order we visit square blocks when doing a PARTITION_VERT_A or
1456 : // PARTITION_VERT_B. This is the same order as normal except for on the last
1457 : // split where we go vertically (TL, BL, TR, BR). We treat the rectangular block
1458 : // as a pair of squares, which means that these tables work correctly for both
1459 : // mixed vertical partition types.
1460 : //
1461 : // There are tables for each of the square sizes. Vertical rectangles (like
1462 : // BLOCK_16X32) use their respective "non-vert" table
1463 : const uint8_t *const has_bl_vert_tables[BlockSizeS] = {
1464 : // 4X4
1465 : NULL,
1466 : // 4X8, 8X4, 8X8
1467 : has_bl_4x8, NULL, has_bl_vert_8x8,
1468 : // 8X16, 16X8, 16X16
1469 : has_bl_8x16, NULL, has_bl_vert_16x16,
1470 : // 16X32, 32X16, 32X32
1471 : has_bl_16x32, NULL, has_bl_vert_32x32,
1472 : // 32X64, 64X32, 64X64
1473 : has_bl_32x64, NULL, has_bl_vert_64x64,
1474 : // 64x128, 128x64, 128x128
1475 : has_bl_64x128, NULL, has_bl_128x128
1476 : };
1477 :
1478 26520300 : static const uint8_t *get_has_bl_table(PartitionType partition,
1479 : BlockSize bsize) {
1480 26520300 : const uint8_t *ret = NULL;
1481 : // If this is a mixed vertical partition, look up bsize in orders_vert.
1482 26520300 : if (partition == PARTITION_VERT_A || partition == PARTITION_VERT_B) {
1483 5145240 : assert(bsize < BlockSizeS);
1484 5145240 : ret = has_bl_vert_tables[bsize];
1485 : }
1486 : else
1487 21375100 : ret = has_bl_tables[bsize];
1488 26520300 : assert(ret);
1489 26520300 : return ret;
1490 : }
1491 :
1492 45969900 : int32_t intra_has_bottom_left(BlockSize sb_size, BlockSize bsize, int32_t mi_row,
1493 : int32_t mi_col, int32_t bottom_available, int32_t left_available,
1494 : PartitionType partition, TxSize txsz, int32_t row_off,
1495 : int32_t col_off, int32_t ss_x, int32_t ss_y) {
1496 45969900 : if (!bottom_available || !left_available) return 0;
1497 :
1498 : // Special case for 128x* blocks, when col_off is half the block width.
1499 : // This is needed because 128x* superblocks are divided into 64x* blocks in
1500 : // raster order
1501 41762800 : if (block_size_wide[bsize] > block_size_wide[BLOCK_64X64] && col_off > 0) {
1502 0 : const int32_t plane_bw_unit_64 = mi_size_wide[BLOCK_64X64] >> ss_x;
1503 0 : const int32_t col_off_64 = col_off % plane_bw_unit_64;
1504 0 : if (col_off_64 == 0) {
1505 : // We are at the left edge of top-right or bottom-right 64x* block.
1506 0 : const int32_t plane_bh_unit_64 = mi_size_high[BLOCK_64X64] >> ss_y;
1507 0 : const int32_t row_off_64 = row_off % plane_bh_unit_64;
1508 0 : const int32_t plane_bh_unit =
1509 0 : AOMMIN(mi_size_high[bsize] >> ss_y, plane_bh_unit_64);
1510 : // Check if all bottom-left pixels are in the left 64x* block (which is
1511 : // already coded).
1512 0 : return row_off_64 + tx_size_high_unit[txsz] < plane_bh_unit;
1513 : }
1514 : }
1515 :
1516 41762800 : if (col_off > 0) {
1517 : // Bottom-left pixels are in the bottom-left block, which is not available.
1518 594624 : return 0;
1519 : }
1520 : else {
1521 41168100 : const int32_t bh_unit = block_size_high[bsize] >> tx_size_high_log2[0];
1522 41168100 : const int32_t plane_bh_unit = AOMMAX(bh_unit >> ss_y, 1);
1523 41168100 : const int32_t bottom_left_count_unit = tx_size_high_unit[txsz];
1524 :
1525 : // All bottom-left pixels are in the left block, which is already available.
1526 41168100 : if (row_off + bottom_left_count_unit < plane_bh_unit) return 1;
1527 :
1528 40732100 : const int32_t bw_in_mi_log2 = mi_size_wide_log2[bsize];
1529 40732100 : const int32_t bh_in_mi_log2 = mi_size_high_log2[bsize];
1530 40732100 : const int32_t sb_mi_size = mi_size_high[sb_size];
1531 40732100 : const int32_t blk_row_in_sb = (mi_row & (sb_mi_size - 1)) >> bh_in_mi_log2;
1532 40732100 : const int32_t blk_col_in_sb = (mi_col & (sb_mi_size - 1)) >> bw_in_mi_log2;
1533 :
1534 : // Leftmost column of superblock: so bottom-left pixels maybe in the left
1535 : // and/or bottom-left superblocks. But only the left superblock is
1536 : // available, so check if all required pixels fall in that superblock.
1537 40732100 : if (blk_col_in_sb == 0) {
1538 8448160 : const int32_t blk_start_row_off = blk_row_in_sb
1539 8448160 : << (bh_in_mi_log2 + MI_SIZE_LOG2 -
1540 8448160 : tx_size_wide_log2[0]) >>
1541 : ss_y;
1542 8448160 : const int32_t row_off_in_sb = blk_start_row_off + row_off;
1543 8448160 : const int32_t sb_height_unit = sb_mi_size >> ss_y;
1544 8448160 : return row_off_in_sb + bottom_left_count_unit < sb_height_unit;
1545 : }
1546 :
1547 : // Bottom row of superblock (and not the leftmost column): so bottom-left
1548 : // pixels fall in the bottom superblock, which is not available yet.
1549 32284000 : if (((blk_row_in_sb + 1) << bh_in_mi_log2) >= sb_mi_size) return 0;
1550 :
1551 : // General case (neither leftmost column nor bottom row): check if the
1552 : // bottom-left block is coded before the current block.
1553 26497800 : const int32_t this_blk_index =
1554 26497800 : ((blk_row_in_sb + 0) << (MAX_MIB_SIZE_LOG2 - bw_in_mi_log2)) +
1555 : blk_col_in_sb + 0;
1556 26497800 : const int32_t idx1 = this_blk_index / 8;
1557 26497800 : const int32_t idx2 = this_blk_index % 8;
1558 26497800 : const uint8_t *has_bl_table = get_has_bl_table(partition, bsize);
1559 26519800 : return (has_bl_table[idx1] >> idx2) & 1;
1560 : }
1561 : }
1562 :
1563 : IntraPredFn pred[INTRA_MODES][TX_SIZES_ALL];
1564 : IntraPredFn dc_pred[2][2][TX_SIZES_ALL];
1565 :
1566 : IntraHighPredFn pred_high[INTRA_MODES][TX_SIZES_ALL];
1567 : IntraHighPredFn dc_pred_high[2][2][TX_SIZES_ALL];
1568 :
1569 3 : static INLINE void dc_128_predictor(uint8_t *dst, ptrdiff_t stride, int32_t bw,
1570 : int32_t bh, const uint8_t *above,
1571 : const uint8_t *left) {
1572 : int32_t r;
1573 : (void)above;
1574 : (void)left;
1575 :
1576 27 : for (r = 0; r < bh; r++) {
1577 24 : memset(dst, 128, bw);
1578 24 : dst += stride;
1579 : }
1580 3 : }
1581 :
1582 41 : static INLINE void dc_left_predictor(uint8_t *dst, ptrdiff_t stride, int32_t bw,
1583 : int32_t bh, const uint8_t *above,
1584 : const uint8_t *left) {
1585 41 : int32_t i, r, expected_dc, sum = 0;
1586 : (void)above;
1587 :
1588 369 : for (i = 0; i < bh; i++) sum += left[i];
1589 41 : expected_dc = (sum + (bh >> 1)) / bh;
1590 :
1591 369 : for (r = 0; r < bh; r++) {
1592 328 : memset(dst, expected_dc, bw);
1593 328 : dst += stride;
1594 : }
1595 41 : }
1596 56 : static INLINE void dc_top_predictor(uint8_t *dst, ptrdiff_t stride, int32_t bw,
1597 : int32_t bh, const uint8_t *above,
1598 : const uint8_t *left) {
1599 56 : int32_t i, r, expected_dc, sum = 0;
1600 : (void)left;
1601 :
1602 504 : for (i = 0; i < bw; i++) sum += above[i];
1603 56 : expected_dc = (sum + (bw >> 1)) / bw;
1604 :
1605 504 : for (r = 0; r < bh; r++) {
1606 448 : memset(dst, expected_dc, bw);
1607 448 : dst += stride;
1608 : }
1609 56 : }
1610 637 : static INLINE void dc_predictor(uint8_t *dst, ptrdiff_t stride, int32_t bw, int32_t bh,
1611 : const uint8_t *above, const uint8_t *left) {
1612 637 : int32_t i, r, expected_dc, sum = 0;
1613 637 : const int32_t count = bw + bh;
1614 :
1615 5733 : for (i = 0; i < bw; i++)
1616 5096 : sum += above[i];
1617 5733 : for (i = 0; i < bh; i++)
1618 5096 : sum += left[i];
1619 637 : expected_dc = (sum + (count >> 1)) / count;
1620 :
1621 5733 : for (r = 0; r < bh; r++) {
1622 5096 : memset(dst, expected_dc, bw);
1623 5096 : dst += stride;
1624 : }
1625 637 : }
1626 108 : static INLINE void v_predictor(uint8_t *dst, ptrdiff_t stride, int32_t bw, int32_t bh,
1627 : const uint8_t *above, const uint8_t *left) {
1628 : int32_t r;
1629 : (void)left;
1630 :
1631 972 : for (r = 0; r < bh; r++) {
1632 864 : memcpy(dst, above, bw);
1633 864 : dst += stride;
1634 : }
1635 108 : }
1636 :
1637 56 : static INLINE void h_predictor(uint8_t *dst, ptrdiff_t stride, int32_t bw, int32_t bh,
1638 : const uint8_t *above, const uint8_t *left) {
1639 : int32_t r;
1640 : (void)above;
1641 :
1642 504 : for (r = 0; r < bh; r++) {
1643 448 : memset(dst, left[r], bw);
1644 448 : dst += stride;
1645 : }
1646 56 : }
1647 :
1648 0 : static INLINE void smooth_predictor(uint8_t *dst, ptrdiff_t stride, int32_t bw,
1649 : int32_t bh, const uint8_t *above,
1650 : const uint8_t *left) {
1651 0 : const uint8_t below_pred = left[bh - 1]; // estimated by bottom-left pixel
1652 0 : const uint8_t right_pred = above[bw - 1]; // estimated by top-right pixel
1653 0 : const uint8_t *const sm_weights_w = sm_weight_arrays + bw;
1654 0 : const uint8_t *const sm_weights_h = sm_weight_arrays + bh;
1655 : // scale = 2 * 2^sm_weight_log2_scale
1656 0 : const int32_t log2_scale = 1 + sm_weight_log2_scale;
1657 0 : const uint16_t scale = (1 << sm_weight_log2_scale);
1658 0 : sm_weights_sanity_checks(sm_weights_w, sm_weights_h, scale,
1659 : log2_scale + sizeof(*dst));
1660 : int32_t r;
1661 0 : for (r = 0; r < bh; ++r) {
1662 : int32_t c;
1663 0 : for (c = 0; c < bw; ++c) {
1664 0 : const uint8_t pixels[] = { above[c], below_pred, left[r], right_pred };
1665 0 : const uint8_t weights[] = { sm_weights_h[r], (uint8_t)(scale - sm_weights_h[r]),
1666 0 : sm_weights_w[c], (uint8_t)(scale - sm_weights_w[c]) };
1667 0 : uint32_t this_pred = 0;
1668 : int32_t i;
1669 0 : assert(scale >= sm_weights_h[r] && scale >= sm_weights_w[c]);
1670 0 : for (i = 0; i < 4; ++i)
1671 0 : this_pred += weights[i] * pixels[i];
1672 0 : dst[c] = (uint8_t)divide_round(this_pred, log2_scale);
1673 : }
1674 0 : dst += stride;
1675 : }
1676 0 : }
1677 :
1678 0 : static INLINE void smooth_v_predictor(uint8_t *dst, ptrdiff_t stride, int32_t bw,
1679 : int32_t bh, const uint8_t *above,
1680 : const uint8_t *left) {
1681 0 : const uint8_t below_pred = left[bh - 1]; // estimated by bottom-left pixel
1682 0 : const uint8_t *const sm_weights = sm_weight_arrays + bh;
1683 : // scale = 2^sm_weight_log2_scale
1684 0 : const int32_t log2_scale = sm_weight_log2_scale;
1685 0 : const uint16_t scale = (1 << sm_weight_log2_scale);
1686 0 : sm_weights_sanity_checks(sm_weights, sm_weights, scale,
1687 : log2_scale + sizeof(*dst));
1688 :
1689 : int32_t r;
1690 0 : for (r = 0; r < bh; r++) {
1691 : int32_t c;
1692 0 : for (c = 0; c < bw; ++c) {
1693 0 : const uint8_t pixels[] = { above[c], below_pred };
1694 0 : const uint8_t weights[] = { sm_weights[r], (uint8_t)(scale - sm_weights[r]) };
1695 0 : uint32_t this_pred = 0;
1696 0 : assert(scale >= sm_weights[r]);
1697 : int32_t i;
1698 0 : for (i = 0; i < 2; ++i)
1699 0 : this_pred += weights[i] * pixels[i];
1700 0 : dst[c] = (uint8_t)divide_round(this_pred, log2_scale);
1701 : }
1702 0 : dst += stride;
1703 : }
1704 0 : }
1705 :
1706 0 : static INLINE void smooth_h_predictor(uint8_t *dst, ptrdiff_t stride, int32_t bw,
1707 : int32_t bh, const uint8_t *above,
1708 : const uint8_t *left) {
1709 0 : const uint8_t right_pred = above[bw - 1]; // estimated by top-right pixel
1710 0 : const uint8_t *const sm_weights = sm_weight_arrays + bw;
1711 : // scale = 2^sm_weight_log2_scale
1712 0 : const int32_t log2_scale = sm_weight_log2_scale;
1713 0 : const uint16_t scale = (1 << sm_weight_log2_scale);
1714 0 : sm_weights_sanity_checks(sm_weights, sm_weights, scale,
1715 : log2_scale + sizeof(*dst));
1716 :
1717 : int32_t r;
1718 0 : for (r = 0; r < bh; r++) {
1719 : int32_t c;
1720 0 : for (c = 0; c < bw; ++c) {
1721 0 : const uint8_t pixels[] = { left[r], right_pred };
1722 0 : const uint8_t weights[] = { sm_weights[c], (uint8_t)(scale - sm_weights[c]) };
1723 0 : uint32_t this_pred = 0;
1724 0 : assert(scale >= sm_weights[c]);
1725 : int32_t i;
1726 0 : for (i = 0; i < 2; ++i)
1727 0 : this_pred += weights[i] * pixels[i];
1728 0 : dst[c] = (uint8_t)divide_round(this_pred, log2_scale);
1729 : }
1730 0 : dst += stride;
1731 : }
1732 0 : }
1733 : #undef DC_MULTIPLIER_1X2
1734 : #undef DC_MULTIPLIER_1X4
1735 :
1736 0 : static INLINE void highbd_v_predictor(uint16_t *dst, ptrdiff_t stride, int32_t bw,
1737 : int32_t bh, const uint16_t *above,
1738 : const uint16_t *left, int32_t bd) {
1739 : int32_t r;
1740 : (void)left;
1741 : (void)bd;
1742 0 : for (r = 0; r < bh; r++) {
1743 0 : memcpy(dst, above, bw * sizeof(uint16_t));
1744 0 : dst += stride;
1745 : }
1746 0 : }
1747 :
1748 0 : static INLINE void highbd_h_predictor(uint16_t *dst, ptrdiff_t stride, int32_t bw,
1749 : int32_t bh, const uint16_t *above,
1750 : const uint16_t *left, int32_t bd) {
1751 : int32_t r;
1752 : (void)above;
1753 : (void)bd;
1754 0 : for (r = 0; r < bh; r++) {
1755 0 : eb_aom_memset16(dst, left[r], bw);
1756 0 : dst += stride;
1757 : }
1758 0 : }
1759 0 : static INLINE int abs_diff(int a, int b) { return (a > b) ? a - b : b - a; }
1760 0 : static INLINE uint16_t paeth_predictor_single(uint16_t left, uint16_t top,
1761 : uint16_t top_left) {
1762 0 : const int base = top + left - top_left;
1763 0 : const int p_left = abs_diff(base, left);
1764 0 : const int p_top = abs_diff(base, top);
1765 0 : const int p_top_left = abs_diff(base, top_left);
1766 :
1767 : // Return nearest to base of left, top and top_left.
1768 0 : return (p_left <= p_top && p_left <= p_top_left)
1769 : ? left
1770 0 : : (p_top <= p_top_left) ? top : top_left;
1771 : }
1772 :
1773 0 : static INLINE void paeth_predictor(uint8_t *dst, ptrdiff_t stride, int bw,
1774 : int bh, const uint8_t *above,
1775 : const uint8_t *left) {
1776 : int r, c;
1777 0 : const uint8_t ytop_left = above[-1];
1778 :
1779 0 : for (r = 0; r < bh; r++) {
1780 0 : for (c = 0; c < bw; c++)
1781 0 : dst[c] = (uint8_t)paeth_predictor_single(left[r], above[c], ytop_left);
1782 0 : dst += stride;
1783 : }
1784 0 : }
1785 :
1786 0 : static INLINE void highbd_paeth_predictor(uint16_t *dst, ptrdiff_t stride,
1787 : int bw, int bh, const uint16_t *above,
1788 : const uint16_t *left, int bd) {
1789 : int r, c;
1790 0 : const uint16_t ytop_left = above[-1];
1791 : (void)bd;
1792 :
1793 0 : for (r = 0; r < bh; r++) {
1794 0 : for (c = 0; c < bw; c++)
1795 0 : dst[c] = paeth_predictor_single(left[r], above[c], ytop_left);
1796 0 : dst += stride;
1797 : }
1798 0 : }
1799 : //static INLINE void highbd_paeth_predictor(uint16_t *dst, ptrdiff_t stride,
1800 : // int32_t bw, int32_t bh, const uint16_t *above,
1801 : // const uint16_t *left, int32_t bd) {
1802 : // int32_t r, c;
1803 : // const uint16_t ytop_left = above[-1];
1804 : // (void)bd;
1805 : //
1806 : // for (r = 0; r < bh; r++) {
1807 : // for (c = 0; c < bw; c++)
1808 : // dst[c] = paeth_predictor_single(left[r], above[c], ytop_left);
1809 : // dst += stride;
1810 : // }
1811 : //}
1812 :
1813 0 : static INLINE void highbd_smooth_predictor(uint16_t *dst, ptrdiff_t stride,
1814 : int32_t bw, int32_t bh,
1815 : const uint16_t *above,
1816 : const uint16_t *left, int32_t bd) {
1817 : (void)bd;
1818 0 : const uint16_t below_pred = left[bh - 1]; // estimated by bottom-left pixel
1819 0 : const uint16_t right_pred = above[bw - 1]; // estimated by top-right pixel
1820 0 : const uint8_t *const sm_weights_w = sm_weight_arrays + bw;
1821 0 : const uint8_t *const sm_weights_h = sm_weight_arrays + bh;
1822 : // scale = 2 * 2^sm_weight_log2_scale
1823 0 : const int32_t log2_scale = 1 + sm_weight_log2_scale;
1824 0 : const uint16_t scale = (1 << sm_weight_log2_scale);
1825 0 : sm_weights_sanity_checks(sm_weights_w, sm_weights_h, scale,
1826 : log2_scale + sizeof(*dst));
1827 : int32_t r;
1828 0 : for (r = 0; r < bh; ++r) {
1829 : int32_t c;
1830 0 : for (c = 0; c < bw; ++c) {
1831 0 : const uint16_t pixels[] = { above[c], below_pred, left[r], right_pred };
1832 0 : const uint8_t weights[] = { sm_weights_h[r], (uint8_t)(scale - sm_weights_h[r]),
1833 0 : sm_weights_w[c], (uint8_t)(scale - sm_weights_w[c]) };
1834 0 : uint32_t this_pred = 0;
1835 : int32_t i;
1836 0 : assert(scale >= sm_weights_h[r] && scale >= sm_weights_w[c]);
1837 0 : for (i = 0; i < 4; ++i)
1838 0 : this_pred += weights[i] * pixels[i];
1839 0 : dst[c] = (uint16_t)divide_round(this_pred, log2_scale);
1840 : }
1841 0 : dst += stride;
1842 : }
1843 0 : }
1844 :
1845 0 : static INLINE void highbd_smooth_v_predictor(uint16_t *dst, ptrdiff_t stride,
1846 : int32_t bw, int32_t bh,
1847 : const uint16_t *above,
1848 : const uint16_t *left, int32_t bd) {
1849 : (void)bd;
1850 0 : const uint16_t below_pred = left[bh - 1]; // estimated by bottom-left pixel
1851 0 : const uint8_t *const sm_weights = sm_weight_arrays + bh;
1852 : // scale = 2^sm_weight_log2_scale
1853 0 : const int32_t log2_scale = sm_weight_log2_scale;
1854 0 : const uint16_t scale = (1 << sm_weight_log2_scale);
1855 0 : sm_weights_sanity_checks(sm_weights, sm_weights, scale,
1856 : log2_scale + sizeof(*dst));
1857 :
1858 : int32_t r;
1859 0 : for (r = 0; r < bh; r++) {
1860 : int32_t c;
1861 0 : for (c = 0; c < bw; ++c) {
1862 0 : const uint16_t pixels[] = { above[c], below_pred };
1863 0 : const uint8_t weights[] = { sm_weights[r], (uint8_t)(scale - sm_weights[r]) };
1864 0 : uint32_t this_pred = 0;
1865 0 : assert(scale >= sm_weights[r]);
1866 : int32_t i;
1867 0 : for (i = 0; i < 2; ++i)
1868 0 : this_pred += weights[i] * pixels[i];
1869 0 : dst[c] = (uint16_t)divide_round(this_pred, log2_scale);
1870 : }
1871 0 : dst += stride;
1872 : }
1873 0 : }
1874 :
1875 0 : static INLINE void highbd_smooth_h_predictor(uint16_t *dst, ptrdiff_t stride,
1876 : int32_t bw, int32_t bh,
1877 : const uint16_t *above,
1878 : const uint16_t *left, int32_t bd) {
1879 : (void)bd;
1880 0 : const uint16_t right_pred = above[bw - 1]; // estimated by top-right pixel
1881 0 : const uint8_t *const sm_weights = sm_weight_arrays + bw;
1882 : // scale = 2^sm_weight_log2_scale
1883 0 : const int32_t log2_scale = sm_weight_log2_scale;
1884 0 : const uint16_t scale = (1 << sm_weight_log2_scale);
1885 0 : sm_weights_sanity_checks(sm_weights, sm_weights, scale,
1886 : log2_scale + sizeof(*dst));
1887 :
1888 : int32_t r;
1889 0 : for (r = 0; r < bh; r++) {
1890 : int32_t c;
1891 0 : for (c = 0; c < bw; ++c) {
1892 0 : const uint16_t pixels[] = { left[r], right_pred };
1893 0 : const uint8_t weights[] = { sm_weights[c], (uint8_t)(scale - sm_weights[c]) };
1894 0 : uint32_t this_pred = 0;
1895 0 : assert(scale >= sm_weights[c]);
1896 : int32_t i;
1897 0 : for (i = 0; i < 2; ++i)
1898 0 : this_pred += weights[i] * pixels[i];
1899 0 : dst[c] = (uint16_t)divide_round(this_pred, log2_scale);
1900 : }
1901 0 : dst += stride;
1902 : }
1903 0 : }
1904 :
1905 0 : static INLINE void highbd_dc_128_predictor(uint16_t *dst, ptrdiff_t stride,
1906 : int32_t bw, int32_t bh,
1907 : const uint16_t *above,
1908 : const uint16_t *left, int32_t bd) {
1909 : int32_t r;
1910 : (void)above;
1911 : (void)left;
1912 :
1913 0 : for (r = 0; r < bh; r++) {
1914 0 : eb_aom_memset16(dst, 128 << (bd - 8), bw);
1915 0 : dst += stride;
1916 : }
1917 0 : }
1918 :
1919 0 : static INLINE void highbd_dc_left_predictor(uint16_t *dst, ptrdiff_t stride,
1920 : int32_t bw, int32_t bh,
1921 : const uint16_t *above,
1922 : const uint16_t *left, int32_t bd) {
1923 0 : int32_t i, r, expected_dc, sum = 0;
1924 : (void)above;
1925 : (void)bd;
1926 :
1927 0 : for (i = 0; i < bh; i++) sum += left[i];
1928 0 : expected_dc = (sum + (bh >> 1)) / bh;
1929 :
1930 0 : for (r = 0; r < bh; r++) {
1931 0 : eb_aom_memset16(dst, expected_dc, bw);
1932 0 : dst += stride;
1933 : }
1934 0 : }
1935 :
1936 0 : static INLINE void highbd_dc_top_predictor(uint16_t *dst, ptrdiff_t stride,
1937 : int32_t bw, int32_t bh,
1938 : const uint16_t *above,
1939 : const uint16_t *left, int32_t bd) {
1940 0 : int32_t i, r, expected_dc, sum = 0;
1941 : (void)left;
1942 : (void)bd;
1943 :
1944 0 : for (i = 0; i < bw; i++) sum += above[i];
1945 0 : expected_dc = (sum + (bw >> 1)) / bw;
1946 :
1947 0 : for (r = 0; r < bh; r++) {
1948 0 : eb_aom_memset16(dst, expected_dc, bw);
1949 0 : dst += stride;
1950 : }
1951 0 : }
1952 :
1953 0 : static INLINE void highbd_dc_predictor(uint16_t *dst, ptrdiff_t stride, int32_t bw,
1954 : int32_t bh, const uint16_t *above,
1955 : const uint16_t *left, int32_t bd) {
1956 0 : int32_t i, r, expected_dc, sum = 0;
1957 0 : const int32_t count = bw + bh;
1958 : (void)bd;
1959 :
1960 0 : for (i = 0; i < bw; i++)
1961 0 : sum += above[i];
1962 0 : for (i = 0; i < bh; i++)
1963 0 : sum += left[i];
1964 0 : expected_dc = (sum + (count >> 1)) / count;
1965 :
1966 0 : for (r = 0; r < bh; r++) {
1967 0 : eb_aom_memset16(dst, expected_dc, bw);
1968 0 : dst += stride;
1969 : }
1970 0 : }
1971 :
1972 : //static INLINE void highbd_dc_predictor_rect(uint16_t *dst, ptrdiff_t stride,
1973 : // int32_t bw, int32_t bh,
1974 : // const uint16_t *above,
1975 : // const uint16_t *left, int32_t bd,
1976 : // int32_t shift1, uint32_t multiplier) {
1977 : // int32_t sum = 0;
1978 : // (void)bd;
1979 : //
1980 : // for (int32_t i = 0; i < bw; i++) {
1981 : // sum += above[i];
1982 : // }
1983 : // for (int32_t i = 0; i < bh; i++) {
1984 : // sum += left[i];
1985 : // }
1986 : //
1987 : // const int32_t expected_dc = divide_using_multiply_shift(
1988 : // sum + ((bw + bh) >> 1), shift1, multiplier, HIGHBD_DC_SHIFT2);
1989 : // assert(expected_dc < (1 << bd));
1990 : //
1991 : // for (int32_t r = 0; r < bh; r++) {
1992 : // eb_aom_memset16(dst, expected_dc, bw);
1993 : // dst += stride;
1994 : // }
1995 : //}
1996 :
1997 : //#undef HIGHBD_DC_SHIFT2
1998 : //
1999 : //void eb_aom_highbd_dc_predictor_4x8_c(uint16_t *dst, ptrdiff_t stride,
2000 : // const uint16_t *above, const uint16_t *left,
2001 : // int32_t bd) {
2002 : // highbd_dc_predictor_rect(dst, stride, 4, 8, above, left, bd, 2,
2003 : // HIGHBD_DC_MULTIPLIER_1X2);
2004 : //}
2005 : //
2006 : //void eb_aom_highbd_dc_predictor_8x4_c(uint16_t *dst, ptrdiff_t stride,
2007 : // const uint16_t *above, const uint16_t *left,
2008 : // int32_t bd) {
2009 : // highbd_dc_predictor_rect(dst, stride, 8, 4, above, left, bd, 2,
2010 : // HIGHBD_DC_MULTIPLIER_1X2);
2011 : //}
2012 : //
2013 : //void eb_aom_highbd_dc_predictor_4x16_c(uint16_t *dst, ptrdiff_t stride,
2014 : // const uint16_t *above, const uint16_t *left,
2015 : // int32_t bd) {
2016 : // highbd_dc_predictor_rect(dst, stride, 4, 16, above, left, bd, 2,
2017 : // HIGHBD_DC_MULTIPLIER_1X4);
2018 : //}
2019 : //
2020 : //void eb_aom_highbd_dc_predictor_16x4_c(uint16_t *dst, ptrdiff_t stride,
2021 : // const uint16_t *above, const uint16_t *left,
2022 : // int32_t bd) {
2023 : // highbd_dc_predictor_rect(dst, stride, 16, 4, above, left, bd, 2,
2024 : // HIGHBD_DC_MULTIPLIER_1X4);
2025 : //}
2026 : //
2027 : //void eb_aom_highbd_dc_predictor_8x16_c(uint16_t *dst, ptrdiff_t stride,
2028 : // const uint16_t *above, const uint16_t *left,
2029 : // int32_t bd) {
2030 : // highbd_dc_predictor_rect(dst, stride, 8, 16, above, left, bd, 3,
2031 : // HIGHBD_DC_MULTIPLIER_1X2);
2032 : //}
2033 : //
2034 : //void eb_aom_highbd_dc_predictor_16x8_c(uint16_t *dst, ptrdiff_t stride,
2035 : // const uint16_t *above, const uint16_t *left,
2036 : // int32_t bd) {
2037 : // highbd_dc_predictor_rect(dst, stride, 16, 8, above, left, bd, 3,
2038 : // HIGHBD_DC_MULTIPLIER_1X2);
2039 : //}
2040 : //
2041 : //void eb_aom_highbd_dc_predictor_8x32_c(uint16_t *dst, ptrdiff_t stride,
2042 : // const uint16_t *above, const uint16_t *left,
2043 : // int32_t bd) {
2044 : // highbd_dc_predictor_rect(dst, stride, 8, 32, above, left, bd, 3,
2045 : // HIGHBD_DC_MULTIPLIER_1X4);
2046 : //}
2047 : //
2048 : //void eb_aom_highbd_dc_predictor_32x8_c(uint16_t *dst, ptrdiff_t stride,
2049 : // const uint16_t *above, const uint16_t *left,
2050 : // int32_t bd) {
2051 : // highbd_dc_predictor_rect(dst, stride, 32, 8, above, left, bd, 3,
2052 : // HIGHBD_DC_MULTIPLIER_1X4);
2053 : //}
2054 : //
2055 : //void eb_aom_highbd_dc_predictor_16x32_c(uint16_t *dst, ptrdiff_t stride,
2056 : // const uint16_t *above,
2057 : // const uint16_t *left, int32_t bd) {
2058 : // highbd_dc_predictor_rect(dst, stride, 16, 32, above, left, bd, 4,
2059 : // HIGHBD_DC_MULTIPLIER_1X2);
2060 : //}
2061 : //
2062 : //void eb_aom_highbd_dc_predictor_32x16_c(uint16_t *dst, ptrdiff_t stride,
2063 : // const uint16_t *above,
2064 : // const uint16_t *left, int32_t bd) {
2065 : // highbd_dc_predictor_rect(dst, stride, 32, 16, above, left, bd, 4,
2066 : // HIGHBD_DC_MULTIPLIER_1X2);
2067 : //}
2068 : //
2069 : //void eb_aom_highbd_dc_predictor_16x64_c(uint16_t *dst, ptrdiff_t stride,
2070 : // const uint16_t *above,
2071 : // const uint16_t *left, int32_t bd) {
2072 : // highbd_dc_predictor_rect(dst, stride, 16, 64, above, left, bd, 4,
2073 : // HIGHBD_DC_MULTIPLIER_1X4);
2074 : //}
2075 : //
2076 : //void eb_aom_highbd_dc_predictor_64x16_c(uint16_t *dst, ptrdiff_t stride,
2077 : // const uint16_t *above,
2078 : // const uint16_t *left, int32_t bd) {
2079 : // highbd_dc_predictor_rect(dst, stride, 64, 16, above, left, bd, 4,
2080 : // HIGHBD_DC_MULTIPLIER_1X4);
2081 : //}
2082 : //
2083 : //void eb_aom_highbd_dc_predictor_32x64_c(uint16_t *dst, ptrdiff_t stride,
2084 : // const uint16_t *above,
2085 : // const uint16_t *left, int32_t bd) {
2086 : // highbd_dc_predictor_rect(dst, stride, 32, 64, above, left, bd, 5,
2087 : // HIGHBD_DC_MULTIPLIER_1X2);
2088 : //}
2089 : //
2090 : //void eb_aom_highbd_dc_predictor_64x32_c(uint16_t *dst, ptrdiff_t stride,
2091 : // const uint16_t *above,
2092 : // const uint16_t *left, int32_t bd) {
2093 : // highbd_dc_predictor_rect(dst, stride, 64, 32, above, left, bd, 5,
2094 : // HIGHBD_DC_MULTIPLIER_1X2);
2095 : //}
2096 : //
2097 : //#undef HIGHBD_DC_MULTIPLIER_1X2
2098 : //#undef HIGHBD_DC_MULTIPLIER_1X4
2099 :
2100 : #define intra_pred_sized(type, width, height) \
2101 : void eb_aom_##type##_predictor_##width##x##height##_c( \
2102 : uint8_t *dst, ptrdiff_t stride, const uint8_t *above, \
2103 : const uint8_t *left) { \
2104 : type##_predictor(dst, stride, width, height, above, left); \
2105 : }
2106 :
2107 0 : intra_pred_sized(dc, 2, 2)
2108 0 : intra_pred_sized(dc, 4, 4)
2109 637 : intra_pred_sized(dc, 8, 8)
2110 0 : intra_pred_sized(dc, 16, 16)
2111 0 : intra_pred_sized(dc, 32, 32)
2112 0 : intra_pred_sized(dc, 64, 64)
2113 0 : intra_pred_sized(dc, 4, 8)
2114 0 : intra_pred_sized(dc, 4, 16)
2115 0 : intra_pred_sized(dc, 8, 4)
2116 0 : intra_pred_sized(dc, 8, 16)
2117 0 : intra_pred_sized(dc, 8, 32)
2118 0 : intra_pred_sized(dc, 16, 4)
2119 0 : intra_pred_sized(dc, 16, 8)
2120 0 : intra_pred_sized(dc, 16, 32)
2121 0 : intra_pred_sized(dc, 16, 64)
2122 0 : intra_pred_sized(dc, 32, 8)
2123 0 : intra_pred_sized(dc, 32, 16)
2124 0 : intra_pred_sized(dc, 32, 64)
2125 0 : intra_pred_sized(dc, 64, 16)
2126 0 : intra_pred_sized(dc, 64, 32)
2127 :
2128 0 : intra_pred_sized(dc_128, 2, 2)
2129 0 : intra_pred_sized(dc_128, 4, 4)
2130 3 : intra_pred_sized(dc_128, 8, 8)
2131 0 : intra_pred_sized(dc_128, 16, 16)
2132 0 : intra_pred_sized(dc_128, 32, 32)
2133 0 : intra_pred_sized(dc_128, 64, 64)
2134 0 : intra_pred_sized(dc_128, 4, 8)
2135 0 : intra_pred_sized(dc_128, 4, 16)
2136 0 : intra_pred_sized(dc_128, 8, 4)
2137 0 : intra_pred_sized(dc_128, 8, 16)
2138 0 : intra_pred_sized(dc_128, 8, 32)
2139 0 : intra_pred_sized(dc_128, 16, 4)
2140 0 : intra_pred_sized(dc_128, 16, 8)
2141 0 : intra_pred_sized(dc_128, 16, 32)
2142 0 : intra_pred_sized(dc_128, 16, 64)
2143 0 : intra_pred_sized(dc_128, 32, 8)
2144 0 : intra_pred_sized(dc_128, 32, 16)
2145 0 : intra_pred_sized(dc_128, 32, 64)
2146 0 : intra_pred_sized(dc_128, 64, 16)
2147 0 : intra_pred_sized(dc_128, 64, 32)
2148 :
2149 0 : intra_pred_sized(dc_left, 2, 2)
2150 0 : intra_pred_sized(dc_left, 4, 4)
2151 41 : intra_pred_sized(dc_left, 8, 8)
2152 0 : intra_pred_sized(dc_left, 16, 16)
2153 0 : intra_pred_sized(dc_left, 32, 32)
2154 0 : intra_pred_sized(dc_left, 64, 64)
2155 0 : intra_pred_sized(dc_left, 4, 8)
2156 0 : intra_pred_sized(dc_left, 4, 16)
2157 0 : intra_pred_sized(dc_left, 8, 4)
2158 0 : intra_pred_sized(dc_left, 8, 16)
2159 0 : intra_pred_sized(dc_left, 8, 32)
2160 0 : intra_pred_sized(dc_left, 16, 4)
2161 0 : intra_pred_sized(dc_left, 16, 8)
2162 0 : intra_pred_sized(dc_left, 16, 32)
2163 0 : intra_pred_sized(dc_left, 16, 64)
2164 0 : intra_pred_sized(dc_left, 32, 8)
2165 0 : intra_pred_sized(dc_left, 32, 16)
2166 0 : intra_pred_sized(dc_left, 32, 64)
2167 0 : intra_pred_sized(dc_left, 64, 16)
2168 0 : intra_pred_sized(dc_left, 64, 32)
2169 :
2170 0 : intra_pred_sized(dc_top, 2, 2)
2171 0 : intra_pred_sized(dc_top, 4, 4)
2172 56 : intra_pred_sized(dc_top, 8, 8)
2173 0 : intra_pred_sized(dc_top, 16, 16)
2174 0 : intra_pred_sized(dc_top, 32, 32)
2175 0 : intra_pred_sized(dc_top, 64, 64)
2176 0 : intra_pred_sized(dc_top, 4, 8)
2177 0 : intra_pred_sized(dc_top, 4, 16)
2178 0 : intra_pred_sized(dc_top, 8, 4)
2179 0 : intra_pred_sized(dc_top, 8, 16)
2180 0 : intra_pred_sized(dc_top, 8, 32)
2181 0 : intra_pred_sized(dc_top, 16, 4)
2182 0 : intra_pred_sized(dc_top, 16, 8)
2183 0 : intra_pred_sized(dc_top, 16, 32)
2184 0 : intra_pred_sized(dc_top, 16, 64)
2185 0 : intra_pred_sized(dc_top, 32, 8)
2186 0 : intra_pred_sized(dc_top, 32, 16)
2187 0 : intra_pred_sized(dc_top, 32, 64)
2188 0 : intra_pred_sized(dc_top, 64, 16)
2189 0 : intra_pred_sized(dc_top, 64, 32)
2190 0 : intra_pred_sized(v, 2, 2)
2191 0 : intra_pred_sized(v, 4, 4)
2192 108 : intra_pred_sized(v, 8, 8)
2193 0 : intra_pred_sized(v, 16, 16)
2194 0 : intra_pred_sized(v, 32, 32)
2195 0 : intra_pred_sized(v, 64, 64)
2196 0 : intra_pred_sized(v, 4, 8)
2197 0 : intra_pred_sized(v, 4, 16)
2198 0 : intra_pred_sized(v, 8, 4)
2199 0 : intra_pred_sized(v, 8, 16)
2200 0 : intra_pred_sized(v, 8, 32)
2201 0 : intra_pred_sized(v, 16, 4)
2202 0 : intra_pred_sized(v, 16, 8)
2203 0 : intra_pred_sized(v, 16, 32)
2204 0 : intra_pred_sized(v, 16, 64)
2205 0 : intra_pred_sized(v, 32, 8)
2206 0 : intra_pred_sized(v, 32, 16)
2207 0 : intra_pred_sized(v, 32, 64)
2208 0 : intra_pred_sized(v, 64, 16)
2209 0 : intra_pred_sized(v, 64, 32)
2210 0 : intra_pred_sized(h, 2, 2)
2211 0 : intra_pred_sized(h, 4, 4)
2212 56 : intra_pred_sized(h, 8, 8)
2213 0 : intra_pred_sized(h, 16, 16)
2214 0 : intra_pred_sized(h, 32, 32)
2215 0 : intra_pred_sized(h, 64, 64)
2216 0 : intra_pred_sized(h, 4, 8)
2217 0 : intra_pred_sized(h, 4, 16)
2218 0 : intra_pred_sized(h, 8, 4)
2219 0 : intra_pred_sized(h, 8, 16)
2220 0 : intra_pred_sized(h, 8, 32)
2221 0 : intra_pred_sized(h, 16, 4)
2222 0 : intra_pred_sized(h, 16, 8)
2223 0 : intra_pred_sized(h, 16, 32)
2224 0 : intra_pred_sized(h, 16, 64)
2225 0 : intra_pred_sized(h, 32, 8)
2226 0 : intra_pred_sized(h, 32, 16)
2227 0 : intra_pred_sized(h, 32, 64)
2228 0 : intra_pred_sized(h, 64, 16)
2229 0 : intra_pred_sized(h, 64, 32)
2230 0 : intra_pred_sized(smooth, 2, 2)
2231 0 : intra_pred_sized(smooth, 4, 4)
2232 0 : intra_pred_sized(smooth, 8, 8)
2233 0 : intra_pred_sized(smooth, 16, 16)
2234 0 : intra_pred_sized(smooth, 32, 32)
2235 0 : intra_pred_sized(smooth, 64, 64)
2236 0 : intra_pred_sized(smooth, 4, 8)
2237 0 : intra_pred_sized(smooth, 4, 16)
2238 0 : intra_pred_sized(smooth, 8, 4)
2239 0 : intra_pred_sized(smooth, 8, 16)
2240 0 : intra_pred_sized(smooth, 8, 32)
2241 0 : intra_pred_sized(smooth, 16, 4)
2242 0 : intra_pred_sized(smooth, 16, 8)
2243 0 : intra_pred_sized(smooth, 16, 32)
2244 0 : intra_pred_sized(smooth, 16, 64)
2245 0 : intra_pred_sized(smooth, 32, 8)
2246 0 : intra_pred_sized(smooth, 32, 16)
2247 0 : intra_pred_sized(smooth, 32, 64)
2248 0 : intra_pred_sized(smooth, 64, 16)
2249 0 : intra_pred_sized(smooth, 64, 32)
2250 0 : intra_pred_sized(smooth_h, 2, 2)
2251 0 : intra_pred_sized(smooth_h, 4, 4)
2252 0 : intra_pred_sized(smooth_h, 8, 8)
2253 0 : intra_pred_sized(smooth_h, 16, 16)
2254 0 : intra_pred_sized(smooth_h, 32, 32)
2255 0 : intra_pred_sized(smooth_h, 64, 64)
2256 0 : intra_pred_sized(smooth_h, 4, 8)
2257 0 : intra_pred_sized(smooth_h, 4, 16)
2258 0 : intra_pred_sized(smooth_h, 8, 4)
2259 0 : intra_pred_sized(smooth_h, 8, 16)
2260 0 : intra_pred_sized(smooth_h, 8, 32)
2261 0 : intra_pred_sized(smooth_h, 16, 4)
2262 0 : intra_pred_sized(smooth_h, 16, 8)
2263 0 : intra_pred_sized(smooth_h, 16, 32)
2264 0 : intra_pred_sized(smooth_h, 16, 64)
2265 0 : intra_pred_sized(smooth_h, 32, 8)
2266 0 : intra_pred_sized(smooth_h, 32, 16)
2267 0 : intra_pred_sized(smooth_h, 32, 64)
2268 0 : intra_pred_sized(smooth_h, 64, 16)
2269 0 : intra_pred_sized(smooth_h, 64, 32)
2270 0 : intra_pred_sized(smooth_v, 2, 2)
2271 0 : intra_pred_sized(smooth_v, 4, 4)
2272 0 : intra_pred_sized(smooth_v, 8, 8)
2273 0 : intra_pred_sized(smooth_v, 16, 16)
2274 0 : intra_pred_sized(smooth_v, 32, 32)
2275 0 : intra_pred_sized(smooth_v, 64, 64)
2276 0 : intra_pred_sized(smooth_v, 4, 8)
2277 0 : intra_pred_sized(smooth_v, 4, 16)
2278 0 : intra_pred_sized(smooth_v, 8, 4)
2279 0 : intra_pred_sized(smooth_v, 8, 16)
2280 0 : intra_pred_sized(smooth_v, 8, 32)
2281 0 : intra_pred_sized(smooth_v, 16, 4)
2282 0 : intra_pred_sized(smooth_v, 16, 8)
2283 0 : intra_pred_sized(smooth_v, 16, 32)
2284 0 : intra_pred_sized(smooth_v, 16, 64)
2285 0 : intra_pred_sized(smooth_v, 32, 8)
2286 0 : intra_pred_sized(smooth_v, 32, 16)
2287 0 : intra_pred_sized(smooth_v, 32, 64)
2288 0 : intra_pred_sized(smooth_v, 64, 16)
2289 0 : intra_pred_sized(smooth_v, 64, 32)
2290 0 : intra_pred_sized(paeth, 2, 2)
2291 0 : intra_pred_sized(paeth, 4, 4)
2292 0 : intra_pred_sized(paeth, 8, 8)
2293 0 : intra_pred_sized(paeth, 16, 16)
2294 0 : intra_pred_sized(paeth, 32, 32)
2295 0 : intra_pred_sized(paeth, 64, 64)
2296 0 : intra_pred_sized(paeth, 4, 8)
2297 0 : intra_pred_sized(paeth, 4, 16)
2298 0 : intra_pred_sized(paeth, 8, 4)
2299 0 : intra_pred_sized(paeth, 8, 16)
2300 0 : intra_pred_sized(paeth, 8, 32)
2301 0 : intra_pred_sized(paeth, 16, 4)
2302 0 : intra_pred_sized(paeth, 16, 8)
2303 0 : intra_pred_sized(paeth, 16, 32)
2304 0 : intra_pred_sized(paeth, 16, 64)
2305 0 : intra_pred_sized(paeth, 32, 8)
2306 0 : intra_pred_sized(paeth, 32, 16)
2307 0 : intra_pred_sized(paeth, 32, 64)
2308 0 : intra_pred_sized(paeth, 64, 16)
2309 0 : intra_pred_sized(paeth, 64, 32)
2310 : #define intra_pred_highbd_sized(type, width, height) \
2311 : void eb_aom_highbd_##type##_predictor_##width##x##height##_c( \
2312 : uint16_t *dst, ptrdiff_t stride, const uint16_t *above, \
2313 : const uint16_t *left, int32_t bd) { \
2314 : highbd_##type##_predictor(dst, stride, width, height, above, left, bd); \
2315 : }
2316 :
2317 0 : intra_pred_highbd_sized(dc, 2, 2)
2318 0 : intra_pred_highbd_sized(dc, 4, 4)
2319 0 : intra_pred_highbd_sized(dc, 8, 8)
2320 0 : intra_pred_highbd_sized(dc, 16, 16)
2321 0 : intra_pred_highbd_sized(dc, 32, 32)
2322 0 : intra_pred_highbd_sized(dc, 64, 64)
2323 0 : intra_pred_highbd_sized(dc, 4, 8)
2324 0 : intra_pred_highbd_sized(dc, 4, 16)
2325 0 : intra_pred_highbd_sized(dc, 8, 4)
2326 0 : intra_pred_highbd_sized(dc, 8, 16)
2327 0 : intra_pred_highbd_sized(dc, 8, 32)
2328 0 : intra_pred_highbd_sized(dc, 16, 4)
2329 0 : intra_pred_highbd_sized(dc, 16, 8)
2330 0 : intra_pred_highbd_sized(dc, 16, 32)
2331 0 : intra_pred_highbd_sized(dc, 16, 64)
2332 0 : intra_pred_highbd_sized(dc, 32, 8)
2333 0 : intra_pred_highbd_sized(dc, 32, 16)
2334 0 : intra_pred_highbd_sized(dc, 32, 64)
2335 0 : intra_pred_highbd_sized(dc, 64, 16)
2336 0 : intra_pred_highbd_sized(dc, 64, 32)
2337 :
2338 0 : intra_pred_highbd_sized(dc_128, 2, 2)
2339 0 : intra_pred_highbd_sized(dc_128, 4, 4)
2340 0 : intra_pred_highbd_sized(dc_128, 8, 8)
2341 0 : intra_pred_highbd_sized(dc_128, 16, 16)
2342 0 : intra_pred_highbd_sized(dc_128, 32, 32)
2343 0 : intra_pred_highbd_sized(dc_128, 64, 64)
2344 :
2345 0 : intra_pred_highbd_sized(dc_128, 4, 8)
2346 0 : intra_pred_highbd_sized(dc_128, 4, 16)
2347 0 : intra_pred_highbd_sized(dc_128, 8, 4)
2348 0 : intra_pred_highbd_sized(dc_128, 8, 16)
2349 0 : intra_pred_highbd_sized(dc_128, 8, 32)
2350 0 : intra_pred_highbd_sized(dc_128, 16, 4)
2351 0 : intra_pred_highbd_sized(dc_128, 16, 8)
2352 0 : intra_pred_highbd_sized(dc_128, 16, 32)
2353 0 : intra_pred_highbd_sized(dc_128, 16, 64)
2354 0 : intra_pred_highbd_sized(dc_128, 32, 8)
2355 0 : intra_pred_highbd_sized(dc_128, 32, 16)
2356 0 : intra_pred_highbd_sized(dc_128, 32, 64)
2357 0 : intra_pred_highbd_sized(dc_128, 64, 16)
2358 0 : intra_pred_highbd_sized(dc_128, 64, 32)
2359 :
2360 0 : intra_pred_highbd_sized(dc_left, 2, 2)
2361 0 : intra_pred_highbd_sized(dc_left, 4, 4)
2362 0 : intra_pred_highbd_sized(dc_left, 8, 8)
2363 0 : intra_pred_highbd_sized(dc_left, 16, 16)
2364 0 : intra_pred_highbd_sized(dc_left, 32, 32)
2365 0 : intra_pred_highbd_sized(dc_left, 64, 64)
2366 :
2367 0 : intra_pred_highbd_sized(dc_left, 4, 8)
2368 0 : intra_pred_highbd_sized(dc_left, 4, 16)
2369 0 : intra_pred_highbd_sized(dc_left, 8, 4)
2370 0 : intra_pred_highbd_sized(dc_left, 8, 16)
2371 0 : intra_pred_highbd_sized(dc_left, 8, 32)
2372 0 : intra_pred_highbd_sized(dc_left, 16, 4)
2373 0 : intra_pred_highbd_sized(dc_left, 16, 8)
2374 0 : intra_pred_highbd_sized(dc_left, 16, 32)
2375 0 : intra_pred_highbd_sized(dc_left, 16, 64)
2376 0 : intra_pred_highbd_sized(dc_left, 32, 8)
2377 0 : intra_pred_highbd_sized(dc_left, 32, 16)
2378 0 : intra_pred_highbd_sized(dc_left, 32, 64)
2379 0 : intra_pred_highbd_sized(dc_left, 64, 16)
2380 0 : intra_pred_highbd_sized(dc_left, 64, 32)
2381 :
2382 0 : intra_pred_highbd_sized(dc_top, 2, 2)
2383 0 : intra_pred_highbd_sized(dc_top, 4, 4)
2384 0 : intra_pred_highbd_sized(dc_top, 8, 8)
2385 0 : intra_pred_highbd_sized(dc_top, 16, 16)
2386 0 : intra_pred_highbd_sized(dc_top, 32, 32)
2387 0 : intra_pred_highbd_sized(dc_top, 64, 64)
2388 :
2389 0 : intra_pred_highbd_sized(dc_top, 4, 8)
2390 0 : intra_pred_highbd_sized(dc_top, 4, 16)
2391 0 : intra_pred_highbd_sized(dc_top, 8, 4)
2392 0 : intra_pred_highbd_sized(dc_top, 8, 16)
2393 0 : intra_pred_highbd_sized(dc_top, 8, 32)
2394 0 : intra_pred_highbd_sized(dc_top, 16, 4)
2395 0 : intra_pred_highbd_sized(dc_top, 16, 8)
2396 0 : intra_pred_highbd_sized(dc_top, 16, 32)
2397 0 : intra_pred_highbd_sized(dc_top, 16, 64)
2398 0 : intra_pred_highbd_sized(dc_top, 32, 8)
2399 0 : intra_pred_highbd_sized(dc_top, 32, 16)
2400 0 : intra_pred_highbd_sized(dc_top, 32, 64)
2401 0 : intra_pred_highbd_sized(dc_top, 64, 16)
2402 0 : intra_pred_highbd_sized(dc_top, 64, 32)
2403 :
2404 0 : intra_pred_highbd_sized(v, 2, 2)
2405 0 : intra_pred_highbd_sized(v, 4, 4)
2406 0 : intra_pred_highbd_sized(v, 8, 8)
2407 0 : intra_pred_highbd_sized(v, 16, 16)
2408 0 : intra_pred_highbd_sized(v, 32, 32)
2409 0 : intra_pred_highbd_sized(v, 64, 64)
2410 :
2411 0 : intra_pred_highbd_sized(v, 4, 8)
2412 0 : intra_pred_highbd_sized(v, 4, 16)
2413 0 : intra_pred_highbd_sized(v, 8, 4)
2414 0 : intra_pred_highbd_sized(v, 8, 16)
2415 0 : intra_pred_highbd_sized(v, 8, 32)
2416 0 : intra_pred_highbd_sized(v, 16, 4)
2417 0 : intra_pred_highbd_sized(v, 16, 8)
2418 0 : intra_pred_highbd_sized(v, 16, 32)
2419 0 : intra_pred_highbd_sized(v, 16, 64)
2420 0 : intra_pred_highbd_sized(v, 32, 8)
2421 0 : intra_pred_highbd_sized(v, 32, 16)
2422 0 : intra_pred_highbd_sized(v, 32, 64)
2423 0 : intra_pred_highbd_sized(v, 64, 16)
2424 0 : intra_pred_highbd_sized(v, 64, 32)
2425 :
2426 0 : intra_pred_highbd_sized(h, 2, 2)
2427 0 : intra_pred_highbd_sized(h, 4, 4)
2428 0 : intra_pred_highbd_sized(h, 8, 8)
2429 0 : intra_pred_highbd_sized(h, 16, 16)
2430 0 : intra_pred_highbd_sized(h, 32, 32)
2431 0 : intra_pred_highbd_sized(h, 64, 64)
2432 :
2433 0 : intra_pred_highbd_sized(h, 4, 8)
2434 0 : intra_pred_highbd_sized(h, 4, 16)
2435 0 : intra_pred_highbd_sized(h, 8, 4)
2436 0 : intra_pred_highbd_sized(h, 8, 16)
2437 0 : intra_pred_highbd_sized(h, 8, 32)
2438 0 : intra_pred_highbd_sized(h, 16, 4)
2439 0 : intra_pred_highbd_sized(h, 16, 8)
2440 0 : intra_pred_highbd_sized(h, 16, 32)
2441 0 : intra_pred_highbd_sized(h, 16, 64)
2442 0 : intra_pred_highbd_sized(h, 32, 8)
2443 0 : intra_pred_highbd_sized(h, 32, 16)
2444 0 : intra_pred_highbd_sized(h, 32, 64)
2445 0 : intra_pred_highbd_sized(h, 64, 16)
2446 0 : intra_pred_highbd_sized(h, 64, 32)
2447 :
2448 0 : intra_pred_highbd_sized(smooth, 2, 2)
2449 0 : intra_pred_highbd_sized(smooth, 4, 4)
2450 0 : intra_pred_highbd_sized(smooth, 8, 8)
2451 0 : intra_pred_highbd_sized(smooth, 16, 16)
2452 0 : intra_pred_highbd_sized(smooth, 32, 32)
2453 0 : intra_pred_highbd_sized(smooth, 64, 64)
2454 :
2455 0 : intra_pred_highbd_sized(smooth, 4, 8)
2456 0 : intra_pred_highbd_sized(smooth, 4, 16)
2457 0 : intra_pred_highbd_sized(smooth, 8, 4)
2458 0 : intra_pred_highbd_sized(smooth, 8, 16)
2459 0 : intra_pred_highbd_sized(smooth, 8, 32)
2460 0 : intra_pred_highbd_sized(smooth, 16, 4)
2461 0 : intra_pred_highbd_sized(smooth, 16, 8)
2462 0 : intra_pred_highbd_sized(smooth, 16, 32)
2463 0 : intra_pred_highbd_sized(smooth, 16, 64)
2464 0 : intra_pred_highbd_sized(smooth, 32, 8)
2465 0 : intra_pred_highbd_sized(smooth, 32, 16)
2466 0 : intra_pred_highbd_sized(smooth, 32, 64)
2467 0 : intra_pred_highbd_sized(smooth, 64, 16)
2468 0 : intra_pred_highbd_sized(smooth, 64, 32)
2469 :
2470 0 : intra_pred_highbd_sized(smooth_h, 2, 2)
2471 0 : intra_pred_highbd_sized(smooth_h, 4, 4)
2472 0 : intra_pred_highbd_sized(smooth_h, 8, 8)
2473 0 : intra_pred_highbd_sized(smooth_h, 16, 16)
2474 0 : intra_pred_highbd_sized(smooth_h, 32, 32)
2475 0 : intra_pred_highbd_sized(smooth_h, 64, 64)
2476 :
2477 0 : intra_pred_highbd_sized(smooth_h, 4, 8)
2478 0 : intra_pred_highbd_sized(smooth_h, 4, 16)
2479 0 : intra_pred_highbd_sized(smooth_h, 8, 4)
2480 0 : intra_pred_highbd_sized(smooth_h, 8, 16)
2481 0 : intra_pred_highbd_sized(smooth_h, 8, 32)
2482 0 : intra_pred_highbd_sized(smooth_h, 16, 4)
2483 0 : intra_pred_highbd_sized(smooth_h, 16, 8)
2484 0 : intra_pred_highbd_sized(smooth_h, 16, 32)
2485 0 : intra_pred_highbd_sized(smooth_h, 16, 64)
2486 0 : intra_pred_highbd_sized(smooth_h, 32, 8)
2487 0 : intra_pred_highbd_sized(smooth_h, 32, 16)
2488 0 : intra_pred_highbd_sized(smooth_h, 32, 64)
2489 0 : intra_pred_highbd_sized(smooth_h, 64, 16)
2490 0 : intra_pred_highbd_sized(smooth_h, 64, 32)
2491 :
2492 0 : intra_pred_highbd_sized(smooth_v, 2, 2)
2493 0 : intra_pred_highbd_sized(smooth_v, 4, 4)
2494 0 : intra_pred_highbd_sized(smooth_v, 8, 8)
2495 0 : intra_pred_highbd_sized(smooth_v, 16, 16)
2496 0 : intra_pred_highbd_sized(smooth_v, 32, 32)
2497 0 : intra_pred_highbd_sized(smooth_v, 64, 64)
2498 :
2499 0 : intra_pred_highbd_sized(smooth_v, 4, 8)
2500 0 : intra_pred_highbd_sized(smooth_v, 4, 16)
2501 0 : intra_pred_highbd_sized(smooth_v, 8, 4)
2502 0 : intra_pred_highbd_sized(smooth_v, 8, 16)
2503 0 : intra_pred_highbd_sized(smooth_v, 8, 32)
2504 0 : intra_pred_highbd_sized(smooth_v, 16, 4)
2505 0 : intra_pred_highbd_sized(smooth_v, 16, 8)
2506 0 : intra_pred_highbd_sized(smooth_v, 16, 32)
2507 0 : intra_pred_highbd_sized(smooth_v, 16, 64)
2508 0 : intra_pred_highbd_sized(smooth_v, 32, 8)
2509 0 : intra_pred_highbd_sized(smooth_v, 32, 16)
2510 0 : intra_pred_highbd_sized(smooth_v, 32, 64)
2511 0 : intra_pred_highbd_sized(smooth_v, 64, 16)
2512 0 : intra_pred_highbd_sized(smooth_v, 64, 32)
2513 :
2514 0 : intra_pred_highbd_sized(paeth, 2, 2)
2515 0 : intra_pred_highbd_sized(paeth, 4, 4)
2516 0 : intra_pred_highbd_sized(paeth, 8, 8)
2517 0 : intra_pred_highbd_sized(paeth, 16, 16)
2518 0 : intra_pred_highbd_sized(paeth, 32, 32)
2519 0 : intra_pred_highbd_sized(paeth, 64, 64)
2520 0 : intra_pred_highbd_sized(paeth, 4, 8)
2521 0 : intra_pred_highbd_sized(paeth, 4, 16)
2522 0 : intra_pred_highbd_sized(paeth, 8, 4)
2523 0 : intra_pred_highbd_sized(paeth, 8, 16)
2524 0 : intra_pred_highbd_sized(paeth, 8, 32)
2525 0 : intra_pred_highbd_sized(paeth, 16, 4)
2526 0 : intra_pred_highbd_sized(paeth, 16, 8)
2527 0 : intra_pred_highbd_sized(paeth, 16, 32)
2528 0 : intra_pred_highbd_sized(paeth, 16, 64)
2529 0 : intra_pred_highbd_sized(paeth, 32, 8)
2530 0 : intra_pred_highbd_sized(paeth, 32, 16)
2531 0 : intra_pred_highbd_sized(paeth, 32, 64)
2532 0 : intra_pred_highbd_sized(paeth, 64, 16)
2533 0 : intra_pred_highbd_sized(paeth, 64, 32)
2534 :
2535 : IntraPredFnC dc_pred_c[2][2];
2536 : IntraHighBdPredFnC highbd_dc_pred_c[2][2];
2537 3 : void init_intra_dc_predictors_c_internal(void)
2538 : {
2539 3 : dc_pred_c[0][0] = dc_128_predictor;
2540 3 : dc_pred_c[0][1] = dc_top_predictor;
2541 3 : dc_pred_c[1][0] = dc_left_predictor;
2542 3 : dc_pred_c[1][1] = dc_predictor;
2543 :
2544 3 : highbd_dc_pred_c[0][0] = highbd_dc_128_predictor;
2545 3 : highbd_dc_pred_c[0][1] = highbd_dc_top_predictor;
2546 3 : highbd_dc_pred_c[1][0] = highbd_dc_left_predictor;
2547 3 : highbd_dc_pred_c[1][1] = highbd_dc_predictor;
2548 3 : }
2549 :
2550 3 : /*static*/ void init_intra_predictors_internal(void) {
2551 3 : pred[V_PRED][TX_4X4] = eb_aom_v_predictor_4x4;
2552 3 : pred[V_PRED][TX_8X8] = eb_aom_v_predictor_8x8;
2553 3 : pred[V_PRED][TX_16X16] = eb_aom_v_predictor_16x16;
2554 3 : pred[V_PRED][TX_32X32] = eb_aom_v_predictor_32x32;
2555 3 : pred[V_PRED][TX_64X64] = eb_aom_v_predictor_64x64;
2556 3 : pred[V_PRED][TX_4X8] = eb_aom_v_predictor_4x8;
2557 3 : pred[V_PRED][TX_4X16] = eb_aom_v_predictor_4x16;
2558 :
2559 3 : pred[V_PRED][TX_8X4] = eb_aom_v_predictor_8x4;
2560 3 : pred[V_PRED][TX_8X16] = eb_aom_v_predictor_8x16;
2561 3 : pred[V_PRED][TX_8X32] = eb_aom_v_predictor_8x32;
2562 :
2563 3 : pred[V_PRED][TX_16X4] = eb_aom_v_predictor_16x4;
2564 3 : pred[V_PRED][TX_16X8] = eb_aom_v_predictor_16x8;
2565 3 : pred[V_PRED][TX_16X32] = eb_aom_v_predictor_16x32;
2566 3 : pred[V_PRED][TX_16X64] = eb_aom_v_predictor_16x64;
2567 :
2568 3 : pred[V_PRED][TX_32X8] = eb_aom_v_predictor_32x8;
2569 3 : pred[V_PRED][TX_32X16] = eb_aom_v_predictor_32x16;
2570 3 : pred[V_PRED][TX_32X64] = eb_aom_v_predictor_32x64;
2571 :
2572 3 : pred[V_PRED][TX_64X16] = eb_aom_v_predictor_64x16;
2573 3 : pred[V_PRED][TX_64X32] = eb_aom_v_predictor_64x32;
2574 :
2575 3 : pred[H_PRED][TX_4X4] = eb_aom_h_predictor_4x4;
2576 3 : pred[H_PRED][TX_8X8] = eb_aom_h_predictor_8x8;
2577 3 : pred[H_PRED][TX_16X16] = eb_aom_h_predictor_16x16;
2578 3 : pred[H_PRED][TX_32X32] = eb_aom_h_predictor_32x32;
2579 3 : pred[H_PRED][TX_64X64] = eb_aom_h_predictor_64x64;
2580 :
2581 3 : pred[H_PRED][TX_4X8] = eb_aom_h_predictor_4x8;
2582 3 : pred[H_PRED][TX_4X16] = eb_aom_h_predictor_4x16;
2583 :
2584 3 : pred[H_PRED][TX_8X4] = eb_aom_h_predictor_8x4;
2585 3 : pred[H_PRED][TX_8X16] = eb_aom_h_predictor_8x16;
2586 3 : pred[H_PRED][TX_8X32] = eb_aom_h_predictor_8x32;
2587 :
2588 3 : pred[H_PRED][TX_16X4] = eb_aom_h_predictor_16x4;
2589 3 : pred[H_PRED][TX_16X8] = eb_aom_h_predictor_16x8;
2590 3 : pred[H_PRED][TX_16X32] = eb_aom_h_predictor_16x32;
2591 3 : pred[H_PRED][TX_16X64] = eb_aom_h_predictor_16x64;
2592 :
2593 3 : pred[H_PRED][TX_32X8] = eb_aom_h_predictor_32x8;
2594 3 : pred[H_PRED][TX_32X16] = eb_aom_h_predictor_32x16;
2595 3 : pred[H_PRED][TX_32X64] = eb_aom_h_predictor_32x64;
2596 :
2597 3 : pred[H_PRED][TX_64X16] = eb_aom_h_predictor_64x16;
2598 3 : pred[H_PRED][TX_64X32] = eb_aom_h_predictor_64x32;
2599 :
2600 3 : pred[SMOOTH_PRED][TX_4X4] = eb_aom_smooth_predictor_4x4;
2601 3 : pred[SMOOTH_PRED][TX_8X8] = eb_aom_smooth_predictor_8x8;
2602 3 : pred[SMOOTH_PRED][TX_16X16] = eb_aom_smooth_predictor_16x16;
2603 3 : pred[SMOOTH_PRED][TX_32X32] = eb_aom_smooth_predictor_32x32;
2604 3 : pred[SMOOTH_PRED][TX_64X64] = eb_aom_smooth_predictor_64x64;
2605 :
2606 3 : pred[SMOOTH_PRED][TX_4X8] = eb_aom_smooth_predictor_4x8;
2607 3 : pred[SMOOTH_PRED][TX_4X16] = eb_aom_smooth_predictor_4x16;
2608 :
2609 3 : pred[SMOOTH_PRED][TX_8X4] = eb_aom_smooth_predictor_8x4;
2610 3 : pred[SMOOTH_PRED][TX_8X16] = eb_aom_smooth_predictor_8x16;
2611 3 : pred[SMOOTH_PRED][TX_8X32] = eb_aom_smooth_predictor_8x32;
2612 :
2613 3 : pred[SMOOTH_PRED][TX_16X4] = eb_aom_smooth_predictor_16x4;
2614 3 : pred[SMOOTH_PRED][TX_16X8] = eb_aom_smooth_predictor_16x8;
2615 3 : pred[SMOOTH_PRED][TX_16X32] = eb_aom_smooth_predictor_16x32;
2616 3 : pred[SMOOTH_PRED][TX_16X64] = eb_aom_smooth_predictor_16x64;
2617 :
2618 3 : pred[SMOOTH_PRED][TX_32X8] = eb_aom_smooth_predictor_32x8;
2619 3 : pred[SMOOTH_PRED][TX_32X16] = eb_aom_smooth_predictor_32x16;
2620 3 : pred[SMOOTH_PRED][TX_32X64] = eb_aom_smooth_predictor_32x64;
2621 :
2622 3 : pred[SMOOTH_PRED][TX_64X16] = eb_aom_smooth_predictor_64x16;
2623 3 : pred[SMOOTH_PRED][TX_64X32] = eb_aom_smooth_predictor_64x32;
2624 :
2625 3 : pred[SMOOTH_V_PRED][TX_4X4] = eb_aom_smooth_v_predictor_4x4;
2626 3 : pred[SMOOTH_V_PRED][TX_8X8] = eb_aom_smooth_v_predictor_8x8;
2627 3 : pred[SMOOTH_V_PRED][TX_16X16] = eb_aom_smooth_v_predictor_16x16;
2628 3 : pred[SMOOTH_V_PRED][TX_32X32] = eb_aom_smooth_v_predictor_32x32;
2629 3 : pred[SMOOTH_V_PRED][TX_64X64] = eb_aom_smooth_v_predictor_64x64;
2630 :
2631 3 : pred[SMOOTH_V_PRED][TX_4X8] = eb_aom_smooth_v_predictor_4x8;
2632 3 : pred[SMOOTH_V_PRED][TX_4X16] = eb_aom_smooth_v_predictor_4x16;
2633 :
2634 3 : pred[SMOOTH_V_PRED][TX_8X4] = eb_aom_smooth_v_predictor_8x4;
2635 3 : pred[SMOOTH_V_PRED][TX_8X16] = eb_aom_smooth_v_predictor_8x16;
2636 3 : pred[SMOOTH_V_PRED][TX_8X32] = eb_aom_smooth_v_predictor_8x32;
2637 :
2638 3 : pred[SMOOTH_V_PRED][TX_16X4] = eb_aom_smooth_v_predictor_16x4;
2639 3 : pred[SMOOTH_V_PRED][TX_16X8] = eb_aom_smooth_v_predictor_16x8;
2640 3 : pred[SMOOTH_V_PRED][TX_16X32] = eb_aom_smooth_v_predictor_16x32;
2641 3 : pred[SMOOTH_V_PRED][TX_16X64] = eb_aom_smooth_v_predictor_16x64;
2642 :
2643 3 : pred[SMOOTH_V_PRED][TX_32X8] = eb_aom_smooth_v_predictor_32x8;
2644 3 : pred[SMOOTH_V_PRED][TX_32X16] = eb_aom_smooth_v_predictor_32x16;
2645 3 : pred[SMOOTH_V_PRED][TX_32X64] = eb_aom_smooth_v_predictor_32x64;
2646 :
2647 3 : pred[SMOOTH_V_PRED][TX_64X16] = eb_aom_smooth_v_predictor_64x16;
2648 3 : pred[SMOOTH_V_PRED][TX_64X32] = eb_aom_smooth_v_predictor_64x32;
2649 :
2650 3 : pred[SMOOTH_H_PRED][TX_4X4] = eb_aom_smooth_h_predictor_4x4;
2651 3 : pred[SMOOTH_H_PRED][TX_8X8] = eb_aom_smooth_h_predictor_8x8;
2652 3 : pred[SMOOTH_H_PRED][TX_16X16] = eb_aom_smooth_h_predictor_16x16;
2653 3 : pred[SMOOTH_H_PRED][TX_32X32] = eb_aom_smooth_h_predictor_32x32;
2654 3 : pred[SMOOTH_H_PRED][TX_64X64] = eb_aom_smooth_h_predictor_64x64;
2655 :
2656 3 : pred[SMOOTH_H_PRED][TX_4X8] = eb_aom_smooth_h_predictor_4x8;
2657 3 : pred[SMOOTH_H_PRED][TX_4X16] = eb_aom_smooth_h_predictor_4x16;
2658 :
2659 3 : pred[SMOOTH_H_PRED][TX_8X4] = eb_aom_smooth_h_predictor_8x4;
2660 3 : pred[SMOOTH_H_PRED][TX_8X16] = eb_aom_smooth_h_predictor_8x16;
2661 3 : pred[SMOOTH_H_PRED][TX_8X32] = eb_aom_smooth_h_predictor_8x32;
2662 :
2663 3 : pred[SMOOTH_H_PRED][TX_16X4] = eb_aom_smooth_h_predictor_16x4;
2664 3 : pred[SMOOTH_H_PRED][TX_16X8] = eb_aom_smooth_h_predictor_16x8;
2665 3 : pred[SMOOTH_H_PRED][TX_16X32] = eb_aom_smooth_h_predictor_16x32;
2666 3 : pred[SMOOTH_H_PRED][TX_16X64] = eb_aom_smooth_h_predictor_16x64;
2667 :
2668 3 : pred[SMOOTH_H_PRED][TX_32X8] = eb_aom_smooth_h_predictor_32x8;
2669 3 : pred[SMOOTH_H_PRED][TX_32X16] = eb_aom_smooth_h_predictor_32x16;
2670 3 : pred[SMOOTH_H_PRED][TX_32X64] = eb_aom_smooth_h_predictor_32x64;
2671 :
2672 3 : pred[SMOOTH_H_PRED][TX_64X16] = eb_aom_smooth_h_predictor_64x16;
2673 3 : pred[SMOOTH_H_PRED][TX_64X32] = eb_aom_smooth_h_predictor_64x32;
2674 :
2675 3 : pred[PAETH_PRED][TX_4X4] = eb_aom_paeth_predictor_4x4;
2676 3 : pred[PAETH_PRED][TX_8X8] = eb_aom_paeth_predictor_8x8;
2677 3 : pred[PAETH_PRED][TX_16X16] = eb_aom_paeth_predictor_16x16;
2678 3 : pred[PAETH_PRED][TX_32X32] = eb_aom_paeth_predictor_32x32;
2679 3 : pred[PAETH_PRED][TX_64X64] = eb_aom_paeth_predictor_64x64;
2680 :
2681 3 : pred[PAETH_PRED][TX_4X8] = eb_aom_paeth_predictor_4x8;
2682 3 : pred[PAETH_PRED][TX_4X16] = eb_aom_paeth_predictor_4x16;
2683 :
2684 3 : pred[PAETH_PRED][TX_8X4] = eb_aom_paeth_predictor_8x4;
2685 3 : pred[PAETH_PRED][TX_8X16] = eb_aom_paeth_predictor_8x16;
2686 3 : pred[PAETH_PRED][TX_8X32] = eb_aom_paeth_predictor_8x32;
2687 :
2688 3 : pred[PAETH_PRED][TX_16X4] = eb_aom_paeth_predictor_16x4;
2689 3 : pred[PAETH_PRED][TX_16X8] = eb_aom_paeth_predictor_16x8;
2690 3 : pred[PAETH_PRED][TX_16X32] = eb_aom_paeth_predictor_16x32;
2691 3 : pred[PAETH_PRED][TX_16X64] = eb_aom_paeth_predictor_16x64;
2692 :
2693 3 : pred[PAETH_PRED][TX_32X8] = eb_aom_paeth_predictor_32x8;
2694 3 : pred[PAETH_PRED][TX_32X16] = eb_aom_paeth_predictor_32x16;
2695 3 : pred[PAETH_PRED][TX_32X64] = eb_aom_paeth_predictor_32x64;
2696 :
2697 3 : pred[PAETH_PRED][TX_64X16] = eb_aom_paeth_predictor_64x16;
2698 3 : pred[PAETH_PRED][TX_64X32] = eb_aom_paeth_predictor_64x32;
2699 3 : dc_pred[0][0][TX_4X4] = eb_aom_dc_128_predictor_4x4;
2700 3 : dc_pred[0][0][TX_8X8] = eb_aom_dc_128_predictor_8x8;
2701 3 : dc_pred[0][0][TX_16X16] = eb_aom_dc_128_predictor_16x16;
2702 3 : dc_pred[0][0][TX_32X32] = eb_aom_dc_128_predictor_32x32;
2703 3 : dc_pred[0][0][TX_64X64] = eb_aom_dc_128_predictor_64x64;
2704 :
2705 3 : dc_pred[0][0][TX_4X8] = eb_aom_dc_128_predictor_4x8;
2706 3 : dc_pred[0][0][TX_4X16] = eb_aom_dc_128_predictor_4x16;
2707 :
2708 3 : dc_pred[0][0][TX_8X4] = eb_aom_dc_128_predictor_8x4;
2709 3 : dc_pred[0][0][TX_8X16] = eb_aom_dc_128_predictor_8x16;
2710 3 : dc_pred[0][0][TX_8X32] = eb_aom_dc_128_predictor_8x32;
2711 :
2712 3 : dc_pred[0][0][TX_16X4] = eb_aom_dc_128_predictor_16x4;
2713 3 : dc_pred[0][0][TX_16X8] = eb_aom_dc_128_predictor_16x8;
2714 3 : dc_pred[0][0][TX_16X32] = eb_aom_dc_128_predictor_16x32;
2715 3 : dc_pred[0][0][TX_16X64] = eb_aom_dc_128_predictor_16x64;
2716 :
2717 3 : dc_pred[0][0][TX_32X8] = eb_aom_dc_128_predictor_32x8;
2718 3 : dc_pred[0][0][TX_32X16] = eb_aom_dc_128_predictor_32x16;
2719 3 : dc_pred[0][0][TX_32X64] = eb_aom_dc_128_predictor_32x64;
2720 :
2721 3 : dc_pred[0][0][TX_64X16] = eb_aom_dc_128_predictor_64x16;
2722 3 : dc_pred[0][0][TX_64X32] = eb_aom_dc_128_predictor_64x32;
2723 :
2724 3 : dc_pred[0][1][TX_4X4] = eb_aom_dc_top_predictor_4x4;
2725 3 : dc_pred[0][1][TX_8X8] = eb_aom_dc_top_predictor_8x8;
2726 3 : dc_pred[0][1][TX_16X16] = eb_aom_dc_top_predictor_16x16;
2727 3 : dc_pred[0][1][TX_32X32] = eb_aom_dc_top_predictor_32x32;
2728 3 : dc_pred[0][1][TX_64X64] = eb_aom_dc_top_predictor_64x64;
2729 :
2730 3 : dc_pred[0][1][TX_4X8] = eb_aom_dc_top_predictor_4x8;
2731 3 : dc_pred[0][1][TX_4X16] = eb_aom_dc_top_predictor_4x16;
2732 :
2733 3 : dc_pred[0][1][TX_8X4] = eb_aom_dc_top_predictor_8x4;
2734 3 : dc_pred[0][1][TX_8X16] = eb_aom_dc_top_predictor_8x16;
2735 3 : dc_pred[0][1][TX_8X32] = eb_aom_dc_top_predictor_8x32;
2736 :
2737 3 : dc_pred[0][1][TX_16X4] = eb_aom_dc_top_predictor_16x4;
2738 3 : dc_pred[0][1][TX_16X8] = eb_aom_dc_top_predictor_16x8;
2739 3 : dc_pred[0][1][TX_16X32] = eb_aom_dc_top_predictor_16x32;
2740 3 : dc_pred[0][1][TX_16X64] = eb_aom_dc_top_predictor_16x64;
2741 :
2742 3 : dc_pred[0][1][TX_32X8] = eb_aom_dc_top_predictor_32x8;
2743 3 : dc_pred[0][1][TX_32X16] = eb_aom_dc_top_predictor_32x16;
2744 3 : dc_pred[0][1][TX_32X64] = eb_aom_dc_top_predictor_32x64;
2745 :
2746 3 : dc_pred[0][1][TX_64X16] = eb_aom_dc_top_predictor_64x16;
2747 3 : dc_pred[0][1][TX_64X32] = eb_aom_dc_top_predictor_64x32;
2748 :
2749 3 : dc_pred[1][0][TX_4X4] = eb_aom_dc_left_predictor_4x4;
2750 3 : dc_pred[1][0][TX_8X8] = eb_aom_dc_left_predictor_8x8;
2751 3 : dc_pred[1][0][TX_16X16] = eb_aom_dc_left_predictor_16x16;
2752 3 : dc_pred[1][0][TX_32X32] = eb_aom_dc_left_predictor_32x32;
2753 3 : dc_pred[1][0][TX_64X64] = eb_aom_dc_left_predictor_64x64;
2754 3 : dc_pred[1][0][TX_4X8] = eb_aom_dc_left_predictor_4x8;
2755 3 : dc_pred[1][0][TX_4X16] = eb_aom_dc_left_predictor_4x16;
2756 :
2757 3 : dc_pred[1][0][TX_8X4] = eb_aom_dc_left_predictor_8x4;
2758 3 : dc_pred[1][0][TX_8X16] = eb_aom_dc_left_predictor_8x16;
2759 3 : dc_pred[1][0][TX_8X32] = eb_aom_dc_left_predictor_8x32;
2760 :
2761 3 : dc_pred[1][0][TX_16X4] = eb_aom_dc_left_predictor_16x4;
2762 3 : dc_pred[1][0][TX_16X8] = eb_aom_dc_left_predictor_16x8;
2763 3 : dc_pred[1][0][TX_16X32] = eb_aom_dc_left_predictor_16x32;
2764 3 : dc_pred[1][0][TX_16X64] = eb_aom_dc_left_predictor_16x64;
2765 :
2766 3 : dc_pred[1][0][TX_32X8] = eb_aom_dc_left_predictor_32x8;
2767 3 : dc_pred[1][0][TX_32X16] = eb_aom_dc_left_predictor_32x16;
2768 3 : dc_pred[1][0][TX_32X64] = eb_aom_dc_left_predictor_32x64;
2769 :
2770 3 : dc_pred[1][0][TX_64X16] = eb_aom_dc_left_predictor_64x16;
2771 3 : dc_pred[1][0][TX_64X32] = eb_aom_dc_left_predictor_64x32;
2772 :
2773 3 : dc_pred[1][1][TX_4X4] = eb_aom_dc_predictor_4x4;
2774 3 : dc_pred[1][1][TX_8X8] = eb_aom_dc_predictor_8x8;
2775 3 : dc_pred[1][1][TX_16X16] = eb_aom_dc_predictor_16x16;
2776 3 : dc_pred[1][1][TX_32X32] = eb_aom_dc_predictor_32x32;
2777 3 : dc_pred[1][1][TX_64X64] = eb_aom_dc_predictor_64x64;
2778 3 : dc_pred[1][1][TX_4X8] = eb_aom_dc_predictor_4x8;
2779 3 : dc_pred[1][1][TX_4X16] = eb_aom_dc_predictor_4x16;
2780 :
2781 3 : dc_pred[1][1][TX_8X4] = eb_aom_dc_predictor_8x4;
2782 3 : dc_pred[1][1][TX_8X16] = eb_aom_dc_predictor_8x16;
2783 3 : dc_pred[1][1][TX_8X32] = eb_aom_dc_predictor_8x32;
2784 :
2785 3 : dc_pred[1][1][TX_16X4] = eb_aom_dc_predictor_16x4;
2786 3 : dc_pred[1][1][TX_16X8] = eb_aom_dc_predictor_16x8;
2787 3 : dc_pred[1][1][TX_16X32] = eb_aom_dc_predictor_16x32;
2788 3 : dc_pred[1][1][TX_16X64] = eb_aom_dc_predictor_16x64;
2789 :
2790 3 : dc_pred[1][1][TX_32X8] = eb_aom_dc_predictor_32x8;
2791 3 : dc_pred[1][1][TX_32X16] = eb_aom_dc_predictor_32x16;
2792 3 : dc_pred[1][1][TX_32X64] = eb_aom_dc_predictor_32x64;
2793 :
2794 3 : dc_pred[1][1][TX_64X16] = eb_aom_dc_predictor_64x16;
2795 3 : dc_pred[1][1][TX_64X32] = eb_aom_dc_predictor_64x32;
2796 :
2797 3 : pred_high[V_PRED][TX_4X4] = eb_aom_highbd_v_predictor_4x4;
2798 3 : pred_high[V_PRED][TX_8X8] = eb_aom_highbd_v_predictor_8x8;
2799 3 : pred_high[V_PRED][TX_16X16] = eb_aom_highbd_v_predictor_16x16;
2800 3 : pred_high[V_PRED][TX_32X32] = eb_aom_highbd_v_predictor_32x32;
2801 3 : pred_high[V_PRED][TX_64X64] = eb_aom_highbd_v_predictor_64x64;
2802 :
2803 3 : pred_high[V_PRED][TX_4X8] = eb_aom_highbd_v_predictor_4x8;
2804 3 : pred_high[V_PRED][TX_4X16] = eb_aom_highbd_v_predictor_4x16;
2805 :
2806 3 : pred_high[V_PRED][TX_8X4] = eb_aom_highbd_v_predictor_8x4;
2807 3 : pred_high[V_PRED][TX_8X16] = eb_aom_highbd_v_predictor_8x16;
2808 3 : pred_high[V_PRED][TX_8X32] = eb_aom_highbd_v_predictor_8x32;
2809 :
2810 3 : pred_high[V_PRED][TX_16X4] = eb_aom_highbd_v_predictor_16x4;
2811 3 : pred_high[V_PRED][TX_16X8] = eb_aom_highbd_v_predictor_16x8;
2812 3 : pred_high[V_PRED][TX_16X32] = eb_aom_highbd_v_predictor_16x32;
2813 3 : pred_high[V_PRED][TX_16X64] = eb_aom_highbd_v_predictor_16x64;
2814 :
2815 3 : pred_high[V_PRED][TX_32X8] = eb_aom_highbd_v_predictor_32x8;
2816 3 : pred_high[V_PRED][TX_32X16] = eb_aom_highbd_v_predictor_32x16;
2817 3 : pred_high[V_PRED][TX_32X64] = eb_aom_highbd_v_predictor_32x64;
2818 :
2819 3 : pred_high[V_PRED][TX_64X16] = eb_aom_highbd_v_predictor_64x16;
2820 3 : pred_high[V_PRED][TX_64X32] = eb_aom_highbd_v_predictor_64x32;
2821 :
2822 3 : pred_high[H_PRED][TX_4X4] = eb_aom_highbd_h_predictor_4x4;
2823 3 : pred_high[H_PRED][TX_8X8] = eb_aom_highbd_h_predictor_8x8;
2824 3 : pred_high[H_PRED][TX_16X16] = eb_aom_highbd_h_predictor_16x16;
2825 3 : pred_high[H_PRED][TX_32X32] = eb_aom_highbd_h_predictor_32x32;
2826 3 : pred_high[H_PRED][TX_64X64] = eb_aom_highbd_h_predictor_64x64;
2827 :
2828 3 : pred_high[H_PRED][TX_4X8] = eb_aom_highbd_h_predictor_4x8;
2829 3 : pred_high[H_PRED][TX_4X16] = eb_aom_highbd_h_predictor_4x16;
2830 :
2831 3 : pred_high[H_PRED][TX_8X4] = eb_aom_highbd_h_predictor_8x4;
2832 3 : pred_high[H_PRED][TX_8X16] = eb_aom_highbd_h_predictor_8x16;
2833 3 : pred_high[H_PRED][TX_8X32] = eb_aom_highbd_h_predictor_8x32;
2834 :
2835 3 : pred_high[H_PRED][TX_16X4] = eb_aom_highbd_h_predictor_16x4;
2836 3 : pred_high[H_PRED][TX_16X8] = eb_aom_highbd_h_predictor_16x8;
2837 3 : pred_high[H_PRED][TX_16X32] = eb_aom_highbd_h_predictor_16x32;
2838 3 : pred_high[H_PRED][TX_16X64] = eb_aom_highbd_h_predictor_16x64;
2839 :
2840 3 : pred_high[H_PRED][TX_32X8] = eb_aom_highbd_h_predictor_32x8;
2841 3 : pred_high[H_PRED][TX_32X16] = eb_aom_highbd_h_predictor_32x16;
2842 3 : pred_high[H_PRED][TX_32X64] = eb_aom_highbd_h_predictor_32x64;
2843 :
2844 3 : pred_high[H_PRED][TX_64X16] = eb_aom_highbd_h_predictor_64x16;
2845 3 : pred_high[H_PRED][TX_64X32] = eb_aom_highbd_h_predictor_64x32;
2846 :
2847 3 : pred_high[SMOOTH_PRED][TX_4X4] = eb_aom_highbd_smooth_predictor_4x4;
2848 3 : pred_high[SMOOTH_PRED][TX_8X8] = eb_aom_highbd_smooth_predictor_8x8;
2849 3 : pred_high[SMOOTH_PRED][TX_16X16] = eb_aom_highbd_smooth_predictor_16x16;
2850 3 : pred_high[SMOOTH_PRED][TX_32X32] = eb_aom_highbd_smooth_predictor_32x32;
2851 3 : pred_high[SMOOTH_PRED][TX_64X64] = eb_aom_highbd_smooth_predictor_64x64;
2852 :
2853 3 : pred_high[SMOOTH_PRED][TX_4X8] = eb_aom_highbd_smooth_predictor_4x8;
2854 3 : pred_high[SMOOTH_PRED][TX_4X16] = eb_aom_highbd_smooth_predictor_4x16;
2855 :
2856 3 : pred_high[SMOOTH_PRED][TX_8X4] = eb_aom_highbd_smooth_predictor_8x4;
2857 3 : pred_high[SMOOTH_PRED][TX_8X16] = eb_aom_highbd_smooth_predictor_8x16;
2858 3 : pred_high[SMOOTH_PRED][TX_8X32] = eb_aom_highbd_smooth_predictor_8x32;
2859 :
2860 3 : pred_high[SMOOTH_PRED][TX_16X4] = eb_aom_highbd_smooth_predictor_16x4;
2861 3 : pred_high[SMOOTH_PRED][TX_16X8] = eb_aom_highbd_smooth_predictor_16x8;
2862 3 : pred_high[SMOOTH_PRED][TX_16X32] = eb_aom_highbd_smooth_predictor_16x32;
2863 3 : pred_high[SMOOTH_PRED][TX_16X64] = eb_aom_highbd_smooth_predictor_16x64;
2864 :
2865 3 : pred_high[SMOOTH_PRED][TX_32X8] = eb_aom_highbd_smooth_predictor_32x8;
2866 3 : pred_high[SMOOTH_PRED][TX_32X16] = eb_aom_highbd_smooth_predictor_32x16;
2867 3 : pred_high[SMOOTH_PRED][TX_32X64] = eb_aom_highbd_smooth_predictor_32x64;
2868 :
2869 3 : pred_high[SMOOTH_PRED][TX_64X16] = eb_aom_highbd_smooth_predictor_64x16;
2870 3 : pred_high[SMOOTH_PRED][TX_64X32] = eb_aom_highbd_smooth_predictor_64x32;
2871 :
2872 3 : pred_high[SMOOTH_V_PRED][TX_4X4] = eb_aom_highbd_smooth_v_predictor_4x4;
2873 3 : pred_high[SMOOTH_V_PRED][TX_8X8] = eb_aom_highbd_smooth_v_predictor_8x8;
2874 3 : pred_high[SMOOTH_V_PRED][TX_16X16] = eb_aom_highbd_smooth_v_predictor_16x16;
2875 3 : pred_high[SMOOTH_V_PRED][TX_32X32] = eb_aom_highbd_smooth_v_predictor_32x32;
2876 3 : pred_high[SMOOTH_V_PRED][TX_64X64] = eb_aom_highbd_smooth_v_predictor_64x64;
2877 :
2878 3 : pred_high[SMOOTH_V_PRED][TX_4X8] = eb_aom_highbd_smooth_v_predictor_4x8;
2879 3 : pred_high[SMOOTH_V_PRED][TX_4X16] = eb_aom_highbd_smooth_v_predictor_4x16;
2880 :
2881 3 : pred_high[SMOOTH_V_PRED][TX_8X4] = eb_aom_highbd_smooth_v_predictor_8x4;
2882 3 : pred_high[SMOOTH_V_PRED][TX_8X16] = eb_aom_highbd_smooth_v_predictor_8x16;
2883 3 : pred_high[SMOOTH_V_PRED][TX_8X32] = eb_aom_highbd_smooth_v_predictor_8x32;
2884 :
2885 3 : pred_high[SMOOTH_V_PRED][TX_16X4] = eb_aom_highbd_smooth_v_predictor_16x4;
2886 3 : pred_high[SMOOTH_V_PRED][TX_16X8] = eb_aom_highbd_smooth_v_predictor_16x8;
2887 3 : pred_high[SMOOTH_V_PRED][TX_16X32] = eb_aom_highbd_smooth_v_predictor_16x32;
2888 3 : pred_high[SMOOTH_V_PRED][TX_16X64] = eb_aom_highbd_smooth_v_predictor_16x64;
2889 :
2890 3 : pred_high[SMOOTH_V_PRED][TX_32X8] = eb_aom_highbd_smooth_v_predictor_32x8;
2891 3 : pred_high[SMOOTH_V_PRED][TX_32X16] = eb_aom_highbd_smooth_v_predictor_32x16;
2892 3 : pred_high[SMOOTH_V_PRED][TX_32X64] = eb_aom_highbd_smooth_v_predictor_32x64;
2893 :
2894 3 : pred_high[SMOOTH_V_PRED][TX_64X16] = eb_aom_highbd_smooth_v_predictor_64x16;
2895 3 : pred_high[SMOOTH_V_PRED][TX_64X32] = eb_aom_highbd_smooth_v_predictor_64x32;
2896 :
2897 3 : pred_high[SMOOTH_H_PRED][TX_4X4] = eb_aom_highbd_smooth_h_predictor_4x4;
2898 3 : pred_high[SMOOTH_H_PRED][TX_8X8] = eb_aom_highbd_smooth_h_predictor_8x8;
2899 3 : pred_high[SMOOTH_H_PRED][TX_16X16] = eb_aom_highbd_smooth_h_predictor_16x16;
2900 3 : pred_high[SMOOTH_H_PRED][TX_32X32] = eb_aom_highbd_smooth_h_predictor_32x32;
2901 3 : pred_high[SMOOTH_H_PRED][TX_64X64] = eb_aom_highbd_smooth_h_predictor_64x64;
2902 :
2903 3 : pred_high[SMOOTH_H_PRED][TX_4X8] = eb_aom_highbd_smooth_h_predictor_4x8;
2904 3 : pred_high[SMOOTH_H_PRED][TX_4X16] = eb_aom_highbd_smooth_h_predictor_4x16;
2905 :
2906 3 : pred_high[SMOOTH_H_PRED][TX_8X4] = eb_aom_highbd_smooth_h_predictor_8x4;
2907 3 : pred_high[SMOOTH_H_PRED][TX_8X16] = eb_aom_highbd_smooth_h_predictor_8x16;
2908 3 : pred_high[SMOOTH_H_PRED][TX_8X32] = eb_aom_highbd_smooth_h_predictor_8x32;
2909 :
2910 3 : pred_high[SMOOTH_H_PRED][TX_16X4] = eb_aom_highbd_smooth_h_predictor_16x4;
2911 3 : pred_high[SMOOTH_H_PRED][TX_16X8] = eb_aom_highbd_smooth_h_predictor_16x8;
2912 3 : pred_high[SMOOTH_H_PRED][TX_16X32] = eb_aom_highbd_smooth_h_predictor_16x32;
2913 3 : pred_high[SMOOTH_H_PRED][TX_16X64] = eb_aom_highbd_smooth_h_predictor_16x64;
2914 :
2915 3 : pred_high[SMOOTH_H_PRED][TX_32X8] = eb_aom_highbd_smooth_h_predictor_32x8;
2916 3 : pred_high[SMOOTH_H_PRED][TX_32X16] = eb_aom_highbd_smooth_h_predictor_32x16;
2917 3 : pred_high[SMOOTH_H_PRED][TX_32X64] = eb_aom_highbd_smooth_h_predictor_32x64;
2918 :
2919 3 : pred_high[SMOOTH_H_PRED][TX_64X16] = eb_aom_highbd_smooth_h_predictor_64x16;
2920 3 : pred_high[SMOOTH_H_PRED][TX_64X32] = eb_aom_highbd_smooth_h_predictor_64x32;
2921 :
2922 3 : pred_high[PAETH_PRED][TX_4X4] = eb_aom_highbd_paeth_predictor_4x4;
2923 3 : pred_high[PAETH_PRED][TX_8X8] = eb_aom_highbd_paeth_predictor_8x8;
2924 3 : pred_high[PAETH_PRED][TX_16X16] = eb_aom_highbd_paeth_predictor_16x16;
2925 3 : pred_high[PAETH_PRED][TX_32X32] = eb_aom_highbd_paeth_predictor_32x32;
2926 3 : pred_high[PAETH_PRED][TX_64X64] = eb_aom_highbd_paeth_predictor_64x64;
2927 :
2928 3 : pred_high[PAETH_PRED][TX_4X8] = eb_aom_highbd_paeth_predictor_4x8;
2929 3 : pred_high[PAETH_PRED][TX_4X16] = eb_aom_highbd_paeth_predictor_4x16;
2930 :
2931 3 : pred_high[PAETH_PRED][TX_8X4] = eb_aom_highbd_paeth_predictor_8x4;
2932 3 : pred_high[PAETH_PRED][TX_8X16] = eb_aom_highbd_paeth_predictor_8x16;
2933 3 : pred_high[PAETH_PRED][TX_8X32] = eb_aom_highbd_paeth_predictor_8x32;
2934 :
2935 3 : pred_high[PAETH_PRED][TX_16X4] = eb_aom_highbd_paeth_predictor_16x4;
2936 3 : pred_high[PAETH_PRED][TX_16X8] = eb_aom_highbd_paeth_predictor_16x8;
2937 3 : pred_high[PAETH_PRED][TX_16X32] = eb_aom_highbd_paeth_predictor_16x32;
2938 3 : pred_high[PAETH_PRED][TX_16X64] = eb_aom_highbd_paeth_predictor_16x64;
2939 :
2940 3 : pred_high[PAETH_PRED][TX_32X8] = eb_aom_highbd_paeth_predictor_32x8;
2941 3 : pred_high[PAETH_PRED][TX_32X16] = eb_aom_highbd_paeth_predictor_32x16;
2942 3 : pred_high[PAETH_PRED][TX_32X64] = eb_aom_highbd_paeth_predictor_32x64;
2943 :
2944 3 : pred_high[PAETH_PRED][TX_64X16] = eb_aom_highbd_paeth_predictor_64x16;
2945 3 : pred_high[PAETH_PRED][TX_64X32] = eb_aom_highbd_paeth_predictor_64x32;
2946 3 : dc_pred_high[0][0][TX_4X4] = eb_aom_highbd_dc_128_predictor_4x4;
2947 3 : dc_pred_high[0][0][TX_8X8] = eb_aom_highbd_dc_128_predictor_8x8;
2948 3 : dc_pred_high[0][0][TX_16X16] = eb_aom_highbd_dc_128_predictor_16x16;
2949 3 : dc_pred_high[0][0][TX_32X32] = eb_aom_highbd_dc_128_predictor_32x32;
2950 3 : dc_pred_high[0][0][TX_64X64] = eb_aom_highbd_dc_128_predictor_64x64;
2951 :
2952 3 : dc_pred_high[0][0][TX_4X8] = eb_aom_highbd_dc_128_predictor_4x8;
2953 3 : dc_pred_high[0][0][TX_4X16] = eb_aom_highbd_dc_128_predictor_4x16;
2954 :
2955 3 : dc_pred_high[0][0][TX_8X4] = eb_aom_highbd_dc_128_predictor_8x4;
2956 3 : dc_pred_high[0][0][TX_8X16] = eb_aom_highbd_dc_128_predictor_8x16;
2957 3 : dc_pred_high[0][0][TX_8X32] = eb_aom_highbd_dc_128_predictor_8x32;
2958 :
2959 3 : dc_pred_high[0][0][TX_16X4] = eb_aom_highbd_dc_128_predictor_16x4;
2960 3 : dc_pred_high[0][0][TX_16X8] = eb_aom_highbd_dc_128_predictor_16x8;
2961 3 : dc_pred_high[0][0][TX_16X32] = eb_aom_highbd_dc_128_predictor_16x32;
2962 3 : dc_pred_high[0][0][TX_16X64] = eb_aom_highbd_dc_128_predictor_16x64;
2963 :
2964 3 : dc_pred_high[0][0][TX_32X8] = eb_aom_highbd_dc_128_predictor_32x8;
2965 3 : dc_pred_high[0][0][TX_32X16] = eb_aom_highbd_dc_128_predictor_32x16;
2966 3 : dc_pred_high[0][0][TX_32X64] = eb_aom_highbd_dc_128_predictor_32x64;
2967 :
2968 3 : dc_pred_high[0][0][TX_64X16] = eb_aom_highbd_dc_128_predictor_64x16;
2969 3 : dc_pred_high[0][0][TX_64X32] = eb_aom_highbd_dc_128_predictor_64x32;
2970 :
2971 3 : dc_pred_high[0][1][TX_4X4] = eb_aom_highbd_dc_top_predictor_4x4;
2972 3 : dc_pred_high[0][1][TX_8X8] = eb_aom_highbd_dc_top_predictor_8x8;
2973 3 : dc_pred_high[0][1][TX_16X16] = eb_aom_highbd_dc_top_predictor_16x16;
2974 3 : dc_pred_high[0][1][TX_32X32] = eb_aom_highbd_dc_top_predictor_32x32;
2975 3 : dc_pred_high[0][1][TX_64X64] = eb_aom_highbd_dc_top_predictor_64x64;
2976 :
2977 3 : dc_pred_high[0][1][TX_4X8] = eb_aom_highbd_dc_top_predictor_4x8;
2978 3 : dc_pred_high[0][1][TX_4X16] = eb_aom_highbd_dc_top_predictor_4x16;
2979 :
2980 3 : dc_pred_high[0][1][TX_8X4] = eb_aom_highbd_dc_top_predictor_8x4;
2981 3 : dc_pred_high[0][1][TX_8X16] = eb_aom_highbd_dc_top_predictor_8x16;
2982 3 : dc_pred_high[0][1][TX_8X32] = eb_aom_highbd_dc_top_predictor_8x32;
2983 :
2984 3 : dc_pred_high[0][1][TX_16X4] = eb_aom_highbd_dc_top_predictor_16x4;
2985 3 : dc_pred_high[0][1][TX_16X8] = eb_aom_highbd_dc_top_predictor_16x8;
2986 3 : dc_pred_high[0][1][TX_16X32] = eb_aom_highbd_dc_top_predictor_16x32;
2987 3 : dc_pred_high[0][1][TX_16X64] = eb_aom_highbd_dc_top_predictor_16x64;
2988 :
2989 3 : dc_pred_high[0][1][TX_32X8] = eb_aom_highbd_dc_top_predictor_32x8;
2990 3 : dc_pred_high[0][1][TX_32X16] = eb_aom_highbd_dc_top_predictor_32x16;
2991 3 : dc_pred_high[0][1][TX_32X64] = eb_aom_highbd_dc_top_predictor_32x64;
2992 :
2993 3 : dc_pred_high[0][1][TX_64X16] = eb_aom_highbd_dc_top_predictor_64x16;
2994 3 : dc_pred_high[0][1][TX_64X32] = eb_aom_highbd_dc_top_predictor_64x32;
2995 :
2996 3 : dc_pred_high[1][0][TX_4X4] = eb_aom_highbd_dc_left_predictor_4x4;
2997 3 : dc_pred_high[1][0][TX_8X8] = eb_aom_highbd_dc_left_predictor_8x8;
2998 3 : dc_pred_high[1][0][TX_16X16] = eb_aom_highbd_dc_left_predictor_16x16;
2999 3 : dc_pred_high[1][0][TX_32X32] = eb_aom_highbd_dc_left_predictor_32x32;
3000 3 : dc_pred_high[1][0][TX_64X64] = eb_aom_highbd_dc_left_predictor_64x64;
3001 :
3002 3 : dc_pred_high[1][0][TX_4X8] = eb_aom_highbd_dc_left_predictor_4x8;
3003 3 : dc_pred_high[1][0][TX_4X16] = eb_aom_highbd_dc_left_predictor_4x16;
3004 :
3005 3 : dc_pred_high[1][0][TX_8X4] = eb_aom_highbd_dc_left_predictor_8x4;
3006 3 : dc_pred_high[1][0][TX_8X16] = eb_aom_highbd_dc_left_predictor_8x16;
3007 3 : dc_pred_high[1][0][TX_8X32] = eb_aom_highbd_dc_left_predictor_8x32;
3008 :
3009 3 : dc_pred_high[1][0][TX_16X4] = eb_aom_highbd_dc_left_predictor_16x4;
3010 3 : dc_pred_high[1][0][TX_16X8] = eb_aom_highbd_dc_left_predictor_16x8;
3011 3 : dc_pred_high[1][0][TX_16X32] = eb_aom_highbd_dc_left_predictor_16x32;
3012 3 : dc_pred_high[1][0][TX_16X64] = eb_aom_highbd_dc_left_predictor_16x64;
3013 :
3014 3 : dc_pred_high[1][0][TX_32X8] = eb_aom_highbd_dc_left_predictor_32x8;
3015 3 : dc_pred_high[1][0][TX_32X16] = eb_aom_highbd_dc_left_predictor_32x16;
3016 3 : dc_pred_high[1][0][TX_32X64] = eb_aom_highbd_dc_left_predictor_32x64;
3017 :
3018 3 : dc_pred_high[1][0][TX_64X16] = eb_aom_highbd_dc_left_predictor_64x16;
3019 3 : dc_pred_high[1][0][TX_64X32] = eb_aom_highbd_dc_left_predictor_64x32;
3020 :
3021 3 : dc_pred_high[1][1][TX_4X4] = eb_aom_highbd_dc_predictor_4x4;
3022 3 : dc_pred_high[1][1][TX_8X8] = eb_aom_highbd_dc_predictor_8x8;
3023 3 : dc_pred_high[1][1][TX_16X16] = eb_aom_highbd_dc_predictor_16x16;
3024 3 : dc_pred_high[1][1][TX_32X32] = eb_aom_highbd_dc_predictor_32x32;
3025 3 : dc_pred_high[1][1][TX_64X64] = eb_aom_highbd_dc_predictor_64x64;
3026 :
3027 3 : dc_pred_high[1][1][TX_4X8] = eb_aom_highbd_dc_predictor_4x8;
3028 3 : dc_pred_high[1][1][TX_4X16] = eb_aom_highbd_dc_predictor_4x16;
3029 :
3030 3 : dc_pred_high[1][1][TX_8X4] = eb_aom_highbd_dc_predictor_8x4;
3031 3 : dc_pred_high[1][1][TX_8X16] = eb_aom_highbd_dc_predictor_8x16;
3032 3 : dc_pred_high[1][1][TX_8X32] = eb_aom_highbd_dc_predictor_8x32;
3033 :
3034 3 : dc_pred_high[1][1][TX_16X4] = eb_aom_highbd_dc_predictor_16x4;
3035 3 : dc_pred_high[1][1][TX_16X8] = eb_aom_highbd_dc_predictor_16x8;
3036 3 : dc_pred_high[1][1][TX_16X32] = eb_aom_highbd_dc_predictor_16x32;
3037 3 : dc_pred_high[1][1][TX_16X64] = eb_aom_highbd_dc_predictor_16x64;
3038 :
3039 3 : dc_pred_high[1][1][TX_32X8] = eb_aom_highbd_dc_predictor_32x8;
3040 3 : dc_pred_high[1][1][TX_32X16] = eb_aom_highbd_dc_predictor_32x16;
3041 3 : dc_pred_high[1][1][TX_32X64] = eb_aom_highbd_dc_predictor_32x64;
3042 :
3043 3 : dc_pred_high[1][1][TX_64X16] = eb_aom_highbd_dc_predictor_64x16;
3044 3 : dc_pred_high[1][1][TX_64X32] = eb_aom_highbd_dc_predictor_64x32;
3045 3 : }
3046 25559400 : void dr_predictor(uint8_t *dst, ptrdiff_t stride, TxSize tx_size,
3047 : const uint8_t *above, const uint8_t *left,
3048 : int32_t upsample_above, int32_t upsample_left, int32_t angle) {
3049 25559400 : const int32_t dx = get_dx(angle);
3050 25559600 : const int32_t dy = get_dy(angle);
3051 25559700 : const int32_t bw = tx_size_wide[tx_size];
3052 25559700 : const int32_t bh = tx_size_high[tx_size];
3053 25559700 : assert(angle > 0 && angle < 270);
3054 :
3055 25559700 : if (angle > 0 && angle < 90) {
3056 4343390 : eb_av1_dr_prediction_z1(dst, stride, bw, bh, above, left, upsample_above, dx,
3057 : dy);
3058 : }
3059 21216300 : else if (angle > 90 && angle < 180) {
3060 7384680 : eb_av1_dr_prediction_z2(dst, stride, bw, bh, above, left, upsample_above,
3061 : upsample_left, dx, dy);
3062 : }
3063 13831600 : else if (angle > 180 && angle < 270) {
3064 2964180 : eb_av1_dr_prediction_z3(dst, stride, bw, bh, above, left, upsample_left, dx,
3065 : dy);
3066 : }
3067 10867500 : else if (angle == 90)
3068 3880130 : pred[V_PRED][tx_size](dst, stride, above, left);
3069 6987340 : else if (angle == 180)
3070 6999720 : pred[H_PRED][tx_size](dst, stride, above, left);
3071 25560200 : }
3072 :
3073 2524250 : void filter_intra_edge_corner(uint8_t *p_above, uint8_t *p_left) {
3074 : const int32_t kernel[3] = { 5, 6, 5 };
3075 :
3076 2524250 : int32_t s = (p_left[0] * kernel[0]) + (p_above[-1] * kernel[1]) +
3077 2524250 : (p_above[0] * kernel[2]);
3078 2524250 : s = (s + 8) >> 4;
3079 2524250 : p_above[-1] = (uint8_t)s;
3080 2524250 : p_left[-1] = (uint8_t)s;
3081 2524250 : }
3082 :
3083 : // Directional prediction, zone 1: 0 < angle < 90
3084 0 : void eb_av1_highbd_dr_prediction_z1_c(uint16_t *dst, ptrdiff_t stride, int32_t bw,
3085 : int32_t bh, const uint16_t *above,
3086 : const uint16_t *left, int32_t upsample_above,
3087 : int32_t dx, int32_t dy, int32_t bd) {
3088 : int32_t r, c, x, base, shift, val;
3089 :
3090 : (void)left;
3091 : (void)dy;
3092 : (void)bd;
3093 0 : assert(dy == 1);
3094 0 : assert(dx > 0);
3095 :
3096 0 : const int32_t max_base_x = ((bw + bh) - 1) << upsample_above;
3097 0 : const int32_t frac_bits = 6 - upsample_above;
3098 0 : const int32_t base_inc = 1 << upsample_above;
3099 0 : x = dx;
3100 0 : for (r = 0; r < bh; ++r, dst += stride, x += dx) {
3101 0 : base = x >> frac_bits;
3102 0 : shift = ((x << upsample_above) & 0x3F) >> 1;
3103 :
3104 0 : if (base >= max_base_x) {
3105 0 : for (int32_t i = r; i < bh; ++i) {
3106 0 : eb_aom_memset16(dst, above[max_base_x], bw);
3107 0 : dst += stride;
3108 : }
3109 0 : return;
3110 : }
3111 :
3112 0 : for (c = 0; c < bw; ++c, base += base_inc) {
3113 0 : if (base < max_base_x) {
3114 0 : val = above[base] * (32 - shift) + above[base + 1] * shift;
3115 0 : val = ROUND_POWER_OF_TWO(val, 5);
3116 0 : dst[c] = (uint16_t)clip_pixel_highbd(val, bd);
3117 : }
3118 : else
3119 0 : dst[c] = above[max_base_x];
3120 : }
3121 : }
3122 : }
3123 :
3124 : // Directional prediction, zone 2: 90 < angle < 180
3125 0 : void eb_av1_highbd_dr_prediction_z2_c(uint16_t *dst, ptrdiff_t stride, int32_t bw,
3126 : int32_t bh, const uint16_t *above,
3127 : const uint16_t *left, int32_t upsample_above,
3128 : int32_t upsample_left, int32_t dx, int32_t dy, int32_t bd) {
3129 : int32_t r, c, x, y, shift, val, base;
3130 :
3131 : (void)bd;
3132 0 : assert(dx > 0);
3133 0 : assert(dy > 0);
3134 :
3135 0 : const int32_t min_base_x = -(1 << upsample_above);
3136 0 : const int32_t frac_bits_x = 6 - upsample_above;
3137 0 : const int32_t frac_bits_y = 6 - upsample_left;
3138 0 : for (r = 0; r < bh; ++r) {
3139 0 : for (c = 0; c < bw; ++c) {
3140 0 : y = r + 1;
3141 0 : x = (c << 6) - y * dx;
3142 0 : base = x >> frac_bits_x;
3143 0 : if (base >= min_base_x) {
3144 0 : shift = ((x * (1 << upsample_above)) & 0x3F) >> 1;
3145 0 : val = above[base] * (32 - shift) + above[base + 1] * shift;
3146 0 : val = ROUND_POWER_OF_TWO(val, 5);
3147 : }
3148 : else {
3149 0 : x = c + 1;
3150 0 : y = (r << 6) - x * dy;
3151 0 : base = y >> frac_bits_y;
3152 0 : shift = ((y * (1 << upsample_left)) & 0x3F) >> 1;
3153 0 : val = left[base] * (32 - shift) + left[base + 1] * shift;
3154 0 : val = ROUND_POWER_OF_TWO(val, 5);
3155 : }
3156 0 : dst[c] = (uint16_t)clip_pixel_highbd(val, bd);
3157 : }
3158 0 : dst += stride;
3159 : }
3160 0 : }
3161 :
3162 : // Directional prediction, zone 3: 180 < angle < 270
3163 0 : void eb_av1_highbd_dr_prediction_z3_c(uint16_t *dst, ptrdiff_t stride, int32_t bw,
3164 : int32_t bh, const uint16_t *above,
3165 : const uint16_t *left, int32_t upsample_left,
3166 : int32_t dx, int32_t dy, int32_t bd) {
3167 : int32_t r, c, y, base, shift, val;
3168 :
3169 : (void)above;
3170 : (void)dx;
3171 : (void)bd;
3172 0 : assert(dx == 1);
3173 0 : assert(dy > 0);
3174 :
3175 0 : const int32_t max_base_y = (bw + bh - 1) << upsample_left;
3176 0 : const int32_t frac_bits = 6 - upsample_left;
3177 0 : const int32_t base_inc = 1 << upsample_left;
3178 0 : y = dy;
3179 0 : for (c = 0; c < bw; ++c, y += dy) {
3180 0 : base = y >> frac_bits;
3181 0 : shift = ((y << upsample_left) & 0x3F) >> 1;
3182 :
3183 0 : for (r = 0; r < bh; ++r, base += base_inc) {
3184 0 : if (base < max_base_y) {
3185 0 : val = left[base] * (32 - shift) + left[base + 1] * shift;
3186 0 : val = ROUND_POWER_OF_TWO(val, 5);
3187 0 : dst[r * stride + c] = (uint16_t)clip_pixel_highbd(val, bd);
3188 : }
3189 : else {
3190 0 : for (; r < bh; ++r) dst[r * stride + c] = left[max_base_y];
3191 0 : break;
3192 : }
3193 : }
3194 : }
3195 0 : }
3196 :
3197 0 : void highbd_dr_predictor(uint16_t *dst, ptrdiff_t stride,
3198 : TxSize tx_size, const uint16_t *above,
3199 : const uint16_t *left, int32_t upsample_above,
3200 : int32_t upsample_left, int32_t angle, int32_t bd) {
3201 0 : const int32_t dx = get_dx(angle);
3202 0 : const int32_t dy = get_dy(angle);
3203 0 : const int32_t bw = tx_size_wide[tx_size];
3204 0 : const int32_t bh = tx_size_high[tx_size];
3205 0 : assert(angle > 0 && angle < 270);
3206 :
3207 0 : if (angle > 0 && angle < 90) {
3208 0 : eb_av1_highbd_dr_prediction_z1(dst, stride, bw, bh, above, left,
3209 : upsample_above, dx, dy, bd);
3210 : }
3211 0 : else if (angle > 90 && angle < 180) {
3212 0 : eb_av1_highbd_dr_prediction_z2(dst, stride, bw, bh, above, left,
3213 : upsample_above, upsample_left, dx, dy, bd);
3214 : }
3215 0 : else if (angle > 180 && angle < 270) {
3216 0 : eb_av1_highbd_dr_prediction_z3(dst, stride, bw, bh, above, left, upsample_left,
3217 : dx, dy, bd);
3218 : }
3219 0 : else if (angle == 90)
3220 0 : pred_high[V_PRED][tx_size](dst, stride, above, left, bd);
3221 0 : else if (angle == 180)
3222 0 : pred_high[H_PRED][tx_size](dst, stride, above, left, bd);
3223 0 : }
3224 :
3225 0 : void eb_av1_filter_intra_edge_high_c(uint16_t *p, int32_t sz, int32_t strength) {
3226 0 : if (!strength) return;
3227 :
3228 0 : const int32_t kernel[INTRA_EDGE_FILT][INTRA_EDGE_TAPS] = {
3229 : { 0, 4, 8, 4, 0 }, { 0, 5, 6, 5, 0 }, { 2, 4, 4, 4, 2 }
3230 : };
3231 0 : const int32_t filt = strength - 1;
3232 : uint16_t edge[129];
3233 :
3234 0 : memcpy(edge, p, sz * sizeof(*p));
3235 0 : for (int32_t i = 1; i < sz; i++) {
3236 0 : int32_t s = 0;
3237 0 : for (int32_t j = 0; j < INTRA_EDGE_TAPS; j++) {
3238 0 : int32_t k = i - 2 + j;
3239 0 : k = (k < 0) ? 0 : k;
3240 0 : k = (k > sz - 1) ? sz - 1 : k;
3241 0 : s += edge[k] * kernel[filt][j];
3242 : }
3243 0 : s = (s + 8) >> 4;
3244 0 : p[i] = (uint16_t)s;
3245 : }
3246 : }
3247 :
3248 0 : void filter_intra_edge_corner_high(uint16_t *p_above, uint16_t *p_left) {
3249 : const int32_t kernel[3] = { 5, 6, 5 };
3250 :
3251 0 : int32_t s = (p_left[0] * kernel[0]) + (p_above[-1] * kernel[1]) +
3252 0 : (p_above[0] * kernel[2]);
3253 0 : s = (s + 8) >> 4;
3254 0 : p_above[-1] = (uint16_t)s;
3255 0 : p_left[-1] = (uint16_t)s;
3256 0 : }
3257 :
3258 0 : void eb_av1_upsample_intra_edge_high_c(uint16_t *p, int32_t sz, int32_t bd) {
3259 : // interpolate half-sample positions
3260 0 : assert(sz <= MAX_UPSAMPLE_SZ);
3261 :
3262 : uint16_t in[MAX_UPSAMPLE_SZ + 3];
3263 : // copy p[-1..(sz-1)] and extend first and last samples
3264 0 : in[0] = p[-1];
3265 0 : in[1] = p[-1];
3266 0 : for (int32_t i = 0; i < sz; i++)
3267 0 : in[i + 2] = p[i];
3268 0 : in[sz + 2] = p[sz - 1];
3269 :
3270 : // interpolate half-sample edge positions
3271 0 : p[-2] = in[0];
3272 0 : for (int32_t i = 0; i < sz; i++) {
3273 0 : int32_t s = -in[i] + (9 * in[i + 1]) + (9 * in[i + 2]) - in[i + 3];
3274 0 : s = (s + 8) >> 4;
3275 0 : s = clip_pixel_highbd(s, bd);
3276 0 : p[2 * i - 1] = (uint16_t)s;
3277 0 : p[2 * i] = in[i + 2];
3278 : }
3279 0 : }
3280 :
3281 0 : void eb_av1_upsample_intra_edge_c(uint8_t *p, int32_t sz) {
3282 : // interpolate half-sample positions
3283 0 : assert(sz <= MAX_UPSAMPLE_SZ);
3284 :
3285 : uint8_t in[MAX_UPSAMPLE_SZ + 3];
3286 : // copy p[-1..(sz-1)] and extend first and last samples
3287 0 : in[0] = p[-1];
3288 0 : in[1] = p[-1];
3289 0 : for (int32_t i = 0; i < sz; i++)
3290 0 : in[i + 2] = p[i];
3291 0 : in[sz + 2] = p[sz - 1];
3292 :
3293 : // interpolate half-sample edge positions
3294 0 : p[-2] = in[0];
3295 0 : for (int32_t i = 0; i < sz; i++) {
3296 0 : int32_t s = -in[i] + (9 * in[i + 1]) + (9 * in[i + 2]) - in[i + 3];
3297 0 : s = clip_pixel((s + 8) >> 4);
3298 0 : p[2 * i - 1] = (uint8_t)s;
3299 0 : p[2 * i] = in[i + 2];
3300 : }
3301 0 : }
3302 46204000 : /*static INLINE*/ BlockSize scale_chroma_bsize(BlockSize bsize, int32_t subsampling_x,
3303 : int32_t subsampling_y) {
3304 46204000 : BlockSize bs = bsize;
3305 46204000 : switch (bsize) {
3306 798371 : case BLOCK_4X4:
3307 798371 : if (subsampling_x == 1 && subsampling_y == 1)
3308 268711 : bs = BLOCK_8X8;
3309 529660 : else if (subsampling_x == 1)
3310 0 : bs = BLOCK_8X4;
3311 529660 : else if (subsampling_y == 1)
3312 0 : bs = BLOCK_4X8;
3313 798371 : break;
3314 876898 : case BLOCK_4X8:
3315 876898 : if (subsampling_x == 1 && subsampling_y == 1)
3316 585442 : bs = BLOCK_8X8;
3317 291456 : else if (subsampling_x == 1)
3318 0 : bs = BLOCK_8X8;
3319 291456 : else if (subsampling_y == 1)
3320 0 : bs = BLOCK_4X8;
3321 876898 : break;
3322 880203 : case BLOCK_8X4:
3323 880203 : if (subsampling_x == 1 && subsampling_y == 1)
3324 587796 : bs = BLOCK_8X8;
3325 292407 : else if (subsampling_x == 1)
3326 0 : bs = BLOCK_8X4;
3327 292407 : else if (subsampling_y == 1)
3328 0 : bs = BLOCK_8X8;
3329 880203 : break;
3330 2310150 : case BLOCK_4X16:
3331 2310150 : if (subsampling_x == 1 && subsampling_y == 1)
3332 1308030 : bs = BLOCK_8X16;
3333 1002120 : else if (subsampling_x == 1)
3334 0 : bs = BLOCK_8X16;
3335 1002120 : else if (subsampling_y == 1)
3336 0 : bs = BLOCK_4X16;
3337 2310150 : break;
3338 2388090 : case BLOCK_16X4:
3339 2388090 : if (subsampling_x == 1 && subsampling_y == 1)
3340 1296310 : bs = BLOCK_16X8;
3341 1091780 : else if (subsampling_x == 1)
3342 0 : bs = BLOCK_16X4;
3343 1091780 : else if (subsampling_y == 1)
3344 0 : bs = BLOCK_16X8;
3345 2388090 : break;
3346 38950300 : default: break;
3347 : }
3348 46204000 : return bs;
3349 : }
3350 :
3351 : ////////////########...........Recurssive intra prediction starting...........#########
3352 :
3353 : DECLARE_ALIGNED(16, const int8_t,
3354 : eb_av1_filter_intra_taps[FILTER_INTRA_MODES][8][8]) = {
3355 : {
3356 : { -6, 10, 0, 0, 0, 12, 0, 0 },
3357 : { -5, 2, 10, 0, 0, 9, 0, 0 },
3358 : { -3, 1, 1, 10, 0, 7, 0, 0 },
3359 : { -3, 1, 1, 2, 10, 5, 0, 0 },
3360 : { -4, 6, 0, 0, 0, 2, 12, 0 },
3361 : { -3, 2, 6, 0, 0, 2, 9, 0 },
3362 : { -3, 2, 2, 6, 0, 2, 7, 0 },
3363 : { -3, 1, 2, 2, 6, 3, 5, 0 },
3364 : },
3365 : {
3366 : { -10, 16, 0, 0, 0, 10, 0, 0 },
3367 : { -6, 0, 16, 0, 0, 6, 0, 0 },
3368 : { -4, 0, 0, 16, 0, 4, 0, 0 },
3369 : { -2, 0, 0, 0, 16, 2, 0, 0 },
3370 : { -10, 16, 0, 0, 0, 0, 10, 0 },
3371 : { -6, 0, 16, 0, 0, 0, 6, 0 },
3372 : { -4, 0, 0, 16, 0, 0, 4, 0 },
3373 : { -2, 0, 0, 0, 16, 0, 2, 0 },
3374 : },
3375 : {
3376 : { -8, 8, 0, 0, 0, 16, 0, 0 },
3377 : { -8, 0, 8, 0, 0, 16, 0, 0 },
3378 : { -8, 0, 0, 8, 0, 16, 0, 0 },
3379 : { -8, 0, 0, 0, 8, 16, 0, 0 },
3380 : { -4, 4, 0, 0, 0, 0, 16, 0 },
3381 : { -4, 0, 4, 0, 0, 0, 16, 0 },
3382 : { -4, 0, 0, 4, 0, 0, 16, 0 },
3383 : { -4, 0, 0, 0, 4, 0, 16, 0 },
3384 : },
3385 : {
3386 : { -2, 8, 0, 0, 0, 10, 0, 0 },
3387 : { -1, 3, 8, 0, 0, 6, 0, 0 },
3388 : { -1, 2, 3, 8, 0, 4, 0, 0 },
3389 : { 0, 1, 2, 3, 8, 2, 0, 0 },
3390 : { -1, 4, 0, 0, 0, 3, 10, 0 },
3391 : { -1, 3, 4, 0, 0, 4, 6, 0 },
3392 : { -1, 2, 3, 4, 0, 4, 4, 0 },
3393 : { -1, 2, 2, 3, 4, 3, 3, 0 },
3394 : },
3395 : {
3396 : { -12, 14, 0, 0, 0, 14, 0, 0 },
3397 : { -10, 0, 14, 0, 0, 12, 0, 0 },
3398 : { -9, 0, 0, 14, 0, 11, 0, 0 },
3399 : { -8, 0, 0, 0, 14, 10, 0, 0 },
3400 : { -10, 12, 0, 0, 0, 0, 14, 0 },
3401 : { -9, 1, 12, 0, 0, 0, 12, 0 },
3402 : { -8, 0, 0, 12, 0, 1, 11, 0 },
3403 : { -7, 0, 0, 1, 12, 1, 9, 0 },
3404 : },
3405 : };
3406 :
3407 0 : void eb_av1_filter_intra_predictor_c(uint8_t *dst, ptrdiff_t stride,
3408 : TxSize tx_size,
3409 : const uint8_t *above,
3410 : const uint8_t *left, int32_t mode) {
3411 : int r, c;
3412 : uint8_t buffer[33][33];
3413 0 : const int bw = tx_size_wide[tx_size];
3414 0 : const int bh = tx_size_high[tx_size];
3415 :
3416 0 : assert(bw <= 32 && bh <= 32);
3417 :
3418 : // The initialization is just for silencing Jenkins static analysis warnings
3419 0 : for (r = 0; r < bh + 1; ++r)
3420 0 : memset(buffer[r], 0, (bw + 1) * sizeof(buffer[0][0]));
3421 :
3422 0 : for (r = 0; r < bh; ++r) buffer[r + 1][0] = left[r];
3423 0 : memcpy(buffer[0], &above[-1], (bw + 1) * sizeof(uint8_t));
3424 :
3425 0 : for (r = 1; r < bh + 1; r += 2)
3426 0 : for (c = 1; c < bw + 1; c += 4) {
3427 0 : const uint8_t p0 = buffer[r - 1][c - 1];
3428 0 : const uint8_t p1 = buffer[r - 1][c];
3429 0 : const uint8_t p2 = buffer[r - 1][c + 1];
3430 0 : const uint8_t p3 = buffer[r - 1][c + 2];
3431 0 : const uint8_t p4 = buffer[r - 1][c + 3];
3432 0 : const uint8_t p5 = buffer[r][c - 1];
3433 0 : const uint8_t p6 = buffer[r + 1][c - 1];
3434 0 : for (int k = 0; k < 8; ++k) {
3435 0 : int r_offset = k >> 2;
3436 0 : int c_offset = k & 0x03;
3437 0 : buffer[r + r_offset][c + c_offset] =
3438 0 : clip_pixel(ROUND_POWER_OF_TWO_SIGNED(
3439 : eb_av1_filter_intra_taps[mode][k][0] * p0 +
3440 : eb_av1_filter_intra_taps[mode][k][1] * p1 +
3441 : eb_av1_filter_intra_taps[mode][k][2] * p2 +
3442 : eb_av1_filter_intra_taps[mode][k][3] * p3 +
3443 : eb_av1_filter_intra_taps[mode][k][4] * p4 +
3444 : eb_av1_filter_intra_taps[mode][k][5] * p5 +
3445 : eb_av1_filter_intra_taps[mode][k][6] * p6,
3446 : FILTER_INTRA_SCALE_BITS));
3447 : }
3448 : }
3449 :
3450 0 : for (r = 0; r < bh; ++r) {
3451 0 : memcpy(dst, &buffer[r + 1][1], bw * sizeof(uint8_t));
3452 0 : dst += stride;
3453 : }
3454 0 : }
3455 :
3456 0 : void highbd_filter_intra_predictor(uint16_t *dst, ptrdiff_t stride,
3457 : TxSize tx_size,
3458 : const uint16_t *above,
3459 : const uint16_t *left, int mode,
3460 : int bd) {
3461 : int r, c;
3462 : uint16_t buffer[33][33];
3463 0 : const int bw = tx_size_wide[tx_size];
3464 0 : const int bh = tx_size_high[tx_size];
3465 :
3466 0 : assert(bw <= 32 && bh <= 32);
3467 :
3468 : // The initialization is just for silencing Jenkins static analysis warnings
3469 0 : for (r = 0; r < bh + 1; ++r)
3470 0 : memset(buffer[r], 0, (bw + 1) * sizeof(buffer[0][0]));
3471 :
3472 0 : for (r = 0; r < bh; ++r) buffer[r + 1][0] = left[r];
3473 0 : memcpy(buffer[0], &above[-1], (bw + 1) * sizeof(buffer[0][0]));
3474 :
3475 0 : for (r = 1; r < bh + 1; r += 2)
3476 0 : for (c = 1; c < bw + 1; c += 4) {
3477 0 : const uint16_t p0 = buffer[r - 1][c - 1];
3478 0 : const uint16_t p1 = buffer[r - 1][c];
3479 0 : const uint16_t p2 = buffer[r - 1][c + 1];
3480 0 : const uint16_t p3 = buffer[r - 1][c + 2];
3481 0 : const uint16_t p4 = buffer[r - 1][c + 3];
3482 0 : const uint16_t p5 = buffer[r][c - 1];
3483 0 : const uint16_t p6 = buffer[r + 1][c - 1];
3484 0 : for (int k = 0; k < 8; ++k) {
3485 0 : int r_offset = k >> 2;
3486 0 : int c_offset = k & 0x03;
3487 0 : buffer[r + r_offset][c + c_offset] =
3488 0 : clip_pixel_highbd(ROUND_POWER_OF_TWO_SIGNED(
3489 : eb_av1_filter_intra_taps[mode][k][0] * p0 +
3490 : eb_av1_filter_intra_taps[mode][k][1] * p1 +
3491 : eb_av1_filter_intra_taps[mode][k][2] * p2 +
3492 : eb_av1_filter_intra_taps[mode][k][3] * p3 +
3493 : eb_av1_filter_intra_taps[mode][k][4] * p4 +
3494 : eb_av1_filter_intra_taps[mode][k][5] * p5 +
3495 : eb_av1_filter_intra_taps[mode][k][6] * p6,
3496 : FILTER_INTRA_SCALE_BITS),
3497 : bd);
3498 : }
3499 : }
3500 :
3501 0 : for (r = 0; r < bh; ++r) {
3502 0 : memcpy(dst, &buffer[r + 1][1], bw * sizeof(dst[0]));
3503 0 : dst += stride;
3504 : }
3505 0 : }
3506 :
3507 : ////////////#####################...........Recurssive intra prediction ending...........#####################////////////
3508 :
3509 45958500 : static void build_intra_predictors(
3510 : const MacroBlockD *xd,
3511 : uint8_t* topNeighArray,
3512 : uint8_t* leftNeighArray,
3513 : // const uint8_t *ref, int32_t ref_stride,
3514 : uint8_t *dst, int32_t dst_stride,
3515 : PredictionMode mode, int32_t angle_delta,
3516 : FilterIntraMode filter_intra_mode,
3517 : TxSize tx_size, int32_t disable_edge_filter,
3518 : int32_t n_top_px, int32_t n_topright_px,
3519 : int32_t n_left_px, int32_t n_bottomleft_px,
3520 : int32_t plane)
3521 : {
3522 : (void)xd;
3523 : int32_t i;
3524 :
3525 45958500 : int32_t ref_stride = 1;
3526 45958500 : const uint8_t *above_ref = topNeighArray;//CHKN ref - ref_stride;
3527 45958500 : const uint8_t *left_ref = leftNeighArray;//CHKN ref - 1;
3528 : DECLARE_ALIGNED(32, uint8_t, left_data[MAX_TX_SIZE * 2 + 48]);
3529 : DECLARE_ALIGNED(32, uint8_t, above_data[MAX_TX_SIZE * 2 + 48]);
3530 45958500 : uint8_t *const above_row = above_data + 32;
3531 45958500 : uint8_t *const left_col = left_data + 32;
3532 :
3533 45958500 : const int32_t txwpx = tx_size_wide[tx_size];
3534 45958500 : const int32_t txhpx = tx_size_high[tx_size];
3535 45958500 : int32_t need_left = extend_modes[mode] & NEED_LEFT;
3536 45958500 : int32_t need_above = extend_modes[mode] & NEED_ABOVE;
3537 45958500 : int32_t need_above_left = extend_modes[mode] & NEED_ABOVELEFT;
3538 45958500 : int32_t p_angle = 0;
3539 45958500 : const int32_t is_dr_mode = av1_is_directional_mode(mode);
3540 45956000 : const int32_t use_filter_intra = filter_intra_mode != FILTER_INTRA_MODES;
3541 :
3542 45956000 : if (is_dr_mode) {
3543 26467200 : p_angle = mode_to_angle_map[mode] + angle_delta * ANGLE_STEP;
3544 26467200 : if (p_angle <= 90)
3545 8682830 : need_above = 1, need_left = 0, need_above_left = 1;
3546 17784400 : else if (p_angle < 180)
3547 7383400 : need_above = 1, need_left = 1, need_above_left = 1;
3548 : else
3549 10401000 : need_above = 0, need_left = 1, need_above_left = 1;
3550 : }
3551 45956000 : if (use_filter_intra) need_left = need_above = need_above_left = 1;
3552 :
3553 45956000 : assert(n_top_px >= 0);
3554 45956000 : assert(n_topright_px >= 0);
3555 45956000 : assert(n_left_px >= 0);
3556 45956000 : assert(n_bottomleft_px >= 0);
3557 :
3558 45956000 : if ((!need_above && n_left_px == 0) || (!need_left && n_top_px == 0)) {
3559 : int32_t val;
3560 901932 : if (need_left)
3561 441394 : val = (n_top_px > 0) ? above_ref[0] : 129;
3562 : else
3563 460538 : val = (n_left_px > 0) ? left_ref[0] : 127;
3564 16481900 : for (i = 0; i < txhpx; ++i) {
3565 15580000 : memset(dst, val, txwpx);
3566 15580000 : dst += dst_stride;
3567 : }
3568 27653200 : return;
3569 : }
3570 :
3571 : // NEED_LEFT
3572 45054100 : if (need_left) {
3573 36845800 : int32_t need_bottom = !!(extend_modes[mode] & NEED_BOTTOMLEFT);
3574 36845800 : if (use_filter_intra) need_bottom = 0;
3575 36845800 : if (is_dr_mode) need_bottom = p_angle > 180;
3576 36845800 : const int32_t num_left_pixels_needed = txhpx + (need_bottom ? txwpx : 0);
3577 36845800 : i = 0;
3578 36845800 : if (n_left_px > 0) {
3579 402773000 : for (; i < n_left_px; i++) left_col[i] = left_ref[i * ref_stride];
3580 35154800 : if (need_bottom && n_bottomleft_px > 0) {
3581 1006570 : assert(i == txhpx);
3582 8774790 : for (; i < txhpx + n_bottomleft_px; i++)
3583 7768220 : left_col[i] = left_ref[i * ref_stride];
3584 : }
3585 35154800 : if (i < num_left_pixels_needed)
3586 2678050 : memset(&left_col[i], left_col[i - 1], num_left_pixels_needed - i);
3587 : }
3588 : else {
3589 1691050 : if (n_top_px > 0)
3590 1624780 : memset(left_col, above_ref[0], num_left_pixels_needed);
3591 : else
3592 66274 : memset(left_col, 129, num_left_pixels_needed);
3593 : }
3594 : }
3595 :
3596 : // NEED_ABOVE
3597 45054100 : if (need_above) {
3598 35097200 : int32_t need_right = !!(extend_modes[mode] & NEED_ABOVERIGHT);
3599 35097200 : if (use_filter_intra) need_right = 0;
3600 35097200 : if (is_dr_mode) need_right = p_angle < 90;
3601 35097200 : const int32_t num_top_pixels_needed = txwpx + (need_right ? txhpx : 0);
3602 35097200 : if (n_top_px > 0) {
3603 33786300 : memcpy(above_row, above_ref, n_top_px);
3604 33786300 : i = n_top_px;
3605 33786300 : if (need_right && n_topright_px > 0) {
3606 2604160 : assert(n_top_px == txwpx);
3607 2604160 : memcpy(above_row + txwpx, above_ref + txwpx, n_topright_px);
3608 2604160 : i += n_topright_px;
3609 : }
3610 33786300 : if (i < num_top_pixels_needed)
3611 2752070 : memset(&above_row[i], above_row[i - 1], num_top_pixels_needed - i);
3612 : }
3613 : else {
3614 1310900 : if (n_left_px > 0)
3615 1249860 : memset(above_row, left_ref[0], num_top_pixels_needed);
3616 : else
3617 61042 : memset(above_row, 127, num_top_pixels_needed);
3618 : }
3619 : }
3620 :
3621 45054100 : if (need_above_left) {
3622 27211200 : if (n_top_px > 0 && n_left_px > 0)
3623 25501900 : above_row[-1] = above_ref[-1];
3624 1709320 : else if (n_top_px > 0)
3625 830947 : above_row[-1] = above_ref[0];
3626 878377 : else if (n_left_px > 0)
3627 856968 : above_row[-1] = left_ref[0];
3628 : else
3629 21409 : above_row[-1] = 128;
3630 27211200 : left_col[-1] = above_row[-1];
3631 : }
3632 : #if FILTER_INTRA_FLAG
3633 45054100 : if (use_filter_intra) {
3634 1192440 : eb_av1_filter_intra_predictor(dst, dst_stride, tx_size, above_row, left_col,
3635 : filter_intra_mode);
3636 1192470 : return;
3637 : }
3638 : #else
3639 : // if (use_filter_intra) {
3640 : //// eb_av1_filter_intra_predictor(dst, dst_stride, tx_size, above_row, left_col,
3641 : ////CHKN filter_intra_mode);
3642 : // return;
3643 : // }
3644 : #endif
3645 43861600 : if (is_dr_mode) {
3646 25557600 : int32_t upsample_above = 0;
3647 25557600 : int32_t upsample_left = 0;
3648 25557600 : if (!disable_edge_filter) {
3649 25557300 : const int32_t need_right = p_angle < 90;
3650 25557300 : const int32_t need_bottom = p_angle > 180;
3651 25557300 : const int32_t filt_type = get_filt_type(xd, plane);
3652 :
3653 25552400 : if (p_angle != 90 && p_angle != 180) {
3654 14681100 : const int32_t ab_le = need_above_left ? 1 : 0;
3655 14681100 : if (need_above && need_left && (txwpx + txhpx >= 24))
3656 2524050 : filter_intra_edge_corner(above_row, left_col);
3657 14681100 : if (need_above && n_top_px > 0) {
3658 : const int32_t strength =
3659 11364700 : intra_edge_filter_strength(txwpx, txhpx, p_angle - 90, filt_type);
3660 11364500 : const int32_t n_px = n_top_px + ab_le + (need_right ? txhpx : 0);
3661 11364500 : eb_av1_filter_intra_edge(above_row - ab_le, n_px, strength);
3662 : }
3663 14684800 : if (need_left && n_left_px > 0) {
3664 9907790 : const int32_t strength = intra_edge_filter_strength(
3665 : txhpx, txwpx, p_angle - 180, filt_type);
3666 9907360 : const int32_t n_px = n_left_px + ab_le + (need_bottom ? txwpx : 0);
3667 9907360 : eb_av1_filter_intra_edge(left_col - ab_le, n_px, strength);
3668 : }
3669 : }
3670 : upsample_above =
3671 25556500 : use_intra_edge_upsample(txwpx, txhpx, p_angle - 90, filt_type);
3672 25556800 : if (need_above && upsample_above) {
3673 2929280 : const int32_t n_px = txwpx + (need_right ? txhpx : 0);
3674 2929280 : eb_av1_upsample_intra_edge(above_row, n_px);
3675 : }
3676 : upsample_left =
3677 25557100 : use_intra_edge_upsample(txhpx, txwpx, p_angle - 180, filt_type);
3678 25555400 : if (need_left && upsample_left) {
3679 3018120 : const int32_t n_px = txhpx + (need_bottom ? txwpx : 0);
3680 3018120 : eb_av1_upsample_intra_edge(left_col, n_px);
3681 : }
3682 : }
3683 25556000 : dr_predictor(dst, dst_stride, tx_size, above_row, left_col, upsample_above,
3684 : upsample_left, p_angle);
3685 25558800 : return;
3686 : }
3687 :
3688 : // predict
3689 18304000 : if (mode == DC_PRED) {
3690 14909200 : dc_pred[n_left_px > 0][n_top_px > 0][tx_size](dst, dst_stride, above_row,
3691 : left_col);
3692 : }
3693 : else
3694 3394780 : pred[mode][tx_size](dst, dst_stride, above_row, left_col);
3695 : }
3696 0 : static void build_intra_predictors_high(
3697 : const MacroBlockD *xd,
3698 : uint16_t* topNeighArray, // int8_t
3699 : uint16_t* leftNeighArray, // int8_t
3700 : //const uint8_t *ref8, int32_t ref_stride,
3701 : uint16_t *dst,//uint8_t *dst8
3702 : int32_t dst_stride, PredictionMode mode, int32_t angle_delta,
3703 : FilterIntraMode filter_intra_mode, TxSize tx_size,
3704 : int32_t disable_edge_filter, int32_t n_top_px, int32_t n_topright_px, int32_t n_left_px,
3705 : int32_t n_bottomleft_px, int32_t plane, int32_t bd) {
3706 : (void)xd;
3707 : int32_t i;
3708 : //uint16_t *dst = CONVERT_TO_SHORTPTR(dst8);
3709 : //uint16_t *ref = CONVERT_TO_SHORTPTR(ref8);
3710 :
3711 : DECLARE_ALIGNED(16, uint16_t, left_data[MAX_TX_SIZE * 2 + 32]);
3712 : DECLARE_ALIGNED(16, uint16_t, above_data[MAX_TX_SIZE * 2 + 32]);
3713 0 : uint16_t *const above_row = above_data + 16;
3714 0 : uint16_t *const left_col = left_data + 16;
3715 0 : const int32_t txwpx = tx_size_wide[tx_size];
3716 0 : const int32_t txhpx = tx_size_high[tx_size];
3717 0 : int32_t need_left = extend_modes[mode] & NEED_LEFT;
3718 0 : int32_t need_above = extend_modes[mode] & NEED_ABOVE;
3719 0 : int32_t need_above_left = extend_modes[mode] & NEED_ABOVELEFT;
3720 :
3721 0 : int32_t ref_stride = 1;
3722 0 : const uint16_t *above_ref = topNeighArray;
3723 0 : const uint16_t *left_ref = leftNeighArray;
3724 : //const uint16_t *above_ref = ref - ref_stride;
3725 : //const uint16_t *left_ref = ref - 1;
3726 0 : int32_t p_angle = 0;
3727 0 : const int32_t is_dr_mode = av1_is_directional_mode(mode);
3728 0 : const int32_t use_filter_intra = filter_intra_mode != FILTER_INTRA_MODES;
3729 0 : int32_t base = 128 << (bd - 8);
3730 :
3731 : // The default values if ref pixels are not available:
3732 : // base-1 base-1 base-1 .. base-1 base-1 base-1 base-1 base-1 base-1
3733 : // base+1 A B .. Y Z
3734 : // base+1 C D .. W X
3735 : // base+1 E F .. U V
3736 : // base+1 G H .. S T T T T T
3737 :
3738 0 : if (is_dr_mode) {
3739 0 : p_angle = mode_to_angle_map[mode] + angle_delta * ANGLE_STEP;
3740 0 : if (p_angle <= 90)
3741 0 : need_above = 1, need_left = 0, need_above_left = 1;
3742 0 : else if (p_angle < 180)
3743 0 : need_above = 1, need_left = 1, need_above_left = 1;
3744 : else
3745 0 : need_above = 0, need_left = 1, need_above_left = 1;
3746 : }
3747 0 : if (use_filter_intra) need_left = need_above = need_above_left = 1;
3748 :
3749 0 : assert(n_top_px >= 0);
3750 0 : assert(n_topright_px >= 0);
3751 0 : assert(n_left_px >= 0);
3752 0 : assert(n_bottomleft_px >= 0);
3753 :
3754 0 : if ((!need_above && n_left_px == 0) || (!need_left && n_top_px == 0)) {
3755 : int32_t val;
3756 0 : if (need_left)
3757 0 : val = (n_top_px > 0) ? above_ref[0] : base + 1;
3758 : else
3759 0 : val = (n_left_px > 0) ? left_ref[0] : base - 1;
3760 0 : for (i = 0; i < txhpx; ++i) {
3761 0 : eb_aom_memset16(dst, val, txwpx);
3762 0 : dst += dst_stride;
3763 : }
3764 0 : return;
3765 : }
3766 :
3767 : // NEED_LEFT
3768 0 : if (need_left) {
3769 0 : int32_t need_bottom = !!(extend_modes[mode] & NEED_BOTTOMLEFT);
3770 0 : if (use_filter_intra) need_bottom = 0;
3771 0 : if (is_dr_mode) need_bottom = p_angle > 180;
3772 0 : const int32_t num_left_pixels_needed = txhpx + (need_bottom ? txwpx : 0);
3773 0 : i = 0;
3774 0 : if (n_left_px > 0) {
3775 0 : for (; i < n_left_px; i++) left_col[i] = left_ref[i * ref_stride];
3776 0 : if (need_bottom && n_bottomleft_px > 0) {
3777 0 : assert(i == txhpx);
3778 0 : for (; i < txhpx + n_bottomleft_px; i++)
3779 0 : left_col[i] = left_ref[i * ref_stride];
3780 : }
3781 0 : if (i < num_left_pixels_needed)
3782 0 : eb_aom_memset16(&left_col[i], left_col[i - 1], num_left_pixels_needed - i);
3783 : }
3784 : else {
3785 0 : if (n_top_px > 0)
3786 0 : eb_aom_memset16(left_col, above_ref[0], num_left_pixels_needed);
3787 : else
3788 0 : eb_aom_memset16(left_col, base + 1, num_left_pixels_needed);
3789 : }
3790 : }
3791 :
3792 : // NEED_ABOVE
3793 0 : if (need_above) {
3794 0 : int32_t need_right = !!(extend_modes[mode] & NEED_ABOVERIGHT);
3795 0 : if (use_filter_intra) need_right = 0;
3796 0 : if (is_dr_mode) need_right = p_angle < 90;
3797 0 : const int32_t num_top_pixels_needed = txwpx + (need_right ? txhpx : 0);
3798 0 : if (n_top_px > 0) {
3799 0 : memcpy(above_row, above_ref, n_top_px * sizeof(above_ref[0]));
3800 0 : i = n_top_px;
3801 0 : if (need_right && n_topright_px > 0) {
3802 0 : assert(n_top_px == txwpx);
3803 0 : memcpy(above_row + txwpx, above_ref + txwpx,
3804 : n_topright_px * sizeof(above_ref[0]));
3805 0 : i += n_topright_px;
3806 : }
3807 0 : if (i < num_top_pixels_needed)
3808 0 : eb_aom_memset16(&above_row[i], above_row[i - 1],
3809 0 : num_top_pixels_needed - i);
3810 : }
3811 : else {
3812 0 : if (n_left_px > 0)
3813 0 : eb_aom_memset16(above_row, left_ref[0], num_top_pixels_needed);
3814 : else
3815 0 : eb_aom_memset16(above_row, base - 1, num_top_pixels_needed);
3816 : }
3817 : }
3818 :
3819 0 : if (need_above_left) {
3820 0 : if (n_top_px > 0 && n_left_px > 0)
3821 0 : above_row[-1] = above_ref[-1];
3822 0 : else if (n_top_px > 0)
3823 0 : above_row[-1] = above_ref[0];
3824 0 : else if (n_left_px > 0)
3825 0 : above_row[-1] = left_ref[0];
3826 : else
3827 0 : above_row[-1] = (uint16_t)base;
3828 0 : left_col[-1] = above_row[-1];
3829 : }
3830 : #if FILTER_INTRA_FLAG
3831 0 : if (use_filter_intra) {
3832 0 : highbd_filter_intra_predictor(dst, dst_stride, tx_size, above_row, left_col,
3833 : filter_intra_mode,10);
3834 0 : return;
3835 : }
3836 : #else
3837 : // not added yet
3838 : //if (use_filter_intra) {
3839 : // highbd_filter_intra_predictor(dst, dst_stride, tx_size, above_row, left_col,
3840 : // filter_intra_mode, xd->bd);
3841 : // return;
3842 : //}
3843 : #endif
3844 0 : if (is_dr_mode) {
3845 0 : int32_t upsample_above = 0;
3846 0 : int32_t upsample_left = 0;
3847 0 : if (!disable_edge_filter) {
3848 0 : const int32_t need_right = p_angle < 90;
3849 0 : const int32_t need_bottom = p_angle > 180;
3850 : //const int32_t filt_type = get_filt_type(xd, plane);
3851 0 : const int32_t filt_type = get_filt_type(xd, plane);
3852 0 : if (p_angle != 90 && p_angle != 180) {
3853 0 : const int32_t ab_le = need_above_left ? 1 : 0;
3854 0 : if (need_above && need_left && (txwpx + txhpx >= 24))
3855 0 : filter_intra_edge_corner_high(above_row, left_col);
3856 0 : if (need_above && n_top_px > 0) {
3857 : const int32_t strength =
3858 0 : intra_edge_filter_strength(txwpx, txhpx, p_angle - 90, filt_type);
3859 0 : const int32_t n_px = n_top_px + ab_le + (need_right ? txhpx : 0);
3860 0 : eb_av1_filter_intra_edge_high(above_row - ab_le, n_px, strength);
3861 : }
3862 0 : if (need_left && n_left_px > 0) {
3863 0 : const int32_t strength = intra_edge_filter_strength(
3864 : txhpx, txwpx, p_angle - 180, filt_type);
3865 0 : const int32_t n_px = n_left_px + ab_le + (need_bottom ? txwpx : 0);
3866 :
3867 0 : eb_av1_filter_intra_edge_high(left_col - ab_le, n_px, strength);
3868 : }
3869 : }
3870 : upsample_above =
3871 0 : use_intra_edge_upsample(txwpx, txhpx, p_angle - 90, filt_type);
3872 0 : if (need_above && upsample_above) {
3873 0 : const int32_t n_px = txwpx + (need_right ? txhpx : 0);
3874 : //av1_upsample_intra_edge_high(above_row, n_px, bd);// AMIR : to be replaced by optimized code
3875 0 : eb_av1_upsample_intra_edge_high_c(above_row, n_px, bd);
3876 : }
3877 : upsample_left =
3878 0 : use_intra_edge_upsample(txhpx, txwpx, p_angle - 180, filt_type);
3879 0 : if (need_left && upsample_left) {
3880 0 : const int32_t n_px = txhpx + (need_bottom ? txwpx : 0);
3881 : //av1_upsample_intra_edge_high(left_col, n_px, bd);// AMIR: to be replaced by optimized code
3882 0 : eb_av1_upsample_intra_edge_high_c(left_col, n_px, bd);
3883 : }
3884 : }
3885 0 : highbd_dr_predictor(dst, dst_stride, tx_size, above_row, left_col,
3886 : upsample_above, upsample_left, p_angle, bd);
3887 0 : return;
3888 : }
3889 :
3890 : // predict
3891 0 : if (mode == DC_PRED) {
3892 0 : dc_pred_high[n_left_px > 0][n_top_px > 0][tx_size](
3893 : dst, dst_stride, above_row, left_col, bd);
3894 : }
3895 : else
3896 0 : pred_high[mode][tx_size](dst, dst_stride, above_row, left_col, bd);
3897 : }
3898 :
3899 45956500 : void eb_av1_predict_intra_block(
3900 : TileInfo * tile,
3901 : STAGE stage,
3902 : const BlockGeom * blk_geom,
3903 : const Av1Common *cm,
3904 : int32_t wpx,
3905 : int32_t hpx,
3906 : TxSize tx_size,
3907 : PredictionMode mode,
3908 : int32_t angle_delta,
3909 : int32_t use_palette,
3910 : #if PAL_SUP
3911 : PaletteInfo *palette_info,
3912 : #endif
3913 : FilterIntraMode filter_intra_mode,
3914 : uint8_t* topNeighArray,
3915 : uint8_t* leftNeighArray,
3916 : EbPictureBufferDesc *recon_buffer,
3917 : int32_t col_off,
3918 : int32_t row_off,
3919 : int32_t plane,
3920 : BlockSize bsize,
3921 : uint32_t tu_org_x_pict,
3922 : uint32_t tu_org_y_pict,
3923 : uint32_t bl_org_x_pict,
3924 : uint32_t bl_org_y_pict,
3925 : uint32_t bl_org_x_mb,
3926 : uint32_t bl_org_y_mb)
3927 : {
3928 : (void)use_palette;
3929 : MacroBlockD xdS;
3930 45956500 : MacroBlockD *xd = &xdS;
3931 :
3932 : uint32_t pred_buf_x_offest;
3933 : uint32_t pred_buf_y_offest;
3934 :
3935 45956500 : if (stage == ED_STAGE) { // EncDec
3936 19705 : pred_buf_x_offest = plane ? ((bl_org_x_pict >> 3) << 3) >> 1 : tu_org_x_pict;
3937 19705 : pred_buf_y_offest = plane ? ((bl_org_y_pict >> 3) << 3) >> 1 : tu_org_y_pict;
3938 : }
3939 : else { // MD
3940 45936800 : pred_buf_x_offest = bl_org_x_mb;
3941 45936800 : pred_buf_y_offest = bl_org_y_mb;
3942 : }
3943 :
3944 : // Adjust mirow , micol ;
3945 : // All plane have the same values
3946 :
3947 45956500 : int32_t mirow = bl_org_y_pict >> 2;
3948 45956500 : int32_t micol = bl_org_x_pict >> 2;
3949 45956500 : xd->up_available = (mirow > tile->mi_row_start);
3950 45956500 : xd->left_available = (micol > tile->mi_col_start);
3951 45956500 : const int32_t bw = mi_size_wide[bsize];
3952 45956500 : const int32_t bh = mi_size_high[bsize];
3953 :
3954 45956500 : xd->mb_to_top_edge = -((mirow * MI_SIZE) * 8);
3955 45956500 : xd->mb_to_bottom_edge = ((cm->mi_rows - bh - mirow) * MI_SIZE) * 8;
3956 45956500 : xd->mb_to_left_edge = -((micol * MI_SIZE) * 8);
3957 45956500 : xd->mb_to_right_edge = ((cm->mi_cols - bw - micol) * MI_SIZE) * 8;
3958 45956500 : xd->tile.mi_col_start = tile->mi_col_start;
3959 45956500 : xd->tile.mi_col_end = tile->mi_col_end;
3960 45956500 : xd->tile.mi_row_start = tile->mi_row_start;
3961 45956500 : xd->tile.mi_row_end = tile->mi_row_end;
3962 45956500 : xd->n8_h = bh;
3963 45956500 : xd->n8_w = bw;
3964 45956500 : xd->is_sec_rect = 0;
3965 45956500 : if (xd->n8_w < xd->n8_h) {
3966 : // Only mark is_sec_rect as 1 for the last block.
3967 : // For PARTITION_VERT_4, it would be (0, 0, 0, 1);
3968 : // For other partitions, it would be (0, 1).
3969 12762600 : if (!((micol + xd->n8_w) & (xd->n8_h - 1))) xd->is_sec_rect = 1;
3970 : }
3971 :
3972 45956500 : if (xd->n8_w > xd->n8_h)
3973 11881500 : if (mirow & (xd->n8_w - 1)) xd->is_sec_rect = 1;
3974 : uint8_t *dst;
3975 : int32_t dst_stride;
3976 45956500 : if (plane == 0) {
3977 23501500 : dst = recon_buffer->buffer_y + pred_buf_x_offest + recon_buffer->origin_x + (pred_buf_y_offest + recon_buffer->origin_y)*recon_buffer->stride_y;
3978 23501500 : dst_stride = recon_buffer->stride_y;
3979 : }
3980 22455000 : else if (plane == 1) {
3981 11243400 : dst = recon_buffer->buffer_cb + (pred_buf_x_offest + recon_buffer->origin_x / 2 + (pred_buf_y_offest + recon_buffer->origin_y / 2)*recon_buffer->stride_cb);
3982 11243400 : dst_stride = recon_buffer->stride_cb;
3983 : }
3984 : else {
3985 11211600 : dst = recon_buffer->buffer_cr + (pred_buf_x_offest + recon_buffer->origin_x / 2 + (pred_buf_y_offest + recon_buffer->origin_y / 2)*recon_buffer->stride_cr);
3986 11211600 : dst_stride = recon_buffer->stride_cr;
3987 : }
3988 :
3989 45956500 : int32_t chroma_up_available = xd->up_available;
3990 45956500 : int32_t chroma_left_available = xd->left_available;
3991 45956500 : const int32_t ss_x = plane == 0 ? 0 : 1; //CHKN
3992 45956500 : const int32_t ss_y = plane == 0 ? 0 : 1;
3993 :
3994 45956500 : if (ss_x && bw < mi_size_wide[BLOCK_8X8])
3995 2048930 : chroma_left_available = (micol - 1) > tile->mi_col_start;
3996 45956500 : if (ss_y && bh < mi_size_high[BLOCK_8X8])
3997 2037290 : chroma_up_available = (mirow - 1) > tile->mi_row_start;
3998 :
3999 45956500 : int mi_stride = cm->mi_stride;
4000 45956500 : const int32_t offset = mirow * mi_stride + micol;
4001 45956500 : xd->mi = cm->pcs_ptr->mi_grid_base + offset;
4002 45956500 : ModeInfo *miPtr = *xd->mi;
4003 :
4004 45956500 : if (xd->up_available) {
4005 : // xd->above_mbmi = xd->mi[-xd->mi_stride].mbmi;
4006 43738200 : xd->above_mbmi = &miPtr[-mi_stride].mbmi;
4007 : }
4008 : else
4009 2218260 : xd->above_mbmi = NULL;
4010 45956500 : if (xd->left_available) {
4011 : //xd->left_mbmi = xd->mi[-1].mbmi;
4012 43510300 : xd->left_mbmi = &miPtr[-1].mbmi;
4013 : }
4014 : else
4015 2446180 : xd->left_mbmi = NULL;
4016 91913000 : const int chroma_ref = ((mirow & 0x01) || !(bh & 0x01) || !ss_y) &&
4017 45956500 : ((micol & 0x01) || !(bw & 0x01) || !ss_x);
4018 45956500 : if (chroma_ref) {
4019 : // To help calculate the "above" and "left" chroma blocks, note that the
4020 : // current block may cover multiple luma blocks (eg, if partitioned into
4021 : // 4x4 luma blocks).
4022 : // First, find the top-left-most luma block covered by this chroma block
4023 :
4024 45966000 : ModeInfo *miPtr = xd->mi[-(mirow & ss_y) * mi_stride - (micol & ss_x)];
4025 :
4026 : // Then, we consider the luma region covered by the left or above 4x4 chroma
4027 : // prediction. We want to point to the chroma reference block in that
4028 : // region, which is the bottom-right-most mi unit.
4029 : // This leads to the following offsets:
4030 45966000 : MbModeInfo *chroma_above_mi =
4031 45966000 : chroma_up_available ? &miPtr[-mi_stride + ss_x].mbmi : NULL;
4032 45966000 : xd->chroma_above_mbmi = chroma_above_mi;
4033 :
4034 45966000 : MbModeInfo *chroma_left_mi =
4035 45966000 : chroma_left_available ? &miPtr[ss_y * mi_stride - 1].mbmi : NULL;
4036 45966000 : xd->chroma_left_mbmi = chroma_left_mi;
4037 : }
4038 :
4039 : //CHKN const MbModeInfo *const mbmi = xd->mi[0];
4040 45956500 : const int32_t txwpx = tx_size_wide[tx_size];
4041 45956500 : const int32_t txhpx = tx_size_high[tx_size];
4042 45956500 : const int32_t x = col_off << tx_size_wide_log2[0];
4043 45956500 : const int32_t y = row_off << tx_size_high_log2[0];
4044 :
4045 : #if PAL_SUP
4046 45956500 : if (use_palette) {
4047 : int32_t r, c;
4048 :
4049 0 : const uint8_t *const map = palette_info->color_idx_map;
4050 0 : const uint16_t *const palette =
4051 0 : palette_info->pmi.palette_colors + plane * PALETTE_MAX_SIZE;
4052 0 : for (r = 0; r < txhpx; ++r) {
4053 0 : for (c = 0; c < txwpx; ++c) {
4054 0 : dst[r * dst_stride + c] =
4055 0 : (uint8_t)palette[map[(r + y) * wpx + c + x]];
4056 : }
4057 : }
4058 0 : return;
4059 : }
4060 : #else
4061 :
4062 : //if (use_palette) {
4063 : // int32_t r, c;
4064 : // const uint8_t *const map = xd->plane[plane != 0].color_index_map;
4065 : // const uint16_t *const palette =
4066 : // mbmi->palette_mode_info.palette_colors + plane * PALETTE_MAX_SIZE;
4067 : // if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
4068 : // uint16_t *dst16 = CONVERT_TO_SHORTPTR(dst);
4069 : // for (r = 0; r < txhpx; ++r) {
4070 : // for (c = 0; c < txwpx; ++c) {
4071 : // dst16[r * dst_stride + c] = palette[map[(r + y) * wpx + c + x]];
4072 : // }
4073 : // }
4074 : // } else {
4075 : // for (r = 0; r < txhpx; ++r) {
4076 : // for (c = 0; c < txwpx; ++c) {
4077 : // dst[r * dst_stride + c] =
4078 : // (uint8_t)palette[map[(r + y) * wpx + c + x]];
4079 : // }
4080 : // }
4081 : // }
4082 : // return;
4083 : //}
4084 : #endif
4085 : //CHKN BlockSize bsize = mbmi->sb_type;
4086 : struct MacroblockdPlane pd_s;
4087 45956500 : struct MacroblockdPlane * pd = &pd_s;
4088 45956500 : if (plane == 0)
4089 23501600 : pd->subsampling_x = pd->subsampling_y = 0;
4090 : else
4091 22454900 : pd->subsampling_x = pd->subsampling_y = 1;
4092 45956500 : const int32_t txw = tx_size_wide_unit[tx_size];
4093 45956500 : const int32_t txh = tx_size_high_unit[tx_size];
4094 68855500 : const int32_t have_top = row_off || (pd->subsampling_y ? /*xd->*/chroma_up_available
4095 22899000 : : xd->up_available);
4096 45956500 : const int32_t have_left =
4097 91332200 : col_off ||
4098 45375800 : (pd->subsampling_x ? /*xd->*/chroma_left_available : xd->left_available);
4099 45956500 : const int32_t mi_row = -xd->mb_to_top_edge >> (3 + MI_SIZE_LOG2);
4100 45956500 : const int32_t mi_col = -xd->mb_to_left_edge >> (3 + MI_SIZE_LOG2);
4101 45956500 : const int32_t xr_chr_offset = 0;
4102 45956500 : const int32_t yd_chr_offset = 0;
4103 :
4104 : // Distance between the right edge of this prediction block to
4105 : // the frame right edge
4106 45956500 : const int32_t xr = (xd->mb_to_right_edge >> (3 + pd->subsampling_x)) +
4107 45956500 : (wpx - x - txwpx) - xr_chr_offset;
4108 : // Distance between the bottom edge of this prediction block to
4109 : // the frame bottom edge
4110 45956500 : const int32_t yd = (xd->mb_to_bottom_edge >> (3 + pd->subsampling_y)) +
4111 45956500 : (hpx - y - txhpx) - yd_chr_offset;
4112 45956500 : const int32_t right_available =
4113 45956500 : mi_col + ((col_off + txw) << pd->subsampling_x) < xd->tile.mi_col_end;
4114 45956500 : const int32_t bottom_available =
4115 90178600 : (yd > 0) &&
4116 44222100 : (mi_row + ((row_off + txh) << pd->subsampling_y) < xd->tile.mi_row_end);
4117 :
4118 45956500 : const PartitionType partition = from_shape_to_part[blk_geom->shape]; //cu_ptr->part;// PARTITION_NONE;//CHKN this is good enough as the avail functions need to know if VERT part is used or not mbmi->partition;
4119 :
4120 : // force 4x4 chroma component block size.
4121 45956500 : bsize = scale_chroma_bsize(bsize, pd->subsampling_x, pd->subsampling_y);
4122 :
4123 45964100 : const int32_t have_top_right = intra_has_top_right(
4124 45964100 : cm->p_pcs_ptr->sequence_control_set_ptr->seq_header.sb_size, bsize,
4125 : mi_row, mi_col, have_top, right_available, partition, tx_size,
4126 : row_off, col_off, pd->subsampling_x, pd->subsampling_y);
4127 45959200 : const int32_t have_bottom_left = intra_has_bottom_left(
4128 45959200 : cm->p_pcs_ptr->sequence_control_set_ptr->seq_header.sb_size, bsize,
4129 : mi_row, mi_col, bottom_available, have_left, partition,
4130 : tx_size, row_off, col_off, pd->subsampling_x, pd->subsampling_y);
4131 :
4132 45976300 : const int32_t disable_edge_filter = 0;//CHKN !cm->seq_params.enable_intra_edge_filter;
4133 :
4134 : //if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
4135 : // build_intra_predictors_high(
4136 : // xd, ref, ref_stride, dst, dst_stride, mode, angle_delta,
4137 : // filter_intra_mode, tx_size, disable_edge_filter,
4138 : // have_top ? AOMMIN(txwpx, xr + txwpx) : 0,
4139 : // have_top_right ? AOMMIN(txwpx, xr) : 0,
4140 : // have_left ? AOMMIN(txhpx, yd + txhpx) : 0,
4141 : // have_bottom_left ? AOMMIN(txhpx, yd) : 0, plane);
4142 : // return;
4143 : //}
4144 :
4145 133133000 : build_intra_predictors(
4146 : xd,
4147 : topNeighArray,
4148 : leftNeighArray,
4149 : // ref, ref_stride,
4150 : dst, dst_stride, mode,
4151 : angle_delta, filter_intra_mode, tx_size,
4152 : disable_edge_filter,
4153 43705900 : have_top ? AOMMIN(txwpx, xr + txwpx) : 0,
4154 : have_top_right ? AOMMIN(txwpx, xr) : 0,
4155 43450600 : have_left ? AOMMIN(txhpx, yd + txhpx) : 0,
4156 : have_bottom_left ? AOMMIN(txhpx, yd) : 0, plane);
4157 : }
4158 :
4159 0 : void eb_av1_predict_intra_block_16bit(
4160 : TileInfo * tile,
4161 : STAGE stage,
4162 : const BlockGeom * blk_geom,
4163 : const Av1Common *cm,
4164 : int32_t wpx,
4165 : int32_t hpx,
4166 : TxSize tx_size,
4167 : PredictionMode mode,
4168 : int32_t angle_delta,
4169 : int32_t use_palette,
4170 : #if PAL_SUP
4171 : PaletteInfo *palette_info,
4172 : #endif
4173 : FilterIntraMode filter_intra_mode,
4174 : uint16_t* topNeighArray,
4175 : uint16_t* leftNeighArray,
4176 : EbPictureBufferDesc *recon_buffer,
4177 : int32_t col_off,
4178 : int32_t row_off,
4179 : int32_t plane,
4180 : BlockSize bsize,
4181 : uint32_t tu_org_x_pict,
4182 : uint32_t tu_org_y_pict,
4183 : uint32_t bl_org_x_pict,
4184 : uint32_t bl_org_y_pict,
4185 : uint32_t bl_org_x_mb,
4186 : uint32_t bl_org_y_mb)
4187 : {
4188 : (void)use_palette;
4189 : MacroBlockD xdS;
4190 0 : MacroBlockD *xd = &xdS;
4191 :
4192 : uint32_t pred_buf_x_offest;
4193 : uint32_t pred_buf_y_offest;
4194 :
4195 0 : if (stage == ED_STAGE) { // EncDec
4196 0 : pred_buf_x_offest = plane ? ((bl_org_x_pict >> 3) << 3) >> 1 : tu_org_x_pict;
4197 0 : pred_buf_y_offest = plane ? ((bl_org_y_pict >> 3) << 3) >> 1 : tu_org_y_pict;
4198 : } else { // MD
4199 0 : pred_buf_x_offest = bl_org_x_mb;
4200 0 : pred_buf_y_offest = bl_org_y_mb;
4201 : }
4202 :
4203 0 : int32_t mirow = bl_org_y_pict >> 2;
4204 0 : int32_t micol = bl_org_x_pict >> 2;
4205 0 : xd->up_available = (mirow > tile->mi_row_start);
4206 0 : xd->left_available = (micol > tile->mi_col_start);
4207 :
4208 0 : const int32_t bw = mi_size_wide[bsize];
4209 0 : const int32_t bh = mi_size_high[bsize];
4210 :
4211 0 : xd->mb_to_top_edge = -((mirow * MI_SIZE) * 8);
4212 0 : xd->mb_to_bottom_edge = ((cm->mi_rows - bh - mirow) * MI_SIZE) * 8;
4213 0 : xd->mb_to_left_edge = -((micol * MI_SIZE) * 8);
4214 0 : xd->mb_to_right_edge = ((cm->mi_cols - bw - micol) * MI_SIZE) * 8;
4215 0 : xd->tile.mi_col_start = tile->mi_col_start;
4216 0 : xd->tile.mi_col_end = tile->mi_col_end;
4217 0 : xd->tile.mi_row_start = tile->mi_row_start;
4218 0 : xd->tile.mi_row_end = tile->mi_row_end;
4219 0 : xd->n8_h = bh;
4220 0 : xd->n8_w = bw;
4221 0 : xd->is_sec_rect = 0;
4222 0 : if (xd->n8_w < xd->n8_h) {
4223 : // Only mark is_sec_rect as 1 for the last block.
4224 : // For PARTITION_VERT_4, it would be (0, 0, 0, 1);
4225 : // For other partitions, it would be (0, 1).
4226 0 : if (!((micol + xd->n8_w) & (xd->n8_h - 1))) xd->is_sec_rect = 1;
4227 : }
4228 :
4229 0 : if (xd->n8_w > xd->n8_h)
4230 0 : if (mirow & (xd->n8_w - 1)) xd->is_sec_rect = 1;
4231 :
4232 : // Adjust prediction pointers
4233 : uint16_t *dst;
4234 : int32_t dst_stride;
4235 0 : if (plane == 0) {
4236 0 : dst = (uint16_t*)(recon_buffer->buffer_y) + pred_buf_x_offest + recon_buffer->origin_x + (pred_buf_y_offest + recon_buffer->origin_y)*recon_buffer->stride_y;
4237 0 : dst_stride = recon_buffer->stride_y;
4238 : }
4239 0 : else if (plane == 1) {
4240 0 : dst = (uint16_t*)(recon_buffer->buffer_cb) + (pred_buf_x_offest + recon_buffer->origin_x / 2 + (pred_buf_y_offest + recon_buffer->origin_y / 2)*recon_buffer->stride_cb);
4241 0 : dst_stride = recon_buffer->stride_cb;
4242 : }
4243 : else {
4244 0 : dst = (uint16_t*)(recon_buffer->buffer_cr) + (pred_buf_x_offest + recon_buffer->origin_x / 2 + (pred_buf_y_offest + recon_buffer->origin_y / 2)*recon_buffer->stride_cr);
4245 0 : dst_stride = recon_buffer->stride_cr;
4246 : }
4247 :
4248 0 : int32_t chroma_up_available = xd->up_available;
4249 0 : int32_t chroma_left_available = xd->left_available;
4250 :
4251 0 : const int32_t ss_x = plane == 0 ? 0 : 1;
4252 0 : const int32_t ss_y = plane == 0 ? 0 : 1;
4253 :
4254 0 : if (ss_x && bw < mi_size_wide[BLOCK_8X8])
4255 0 : chroma_left_available = (micol - 1) > tile->mi_col_start;
4256 0 : if (ss_y && bh < mi_size_high[BLOCK_8X8])
4257 0 : chroma_up_available = (mirow - 1) > tile->mi_row_start;
4258 :
4259 0 : int mi_stride = cm->mi_stride;
4260 0 : const int32_t offset = mirow * mi_stride + micol;
4261 0 : xd->mi = cm->pcs_ptr->mi_grid_base + offset;
4262 0 : ModeInfo *miPtr = *xd->mi;
4263 :
4264 0 : if (xd->up_available) {
4265 : // xd->above_mbmi = xd->mi[-xd->mi_stride].mbmi;
4266 0 : xd->above_mbmi = &miPtr[-mi_stride].mbmi;
4267 : }
4268 : else
4269 0 : xd->above_mbmi = NULL;
4270 0 : if (xd->left_available) {
4271 : //xd->left_mbmi = xd->mi[-1].mbmi;
4272 0 : xd->left_mbmi = &miPtr[-1].mbmi;
4273 : }
4274 : else
4275 0 : xd->left_mbmi = NULL;
4276 0 : const int chroma_ref = ((mirow & 0x01) || !(bh & 0x01) || !ss_y) &&
4277 0 : ((micol & 0x01) || !(bw & 0x01) || !ss_x);
4278 0 : if (chroma_ref) {
4279 : // To help calculate the "above" and "left" chroma blocks, note that the
4280 : // current block may cover multiple luma blocks (eg, if partitioned into
4281 : // 4x4 luma blocks).
4282 : // First, find the top-left-most luma block covered by this chroma block
4283 :
4284 0 : ModeInfo *miPtr = xd->mi[-(mirow & ss_y) * mi_stride - (micol & ss_x)];
4285 :
4286 : // Then, we consider the luma region covered by the left or above 4x4 chroma
4287 : // prediction. We want to point to the chroma reference block in that
4288 : // region, which is the bottom-right-most mi unit.
4289 : // This leads to the following offsets:
4290 0 : MbModeInfo *chroma_above_mi =
4291 0 : chroma_up_available ? &miPtr[-mi_stride + ss_x].mbmi : NULL;
4292 0 : xd->chroma_above_mbmi = chroma_above_mi;
4293 :
4294 0 : MbModeInfo *chroma_left_mi =
4295 0 : chroma_left_available ? &miPtr[ss_y * mi_stride - 1].mbmi : NULL;
4296 0 : xd->chroma_left_mbmi = chroma_left_mi;
4297 : }
4298 :
4299 : //CHKN const MbModeInfo *const mbmi = xd->mi[0];
4300 0 : const int32_t txwpx = tx_size_wide[tx_size];
4301 0 : const int32_t txhpx = tx_size_high[tx_size];
4302 0 : const int32_t x = col_off << tx_size_wide_log2[0];
4303 0 : const int32_t y = row_off << tx_size_high_log2[0];
4304 : #if PAL_SUP
4305 0 : if (use_palette) {
4306 : int32_t r, c;
4307 0 : const uint8_t *const map = palette_info->color_idx_map;
4308 0 : const uint16_t *const palette =
4309 0 : palette_info->pmi.palette_colors + plane * PALETTE_MAX_SIZE;
4310 0 : for (r = 0; r < txhpx; ++r) {
4311 0 : for (c = 0; c < txwpx; ++c) {
4312 0 : dst[r * dst_stride + c] = palette[map[(r + y) * wpx + c + x]];
4313 : }
4314 : }
4315 0 : return;
4316 : }
4317 : #else
4318 : //if (use_palette) {
4319 : // int32_t r, c;
4320 : // const uint8_t *const map = xd->plane[plane != 0].color_index_map;
4321 : // const uint16_t *const palette =
4322 : // mbmi->palette_mode_info.palette_colors + plane * PALETTE_MAX_SIZE;
4323 : // if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
4324 : // uint16_t *dst16 = CONVERT_TO_SHORTPTR(dst);
4325 : // for (r = 0; r < txhpx; ++r) {
4326 : // for (c = 0; c < txwpx; ++c) {
4327 : // dst16[r * dst_stride + c] = palette[map[(r + y) * wpx + c + x]];
4328 : // }
4329 : // }
4330 : // } else {
4331 : // for (r = 0; r < txhpx; ++r) {
4332 : // for (c = 0; c < txwpx; ++c) {
4333 : // dst[r * dst_stride + c] =
4334 : // (uint8_t)palette[map[(r + y) * wpx + c + x]];
4335 : // }
4336 : // }
4337 : // }
4338 : // return;
4339 : //}
4340 : #endif
4341 : //CHKN BlockSize bsize = mbmi->sb_type;
4342 :
4343 : struct MacroblockdPlane pd_s;
4344 0 : struct MacroblockdPlane * pd = &pd_s;
4345 0 : if (plane == 0)
4346 0 : pd->subsampling_x = pd->subsampling_y = 0;
4347 : else
4348 0 : pd->subsampling_x = pd->subsampling_y = 1;
4349 0 : const int32_t txw = tx_size_wide_unit[tx_size];
4350 0 : const int32_t txh = tx_size_high_unit[tx_size];
4351 0 : const int32_t have_top = row_off || (pd->subsampling_y ? /*xd->*/chroma_up_available
4352 0 : : xd->up_available);
4353 0 : const int32_t have_left =
4354 0 : col_off ||
4355 0 : (pd->subsampling_x ? /*xd->*/chroma_left_available : xd->left_available);
4356 0 : const int32_t mi_row = -xd->mb_to_top_edge >> (3 + MI_SIZE_LOG2);
4357 0 : const int32_t mi_col = -xd->mb_to_left_edge >> (3 + MI_SIZE_LOG2);
4358 0 : const int32_t xr_chr_offset = 0;
4359 0 : const int32_t yd_chr_offset = 0;
4360 :
4361 : // Distance between the right edge of this prediction block to
4362 : // the frame right edge
4363 0 : const int32_t xr = (xd->mb_to_right_edge >> (3 + pd->subsampling_x)) +
4364 0 : (wpx - x - txwpx) - xr_chr_offset;
4365 : // Distance between the bottom edge of this prediction block to
4366 : // the frame bottom edge
4367 0 : const int32_t yd = (xd->mb_to_bottom_edge >> (3 + pd->subsampling_y)) +
4368 0 : (hpx - y - txhpx) - yd_chr_offset;
4369 0 : const int32_t right_available =
4370 0 : mi_col + ((col_off + txw) << pd->subsampling_x) < xd->tile.mi_col_end;
4371 0 : const int32_t bottom_available =
4372 0 : (yd > 0) &&
4373 0 : (mi_row + ((row_off + txh) << pd->subsampling_y) < xd->tile.mi_row_end);
4374 :
4375 0 : const PartitionType partition = from_shape_to_part[blk_geom->shape]; //cu_ptr->part;// PARTITION_NONE;//CHKN this is good enough as the avail functions need to know if VERT part is used or not mbmi->partition;
4376 :
4377 : // force 4x4 chroma component block size.
4378 0 : bsize = scale_chroma_bsize(bsize, pd->subsampling_x, pd->subsampling_y);
4379 :
4380 0 : const int32_t have_top_right = intra_has_top_right(
4381 0 : cm->p_pcs_ptr->sequence_control_set_ptr->seq_header.sb_size, bsize,
4382 : mi_row, mi_col, have_top, right_available, partition, tx_size,
4383 : row_off, col_off, pd->subsampling_x, pd->subsampling_y);
4384 0 : const int32_t have_bottom_left = intra_has_bottom_left(
4385 0 : cm->p_pcs_ptr->sequence_control_set_ptr->seq_header.sb_size, bsize,
4386 : mi_row, mi_col, bottom_available, have_left, partition,
4387 : tx_size, row_off, col_off, pd->subsampling_x, pd->subsampling_y);
4388 :
4389 0 : const int32_t disable_edge_filter = 0;//CHKN !cm->seq_params.enable_intra_edge_filter;
4390 :
4391 0 : build_intra_predictors_high(
4392 : xd,
4393 : topNeighArray,
4394 : leftNeighArray,
4395 : // ref, ref_stride,
4396 : dst, dst_stride, mode,
4397 : angle_delta, filter_intra_mode, tx_size,
4398 : disable_edge_filter,
4399 0 : have_top ? AOMMIN(txwpx, xr + txwpx) : 0,
4400 : have_top_right ? AOMMIN(txwpx, xr) : 0,
4401 0 : have_left ? AOMMIN(txhpx, yd + txhpx) : 0,
4402 : have_bottom_left ? AOMMIN(txhpx, yd) : 0, plane, EB_10BIT);
4403 : }
4404 :
4405 : /** IntraPrediction()
4406 : is the main function to compute intra prediction for a PU
4407 : */
4408 12949900 : EbErrorType eb_av1_intra_prediction_cl(
4409 : ModeDecisionContext *md_context_ptr,
4410 : PictureControlSet *picture_control_set_ptr,
4411 : ModeDecisionCandidateBuffer *candidate_buffer_ptr)
4412 : {
4413 12949900 : EbErrorType return_error = EB_ErrorNone;
4414 :
4415 12949900 : uint32_t modeTypeLeftNeighborIndex = get_neighbor_array_unit_left_index(
4416 : md_context_ptr->mode_type_neighbor_array,
4417 12949900 : md_context_ptr->cu_origin_y);
4418 12949400 : uint32_t modeTypeTopNeighborIndex = get_neighbor_array_unit_top_index(
4419 : md_context_ptr->mode_type_neighbor_array,
4420 12949400 : md_context_ptr->cu_origin_x);
4421 12949200 : uint32_t intraLumaModeLeftNeighborIndex = get_neighbor_array_unit_left_index(
4422 : md_context_ptr->intra_luma_mode_neighbor_array,
4423 12949200 : md_context_ptr->cu_origin_y);
4424 12948400 : uint32_t intraLumaModeTopNeighborIndex = get_neighbor_array_unit_top_index(
4425 : md_context_ptr->intra_luma_mode_neighbor_array,
4426 12948400 : md_context_ptr->cu_origin_x);
4427 :
4428 12947600 : uint32_t intraChromaModeLeftNeighborIndex = get_neighbor_array_unit_left_index(
4429 : md_context_ptr->intra_chroma_mode_neighbor_array,
4430 12947600 : md_context_ptr->round_origin_y >> 1);
4431 12946800 : uint32_t intraChromaModeTopNeighborIndex = get_neighbor_array_unit_top_index(
4432 : md_context_ptr->intra_chroma_mode_neighbor_array,
4433 12946800 : md_context_ptr->round_origin_x >> 1);
4434 :
4435 7707780 : md_context_ptr->intra_luma_left_mode = (uint32_t)(
4436 12948300 : (md_context_ptr->mode_type_neighbor_array->left_array[modeTypeLeftNeighborIndex] != INTRA_MODE) ? DC_PRED/*EB_INTRA_DC*/ :
4437 5240500 : (uint32_t)md_context_ptr->intra_luma_mode_neighbor_array->left_array[intraLumaModeLeftNeighborIndex]);
4438 :
4439 7763580 : md_context_ptr->intra_luma_top_mode = (uint32_t)(
4440 12948300 : (md_context_ptr->mode_type_neighbor_array->top_array[modeTypeTopNeighborIndex] != INTRA_MODE) ? DC_PRED/*EB_INTRA_DC*/ :
4441 5184690 : (uint32_t)md_context_ptr->intra_luma_mode_neighbor_array->top_array[intraLumaModeTopNeighborIndex]); // use DC. This seems like we could use a LCU-width
4442 :
4443 12948300 : md_context_ptr->intra_chroma_left_mode = md_context_ptr->intra_luma_left_mode;
4444 12948300 : md_context_ptr->intra_chroma_top_mode = md_context_ptr->intra_luma_top_mode;
4445 :
4446 7707420 : md_context_ptr->intra_chroma_left_mode = (uint32_t)(
4447 12948300 : (md_context_ptr->mode_type_neighbor_array->left_array[modeTypeLeftNeighborIndex] != INTRA_MODE) ? UV_DC_PRED :
4448 5240860 : (uint32_t)md_context_ptr->intra_chroma_mode_neighbor_array->left_array[intraChromaModeLeftNeighborIndex]);
4449 :
4450 7763220 : md_context_ptr->intra_chroma_top_mode = (uint32_t)(
4451 12948300 : (md_context_ptr->mode_type_neighbor_array->top_array[modeTypeTopNeighborIndex] != INTRA_MODE) ? UV_DC_PRED :
4452 5185060 : (uint32_t)md_context_ptr->intra_chroma_mode_neighbor_array->top_array[intraChromaModeTopNeighborIndex]); // use DC. This seems like we could use a LCU-width
4453 12948300 : TxSize tx_size = md_context_ptr->blk_geom->txsize[candidate_buffer_ptr->candidate_ptr->tx_depth][0]; // Nader - Intra 128x128 not supported
4454 12948300 : TxSize tx_size_Chroma = md_context_ptr->blk_geom->txsize_uv[candidate_buffer_ptr->candidate_ptr->tx_depth][0]; //Nader - Intra 128x128 not supported
4455 :
4456 12948300 : if(!md_context_ptr->hbd_mode_decision) {
4457 : uint8_t topNeighArray[64 * 2 + 1];
4458 : uint8_t leftNeighArray[64 * 2 + 1];
4459 : PredictionMode mode;
4460 : // Hsan: plane should be derived @ an earlier stage (e.g. @ the call of perform_fast_loop())
4461 12947600 : int32_t start_plane = (md_context_ptr->uv_search_path) ? 1 : 0;
4462 12947600 : int32_t end_plane = (md_context_ptr->blk_geom->has_uv && md_context_ptr->chroma_level <= CHROMA_MODE_1) ? (int)MAX_MB_PLANE : 1;
4463 :
4464 43938300 : for (int32_t plane = start_plane; plane < end_plane; ++plane) {
4465 30999100 : if (plane == 0) {
4466 8698350 : if (md_context_ptr->cu_origin_y != 0)
4467 8264610 : memcpy(topNeighArray + 1, md_context_ptr->luma_recon_neighbor_array->top_array + md_context_ptr->cu_origin_x, md_context_ptr->blk_geom->bwidth * 2);
4468 8698350 : if (md_context_ptr->cu_origin_x != 0)
4469 8099450 : memcpy(leftNeighArray + 1, md_context_ptr->luma_recon_neighbor_array->left_array + md_context_ptr->cu_origin_y, md_context_ptr->blk_geom->bheight * 2);
4470 8698350 : if (md_context_ptr->cu_origin_y != 0 && md_context_ptr->cu_origin_x != 0)
4471 7691460 : topNeighArray[0] = leftNeighArray[0] = md_context_ptr->luma_recon_neighbor_array->top_left_array[MAX_PICTURE_HEIGHT_SIZE + md_context_ptr->cu_origin_x - md_context_ptr->cu_origin_y];
4472 : }
4473 :
4474 22300800 : else if (plane == 1) {
4475 11154700 : if (md_context_ptr->round_origin_y != 0)
4476 10576700 : memcpy(topNeighArray + 1, md_context_ptr->cb_recon_neighbor_array->top_array + md_context_ptr->round_origin_x / 2, md_context_ptr->blk_geom->bwidth_uv * 2);
4477 :
4478 11154700 : if (md_context_ptr->round_origin_x != 0)
4479 10498300 : memcpy(leftNeighArray + 1, md_context_ptr->cb_recon_neighbor_array->left_array + md_context_ptr->round_origin_y / 2, md_context_ptr->blk_geom->bheight_uv * 2);
4480 :
4481 11154700 : if (md_context_ptr->round_origin_y != 0 && md_context_ptr->round_origin_x != 0)
4482 9950800 : topNeighArray[0] = leftNeighArray[0] = md_context_ptr->cb_recon_neighbor_array->top_left_array[MAX_PICTURE_HEIGHT_SIZE / 2 + md_context_ptr->round_origin_x / 2 - md_context_ptr->round_origin_y / 2];
4483 : }
4484 : else {
4485 11146000 : if (md_context_ptr->round_origin_y != 0)
4486 10577300 : memcpy(topNeighArray + 1, md_context_ptr->cr_recon_neighbor_array->top_array + md_context_ptr->round_origin_x / 2, md_context_ptr->blk_geom->bwidth_uv * 2);
4487 :
4488 11146000 : if (md_context_ptr->round_origin_x != 0)
4489 10498800 : memcpy(leftNeighArray + 1, md_context_ptr->cr_recon_neighbor_array->left_array + md_context_ptr->round_origin_y / 2, md_context_ptr->blk_geom->bheight_uv * 2);
4490 :
4491 11146000 : if (md_context_ptr->round_origin_y != 0 && md_context_ptr->round_origin_x != 0)
4492 9950810 : topNeighArray[0] = leftNeighArray[0] = md_context_ptr->cr_recon_neighbor_array->top_left_array[MAX_PICTURE_HEIGHT_SIZE / 2 + md_context_ptr->round_origin_x / 2 - md_context_ptr->round_origin_y / 2];
4493 : }
4494 :
4495 30999100 : if (plane)
4496 22303300 : mode = (candidate_buffer_ptr->candidate_ptr->intra_chroma_mode == UV_CFL_PRED) ? (PredictionMode) UV_DC_PRED : (PredictionMode) candidate_buffer_ptr->candidate_ptr->intra_chroma_mode;
4497 : else
4498 8695800 : mode = candidate_buffer_ptr->candidate_ptr->pred_mode;
4499 :
4500 172394000 : eb_av1_predict_intra_block(
4501 30999100 : &md_context_ptr->sb_ptr->tile_info,
4502 : !ED_STAGE,
4503 : md_context_ptr->blk_geom,
4504 30999100 : picture_control_set_ptr->parent_pcs_ptr->av1_cm, //const Av1Common *cm,
4505 30999100 : plane ? md_context_ptr->blk_geom->bwidth_uv : md_context_ptr->blk_geom->bwidth, //int32_t wpx,
4506 30999100 : plane ? md_context_ptr->blk_geom->bheight_uv : md_context_ptr->blk_geom->bheight, //int32_t hpx,
4507 : plane ? tx_size_Chroma : tx_size, //TxSize tx_size,
4508 : mode, //PredictionMode mode,
4509 30999100 : plane ? candidate_buffer_ptr->candidate_ptr->angle_delta[PLANE_TYPE_UV] : candidate_buffer_ptr->candidate_ptr->angle_delta[PLANE_TYPE_Y],
4510 : #if PAL_SUP
4511 8699290 : plane==0 ? (candidate_buffer_ptr->candidate_ptr->palette_info.pmi.palette_size[0]>0) : 0,
4512 8699280 : plane==0 ? &candidate_buffer_ptr->candidate_ptr->palette_info : NULL, //MD
4513 : #else
4514 : 0, //int32_t use_palette,
4515 : #endif
4516 : #if FILTER_INTRA_FLAG
4517 8699170 : plane ? FILTER_INTRA_MODES : candidate_buffer_ptr->candidate_ptr->filter_intra_mode,
4518 : #else
4519 : FILTER_INTRA_MODES, //CHKN FilterIntraMode filter_intra_mode,
4520 : #endif
4521 : topNeighArray + 1,
4522 : leftNeighArray + 1,
4523 : candidate_buffer_ptr->prediction_ptr, //uint8_t *dst,
4524 : //int32_t dst_stride,
4525 : 0, //int32_t col_off,
4526 : 0, //int32_t row_off,
4527 : plane, //int32_t plane,
4528 30999100 : md_context_ptr->blk_geom->bsize, //uint32_t puSize,
4529 30999100 : md_context_ptr->cu_origin_x,
4530 30999100 : md_context_ptr->cu_origin_y,
4531 30999100 : md_context_ptr->cu_origin_x, //uint32_t cuOrgX,
4532 30999100 : md_context_ptr->cu_origin_y, //uint32_t cuOrgY
4533 30999100 : plane ? ((md_context_ptr->blk_geom->origin_x >> 3) << 3) / 2 : md_context_ptr->blk_geom->origin_x, //uint32_t cuOrgX used only for prediction Ptr
4534 30999100 : plane ? ((md_context_ptr->blk_geom->origin_y >> 3) << 3) / 2 : md_context_ptr->blk_geom->origin_y //uint32_t cuOrgY used only for prediction Ptr
4535 : );
4536 : }
4537 : } else {
4538 : uint16_t topNeighArray[64 * 2 + 1];
4539 : uint16_t leftNeighArray[64 * 2 + 1];
4540 : PredictionMode mode;
4541 : // Hsan: plane should be derived @ an earlier stage (e.g. @ the call of perform_fast_loop())
4542 651 : int32_t start_plane = (md_context_ptr->uv_search_path) ? 1 : 0;
4543 651 : int32_t end_plane = (md_context_ptr->blk_geom->has_uv && md_context_ptr->chroma_level <= CHROMA_MODE_1) ? (int)MAX_MB_PLANE : 1;
4544 651 : for (int32_t plane = start_plane; plane < end_plane; ++plane) {
4545 0 : if (plane == 0) {
4546 0 : if (md_context_ptr->cu_origin_y != 0)
4547 0 : memcpy(topNeighArray + 1, (uint16_t*)(md_context_ptr->luma_recon_neighbor_array16bit->top_array) + md_context_ptr->cu_origin_x, md_context_ptr->blk_geom->bwidth * 2 * sizeof(uint16_t));
4548 :
4549 0 : if (md_context_ptr->cu_origin_x != 0)
4550 0 : memcpy(leftNeighArray + 1, (uint16_t*)(md_context_ptr->luma_recon_neighbor_array16bit->left_array) + md_context_ptr->cu_origin_y, md_context_ptr->blk_geom->bheight * 2 * sizeof(uint16_t));
4551 :
4552 0 : if (md_context_ptr->cu_origin_y != 0 && md_context_ptr->cu_origin_x != 0)
4553 0 : topNeighArray[0] = leftNeighArray[0] = ((uint16_t*)(md_context_ptr->luma_recon_neighbor_array16bit->top_left_array) + MAX_PICTURE_HEIGHT_SIZE + md_context_ptr->cu_origin_x - md_context_ptr->cu_origin_y)[0];
4554 : }
4555 0 : else if (plane == 1) {
4556 0 : if (md_context_ptr->round_origin_y != 0)
4557 0 : memcpy(topNeighArray + 1, (uint16_t*)(md_context_ptr->cb_recon_neighbor_array16bit->top_array) + md_context_ptr->round_origin_x / 2, md_context_ptr->blk_geom->bwidth_uv * 2 * sizeof(uint16_t));
4558 :
4559 0 : if (md_context_ptr->round_origin_x != 0)
4560 0 : memcpy(leftNeighArray + 1, (uint16_t*)(md_context_ptr->cb_recon_neighbor_array16bit->left_array) + md_context_ptr->round_origin_y / 2, md_context_ptr->blk_geom->bheight_uv * 2 * sizeof(uint16_t));
4561 :
4562 0 : if (md_context_ptr->round_origin_y != 0 && md_context_ptr->round_origin_x != 0)
4563 0 : topNeighArray[0] = leftNeighArray[0] = ((uint16_t*) (md_context_ptr->cb_recon_neighbor_array16bit->top_left_array) + MAX_PICTURE_HEIGHT_SIZE / 2 + md_context_ptr->round_origin_x / 2 - md_context_ptr->round_origin_y / 2)[0];
4564 : }
4565 : else {
4566 0 : if (md_context_ptr->round_origin_y != 0)
4567 0 : memcpy(topNeighArray + 1, (uint16_t*)(md_context_ptr->cr_recon_neighbor_array16bit->top_array) + md_context_ptr->round_origin_x / 2, md_context_ptr->blk_geom->bwidth_uv * 2 * sizeof(uint16_t));
4568 :
4569 0 : if (md_context_ptr->round_origin_x != 0)
4570 0 : memcpy(leftNeighArray + 1, (uint16_t*)(md_context_ptr->cr_recon_neighbor_array16bit->left_array) + md_context_ptr->round_origin_y / 2, md_context_ptr->blk_geom->bheight_uv * 2 * sizeof(uint16_t));
4571 :
4572 0 : if (md_context_ptr->round_origin_y != 0 && md_context_ptr->round_origin_x != 0)
4573 0 : topNeighArray[0] = leftNeighArray[0] = ((uint16_t*) (md_context_ptr->cr_recon_neighbor_array16bit->top_left_array) + MAX_PICTURE_HEIGHT_SIZE / 2 + md_context_ptr->round_origin_x / 2 - md_context_ptr->round_origin_y / 2)[0];
4574 : }
4575 :
4576 0 : if (plane)
4577 0 : mode = (candidate_buffer_ptr->candidate_ptr->intra_chroma_mode == UV_CFL_PRED) ? (PredictionMode) UV_DC_PRED : (PredictionMode) candidate_buffer_ptr->candidate_ptr->intra_chroma_mode;
4578 : else
4579 0 : mode = candidate_buffer_ptr->candidate_ptr->pred_mode;
4580 :
4581 0 : eb_av1_predict_intra_block_16bit(
4582 0 : &md_context_ptr->sb_ptr->tile_info,
4583 : !ED_STAGE,
4584 : md_context_ptr->blk_geom,
4585 0 : picture_control_set_ptr->parent_pcs_ptr->av1_cm, //const Av1Common *cm,
4586 0 : plane ? md_context_ptr->blk_geom->bwidth_uv : md_context_ptr->blk_geom->bwidth, //int32_t wpx,
4587 0 : plane ? md_context_ptr->blk_geom->bheight_uv : md_context_ptr->blk_geom->bheight, //int32_t hpx,
4588 : plane ? tx_size_Chroma : tx_size, //TxSize tx_size,
4589 : mode, //PredictionMode mode,
4590 0 : plane ? candidate_buffer_ptr->candidate_ptr->angle_delta[PLANE_TYPE_UV] : candidate_buffer_ptr->candidate_ptr->angle_delta[PLANE_TYPE_Y],
4591 : #if PAL_SUP
4592 0 : plane == 0 ? (candidate_buffer_ptr->candidate_ptr->palette_info.pmi.palette_size[0] > 0) : 0,
4593 0 : plane == 0 ? &candidate_buffer_ptr->candidate_ptr->palette_info : NULL, //MD
4594 : #else
4595 : 0, //int32_t use_palette,
4596 : #endif
4597 : #if FILTER_INTRA_FLAG
4598 0 : plane ? FILTER_INTRA_MODES : candidate_buffer_ptr->candidate_ptr->filter_intra_mode,
4599 : #else
4600 : FILTER_INTRA_MODES, //CHKN FilterIntraMode filter_intra_mode,
4601 : #endif
4602 : topNeighArray + 1,
4603 : leftNeighArray + 1,
4604 : candidate_buffer_ptr->prediction_ptr, //uint8_t *dst,
4605 : 0, //int32_t col_off,
4606 : 0, //int32_t row_off,
4607 : plane, //int32_t plane,
4608 0 : md_context_ptr->blk_geom->bsize, //uint32_t puSize,
4609 0 : md_context_ptr->cu_origin_x,
4610 0 : md_context_ptr->cu_origin_y,
4611 0 : md_context_ptr->cu_origin_x, //uint32_t cuOrgX,
4612 0 : md_context_ptr->cu_origin_y, //uint32_t cuOrgY
4613 0 : plane ? ((md_context_ptr->blk_geom->origin_x >> 3) << 3) / 2 : md_context_ptr->blk_geom->origin_x, //uint32_t cuOrgX used only for prediction Ptr
4614 0 : plane ? ((md_context_ptr->blk_geom->origin_y >> 3) << 3) / 2 : md_context_ptr->blk_geom->origin_y //uint32_t cuOrgY used only for prediction Ptr
4615 : );
4616 : }
4617 : }
4618 :
4619 12939800 : return return_error;
4620 : }
4621 :
4622 : #if II_COMP_FLAG
4623 1183710 : EbErrorType intra_luma_prediction_for_interintra(
4624 : ModeDecisionContext *md_context_ptr,
4625 : PictureControlSet *picture_control_set_ptr,
4626 : INTERINTRA_MODE interintra_mode,
4627 : EbPictureBufferDesc *prediction_ptr)
4628 : {
4629 1183710 : EbErrorType return_error = EB_ErrorNone;
4630 :
4631 1183710 : uint32_t mode_type_left_neighbor_index = get_neighbor_array_unit_left_index(
4632 : md_context_ptr->mode_type_neighbor_array,
4633 1183710 : md_context_ptr->cu_origin_y);
4634 1183700 : uint32_t mode_type_top_neighbor_index = get_neighbor_array_unit_top_index(
4635 : md_context_ptr->mode_type_neighbor_array,
4636 1183700 : md_context_ptr->cu_origin_x);
4637 1183700 : uint32_t intra_luma_mode_left_neighbor_index = get_neighbor_array_unit_left_index(
4638 : md_context_ptr->intra_luma_mode_neighbor_array,
4639 1183700 : md_context_ptr->cu_origin_y);
4640 1183700 : uint32_t intra_luma_mode_top_neighbor_index = get_neighbor_array_unit_top_index(
4641 : md_context_ptr->intra_luma_mode_neighbor_array,
4642 1183700 : md_context_ptr->cu_origin_x);
4643 :
4644 1173210 : md_context_ptr->intra_luma_left_mode = (uint32_t)(
4645 1183690 : (md_context_ptr->mode_type_neighbor_array->left_array[mode_type_left_neighbor_index] != INTRA_MODE) ? DC_PRED:
4646 10476 : (uint32_t)md_context_ptr->intra_luma_mode_neighbor_array->left_array[intra_luma_mode_left_neighbor_index]);
4647 :
4648 1172990 : md_context_ptr->intra_luma_top_mode = (uint32_t)(
4649 1183690 : (md_context_ptr->mode_type_neighbor_array->top_array[mode_type_top_neighbor_index] != INTRA_MODE) ? DC_PRED:
4650 10696 : (uint32_t)md_context_ptr->intra_luma_mode_neighbor_array->top_array[intra_luma_mode_top_neighbor_index]); // use DC. This seems like we could use a LCU-width
4651 :
4652 1183690 : TxSize tx_size = md_context_ptr->blk_geom->txsize[0][0]; //CHKN TOcheck
4653 1183690 : PredictionMode mode = interintra_to_intra_mode[interintra_mode];
4654 :
4655 1183690 : if (!md_context_ptr->hbd_mode_decision) {
4656 : uint8_t top_neigh_array[64 * 2 + 1];
4657 : uint8_t left_neigh_array[64 * 2 + 1];
4658 :
4659 1183690 : if (md_context_ptr->cu_origin_y != 0)
4660 1129610 : memcpy(top_neigh_array + 1, md_context_ptr->luma_recon_neighbor_array->top_array + md_context_ptr->cu_origin_x, md_context_ptr->blk_geom->bwidth * 2);
4661 1183690 : if (md_context_ptr->cu_origin_x != 0)
4662 1136170 : memcpy(left_neigh_array + 1, md_context_ptr->luma_recon_neighbor_array->left_array + md_context_ptr->cu_origin_y, md_context_ptr->blk_geom->bheight * 2);
4663 1183690 : if (md_context_ptr->cu_origin_y != 0 && md_context_ptr->cu_origin_x != 0)
4664 1083720 : top_neigh_array[0] = left_neigh_array[0] = md_context_ptr->luma_recon_neighbor_array->top_left_array[MAX_PICTURE_HEIGHT_SIZE + md_context_ptr->cu_origin_x - md_context_ptr->cu_origin_y];
4665 :
4666 1183690 : eb_av1_predict_intra_block(
4667 1183690 : &md_context_ptr->sb_ptr->tile_info,
4668 : !ED_STAGE,
4669 : md_context_ptr->blk_geom,
4670 1183690 : picture_control_set_ptr->parent_pcs_ptr->av1_cm, //const Av1Common *cm,
4671 1183690 : md_context_ptr->blk_geom->bwidth, //int32_t wpx,
4672 1183690 : md_context_ptr->blk_geom->bheight, //int32_t hpx,
4673 : tx_size, //TxSize tx_size,
4674 : mode, //PredictionMode mode,
4675 : 0, //candidate_buffer_ptr->candidate_ptr->angle_delta[PLANE_TYPE_Y],
4676 : 0, //int32_t use_palette,
4677 : #if PAL_SUP
4678 : NULL, //Inter-Intra
4679 : #endif
4680 : FILTER_INTRA_MODES, //CHKN FilterIntraMode filter_intra_mode,
4681 : top_neigh_array + 1,
4682 : left_neigh_array + 1,
4683 : prediction_ptr, //uint8_t *dst,
4684 1183690 : md_context_ptr->blk_geom->tx_boff_x[0][0] >> 2, //int32_t col_off,
4685 1183690 : md_context_ptr->blk_geom->tx_boff_y[0][0] >> 2, //int32_t row_off,
4686 : PLANE_TYPE_Y, //int32_t plane,
4687 1183690 : md_context_ptr->blk_geom->bsize, //uint32_t puSize,
4688 1183690 : md_context_ptr->cu_origin_x,
4689 1183690 : md_context_ptr->cu_origin_y,
4690 1183690 : md_context_ptr->cu_origin_x, //uint32_t cuOrgX,
4691 1183690 : md_context_ptr->cu_origin_y, //uint32_t cuOrgY
4692 : 0, //cuOrgX used only for prediction Ptr
4693 : 0 //cuOrgY used only for prediction Ptr
4694 : );
4695 : } else {
4696 : uint16_t top_neigh_array[64 * 2 + 1];
4697 : uint16_t left_neigh_array[64 * 2 + 1];
4698 :
4699 0 : if (md_context_ptr->cu_origin_y != 0)
4700 0 : memcpy(top_neigh_array + 1, (uint16_t*)(md_context_ptr->luma_recon_neighbor_array16bit->top_array) + md_context_ptr->cu_origin_x, md_context_ptr->blk_geom->bwidth * 2 * sizeof(uint16_t));
4701 0 : if (md_context_ptr->cu_origin_x != 0)
4702 0 : memcpy(left_neigh_array + 1, (uint16_t*)(md_context_ptr->luma_recon_neighbor_array16bit->left_array) + md_context_ptr->cu_origin_y, md_context_ptr->blk_geom->bheight * 2 * sizeof(uint16_t));
4703 0 : if (md_context_ptr->cu_origin_y != 0 && md_context_ptr->cu_origin_x != 0)
4704 0 : top_neigh_array[0] = left_neigh_array[0] = ((uint16_t*)(md_context_ptr->luma_recon_neighbor_array16bit->top_left_array) + MAX_PICTURE_HEIGHT_SIZE + md_context_ptr->cu_origin_x - md_context_ptr->cu_origin_y)[0];
4705 :
4706 0 : eb_av1_predict_intra_block_16bit(
4707 0 : &md_context_ptr->sb_ptr->tile_info,
4708 : !ED_STAGE,
4709 : md_context_ptr->blk_geom,
4710 0 : picture_control_set_ptr->parent_pcs_ptr->av1_cm, //const Av1Common *cm,
4711 0 : md_context_ptr->blk_geom->bwidth, //int32_t wpx,
4712 0 : md_context_ptr->blk_geom->bheight, //int32_t hpx,
4713 : tx_size, //TxSize tx_size,
4714 : mode, //PredictionMode mode,
4715 : 0, //candidate_buffer_ptr->candidate_ptr->angle_delta[PLANE_TYPE_Y],
4716 : 0, //int32_t use_palette,
4717 : #if PAL_SUP
4718 : NULL, //Inter-Intra
4719 : #endif
4720 : FILTER_INTRA_MODES, //CHKN FilterIntraMode filter_intra_mode,
4721 : top_neigh_array + 1,
4722 : left_neigh_array + 1,
4723 : prediction_ptr, //uint8_t *dst,
4724 0 : md_context_ptr->blk_geom->tx_boff_x[0][0] >> 2, //int32_t col_off,
4725 0 : md_context_ptr->blk_geom->tx_boff_y[0][0] >> 2, //int32_t row_off,
4726 : PLANE_TYPE_Y, //int32_t plane,
4727 0 : md_context_ptr->blk_geom->bsize, //uint32_t puSize,
4728 0 : md_context_ptr->cu_origin_x,
4729 0 : md_context_ptr->cu_origin_y,
4730 0 : md_context_ptr->cu_origin_x, //uint32_t cuOrgX,
4731 0 : md_context_ptr->cu_origin_y, //uint32_t cuOrgY
4732 : 0, //cuOrgX used only for prediction Ptr
4733 : 0 //cuOrgY used only for prediction Ptr
4734 : );
4735 : }
4736 :
4737 1183710 : return return_error;
4738 : }
4739 : #endif
4740 :
4741 0 : EbErrorType update_neighbor_samples_array_open_loop(
4742 : uint8_t *above_ref,
4743 : uint8_t *left_ref,
4744 : EbPictureBufferDesc *input_ptr,
4745 : uint32_t stride,
4746 : uint32_t src_origin_x,
4747 : uint32_t src_origin_y,
4748 : uint8_t bwidth,
4749 : uint8_t bheight)
4750 : {
4751 0 : EbErrorType return_error = EB_ErrorNone;
4752 :
4753 : uint32_t idx;
4754 : uint8_t *src_ptr;
4755 : uint8_t *read_ptr;
4756 : uint32_t count;
4757 :
4758 0 : uint32_t width = input_ptr->width;
4759 0 : uint32_t height = input_ptr->height;
4760 0 : uint32_t block_size_half = bwidth << 1;
4761 :
4762 : // Adjust the Source ptr to start at the origin of the block being updated
4763 0 : src_ptr = input_ptr->buffer_y + (((src_origin_y + input_ptr->origin_y) * stride) + (src_origin_x + input_ptr->origin_x));
4764 :
4765 : //Initialise the Luma Intra Reference Array to the mid range value 128 (for CUs at the picture boundaries)
4766 0 : EB_MEMSET(above_ref, 127, (bwidth << 1) + 1);
4767 0 : EB_MEMSET(left_ref, 129, (bheight << 1) + 1);
4768 :
4769 : // Get the upper left sample
4770 0 : if (src_origin_x != 0 && src_origin_y != 0) {
4771 0 : read_ptr = src_ptr - stride - 1;
4772 0 : *above_ref = *read_ptr;
4773 0 : *left_ref = *read_ptr;
4774 0 : left_ref++;
4775 0 : above_ref++;
4776 : }else {
4777 0 : *above_ref = *left_ref = 128;
4778 0 : left_ref++;
4779 0 : above_ref++;
4780 : }
4781 : // Get the left-column
4782 0 : count = block_size_half;
4783 0 : if (src_origin_x != 0) {
4784 0 : read_ptr = src_ptr - 1;
4785 0 : count = ((src_origin_y + count) > height) ? count - ((src_origin_y + count) - height) : count;
4786 0 : for (idx = 0; idx < count; ++idx) {
4787 0 : *left_ref = *read_ptr;
4788 0 : read_ptr += stride;
4789 0 : left_ref++;
4790 : }
4791 0 : left_ref += (block_size_half - count);
4792 : }else
4793 0 : left_ref += count;
4794 :
4795 : // Get the top-row
4796 0 : count = block_size_half;
4797 0 : if (src_origin_y != 0) {
4798 0 : read_ptr = src_ptr - stride;
4799 0 : count = ((src_origin_x + count) > width) ? count - ((src_origin_x + count) - width) : count;
4800 0 : EB_MEMCPY(above_ref, read_ptr, count);
4801 0 : above_ref += (block_size_half - count);
4802 : }else
4803 0 : above_ref += count;
4804 :
4805 0 : return return_error;
4806 : }
4807 : /** intra_prediction_open_loop()
4808 : performs Open-loop Intra candidate Search for a CU
4809 : */
4810 0 : EbErrorType intra_prediction_open_loop(
4811 : int32_t p_angle ,
4812 : uint8_t ois_intra_mode,
4813 : uint32_t src_origin_x,
4814 : uint32_t src_origin_y,
4815 : TxSize tx_size,
4816 : uint8_t *above_row,
4817 : uint8_t *left_col,
4818 : MotionEstimationContext_t *context_ptr) // input parameter, ME context
4819 :
4820 : {
4821 0 : EbErrorType return_error = EB_ErrorNone;
4822 0 : PredictionMode mode = ois_intra_mode;
4823 0 : const int32_t is_dr_mode = av1_is_directional_mode(mode);
4824 0 : uint8_t *dst = (&(context_ptr->me_context_ptr->sb_buffer[0]));
4825 0 : uint32_t dst_stride = context_ptr->me_context_ptr->sb_buffer_stride;
4826 :
4827 0 : if (is_dr_mode)
4828 0 : dr_predictor(dst, dst_stride, tx_size, above_row, left_col, 0, 0, p_angle);
4829 : else {
4830 : // predict
4831 0 : if (mode == DC_PRED) {
4832 0 : dc_pred[src_origin_x > 0][src_origin_y > 0][tx_size](dst, dst_stride, above_row, left_col);
4833 : } else
4834 0 : pred[mode][tx_size](dst, dst_stride, above_row, left_col);
4835 : }
4836 0 : return return_error;
4837 : }
|