1 /*
2  * Copyright (c) 2016, Alliance for Open Media. All rights reserved
3  *
4  * This source code is subject to the terms of the BSD 2 Clause License and
5  * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6  * was not distributed with this source code in the LICENSE file, you can
7  * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8  * Media Patent License 1.0 was not distributed with this source code in the
9  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10  */
11 
12 #include <assert.h>
13 #include <math.h>
14 
15 #include "./aom_config.h"
16 #include "./aom_dsp_rtcd.h"
17 
18 #include "aom_dsp/aom_dsp_common.h"
19 #include "aom_dsp/intrapred_common.h"
20 #include "aom_mem/aom_mem.h"
21 #include "aom_ports/bitops.h"
22 
23 #define DST(x, y) dst[(x) + (y)*stride]
24 #define AVG3(a, b, c) (((a) + 2 * (b) + (c) + 2) >> 2)
25 #define AVG2(a, b) (((a) + (b) + 1) >> 1)
26 
d207e_predictor(uint8_t * dst,ptrdiff_t stride,int bw,int bh,const uint8_t * above,const uint8_t * left)27 static INLINE void d207e_predictor(uint8_t *dst, ptrdiff_t stride, int bw,
28                                    int bh, const uint8_t *above,
29                                    const uint8_t *left) {
30   int r, c;
31   (void)above;
32 
33   for (r = 0; r < bh; ++r) {
34     for (c = 0; c < bw; ++c) {
35       dst[c] = c & 1 ? AVG3(left[(c >> 1) + r], left[(c >> 1) + r + 1],
36                             left[(c >> 1) + r + 2])
37                      : AVG2(left[(c >> 1) + r], left[(c >> 1) + r + 1]);
38     }
39     dst += stride;
40   }
41 }
42 
d63e_predictor(uint8_t * dst,ptrdiff_t stride,int bw,int bh,const uint8_t * above,const uint8_t * left)43 static INLINE void d63e_predictor(uint8_t *dst, ptrdiff_t stride, int bw,
44                                   int bh, const uint8_t *above,
45                                   const uint8_t *left) {
46   int r, c;
47   (void)left;
48   for (r = 0; r < bh; ++r) {
49     for (c = 0; c < bw; ++c) {
50       dst[c] = r & 1 ? AVG3(above[(r >> 1) + c], above[(r >> 1) + c + 1],
51                             above[(r >> 1) + c + 2])
52                      : AVG2(above[(r >> 1) + c], above[(r >> 1) + c + 1]);
53     }
54     dst += stride;
55   }
56 }
57 
d45e_predictor(uint8_t * dst,ptrdiff_t stride,int bw,int bh,const uint8_t * above,const uint8_t * left)58 static INLINE void d45e_predictor(uint8_t *dst, ptrdiff_t stride, int bw,
59                                   int bh, const uint8_t *above,
60                                   const uint8_t *left) {
61   int r, c;
62   (void)left;
63   for (r = 0; r < bh; ++r) {
64     for (c = 0; c < bw; ++c) {
65       dst[c] = AVG3(above[r + c], above[r + c + 1],
66                     above[r + c + 1 + (r + c + 2 < bw + bh)]);
67     }
68     dst += stride;
69   }
70 }
71 
d117_predictor(uint8_t * dst,ptrdiff_t stride,int bw,int bh,const uint8_t * above,const uint8_t * left)72 static INLINE void d117_predictor(uint8_t *dst, ptrdiff_t stride, int bw,
73                                   int bh, const uint8_t *above,
74                                   const uint8_t *left) {
75   int r, c;
76 
77   // first row
78   for (c = 0; c < bw; c++) dst[c] = AVG2(above[c - 1], above[c]);
79   dst += stride;
80 
81   // second row
82   dst[0] = AVG3(left[0], above[-1], above[0]);
83   for (c = 1; c < bw; c++) dst[c] = AVG3(above[c - 2], above[c - 1], above[c]);
84   dst += stride;
85 
86   // the rest of first col
87   dst[0] = AVG3(above[-1], left[0], left[1]);
88   for (r = 3; r < bh; ++r)
89     dst[(r - 2) * stride] = AVG3(left[r - 3], left[r - 2], left[r - 1]);
90 
91   // the rest of the block
92   for (r = 2; r < bh; ++r) {
93     for (c = 1; c < bw; c++) dst[c] = dst[-2 * stride + c - 1];
94     dst += stride;
95   }
96 }
97 
d135_predictor(uint8_t * dst,ptrdiff_t stride,int bw,int bh,const uint8_t * above,const uint8_t * left)98 static INLINE void d135_predictor(uint8_t *dst, ptrdiff_t stride, int bw,
99                                   int bh, const uint8_t *above,
100                                   const uint8_t *left) {
101   int i;
102 #if CONFIG_TX64X64
103 #if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ > 7
104   // silence a spurious -Warray-bounds warning, possibly related to:
105   // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56273
106   uint8_t border[133];
107 #else
108   uint8_t border[64 + 64 - 1];  // outer border from bottom-left to top-right
109 #endif
110 #else
111 #if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ > 7
112   // silence a spurious -Warray-bounds warning, possibly related to:
113   // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56273
114   uint8_t border[69];
115 #else
116   uint8_t border[32 + 32 - 1];  // outer border from bottom-left to top-right
117 #endif
118 #endif  // CONFIG_TX64X64
119 
120   // dst(bh, bh - 2)[0], i.e., border starting at bottom-left
121   for (i = 0; i < bh - 2; ++i) {
122     border[i] = AVG3(left[bh - 3 - i], left[bh - 2 - i], left[bh - 1 - i]);
123   }
124   border[bh - 2] = AVG3(above[-1], left[0], left[1]);
125   border[bh - 1] = AVG3(left[0], above[-1], above[0]);
126   border[bh - 0] = AVG3(above[-1], above[0], above[1]);
127   // dst[0][2, size), i.e., remaining top border ascending
128   for (i = 0; i < bw - 2; ++i) {
129     border[bh + 1 + i] = AVG3(above[i], above[i + 1], above[i + 2]);
130   }
131 
132   for (i = 0; i < bh; ++i) {
133     memcpy(dst + i * stride, border + bh - 1 - i, bw);
134   }
135 }
136 
d153_predictor(uint8_t * dst,ptrdiff_t stride,int bw,int bh,const uint8_t * above,const uint8_t * left)137 static INLINE void d153_predictor(uint8_t *dst, ptrdiff_t stride, int bw,
138                                   int bh, const uint8_t *above,
139                                   const uint8_t *left) {
140   int r, c;
141   dst[0] = AVG2(above[-1], left[0]);
142   for (r = 1; r < bh; r++) dst[r * stride] = AVG2(left[r - 1], left[r]);
143   dst++;
144 
145   dst[0] = AVG3(left[0], above[-1], above[0]);
146   dst[stride] = AVG3(above[-1], left[0], left[1]);
147   for (r = 2; r < bh; r++)
148     dst[r * stride] = AVG3(left[r - 2], left[r - 1], left[r]);
149   dst++;
150 
151   for (c = 0; c < bw - 2; c++)
152     dst[c] = AVG3(above[c - 1], above[c], above[c + 1]);
153   dst += stride;
154 
155   for (r = 1; r < bh; ++r) {
156     for (c = 0; c < bw - 2; c++) dst[c] = dst[-stride + c - 2];
157     dst += stride;
158   }
159 }
160 
v_predictor(uint8_t * dst,ptrdiff_t stride,int bw,int bh,const uint8_t * above,const uint8_t * left)161 static INLINE void v_predictor(uint8_t *dst, ptrdiff_t stride, int bw, int bh,
162                                const uint8_t *above, const uint8_t *left) {
163   int r;
164   (void)left;
165 
166   for (r = 0; r < bh; r++) {
167     memcpy(dst, above, bw);
168     dst += stride;
169   }
170 }
171 
h_predictor(uint8_t * dst,ptrdiff_t stride,int bw,int bh,const uint8_t * above,const uint8_t * left)172 static INLINE void h_predictor(uint8_t *dst, ptrdiff_t stride, int bw, int bh,
173                                const uint8_t *above, const uint8_t *left) {
174   int r;
175   (void)above;
176 
177   for (r = 0; r < bh; r++) {
178     memset(dst, left[r], bw);
179     dst += stride;
180   }
181 }
182 
abs_diff(int a,int b)183 static INLINE int abs_diff(int a, int b) { return (a > b) ? a - b : b - a; }
184 
paeth_predictor_single(uint16_t left,uint16_t top,uint16_t top_left)185 static INLINE uint16_t paeth_predictor_single(uint16_t left, uint16_t top,
186                                               uint16_t top_left) {
187   const int base = top + left - top_left;
188   const int p_left = abs_diff(base, left);
189   const int p_top = abs_diff(base, top);
190   const int p_top_left = abs_diff(base, top_left);
191 
192   // Return nearest to base of left, top and top_left.
193   return (p_left <= p_top && p_left <= p_top_left)
194              ? left
195              : (p_top <= p_top_left) ? top : top_left;
196 }
197 
paeth_predictor(uint8_t * dst,ptrdiff_t stride,int bw,int bh,const uint8_t * above,const uint8_t * left)198 static INLINE void paeth_predictor(uint8_t *dst, ptrdiff_t stride, int bw,
199                                    int bh, const uint8_t *above,
200                                    const uint8_t *left) {
201   int r, c;
202   const uint8_t ytop_left = above[-1];
203 
204   for (r = 0; r < bh; r++) {
205     for (c = 0; c < bw; c++)
206       dst[c] = (uint8_t)paeth_predictor_single(left[r], above[c], ytop_left);
207     dst += stride;
208   }
209 }
210 
211 // Some basic checks on weights for smooth predictor.
212 #define sm_weights_sanity_checks(weights_w, weights_h, weights_scale, \
213                                  pred_scale)                          \
214   assert(weights_w[0] < weights_scale);                               \
215   assert(weights_h[0] < weights_scale);                               \
216   assert(weights_scale - weights_w[bw - 1] < weights_scale);          \
217   assert(weights_scale - weights_h[bh - 1] < weights_scale);          \
218   assert(pred_scale < 31)  // ensures no overflow when calculating predictor.
219 
220 #define divide_round(value, bits) (((value) + (1 << ((bits)-1))) >> (bits))
221 
smooth_predictor(uint8_t * dst,ptrdiff_t stride,int bw,int bh,const uint8_t * above,const uint8_t * left)222 static INLINE void smooth_predictor(uint8_t *dst, ptrdiff_t stride, int bw,
223                                     int bh, const uint8_t *above,
224                                     const uint8_t *left) {
225   const uint8_t below_pred = left[bh - 1];   // estimated by bottom-left pixel
226   const uint8_t right_pred = above[bw - 1];  // estimated by top-right pixel
227   const uint8_t *const sm_weights_w = sm_weight_arrays + bw;
228   const uint8_t *const sm_weights_h = sm_weight_arrays + bh;
229   // scale = 2 * 2^sm_weight_log2_scale
230   const int log2_scale = 1 + sm_weight_log2_scale;
231   const uint16_t scale = (1 << sm_weight_log2_scale);
232   sm_weights_sanity_checks(sm_weights_w, sm_weights_h, scale,
233                            log2_scale + sizeof(*dst));
234   int r;
235   for (r = 0; r < bh; ++r) {
236     int c;
237     for (c = 0; c < bw; ++c) {
238       const uint8_t pixels[] = { above[c], below_pred, left[r], right_pred };
239       const uint8_t weights[] = { sm_weights_h[r], scale - sm_weights_h[r],
240                                   sm_weights_w[c], scale - sm_weights_w[c] };
241       uint32_t this_pred = 0;
242       int i;
243       assert(scale >= sm_weights_h[r] && scale >= sm_weights_w[c]);
244       for (i = 0; i < 4; ++i) {
245         this_pred += weights[i] * pixels[i];
246       }
247       dst[c] = clip_pixel(divide_round(this_pred, log2_scale));
248     }
249     dst += stride;
250   }
251 }
252 
253 #if CONFIG_SMOOTH_HV
smooth_v_predictor(uint8_t * dst,ptrdiff_t stride,int bw,int bh,const uint8_t * above,const uint8_t * left)254 static INLINE void smooth_v_predictor(uint8_t *dst, ptrdiff_t stride, int bw,
255                                       int bh, const uint8_t *above,
256                                       const uint8_t *left) {
257   const uint8_t below_pred = left[bh - 1];  // estimated by bottom-left pixel
258   const uint8_t *const sm_weights = sm_weight_arrays + bh;
259   // scale = 2^sm_weight_log2_scale
260   const int log2_scale = sm_weight_log2_scale;
261   const uint16_t scale = (1 << sm_weight_log2_scale);
262   sm_weights_sanity_checks(sm_weights, sm_weights, scale,
263                            log2_scale + sizeof(*dst));
264 
265   int r;
266   for (r = 0; r < bh; r++) {
267     int c;
268     for (c = 0; c < bw; ++c) {
269       const uint8_t pixels[] = { above[c], below_pred };
270       const uint8_t weights[] = { sm_weights[r], scale - sm_weights[r] };
271       uint32_t this_pred = 0;
272       assert(scale >= sm_weights[r]);
273       int i;
274       for (i = 0; i < 2; ++i) {
275         this_pred += weights[i] * pixels[i];
276       }
277       dst[c] = clip_pixel(divide_round(this_pred, log2_scale));
278     }
279     dst += stride;
280   }
281 }
282 
smooth_h_predictor(uint8_t * dst,ptrdiff_t stride,int bw,int bh,const uint8_t * above,const uint8_t * left)283 static INLINE void smooth_h_predictor(uint8_t *dst, ptrdiff_t stride, int bw,
284                                       int bh, const uint8_t *above,
285                                       const uint8_t *left) {
286   const uint8_t right_pred = above[bw - 1];  // estimated by top-right pixel
287   const uint8_t *const sm_weights = sm_weight_arrays + bw;
288   // scale = 2^sm_weight_log2_scale
289   const int log2_scale = sm_weight_log2_scale;
290   const uint16_t scale = (1 << sm_weight_log2_scale);
291   sm_weights_sanity_checks(sm_weights, sm_weights, scale,
292                            log2_scale + sizeof(*dst));
293 
294   int r;
295   for (r = 0; r < bh; r++) {
296     int c;
297     for (c = 0; c < bw; ++c) {
298       const uint8_t pixels[] = { left[r], right_pred };
299       const uint8_t weights[] = { sm_weights[c], scale - sm_weights[c] };
300       uint32_t this_pred = 0;
301       assert(scale >= sm_weights[c]);
302       int i;
303       for (i = 0; i < 2; ++i) {
304         this_pred += weights[i] * pixels[i];
305       }
306       dst[c] = clip_pixel(divide_round(this_pred, log2_scale));
307     }
308     dst += stride;
309   }
310 }
311 #endif  // CONFIG_SMOOTH_HV
312 
dc_128_predictor(uint8_t * dst,ptrdiff_t stride,int bw,int bh,const uint8_t * above,const uint8_t * left)313 static INLINE void dc_128_predictor(uint8_t *dst, ptrdiff_t stride, int bw,
314                                     int bh, const uint8_t *above,
315                                     const uint8_t *left) {
316   int r;
317   (void)above;
318   (void)left;
319 
320   for (r = 0; r < bh; r++) {
321     memset(dst, 128, bw);
322     dst += stride;
323   }
324 }
325 
dc_left_predictor(uint8_t * dst,ptrdiff_t stride,int bw,int bh,const uint8_t * above,const uint8_t * left)326 static INLINE void dc_left_predictor(uint8_t *dst, ptrdiff_t stride, int bw,
327                                      int bh, const uint8_t *above,
328                                      const uint8_t *left) {
329   int i, r, expected_dc, sum = 0;
330   (void)above;
331 
332   for (i = 0; i < bh; i++) sum += left[i];
333   expected_dc = (sum + (bh >> 1)) / bh;
334 
335   for (r = 0; r < bh; r++) {
336     memset(dst, expected_dc, bw);
337     dst += stride;
338   }
339 }
340 
dc_top_predictor(uint8_t * dst,ptrdiff_t stride,int bw,int bh,const uint8_t * above,const uint8_t * left)341 static INLINE void dc_top_predictor(uint8_t *dst, ptrdiff_t stride, int bw,
342                                     int bh, const uint8_t *above,
343                                     const uint8_t *left) {
344   int i, r, expected_dc, sum = 0;
345   (void)left;
346 
347   for (i = 0; i < bw; i++) sum += above[i];
348   expected_dc = (sum + (bw >> 1)) / bw;
349 
350   for (r = 0; r < bh; r++) {
351     memset(dst, expected_dc, bw);
352     dst += stride;
353   }
354 }
355 
dc_predictor(uint8_t * dst,ptrdiff_t stride,int bw,int bh,const uint8_t * above,const uint8_t * left)356 static INLINE void dc_predictor(uint8_t *dst, ptrdiff_t stride, int bw, int bh,
357                                 const uint8_t *above, const uint8_t *left) {
358   int i, r, expected_dc, sum = 0;
359   const int count = bw + bh;
360 
361   for (i = 0; i < bw; i++) {
362     sum += above[i];
363   }
364   for (i = 0; i < bh; i++) {
365     sum += left[i];
366   }
367 
368   expected_dc = (sum + (count >> 1)) / count;
369 
370   for (r = 0; r < bh; r++) {
371     memset(dst, expected_dc, bw);
372     dst += stride;
373   }
374 }
375 
aom_d45e_predictor_2x2_c(uint8_t * dst,ptrdiff_t stride,const uint8_t * above,const uint8_t * left)376 void aom_d45e_predictor_2x2_c(uint8_t *dst, ptrdiff_t stride,
377                               const uint8_t *above, const uint8_t *left) {
378   const int A = above[0];
379   const int B = above[1];
380   const int C = above[2];
381   const int D = above[3];
382   (void)stride;
383   (void)left;
384 
385   DST(0, 0) = AVG3(A, B, C);
386   DST(1, 0) = DST(0, 1) = AVG3(B, C, D);
387   DST(1, 1) = AVG3(C, D, D);
388 }
389 
aom_d117_predictor_2x2_c(uint8_t * dst,ptrdiff_t stride,const uint8_t * above,const uint8_t * left)390 void aom_d117_predictor_2x2_c(uint8_t *dst, ptrdiff_t stride,
391                               const uint8_t *above, const uint8_t *left) {
392   const int I = left[0];
393   const int X = above[-1];
394   const int A = above[0];
395   const int B = above[1];
396   DST(0, 0) = AVG2(X, A);
397   DST(1, 0) = AVG2(A, B);
398   DST(0, 1) = AVG3(I, X, A);
399   DST(1, 1) = AVG3(X, A, B);
400 }
401 
aom_d135_predictor_2x2_c(uint8_t * dst,ptrdiff_t stride,const uint8_t * above,const uint8_t * left)402 void aom_d135_predictor_2x2_c(uint8_t *dst, ptrdiff_t stride,
403                               const uint8_t *above, const uint8_t *left) {
404   const int I = left[0];
405   const int J = left[1];
406   const int X = above[-1];
407   const int A = above[0];
408   const int B = above[1];
409   (void)stride;
410   DST(0, 1) = AVG3(X, I, J);
411   DST(1, 1) = DST(0, 0) = AVG3(A, X, I);
412   DST(1, 0) = AVG3(B, A, X);
413 }
414 
aom_d153_predictor_2x2_c(uint8_t * dst,ptrdiff_t stride,const uint8_t * above,const uint8_t * left)415 void aom_d153_predictor_2x2_c(uint8_t *dst, ptrdiff_t stride,
416                               const uint8_t *above, const uint8_t *left) {
417   const int I = left[0];
418   const int J = left[1];
419   const int X = above[-1];
420   const int A = above[0];
421 
422   DST(0, 0) = AVG2(I, X);
423   DST(0, 1) = AVG2(J, I);
424   DST(1, 0) = AVG3(I, X, A);
425   DST(1, 1) = AVG3(J, I, X);
426 }
427 
aom_d45e_predictor_4x4_c(uint8_t * dst,ptrdiff_t stride,const uint8_t * above,const uint8_t * left)428 void aom_d45e_predictor_4x4_c(uint8_t *dst, ptrdiff_t stride,
429                               const uint8_t *above, const uint8_t *left) {
430   const int A = above[0];
431   const int B = above[1];
432   const int C = above[2];
433   const int D = above[3];
434   const int E = above[4];
435   const int F = above[5];
436   const int G = above[6];
437   const int H = above[7];
438   (void)stride;
439   (void)left;
440   DST(0, 0) = AVG3(A, B, C);
441   DST(1, 0) = DST(0, 1) = AVG3(B, C, D);
442   DST(2, 0) = DST(1, 1) = DST(0, 2) = AVG3(C, D, E);
443   DST(3, 0) = DST(2, 1) = DST(1, 2) = DST(0, 3) = AVG3(D, E, F);
444   DST(3, 1) = DST(2, 2) = DST(1, 3) = AVG3(E, F, G);
445   DST(3, 2) = DST(2, 3) = AVG3(F, G, H);
446   DST(3, 3) = AVG3(G, H, H);
447 }
448 
aom_d117_predictor_4x4_c(uint8_t * dst,ptrdiff_t stride,const uint8_t * above,const uint8_t * left)449 void aom_d117_predictor_4x4_c(uint8_t *dst, ptrdiff_t stride,
450                               const uint8_t *above, const uint8_t *left) {
451   const int I = left[0];
452   const int J = left[1];
453   const int K = left[2];
454   const int X = above[-1];
455   const int A = above[0];
456   const int B = above[1];
457   const int C = above[2];
458   const int D = above[3];
459   DST(0, 0) = DST(1, 2) = AVG2(X, A);
460   DST(1, 0) = DST(2, 2) = AVG2(A, B);
461   DST(2, 0) = DST(3, 2) = AVG2(B, C);
462   DST(3, 0) = AVG2(C, D);
463 
464   DST(0, 3) = AVG3(K, J, I);
465   DST(0, 2) = AVG3(J, I, X);
466   DST(0, 1) = DST(1, 3) = AVG3(I, X, A);
467   DST(1, 1) = DST(2, 3) = AVG3(X, A, B);
468   DST(2, 1) = DST(3, 3) = AVG3(A, B, C);
469   DST(3, 1) = AVG3(B, C, D);
470 }
471 
aom_d135_predictor_4x4_c(uint8_t * dst,ptrdiff_t stride,const uint8_t * above,const uint8_t * left)472 void aom_d135_predictor_4x4_c(uint8_t *dst, ptrdiff_t stride,
473                               const uint8_t *above, const uint8_t *left) {
474   const int I = left[0];
475   const int J = left[1];
476   const int K = left[2];
477   const int L = left[3];
478   const int X = above[-1];
479   const int A = above[0];
480   const int B = above[1];
481   const int C = above[2];
482   const int D = above[3];
483   (void)stride;
484   DST(0, 3) = AVG3(J, K, L);
485   DST(1, 3) = DST(0, 2) = AVG3(I, J, K);
486   DST(2, 3) = DST(1, 2) = DST(0, 1) = AVG3(X, I, J);
487   DST(3, 3) = DST(2, 2) = DST(1, 1) = DST(0, 0) = AVG3(A, X, I);
488   DST(3, 2) = DST(2, 1) = DST(1, 0) = AVG3(B, A, X);
489   DST(3, 1) = DST(2, 0) = AVG3(C, B, A);
490   DST(3, 0) = AVG3(D, C, B);
491 }
492 
aom_d153_predictor_4x4_c(uint8_t * dst,ptrdiff_t stride,const uint8_t * above,const uint8_t * left)493 void aom_d153_predictor_4x4_c(uint8_t *dst, ptrdiff_t stride,
494                               const uint8_t *above, const uint8_t *left) {
495   const int I = left[0];
496   const int J = left[1];
497   const int K = left[2];
498   const int L = left[3];
499   const int X = above[-1];
500   const int A = above[0];
501   const int B = above[1];
502   const int C = above[2];
503 
504   DST(0, 0) = DST(2, 1) = AVG2(I, X);
505   DST(0, 1) = DST(2, 2) = AVG2(J, I);
506   DST(0, 2) = DST(2, 3) = AVG2(K, J);
507   DST(0, 3) = AVG2(L, K);
508 
509   DST(3, 0) = AVG3(A, B, C);
510   DST(2, 0) = AVG3(X, A, B);
511   DST(1, 0) = DST(3, 1) = AVG3(I, X, A);
512   DST(1, 1) = DST(3, 2) = AVG3(J, I, X);
513   DST(1, 2) = DST(3, 3) = AVG3(K, J, I);
514   DST(1, 3) = AVG3(L, K, J);
515 }
516 
517 #if CONFIG_HIGHBITDEPTH
highbd_d207e_predictor(uint16_t * dst,ptrdiff_t stride,int bw,int bh,const uint16_t * above,const uint16_t * left,int bd)518 static INLINE void highbd_d207e_predictor(uint16_t *dst, ptrdiff_t stride,
519                                           int bw, int bh, const uint16_t *above,
520                                           const uint16_t *left, int bd) {
521   int r, c;
522   (void)above;
523   (void)bd;
524 
525   for (r = 0; r < bh; ++r) {
526     for (c = 0; c < bw; ++c) {
527       dst[c] = c & 1 ? AVG3(left[(c >> 1) + r], left[(c >> 1) + r + 1],
528                             left[(c >> 1) + r + 2])
529                      : AVG2(left[(c >> 1) + r], left[(c >> 1) + r + 1]);
530     }
531     dst += stride;
532   }
533 }
534 
highbd_d63e_predictor(uint16_t * dst,ptrdiff_t stride,int bw,int bh,const uint16_t * above,const uint16_t * left,int bd)535 static INLINE void highbd_d63e_predictor(uint16_t *dst, ptrdiff_t stride,
536                                          int bw, int bh, const uint16_t *above,
537                                          const uint16_t *left, int bd) {
538   int r, c;
539   (void)left;
540   (void)bd;
541   for (r = 0; r < bh; ++r) {
542     for (c = 0; c < bw; ++c) {
543       dst[c] = r & 1 ? AVG3(above[(r >> 1) + c], above[(r >> 1) + c + 1],
544                             above[(r >> 1) + c + 2])
545                      : AVG2(above[(r >> 1) + c], above[(r >> 1) + c + 1]);
546     }
547     dst += stride;
548   }
549 }
550 
highbd_d45e_predictor(uint16_t * dst,ptrdiff_t stride,int bw,int bh,const uint16_t * above,const uint16_t * left,int bd)551 static INLINE void highbd_d45e_predictor(uint16_t *dst, ptrdiff_t stride,
552                                          int bw, int bh, const uint16_t *above,
553                                          const uint16_t *left, int bd) {
554   int r, c;
555   (void)left;
556   (void)bd;
557   for (r = 0; r < bh; ++r) {
558     for (c = 0; c < bw; ++c) {
559       dst[c] = AVG3(above[r + c], above[r + c + 1],
560                     above[r + c + 1 + (r + c + 2 < bw + bh)]);
561     }
562     dst += stride;
563   }
564 }
565 
highbd_d117_predictor(uint16_t * dst,ptrdiff_t stride,int bw,int bh,const uint16_t * above,const uint16_t * left,int bd)566 static INLINE void highbd_d117_predictor(uint16_t *dst, ptrdiff_t stride,
567                                          int bw, int bh, const uint16_t *above,
568                                          const uint16_t *left, int bd) {
569   int r, c;
570   (void)bd;
571 
572   // first row
573   for (c = 0; c < bw; c++) dst[c] = AVG2(above[c - 1], above[c]);
574   dst += stride;
575 
576   // second row
577   dst[0] = AVG3(left[0], above[-1], above[0]);
578   for (c = 1; c < bw; c++) dst[c] = AVG3(above[c - 2], above[c - 1], above[c]);
579   dst += stride;
580 
581   // the rest of first col
582   dst[0] = AVG3(above[-1], left[0], left[1]);
583   for (r = 3; r < bh; ++r)
584     dst[(r - 2) * stride] = AVG3(left[r - 3], left[r - 2], left[r - 1]);
585 
586   // the rest of the block
587   for (r = 2; r < bh; ++r) {
588     for (c = 1; c < bw; c++) dst[c] = dst[-2 * stride + c - 1];
589     dst += stride;
590   }
591 }
592 
highbd_d135_predictor(uint16_t * dst,ptrdiff_t stride,int bw,int bh,const uint16_t * above,const uint16_t * left,int bd)593 static INLINE void highbd_d135_predictor(uint16_t *dst, ptrdiff_t stride,
594                                          int bw, int bh, const uint16_t *above,
595                                          const uint16_t *left, int bd) {
596   int r, c;
597   (void)bd;
598   dst[0] = AVG3(left[0], above[-1], above[0]);
599   for (c = 1; c < bw; c++) dst[c] = AVG3(above[c - 2], above[c - 1], above[c]);
600 
601   dst[stride] = AVG3(above[-1], left[0], left[1]);
602   for (r = 2; r < bh; ++r)
603     dst[r * stride] = AVG3(left[r - 2], left[r - 1], left[r]);
604 
605   dst += stride;
606   for (r = 1; r < bh; ++r) {
607     for (c = 1; c < bw; c++) dst[c] = dst[-stride + c - 1];
608     dst += stride;
609   }
610 }
611 
highbd_d153_predictor(uint16_t * dst,ptrdiff_t stride,int bw,int bh,const uint16_t * above,const uint16_t * left,int bd)612 static INLINE void highbd_d153_predictor(uint16_t *dst, ptrdiff_t stride,
613                                          int bw, int bh, const uint16_t *above,
614                                          const uint16_t *left, int bd) {
615   int r, c;
616   (void)bd;
617   dst[0] = AVG2(above[-1], left[0]);
618   for (r = 1; r < bh; r++) dst[r * stride] = AVG2(left[r - 1], left[r]);
619   dst++;
620 
621   dst[0] = AVG3(left[0], above[-1], above[0]);
622   dst[stride] = AVG3(above[-1], left[0], left[1]);
623   for (r = 2; r < bh; r++)
624     dst[r * stride] = AVG3(left[r - 2], left[r - 1], left[r]);
625   dst++;
626 
627   for (c = 0; c < bw - 2; c++)
628     dst[c] = AVG3(above[c - 1], above[c], above[c + 1]);
629   dst += stride;
630 
631   for (r = 1; r < bh; ++r) {
632     for (c = 0; c < bw - 2; c++) dst[c] = dst[-stride + c - 2];
633     dst += stride;
634   }
635 }
636 
highbd_v_predictor(uint16_t * dst,ptrdiff_t stride,int bw,int bh,const uint16_t * above,const uint16_t * left,int bd)637 static INLINE void highbd_v_predictor(uint16_t *dst, ptrdiff_t stride, int bw,
638                                       int bh, const uint16_t *above,
639                                       const uint16_t *left, int bd) {
640   int r;
641   (void)left;
642   (void)bd;
643   for (r = 0; r < bh; r++) {
644     memcpy(dst, above, bw * sizeof(uint16_t));
645     dst += stride;
646   }
647 }
648 
highbd_h_predictor(uint16_t * dst,ptrdiff_t stride,int bw,int bh,const uint16_t * above,const uint16_t * left,int bd)649 static INLINE void highbd_h_predictor(uint16_t *dst, ptrdiff_t stride, int bw,
650                                       int bh, const uint16_t *above,
651                                       const uint16_t *left, int bd) {
652   int r;
653   (void)above;
654   (void)bd;
655   for (r = 0; r < bh; r++) {
656     aom_memset16(dst, left[r], bw);
657     dst += stride;
658   }
659 }
660 
aom_highbd_d207_predictor_2x2_c(uint16_t * dst,ptrdiff_t stride,const uint16_t * above,const uint16_t * left,int bd)661 void aom_highbd_d207_predictor_2x2_c(uint16_t *dst, ptrdiff_t stride,
662                                      const uint16_t *above,
663                                      const uint16_t *left, int bd) {
664   const int I = left[0];
665   const int J = left[1];
666   const int K = left[2];
667   const int L = left[3];
668   (void)above;
669   (void)bd;
670   DST(0, 0) = AVG2(I, J);
671   DST(0, 1) = AVG2(J, K);
672   DST(1, 0) = AVG3(I, J, K);
673   DST(1, 1) = AVG3(J, K, L);
674 }
675 
aom_highbd_d63_predictor_2x2_c(uint16_t * dst,ptrdiff_t stride,const uint16_t * above,const uint16_t * left,int bd)676 void aom_highbd_d63_predictor_2x2_c(uint16_t *dst, ptrdiff_t stride,
677                                     const uint16_t *above, const uint16_t *left,
678                                     int bd) {
679   const int A = above[0];
680   const int B = above[1];
681   const int C = above[2];
682   const int D = above[3];
683   (void)left;
684   (void)bd;
685   DST(0, 0) = AVG2(A, B);
686   DST(1, 0) = AVG2(B, C);
687   DST(0, 1) = AVG3(A, B, C);
688   DST(1, 1) = AVG3(B, C, D);
689 }
690 
aom_highbd_d45e_predictor_2x2_c(uint16_t * dst,ptrdiff_t stride,const uint16_t * above,const uint16_t * left,int bd)691 void aom_highbd_d45e_predictor_2x2_c(uint16_t *dst, ptrdiff_t stride,
692                                      const uint16_t *above,
693                                      const uint16_t *left, int bd) {
694   const int A = above[0];
695   const int B = above[1];
696   const int C = above[2];
697   const int D = above[3];
698   (void)stride;
699   (void)left;
700   (void)bd;
701   DST(0, 0) = AVG3(A, B, C);
702   DST(1, 0) = DST(0, 1) = AVG3(B, C, D);
703   DST(1, 1) = AVG3(C, D, D);
704 }
705 
aom_highbd_d117_predictor_2x2_c(uint16_t * dst,ptrdiff_t stride,const uint16_t * above,const uint16_t * left,int bd)706 void aom_highbd_d117_predictor_2x2_c(uint16_t *dst, ptrdiff_t stride,
707                                      const uint16_t *above,
708                                      const uint16_t *left, int bd) {
709   const int I = left[0];
710   const int X = above[-1];
711   const int A = above[0];
712   const int B = above[1];
713   (void)bd;
714   DST(0, 0) = AVG2(X, A);
715   DST(1, 0) = AVG2(A, B);
716   DST(0, 1) = AVG3(I, X, A);
717   DST(1, 1) = AVG3(X, A, B);
718 }
719 
aom_highbd_d135_predictor_2x2_c(uint16_t * dst,ptrdiff_t stride,const uint16_t * above,const uint16_t * left,int bd)720 void aom_highbd_d135_predictor_2x2_c(uint16_t *dst, ptrdiff_t stride,
721                                      const uint16_t *above,
722                                      const uint16_t *left, int bd) {
723   const int I = left[0];
724   const int J = left[1];
725   const int X = above[-1];
726   const int A = above[0];
727   const int B = above[1];
728   (void)bd;
729   DST(0, 1) = AVG3(X, I, J);
730   DST(1, 1) = DST(0, 0) = AVG3(A, X, I);
731   DST(1, 0) = AVG3(B, A, X);
732 }
733 
aom_highbd_d153_predictor_2x2_c(uint16_t * dst,ptrdiff_t stride,const uint16_t * above,const uint16_t * left,int bd)734 void aom_highbd_d153_predictor_2x2_c(uint16_t *dst, ptrdiff_t stride,
735                                      const uint16_t *above,
736                                      const uint16_t *left, int bd) {
737   const int I = left[0];
738   const int J = left[1];
739   const int X = above[-1];
740   const int A = above[0];
741   (void)bd;
742   DST(0, 0) = AVG2(I, X);
743   DST(0, 1) = AVG2(J, I);
744   DST(1, 0) = AVG3(I, X, A);
745   DST(1, 1) = AVG3(J, I, X);
746 }
747 
highbd_paeth_predictor(uint16_t * dst,ptrdiff_t stride,int bw,int bh,const uint16_t * above,const uint16_t * left,int bd)748 static INLINE void highbd_paeth_predictor(uint16_t *dst, ptrdiff_t stride,
749                                           int bw, int bh, const uint16_t *above,
750                                           const uint16_t *left, int bd) {
751   int r, c;
752   const uint16_t ytop_left = above[-1];
753   (void)bd;
754 
755   for (r = 0; r < bh; r++) {
756     for (c = 0; c < bw; c++)
757       dst[c] = paeth_predictor_single(left[r], above[c], ytop_left);
758     dst += stride;
759   }
760 }
761 
highbd_smooth_predictor(uint16_t * dst,ptrdiff_t stride,int bw,int bh,const uint16_t * above,const uint16_t * left,int bd)762 static INLINE void highbd_smooth_predictor(uint16_t *dst, ptrdiff_t stride,
763                                            int bw, int bh,
764                                            const uint16_t *above,
765                                            const uint16_t *left, int bd) {
766   const uint16_t below_pred = left[bh - 1];   // estimated by bottom-left pixel
767   const uint16_t right_pred = above[bw - 1];  // estimated by top-right pixel
768   const uint8_t *const sm_weights_w = sm_weight_arrays + bw;
769   const uint8_t *const sm_weights_h = sm_weight_arrays + bh;
770   // scale = 2 * 2^sm_weight_log2_scale
771   const int log2_scale = 1 + sm_weight_log2_scale;
772   const uint16_t scale = (1 << sm_weight_log2_scale);
773   sm_weights_sanity_checks(sm_weights_w, sm_weights_h, scale,
774                            log2_scale + sizeof(*dst));
775   int r;
776   for (r = 0; r < bh; ++r) {
777     int c;
778     for (c = 0; c < bw; ++c) {
779       const uint16_t pixels[] = { above[c], below_pred, left[r], right_pred };
780       const uint8_t weights[] = { sm_weights_h[r], scale - sm_weights_h[r],
781                                   sm_weights_w[c], scale - sm_weights_w[c] };
782       uint32_t this_pred = 0;
783       int i;
784       assert(scale >= sm_weights_h[r] && scale >= sm_weights_w[c]);
785       for (i = 0; i < 4; ++i) {
786         this_pred += weights[i] * pixels[i];
787       }
788       dst[c] = clip_pixel_highbd(divide_round(this_pred, log2_scale), bd);
789     }
790     dst += stride;
791   }
792 }
793 
794 #if CONFIG_SMOOTH_HV
highbd_smooth_v_predictor(uint16_t * dst,ptrdiff_t stride,int bw,int bh,const uint16_t * above,const uint16_t * left,int bd)795 static INLINE void highbd_smooth_v_predictor(uint16_t *dst, ptrdiff_t stride,
796                                              int bw, int bh,
797                                              const uint16_t *above,
798                                              const uint16_t *left, int bd) {
799   const uint16_t below_pred = left[bh - 1];  // estimated by bottom-left pixel
800   const uint8_t *const sm_weights = sm_weight_arrays + bh;
801   // scale = 2^sm_weight_log2_scale
802   const int log2_scale = sm_weight_log2_scale;
803   const uint16_t scale = (1 << sm_weight_log2_scale);
804   sm_weights_sanity_checks(sm_weights, sm_weights, scale,
805                            log2_scale + sizeof(*dst));
806 
807   int r;
808   for (r = 0; r < bh; r++) {
809     int c;
810     for (c = 0; c < bw; ++c) {
811       const uint16_t pixels[] = { above[c], below_pred };
812       const uint8_t weights[] = { sm_weights[r], scale - sm_weights[r] };
813       uint32_t this_pred = 0;
814       assert(scale >= sm_weights[r]);
815       int i;
816       for (i = 0; i < 2; ++i) {
817         this_pred += weights[i] * pixels[i];
818       }
819       dst[c] = clip_pixel_highbd(divide_round(this_pred, log2_scale), bd);
820     }
821     dst += stride;
822   }
823 }
824 
highbd_smooth_h_predictor(uint16_t * dst,ptrdiff_t stride,int bw,int bh,const uint16_t * above,const uint16_t * left,int bd)825 static INLINE void highbd_smooth_h_predictor(uint16_t *dst, ptrdiff_t stride,
826                                              int bw, int bh,
827                                              const uint16_t *above,
828                                              const uint16_t *left, int bd) {
829   const uint16_t right_pred = above[bw - 1];  // estimated by top-right pixel
830   const uint8_t *const sm_weights = sm_weight_arrays + bw;
831   // scale = 2^sm_weight_log2_scale
832   const int log2_scale = sm_weight_log2_scale;
833   const uint16_t scale = (1 << sm_weight_log2_scale);
834   sm_weights_sanity_checks(sm_weights, sm_weights, scale,
835                            log2_scale + sizeof(*dst));
836 
837   int r;
838   for (r = 0; r < bh; r++) {
839     int c;
840     for (c = 0; c < bw; ++c) {
841       const uint16_t pixels[] = { left[r], right_pred };
842       const uint8_t weights[] = { sm_weights[c], scale - sm_weights[c] };
843       uint32_t this_pred = 0;
844       assert(scale >= sm_weights[c]);
845       int i;
846       for (i = 0; i < 2; ++i) {
847         this_pred += weights[i] * pixels[i];
848       }
849       dst[c] = clip_pixel_highbd(divide_round(this_pred, log2_scale), bd);
850     }
851     dst += stride;
852   }
853 }
854 #endif  // CONFIG_SMOOTH_HV
855 
highbd_dc_128_predictor(uint16_t * dst,ptrdiff_t stride,int bw,int bh,const uint16_t * above,const uint16_t * left,int bd)856 static INLINE void highbd_dc_128_predictor(uint16_t *dst, ptrdiff_t stride,
857                                            int bw, int bh,
858                                            const uint16_t *above,
859                                            const uint16_t *left, int bd) {
860   int r;
861   (void)above;
862   (void)left;
863 
864   for (r = 0; r < bh; r++) {
865     aom_memset16(dst, 128 << (bd - 8), bw);
866     dst += stride;
867   }
868 }
869 
highbd_dc_left_predictor(uint16_t * dst,ptrdiff_t stride,int bw,int bh,const uint16_t * above,const uint16_t * left,int bd)870 static INLINE void highbd_dc_left_predictor(uint16_t *dst, ptrdiff_t stride,
871                                             int bw, int bh,
872                                             const uint16_t *above,
873                                             const uint16_t *left, int bd) {
874   int i, r, expected_dc, sum = 0;
875   (void)above;
876   (void)bd;
877 
878   for (i = 0; i < bh; i++) sum += left[i];
879   expected_dc = (sum + (bh >> 1)) / bh;
880 
881   for (r = 0; r < bh; r++) {
882     aom_memset16(dst, expected_dc, bw);
883     dst += stride;
884   }
885 }
886 
highbd_dc_top_predictor(uint16_t * dst,ptrdiff_t stride,int bw,int bh,const uint16_t * above,const uint16_t * left,int bd)887 static INLINE void highbd_dc_top_predictor(uint16_t *dst, ptrdiff_t stride,
888                                            int bw, int bh,
889                                            const uint16_t *above,
890                                            const uint16_t *left, int bd) {
891   int i, r, expected_dc, sum = 0;
892   (void)left;
893   (void)bd;
894 
895   for (i = 0; i < bw; i++) sum += above[i];
896   expected_dc = (sum + (bw >> 1)) / bw;
897 
898   for (r = 0; r < bh; r++) {
899     aom_memset16(dst, expected_dc, bw);
900     dst += stride;
901   }
902 }
903 
highbd_dc_predictor(uint16_t * dst,ptrdiff_t stride,int bw,int bh,const uint16_t * above,const uint16_t * left,int bd)904 static INLINE void highbd_dc_predictor(uint16_t *dst, ptrdiff_t stride, int bw,
905                                        int bh, const uint16_t *above,
906                                        const uint16_t *left, int bd) {
907   int i, r, expected_dc, sum = 0;
908   const int count = bw + bh;
909   (void)bd;
910 
911   for (i = 0; i < bw; i++) {
912     sum += above[i];
913   }
914   for (i = 0; i < bh; i++) {
915     sum += left[i];
916   }
917 
918   expected_dc = (sum + (count >> 1)) / count;
919 
920   for (r = 0; r < bh; r++) {
921     aom_memset16(dst, expected_dc, bw);
922     dst += stride;
923   }
924 }
925 #endif  // CONFIG_HIGHBITDEPTH
926 
927 // This serves as a wrapper function, so that all the prediction functions
928 // can be unified and accessed as a pointer array. Note that the boundary
929 // above and left are not necessarily used all the time.
930 #define intra_pred_sized(type, width, height)                  \
931   void aom_##type##_predictor_##width##x##height##_c(          \
932       uint8_t *dst, ptrdiff_t stride, const uint8_t *above,    \
933       const uint8_t *left) {                                   \
934     type##_predictor(dst, stride, width, height, above, left); \
935   }
936 
937 #if CONFIG_HIGHBITDEPTH
938 #define intra_pred_highbd_sized(type, width, height)                        \
939   void aom_highbd_##type##_predictor_##width##x##height##_c(                \
940       uint16_t *dst, ptrdiff_t stride, const uint16_t *above,               \
941       const uint16_t *left, int bd) {                                       \
942     highbd_##type##_predictor(dst, stride, width, height, above, left, bd); \
943   }
944 
945 /* clang-format off */
946 #if CONFIG_TX64X64
947 #define intra_pred_rectangular(type) \
948   intra_pred_sized(type, 4, 8) \
949   intra_pred_sized(type, 8, 4) \
950   intra_pred_sized(type, 8, 16) \
951   intra_pred_sized(type, 16, 8) \
952   intra_pred_sized(type, 16, 32) \
953   intra_pred_sized(type, 32, 16) \
954   intra_pred_sized(type, 32, 64) \
955   intra_pred_sized(type, 64, 32) \
956   intra_pred_highbd_sized(type, 4, 8) \
957   intra_pred_highbd_sized(type, 8, 4) \
958   intra_pred_highbd_sized(type, 8, 16) \
959   intra_pred_highbd_sized(type, 16, 8) \
960   intra_pred_highbd_sized(type, 16, 32) \
961   intra_pred_highbd_sized(type, 32, 16) \
962   intra_pred_highbd_sized(type, 32, 64) \
963   intra_pred_highbd_sized(type, 64, 32)
964 #define intra_pred_above_4x4(type) \
965   intra_pred_sized(type, 8, 8) \
966   intra_pred_sized(type, 16, 16) \
967   intra_pred_sized(type, 32, 32) \
968   intra_pred_sized(type, 64, 64) \
969   intra_pred_highbd_sized(type, 4, 4) \
970   intra_pred_highbd_sized(type, 8, 8) \
971   intra_pred_highbd_sized(type, 16, 16) \
972   intra_pred_highbd_sized(type, 32, 32) \
973   intra_pred_highbd_sized(type, 64, 64) \
974   intra_pred_rectangular(type)
975 #define intra_pred_allsizes(type) \
976   intra_pred_sized(type, 2, 2) \
977   intra_pred_sized(type, 4, 4) \
978   intra_pred_highbd_sized(type, 2, 2) \
979   intra_pred_above_4x4(type)
980 #else  // CONFIG_TX64X64
981 #define intra_pred_rectangular(type) \
982   intra_pred_sized(type, 4, 8) \
983   intra_pred_sized(type, 8, 4) \
984   intra_pred_sized(type, 8, 16) \
985   intra_pred_sized(type, 16, 8) \
986   intra_pred_sized(type, 16, 32) \
987   intra_pred_sized(type, 32, 16) \
988   intra_pred_highbd_sized(type, 4, 8) \
989   intra_pred_highbd_sized(type, 8, 4) \
990   intra_pred_highbd_sized(type, 8, 16) \
991   intra_pred_highbd_sized(type, 16, 8) \
992   intra_pred_highbd_sized(type, 16, 32) \
993   intra_pred_highbd_sized(type, 32, 16)
994 #define intra_pred_above_4x4(type) \
995   intra_pred_sized(type, 8, 8) \
996   intra_pred_sized(type, 16, 16) \
997   intra_pred_sized(type, 32, 32) \
998   intra_pred_highbd_sized(type, 4, 4) \
999   intra_pred_highbd_sized(type, 8, 8) \
1000   intra_pred_highbd_sized(type, 16, 16) \
1001   intra_pred_highbd_sized(type, 32, 32) \
1002   intra_pred_rectangular(type)
1003 #define intra_pred_allsizes(type) \
1004   intra_pred_sized(type, 2, 2) \
1005   intra_pred_sized(type, 4, 4) \
1006   intra_pred_highbd_sized(type, 2, 2) \
1007   intra_pred_above_4x4(type)
1008 #endif  // CONFIG_TX64X64
1009 
1010 #else
1011 
1012 #if CONFIG_TX64X64
1013 #define intra_pred_rectangular(type) \
1014   intra_pred_sized(type, 4, 8) \
1015   intra_pred_sized(type, 8, 4) \
1016   intra_pred_sized(type, 8, 16) \
1017   intra_pred_sized(type, 16, 8) \
1018   intra_pred_sized(type, 16, 32) \
1019   intra_pred_sized(type, 32, 16) \
1020   intra_pred_sized(type, 32, 64) \
1021   intra_pred_sized(type, 64, 32)
1022 #define intra_pred_above_4x4(type) \
1023   intra_pred_sized(type, 8, 8) \
1024   intra_pred_sized(type, 16, 16) \
1025   intra_pred_sized(type, 32, 32) \
1026   intra_pred_sized(type, 64, 64) \
1027   intra_pred_rectangular(type)
1028 #define intra_pred_allsizes(type) \
1029   intra_pred_sized(type, 2, 2) \
1030   intra_pred_sized(type, 4, 4) \
1031   intra_pred_above_4x4(type)
1032 #else  // CONFIG_TX64X64
1033 #define intra_pred_rectangular(type) \
1034   intra_pred_sized(type, 4, 8) \
1035   intra_pred_sized(type, 8, 4) \
1036   intra_pred_sized(type, 8, 16) \
1037   intra_pred_sized(type, 16, 8) \
1038   intra_pred_sized(type, 16, 32) \
1039   intra_pred_sized(type, 32, 16)
1040 #define intra_pred_above_4x4(type) \
1041   intra_pred_sized(type, 8, 8) \
1042   intra_pred_sized(type, 16, 16) \
1043   intra_pred_sized(type, 32, 32) \
1044   intra_pred_rectangular(type)
1045 #define intra_pred_allsizes(type) \
1046   intra_pred_sized(type, 2, 2) \
1047   intra_pred_sized(type, 4, 4) \
1048   intra_pred_above_4x4(type)
1049 #endif  // CONFIG_TX64X64
1050 
1051 #endif  // CONFIG_HIGHBITDEPTH
1052 
1053 intra_pred_allsizes(d207e)
1054 intra_pred_allsizes(d63e)
1055 intra_pred_above_4x4(d45e)
1056 intra_pred_above_4x4(d117)
1057 intra_pred_above_4x4(d135)
1058 intra_pred_above_4x4(d153)
1059 intra_pred_allsizes(v)
1060 intra_pred_allsizes(h)
1061 intra_pred_allsizes(smooth)
1062 #if CONFIG_SMOOTH_HV
1063 intra_pred_allsizes(smooth_v)
1064 intra_pred_allsizes(smooth_h)
1065 #endif  // CONFIG_SMOOTH_HV
1066 intra_pred_allsizes(paeth)
1067 intra_pred_allsizes(dc_128)
1068 intra_pred_allsizes(dc_left)
1069 intra_pred_allsizes(dc_top)
1070 intra_pred_allsizes(dc)
1071 /* clang-format on */
1072 #undef intra_pred_allsizes
1073