Line data Source code
1 : /*
2 : * Copyright(c) 2019 Intel Corporation
3 : * SPDX - License - Identifier: BSD - 2 - Clause - Patent
4 : */
5 :
6 : #ifndef EbIntraPrediction_h
7 : #define EbIntraPrediction_h
8 :
9 : #include "EbIntraPrediction_AVX2.h"
10 :
11 : #include "EbDefinitions.h"
12 : #include "EbUtility.h"
13 : #include "EbPictureBufferDesc.h"
14 : #include "EbPictureControlSet.h"
15 : #include "EbCodingUnit.h"
16 : #include "EbPictureControlSet.h"
17 : #include "EbModeDecision.h"
18 : #include "EbNeighborArrays.h"
19 : #include "EbMotionEstimationProcess.h"
20 : #include "EbObject.h"
21 :
22 : #ifdef __cplusplus
23 : extern "C" {
24 : #endif
25 : #define MAX_PU_SIZE 64
26 :
27 : struct ModeDecisionContext;
28 :
29 : typedef void(*IntraPredFnC)(uint8_t *dst, ptrdiff_t stride, int32_t w, int32_t h,
30 : const uint8_t *above, const uint8_t *left);
31 : typedef void(*IntraHighBdPredFnC)(uint16_t *dst, ptrdiff_t stride, int32_t w, int32_t h,
32 : const uint16_t *above, const uint16_t *left, int32_t bd);
33 :
34 : typedef void(*IntraPredFn)(uint8_t *dst, ptrdiff_t stride,
35 : const uint8_t *above, const uint8_t *left);
36 :
37 : typedef void(*IntraHighPredFn)(uint16_t *dst, ptrdiff_t stride,
38 : const uint16_t *above, const uint16_t *left,
39 : int32_t bd);
40 :
41 : typedef struct IntraReferenceSamples
42 : {
43 : EbDctor dctor;
44 : uint8_t *y_intra_reference_array;
45 : uint8_t *cb_intra_reference_array;
46 : uint8_t *cr_intra_reference_array;
47 : uint8_t *y_intra_filtered_reference_array;
48 :
49 : uint8_t *y_intra_reference_array_reverse;
50 : uint8_t *y_intra_filtered_reference_array_reverse;
51 : uint8_t *cb_intra_reference_array_reverse;
52 : uint8_t *cr_intra_reference_array_reverse;
53 :
54 : // Scratch buffers used in the interpolaiton process
55 : uint8_t reference_above_line_y[(MAX_PU_SIZE << 2) + 1];
56 : uint8_t reference_left_line_y[(MAX_PU_SIZE << 2) + 1];
57 : EbBool above_ready_flag_y;
58 : EbBool left_ready_flag_y;
59 :
60 : uint8_t reference_above_line_cb[(MAX_PU_SIZE << 2) + 2];
61 : uint8_t reference_left_line_cb[(MAX_PU_SIZE << 2) + 2];
62 : EbBool above_ready_flag_cb;
63 : EbBool left_ready_flag_cb;
64 :
65 : uint8_t reference_above_line_cr[(MAX_PU_SIZE << 2) + 2];
66 : uint8_t reference_left_line_cr[(MAX_PU_SIZE << 2) + 2];
67 : EbBool above_ready_flag_cr;
68 : EbBool left_ready_flag_cr;
69 : } IntraReferenceSamples;
70 :
71 : typedef struct IntraReference16bitSamples
72 : {
73 : EbDctor dctor;
74 : uint16_t *y_intra_reference_array;
75 : uint16_t *cb_intra_reference_array;
76 : uint16_t *cr_intra_reference_array;
77 : uint16_t *y_intra_filtered_reference_array;
78 :
79 : uint16_t *y_intra_reference_array_reverse;
80 : uint16_t *y_intra_filtered_reference_array_reverse;
81 : uint16_t *cb_intra_reference_array_reverse;
82 : uint16_t *cr_intra_reference_array_reverse;
83 :
84 : // Scratch buffers used in the interpolaiton process
85 : uint16_t reference_above_line_y[(MAX_PU_SIZE << 2) + 1];
86 : uint16_t reference_left_line_y[(MAX_PU_SIZE << 2) + 1];
87 : EbBool above_ready_flag_y;
88 : EbBool left_ready_flag_y;
89 :
90 : uint16_t reference_above_line_cb[(MAX_PU_SIZE << 2) + 2];
91 : uint16_t reference_left_line_cb[(MAX_PU_SIZE << 2) + 2];
92 : EbBool above_ready_flag_cb;
93 : EbBool left_ready_flag_cb;
94 :
95 : uint16_t reference_above_line_cr[(MAX_PU_SIZE << 2) + 2];
96 : uint16_t reference_left_line_cr[(MAX_PU_SIZE << 2) + 2];
97 : EbBool above_ready_flag_cr;
98 : EbBool left_ready_flag_cr;
99 : } IntraReference16bitSamples;
100 :
101 : #define TOTAL_LUMA_MODES 35
102 : #define TOTAL_CHROMA_MODES 5
103 : #define TOTAL_INTRA_GROUPS 5
104 : #define INTRA_PLANAR_MODE 0
105 : #define INTRA_DC_MODE 1
106 : #define INTRA_HORIZONTAL_MODE 10
107 : #define INTRA_VERTICAL_MODE 26
108 : #define STRONG_INTRA_SMOOTHING_BLOCKSIZE 32
109 : #define SMOOTHING_THRESHOLD 8
110 : #define SMOOTHING_THRESHOLD_10BIT 32
111 :
112 : /////####.... For recursive intra prediction.....#####///
113 :
114 : #define FILTER_INTRA_SCALE_BITS 4
115 : extern const int8_t eb_av1_filter_intra_taps[FILTER_INTRA_MODES][8][8];
116 :
117 : /////####.... To make functions common between EbIntraPrediction.c &
118 : void *eb_aom_memset16(void *dest, int32_t val, size_t length);
119 :
120 : int32_t use_intra_edge_upsample(int32_t bs0, int32_t bs1, int32_t delta,
121 : int32_t type);
122 :
123 : BlockSize scale_chroma_bsize(BlockSize bsize, int32_t subsampling_x,
124 : int32_t subsampling_y);
125 :
126 : int32_t intra_edge_filter_strength(int32_t bs0, int32_t bs1, int32_t delta, int32_t type);
127 :
128 : enum {
129 : NEED_LEFT = 1 << 1,
130 : NEED_ABOVE = 1 << 2,
131 : NEED_ABOVERIGHT = 1 << 3,
132 : NEED_ABOVELEFT = 1 << 4,
133 : NEED_BOTTOMLEFT = 1 << 5,
134 : };
135 :
136 : int is_smooth(const BlockModeInfo *mbmi, int plane);
137 :
138 : extern const uint8_t extend_modes[INTRA_MODES];
139 :
140 : /* TODO: Need to harmonize with fun from EbAdaptiveMotionVectorPrediction.c */
141 : int32_t intra_has_top_right(BlockSize sb_size, BlockSize bsize, int32_t mi_row,
142 : int32_t mi_col, int32_t top_available, int32_t right_available,
143 : PartitionType partition, TxSize txsz, int32_t row_off,
144 : int32_t col_off, int32_t ss_x, int32_t ss_y);
145 :
146 : extern int32_t intra_has_bottom_left(BlockSize sb_size, BlockSize bsize, int32_t mi_row,
147 : int32_t mi_col, int32_t bottom_available, int32_t left_available,
148 : PartitionType partition, TxSize txsz, int32_t row_off,
149 : int32_t col_off, int32_t ss_x, int32_t ss_y);
150 :
151 : extern IntraPredFn pred[INTRA_MODES][TX_SIZES_ALL];
152 : extern IntraPredFn dc_pred[2][2][TX_SIZES_ALL];
153 :
154 : extern IntraHighPredFn pred_high[INTRA_MODES][TX_SIZES_ALL];
155 : extern IntraHighPredFn dc_pred_high[2][2][TX_SIZES_ALL];
156 :
157 : void dr_predictor(uint8_t *dst, ptrdiff_t stride, TxSize tx_size,
158 : const uint8_t *above, const uint8_t *left,
159 : int32_t upsample_above, int32_t upsample_left, int32_t angle);
160 :
161 : void filter_intra_edge_corner(uint8_t *p_above, uint8_t *p_left);
162 :
163 : void highbd_dr_predictor(uint16_t *dst, ptrdiff_t stride,
164 : TxSize tx_size, const uint16_t *above,
165 : const uint16_t *left, int32_t upsample_above,
166 : int32_t upsample_left, int32_t angle, int32_t bd);
167 :
168 : void filter_intra_edge_corner_high(uint16_t *p_above, uint16_t *p_left);
169 :
170 : void highbd_filter_intra_predictor(uint16_t *dst, ptrdiff_t stride,
171 : TxSize tx_size,
172 : const uint16_t *above,
173 : const uint16_t *left, int mode,
174 : int bd);
175 :
176 : /////////..............................................//////////////////////////
177 :
178 : extern EbErrorType eb_av1_intra_prediction_cl(
179 : struct ModeDecisionContext *context_ptr,
180 : PictureControlSet *picture_control_set_ptr,
181 : ModeDecisionCandidateBuffer *candidate_buffer_ptr);
182 :
183 : extern EbErrorType intra_open_loop_reference_samples_ctor(
184 : IntraReferenceSamplesOpenLoop *context_ptr);
185 :
186 : extern EbErrorType update_neighbor_samples_array_open_loop(
187 : uint8_t *above_ref,
188 : uint8_t *left_ref,
189 : EbPictureBufferDesc *input_ptr,
190 : uint32_t stride,
191 : uint32_t srcOriginX,
192 : uint32_t srcOriginY,
193 : uint8_t bwidth,
194 : uint8_t bheight);
195 : extern EbErrorType intra_prediction_open_loop(
196 : int32_t p_angle ,
197 : uint8_t ois_intra_mode,
198 : uint32_t srcOriginX,
199 : uint32_t srcOriginY,
200 : TxSize tx_size,
201 : uint8_t *above_row,
202 : uint8_t *left_col,
203 : MotionEstimationContext_t *context_ptr); // input parameter, ME context
204 :
205 : typedef void(*EB_INTRA_NOANG_TYPE)(
206 : const uint32_t size,
207 : uint8_t *ref_samples,
208 : uint8_t *prediction_ptr,
209 : const uint32_t prediction_buffer_stride,
210 : const EbBool skip);
211 : typedef void(*EB_INTRA_DC_AV1_TYPE)(
212 : EbBool is_left_availble,
213 : EbBool is_above_availble,
214 : const uint32_t size, //input parameter, denotes the size of the current PU
215 : uint8_t *ref_samples, //input parameter, pointer to the reference samples
216 : uint8_t *dst, //output parameter, pointer to the prediction
217 : const uint32_t prediction_buffer_stride, //input parameter, denotes the stride for the prediction ptr
218 : const EbBool skip); //skip half rows
219 : typedef void(*EB_INTRA_NOANG_16bit_TYPE)(
220 : const uint32_t size,
221 : uint16_t *ref_samples,
222 : uint16_t *prediction_ptr,
223 : const uint32_t prediction_buffer_stride,
224 : const EbBool skip);
225 : typedef void(*EB_INTRA_ANG_Z1_Z2_Z3_16bit_TYPE)(
226 : const uint32_t size,
227 : uint16_t *ref_samples,
228 : uint16_t *dst,
229 : const uint32_t prediction_buffer_stride,
230 : const EbBool skip,
231 : uint16_t dx,
232 : uint16_t dy,
233 : uint16_t bd);
234 : typedef void(*EB_INTRA_ANG_TYPE)(
235 : uint32_t size,
236 : uint8_t *ref_samp_main,
237 : uint8_t *prediction_ptr,
238 : uint32_t prediction_buffer_stride,
239 : const EbBool skip,
240 : int32_t intra_pred_angle);
241 : typedef void(*EB_INTRA_ANG_16BIT_TYPE)(
242 : uint32_t size, //input parameter, denotes the size of the current PU
243 : uint16_t *ref_samp_main, //input parameter, pointer to the reference samples
244 : uint16_t *prediction_ptr, //output parameter, pointer to the prediction
245 : uint32_t prediction_buffer_stride, //input parameter, denotes the stride for the prediction ptr
246 : const EbBool skip,
247 : int32_t intra_pred_angle);
248 : extern void intra_mode_planar(
249 : const uint32_t size, //input parameter, denotes the size of the current PU
250 : uint8_t *ref_samples, //input parameter, pointer to the reference samples
251 : uint8_t *dst, //output parameter, pointer to the prediction
252 : const uint32_t prediction_buffer_stride, //input parameter, denotes the stride for the prediction ptr
253 : const EbBool skip);
254 : extern void ebav1_smooth_v_predictor(
255 : const uint32_t size, //input parameter, denotes the size of the current PU
256 : uint8_t *ref_samples, //input parameter, pointer to the reference samples
257 : uint8_t *dst, //output parameter, pointer to the prediction
258 : const uint32_t prediction_buffer_stride, //input parameter, denotes the stride for the prediction ptr
259 : const EbBool skip);
260 : extern void ebav1_smooth_h_predictor(
261 : const uint32_t size, //input parameter, denotes the size of the current PU
262 : uint8_t *ref_samples, //input parameter, pointer to the reference samples
263 : uint8_t *dst, //output parameter, pointer to the prediction
264 : const uint32_t prediction_buffer_stride, //input parameter, denotes the stride for the prediction ptr
265 : const EbBool skip);
266 :
267 : void intra_mode_angular_av1_z1_16bit(
268 : const uint32_t size, //input parameter, denotes the size of the current PU
269 : uint16_t *ref_samples, //input parameter, pointer to the reference samples
270 : uint16_t *dst, //output parameter, pointer to the prediction
271 : const uint32_t prediction_buffer_stride, //input parameter, denotes the stride for the prediction ptr
272 : const EbBool skip,
273 : uint16_t dx, //output parameter, pointer to the prediction
274 : uint16_t dy, //output parameter, pointer to the prediction
275 : uint16_t bd);
276 :
277 : void intra_mode_angular_av1_z2_16bit(
278 : const uint32_t size, //input parameter, denotes the size of the current PU
279 : uint16_t *ref_samples, //input parameter, pointer to the reference samples
280 : uint16_t *dst, //output parameter, pointer to the prediction
281 : const uint32_t prediction_buffer_stride, //input parameter, denotes the stride for the prediction ptr
282 : const EbBool skip,
283 : uint16_t dx, //output parameter, pointer to the prediction
284 : uint16_t dy, //output parameter, pointer to the prediction
285 : uint16_t bd);
286 :
287 : void intra_mode_angular_av1_z3_16bit(
288 : const uint32_t size, //input parameter, denotes the size of the current PU
289 : uint16_t *ref_samples, //input parameter, pointer to the reference samples
290 : uint16_t *dst, //output parameter, pointer to the prediction
291 : const uint32_t prediction_buffer_stride, //input parameter, denotes the stride for the prediction ptr
292 : const EbBool skip,
293 : uint16_t dx, //output parameter, pointer to the prediction
294 : uint16_t dy, //output parameter, pointer to the prediction
295 : uint16_t bd);
296 :
297 : typedef struct CflCtx {
298 : // Q3 reconstructed luma pixels (only Q2 is required, but Q3 is used to avoid
299 : // shifts)
300 : EB_ALIGN(64) int16_t recon_buf_q3[CFL_BUF_SQUARE];
301 :
302 : // Height and width currently used in the CfL prediction buffer.
303 : int32_t buf_height, buf_width;
304 :
305 : int32_t are_parameters_computed;
306 :
307 : // Chroma subsampling
308 : int32_t subsampling_x, subsampling_y;
309 : } CflCtx;
310 :
311 : extern void cfl_luma_subsampling_420_lbd_c(
312 : const uint8_t *input, // AMIR-> Changed to 8 bit
313 : int32_t input_stride, int16_t *output_q3,
314 : int32_t width, int32_t height);
315 : extern void cfl_luma_subsampling_420_hbd_c(
316 : const uint16_t *input,
317 : int32_t input_stride, int16_t *output_q3,
318 : int32_t width, int32_t height);
319 : extern void eb_subtract_average_c(
320 : int16_t *pred_buf_q3,
321 : int32_t width,
322 : int32_t height,
323 : int32_t round_offset,
324 : int32_t num_pel_log2);
325 :
326 : #define ROUND_POWER_OF_TWO_SIGNED(value, n) \
327 : (((value) < 0) ? -ROUND_POWER_OF_TWO(-(value), (n)) \
328 : : ROUND_POWER_OF_TWO((value), (n)))
329 :
330 0 : static INLINE int32_t get_scaled_luma_q0(int32_t alpha_q3, int16_t pred_buf_q3) {
331 0 : int32_t scaled_luma_q6 = alpha_q3 * pred_buf_q3;
332 0 : return ROUND_POWER_OF_TWO_SIGNED(scaled_luma_q6, 6);
333 : }
334 :
335 : //CFL_PREDICT_FN(c, lbd)
336 :
337 : void eb_cfl_predict_lbd_c(
338 : const int16_t *pred_buf_q3,
339 : uint8_t *pred,// AMIR ADDED
340 : int32_t pred_stride,
341 : uint8_t *dst,// AMIR changed to 8 bit
342 : int32_t dst_stride,
343 : int32_t alpha_q3,
344 : int32_t bit_depth,
345 : int32_t width,
346 : int32_t height);
347 :
348 : void eb_cfl_predict_hbd_c(
349 : const int16_t *pred_buf_q3,
350 : uint16_t *pred,// AMIR ADDED
351 : int32_t pred_stride,
352 : uint16_t *dst,// AMIR changed to 8 bit
353 : int32_t dst_stride,
354 : int32_t alpha_q3,
355 : int32_t bit_depth,
356 : int32_t width,
357 : int32_t height);
358 :
359 6226 : static INLINE int32_t cfl_idx_to_alpha(int32_t alpha_idx, int32_t joint_sign,
360 : CflPredType pred_type) {
361 9339 : const int32_t alpha_sign = (pred_type == CFL_PRED_U) ? CFL_SIGN_U(joint_sign)
362 6226 : : CFL_SIGN_V(joint_sign);
363 6226 : if (alpha_sign == CFL_SIGN_ZERO) return 0;
364 5794 : const int32_t abs_alpha_q3 =
365 5794 : (pred_type == CFL_PRED_U) ? CFL_IDX_U(alpha_idx) : CFL_IDX_V(alpha_idx);
366 5794 : return (alpha_sign == CFL_SIGN_POS) ? abs_alpha_q3 + 1 : -abs_alpha_q3 - 1;
367 : }
368 :
369 : /* Function pointers return by CfL functions */
370 :
371 : typedef void(*cfl_subsample_lbd_fn)(const uint8_t *input, int input_stride,
372 : int16_t *output_q3);
373 :
374 : typedef void(*cfl_subsample_hbd_fn)(const uint16_t *input, int input_stride,
375 : int16_t *output_q3);
376 :
377 : typedef void(*cfl_subtract_average_fn)(int16_t *dst);
378 :
379 : typedef void(*cfl_predict_lbd_fn)(const int16_t *pred_buf_q3, uint8_t *pred, int32_t pred_stride,
380 : uint8_t *dst, int32_t dst_stride, int32_t alpha_q3, int32_t bit_depth, int32_t width, int32_t height);
381 :
382 : typedef void(*cfl_predict_hbd_fn)(const int16_t *src, uint16_t *dst,
383 : int dst_stride, int alpha_q3, int bd);
384 :
385 : #define cfl_get_luma_subsampling_420_hbd cfl_get_luma_subsampling_420_hbd_c
386 : cfl_subsample_hbd_fn cfl_get_luma_subsampling_420_hbd_c(TxSize tx_size);
387 :
388 : #define cfl_get_luma_subsampling_420_lbd cfl_get_luma_subsampling_420_lbd_c
389 : cfl_subsample_lbd_fn cfl_get_luma_subsampling_420_lbd_c(TxSize tx_size);
390 :
391 : #define cfl_get_luma_subsampling_422_hbd cfl_get_luma_subsampling_422_hbd_c
392 : cfl_subsample_hbd_fn cfl_get_luma_subsampling_422_hbd_c(TxSize tx_size);
393 :
394 : #define cfl_get_luma_subsampling_422_lbd cfl_get_luma_subsampling_422_lbd_c
395 : cfl_subsample_lbd_fn cfl_get_luma_subsampling_422_lbd_c(TxSize tx_size);
396 :
397 : #define cfl_get_luma_subsampling_444_hbd cfl_get_luma_subsampling_444_hbd_c
398 : cfl_subsample_hbd_fn cfl_get_luma_subsampling_444_hbd_c(TxSize tx_size);
399 :
400 : #define cfl_get_luma_subsampling_444_lbd cfl_get_luma_subsampling_444_lbd_c
401 : cfl_subsample_lbd_fn cfl_get_luma_subsampling_444_lbd_c(TxSize tx_size);
402 :
403 : cfl_subtract_average_fn eb_get_subtract_average_fn_c(TxSize tx_size);
404 : #define get_subtract_average_fn eb_get_subtract_average_fn_c
405 :
406 : // Allows the CFL_SUBSAMPLE function to switch types depending on the bitdepth.
407 : #define CFL_lbd_TYPE uint8_t *cfl_type
408 : #define CFL_hbd_TYPE uint16_t *cfl_type
409 :
410 : // Declare a size-specific wrapper for the size-generic function. The compiler
411 : // will inline the size generic function in here, the advantage is that the size
412 : // will be constant allowing for loop unrolling and other constant propagated
413 : // goodness.
414 : #define CFL_SUBSAMPLE(arch, sub, bd, width, height) \
415 : void subsample_##bd##_##sub##_##width##x##height##_##arch( \
416 : const CFL_##bd##_TYPE, int input_stride, int16_t *output_q3) { \
417 : cfl_luma_subsampling_##sub##_##bd##_##arch(cfl_type, input_stride, \
418 : output_q3, width, height); \
419 : }
420 :
421 : // Declare size-specific wrappers for all valid CfL sizes.
422 : #define CFL_SUBSAMPLE_FUNCTIONS(arch, sub, bd) \
423 : CFL_SUBSAMPLE(arch, sub, bd, 4, 4) \
424 : CFL_SUBSAMPLE(arch, sub, bd, 8, 8) \
425 : CFL_SUBSAMPLE(arch, sub, bd, 16, 16) \
426 : CFL_SUBSAMPLE(arch, sub, bd, 32, 32) \
427 : CFL_SUBSAMPLE(arch, sub, bd, 4, 8) \
428 : CFL_SUBSAMPLE(arch, sub, bd, 8, 4) \
429 : CFL_SUBSAMPLE(arch, sub, bd, 8, 16) \
430 : CFL_SUBSAMPLE(arch, sub, bd, 16, 8) \
431 : CFL_SUBSAMPLE(arch, sub, bd, 16, 32) \
432 : CFL_SUBSAMPLE(arch, sub, bd, 32, 16) \
433 : CFL_SUBSAMPLE(arch, sub, bd, 4, 16) \
434 : CFL_SUBSAMPLE(arch, sub, bd, 16, 4) \
435 : CFL_SUBSAMPLE(arch, sub, bd, 8, 32) \
436 : CFL_SUBSAMPLE(arch, sub, bd, 32, 8) \
437 : cfl_subsample_##bd##_fn cfl_get_luma_subsampling_##sub##_##bd##_##arch( \
438 : TxSize tx_size) { \
439 : CFL_SUBSAMPLE_FUNCTION_ARRAY(arch, sub, bd) \
440 : return subfn_##sub[tx_size]; \
441 : }
442 :
443 : // Declare an architecture-specific array of function pointers for size-specific
444 : // wrappers.
445 : #define CFL_SUBSAMPLE_FUNCTION_ARRAY(arch, sub, bd) \
446 : const cfl_subsample_##bd##_fn subfn_##sub[TX_SIZES_ALL] = { \
447 : subsample_##bd##_##sub##_4x4_##arch, /* 4x4 */ \
448 : subsample_##bd##_##sub##_8x8_##arch, /* 8x8 */ \
449 : subsample_##bd##_##sub##_16x16_##arch, /* 16x16 */ \
450 : subsample_##bd##_##sub##_32x32_##arch, /* 32x32 */ \
451 : NULL, /* 64x64 (invalid CFL size) */ \
452 : subsample_##bd##_##sub##_4x8_##arch, /* 4x8 */ \
453 : subsample_##bd##_##sub##_8x4_##arch, /* 8x4 */ \
454 : subsample_##bd##_##sub##_8x16_##arch, /* 8x16 */ \
455 : subsample_##bd##_##sub##_16x8_##arch, /* 16x8 */ \
456 : subsample_##bd##_##sub##_16x32_##arch, /* 16x32 */ \
457 : subsample_##bd##_##sub##_32x16_##arch, /* 32x16 */ \
458 : NULL, /* 32x64 (invalid CFL size) */ \
459 : NULL, /* 64x32 (invalid CFL size) */ \
460 : subsample_##bd##_##sub##_4x16_##arch, /* 4x16 */ \
461 : subsample_##bd##_##sub##_16x4_##arch, /* 16x4 */ \
462 : subsample_##bd##_##sub##_8x32_##arch, /* 8x32 */ \
463 : subsample_##bd##_##sub##_32x8_##arch, /* 32x8 */ \
464 : NULL, /* 16x64 (invalid CFL size) */ \
465 : NULL, /* 64x16 (invalid CFL size) */ \
466 : };
467 :
468 : // The RTCD script does not support passing in an array, so we wrap it in this
469 : // function.
470 : #define CFL_GET_SUBSAMPLE_FUNCTION(arch) \
471 : CFL_SUBSAMPLE_FUNCTIONS(arch, 420, lbd) \
472 : CFL_SUBSAMPLE_FUNCTIONS(arch, 422, lbd) \
473 : CFL_SUBSAMPLE_FUNCTIONS(arch, 444, lbd) \
474 : CFL_SUBSAMPLE_FUNCTIONS(arch, 420, hbd) \
475 : CFL_SUBSAMPLE_FUNCTIONS(arch, 422, hbd) \
476 : CFL_SUBSAMPLE_FUNCTIONS(arch, 444, hbd)
477 :
478 : // Declare a size-specific wrapper for the size-generic function. The compiler
479 : // will inline the size generic function in here, the advantage is that the size
480 : // will be constant allowing for loop unrolling and other constant propagated
481 : // goodness.
482 : #define CFL_SUB_AVG_X(arch, width, height, round_offset, num_pel_log2) \
483 : void eb_subtract_average_##width##x##height##_##arch(int16_t *buf) { \
484 : eb_subtract_average_##arch(buf, width, height, round_offset, \
485 : num_pel_log2); \
486 : }
487 :
488 : // Declare size-specific wrappers for all valid CfL sizes.
489 : #define CFL_SUB_AVG_FN(arch) \
490 : CFL_SUB_AVG_X(arch, 4, 4, 8, 4) \
491 : CFL_SUB_AVG_X(arch, 4, 8, 16, 5) \
492 : CFL_SUB_AVG_X(arch, 4, 16, 32, 6) \
493 : CFL_SUB_AVG_X(arch, 8, 4, 16, 5) \
494 : CFL_SUB_AVG_X(arch, 8, 8, 32, 6) \
495 : CFL_SUB_AVG_X(arch, 8, 16, 64, 7) \
496 : CFL_SUB_AVG_X(arch, 8, 32, 128, 8) \
497 : CFL_SUB_AVG_X(arch, 16, 4, 32, 6) \
498 : CFL_SUB_AVG_X(arch, 16, 8, 64, 7) \
499 : CFL_SUB_AVG_X(arch, 16, 16, 128, 8) \
500 : CFL_SUB_AVG_X(arch, 16, 32, 256, 9) \
501 : CFL_SUB_AVG_X(arch, 32, 8, 128, 8) \
502 : CFL_SUB_AVG_X(arch, 32, 16, 256, 9) \
503 : CFL_SUB_AVG_X(arch, 32, 32, 512, 10) \
504 : cfl_subtract_average_fn eb_get_subtract_average_fn_##arch(TxSize tx_size) { \
505 : const cfl_subtract_average_fn sub_avg[TX_SIZES_ALL] = { \
506 : eb_subtract_average_4x4_##arch, /* 4x4 */ \
507 : eb_subtract_average_8x8_##arch, /* 8x8 */ \
508 : eb_subtract_average_16x16_##arch, /* 16x16 */ \
509 : eb_subtract_average_32x32_##arch, /* 32x32 */ \
510 : NULL, /* 64x64 (invalid CFL size) */ \
511 : eb_subtract_average_4x8_##arch, /* 4x8 */ \
512 : eb_subtract_average_8x4_##arch, /* 8x4 */ \
513 : eb_subtract_average_8x16_##arch, /* 8x16 */ \
514 : eb_subtract_average_16x8_##arch, /* 16x8 */ \
515 : eb_subtract_average_16x32_##arch, /* 16x32 */ \
516 : eb_subtract_average_32x16_##arch, /* 32x16 */ \
517 : NULL, /* 32x64 (invalid CFL size) */ \
518 : NULL, /* 64x32 (invalid CFL size) */ \
519 : eb_subtract_average_4x16_##arch, /* 4x16 (invalid CFL size) */ \
520 : eb_subtract_average_16x4_##arch, /* 16x4 (invalid CFL size) */ \
521 : eb_subtract_average_8x32_##arch, /* 8x32 (invalid CFL size) */ \
522 : eb_subtract_average_32x8_##arch, /* 32x8 (invalid CFL size) */ \
523 : NULL, /* 16x64 (invalid CFL size) */ \
524 : NULL, /* 64x16 (invalid CFL size) */ \
525 : }; \
526 : /* Modulo TX_SIZES_ALL to ensure that an attacker won't be able to */ \
527 : /* index the function pointer array out of bounds. */ \
528 : return sub_avg[tx_size % TX_SIZES_ALL]; \
529 : }
530 :
531 : void eb_av1_predict_intra_block(
532 : TileInfo *tile,
533 : STAGE stage,
534 : const BlockGeom *blk_geom,
535 : const Av1Common *cm,
536 : int32_t wpx,
537 : int32_t hpx,
538 : TxSize tx_size,
539 : PredictionMode mode,
540 : int32_t angle_delta,
541 : int32_t use_palette,
542 : #if PAL_SUP
543 : PaletteInfo *palette_info,
544 : #endif
545 : FilterIntraMode filter_intra_mode,
546 : uint8_t* topNeighArray,
547 : uint8_t* leftNeighArray,
548 : EbPictureBufferDesc *recon_buffer,
549 : int32_t col_off,
550 : int32_t row_off,
551 : int32_t plane,
552 : BlockSize bsize,
553 : uint32_t tu_org_x_pict,
554 : uint32_t tu_org_y_pict,
555 : uint32_t bl_org_x_pict,
556 : uint32_t bl_org_y_pict,
557 : uint32_t bl_org_x_mb,
558 : uint32_t bl_org_y_mb);
559 :
560 : void eb_av1_predict_intra_block_16bit(
561 : TileInfo * tile,
562 : STAGE stage,
563 : const BlockGeom * blk_geom,
564 : const Av1Common *cm,
565 : int32_t wpx,
566 : int32_t hpx,
567 : TxSize tx_size,
568 : PredictionMode mode,
569 : int32_t angle_delta,
570 : int32_t use_palette,
571 : #if PAL_SUP
572 : PaletteInfo *palette_info,
573 : #endif
574 : FilterIntraMode filter_intra_mode,
575 : uint16_t* topNeighArray,
576 : uint16_t* leftNeighArray,
577 : EbPictureBufferDesc *recon_buffer,
578 : int32_t col_off,
579 : int32_t row_off,
580 : int32_t plane,
581 : BlockSize bsize,
582 : uint32_t tu_org_x_pict,
583 : uint32_t tu_org_y_pict,
584 : uint32_t bl_org_x_pict,
585 : uint32_t bl_org_y_pict,
586 : uint32_t bl_org_x_mb,
587 : uint32_t bl_org_y_mb);
588 :
589 : #ifdef __cplusplus
590 : }
591 : #endif
592 : #endif // EbIntraPrediction_h
|