1 // clang-format off
2 /*
3 * Copyright(c) 2019 Intel Corporation
4 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
5 *
6 * This source code is subject to the terms of the BSD 2 Clause License and
7 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
8 * was not distributed with this source code in the LICENSE file, you can
9 * obtain it at https://www.aomedia.org/license/software-license. If the Alliance for Open
10 * Media Patent License 1.0 was not distributed with this source code in the
11 * PATENTS file, you can obtain it at https://www.aomedia.org/license/patent-license.
12 */
13 
14 #include <stdlib.h>
15 #include <string.h>
16 
17 
18 #include "EbIntraPrediction.h"
19 #include "EbModeDecisionProcess.h"
20 #include "common_dsp_rtcd.h"
21 
22 int32_t is_inter_block(const BlockModeInfo *mbmi);
23 // Weights are quadratic from '1' to '1 / BlockSize', scaled by
24 // 2^sm_weight_log2_scale.
25 static const int32_t sm_weight_log2_scale = 8;
26 // max(block_size_wide[BLOCK_LARGEST], block_size_high[BLOCK_LARGEST])
27 #define MAX_BLOCK_DIM 64
28 static const uint8_t sm_weight_arrays[2 * MAX_BLOCK_DIM] = {
29     // Unused, because we always offset by bs, which is at least 2.
30     0, 0,
31     // bs = 2
32     255, 128,
33     // bs = 4
34     255, 149, 85, 64,
35     // bs = 8
36     255, 197, 146, 105, 73, 50, 37, 32,
37     // bs = 16
38     255, 225, 196, 170, 145, 123, 102, 84, 68, 54, 43, 33, 26, 20, 17, 16,
39     // bs = 32
40     255, 240, 225, 210, 196, 182, 169, 157, 145, 133, 122, 111, 101, 92, 83, 74,
41     66, 59, 52, 45, 39, 34, 29, 25, 21, 17, 14, 12, 10, 9, 8, 8,
42     // bs = 64
43     255, 248, 240, 233, 225, 218, 210, 203, 196, 189, 182, 176, 169, 163, 156,
44     150, 144, 138, 133, 127, 121, 116, 111, 106, 101, 96, 91, 86, 82, 77, 73, 69,
45     65, 61, 57, 54, 50, 47, 44, 41, 38, 35, 32, 29, 27, 25, 22, 20, 18, 16, 15,
46     13, 12, 10, 9, 8, 7, 6, 6, 5, 5, 4, 4, 4,
47 };
48 // Some basic checks on weights for smooth predictor.
49 #define sm_weights_sanity_checks(weights_w, weights_h, weights_scale, pred_scale) \
50     do {                                                                          \
51         assert(weights_w[0] < weights_scale);                                     \
52         assert(weights_h[0] < weights_scale);                                     \
53         assert(weights_scale - weights_w[bw - 1] < weights_scale);                \
54         assert(weights_scale - weights_h[bh - 1] < weights_scale);                \
55         assert(pred_scale < 31);                                                  \
56     } while (0) // ensures no overflow when calculating predictor.
57 #define MIDRANGE_VALUE_8BIT    128
58 #define MIDRANGE_VALUE_10BIT   512
59 
is_smooth(const BlockModeInfo * block_mi,int plane)60 int is_smooth(const BlockModeInfo *block_mi, int plane)
61 {
62     if (plane == 0) {
63         const PredictionMode mode = block_mi->mode;
64         return (mode == SMOOTH_PRED || mode == SMOOTH_V_PRED ||
65             mode == SMOOTH_H_PRED);
66     }
67     else {
68         // uv_mode is not set for inter blocks, so need to explicitly
69         // detect that case.
70         if (is_inter_block(block_mi)) return 0;
71 
72         const UvPredictionMode uv_mode = block_mi->uv_mode;
73         return (uv_mode == UV_SMOOTH_PRED || uv_mode == UV_SMOOTH_V_PRED ||
74             uv_mode == UV_SMOOTH_H_PRED);
75     }
76 }
77 
use_intra_edge_upsample(int32_t bs0,int32_t bs1,int32_t delta,int32_t type)78 int32_t use_intra_edge_upsample(int32_t bs0, int32_t bs1, int32_t delta, int32_t type)
79 {
80     const int32_t d = abs(delta);
81     const int32_t blk_wh = bs0 + bs1;
82     if (d <= 0 || d >= 40) return 0;
83     return type ? (blk_wh <= 8) : (blk_wh <= 16);
84 }
85 
86 #define INTRA_EDGE_FILT 3
87 #define INTRA_EDGE_TAPS 5
svt_av1_filter_intra_edge_c(uint8_t * p,int32_t sz,int32_t strength)88 void svt_av1_filter_intra_edge_c(uint8_t *p, int32_t sz, int32_t strength)
89 {
90     if (!strength) return;
91 
92     const int32_t kernel[INTRA_EDGE_FILT][INTRA_EDGE_TAPS] = {
93       { 0, 4, 8, 4, 0 }, { 0, 5, 6, 5, 0 }, { 2, 4, 4, 4, 2 }
94     };
95     const int32_t filt = strength - 1;
96     uint8_t edge[129];
97 
98     svt_memcpy(edge, p, sz * sizeof(*p));
99     for (int32_t i = 1; i < sz; i++) {
100         int32_t s = 0;
101         for (int32_t j = 0; j < INTRA_EDGE_TAPS; j++) {
102             int32_t k = i - 2 + j;
103             k = (k < 0) ? 0 : k;
104             k = (k > sz - 1) ? sz - 1 : k;
105             s += edge[k] * kernel[filt][j];
106         }
107         s = (s + 8) >> 4;
108         p[i] = (uint8_t)s;
109     }
110 }
111 
intra_edge_filter_strength(int32_t bs0,int32_t bs1,int32_t delta,int32_t type)112 int32_t intra_edge_filter_strength(int32_t bs0, int32_t bs1, int32_t delta, int32_t type)
113 {
114     const int32_t d = abs(delta);
115     int32_t strength = 0;
116 
117     const int32_t blk_wh = bs0 + bs1;
118     if (type == 0) {
119         if (blk_wh <= 8) {
120             if (d >= 56)
121                 strength = 1;
122         }
123         else if (blk_wh <= 12) {
124             if (d >= 40)
125                 strength = 1;
126         }
127         else if (blk_wh <= 16) {
128             if (d >= 40)
129                 strength = 1;
130         }
131         else if (blk_wh <= 24) {
132             if (d >= 8)
133                 strength = 1;
134             if (d >= 16)
135                 strength = 2;
136             if (d >= 32)
137                 strength = 3;
138         }
139         else if (blk_wh <= 32) {
140             if (d >= 1)
141                 strength = 1;
142             if (d >= 4)
143                 strength = 2;
144             if (d >= 32)
145                 strength = 3;
146         }
147         else {
148             if (d >= 1)
149                 strength = 3;
150         }
151     }
152     else {
153         if (blk_wh <= 8) {
154             if (d >= 40)
155                 strength = 1;
156             if (d >= 64)
157                 strength = 2;
158         }
159         else if (blk_wh <= 16) {
160             if (d >= 20)
161                 strength = 1;
162             if (d >= 48)
163                 strength = 2;
164         }
165         else if (blk_wh <= 24) {
166             if (d >= 4)
167                 strength = 3;
168         }
169         else {
170             if (d >= 1)
171                 strength = 3;
172         }
173     }
174     return strength;
175 }
176 
177 const uint16_t eb_dr_intra_derivative[90] = {
178     // More evenly spread out angles and limited to 10-bit
179     // Values that are 0 will never be used
180     //                    Approx angle
181     0,    0, 0,        //
182     1023, 0, 0,        // 3, ...
183     547,  0, 0,        // 6, ...
184     372,  0, 0, 0, 0,  // 9, ...
185     273,  0, 0,        // 14, ...
186     215,  0, 0,        // 17, ...
187     178,  0, 0,        // 20, ...
188     151,  0, 0,        // 23, ... (113 & 203 are base angles)
189     132,  0, 0,        // 26, ...
190     116,  0, 0,        // 29, ...
191     102,  0, 0, 0,     // 32, ...
192     90,   0, 0,        // 36, ...
193     80,   0, 0,        // 39, ...
194     71,   0, 0,        // 42, ...
195     64,   0, 0,        // 45, ... (45 & 135 are base angles)
196     57,   0, 0,        // 48, ...
197     51,   0, 0,        // 51, ...
198     45,   0, 0, 0,     // 54, ...
199     40,   0, 0,        // 58, ...
200     35,   0, 0,        // 61, ...
201     31,   0, 0,        // 64, ...
202     27,   0, 0,        // 67, ... (67 & 157 are base angles)
203     23,   0, 0,        // 70, ...
204     19,   0, 0,        // 73, ...
205     15,   0, 0, 0, 0,  // 76, ...
206     11,   0, 0,        // 81, ...
207     7,    0, 0,        // 84, ...
208     3,    0, 0,        // 87, ...
209 };
210 
211 // Get the shift (up-scaled by 256) in Y w.r.t a unit change in X.
212 // If angle > 0 && angle < 90, dy = 1;
213 // If angle > 90 && angle < 180, dy = (int32_t)(256 * t);
214 // If angle > 180 && angle < 270, dy = -((int32_t)(256 * t));
215 
216 #define divide_round(value, bits) (((value) + (1 << ((bits)-1))) >> (bits))
217 
get_dy(int32_t angle)218 static INLINE uint16_t get_dy(int32_t angle)
219 {
220     if (angle > 90 && angle < 180)
221         return eb_dr_intra_derivative[angle - 90];
222     else if (angle > 180 && angle < 270)
223         return eb_dr_intra_derivative[270 - angle];
224     else {
225         // In this case, we are not really going to use dy. We may return any value.
226         return 1;
227     }
228 }
229 // Get the shift (up-scaled by 256) in X w.r.t a unit change in Y.
230 // If angle > 0 && angle < 90, dx = -((int32_t)(256 / t));
231 // If angle > 90 && angle < 180, dx = (int32_t)(256 / t);
232 // If angle > 180 && angle < 270, dx = 1;
get_dx(int32_t angle)233 static INLINE uint16_t get_dx(int32_t angle)
234 {
235     if (angle > 0 && angle < 90)
236         return eb_dr_intra_derivative[angle];
237     else if (angle > 90 && angle < 180)
238         return eb_dr_intra_derivative[180 - angle];
239     else {
240         // In this case, we are not really going to use dx. We may return any value.
241         return 1;
242     }
243 }
244 
245 // Directional prediction, zone 3: 180 < angle < 270
svt_av1_dr_prediction_z3_c(uint8_t * dst,ptrdiff_t stride,int32_t bw,int32_t bh,const uint8_t * above,const uint8_t * left,int32_t upsample_left,int32_t dx,int32_t dy)246 void svt_av1_dr_prediction_z3_c(uint8_t *dst, ptrdiff_t stride, int32_t bw, int32_t bh,
247     const uint8_t *above, const uint8_t *left,
248     int32_t upsample_left, int32_t dx, int32_t dy)
249 {
250     (void)above;
251     (void)dx;
252 
253     assert(dx == 1);
254     assert(dy > 0);
255 
256     const int32_t max_base_y = (bw + bh - 1) << upsample_left;
257     const int32_t frac_bits = 6 - upsample_left;
258     const int32_t base_inc = 1 << upsample_left;
259     for (int32_t c = 0, y = dy; c < bw; ++c, y += dy) {
260         int32_t base = y >> frac_bits, shift = ((y << upsample_left) & 0x3F) >> 1;
261 
262         for (int32_t r = 0; r < bh; ++r, base += base_inc) {
263             if (base < max_base_y) {
264                 int32_t val;
265                 val = left[base] * (32 - shift) + left[base + 1] * shift;
266                 val = ROUND_POWER_OF_TWO(val, 5);
267                 dst[r * stride + c] = (uint8_t)clip_pixel_highbd(val, 8);
268             }
269             else {
270                 for (; r < bh; ++r) dst[r * stride + c] = left[max_base_y];
271                 break;
272             }
273         }
274     }
275 }
svt_av1_dr_prediction_z1_c(uint8_t * dst,ptrdiff_t stride,int32_t bw,int32_t bh,const uint8_t * above,const uint8_t * left,int32_t upsample_above,int32_t dx,int32_t dy)276 void svt_av1_dr_prediction_z1_c(uint8_t *dst, ptrdiff_t stride, int32_t bw, int32_t bh,
277     const uint8_t *above, const uint8_t *left,
278     int32_t upsample_above, int32_t dx, int32_t dy)
279 {
280     (void)left;
281     (void)dy;
282     assert(dy == 1);
283     assert(dx > 0);
284 
285     const int32_t max_base_x = ((bw + bh) - 1) << upsample_above;
286     const int32_t frac_bits = 6 - upsample_above;
287     const int32_t base_inc = 1 << upsample_above;
288     for (int32_t r = 0, x = dx; r < bh; ++r, dst += stride, x += dx) {
289         int32_t base = x >> frac_bits, shift = ((x << upsample_above) & 0x3F) >> 1;
290 
291         if (base >= max_base_x) {
292             for (int32_t i = r; i < bh; ++i) {
293                 memset(dst, above[max_base_x], bw * sizeof(dst[0]));
294                 dst += stride;
295             }
296             return;
297         }
298 
299         for (int32_t c = 0; c < bw; ++c, base += base_inc) {
300             if (base < max_base_x) {
301                 int32_t val;
302                 val = above[base] * (32 - shift) + above[base + 1] * shift;
303                 val = ROUND_POWER_OF_TWO(val, 5);
304                 dst[c] = (uint8_t)clip_pixel_highbd(val, 8);
305             }
306             else
307                 dst[c] = above[max_base_x];
308         }
309     }
310 }
311 
312 // Directional prediction, zone 2: 90 < angle < 180
svt_av1_dr_prediction_z2_c(uint8_t * dst,ptrdiff_t stride,int32_t bw,int32_t bh,const uint8_t * above,const uint8_t * left,int32_t upsample_above,int32_t upsample_left,int32_t dx,int32_t dy)313 void svt_av1_dr_prediction_z2_c(uint8_t *dst, ptrdiff_t stride, int32_t bw, int32_t bh,
314     const uint8_t *above, const uint8_t *left,
315     int32_t upsample_above, int32_t upsample_left, int32_t dx,
316     int32_t dy)
317 {
318     assert(dx > 0);
319     assert(dy > 0);
320 
321     const int32_t min_base_x = -(1 << upsample_above);
322     const int32_t frac_bits_x = 6 - upsample_above;
323     const int32_t frac_bits_y = 6 - upsample_left;
324     const int32_t base_inc_x = 1 << upsample_above;
325     for (int32_t r = 0, x = -dx; r < bh; ++r, x -= dx, dst += stride) {
326         int32_t val;
327         int32_t base1 = x >> frac_bits_x;
328         int32_t y = (r << 6) - dy;
329         for (int32_t c = 0; c < bw; ++c, base1 += base_inc_x, y -= dy) {
330             if (base1 >= min_base_x) {
331                 int32_t shift1 = ((x * (1 << upsample_above)) & 0x3F) >> 1;
332                 val = above[base1] * (32 - shift1) + above[base1 + 1] * shift1;
333                 val = ROUND_POWER_OF_TWO(val, 5);
334             }
335             else {
336                 int32_t base2 = y >> frac_bits_y;
337                 assert(base2 >= -(1 << upsample_left));
338                 int32_t shift2 = ((y * (1 << upsample_left)) & 0x3F) >> 1;
339                 val = left[base2] * (32 - shift2) + left[base2 + 1] * shift2;
340                 val = ROUND_POWER_OF_TWO(val, 5);
341             }
342             dst[c] = (uint8_t)clip_pixel_highbd(val, 8);
343         }
344     }
345 }
346 
347 /* clang-format on */
348 
svt_cfl_luma_subsampling_420_lbd_c(const uint8_t * input,int32_t input_stride,int16_t * output_q3,int32_t width,int32_t height)349 void svt_cfl_luma_subsampling_420_lbd_c(
350     const uint8_t *input,
351     int32_t input_stride, int16_t *output_q3,
352     int32_t width, int32_t height)
353 {
354     for (int32_t j = 0; j < height; j += 2) {
355         for (int32_t i = 0; i < width; i += 2) {
356             const int32_t bot = i + input_stride;
357             output_q3[i >> 1] =
358                 (input[i] + input[i + 1] + input[bot] + input[bot + 1]) << 1;
359         }
360         input += input_stride << 1;
361         output_q3 += CFL_BUF_LINE;
362     }
363 }
svt_cfl_luma_subsampling_420_hbd_c(const uint16_t * input,int32_t input_stride,int16_t * output_q3,int32_t width,int32_t height)364 void svt_cfl_luma_subsampling_420_hbd_c(
365     const uint16_t *input,
366     int32_t input_stride, int16_t *output_q3,
367     int32_t width, int32_t height)
368 {
369     for (int32_t j = 0; j < height; j += 2, input += input_stride << 1, output_q3 += CFL_BUF_LINE) {
370         for (int32_t i = 0; i < width; i += 2) {
371             const int32_t bot = i + input_stride;
372             output_q3[i >> 1] =
373                 (input[i] + input[i + 1] + input[bot] + input[bot + 1]) << 1;
374         }
375     }
376 }
svt_subtract_average_c(int16_t * pred_buf_q3,int32_t width,int32_t height,int32_t round_offset,int32_t num_pel_log2)377 void svt_subtract_average_c(
378     int16_t *pred_buf_q3,
379     int32_t width,
380     int32_t height,
381     int32_t round_offset,
382     int32_t num_pel_log2) {
383     int32_t sum_q3 = 0;
384     int16_t *pred_buf = pred_buf_q3;
385     for (int32_t j = 0; j < height; j++) {
386         // assert(pred_buf_q3 + tx_width <= cfl->pred_buf_q3 + CFL_BUF_SQUARE);
387         for (int32_t i = 0; i < width; i++)
388             sum_q3 += pred_buf[i];
389         pred_buf += CFL_BUF_LINE;
390     }
391     const int32_t avg_q3 = (sum_q3 + round_offset) >> num_pel_log2;
392     // Loss is never more than 1/2 (in Q3)
393     // assert(abs((avg_q3 * (1 << num_pel_log2)) - sum_q3) <= 1 << num_pel_log2 >>
394     //       1);
395     for (int32_t j = 0; j < height; j++) {
396         for (int32_t i = 0; i < width; i++)
397             pred_buf_q3[i] -= (int16_t)(avg_q3);
398         pred_buf_q3 += CFL_BUF_LINE;
399     }
400 }
401 
402 CFL_SUB_AVG_FN(c)
403 
404 
405 
406 const uint8_t extend_modes[INTRA_MODES] = {
407     NEED_ABOVE | NEED_LEFT,                   // DC
408     NEED_ABOVE,                               // V
409     NEED_LEFT,                                // H
410     NEED_ABOVE | NEED_ABOVERIGHT,             // D45
411     NEED_LEFT | NEED_ABOVE | NEED_ABOVELEFT,  // D135
412     NEED_LEFT | NEED_ABOVE | NEED_ABOVELEFT,  // D113
413     NEED_LEFT | NEED_ABOVE | NEED_ABOVELEFT,  // D157
414     NEED_LEFT | NEED_BOTTOMLEFT,              // D203
415     NEED_ABOVE | NEED_ABOVERIGHT,             // D67
416     NEED_LEFT | NEED_ABOVE,                   // SMOOTH
417     NEED_LEFT | NEED_ABOVE,                   // SMOOTH_V
418     NEED_LEFT | NEED_ABOVE,                   // SMOOTH_H
419     NEED_LEFT | NEED_ABOVE | NEED_ABOVELEFT,  // PAETH
420 };
421 
422 // Tables to store if the top-right reference pixels are available. The flags
423 // are represented with bits, packed into 8-bit integers. E.g., for the 32x32
424 // blocks in a 128x128 superblock, the index of the "o" block is 10 (in raster
425 // order), so its flag is stored at the 3rd bit of the 2nd entry in the table,
426 // i.e. (table[10 / 8] >> (10 % 8)) & 1.
427 //       . . . .
428 //       . . . .
429 //       . . o .
430 //       . . . .
431 static uint8_t has_tr_4x4[128] = {
432     255, 255, 255, 255, 85, 85, 85, 85, 119, 119, 119, 119, 85, 85, 85, 85,
433     127, 127, 127, 127, 85, 85, 85, 85, 119, 119, 119, 119, 85, 85, 85, 85,
434     255, 127, 255, 127, 85, 85, 85, 85, 119, 119, 119, 119, 85, 85, 85, 85,
435     127, 127, 127, 127, 85, 85, 85, 85, 119, 119, 119, 119, 85, 85, 85, 85,
436     255, 255, 255, 127, 85, 85, 85, 85, 119, 119, 119, 119, 85, 85, 85, 85,
437     127, 127, 127, 127, 85, 85, 85, 85, 119, 119, 119, 119, 85, 85, 85, 85,
438     255, 127, 255, 127, 85, 85, 85, 85, 119, 119, 119, 119, 85, 85, 85, 85,
439     127, 127, 127, 127, 85, 85, 85, 85, 119, 119, 119, 119, 85, 85, 85, 85,
440 };
441 static uint8_t has_tr_4x8[64] = {
442     255, 255, 255, 255, 119, 119, 119, 119, 127, 127, 127, 127, 119,
443     119, 119, 119, 255, 127, 255, 127, 119, 119, 119, 119, 127, 127,
444     127, 127, 119, 119, 119, 119, 255, 255, 255, 127, 119, 119, 119,
445     119, 127, 127, 127, 127, 119, 119, 119, 119, 255, 127, 255, 127,
446     119, 119, 119, 119, 127, 127, 127, 127, 119, 119, 119, 119,
447 };
448 static uint8_t has_tr_8x4[64] = {
449     255, 255, 0, 0, 85, 85, 0, 0, 119, 119, 0, 0, 85, 85, 0, 0,
450     127, 127, 0, 0, 85, 85, 0, 0, 119, 119, 0, 0, 85, 85, 0, 0,
451     255, 127, 0, 0, 85, 85, 0, 0, 119, 119, 0, 0, 85, 85, 0, 0,
452     127, 127, 0, 0, 85, 85, 0, 0, 119, 119, 0, 0, 85, 85, 0, 0,
453 };
454 static uint8_t has_tr_8x8[32] = {
455     255, 255, 85, 85, 119, 119, 85, 85, 127, 127, 85, 85, 119, 119, 85, 85,
456     255, 127, 85, 85, 119, 119, 85, 85, 127, 127, 85, 85, 119, 119, 85, 85,
457 };
458 static uint8_t has_tr_8x16[16] = {
459     255, 255, 119, 119, 127, 127, 119, 119,
460     255, 127, 119, 119, 127, 127, 119, 119,
461 };
462 static uint8_t has_tr_16x8[16] = {
463     255, 0, 85, 0, 119, 0, 85, 0, 127, 0, 85, 0, 119, 0, 85, 0,
464 };
465 static uint8_t has_tr_16x16[8] = {
466     255, 85, 119, 85, 127, 85, 119, 85,
467 };
468 static uint8_t has_tr_16x32[4] = { 255, 119, 127, 119 };
469 static uint8_t has_tr_32x16[4] = { 15, 5, 7, 5 };
470 static uint8_t has_tr_32x32[2] = { 95, 87 };
471 static uint8_t has_tr_32x64[1] = { 127 };
472 static uint8_t has_tr_64x32[1] = { 19 };
473 static uint8_t has_tr_64x64[1] = { 7 };
474 static uint8_t has_tr_64x128[1] = { 3 };
475 static uint8_t has_tr_128x64[1] = { 1 };
476 static uint8_t has_tr_128x128[1] = { 1 };
477 static uint8_t has_tr_4x16[32] = {
478     255, 255, 255, 255, 127, 127, 127, 127, 255, 127, 255,
479     127, 127, 127, 127, 127, 255, 255, 255, 127, 127, 127,
480     127, 127, 255, 127, 255, 127, 127, 127, 127, 127,
481 };
482 static uint8_t has_tr_16x4[32] = {
483     255, 0, 0, 0, 85, 0, 0, 0, 119, 0, 0, 0, 85, 0, 0, 0,
484     127, 0, 0, 0, 85, 0, 0, 0, 119, 0, 0, 0, 85, 0, 0, 0,
485 };
486 static uint8_t has_tr_8x32[8] = {
487     255, 255, 127, 127, 255, 127, 127, 127,
488 };
489 static uint8_t has_tr_32x8[8] = {
490     15, 0, 5, 0, 7, 0, 5, 0,
491 };
492 static uint8_t has_tr_16x64[2] = { 255, 127 };
493 static uint8_t has_tr_64x16[2] = { 3, 1 };
494 
495 const uint8_t *const has_tr_tables[BlockSizeS_ALL] = {
496     // 4X4
497     has_tr_4x4,
498     // 4X8,       8X4,            8X8
499     has_tr_4x8, has_tr_8x4, has_tr_8x8,
500     // 8X16,      16X8,           16X16
501     has_tr_8x16, has_tr_16x8, has_tr_16x16,
502     // 16X32,     32X16,          32X32
503     has_tr_16x32, has_tr_32x16, has_tr_32x32,
504     // 32X64,     64X32,          64X64
505     has_tr_32x64, has_tr_64x32, has_tr_64x64,
506     // 64x128,    128x64,         128x128
507     has_tr_64x128, has_tr_128x64, has_tr_128x128,
508     // 4x16,      16x4,            8x32
509     has_tr_4x16, has_tr_16x4, has_tr_8x32,
510     // 32x8,      16x64,           64x16
511     has_tr_32x8, has_tr_16x64, has_tr_64x16
512 };
513 
514 static uint8_t has_tr_vert_8x8[32] = {
515     255, 255, 0, 0, 119, 119, 0, 0, 127, 127, 0, 0, 119, 119, 0, 0,
516     255, 127, 0, 0, 119, 119, 0, 0, 127, 127, 0, 0, 119, 119, 0, 0,
517 };
518 static uint8_t has_tr_vert_16x16[8] = {
519     255, 0, 119, 0, 127, 0, 119, 0,
520 };
521 static uint8_t has_tr_vert_32x32[2] = { 15, 7 };
522 static uint8_t has_tr_vert_64x64[1] = { 3 };
523 
524 // The _vert_* tables are like the ordinary tables above, but describe the
525 // order we visit square blocks when doing a PARTITION_VERT_A or
526 // PARTITION_VERT_B. This is the same order as normal except for on the last
527 // split where we go vertically (TL, BL, TR, BR). We treat the rectangular block
528 // as a pair of squares, which means that these tables work correctly for both
529 // mixed vertical partition types.
530 //
531 // There are tables for each of the square sizes. Vertical rectangles (like
532 // BLOCK_16X32) use their respective "non-vert" table
533 const uint8_t *const has_tr_vert_tables[BlockSizeS] = {
534     // 4X4
535     NULL,
536     // 4X8,      8X4,         8X8
537     has_tr_4x8, NULL, has_tr_vert_8x8,
538     // 8X16,     16X8,        16X16
539     has_tr_8x16, NULL, has_tr_vert_16x16,
540     // 16X32,    32X16,       32X32
541     has_tr_16x32, NULL, has_tr_vert_32x32,
542     // 32X64,    64X32,       64X64
543     has_tr_32x64, NULL, has_tr_vert_64x64,
544     // 64x128,   128x64,      128x128
545     has_tr_64x128, NULL, has_tr_128x128
546 };
547 
get_has_tr_table(PartitionType partition,BlockSize bsize)548 static const uint8_t *get_has_tr_table(PartitionType partition,
549     BlockSize bsize) {
550     const uint8_t *ret = NULL;
551     // If this is a mixed vertical partition, look up bsize in orders_vert.
552     if (partition == PARTITION_VERT_A || partition == PARTITION_VERT_B) {
553         assert(bsize < BlockSizeS);
554         ret = has_tr_vert_tables[bsize];
555     }
556     else
557         ret = has_tr_tables[bsize];
558     assert(ret);
559     return ret;
560 }
561 
intra_has_top_right(BlockSize sb_size,BlockSize bsize,int32_t mi_row,int32_t mi_col,int32_t top_available,int32_t right_available,PartitionType partition,TxSize txsz,int32_t row_off,int32_t col_off,int32_t ss_x,int32_t ss_y)562 int32_t intra_has_top_right(BlockSize   sb_size, BlockSize bsize, int32_t mi_row,
563     int32_t mi_col, int32_t top_available, int32_t right_available,
564     PartitionType partition, TxSize txsz, int32_t row_off,
565     int32_t col_off, int32_t ss_x, int32_t ss_y) {
566     if (!top_available || !right_available) return 0;
567 
568     const int32_t bw_unit = block_size_wide[bsize] >> tx_size_wide_log2[0];
569     const int32_t plane_bw_unit = AOMMAX(bw_unit >> ss_x, 1);
570     const int32_t top_right_count_unit = tx_size_wide_unit[txsz];
571 
572     if (row_off > 0) {  // Just need to check if enough pixels on the right.
573         if (block_size_wide[bsize] > block_size_wide[BLOCK_64X64]) {
574             // Special case: For 128x128 blocks, the transform unit whose
575             // top-right corner is at the center of the block does in fact have
576             // pixels available at its top-right corner.
577             if (row_off == mi_size_high[BLOCK_64X64] >> ss_y &&
578                 col_off + top_right_count_unit == mi_size_wide[BLOCK_64X64] >> ss_x) {
579                 return 1;
580             }
581             const int32_t plane_bw_unit_64 = mi_size_wide[BLOCK_64X64] >> ss_x;
582             const int32_t col_off_64 = col_off % plane_bw_unit_64;
583             return col_off_64 + top_right_count_unit < plane_bw_unit_64;
584         }
585         return col_off + top_right_count_unit < plane_bw_unit;
586     }
587     else {
588         // All top-right pixels are in the block above, which is already available.
589         if (col_off + top_right_count_unit < plane_bw_unit) return 1;
590 
591         const int32_t bw_in_mi_log2 = mi_size_wide_log2[bsize];
592         const int32_t bh_in_mi_log2 = mi_size_high_log2[bsize];
593         const int32_t sb_mi_size = mi_size_high[sb_size];
594         const int32_t blk_row_in_sb = (mi_row & (sb_mi_size - 1)) >> bh_in_mi_log2;
595         const int32_t blk_col_in_sb = (mi_col & (sb_mi_size - 1)) >> bw_in_mi_log2;
596 
597         // Top row of superblock: so top-right pixels are in the top and/or
598         // top-right superblocks, both of which are already available.
599         if (blk_row_in_sb == 0) return 1;
600 
601         // Rightmost column of superblock (and not the top row): so top-right pixels
602         // fall in the right superblock, which is not available yet.
603         if (((blk_col_in_sb + 1) << bw_in_mi_log2) >= sb_mi_size)
604             return 0;
605         // General case (neither top row nor rightmost column): check if the
606         // top-right block is coded before the current block.
607         const int32_t this_blk_index =
608             ((blk_row_in_sb + 0) << (MAX_MIB_SIZE_LOG2 - bw_in_mi_log2)) +
609             blk_col_in_sb + 0;
610         const int32_t idx1 = this_blk_index / 8;
611         const int32_t idx2 = this_blk_index % 8;
612         const uint8_t *has_tr_table = get_has_tr_table(partition, bsize);
613         return (has_tr_table[idx1] >> idx2) & 1;
614     }
615 }
616 
617 // Similar to the has_tr_* tables, but store if the bottom-left reference
618 // pixels are available.
619 static uint8_t has_bl_4x4[128] = {
620     84, 85, 85, 85, 16, 17, 17, 17, 84, 85, 85, 85, 0, 1, 1, 1, 84, 85, 85,
621     85, 16, 17, 17, 17, 84, 85, 85, 85, 0, 0, 1, 0, 84, 85, 85, 85, 16, 17,
622     17, 17, 84, 85, 85, 85, 0, 1, 1, 1, 84, 85, 85, 85, 16, 17, 17, 17, 84,
623     85, 85, 85, 0, 0, 0, 0, 84, 85, 85, 85, 16, 17, 17, 17, 84, 85, 85, 85,
624     0, 1, 1, 1, 84, 85, 85, 85, 16, 17, 17, 17, 84, 85, 85, 85, 0, 0, 1,
625     0, 84, 85, 85, 85, 16, 17, 17, 17, 84, 85, 85, 85, 0, 1, 1, 1, 84, 85,
626     85, 85, 16, 17, 17, 17, 84, 85, 85, 85, 0, 0, 0, 0,
627 };
628 static uint8_t has_bl_4x8[64] = {
629     16, 17, 17, 17, 0, 1, 1, 1, 16, 17, 17, 17, 0, 0, 1, 0,
630     16, 17, 17, 17, 0, 1, 1, 1, 16, 17, 17, 17, 0, 0, 0, 0,
631     16, 17, 17, 17, 0, 1, 1, 1, 16, 17, 17, 17, 0, 0, 1, 0,
632     16, 17, 17, 17, 0, 1, 1, 1, 16, 17, 17, 17, 0, 0, 0, 0,
633 };
634 static uint8_t has_bl_8x4[64] = {
635     254, 255, 84, 85, 254, 255, 16, 17, 254, 255, 84, 85, 254, 255, 0, 1,
636     254, 255, 84, 85, 254, 255, 16, 17, 254, 255, 84, 85, 254, 255, 0, 0,
637     254, 255, 84, 85, 254, 255, 16, 17, 254, 255, 84, 85, 254, 255, 0, 1,
638     254, 255, 84, 85, 254, 255, 16, 17, 254, 255, 84, 85, 254, 255, 0, 0,
639 };
640 static uint8_t has_bl_8x8[32] = {
641     84, 85, 16, 17, 84, 85, 0, 1, 84, 85, 16, 17, 84, 85, 0, 0,
642     84, 85, 16, 17, 84, 85, 0, 1, 84, 85, 16, 17, 84, 85, 0, 0,
643 };
644 static uint8_t has_bl_8x16[16] = {
645     16, 17, 0, 1, 16, 17, 0, 0, 16, 17, 0, 1, 16, 17, 0, 0,
646 };
647 static uint8_t has_bl_16x8[16] = {
648     254, 84, 254, 16, 254, 84, 254, 0, 254, 84, 254, 16, 254, 84, 254, 0,
649 };
650 static uint8_t has_bl_16x16[8] = {
651     84, 16, 84, 0, 84, 16, 84, 0,
652 };
653 static uint8_t has_bl_16x32[4] = { 16, 0, 16, 0 };
654 static uint8_t has_bl_32x16[4] = { 78, 14, 78, 14 };
655 static uint8_t has_bl_32x32[2] = { 4, 4 };
656 static uint8_t has_bl_32x64[1] = { 0 };
657 static uint8_t has_bl_64x32[1] = { 34 };
658 static uint8_t has_bl_64x64[1] = { 0 };
659 static uint8_t has_bl_64x128[1] = { 0 };
660 static uint8_t has_bl_128x64[1] = { 0 };
661 static uint8_t has_bl_128x128[1] = { 0 };
662 static uint8_t has_bl_4x16[32] = {
663     0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0,
664     0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0,
665 };
666 static uint8_t has_bl_16x4[32] = {
667     254, 254, 254, 84, 254, 254, 254, 16, 254, 254, 254, 84, 254, 254, 254, 0,
668     254, 254, 254, 84, 254, 254, 254, 16, 254, 254, 254, 84, 254, 254, 254, 0,
669 };
670 static uint8_t has_bl_8x32[8] = {
671     0, 1, 0, 0, 0, 1, 0, 0,
672 };
673 static uint8_t has_bl_32x8[8] = {
674     238, 78, 238, 14, 238, 78, 238, 14,
675 };
676 static uint8_t has_bl_16x64[2] = { 0, 0 };
677 static uint8_t has_bl_64x16[2] = { 42, 42 };
678 
679 static const uint8_t *const has_bl_tables[BlockSizeS_ALL] = {
680     // 4X4
681     has_bl_4x4,
682     // 4X8,         8X4,         8X8
683     has_bl_4x8, has_bl_8x4, has_bl_8x8,
684     // 8X16,        16X8,        16X16
685     has_bl_8x16, has_bl_16x8, has_bl_16x16,
686     // 16X32,       32X16,       32X32
687     has_bl_16x32, has_bl_32x16, has_bl_32x32,
688     // 32X64,       64X32,       64X64
689     has_bl_32x64, has_bl_64x32, has_bl_64x64,
690     // 64x128,      128x64,      128x128
691     has_bl_64x128, has_bl_128x64, has_bl_128x128,
692     // 4x16,        16x4,        8x32
693     has_bl_4x16, has_bl_16x4, has_bl_8x32,
694     // 32x8,        16x64,       64x16
695     has_bl_32x8, has_bl_16x64, has_bl_64x16
696 };
697 
698 static uint8_t has_bl_vert_8x8[32] = {
699     254, 255, 16, 17, 254, 255, 0, 1, 254, 255, 16, 17, 254, 255, 0, 0,
700     254, 255, 16, 17, 254, 255, 0, 1, 254, 255, 16, 17, 254, 255, 0, 0,
701 };
702 static uint8_t has_bl_vert_16x16[8] = {
703     254, 16, 254, 0, 254, 16, 254, 0,
704 };
705 static uint8_t has_bl_vert_32x32[2] = { 14, 14 };
706 static uint8_t has_bl_vert_64x64[1] = { 2 };
707 
708 // The _vert_* tables are like the ordinary tables above, but describe the
709 // order we visit square blocks when doing a PARTITION_VERT_A or
710 // PARTITION_VERT_B. This is the same order as normal except for on the last
711 // split where we go vertically (TL, BL, TR, BR). We treat the rectangular block
712 // as a pair of squares, which means that these tables work correctly for both
713 // mixed vertical partition types.
714 //
715 // There are tables for each of the square sizes. Vertical rectangles (like
716 // BLOCK_16X32) use their respective "non-vert" table
717 const uint8_t *const has_bl_vert_tables[BlockSizeS] = {
718     // 4X4
719     NULL,
720     // 4X8,     8X4,         8X8
721     has_bl_4x8, NULL, has_bl_vert_8x8,
722     // 8X16,    16X8,        16X16
723     has_bl_8x16, NULL, has_bl_vert_16x16,
724     // 16X32,   32X16,       32X32
725     has_bl_16x32, NULL, has_bl_vert_32x32,
726     // 32X64,   64X32,       64X64
727     has_bl_32x64, NULL, has_bl_vert_64x64,
728     // 64x128,  128x64,      128x128
729     has_bl_64x128, NULL, has_bl_128x128
730 };
731 
get_has_bl_table(PartitionType partition,BlockSize bsize)732 static const uint8_t *get_has_bl_table(PartitionType partition,
733     BlockSize bsize) {
734     const uint8_t *ret = NULL;
735     // If this is a mixed vertical partition, look up bsize in orders_vert.
736     if (partition == PARTITION_VERT_A || partition == PARTITION_VERT_B) {
737         assert(bsize < BlockSizeS);
738         ret = has_bl_vert_tables[bsize];
739     }
740     else
741         ret = has_bl_tables[bsize];
742     assert(ret);
743     return ret;
744 }
745 
intra_has_bottom_left(BlockSize sb_size,BlockSize bsize,int32_t mi_row,int32_t mi_col,int32_t bottom_available,int32_t left_available,PartitionType partition,TxSize txsz,int32_t row_off,int32_t col_off,int32_t ss_x,int32_t ss_y)746 int32_t intra_has_bottom_left(BlockSize sb_size, BlockSize bsize, int32_t mi_row,
747     int32_t mi_col, int32_t bottom_available, int32_t left_available,
748     PartitionType partition, TxSize txsz, int32_t row_off,
749     int32_t col_off, int32_t ss_x, int32_t ss_y) {
750     if (!bottom_available || !left_available) return 0;
751 
752     // Special case for 128x* blocks, when col_off is half the block width.
753     // This is needed because 128x* superblocks are divided into 64x* blocks in
754     // raster order
755     if (block_size_wide[bsize] > block_size_wide[BLOCK_64X64] && col_off > 0) {
756         const int32_t plane_bw_unit_64 = mi_size_wide[BLOCK_64X64] >> ss_x;
757         const int32_t col_off_64 = col_off % plane_bw_unit_64;
758         if (col_off_64 == 0) {
759             // We are at the left edge of top-right or bottom-right 64x* block.
760             const int32_t plane_bh_unit_64 = mi_size_high[BLOCK_64X64] >> ss_y;
761             const int32_t row_off_64 = row_off % plane_bh_unit_64;
762             const int32_t plane_bh_unit =
763                 AOMMIN(mi_size_high[bsize] >> ss_y, plane_bh_unit_64);
764             // Check if all bottom-left pixels are in the left 64x* block (which is
765             // already coded).
766             return row_off_64 + tx_size_high_unit[txsz] < plane_bh_unit;
767         }
768     }
769 
770     if (col_off > 0) {
771         // Bottom-left pixels are in the bottom-left block, which is not available.
772         return 0;
773     }
774     else {
775         const int32_t bh_unit = block_size_high[bsize] >> tx_size_high_log2[0];
776         const int32_t plane_bh_unit = AOMMAX(bh_unit >> ss_y, 1);
777         const int32_t bottom_left_count_unit = tx_size_high_unit[txsz];
778 
779         // All bottom-left pixels are in the left block, which is already available.
780         if (row_off + bottom_left_count_unit < plane_bh_unit) return 1;
781 
782         const int32_t bw_in_mi_log2 = mi_size_wide_log2[bsize];
783         const int32_t bh_in_mi_log2 = mi_size_high_log2[bsize];
784         const int32_t sb_mi_size = mi_size_high[sb_size];
785         const int32_t blk_row_in_sb = (mi_row & (sb_mi_size - 1)) >> bh_in_mi_log2;
786         const int32_t blk_col_in_sb = (mi_col & (sb_mi_size - 1)) >> bw_in_mi_log2;
787 
788         // Leftmost column of superblock: so bottom-left pixels maybe in the left
789         // and/or bottom-left superblocks. But only the left superblock is
790         // available, so check if all required pixels fall in that superblock.
791         if (blk_col_in_sb == 0) {
792             const int32_t blk_start_row_off = blk_row_in_sb
793                 << (bh_in_mi_log2 + MI_SIZE_LOG2 -
794                     tx_size_wide_log2[0]) >>
795                 ss_y;
796             const int32_t row_off_in_sb = blk_start_row_off + row_off;
797             const int32_t sb_height_unit = sb_mi_size >> ss_y;
798             return row_off_in_sb + bottom_left_count_unit < sb_height_unit;
799         }
800 
801         // Bottom row of superblock (and not the leftmost column): so bottom-left
802         // pixels fall in the bottom superblock, which is not available yet.
803         if (((blk_row_in_sb + 1) << bh_in_mi_log2) >= sb_mi_size) return 0;
804 
805         // General case (neither leftmost column nor bottom row): check if the
806         // bottom-left block is coded before the current block.
807         const int32_t this_blk_index =
808             ((blk_row_in_sb + 0) << (MAX_MIB_SIZE_LOG2 - bw_in_mi_log2)) +
809             blk_col_in_sb + 0;
810         const int32_t idx1 = this_blk_index / 8;
811         const int32_t idx2 = this_blk_index % 8;
812         const uint8_t *has_bl_table = get_has_bl_table(partition, bsize);
813         return (has_bl_table[idx1] >> idx2) & 1;
814     }
815 }
816 
817 IntraPredFn eb_pred[INTRA_MODES][TX_SIZES_ALL];
818 IntraPredFn dc_pred[2][2][TX_SIZES_ALL];
819 
820 IntraHighPredFn pred_high[INTRA_MODES][TX_SIZES_ALL];
821 IntraHighPredFn dc_pred_high[2][2][TX_SIZES_ALL];
822 
dc_128_predictor(uint8_t * dst,ptrdiff_t stride,int32_t bw,int32_t bh,const uint8_t * above,const uint8_t * left)823 static INLINE void dc_128_predictor(uint8_t *dst, ptrdiff_t stride, int32_t bw,
824     int32_t bh, const uint8_t *above,
825     const uint8_t *left) {
826     (void)above;
827     (void)left;
828 
829     for (int32_t r = 0; r < bh; r++) {
830         memset(dst, 128, bw);
831         dst += stride;
832     }
833 }
834 
dc_left_predictor(uint8_t * dst,ptrdiff_t stride,int32_t bw,int32_t bh,const uint8_t * above,const uint8_t * left)835 static INLINE void dc_left_predictor(uint8_t *dst, ptrdiff_t stride, int32_t bw,
836     int32_t bh, const uint8_t *above,
837     const uint8_t *left) {
838     int32_t sum = 0;
839     (void)above;
840 
841     for (int32_t i = 0; i < bh; i++) sum += left[i];
842     int32_t expected_dc = (sum + (bh >> 1)) / bh;
843 
844     for (int32_t r = 0; r < bh; r++) {
845         memset(dst, expected_dc, bw);
846         dst += stride;
847     }
848 }
dc_top_predictor(uint8_t * dst,ptrdiff_t stride,int32_t bw,int32_t bh,const uint8_t * above,const uint8_t * left)849 static INLINE void dc_top_predictor(uint8_t *dst, ptrdiff_t stride, int32_t bw,
850     int32_t bh, const uint8_t *above,
851     const uint8_t *left) {
852     int32_t sum = 0;
853     (void)left;
854 
855     for (int32_t i = 0; i < bw; i++) sum += above[i];
856     int32_t expected_dc = (sum + (bw >> 1)) / bw;
857 
858     for (int32_t r = 0; r < bh; r++) {
859         memset(dst, expected_dc, bw);
860         dst += stride;
861     }
862 }
dc_predictor(uint8_t * dst,ptrdiff_t stride,int32_t bw,int32_t bh,const uint8_t * above,const uint8_t * left)863 static INLINE void dc_predictor(uint8_t *dst, ptrdiff_t stride, int32_t bw, int32_t bh,
864     const uint8_t *above, const uint8_t *left) {
865     int32_t sum = 0;
866     const int32_t count = bw + bh;
867 
868     for (int32_t i = 0; i < bw; i++) sum += above[i];
869     for (int32_t i = 0; i < bh; i++) sum += left[i];
870     int32_t expected_dc = (sum + (count >> 1)) / count;
871 
872     for (int32_t r = 0; r < bh; r++) {
873         memset(dst, expected_dc, bw);
874         dst += stride;
875     }
876 }
v_predictor(uint8_t * dst,ptrdiff_t stride,int32_t bw,int32_t bh,const uint8_t * above,const uint8_t * left)877 static INLINE void v_predictor(uint8_t *dst, ptrdiff_t stride, int32_t bw, int32_t bh,
878     const uint8_t *above, const uint8_t *left) {
879     (void)left;
880 
881     for (int32_t r = 0; r < bh; r++) {
882         svt_memcpy(dst, above, bw);
883         dst += stride;
884     }
885 }
886 
h_predictor(uint8_t * dst,ptrdiff_t stride,int32_t bw,int32_t bh,const uint8_t * above,const uint8_t * left)887 static INLINE void h_predictor(uint8_t *dst, ptrdiff_t stride, int32_t bw, int32_t bh,
888     const uint8_t *above, const uint8_t *left) {
889     (void)above;
890 
891     for (int32_t r = 0; r < bh; r++) {
892         memset(dst, left[r], bw);
893         dst += stride;
894     }
895 }
896 
smooth_predictor(uint8_t * dst,ptrdiff_t stride,int32_t bw,int32_t bh,const uint8_t * above,const uint8_t * left)897 static INLINE void smooth_predictor(uint8_t *dst, ptrdiff_t stride, int32_t bw,
898     int32_t bh, const uint8_t *above,
899     const uint8_t *left) {
900     const uint8_t below_pred = left[bh - 1];   // estimated by bottom-left pixel
901     const uint8_t right_pred = above[bw - 1];  // estimated by top-right pixel
902     const uint8_t *const sm_weights_w = sm_weight_arrays + bw;
903     const uint8_t *const sm_weights_h = sm_weight_arrays + bh;
904     // scale = 2 * 2^sm_weight_log2_scale
905     const int32_t log2_scale = 1 + sm_weight_log2_scale;
906     const uint16_t scale = (1 << sm_weight_log2_scale);
907     sm_weights_sanity_checks(sm_weights_w, sm_weights_h, scale,
908         log2_scale + 1);
909     for (int32_t r = 0; r < bh; ++r, dst += stride) {
910         for (int32_t c = 0; c < bw; ++c) {
911             const uint8_t pixels[] = { above[c], below_pred, left[r], right_pred };
912             const uint8_t weights[] = { sm_weights_h[r], (uint8_t)(scale - sm_weights_h[r]),
913                 sm_weights_w[c], (uint8_t)(scale - sm_weights_w[c]) };
914             uint32_t this_pred = 0;
915             assert(scale >= sm_weights_h[r] && scale >= sm_weights_w[c]);
916             for (int i = 0; i < 4; ++i) this_pred += weights[i] * pixels[i];
917             dst[c] = (uint8_t)divide_round(this_pred, log2_scale);
918         }
919     }
920 }
921 
smooth_v_predictor(uint8_t * dst,ptrdiff_t stride,int32_t bw,int32_t bh,const uint8_t * above,const uint8_t * left)922 static INLINE void smooth_v_predictor(uint8_t *dst, ptrdiff_t stride, int32_t bw,
923     int32_t bh, const uint8_t *above,
924     const uint8_t *left) {
925     const uint8_t below_pred = left[bh - 1];  // estimated by bottom-left pixel
926     const uint8_t *const sm_weights = sm_weight_arrays + bh;
927     // scale = 2^sm_weight_log2_scale
928     const int32_t log2_scale = sm_weight_log2_scale;
929     const uint16_t scale = (1 << sm_weight_log2_scale);
930     sm_weights_sanity_checks(sm_weights, sm_weights, scale,
931         log2_scale + 1);
932 
933     for (int32_t r = 0; r < bh; ++r, dst += stride) {
934         for (int32_t c = 0; c < bw; ++c) {
935             const uint8_t pixels[] = { above[c], below_pred };
936             const uint8_t weights[] = { sm_weights[r], (uint8_t)(scale - sm_weights[r]) };
937             uint32_t this_pred = 0;
938             assert(scale >= sm_weights[r]);
939             for (unsigned i = 0; i < 2; ++i)
940                 this_pred += weights[i] * pixels[i];
941             dst[c] = (uint8_t)divide_round(this_pred, log2_scale);
942         }
943     }
944 }
945 
smooth_h_predictor(uint8_t * dst,ptrdiff_t stride,int32_t bw,int32_t bh,const uint8_t * above,const uint8_t * left)946 static INLINE void smooth_h_predictor(uint8_t *dst, ptrdiff_t stride, int32_t bw,
947     int32_t bh, const uint8_t *above,
948     const uint8_t *left) {
949     const uint8_t right_pred = above[bw - 1];  // estimated by top-right pixel
950     const uint8_t *const sm_weights = sm_weight_arrays + bw;
951     // scale = 2^sm_weight_log2_scale
952     const int32_t log2_scale = sm_weight_log2_scale;
953     const uint16_t scale = (1 << sm_weight_log2_scale);
954     sm_weights_sanity_checks(sm_weights, sm_weights, scale,
955         log2_scale + 1);
956 
957     for (int32_t r = 0; r < bh; ++r, dst += stride) {
958         for (int32_t c = 0; c < bw; ++c) {
959             const uint8_t pixels[] = { left[r], right_pred };
960             const uint8_t weights[] = { sm_weights[c], (uint8_t)(scale - sm_weights[c]) };
961             uint32_t this_pred = 0;
962             assert(scale >= sm_weights[c]);
963             for (unsigned i = 0; i < 2; ++i)
964                 this_pred += weights[i] * pixels[i];
965             dst[c] = (uint8_t)divide_round(this_pred, log2_scale);
966         }
967     }
968 }
969 #undef DC_MULTIPLIER_1X2
970 #undef DC_MULTIPLIER_1X4
971 
highbd_v_predictor(uint16_t * dst,ptrdiff_t stride,int32_t bw,int32_t bh,const uint16_t * above,const uint16_t * left,int32_t bd)972 static INLINE void highbd_v_predictor(uint16_t *dst, ptrdiff_t stride, int32_t bw,
973     int32_t bh, const uint16_t *above,
974     const uint16_t *left, int32_t bd) {
975     (void)left;
976     (void)bd;
977     for (int32_t r = 0; r < bh; r++) {
978         svt_memcpy(dst, above, bw * sizeof(uint16_t));
979         dst += stride;
980     }
981 }
982 
highbd_h_predictor(uint16_t * dst,ptrdiff_t stride,int32_t bw,int32_t bh,const uint16_t * above,const uint16_t * left,int32_t bd)983 static INLINE void highbd_h_predictor(uint16_t *dst, ptrdiff_t stride, int32_t bw,
984     int32_t bh, const uint16_t *above,
985     const uint16_t *left, int32_t bd) {
986     (void)above;
987     (void)bd;
988     for (int32_t r = 0; r < bh; r++) {
989         svt_aom_memset16(dst, left[r], bw);
990         dst += stride;
991     }
992 }
abs_diff(int a,int b)993 static INLINE int abs_diff(int a, int b) { return (a > b) ? a - b : b - a; }
paeth_predictor_single(uint16_t left,uint16_t top,uint16_t top_left)994 static INLINE uint16_t paeth_predictor_single(uint16_t left, uint16_t top,
995                                               uint16_t top_left) {
996   const int base = top + left - top_left;
997   const int p_left = abs_diff(base, left);
998   const int p_top = abs_diff(base, top);
999   const int p_top_left = abs_diff(base, top_left);
1000 
1001   // Return nearest to base of left, top and top_left.
1002   return (p_left <= p_top && p_left <= p_top_left)
1003              ? left
1004              : (p_top <= p_top_left) ? top : top_left;
1005 }
1006 
paeth_predictor(uint8_t * dst,ptrdiff_t stride,int bw,int bh,const uint8_t * above,const uint8_t * left)1007 static INLINE void paeth_predictor(uint8_t *dst, ptrdiff_t stride, int bw,
1008                                    int bh, const uint8_t *above,
1009                                    const uint8_t *left) {
1010   const uint8_t ytop_left = above[-1];
1011 
1012   for (int r = 0; r < bh; ++r, dst += stride)
1013       for (int c = 0; c < bw; ++c)
1014           dst[c] = (uint8_t)paeth_predictor_single(left[r], above[c], ytop_left);
1015 }
1016 
highbd_paeth_predictor(uint16_t * dst,ptrdiff_t stride,int bw,int bh,const uint16_t * above,const uint16_t * left,int bd)1017 static INLINE void highbd_paeth_predictor(uint16_t *dst, ptrdiff_t stride,
1018                                           int bw, int bh, const uint16_t *above,
1019                                           const uint16_t *left, int bd) {
1020   const uint16_t ytop_left = above[-1];
1021   (void)bd;
1022 
1023   for (int r = 0; r < bh; ++r, dst += stride)
1024       for (int c = 0; c < bw; ++c) dst[c] = paeth_predictor_single(left[r], above[c], ytop_left);
1025 }
1026 //static INLINE void highbd_paeth_predictor(uint16_t *dst, ptrdiff_t stride,
1027 //    int32_t bw, int32_t bh, const uint16_t *above,
1028 //    const uint16_t *left, int32_t bd) {
1029 //    int32_t r, c;
1030 //    const uint16_t ytop_left = above[-1];
1031 //    (void)bd;
1032 //
1033 //    for (r = 0; r < bh; r++) {
1034 //        for (c = 0; c < bw; c++)
1035 //            dst[c] = paeth_predictor_single(left[r], above[c], ytop_left);
1036 //        dst += stride;
1037 //    }
1038 //}
1039 
highbd_smooth_predictor(uint16_t * dst,ptrdiff_t stride,int32_t bw,int32_t bh,const uint16_t * above,const uint16_t * left,int32_t bd)1040 static INLINE void highbd_smooth_predictor(uint16_t *dst, ptrdiff_t stride,
1041     int32_t bw, int32_t bh,
1042     const uint16_t *above,
1043     const uint16_t *left, int32_t bd) {
1044     (void)bd;
1045     const uint16_t below_pred = left[bh - 1];   // estimated by bottom-left pixel
1046     const uint16_t right_pred = above[bw - 1];  // estimated by top-right pixel
1047     const uint8_t *const sm_weights_w = sm_weight_arrays + bw;
1048     const uint8_t *const sm_weights_h = sm_weight_arrays + bh;
1049     // scale = 2 * 2^sm_weight_log2_scale
1050     const int32_t log2_scale = 1 + sm_weight_log2_scale;
1051     const uint16_t scale = (1 << sm_weight_log2_scale);
1052     sm_weights_sanity_checks(sm_weights_w, sm_weights_h, scale,
1053         log2_scale + 2);
1054     for (int32_t r = 0; r < bh; ++r, dst += stride) {
1055         for (int32_t c = 0; c < bw; ++c) {
1056             const uint16_t pixels[] = { above[c], below_pred, left[r], right_pred };
1057             const uint8_t weights[] = { sm_weights_h[r], (uint8_t)(scale - sm_weights_h[r]),
1058                 sm_weights_w[c], (uint8_t)(scale - sm_weights_w[c]) };
1059             uint32_t this_pred = 0;
1060             assert(scale >= sm_weights_h[r] && scale >= sm_weights_w[c]);
1061             for (int i = 0; i < 4; ++i)
1062                 this_pred += weights[i] * pixels[i];
1063             dst[c] = (uint16_t)divide_round(this_pred, log2_scale);
1064         }
1065     }
1066 }
1067 
highbd_smooth_v_predictor(uint16_t * dst,ptrdiff_t stride,int32_t bw,int32_t bh,const uint16_t * above,const uint16_t * left,int32_t bd)1068 static INLINE void highbd_smooth_v_predictor(uint16_t *dst, ptrdiff_t stride,
1069     int32_t bw, int32_t bh,
1070     const uint16_t *above,
1071     const uint16_t *left, int32_t bd) {
1072     (void)bd;
1073     const uint16_t below_pred = left[bh - 1];  // estimated by bottom-left pixel
1074     const uint8_t *const sm_weights = sm_weight_arrays + bh;
1075     // scale = 2^sm_weight_log2_scale
1076     const int32_t log2_scale = sm_weight_log2_scale;
1077     const uint16_t scale = (1 << sm_weight_log2_scale);
1078     sm_weights_sanity_checks(sm_weights, sm_weights, scale,
1079         log2_scale + sizeof(*dst));
1080 
1081     for (int32_t r = 0; r < bh; ++r, dst += stride) {
1082         for (int32_t c = 0; c < bw; ++c) {
1083             const uint16_t pixels[] = { above[c], below_pred };
1084             const uint8_t weights[] = { sm_weights[r], (uint8_t)(scale - sm_weights[r]) };
1085             uint32_t this_pred = 0;
1086             assert(scale >= sm_weights[r]);
1087             for (int i = 0; i < 2; ++i)
1088                 this_pred += weights[i] * pixels[i];
1089             dst[c] = (uint16_t)divide_round(this_pred, log2_scale);
1090         }
1091     }
1092 }
1093 
highbd_smooth_h_predictor(uint16_t * dst,ptrdiff_t stride,int32_t bw,int32_t bh,const uint16_t * above,const uint16_t * left,int32_t bd)1094 static INLINE void highbd_smooth_h_predictor(uint16_t *dst, ptrdiff_t stride,
1095     int32_t bw, int32_t bh,
1096     const uint16_t *above,
1097     const uint16_t *left, int32_t bd) {
1098     (void)bd;
1099     const uint16_t right_pred = above[bw - 1];  // estimated by top-right pixel
1100     const uint8_t *const sm_weights = sm_weight_arrays + bw;
1101     // scale = 2^sm_weight_log2_scale
1102     const int32_t log2_scale = sm_weight_log2_scale;
1103     const uint16_t scale = (1 << sm_weight_log2_scale);
1104     sm_weights_sanity_checks(sm_weights, sm_weights, scale,
1105         log2_scale + sizeof(*dst));
1106 
1107     for (int32_t r = 0; r < bh; r++, dst += stride) {
1108         for (int32_t c = 0; c < bw; ++c) {
1109             const uint16_t pixels[] = { left[r], right_pred };
1110             const uint8_t weights[] = { sm_weights[c], (uint8_t)(scale - sm_weights[c]) };
1111             uint32_t this_pred = 0;
1112             assert(scale >= sm_weights[c]);
1113             for (int i = 0; i < 2; ++i)
1114                 this_pred += weights[i] * pixels[i];
1115             dst[c] = (uint16_t)divide_round(this_pred, log2_scale);
1116         }
1117     }
1118 }
1119 
highbd_dc_128_predictor(uint16_t * dst,ptrdiff_t stride,int32_t bw,int32_t bh,const uint16_t * above,const uint16_t * left,int32_t bd)1120 static INLINE void highbd_dc_128_predictor(uint16_t *dst, ptrdiff_t stride,
1121     int32_t bw, int32_t bh,
1122     const uint16_t *above,
1123     const uint16_t *left, int32_t bd) {
1124     (void)above;
1125     (void)left;
1126 
1127     for (int32_t r = 0; r < bh; r++) {
1128         svt_aom_memset16(dst, 128 << (bd - 8), bw);
1129         dst += stride;
1130     }
1131 }
1132 
highbd_dc_left_predictor(uint16_t * dst,ptrdiff_t stride,int32_t bw,int32_t bh,const uint16_t * above,const uint16_t * left,int32_t bd)1133 static INLINE void highbd_dc_left_predictor(uint16_t *dst, ptrdiff_t stride,
1134     int32_t bw, int32_t bh,
1135     const uint16_t *above,
1136     const uint16_t *left, int32_t bd) {
1137     int32_t sum = 0;
1138     (void)above;
1139     (void)bd;
1140 
1141     for (int32_t i = 0; i < bh; i++) sum += left[i];
1142     int32_t expected_dc = (sum + (bh >> 1)) / bh;
1143 
1144     for (int32_t r = 0; r < bh; r++) {
1145         svt_aom_memset16(dst, expected_dc, bw);
1146         dst += stride;
1147     }
1148 }
1149 
highbd_dc_top_predictor(uint16_t * dst,ptrdiff_t stride,int32_t bw,int32_t bh,const uint16_t * above,const uint16_t * left,int32_t bd)1150 static INLINE void highbd_dc_top_predictor(uint16_t *dst, ptrdiff_t stride,
1151     int32_t bw, int32_t bh,
1152     const uint16_t *above,
1153     const uint16_t *left, int32_t bd) {
1154     int32_t sum = 0;
1155     (void)left;
1156     (void)bd;
1157 
1158     for (int32_t i = 0; i < bw; i++) sum += above[i];
1159     int32_t expected_dc = (sum + (bw >> 1)) / bw;
1160 
1161     for (int32_t r = 0; r < bh; r++) {
1162         svt_aom_memset16(dst, expected_dc, bw);
1163         dst += stride;
1164     }
1165 }
1166 
highbd_dc_predictor(uint16_t * dst,ptrdiff_t stride,int32_t bw,int32_t bh,const uint16_t * above,const uint16_t * left,int32_t bd)1167 static INLINE void highbd_dc_predictor(uint16_t *dst, ptrdiff_t stride, int32_t bw,
1168     int32_t bh, const uint16_t *above,
1169     const uint16_t *left, int32_t bd) {
1170     int32_t sum = 0;
1171     const int32_t count = bw + bh;
1172     (void)bd;
1173 
1174     for (int32_t i = 0; i < bw; i++)
1175         sum += above[i];
1176     for (int32_t i = 0; i < bh; i++)
1177         sum += left[i];
1178     int32_t expected_dc = (sum + (count >> 1)) / count;
1179 
1180     for (int32_t r = 0; r < bh; r++) {
1181         svt_aom_memset16(dst, expected_dc, bw);
1182         dst += stride;
1183     }
1184 }
1185 
1186 //static INLINE void highbd_dc_predictor_rect(uint16_t *dst, ptrdiff_t stride,
1187 //    int32_t bw, int32_t bh,
1188 //    const uint16_t *above,
1189 //    const uint16_t *left, int32_t bd,
1190 //    int32_t shift1, uint32_t multiplier) {
1191 //    int32_t sum = 0;
1192 //    (void)bd;
1193 //
1194 //    for (int32_t i = 0; i < bw; i++) {
1195 //        sum += above[i];
1196 //    }
1197 //    for (int32_t i = 0; i < bh; i++) {
1198 //        sum += left[i];
1199 //    }
1200 //
1201 //    const int32_t expected_dc = divide_using_multiply_shift(
1202 //        sum + ((bw + bh) >> 1), shift1, multiplier, HIGHBD_DC_SHIFT2);
1203 //    assert(expected_dc < (1 << bd));
1204 //
1205 //    for (int32_t r = 0; r < bh; r++) {
1206 //        svt_aom_memset16(dst, expected_dc, bw);
1207 //        dst += stride;
1208 //    }
1209 //}
1210 
1211 //#undef HIGHBD_DC_SHIFT2
1212 //
1213 //void svt_aom_highbd_dc_predictor_4x8_c(uint16_t *dst, ptrdiff_t stride,
1214 //    const uint16_t *above, const uint16_t *left,
1215 //    int32_t bd) {
1216 //    highbd_dc_predictor_rect(dst, stride, 4, 8, above, left, bd, 2,
1217 //        HIGHBD_DC_MULTIPLIER_1X2);
1218 //}
1219 //
1220 //void svt_aom_highbd_dc_predictor_8x4_c(uint16_t *dst, ptrdiff_t stride,
1221 //    const uint16_t *above, const uint16_t *left,
1222 //    int32_t bd) {
1223 //    highbd_dc_predictor_rect(dst, stride, 8, 4, above, left, bd, 2,
1224 //        HIGHBD_DC_MULTIPLIER_1X2);
1225 //}
1226 //
1227 //void svt_aom_highbd_dc_predictor_4x16_c(uint16_t *dst, ptrdiff_t stride,
1228 //    const uint16_t *above, const uint16_t *left,
1229 //    int32_t bd) {
1230 //    highbd_dc_predictor_rect(dst, stride, 4, 16, above, left, bd, 2,
1231 //        HIGHBD_DC_MULTIPLIER_1X4);
1232 //}
1233 //
1234 //void svt_aom_highbd_dc_predictor_16x4_c(uint16_t *dst, ptrdiff_t stride,
1235 //    const uint16_t *above, const uint16_t *left,
1236 //    int32_t bd) {
1237 //    highbd_dc_predictor_rect(dst, stride, 16, 4, above, left, bd, 2,
1238 //        HIGHBD_DC_MULTIPLIER_1X4);
1239 //}
1240 //
1241 //void svt_aom_highbd_dc_predictor_8x16_c(uint16_t *dst, ptrdiff_t stride,
1242 //    const uint16_t *above, const uint16_t *left,
1243 //    int32_t bd) {
1244 //    highbd_dc_predictor_rect(dst, stride, 8, 16, above, left, bd, 3,
1245 //        HIGHBD_DC_MULTIPLIER_1X2);
1246 //}
1247 //
1248 //void svt_aom_highbd_dc_predictor_16x8_c(uint16_t *dst, ptrdiff_t stride,
1249 //    const uint16_t *above, const uint16_t *left,
1250 //    int32_t bd) {
1251 //    highbd_dc_predictor_rect(dst, stride, 16, 8, above, left, bd, 3,
1252 //        HIGHBD_DC_MULTIPLIER_1X2);
1253 //}
1254 //
1255 //void svt_aom_highbd_dc_predictor_8x32_c(uint16_t *dst, ptrdiff_t stride,
1256 //    const uint16_t *above, const uint16_t *left,
1257 //    int32_t bd) {
1258 //    highbd_dc_predictor_rect(dst, stride, 8, 32, above, left, bd, 3,
1259 //        HIGHBD_DC_MULTIPLIER_1X4);
1260 //}
1261 //
1262 //void svt_aom_highbd_dc_predictor_32x8_c(uint16_t *dst, ptrdiff_t stride,
1263 //    const uint16_t *above, const uint16_t *left,
1264 //    int32_t bd) {
1265 //    highbd_dc_predictor_rect(dst, stride, 32, 8, above, left, bd, 3,
1266 //        HIGHBD_DC_MULTIPLIER_1X4);
1267 //}
1268 //
1269 //void svt_aom_highbd_dc_predictor_16x32_c(uint16_t *dst, ptrdiff_t stride,
1270 //    const uint16_t *above,
1271 //    const uint16_t *left, int32_t bd) {
1272 //    highbd_dc_predictor_rect(dst, stride, 16, 32, above, left, bd, 4,
1273 //        HIGHBD_DC_MULTIPLIER_1X2);
1274 //}
1275 //
1276 //void svt_aom_highbd_dc_predictor_32x16_c(uint16_t *dst, ptrdiff_t stride,
1277 //    const uint16_t *above,
1278 //    const uint16_t *left, int32_t bd) {
1279 //    highbd_dc_predictor_rect(dst, stride, 32, 16, above, left, bd, 4,
1280 //        HIGHBD_DC_MULTIPLIER_1X2);
1281 //}
1282 //
1283 //void svt_aom_highbd_dc_predictor_16x64_c(uint16_t *dst, ptrdiff_t stride,
1284 //    const uint16_t *above,
1285 //    const uint16_t *left, int32_t bd) {
1286 //    highbd_dc_predictor_rect(dst, stride, 16, 64, above, left, bd, 4,
1287 //        HIGHBD_DC_MULTIPLIER_1X4);
1288 //}
1289 //
1290 //void svt_aom_highbd_dc_predictor_64x16_c(uint16_t *dst, ptrdiff_t stride,
1291 //    const uint16_t *above,
1292 //    const uint16_t *left, int32_t bd) {
1293 //    highbd_dc_predictor_rect(dst, stride, 64, 16, above, left, bd, 4,
1294 //        HIGHBD_DC_MULTIPLIER_1X4);
1295 //}
1296 //
1297 //void svt_aom_highbd_dc_predictor_32x64_c(uint16_t *dst, ptrdiff_t stride,
1298 //    const uint16_t *above,
1299 //    const uint16_t *left, int32_t bd) {
1300 //    highbd_dc_predictor_rect(dst, stride, 32, 64, above, left, bd, 5,
1301 //        HIGHBD_DC_MULTIPLIER_1X2);
1302 //}
1303 //
1304 //void svt_aom_highbd_dc_predictor_64x32_c(uint16_t *dst, ptrdiff_t stride,
1305 //    const uint16_t *above,
1306 //    const uint16_t *left, int32_t bd) {
1307 //    highbd_dc_predictor_rect(dst, stride, 64, 32, above, left, bd, 5,
1308 //        HIGHBD_DC_MULTIPLIER_1X2);
1309 //}
1310 //
1311 //#undef HIGHBD_DC_MULTIPLIER_1X2
1312 //#undef HIGHBD_DC_MULTIPLIER_1X4
1313 
1314 #define intra_pred_sized(type, width, height)                  \
1315   void svt_aom_##type##_predictor_##width##x##height##_c(      \
1316       uint8_t *dst, ptrdiff_t stride, const uint8_t *above,    \
1317       const uint8_t *left) {                                   \
1318     type##_predictor(dst, stride, width, height, above, left); \
1319   }
1320 
1321 intra_pred_sized(dc, 2, 2)
1322 intra_pred_sized(dc, 4, 4)
1323 intra_pred_sized(dc, 8, 8)
1324 intra_pred_sized(dc, 16, 16)
1325 intra_pred_sized(dc, 32, 32)
1326 intra_pred_sized(dc, 64, 64)
1327 intra_pred_sized(dc, 4, 8)
1328 intra_pred_sized(dc, 4, 16)
1329 intra_pred_sized(dc, 8, 4)
1330 intra_pred_sized(dc, 8, 16)
1331 intra_pred_sized(dc, 8, 32)
1332 intra_pred_sized(dc, 16, 4)
1333 intra_pred_sized(dc, 16, 8)
1334 intra_pred_sized(dc, 16, 32)
1335 intra_pred_sized(dc, 16, 64)
1336 intra_pred_sized(dc, 32, 8)
1337 intra_pred_sized(dc, 32, 16)
1338 intra_pred_sized(dc, 32, 64)
1339 intra_pred_sized(dc, 64, 16)
1340 intra_pred_sized(dc, 64, 32)
1341 
1342 intra_pred_sized(dc_128, 2, 2)
1343 intra_pred_sized(dc_128, 4, 4)
1344 intra_pred_sized(dc_128, 8, 8)
1345 intra_pred_sized(dc_128, 16, 16)
1346 intra_pred_sized(dc_128, 32, 32)
1347 intra_pred_sized(dc_128, 64, 64)
1348 intra_pred_sized(dc_128, 4, 8)
1349 intra_pred_sized(dc_128, 4, 16)
1350 intra_pred_sized(dc_128, 8, 4)
1351 intra_pred_sized(dc_128, 8, 16)
1352 intra_pred_sized(dc_128, 8, 32)
1353 intra_pred_sized(dc_128, 16, 4)
1354 intra_pred_sized(dc_128, 16, 8)
1355 intra_pred_sized(dc_128, 16, 32)
1356 intra_pred_sized(dc_128, 16, 64)
1357 intra_pred_sized(dc_128, 32, 8)
1358 intra_pred_sized(dc_128, 32, 16)
1359 intra_pred_sized(dc_128, 32, 64)
1360 intra_pred_sized(dc_128, 64, 16)
1361 intra_pred_sized(dc_128, 64, 32)
1362 
1363 intra_pred_sized(dc_left, 2, 2)
1364 intra_pred_sized(dc_left, 4, 4)
1365 intra_pred_sized(dc_left, 8, 8)
1366 intra_pred_sized(dc_left, 16, 16)
1367 intra_pred_sized(dc_left, 32, 32)
1368 intra_pred_sized(dc_left, 64, 64)
1369 intra_pred_sized(dc_left, 4, 8)
1370 intra_pred_sized(dc_left, 4, 16)
1371 intra_pred_sized(dc_left, 8, 4)
1372 intra_pred_sized(dc_left, 8, 16)
1373 intra_pred_sized(dc_left, 8, 32)
1374 intra_pred_sized(dc_left, 16, 4)
1375 intra_pred_sized(dc_left, 16, 8)
1376 intra_pred_sized(dc_left, 16, 32)
1377 intra_pred_sized(dc_left, 16, 64)
1378 intra_pred_sized(dc_left, 32, 8)
1379 intra_pred_sized(dc_left, 32, 16)
1380 intra_pred_sized(dc_left, 32, 64)
1381 intra_pred_sized(dc_left, 64, 16)
1382 intra_pred_sized(dc_left, 64, 32)
1383 
1384 intra_pred_sized(dc_top, 2, 2)
1385 intra_pred_sized(dc_top, 4, 4)
1386 intra_pred_sized(dc_top, 8, 8)
1387 intra_pred_sized(dc_top, 16, 16)
1388 intra_pred_sized(dc_top, 32, 32)
1389 intra_pred_sized(dc_top, 64, 64)
1390 intra_pred_sized(dc_top, 4, 8)
1391 intra_pred_sized(dc_top, 4, 16)
1392 intra_pred_sized(dc_top, 8, 4)
1393 intra_pred_sized(dc_top, 8, 16)
1394 intra_pred_sized(dc_top, 8, 32)
1395 intra_pred_sized(dc_top, 16, 4)
1396 intra_pred_sized(dc_top, 16, 8)
1397 intra_pred_sized(dc_top, 16, 32)
1398 intra_pred_sized(dc_top, 16, 64)
1399 intra_pred_sized(dc_top, 32, 8)
1400 intra_pred_sized(dc_top, 32, 16)
1401 intra_pred_sized(dc_top, 32, 64)
1402 intra_pred_sized(dc_top, 64, 16)
1403 intra_pred_sized(dc_top, 64, 32)
1404 intra_pred_sized(v, 2, 2)
1405 intra_pred_sized(v, 4, 4)
1406 intra_pred_sized(v, 8, 8)
1407 intra_pred_sized(v, 16, 16)
1408 intra_pred_sized(v, 32, 32)
1409 intra_pred_sized(v, 64, 64)
1410 intra_pred_sized(v, 4, 8)
1411 intra_pred_sized(v, 4, 16)
1412 intra_pred_sized(v, 8, 4)
1413 intra_pred_sized(v, 8, 16)
1414 intra_pred_sized(v, 8, 32)
1415 intra_pred_sized(v, 16, 4)
1416 intra_pred_sized(v, 16, 8)
1417 intra_pred_sized(v, 16, 32)
1418 intra_pred_sized(v, 16, 64)
1419 intra_pred_sized(v, 32, 8)
1420 intra_pred_sized(v, 32, 16)
1421 intra_pred_sized(v, 32, 64)
1422 intra_pred_sized(v, 64, 16)
1423 intra_pred_sized(v, 64, 32)
1424 intra_pred_sized(h, 2, 2)
1425 intra_pred_sized(h, 4, 4)
1426 intra_pred_sized(h, 8, 8)
1427 intra_pred_sized(h, 16, 16)
1428 intra_pred_sized(h, 32, 32)
1429 intra_pred_sized(h, 64, 64)
1430 intra_pred_sized(h, 4, 8)
1431 intra_pred_sized(h, 4, 16)
1432 intra_pred_sized(h, 8, 4)
1433 intra_pred_sized(h, 8, 16)
1434 intra_pred_sized(h, 8, 32)
1435 intra_pred_sized(h, 16, 4)
1436 intra_pred_sized(h, 16, 8)
1437 intra_pred_sized(h, 16, 32)
1438 intra_pred_sized(h, 16, 64)
1439 intra_pred_sized(h, 32, 8)
1440 intra_pred_sized(h, 32, 16)
1441 intra_pred_sized(h, 32, 64)
1442 intra_pred_sized(h, 64, 16)
1443 intra_pred_sized(h, 64, 32)
1444 intra_pred_sized(smooth, 2, 2)
1445 intra_pred_sized(smooth, 4, 4)
1446 intra_pred_sized(smooth, 8, 8)
1447 intra_pred_sized(smooth, 16, 16)
1448 intra_pred_sized(smooth, 32, 32)
1449 intra_pred_sized(smooth, 64, 64)
1450 intra_pred_sized(smooth, 4, 8)
1451 intra_pred_sized(smooth, 4, 16)
1452 intra_pred_sized(smooth, 8, 4)
1453 intra_pred_sized(smooth, 8, 16)
1454 intra_pred_sized(smooth, 8, 32)
1455 intra_pred_sized(smooth, 16, 4)
1456 intra_pred_sized(smooth, 16, 8)
1457 intra_pred_sized(smooth, 16, 32)
1458 intra_pred_sized(smooth, 16, 64)
1459 intra_pred_sized(smooth, 32, 8)
1460 intra_pred_sized(smooth, 32, 16)
1461 intra_pred_sized(smooth, 32, 64)
1462 intra_pred_sized(smooth, 64, 16)
1463 intra_pred_sized(smooth, 64, 32)
1464 intra_pred_sized(smooth_h, 2, 2)
1465 intra_pred_sized(smooth_h, 4, 4)
1466 intra_pred_sized(smooth_h, 8, 8)
1467 intra_pred_sized(smooth_h, 16, 16)
1468 intra_pred_sized(smooth_h, 32, 32)
1469 intra_pred_sized(smooth_h, 64, 64)
1470 intra_pred_sized(smooth_h, 4, 8)
1471 intra_pred_sized(smooth_h, 4, 16)
1472 intra_pred_sized(smooth_h, 8, 4)
1473 intra_pred_sized(smooth_h, 8, 16)
1474 intra_pred_sized(smooth_h, 8, 32)
1475 intra_pred_sized(smooth_h, 16, 4)
1476 intra_pred_sized(smooth_h, 16, 8)
1477 intra_pred_sized(smooth_h, 16, 32)
1478 intra_pred_sized(smooth_h, 16, 64)
1479 intra_pred_sized(smooth_h, 32, 8)
1480 intra_pred_sized(smooth_h, 32, 16)
1481 intra_pred_sized(smooth_h, 32, 64)
1482 intra_pred_sized(smooth_h, 64, 16)
1483 intra_pred_sized(smooth_h, 64, 32)
1484 intra_pred_sized(smooth_v, 2, 2)
1485 intra_pred_sized(smooth_v, 4, 4)
1486 intra_pred_sized(smooth_v, 8, 8)
1487 intra_pred_sized(smooth_v, 16, 16)
1488 intra_pred_sized(smooth_v, 32, 32)
1489 intra_pred_sized(smooth_v, 64, 64)
1490 intra_pred_sized(smooth_v, 4, 8)
1491 intra_pred_sized(smooth_v, 4, 16)
1492 intra_pred_sized(smooth_v, 8, 4)
1493 intra_pred_sized(smooth_v, 8, 16)
1494 intra_pred_sized(smooth_v, 8, 32)
1495 intra_pred_sized(smooth_v, 16, 4)
1496 intra_pred_sized(smooth_v, 16, 8)
1497 intra_pred_sized(smooth_v, 16, 32)
1498 intra_pred_sized(smooth_v, 16, 64)
1499 intra_pred_sized(smooth_v, 32, 8)
1500 intra_pred_sized(smooth_v, 32, 16)
1501 intra_pred_sized(smooth_v, 32, 64)
1502 intra_pred_sized(smooth_v, 64, 16)
1503 intra_pred_sized(smooth_v, 64, 32)
1504 intra_pred_sized(paeth, 2, 2)
1505 intra_pred_sized(paeth, 4, 4)
1506 intra_pred_sized(paeth, 8, 8)
1507 intra_pred_sized(paeth, 16, 16)
1508 intra_pred_sized(paeth, 32, 32)
1509 intra_pred_sized(paeth, 64, 64)
1510 intra_pred_sized(paeth, 4, 8)
1511 intra_pred_sized(paeth, 4, 16)
1512 intra_pred_sized(paeth, 8, 4)
1513 intra_pred_sized(paeth, 8, 16)
1514 intra_pred_sized(paeth, 8, 32)
1515 intra_pred_sized(paeth, 16, 4)
1516 intra_pred_sized(paeth, 16, 8)
1517 intra_pred_sized(paeth, 16, 32)
1518 intra_pred_sized(paeth, 16, 64)
1519 intra_pred_sized(paeth, 32, 8)
1520 intra_pred_sized(paeth, 32, 16)
1521 intra_pred_sized(paeth, 32, 64)
1522 intra_pred_sized(paeth, 64, 16)
1523 intra_pred_sized(paeth, 64, 32)
1524 #define intra_pred_highbd_sized(type, width, height)                        \
1525   void svt_aom_highbd_##type##_predictor_##width##x##height##_c(            \
1526       uint16_t *dst, ptrdiff_t stride, const uint16_t *above,               \
1527       const uint16_t *left, int32_t bd) {                                   \
1528     highbd_##type##_predictor(dst, stride, width, height, above, left, bd); \
1529   }
1530 
1531 intra_pred_highbd_sized(dc, 2, 2)
1532 intra_pred_highbd_sized(dc, 4, 4)
1533 intra_pred_highbd_sized(dc, 8, 8)
1534 intra_pred_highbd_sized(dc, 16, 16)
1535 intra_pred_highbd_sized(dc, 32, 32)
1536 intra_pred_highbd_sized(dc, 64, 64)
1537 intra_pred_highbd_sized(dc, 4, 8)
1538 intra_pred_highbd_sized(dc, 4, 16)
1539 intra_pred_highbd_sized(dc, 8, 4)
1540 intra_pred_highbd_sized(dc, 8, 16)
1541 intra_pred_highbd_sized(dc, 8, 32)
1542 intra_pred_highbd_sized(dc, 16, 4)
1543 intra_pred_highbd_sized(dc, 16, 8)
1544 intra_pred_highbd_sized(dc, 16, 32)
1545 intra_pred_highbd_sized(dc, 16, 64)
1546 intra_pred_highbd_sized(dc, 32, 8)
1547 intra_pred_highbd_sized(dc, 32, 16)
1548 intra_pred_highbd_sized(dc, 32, 64)
1549 intra_pred_highbd_sized(dc, 64, 16)
1550 intra_pred_highbd_sized(dc, 64, 32)
1551 
1552 intra_pred_highbd_sized(dc_128, 2, 2)
1553 intra_pred_highbd_sized(dc_128, 4, 4)
1554 intra_pred_highbd_sized(dc_128, 8, 8)
1555 intra_pred_highbd_sized(dc_128, 16, 16)
1556 intra_pred_highbd_sized(dc_128, 32, 32)
1557 intra_pred_highbd_sized(dc_128, 64, 64)
1558 
1559 intra_pred_highbd_sized(dc_128, 4, 8)
1560 intra_pred_highbd_sized(dc_128, 4, 16)
1561 intra_pred_highbd_sized(dc_128, 8, 4)
1562 intra_pred_highbd_sized(dc_128, 8, 16)
1563 intra_pred_highbd_sized(dc_128, 8, 32)
1564 intra_pred_highbd_sized(dc_128, 16, 4)
1565 intra_pred_highbd_sized(dc_128, 16, 8)
1566 intra_pred_highbd_sized(dc_128, 16, 32)
1567 intra_pred_highbd_sized(dc_128, 16, 64)
1568 intra_pred_highbd_sized(dc_128, 32, 8)
1569 intra_pred_highbd_sized(dc_128, 32, 16)
1570 intra_pred_highbd_sized(dc_128, 32, 64)
1571 intra_pred_highbd_sized(dc_128, 64, 16)
1572 intra_pred_highbd_sized(dc_128, 64, 32)
1573 
1574 intra_pred_highbd_sized(dc_left, 2, 2)
1575 intra_pred_highbd_sized(dc_left, 4, 4)
1576 intra_pred_highbd_sized(dc_left, 8, 8)
1577 intra_pred_highbd_sized(dc_left, 16, 16)
1578 intra_pred_highbd_sized(dc_left, 32, 32)
1579 intra_pred_highbd_sized(dc_left, 64, 64)
1580 
1581 intra_pred_highbd_sized(dc_left, 4, 8)
1582 intra_pred_highbd_sized(dc_left, 4, 16)
1583 intra_pred_highbd_sized(dc_left, 8, 4)
1584 intra_pred_highbd_sized(dc_left, 8, 16)
1585 intra_pred_highbd_sized(dc_left, 8, 32)
1586 intra_pred_highbd_sized(dc_left, 16, 4)
1587 intra_pred_highbd_sized(dc_left, 16, 8)
1588 intra_pred_highbd_sized(dc_left, 16, 32)
1589 intra_pred_highbd_sized(dc_left, 16, 64)
1590 intra_pred_highbd_sized(dc_left, 32, 8)
1591 intra_pred_highbd_sized(dc_left, 32, 16)
1592 intra_pred_highbd_sized(dc_left, 32, 64)
1593 intra_pred_highbd_sized(dc_left, 64, 16)
1594 intra_pred_highbd_sized(dc_left, 64, 32)
1595 
1596 intra_pred_highbd_sized(dc_top, 2, 2)
1597 intra_pred_highbd_sized(dc_top, 4, 4)
1598 intra_pred_highbd_sized(dc_top, 8, 8)
1599 intra_pred_highbd_sized(dc_top, 16, 16)
1600 intra_pred_highbd_sized(dc_top, 32, 32)
1601 intra_pred_highbd_sized(dc_top, 64, 64)
1602 
1603 intra_pred_highbd_sized(dc_top, 4, 8)
1604 intra_pred_highbd_sized(dc_top, 4, 16)
1605 intra_pred_highbd_sized(dc_top, 8, 4)
1606 intra_pred_highbd_sized(dc_top, 8, 16)
1607 intra_pred_highbd_sized(dc_top, 8, 32)
1608 intra_pred_highbd_sized(dc_top, 16, 4)
1609 intra_pred_highbd_sized(dc_top, 16, 8)
1610 intra_pred_highbd_sized(dc_top, 16, 32)
1611 intra_pred_highbd_sized(dc_top, 16, 64)
1612 intra_pred_highbd_sized(dc_top, 32, 8)
1613 intra_pred_highbd_sized(dc_top, 32, 16)
1614 intra_pred_highbd_sized(dc_top, 32, 64)
1615 intra_pred_highbd_sized(dc_top, 64, 16)
1616 intra_pred_highbd_sized(dc_top, 64, 32)
1617 
1618 intra_pred_highbd_sized(v, 2, 2)
1619 intra_pred_highbd_sized(v, 4, 4)
1620 intra_pred_highbd_sized(v, 8, 8)
1621 intra_pred_highbd_sized(v, 16, 16)
1622 intra_pred_highbd_sized(v, 32, 32)
1623 intra_pred_highbd_sized(v, 64, 64)
1624 
1625 intra_pred_highbd_sized(v, 4, 8)
1626 intra_pred_highbd_sized(v, 4, 16)
1627 intra_pred_highbd_sized(v, 8, 4)
1628 intra_pred_highbd_sized(v, 8, 16)
1629 intra_pred_highbd_sized(v, 8, 32)
1630 intra_pred_highbd_sized(v, 16, 4)
1631 intra_pred_highbd_sized(v, 16, 8)
1632 intra_pred_highbd_sized(v, 16, 32)
1633 intra_pred_highbd_sized(v, 16, 64)
1634 intra_pred_highbd_sized(v, 32, 8)
1635 intra_pred_highbd_sized(v, 32, 16)
1636 intra_pred_highbd_sized(v, 32, 64)
1637 intra_pred_highbd_sized(v, 64, 16)
1638 intra_pred_highbd_sized(v, 64, 32)
1639 
1640 intra_pred_highbd_sized(h, 2, 2)
1641 intra_pred_highbd_sized(h, 4, 4)
1642 intra_pred_highbd_sized(h, 8, 8)
1643 intra_pred_highbd_sized(h, 16, 16)
1644 intra_pred_highbd_sized(h, 32, 32)
1645 intra_pred_highbd_sized(h, 64, 64)
1646 
1647 intra_pred_highbd_sized(h, 4, 8)
1648 intra_pred_highbd_sized(h, 4, 16)
1649 intra_pred_highbd_sized(h, 8, 4)
1650 intra_pred_highbd_sized(h, 8, 16)
1651 intra_pred_highbd_sized(h, 8, 32)
1652 intra_pred_highbd_sized(h, 16, 4)
1653 intra_pred_highbd_sized(h, 16, 8)
1654 intra_pred_highbd_sized(h, 16, 32)
1655 intra_pred_highbd_sized(h, 16, 64)
1656 intra_pred_highbd_sized(h, 32, 8)
1657 intra_pred_highbd_sized(h, 32, 16)
1658 intra_pred_highbd_sized(h, 32, 64)
1659 intra_pred_highbd_sized(h, 64, 16)
1660 intra_pred_highbd_sized(h, 64, 32)
1661 
1662 intra_pred_highbd_sized(smooth, 2, 2)
1663 intra_pred_highbd_sized(smooth, 4, 4)
1664 intra_pred_highbd_sized(smooth, 8, 8)
1665 intra_pred_highbd_sized(smooth, 16, 16)
1666 intra_pred_highbd_sized(smooth, 32, 32)
1667 intra_pred_highbd_sized(smooth, 64, 64)
1668 
1669 intra_pred_highbd_sized(smooth, 4, 8)
1670 intra_pred_highbd_sized(smooth, 4, 16)
1671 intra_pred_highbd_sized(smooth, 8, 4)
1672 intra_pred_highbd_sized(smooth, 8, 16)
1673 intra_pred_highbd_sized(smooth, 8, 32)
1674 intra_pred_highbd_sized(smooth, 16, 4)
1675 intra_pred_highbd_sized(smooth, 16, 8)
1676 intra_pred_highbd_sized(smooth, 16, 32)
1677 intra_pred_highbd_sized(smooth, 16, 64)
1678 intra_pred_highbd_sized(smooth, 32, 8)
1679 intra_pred_highbd_sized(smooth, 32, 16)
1680 intra_pred_highbd_sized(smooth, 32, 64)
1681 intra_pred_highbd_sized(smooth, 64, 16)
1682 intra_pred_highbd_sized(smooth, 64, 32)
1683 
1684 intra_pred_highbd_sized(smooth_h, 2, 2)
1685 intra_pred_highbd_sized(smooth_h, 4, 4)
1686 intra_pred_highbd_sized(smooth_h, 8, 8)
1687 intra_pred_highbd_sized(smooth_h, 16, 16)
1688 intra_pred_highbd_sized(smooth_h, 32, 32)
1689 intra_pred_highbd_sized(smooth_h, 64, 64)
1690 
1691 intra_pred_highbd_sized(smooth_h, 4, 8)
1692 intra_pred_highbd_sized(smooth_h, 4, 16)
1693 intra_pred_highbd_sized(smooth_h, 8, 4)
1694 intra_pred_highbd_sized(smooth_h, 8, 16)
1695 intra_pred_highbd_sized(smooth_h, 8, 32)
1696 intra_pred_highbd_sized(smooth_h, 16, 4)
1697 intra_pred_highbd_sized(smooth_h, 16, 8)
1698 intra_pred_highbd_sized(smooth_h, 16, 32)
1699 intra_pred_highbd_sized(smooth_h, 16, 64)
1700 intra_pred_highbd_sized(smooth_h, 32, 8)
1701 intra_pred_highbd_sized(smooth_h, 32, 16)
1702 intra_pred_highbd_sized(smooth_h, 32, 64)
1703 intra_pred_highbd_sized(smooth_h, 64, 16)
1704 intra_pred_highbd_sized(smooth_h, 64, 32)
1705 
1706 intra_pred_highbd_sized(smooth_v, 2, 2)
1707 intra_pred_highbd_sized(smooth_v, 4, 4)
1708 intra_pred_highbd_sized(smooth_v, 8, 8)
1709 intra_pred_highbd_sized(smooth_v, 16, 16)
1710 intra_pred_highbd_sized(smooth_v, 32, 32)
1711 intra_pred_highbd_sized(smooth_v, 64, 64)
1712 
1713 intra_pred_highbd_sized(smooth_v, 4, 8)
1714 intra_pred_highbd_sized(smooth_v, 4, 16)
1715 intra_pred_highbd_sized(smooth_v, 8, 4)
1716 intra_pred_highbd_sized(smooth_v, 8, 16)
1717 intra_pred_highbd_sized(smooth_v, 8, 32)
1718 intra_pred_highbd_sized(smooth_v, 16, 4)
1719 intra_pred_highbd_sized(smooth_v, 16, 8)
1720 intra_pred_highbd_sized(smooth_v, 16, 32)
1721 intra_pred_highbd_sized(smooth_v, 16, 64)
1722 intra_pred_highbd_sized(smooth_v, 32, 8)
1723 intra_pred_highbd_sized(smooth_v, 32, 16)
1724 intra_pred_highbd_sized(smooth_v, 32, 64)
1725 intra_pred_highbd_sized(smooth_v, 64, 16)
1726 intra_pred_highbd_sized(smooth_v, 64, 32)
1727 
1728 intra_pred_highbd_sized(paeth, 2, 2)
1729 intra_pred_highbd_sized(paeth, 4, 4)
1730 intra_pred_highbd_sized(paeth, 8, 8)
1731 intra_pred_highbd_sized(paeth, 16, 16)
1732 intra_pred_highbd_sized(paeth, 32, 32)
1733 intra_pred_highbd_sized(paeth, 64, 64)
1734 intra_pred_highbd_sized(paeth, 4, 8)
1735 intra_pred_highbd_sized(paeth, 4, 16)
1736 intra_pred_highbd_sized(paeth, 8, 4)
1737 intra_pred_highbd_sized(paeth, 8, 16)
1738 intra_pred_highbd_sized(paeth, 8, 32)
1739 intra_pred_highbd_sized(paeth, 16, 4)
1740 intra_pred_highbd_sized(paeth, 16, 8)
1741 intra_pred_highbd_sized(paeth, 16, 32)
1742 intra_pred_highbd_sized(paeth, 16, 64)
1743 intra_pred_highbd_sized(paeth, 32, 8)
1744 intra_pred_highbd_sized(paeth, 32, 16)
1745 intra_pred_highbd_sized(paeth, 32, 64)
1746 intra_pred_highbd_sized(paeth, 64, 16)
1747 intra_pred_highbd_sized(paeth, 64, 32)
1748 
1749 IntraPredFnC  dc_pred_c[2][2];
1750 IntraHighBdPredFnC  highbd_dc_pred_c[2][2];
init_intra_dc_predictors_c_internal(void)1751 void init_intra_dc_predictors_c_internal(void)
1752 {
1753     dc_pred_c[0][0] = dc_128_predictor;
1754     dc_pred_c[0][1] = dc_top_predictor;
1755     dc_pred_c[1][0] = dc_left_predictor;
1756     dc_pred_c[1][1] = dc_predictor;
1757 
1758     highbd_dc_pred_c[0][0] = highbd_dc_128_predictor;
1759     highbd_dc_pred_c[0][1] = highbd_dc_top_predictor;
1760     highbd_dc_pred_c[1][0] = highbd_dc_left_predictor;
1761     highbd_dc_pred_c[1][1] = highbd_dc_predictor;
1762 }
1763 
init_intra_predictors_internal(void)1764 /*static*/ void init_intra_predictors_internal(void) {
1765     eb_pred[V_PRED][TX_4X4] = svt_aom_v_predictor_4x4;
1766     eb_pred[V_PRED][TX_8X8] = svt_aom_v_predictor_8x8;
1767     eb_pred[V_PRED][TX_16X16] = svt_aom_v_predictor_16x16;
1768     eb_pred[V_PRED][TX_32X32] = svt_aom_v_predictor_32x32;
1769     eb_pred[V_PRED][TX_64X64] = svt_aom_v_predictor_64x64;
1770     eb_pred[V_PRED][TX_4X8] = svt_aom_v_predictor_4x8;
1771     eb_pred[V_PRED][TX_4X16] = svt_aom_v_predictor_4x16;
1772 
1773     eb_pred[V_PRED][TX_8X4] = svt_aom_v_predictor_8x4;
1774     eb_pred[V_PRED][TX_8X16] = svt_aom_v_predictor_8x16;
1775     eb_pred[V_PRED][TX_8X32] = svt_aom_v_predictor_8x32;
1776 
1777     eb_pred[V_PRED][TX_16X4] = svt_aom_v_predictor_16x4;
1778     eb_pred[V_PRED][TX_16X8] = svt_aom_v_predictor_16x8;
1779     eb_pred[V_PRED][TX_16X32] = svt_aom_v_predictor_16x32;
1780     eb_pred[V_PRED][TX_16X64] = svt_aom_v_predictor_16x64;
1781 
1782     eb_pred[V_PRED][TX_32X8] = svt_aom_v_predictor_32x8;
1783     eb_pred[V_PRED][TX_32X16] = svt_aom_v_predictor_32x16;
1784     eb_pred[V_PRED][TX_32X64] = svt_aom_v_predictor_32x64;
1785 
1786     eb_pred[V_PRED][TX_64X16] = svt_aom_v_predictor_64x16;
1787     eb_pred[V_PRED][TX_64X32] = svt_aom_v_predictor_64x32;
1788 
1789     eb_pred[H_PRED][TX_4X4] = svt_aom_h_predictor_4x4;
1790     eb_pred[H_PRED][TX_8X8] = svt_aom_h_predictor_8x8;
1791     eb_pred[H_PRED][TX_16X16] = svt_aom_h_predictor_16x16;
1792     eb_pred[H_PRED][TX_32X32] = svt_aom_h_predictor_32x32;
1793     eb_pred[H_PRED][TX_64X64] = svt_aom_h_predictor_64x64;
1794 
1795     eb_pred[H_PRED][TX_4X8] = svt_aom_h_predictor_4x8;
1796     eb_pred[H_PRED][TX_4X16] = svt_aom_h_predictor_4x16;
1797 
1798     eb_pred[H_PRED][TX_8X4] = svt_aom_h_predictor_8x4;
1799     eb_pred[H_PRED][TX_8X16] = svt_aom_h_predictor_8x16;
1800     eb_pred[H_PRED][TX_8X32] = svt_aom_h_predictor_8x32;
1801 
1802     eb_pred[H_PRED][TX_16X4] = svt_aom_h_predictor_16x4;
1803     eb_pred[H_PRED][TX_16X8] = svt_aom_h_predictor_16x8;
1804     eb_pred[H_PRED][TX_16X32] = svt_aom_h_predictor_16x32;
1805     eb_pred[H_PRED][TX_16X64] = svt_aom_h_predictor_16x64;
1806 
1807     eb_pred[H_PRED][TX_32X8] = svt_aom_h_predictor_32x8;
1808     eb_pred[H_PRED][TX_32X16] = svt_aom_h_predictor_32x16;
1809     eb_pred[H_PRED][TX_32X64] = svt_aom_h_predictor_32x64;
1810 
1811     eb_pred[H_PRED][TX_64X16] = svt_aom_h_predictor_64x16;
1812     eb_pred[H_PRED][TX_64X32] = svt_aom_h_predictor_64x32;
1813 
1814     eb_pred[SMOOTH_PRED][TX_4X4] = svt_aom_smooth_predictor_4x4;
1815     eb_pred[SMOOTH_PRED][TX_8X8] = svt_aom_smooth_predictor_8x8;
1816     eb_pred[SMOOTH_PRED][TX_16X16] = svt_aom_smooth_predictor_16x16;
1817     eb_pred[SMOOTH_PRED][TX_32X32] = svt_aom_smooth_predictor_32x32;
1818     eb_pred[SMOOTH_PRED][TX_64X64] = svt_aom_smooth_predictor_64x64;
1819 
1820     eb_pred[SMOOTH_PRED][TX_4X8] = svt_aom_smooth_predictor_4x8;
1821     eb_pred[SMOOTH_PRED][TX_4X16] = svt_aom_smooth_predictor_4x16;
1822 
1823     eb_pred[SMOOTH_PRED][TX_8X4] = svt_aom_smooth_predictor_8x4;
1824     eb_pred[SMOOTH_PRED][TX_8X16] = svt_aom_smooth_predictor_8x16;
1825     eb_pred[SMOOTH_PRED][TX_8X32] = svt_aom_smooth_predictor_8x32;
1826 
1827     eb_pred[SMOOTH_PRED][TX_16X4] = svt_aom_smooth_predictor_16x4;
1828     eb_pred[SMOOTH_PRED][TX_16X8] = svt_aom_smooth_predictor_16x8;
1829     eb_pred[SMOOTH_PRED][TX_16X32] = svt_aom_smooth_predictor_16x32;
1830     eb_pred[SMOOTH_PRED][TX_16X64] = svt_aom_smooth_predictor_16x64;
1831 
1832     eb_pred[SMOOTH_PRED][TX_32X8] = svt_aom_smooth_predictor_32x8;
1833     eb_pred[SMOOTH_PRED][TX_32X16] = svt_aom_smooth_predictor_32x16;
1834     eb_pred[SMOOTH_PRED][TX_32X64] = svt_aom_smooth_predictor_32x64;
1835 
1836     eb_pred[SMOOTH_PRED][TX_64X16] = svt_aom_smooth_predictor_64x16;
1837     eb_pred[SMOOTH_PRED][TX_64X32] = svt_aom_smooth_predictor_64x32;
1838 
1839     eb_pred[SMOOTH_V_PRED][TX_4X4] = svt_aom_smooth_v_predictor_4x4;
1840     eb_pred[SMOOTH_V_PRED][TX_8X8] = svt_aom_smooth_v_predictor_8x8;
1841     eb_pred[SMOOTH_V_PRED][TX_16X16] = svt_aom_smooth_v_predictor_16x16;
1842     eb_pred[SMOOTH_V_PRED][TX_32X32] = svt_aom_smooth_v_predictor_32x32;
1843     eb_pred[SMOOTH_V_PRED][TX_64X64] = svt_aom_smooth_v_predictor_64x64;
1844 
1845     eb_pred[SMOOTH_V_PRED][TX_4X8] = svt_aom_smooth_v_predictor_4x8;
1846     eb_pred[SMOOTH_V_PRED][TX_4X16] = svt_aom_smooth_v_predictor_4x16;
1847 
1848     eb_pred[SMOOTH_V_PRED][TX_8X4] = svt_aom_smooth_v_predictor_8x4;
1849     eb_pred[SMOOTH_V_PRED][TX_8X16] = svt_aom_smooth_v_predictor_8x16;
1850     eb_pred[SMOOTH_V_PRED][TX_8X32] = svt_aom_smooth_v_predictor_8x32;
1851 
1852     eb_pred[SMOOTH_V_PRED][TX_16X4] = svt_aom_smooth_v_predictor_16x4;
1853     eb_pred[SMOOTH_V_PRED][TX_16X8] = svt_aom_smooth_v_predictor_16x8;
1854     eb_pred[SMOOTH_V_PRED][TX_16X32] = svt_aom_smooth_v_predictor_16x32;
1855     eb_pred[SMOOTH_V_PRED][TX_16X64] = svt_aom_smooth_v_predictor_16x64;
1856 
1857     eb_pred[SMOOTH_V_PRED][TX_32X8] = svt_aom_smooth_v_predictor_32x8;
1858     eb_pred[SMOOTH_V_PRED][TX_32X16] = svt_aom_smooth_v_predictor_32x16;
1859     eb_pred[SMOOTH_V_PRED][TX_32X64] = svt_aom_smooth_v_predictor_32x64;
1860 
1861     eb_pred[SMOOTH_V_PRED][TX_64X16] = svt_aom_smooth_v_predictor_64x16;
1862     eb_pred[SMOOTH_V_PRED][TX_64X32] = svt_aom_smooth_v_predictor_64x32;
1863 
1864     eb_pred[SMOOTH_H_PRED][TX_4X4] = svt_aom_smooth_h_predictor_4x4;
1865     eb_pred[SMOOTH_H_PRED][TX_8X8] = svt_aom_smooth_h_predictor_8x8;
1866     eb_pred[SMOOTH_H_PRED][TX_16X16] = svt_aom_smooth_h_predictor_16x16;
1867     eb_pred[SMOOTH_H_PRED][TX_32X32] = svt_aom_smooth_h_predictor_32x32;
1868     eb_pred[SMOOTH_H_PRED][TX_64X64] = svt_aom_smooth_h_predictor_64x64;
1869 
1870     eb_pred[SMOOTH_H_PRED][TX_4X8] = svt_aom_smooth_h_predictor_4x8;
1871     eb_pred[SMOOTH_H_PRED][TX_4X16] = svt_aom_smooth_h_predictor_4x16;
1872 
1873     eb_pred[SMOOTH_H_PRED][TX_8X4] = svt_aom_smooth_h_predictor_8x4;
1874     eb_pred[SMOOTH_H_PRED][TX_8X16] = svt_aom_smooth_h_predictor_8x16;
1875     eb_pred[SMOOTH_H_PRED][TX_8X32] = svt_aom_smooth_h_predictor_8x32;
1876 
1877     eb_pred[SMOOTH_H_PRED][TX_16X4] = svt_aom_smooth_h_predictor_16x4;
1878     eb_pred[SMOOTH_H_PRED][TX_16X8] = svt_aom_smooth_h_predictor_16x8;
1879     eb_pred[SMOOTH_H_PRED][TX_16X32] = svt_aom_smooth_h_predictor_16x32;
1880     eb_pred[SMOOTH_H_PRED][TX_16X64] = svt_aom_smooth_h_predictor_16x64;
1881 
1882     eb_pred[SMOOTH_H_PRED][TX_32X8] = svt_aom_smooth_h_predictor_32x8;
1883     eb_pred[SMOOTH_H_PRED][TX_32X16] = svt_aom_smooth_h_predictor_32x16;
1884     eb_pred[SMOOTH_H_PRED][TX_32X64] = svt_aom_smooth_h_predictor_32x64;
1885 
1886     eb_pred[SMOOTH_H_PRED][TX_64X16] = svt_aom_smooth_h_predictor_64x16;
1887     eb_pred[SMOOTH_H_PRED][TX_64X32] = svt_aom_smooth_h_predictor_64x32;
1888 
1889     eb_pred[PAETH_PRED][TX_4X4] = svt_aom_paeth_predictor_4x4;
1890     eb_pred[PAETH_PRED][TX_8X8] = svt_aom_paeth_predictor_8x8;
1891     eb_pred[PAETH_PRED][TX_16X16] = svt_aom_paeth_predictor_16x16;
1892     eb_pred[PAETH_PRED][TX_32X32] = svt_aom_paeth_predictor_32x32;
1893     eb_pred[PAETH_PRED][TX_64X64] = svt_aom_paeth_predictor_64x64;
1894 
1895     eb_pred[PAETH_PRED][TX_4X8] = svt_aom_paeth_predictor_4x8;
1896     eb_pred[PAETH_PRED][TX_4X16] = svt_aom_paeth_predictor_4x16;
1897 
1898     eb_pred[PAETH_PRED][TX_8X4] = svt_aom_paeth_predictor_8x4;
1899     eb_pred[PAETH_PRED][TX_8X16] = svt_aom_paeth_predictor_8x16;
1900     eb_pred[PAETH_PRED][TX_8X32] = svt_aom_paeth_predictor_8x32;
1901 
1902     eb_pred[PAETH_PRED][TX_16X4] = svt_aom_paeth_predictor_16x4;
1903     eb_pred[PAETH_PRED][TX_16X8] = svt_aom_paeth_predictor_16x8;
1904     eb_pred[PAETH_PRED][TX_16X32] = svt_aom_paeth_predictor_16x32;
1905     eb_pred[PAETH_PRED][TX_16X64] = svt_aom_paeth_predictor_16x64;
1906 
1907     eb_pred[PAETH_PRED][TX_32X8] = svt_aom_paeth_predictor_32x8;
1908     eb_pred[PAETH_PRED][TX_32X16] = svt_aom_paeth_predictor_32x16;
1909     eb_pred[PAETH_PRED][TX_32X64] = svt_aom_paeth_predictor_32x64;
1910 
1911     eb_pred[PAETH_PRED][TX_64X16] = svt_aom_paeth_predictor_64x16;
1912     eb_pred[PAETH_PRED][TX_64X32] = svt_aom_paeth_predictor_64x32;
1913     dc_pred[0][0][TX_4X4] = svt_aom_dc_128_predictor_4x4;
1914     dc_pred[0][0][TX_8X8] = svt_aom_dc_128_predictor_8x8;
1915     dc_pred[0][0][TX_16X16] = svt_aom_dc_128_predictor_16x16;
1916     dc_pred[0][0][TX_32X32] = svt_aom_dc_128_predictor_32x32;
1917     dc_pred[0][0][TX_64X64] = svt_aom_dc_128_predictor_64x64;
1918 
1919     dc_pred[0][0][TX_4X8] = svt_aom_dc_128_predictor_4x8;
1920     dc_pred[0][0][TX_4X16] = svt_aom_dc_128_predictor_4x16;
1921 
1922     dc_pred[0][0][TX_8X4] = svt_aom_dc_128_predictor_8x4;
1923     dc_pred[0][0][TX_8X16] = svt_aom_dc_128_predictor_8x16;
1924     dc_pred[0][0][TX_8X32] = svt_aom_dc_128_predictor_8x32;
1925 
1926     dc_pred[0][0][TX_16X4] = svt_aom_dc_128_predictor_16x4;
1927     dc_pred[0][0][TX_16X8] = svt_aom_dc_128_predictor_16x8;
1928     dc_pred[0][0][TX_16X32] = svt_aom_dc_128_predictor_16x32;
1929     dc_pred[0][0][TX_16X64] = svt_aom_dc_128_predictor_16x64;
1930 
1931     dc_pred[0][0][TX_32X8] = svt_aom_dc_128_predictor_32x8;
1932     dc_pred[0][0][TX_32X16] = svt_aom_dc_128_predictor_32x16;
1933     dc_pred[0][0][TX_32X64] = svt_aom_dc_128_predictor_32x64;
1934 
1935     dc_pred[0][0][TX_64X16] = svt_aom_dc_128_predictor_64x16;
1936     dc_pred[0][0][TX_64X32] = svt_aom_dc_128_predictor_64x32;
1937 
1938     dc_pred[0][1][TX_4X4] = svt_aom_dc_top_predictor_4x4;
1939     dc_pred[0][1][TX_8X8] = svt_aom_dc_top_predictor_8x8;
1940     dc_pred[0][1][TX_16X16] = svt_aom_dc_top_predictor_16x16;
1941     dc_pred[0][1][TX_32X32] = svt_aom_dc_top_predictor_32x32;
1942     dc_pred[0][1][TX_64X64] = svt_aom_dc_top_predictor_64x64;
1943 
1944     dc_pred[0][1][TX_4X8] = svt_aom_dc_top_predictor_4x8;
1945     dc_pred[0][1][TX_4X16] = svt_aom_dc_top_predictor_4x16;
1946 
1947     dc_pred[0][1][TX_8X4] = svt_aom_dc_top_predictor_8x4;
1948     dc_pred[0][1][TX_8X16] = svt_aom_dc_top_predictor_8x16;
1949     dc_pred[0][1][TX_8X32] = svt_aom_dc_top_predictor_8x32;
1950 
1951     dc_pred[0][1][TX_16X4] = svt_aom_dc_top_predictor_16x4;
1952     dc_pred[0][1][TX_16X8] = svt_aom_dc_top_predictor_16x8;
1953     dc_pred[0][1][TX_16X32] = svt_aom_dc_top_predictor_16x32;
1954     dc_pred[0][1][TX_16X64] = svt_aom_dc_top_predictor_16x64;
1955 
1956     dc_pred[0][1][TX_32X8] = svt_aom_dc_top_predictor_32x8;
1957     dc_pred[0][1][TX_32X16] = svt_aom_dc_top_predictor_32x16;
1958     dc_pred[0][1][TX_32X64] = svt_aom_dc_top_predictor_32x64;
1959 
1960     dc_pred[0][1][TX_64X16] = svt_aom_dc_top_predictor_64x16;
1961     dc_pred[0][1][TX_64X32] = svt_aom_dc_top_predictor_64x32;
1962 
1963     dc_pred[1][0][TX_4X4] = svt_aom_dc_left_predictor_4x4;
1964     dc_pred[1][0][TX_8X8] = svt_aom_dc_left_predictor_8x8;
1965     dc_pred[1][0][TX_16X16] = svt_aom_dc_left_predictor_16x16;
1966     dc_pred[1][0][TX_32X32] = svt_aom_dc_left_predictor_32x32;
1967     dc_pred[1][0][TX_64X64] = svt_aom_dc_left_predictor_64x64;
1968     dc_pred[1][0][TX_4X8] = svt_aom_dc_left_predictor_4x8;
1969     dc_pred[1][0][TX_4X16] = svt_aom_dc_left_predictor_4x16;
1970 
1971     dc_pred[1][0][TX_8X4] = svt_aom_dc_left_predictor_8x4;
1972     dc_pred[1][0][TX_8X16] = svt_aom_dc_left_predictor_8x16;
1973     dc_pred[1][0][TX_8X32] = svt_aom_dc_left_predictor_8x32;
1974 
1975     dc_pred[1][0][TX_16X4] = svt_aom_dc_left_predictor_16x4;
1976     dc_pred[1][0][TX_16X8] = svt_aom_dc_left_predictor_16x8;
1977     dc_pred[1][0][TX_16X32] = svt_aom_dc_left_predictor_16x32;
1978     dc_pred[1][0][TX_16X64] = svt_aom_dc_left_predictor_16x64;
1979 
1980     dc_pred[1][0][TX_32X8] = svt_aom_dc_left_predictor_32x8;
1981     dc_pred[1][0][TX_32X16] = svt_aom_dc_left_predictor_32x16;
1982     dc_pred[1][0][TX_32X64] = svt_aom_dc_left_predictor_32x64;
1983 
1984     dc_pred[1][0][TX_64X16] = svt_aom_dc_left_predictor_64x16;
1985     dc_pred[1][0][TX_64X32] = svt_aom_dc_left_predictor_64x32;
1986 
1987     dc_pred[1][1][TX_4X4] = svt_aom_dc_predictor_4x4;
1988     dc_pred[1][1][TX_8X8] = svt_aom_dc_predictor_8x8;
1989     dc_pred[1][1][TX_16X16] = svt_aom_dc_predictor_16x16;
1990     dc_pred[1][1][TX_32X32] = svt_aom_dc_predictor_32x32;
1991     dc_pred[1][1][TX_64X64] = svt_aom_dc_predictor_64x64;
1992     dc_pred[1][1][TX_4X8] = svt_aom_dc_predictor_4x8;
1993     dc_pred[1][1][TX_4X16] = svt_aom_dc_predictor_4x16;
1994 
1995     dc_pred[1][1][TX_8X4] = svt_aom_dc_predictor_8x4;
1996     dc_pred[1][1][TX_8X16] = svt_aom_dc_predictor_8x16;
1997     dc_pred[1][1][TX_8X32] = svt_aom_dc_predictor_8x32;
1998 
1999     dc_pred[1][1][TX_16X4] = svt_aom_dc_predictor_16x4;
2000     dc_pred[1][1][TX_16X8] = svt_aom_dc_predictor_16x8;
2001     dc_pred[1][1][TX_16X32] = svt_aom_dc_predictor_16x32;
2002     dc_pred[1][1][TX_16X64] = svt_aom_dc_predictor_16x64;
2003 
2004     dc_pred[1][1][TX_32X8] = svt_aom_dc_predictor_32x8;
2005     dc_pred[1][1][TX_32X16] = svt_aom_dc_predictor_32x16;
2006     dc_pred[1][1][TX_32X64] = svt_aom_dc_predictor_32x64;
2007 
2008     dc_pred[1][1][TX_64X16] = svt_aom_dc_predictor_64x16;
2009     dc_pred[1][1][TX_64X32] = svt_aom_dc_predictor_64x32;
2010 
2011     pred_high[V_PRED][TX_4X4] = svt_aom_highbd_v_predictor_4x4;
2012     pred_high[V_PRED][TX_8X8] = svt_aom_highbd_v_predictor_8x8;
2013     pred_high[V_PRED][TX_16X16] = svt_aom_highbd_v_predictor_16x16;
2014     pred_high[V_PRED][TX_32X32] = svt_aom_highbd_v_predictor_32x32;
2015     pred_high[V_PRED][TX_64X64] = svt_aom_highbd_v_predictor_64x64;
2016 
2017     pred_high[V_PRED][TX_4X8] = svt_aom_highbd_v_predictor_4x8;
2018     pred_high[V_PRED][TX_4X16] = svt_aom_highbd_v_predictor_4x16;
2019 
2020     pred_high[V_PRED][TX_8X4] = svt_aom_highbd_v_predictor_8x4;
2021     pred_high[V_PRED][TX_8X16] = svt_aom_highbd_v_predictor_8x16;
2022     pred_high[V_PRED][TX_8X32] = svt_aom_highbd_v_predictor_8x32;
2023 
2024     pred_high[V_PRED][TX_16X4] = svt_aom_highbd_v_predictor_16x4;
2025     pred_high[V_PRED][TX_16X8] = svt_aom_highbd_v_predictor_16x8;
2026     pred_high[V_PRED][TX_16X32] = svt_aom_highbd_v_predictor_16x32;
2027     pred_high[V_PRED][TX_16X64] = svt_aom_highbd_v_predictor_16x64;
2028 
2029     pred_high[V_PRED][TX_32X8] = svt_aom_highbd_v_predictor_32x8;
2030     pred_high[V_PRED][TX_32X16] = svt_aom_highbd_v_predictor_32x16;
2031     pred_high[V_PRED][TX_32X64] = svt_aom_highbd_v_predictor_32x64;
2032 
2033     pred_high[V_PRED][TX_64X16] = svt_aom_highbd_v_predictor_64x16;
2034     pred_high[V_PRED][TX_64X32] = svt_aom_highbd_v_predictor_64x32;
2035 
2036     pred_high[H_PRED][TX_4X4] = svt_aom_highbd_h_predictor_4x4;
2037     pred_high[H_PRED][TX_8X8] = svt_aom_highbd_h_predictor_8x8;
2038     pred_high[H_PRED][TX_16X16] = svt_aom_highbd_h_predictor_16x16;
2039     pred_high[H_PRED][TX_32X32] = svt_aom_highbd_h_predictor_32x32;
2040     pred_high[H_PRED][TX_64X64] = svt_aom_highbd_h_predictor_64x64;
2041 
2042     pred_high[H_PRED][TX_4X8] = svt_aom_highbd_h_predictor_4x8;
2043     pred_high[H_PRED][TX_4X16] = svt_aom_highbd_h_predictor_4x16;
2044 
2045     pred_high[H_PRED][TX_8X4] = svt_aom_highbd_h_predictor_8x4;
2046     pred_high[H_PRED][TX_8X16] = svt_aom_highbd_h_predictor_8x16;
2047     pred_high[H_PRED][TX_8X32] = svt_aom_highbd_h_predictor_8x32;
2048 
2049     pred_high[H_PRED][TX_16X4] = svt_aom_highbd_h_predictor_16x4;
2050     pred_high[H_PRED][TX_16X8] = svt_aom_highbd_h_predictor_16x8;
2051     pred_high[H_PRED][TX_16X32] = svt_aom_highbd_h_predictor_16x32;
2052     pred_high[H_PRED][TX_16X64] = svt_aom_highbd_h_predictor_16x64;
2053 
2054     pred_high[H_PRED][TX_32X8] = svt_aom_highbd_h_predictor_32x8;
2055     pred_high[H_PRED][TX_32X16] = svt_aom_highbd_h_predictor_32x16;
2056     pred_high[H_PRED][TX_32X64] = svt_aom_highbd_h_predictor_32x64;
2057 
2058     pred_high[H_PRED][TX_64X16] = svt_aom_highbd_h_predictor_64x16;
2059     pred_high[H_PRED][TX_64X32] = svt_aom_highbd_h_predictor_64x32;
2060 
2061     pred_high[SMOOTH_PRED][TX_4X4] = svt_aom_highbd_smooth_predictor_4x4;
2062     pred_high[SMOOTH_PRED][TX_8X8] = svt_aom_highbd_smooth_predictor_8x8;
2063     pred_high[SMOOTH_PRED][TX_16X16] = svt_aom_highbd_smooth_predictor_16x16;
2064     pred_high[SMOOTH_PRED][TX_32X32] = svt_aom_highbd_smooth_predictor_32x32;
2065     pred_high[SMOOTH_PRED][TX_64X64] = svt_aom_highbd_smooth_predictor_64x64;
2066 
2067     pred_high[SMOOTH_PRED][TX_4X8] = svt_aom_highbd_smooth_predictor_4x8;
2068     pred_high[SMOOTH_PRED][TX_4X16] = svt_aom_highbd_smooth_predictor_4x16;
2069 
2070     pred_high[SMOOTH_PRED][TX_8X4] = svt_aom_highbd_smooth_predictor_8x4;
2071     pred_high[SMOOTH_PRED][TX_8X16] = svt_aom_highbd_smooth_predictor_8x16;
2072     pred_high[SMOOTH_PRED][TX_8X32] = svt_aom_highbd_smooth_predictor_8x32;
2073 
2074     pred_high[SMOOTH_PRED][TX_16X4] = svt_aom_highbd_smooth_predictor_16x4;
2075     pred_high[SMOOTH_PRED][TX_16X8] = svt_aom_highbd_smooth_predictor_16x8;
2076     pred_high[SMOOTH_PRED][TX_16X32] = svt_aom_highbd_smooth_predictor_16x32;
2077     pred_high[SMOOTH_PRED][TX_16X64] = svt_aom_highbd_smooth_predictor_16x64;
2078 
2079     pred_high[SMOOTH_PRED][TX_32X8] = svt_aom_highbd_smooth_predictor_32x8;
2080     pred_high[SMOOTH_PRED][TX_32X16] = svt_aom_highbd_smooth_predictor_32x16;
2081     pred_high[SMOOTH_PRED][TX_32X64] = svt_aom_highbd_smooth_predictor_32x64;
2082 
2083     pred_high[SMOOTH_PRED][TX_64X16] = svt_aom_highbd_smooth_predictor_64x16;
2084     pred_high[SMOOTH_PRED][TX_64X32] = svt_aom_highbd_smooth_predictor_64x32;
2085 
2086     pred_high[SMOOTH_V_PRED][TX_4X4] = svt_aom_highbd_smooth_v_predictor_4x4;
2087     pred_high[SMOOTH_V_PRED][TX_8X8] = svt_aom_highbd_smooth_v_predictor_8x8;
2088     pred_high[SMOOTH_V_PRED][TX_16X16] = svt_aom_highbd_smooth_v_predictor_16x16;
2089     pred_high[SMOOTH_V_PRED][TX_32X32] = svt_aom_highbd_smooth_v_predictor_32x32;
2090     pred_high[SMOOTH_V_PRED][TX_64X64] = svt_aom_highbd_smooth_v_predictor_64x64;
2091 
2092     pred_high[SMOOTH_V_PRED][TX_4X8] = svt_aom_highbd_smooth_v_predictor_4x8;
2093     pred_high[SMOOTH_V_PRED][TX_4X16] = svt_aom_highbd_smooth_v_predictor_4x16;
2094 
2095     pred_high[SMOOTH_V_PRED][TX_8X4] = svt_aom_highbd_smooth_v_predictor_8x4;
2096     pred_high[SMOOTH_V_PRED][TX_8X16] = svt_aom_highbd_smooth_v_predictor_8x16;
2097     pred_high[SMOOTH_V_PRED][TX_8X32] = svt_aom_highbd_smooth_v_predictor_8x32;
2098 
2099     pred_high[SMOOTH_V_PRED][TX_16X4] = svt_aom_highbd_smooth_v_predictor_16x4;
2100     pred_high[SMOOTH_V_PRED][TX_16X8] = svt_aom_highbd_smooth_v_predictor_16x8;
2101     pred_high[SMOOTH_V_PRED][TX_16X32] = svt_aom_highbd_smooth_v_predictor_16x32;
2102     pred_high[SMOOTH_V_PRED][TX_16X64] = svt_aom_highbd_smooth_v_predictor_16x64;
2103 
2104     pred_high[SMOOTH_V_PRED][TX_32X8] = svt_aom_highbd_smooth_v_predictor_32x8;
2105     pred_high[SMOOTH_V_PRED][TX_32X16] = svt_aom_highbd_smooth_v_predictor_32x16;
2106     pred_high[SMOOTH_V_PRED][TX_32X64] = svt_aom_highbd_smooth_v_predictor_32x64;
2107 
2108     pred_high[SMOOTH_V_PRED][TX_64X16] = svt_aom_highbd_smooth_v_predictor_64x16;
2109     pred_high[SMOOTH_V_PRED][TX_64X32] = svt_aom_highbd_smooth_v_predictor_64x32;
2110 
2111     pred_high[SMOOTH_H_PRED][TX_4X4] = svt_aom_highbd_smooth_h_predictor_4x4;
2112     pred_high[SMOOTH_H_PRED][TX_8X8] = svt_aom_highbd_smooth_h_predictor_8x8;
2113     pred_high[SMOOTH_H_PRED][TX_16X16] = svt_aom_highbd_smooth_h_predictor_16x16;
2114     pred_high[SMOOTH_H_PRED][TX_32X32] = svt_aom_highbd_smooth_h_predictor_32x32;
2115     pred_high[SMOOTH_H_PRED][TX_64X64] = svt_aom_highbd_smooth_h_predictor_64x64;
2116 
2117     pred_high[SMOOTH_H_PRED][TX_4X8] = svt_aom_highbd_smooth_h_predictor_4x8;
2118     pred_high[SMOOTH_H_PRED][TX_4X16] = svt_aom_highbd_smooth_h_predictor_4x16;
2119 
2120     pred_high[SMOOTH_H_PRED][TX_8X4] = svt_aom_highbd_smooth_h_predictor_8x4;
2121     pred_high[SMOOTH_H_PRED][TX_8X16] = svt_aom_highbd_smooth_h_predictor_8x16;
2122     pred_high[SMOOTH_H_PRED][TX_8X32] = svt_aom_highbd_smooth_h_predictor_8x32;
2123 
2124     pred_high[SMOOTH_H_PRED][TX_16X4] = svt_aom_highbd_smooth_h_predictor_16x4;
2125     pred_high[SMOOTH_H_PRED][TX_16X8] = svt_aom_highbd_smooth_h_predictor_16x8;
2126     pred_high[SMOOTH_H_PRED][TX_16X32] = svt_aom_highbd_smooth_h_predictor_16x32;
2127     pred_high[SMOOTH_H_PRED][TX_16X64] = svt_aom_highbd_smooth_h_predictor_16x64;
2128 
2129     pred_high[SMOOTH_H_PRED][TX_32X8] = svt_aom_highbd_smooth_h_predictor_32x8;
2130     pred_high[SMOOTH_H_PRED][TX_32X16] = svt_aom_highbd_smooth_h_predictor_32x16;
2131     pred_high[SMOOTH_H_PRED][TX_32X64] = svt_aom_highbd_smooth_h_predictor_32x64;
2132 
2133     pred_high[SMOOTH_H_PRED][TX_64X16] = svt_aom_highbd_smooth_h_predictor_64x16;
2134     pred_high[SMOOTH_H_PRED][TX_64X32] = svt_aom_highbd_smooth_h_predictor_64x32;
2135 
2136     pred_high[PAETH_PRED][TX_4X4] = svt_aom_highbd_paeth_predictor_4x4;
2137     pred_high[PAETH_PRED][TX_8X8] = svt_aom_highbd_paeth_predictor_8x8;
2138     pred_high[PAETH_PRED][TX_16X16] = svt_aom_highbd_paeth_predictor_16x16;
2139     pred_high[PAETH_PRED][TX_32X32] = svt_aom_highbd_paeth_predictor_32x32;
2140     pred_high[PAETH_PRED][TX_64X64] = svt_aom_highbd_paeth_predictor_64x64;
2141 
2142     pred_high[PAETH_PRED][TX_4X8] = svt_aom_highbd_paeth_predictor_4x8;
2143     pred_high[PAETH_PRED][TX_4X16] = svt_aom_highbd_paeth_predictor_4x16;
2144 
2145     pred_high[PAETH_PRED][TX_8X4] = svt_aom_highbd_paeth_predictor_8x4;
2146     pred_high[PAETH_PRED][TX_8X16] = svt_aom_highbd_paeth_predictor_8x16;
2147     pred_high[PAETH_PRED][TX_8X32] = svt_aom_highbd_paeth_predictor_8x32;
2148 
2149     pred_high[PAETH_PRED][TX_16X4] = svt_aom_highbd_paeth_predictor_16x4;
2150     pred_high[PAETH_PRED][TX_16X8] = svt_aom_highbd_paeth_predictor_16x8;
2151     pred_high[PAETH_PRED][TX_16X32] = svt_aom_highbd_paeth_predictor_16x32;
2152     pred_high[PAETH_PRED][TX_16X64] = svt_aom_highbd_paeth_predictor_16x64;
2153 
2154     pred_high[PAETH_PRED][TX_32X8] = svt_aom_highbd_paeth_predictor_32x8;
2155     pred_high[PAETH_PRED][TX_32X16] = svt_aom_highbd_paeth_predictor_32x16;
2156     pred_high[PAETH_PRED][TX_32X64] = svt_aom_highbd_paeth_predictor_32x64;
2157 
2158     pred_high[PAETH_PRED][TX_64X16] = svt_aom_highbd_paeth_predictor_64x16;
2159     pred_high[PAETH_PRED][TX_64X32] = svt_aom_highbd_paeth_predictor_64x32;
2160     dc_pred_high[0][0][TX_4X4] = svt_aom_highbd_dc_128_predictor_4x4;
2161     dc_pred_high[0][0][TX_8X8] = svt_aom_highbd_dc_128_predictor_8x8;
2162     dc_pred_high[0][0][TX_16X16] = svt_aom_highbd_dc_128_predictor_16x16;
2163     dc_pred_high[0][0][TX_32X32] = svt_aom_highbd_dc_128_predictor_32x32;
2164     dc_pred_high[0][0][TX_64X64] = svt_aom_highbd_dc_128_predictor_64x64;
2165 
2166     dc_pred_high[0][0][TX_4X8] = svt_aom_highbd_dc_128_predictor_4x8;
2167     dc_pred_high[0][0][TX_4X16] = svt_aom_highbd_dc_128_predictor_4x16;
2168 
2169     dc_pred_high[0][0][TX_8X4] = svt_aom_highbd_dc_128_predictor_8x4;
2170     dc_pred_high[0][0][TX_8X16] = svt_aom_highbd_dc_128_predictor_8x16;
2171     dc_pred_high[0][0][TX_8X32] = svt_aom_highbd_dc_128_predictor_8x32;
2172 
2173     dc_pred_high[0][0][TX_16X4] = svt_aom_highbd_dc_128_predictor_16x4;
2174     dc_pred_high[0][0][TX_16X8] = svt_aom_highbd_dc_128_predictor_16x8;
2175     dc_pred_high[0][0][TX_16X32] = svt_aom_highbd_dc_128_predictor_16x32;
2176     dc_pred_high[0][0][TX_16X64] = svt_aom_highbd_dc_128_predictor_16x64;
2177 
2178     dc_pred_high[0][0][TX_32X8] = svt_aom_highbd_dc_128_predictor_32x8;
2179     dc_pred_high[0][0][TX_32X16] = svt_aom_highbd_dc_128_predictor_32x16;
2180     dc_pred_high[0][0][TX_32X64] = svt_aom_highbd_dc_128_predictor_32x64;
2181 
2182     dc_pred_high[0][0][TX_64X16] = svt_aom_highbd_dc_128_predictor_64x16;
2183     dc_pred_high[0][0][TX_64X32] = svt_aom_highbd_dc_128_predictor_64x32;
2184 
2185     dc_pred_high[0][1][TX_4X4] = svt_aom_highbd_dc_top_predictor_4x4;
2186     dc_pred_high[0][1][TX_8X8] = svt_aom_highbd_dc_top_predictor_8x8;
2187     dc_pred_high[0][1][TX_16X16] = svt_aom_highbd_dc_top_predictor_16x16;
2188     dc_pred_high[0][1][TX_32X32] = svt_aom_highbd_dc_top_predictor_32x32;
2189     dc_pred_high[0][1][TX_64X64] = svt_aom_highbd_dc_top_predictor_64x64;
2190 
2191     dc_pred_high[0][1][TX_4X8] = svt_aom_highbd_dc_top_predictor_4x8;
2192     dc_pred_high[0][1][TX_4X16] = svt_aom_highbd_dc_top_predictor_4x16;
2193 
2194     dc_pred_high[0][1][TX_8X4] = svt_aom_highbd_dc_top_predictor_8x4;
2195     dc_pred_high[0][1][TX_8X16] = svt_aom_highbd_dc_top_predictor_8x16;
2196     dc_pred_high[0][1][TX_8X32] = svt_aom_highbd_dc_top_predictor_8x32;
2197 
2198     dc_pred_high[0][1][TX_16X4] = svt_aom_highbd_dc_top_predictor_16x4;
2199     dc_pred_high[0][1][TX_16X8] = svt_aom_highbd_dc_top_predictor_16x8;
2200     dc_pred_high[0][1][TX_16X32] = svt_aom_highbd_dc_top_predictor_16x32;
2201     dc_pred_high[0][1][TX_16X64] = svt_aom_highbd_dc_top_predictor_16x64;
2202 
2203     dc_pred_high[0][1][TX_32X8] = svt_aom_highbd_dc_top_predictor_32x8;
2204     dc_pred_high[0][1][TX_32X16] = svt_aom_highbd_dc_top_predictor_32x16;
2205     dc_pred_high[0][1][TX_32X64] = svt_aom_highbd_dc_top_predictor_32x64;
2206 
2207     dc_pred_high[0][1][TX_64X16] = svt_aom_highbd_dc_top_predictor_64x16;
2208     dc_pred_high[0][1][TX_64X32] = svt_aom_highbd_dc_top_predictor_64x32;
2209 
2210     dc_pred_high[1][0][TX_4X4] = svt_aom_highbd_dc_left_predictor_4x4;
2211     dc_pred_high[1][0][TX_8X8] = svt_aom_highbd_dc_left_predictor_8x8;
2212     dc_pred_high[1][0][TX_16X16] = svt_aom_highbd_dc_left_predictor_16x16;
2213     dc_pred_high[1][0][TX_32X32] = svt_aom_highbd_dc_left_predictor_32x32;
2214     dc_pred_high[1][0][TX_64X64] = svt_aom_highbd_dc_left_predictor_64x64;
2215 
2216     dc_pred_high[1][0][TX_4X8] = svt_aom_highbd_dc_left_predictor_4x8;
2217     dc_pred_high[1][0][TX_4X16] = svt_aom_highbd_dc_left_predictor_4x16;
2218 
2219     dc_pred_high[1][0][TX_8X4] = svt_aom_highbd_dc_left_predictor_8x4;
2220     dc_pred_high[1][0][TX_8X16] = svt_aom_highbd_dc_left_predictor_8x16;
2221     dc_pred_high[1][0][TX_8X32] = svt_aom_highbd_dc_left_predictor_8x32;
2222 
2223     dc_pred_high[1][0][TX_16X4] = svt_aom_highbd_dc_left_predictor_16x4;
2224     dc_pred_high[1][0][TX_16X8] = svt_aom_highbd_dc_left_predictor_16x8;
2225     dc_pred_high[1][0][TX_16X32] = svt_aom_highbd_dc_left_predictor_16x32;
2226     dc_pred_high[1][0][TX_16X64] = svt_aom_highbd_dc_left_predictor_16x64;
2227 
2228     dc_pred_high[1][0][TX_32X8] = svt_aom_highbd_dc_left_predictor_32x8;
2229     dc_pred_high[1][0][TX_32X16] = svt_aom_highbd_dc_left_predictor_32x16;
2230     dc_pred_high[1][0][TX_32X64] = svt_aom_highbd_dc_left_predictor_32x64;
2231 
2232     dc_pred_high[1][0][TX_64X16] = svt_aom_highbd_dc_left_predictor_64x16;
2233     dc_pred_high[1][0][TX_64X32] = svt_aom_highbd_dc_left_predictor_64x32;
2234 
2235     dc_pred_high[1][1][TX_4X4] = svt_aom_highbd_dc_predictor_4x4;
2236     dc_pred_high[1][1][TX_8X8] = svt_aom_highbd_dc_predictor_8x8;
2237     dc_pred_high[1][1][TX_16X16] = svt_aom_highbd_dc_predictor_16x16;
2238     dc_pred_high[1][1][TX_32X32] = svt_aom_highbd_dc_predictor_32x32;
2239     dc_pred_high[1][1][TX_64X64] = svt_aom_highbd_dc_predictor_64x64;
2240 
2241     dc_pred_high[1][1][TX_4X8] = svt_aom_highbd_dc_predictor_4x8;
2242     dc_pred_high[1][1][TX_4X16] = svt_aom_highbd_dc_predictor_4x16;
2243 
2244     dc_pred_high[1][1][TX_8X4] = svt_aom_highbd_dc_predictor_8x4;
2245     dc_pred_high[1][1][TX_8X16] = svt_aom_highbd_dc_predictor_8x16;
2246     dc_pred_high[1][1][TX_8X32] = svt_aom_highbd_dc_predictor_8x32;
2247 
2248     dc_pred_high[1][1][TX_16X4] = svt_aom_highbd_dc_predictor_16x4;
2249     dc_pred_high[1][1][TX_16X8] = svt_aom_highbd_dc_predictor_16x8;
2250     dc_pred_high[1][1][TX_16X32] = svt_aom_highbd_dc_predictor_16x32;
2251     dc_pred_high[1][1][TX_16X64] = svt_aom_highbd_dc_predictor_16x64;
2252 
2253     dc_pred_high[1][1][TX_32X8] = svt_aom_highbd_dc_predictor_32x8;
2254     dc_pred_high[1][1][TX_32X16] = svt_aom_highbd_dc_predictor_32x16;
2255     dc_pred_high[1][1][TX_32X64] = svt_aom_highbd_dc_predictor_32x64;
2256 
2257     dc_pred_high[1][1][TX_64X16] = svt_aom_highbd_dc_predictor_64x16;
2258     dc_pred_high[1][1][TX_64X32] = svt_aom_highbd_dc_predictor_64x32;
2259 }
dr_predictor(uint8_t * dst,ptrdiff_t stride,TxSize tx_size,const uint8_t * above,const uint8_t * left,int32_t upsample_above,int32_t upsample_left,int32_t angle)2260 void dr_predictor(uint8_t *dst, ptrdiff_t stride, TxSize tx_size,
2261     const uint8_t *above, const uint8_t *left,
2262     int32_t upsample_above, int32_t upsample_left, int32_t angle)
2263 {
2264     const int32_t dx = get_dx(angle);
2265     const int32_t dy = get_dy(angle);
2266     const int32_t bw = tx_size_wide[tx_size];
2267     const int32_t bh = tx_size_high[tx_size];
2268     assert(angle > 0 && angle < 270);
2269 
2270     if (angle > 0 && angle < 90) {
2271         svt_av1_dr_prediction_z1(dst, stride, bw, bh, above, left, upsample_above, dx,
2272             dy);
2273     }
2274     else if (angle > 90 && angle < 180) {
2275         svt_av1_dr_prediction_z2(dst, stride, bw, bh, above, left, upsample_above,
2276             upsample_left, dx, dy);
2277     }
2278     else if (angle > 180 && angle < 270) {
2279         svt_av1_dr_prediction_z3(dst, stride, bw, bh, above, left, upsample_left, dx,
2280             dy);
2281     }
2282     else if (angle == 90)
2283         eb_pred[V_PRED][tx_size](dst, stride, above, left);
2284     else if (angle == 180)
2285         eb_pred[H_PRED][tx_size](dst, stride, above, left);
2286 }
2287 
filter_intra_edge_corner(uint8_t * p_above,uint8_t * p_left)2288 void filter_intra_edge_corner(uint8_t *p_above, uint8_t *p_left)
2289 {
2290     const int32_t kernel[3] = { 5, 6, 5 };
2291 
2292     int32_t s = (p_left[0] * kernel[0]) + (p_above[-1] * kernel[1]) +
2293         (p_above[0] * kernel[2]);
2294     s = (s + 8) >> 4;
2295     p_above[-1] = (uint8_t)s;
2296     p_left[-1] = (uint8_t)s;
2297 }
2298 
2299 // Directional prediction, zone 1: 0 < angle < 90
svt_av1_highbd_dr_prediction_z1_c(uint16_t * dst,ptrdiff_t stride,int32_t bw,int32_t bh,const uint16_t * above,const uint16_t * left,int32_t upsample_above,int32_t dx,int32_t dy,int32_t bd)2300 void svt_av1_highbd_dr_prediction_z1_c(uint16_t *dst, ptrdiff_t stride, int32_t bw,
2301     int32_t bh, const uint16_t *above,
2302     const uint16_t *left, int32_t upsample_above,
2303     int32_t dx, int32_t dy, int32_t bd)
2304 {
2305     (void)left;
2306     (void)dy;
2307     (void)bd;
2308     assert(dy == 1);
2309     assert(dx > 0);
2310 
2311     const int32_t max_base_x = ((bw + bh) - 1) << upsample_above;
2312     const int32_t frac_bits = 6 - upsample_above;
2313     const int32_t base_inc = 1 << upsample_above;
2314     for (int32_t r = 0, x = dx; r < bh; ++r, dst += stride, x += dx) {
2315         int32_t base = x >> frac_bits;
2316         const int32_t shift = ((x << upsample_above) & 0x3F) >> 1;
2317 
2318         if (base >= max_base_x) {
2319             for (int32_t i = r; i < bh; ++i) {
2320                 svt_aom_memset16(dst, above[max_base_x], bw);
2321                 dst += stride;
2322             }
2323             return;
2324         }
2325 
2326         for (int32_t c = 0; c < bw; ++c, base += base_inc) {
2327             if (base < max_base_x) {
2328                 int32_t val = above[base] * (32 - shift) + above[base + 1] * shift;
2329                 val = ROUND_POWER_OF_TWO(val, 5);
2330                 dst[c] = (uint16_t)clip_pixel_highbd(val, bd);
2331             }
2332             else
2333                 dst[c] = above[max_base_x];
2334         }
2335     }
2336 }
2337 
2338 // Directional prediction, zone 2: 90 < angle < 180
svt_av1_highbd_dr_prediction_z2_c(uint16_t * dst,ptrdiff_t stride,int32_t bw,int32_t bh,const uint16_t * above,const uint16_t * left,int32_t upsample_above,int32_t upsample_left,int32_t dx,int32_t dy,int32_t bd)2339 void svt_av1_highbd_dr_prediction_z2_c(uint16_t *dst, ptrdiff_t stride, int32_t bw,
2340     int32_t bh, const uint16_t *above,
2341     const uint16_t *left, int32_t upsample_above,
2342     int32_t upsample_left, int32_t dx, int32_t dy, int32_t bd)
2343 {
2344     (void)bd;
2345     assert(dx > 0);
2346     assert(dy > 0);
2347 
2348     const int32_t min_base_x = -(1 << upsample_above);
2349     const int32_t frac_bits_x = 6 - upsample_above;
2350     const int32_t frac_bits_y = 6 - upsample_left;
2351     for (int32_t r = 0; r < bh; ++r, dst += stride) {
2352         for (int32_t c = 0; c < bw; ++c) {
2353             int32_t y = r + 1;
2354             int32_t x = (c << 6) - y * dx;
2355             int32_t base = x >> frac_bits_x;
2356             int32_t val;
2357             if (base >= min_base_x) {
2358                 const int32_t shift = ((x * (1 << upsample_above)) & 0x3F) >> 1;
2359                 val   = above[base] * (32 - shift) + above[base + 1] * shift;
2360                 val = ROUND_POWER_OF_TWO(val, 5);
2361             } else {
2362                 x = c + 1;
2363                 y = (r << 6) - x * dy;
2364                 base = y >> frac_bits_y;
2365                 const int32_t shift = ((y * (1 << upsample_left)) & 0x3F) >> 1;
2366                 val   = left[base] * (32 - shift) + left[base + 1] * shift;
2367                 val = ROUND_POWER_OF_TWO(val, 5);
2368             }
2369             dst[c] = clip_pixel_highbd(val, bd);
2370         }
2371     }
2372 }
2373 
highbd_dr_predictor(uint16_t * dst,ptrdiff_t stride,TxSize tx_size,const uint16_t * above,const uint16_t * left,int32_t upsample_above,int32_t upsample_left,int32_t angle,int32_t bd)2374 void highbd_dr_predictor(uint16_t *dst, ptrdiff_t stride,
2375     TxSize tx_size, const uint16_t *above,
2376     const uint16_t *left, int32_t upsample_above,
2377     int32_t upsample_left, int32_t angle, int32_t bd)
2378 {
2379     const int32_t dx = get_dx(angle);
2380     const int32_t dy = get_dy(angle);
2381     const int32_t bw = tx_size_wide[tx_size];
2382     const int32_t bh = tx_size_high[tx_size];
2383     assert(angle > 0 && angle < 270);
2384 
2385     if (angle > 0 && angle < 90) {
2386         svt_av1_highbd_dr_prediction_z1(dst, stride, bw, bh, above, left,
2387             upsample_above, dx, dy, bd);
2388     }
2389     else if (angle > 90 && angle < 180) {
2390         svt_av1_highbd_dr_prediction_z2(dst, stride, bw, bh, above, left,
2391             upsample_above, upsample_left, dx, dy, bd);
2392     }
2393     else if (angle > 180 && angle < 270) {
2394         svt_av1_highbd_dr_prediction_z3(dst, stride, bw, bh, above, left, upsample_left,
2395             dx, dy, bd);
2396     }
2397     else if (angle == 90)
2398         pred_high[V_PRED][tx_size](dst, stride, above, left, bd);
2399     else if (angle == 180)
2400         pred_high[H_PRED][tx_size](dst, stride, above, left, bd);
2401 }
2402 
svt_av1_filter_intra_edge_high_c(uint16_t * p,int32_t sz,int32_t strength)2403 void svt_av1_filter_intra_edge_high_c(uint16_t *p, int32_t sz, int32_t strength)
2404 {
2405     if (!strength) return;
2406 
2407     const int32_t kernel[INTRA_EDGE_FILT][INTRA_EDGE_TAPS] = {
2408         { 0, 4, 8, 4, 0 }, { 0, 5, 6, 5, 0 }, { 2, 4, 4, 4, 2 }
2409     };
2410     const int32_t filt = strength - 1;
2411     uint16_t edge[129];
2412 
2413     svt_memcpy_c(edge, p, sz * sizeof(*p));
2414     for (int32_t i = 1; i < sz; i++) {
2415         int32_t s = 0;
2416         for (unsigned j = 0; j < INTRA_EDGE_TAPS; j++) {
2417             int32_t k = i - 2 + j;
2418             k = (k < 0) ? 0 : k;
2419             k = (k > sz - 1) ? sz - 1 : k;
2420             s += edge[k] * kernel[filt][j];
2421         }
2422         s = (s + 8) >> 4;
2423         p[i] = (uint16_t)s;
2424     }
2425 }
2426 
filter_intra_edge_corner_high(uint16_t * p_above,uint16_t * p_left)2427 void filter_intra_edge_corner_high(uint16_t *p_above, uint16_t *p_left)
2428 {
2429     const int32_t kernel[3] = { 5, 6, 5 };
2430 
2431     int32_t s = (p_left[0] * kernel[0]) + (p_above[-1] * kernel[1]) +
2432         (p_above[0] * kernel[2]);
2433     s = (s + 8) >> 4;
2434     p_above[-1] = (uint16_t)s;
2435     p_left[-1] = (uint16_t)s;
2436 }
2437 
scale_chroma_bsize(BlockSize bsize,int32_t subsampling_x,int32_t subsampling_y)2438 /*static INLINE*/ BlockSize scale_chroma_bsize(BlockSize bsize, int32_t subsampling_x,
2439     int32_t subsampling_y)
2440 {
2441     BlockSize bs = bsize;
2442     switch (bsize) {
2443     case BLOCK_4X4:
2444         if (subsampling_x == 1 && subsampling_y == 1)
2445             bs = BLOCK_8X8;
2446         else if (subsampling_x == 1)
2447             bs = BLOCK_8X4;
2448         else if (subsampling_y == 1)
2449             bs = BLOCK_4X8;
2450         break;
2451     case BLOCK_4X8:
2452         if (subsampling_x == 1 && subsampling_y == 1)
2453             bs = BLOCK_8X8;
2454         else if (subsampling_x == 1)
2455             bs = BLOCK_8X8;
2456         else if (subsampling_y == 1)
2457             bs = BLOCK_4X8;
2458         break;
2459     case BLOCK_8X4:
2460         if (subsampling_x == 1 && subsampling_y == 1)
2461             bs = BLOCK_8X8;
2462         else if (subsampling_x == 1)
2463             bs = BLOCK_8X4;
2464         else if (subsampling_y == 1)
2465             bs = BLOCK_8X8;
2466         break;
2467     case BLOCK_4X16:
2468         if (subsampling_x == 1 && subsampling_y == 1)
2469             bs = BLOCK_8X16;
2470         else if (subsampling_x == 1)
2471             bs = BLOCK_8X16;
2472         else if (subsampling_y == 1)
2473             bs = BLOCK_4X16;
2474         break;
2475     case BLOCK_16X4:
2476         if (subsampling_x == 1 && subsampling_y == 1)
2477             bs = BLOCK_16X8;
2478         else if (subsampling_x == 1)
2479             bs = BLOCK_16X4;
2480         else if (subsampling_y == 1)
2481             bs = BLOCK_16X8;
2482         break;
2483     default: break;
2484     }
2485     return bs;
2486 }
2487 
2488 ////////////########...........Recurssive intra prediction starting...........#########
2489 
2490 
2491 
highbd_filter_intra_predictor(uint16_t * dst,ptrdiff_t stride,TxSize tx_size,const uint16_t * above,const uint16_t * left,int mode,int bd)2492 void highbd_filter_intra_predictor(uint16_t *dst, ptrdiff_t stride,
2493     TxSize tx_size, const uint16_t *above, const uint16_t *left,
2494     int mode, int bd)
2495 {
2496     uint16_t buffer[33][33];
2497     const int bw = tx_size_wide[tx_size];
2498     const int bh = tx_size_high[tx_size];
2499 
2500     assert(bw <= 32 && bh <= 32);
2501 
2502     // The initialization is just for silencing Jenkins static analysis warnings
2503     for (int r = 0; r < bh + 1; ++r)
2504         memset(buffer[r], 0, (bw + 1) * sizeof(buffer[0][0]));
2505 
2506     for (int r = 0; r < bh; ++r) buffer[r + 1][0] = left[r];
2507     svt_memcpy(buffer[0], &above[-1], (bw + 1) * sizeof(buffer[0][0]));
2508 
2509     for (int r = 1; r < bh + 1; r += 2)
2510         for (int c = 1; c < bw + 1; c += 4) {
2511             const uint16_t p0 = buffer[r - 1][c - 1];
2512             const uint16_t p1 = buffer[r - 1][c];
2513             const uint16_t p2 = buffer[r - 1][c + 1];
2514             const uint16_t p3 = buffer[r - 1][c + 2];
2515             const uint16_t p4 = buffer[r - 1][c + 3];
2516             const uint16_t p5 = buffer[r][c - 1];
2517             const uint16_t p6 = buffer[r + 1][c - 1];
2518             for (unsigned k = 0; k < 8; ++k) {
2519                 int r_offset = k >> 2;
2520                 int c_offset = k & 0x03;
2521                 buffer[r + r_offset][c + c_offset] =
2522                     clip_pixel_highbd(ROUND_POWER_OF_TWO_SIGNED(
2523                         eb_av1_filter_intra_taps[mode][k][0] * p0 +
2524                         eb_av1_filter_intra_taps[mode][k][1] * p1 +
2525                         eb_av1_filter_intra_taps[mode][k][2] * p2 +
2526                         eb_av1_filter_intra_taps[mode][k][3] * p3 +
2527                         eb_av1_filter_intra_taps[mode][k][4] * p4 +
2528                         eb_av1_filter_intra_taps[mode][k][5] * p5 +
2529                         eb_av1_filter_intra_taps[mode][k][6] * p6,
2530                         FILTER_INTRA_SCALE_BITS),
2531                         bd);
2532             }
2533         }
2534 
2535     for (int r = 0; r < bh; ++r) {
2536         svt_memcpy(dst, &buffer[r + 1][1], bw * sizeof(dst[0]));
2537         dst += stride;
2538     }
2539 }
2540 
2541 //static int is_smooth_luma(uint8_t mode) {
2542 //    return (mode == SMOOTH_PRED || mode == SMOOTH_V_PRED || mode == SMOOTH_H_PRED);
2543 //}
2544 
filter_intra_edge(OisMbResults * ois_mb_results_ptr,uint8_t mode,uint16_t max_frame_width,uint16_t max_frame_height,int32_t p_angle,int32_t cu_origin_x,int32_t cu_origin_y,uint8_t * above_row,uint8_t * left_col)2545 void filter_intra_edge(OisMbResults *ois_mb_results_ptr, uint8_t mode, uint16_t max_frame_width, uint16_t max_frame_height,
2546                        int32_t p_angle, int32_t cu_origin_x, int32_t cu_origin_y, uint8_t *above_row, uint8_t *left_col) {
2547     (void)ois_mb_results_ptr;
2548     const int mb_stride = (max_frame_width + 15) / 16;
2549     const int mb_height = (max_frame_height + 15) / 16;
2550     const int txwpx = tx_size_wide[TX_16X16];
2551     const int txhpx = tx_size_high[TX_16X16];
2552     const int need_right = p_angle < 90;
2553     const int need_bottom = p_angle > 180;
2554     int need_left = extend_modes[mode] & NEED_LEFT;
2555     int need_above = extend_modes[mode] & NEED_ABOVE;
2556     int need_above_left = extend_modes[mode] & NEED_ABOVELEFT;
2557     //force to 0 for neighbor may not be ready at segment boundary
2558     // int ab_sm = 0; // (cu_origin_y > 0 && (ois_mb_results_ptr - mb_stride)) ? is_smooth_luma((ois_mb_results_ptr - mb_stride)->intra_mode) : 0;
2559     // int le_sm = 0; // (cu_origin_x > 0 && (ois_mb_results_ptr - 1)) ? is_smooth_luma((ois_mb_results_ptr - 1)->intra_mode) : 0;
2560     const int filt_type = 0; // (ab_sm || le_sm) ? 1 : 0
2561     int n_top_px  = cu_origin_y > 0 ? AOMMIN(txwpx, (mb_stride * 16 - cu_origin_x + txwpx)) : 0;
2562     int n_left_px = cu_origin_x > 0 ? AOMMIN(txhpx, (mb_height * 16 - cu_origin_y + txhpx)) : 0;
2563 
2564     if (av1_is_directional_mode((PredictionMode)mode)) {
2565         if (p_angle <= 90)
2566             need_above = 1, need_left = 0, need_above_left = 1;
2567         else if (p_angle < 180)
2568             need_above = 1, need_left = 1, need_above_left = 1;
2569         else
2570             need_above = 0, need_left = 1, need_above_left = 1;
2571     }
2572 
2573     if (p_angle != 90 && p_angle != 180) {
2574         const int ab_le = need_above_left ? 1 : 0;
2575         if (need_above && need_left && (txwpx + txhpx >= 24)) {
2576             filter_intra_edge_corner(above_row, left_col);
2577         }
2578         if (need_above && n_top_px > 0) {
2579             const int strength =
2580                 intra_edge_filter_strength(txwpx, txhpx, p_angle - 90, filt_type);
2581             const int n_px = n_top_px + ab_le + (need_right ? txhpx : 0);
2582             svt_av1_filter_intra_edge(above_row - ab_le, n_px, strength);
2583         }
2584         if (need_left && n_left_px > 0) {
2585             const int strength = intra_edge_filter_strength(
2586                     txhpx, txwpx, p_angle - 180, filt_type);
2587             const int n_px = n_left_px + ab_le + (need_bottom ? txwpx : 0);
2588             svt_av1_filter_intra_edge(left_col - ab_le, n_px, strength);
2589         }
2590     }
2591     int upsample_above =
2592         use_intra_edge_upsample(txwpx, txhpx, p_angle - 90, filt_type);
2593     if (need_above && upsample_above) {
2594         const int n_px = txwpx + (need_right ? txhpx : 0);
2595         svt_av1_upsample_intra_edge(above_row, n_px);
2596     }
2597     int upsample_left =
2598         use_intra_edge_upsample(txhpx, txwpx, p_angle - 180, filt_type);
2599     if (need_left && upsample_left) {
2600         const int n_px = txhpx + (need_bottom ? txwpx : 0);
2601         svt_av1_upsample_intra_edge(left_col, n_px);
2602     }
2603     return;
2604 }
2605 
intra_prediction_open_loop_mb(int32_t p_angle,uint8_t ois_intra_mode,uint32_t src_origin_x,uint32_t src_origin_y,TxSize tx_size,uint8_t * above_row,uint8_t * left_col,uint8_t * dst,uint32_t dst_stride)2606 EbErrorType intra_prediction_open_loop_mb(
2607      int32_t  p_angle ,
2608         uint8_t                          ois_intra_mode,
2609         uint32_t                         src_origin_x,
2610         uint32_t                         src_origin_y,
2611         TxSize                          tx_size,
2612         uint8_t                         *above_row,
2613         uint8_t                         *left_col,
2614         uint8_t                         *dst,
2615         uint32_t                        dst_stride)
2616 
2617 {
2618     EbErrorType                return_error = EB_ErrorNone;
2619     PredictionMode mode = ois_intra_mode;
2620     const int32_t is_dr_mode = av1_is_directional_mode(mode);
2621 
2622     if (is_dr_mode)
2623         dr_predictor(dst, dst_stride, tx_size, above_row, left_col, 0, 0, p_angle);
2624     else {
2625         // predict
2626         if (mode == DC_PRED) {
2627             dc_pred[src_origin_x > 0][src_origin_y > 0][tx_size](dst, dst_stride, above_row, left_col);
2628         } else
2629             eb_pred[mode][tx_size](dst, dst_stride, above_row, left_col);
2630     }
2631     return return_error;
2632 }
2633