blob: 196676ec85ec758bc06ec7c8411f389e6275c695 [file] [log] [blame]
Satish Kumar Suman897b7942020-06-11 11:44:29 +05301/*
2 * Copyright (c) 2020, 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#ifndef AOM_AV1_ENCODER_ENCODER_UTILS_H_
13#define AOM_AV1_ENCODER_ENCODER_UTILS_H_
14
Jayasanker Jdee179d2020-07-10 23:47:37 +053015#include "config/aom_dsp_rtcd.h"
16#include "config/aom_scale_rtcd.h"
17
Satish Kumar Suman897b7942020-06-11 11:44:29 +053018#include "av1/encoder/encoder.h"
19#include "av1/encoder/encodetxb.h"
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25#define AM_SEGMENT_ID_INACTIVE 7
26#define AM_SEGMENT_ID_ACTIVE 0
Jayasanker Jdee179d2020-07-10 23:47:37 +053027#define DUMP_RECON_FRAMES 0
Satish Kumar Suman897b7942020-06-11 11:44:29 +053028
Jayasanker Jdee179d2020-07-10 23:47:37 +053029extern const int default_tx_type_probs[FRAME_UPDATE_TYPES][TX_SIZES_ALL]
30 [TX_TYPES];
Satish Kumar Suman897b7942020-06-11 11:44:29 +053031
Jayasanker Jdee179d2020-07-10 23:47:37 +053032extern const int default_obmc_probs[FRAME_UPDATE_TYPES][BLOCK_SIZES_ALL];
Satish Kumar Suman897b7942020-06-11 11:44:29 +053033
Jayasanker Jdee179d2020-07-10 23:47:37 +053034extern const int default_warped_probs[FRAME_UPDATE_TYPES];
Satish Kumar Suman897b7942020-06-11 11:44:29 +053035
Jayasanker Jdee179d2020-07-10 23:47:37 +053036extern const int default_switchable_interp_probs[FRAME_UPDATE_TYPES]
37 [SWITCHABLE_FILTER_CONTEXTS]
38 [SWITCHABLE_FILTERS];
Satish Kumar Suman897b7942020-06-11 11:44:29 +053039
40// Mark all inactive blocks as active. Other segmentation features may be set
41// so memset cannot be used, instead only inactive blocks should be reset.
42static AOM_INLINE void suppress_active_map(AV1_COMP *cpi) {
43 unsigned char *const seg_map = cpi->enc_seg.map;
44 int i;
chiyotsaiae4339f2022-11-16 10:44:11 -080045 const int num_mis =
46 cpi->common.mi_params.mi_rows * cpi->common.mi_params.mi_cols;
Satish Kumar Suman897b7942020-06-11 11:44:29 +053047 if (cpi->active_map.enabled || cpi->active_map.update)
chiyotsaiae4339f2022-11-16 10:44:11 -080048 for (i = 0; i < num_mis; ++i)
Satish Kumar Suman897b7942020-06-11 11:44:29 +053049 if (seg_map[i] == AM_SEGMENT_ID_INACTIVE)
50 seg_map[i] = AM_SEGMENT_ID_ACTIVE;
51}
52
Wan-Teh Chang071e3792022-09-02 13:28:50 -070053// Returns 'size' in the number of Mode Info (MI) units. 'size' is either the
54// width or height.
55static AOM_INLINE int size_in_mi(int size) {
Satish Kumar Suman897b7942020-06-11 11:44:29 +053056 // Ensure that the decoded width and height are both multiples of
57 // 8 luma pixels (note: this may only be a multiple of 4 chroma pixels if
58 // subsampling is used).
59 // This simplifies the implementation of various experiments,
60 // eg. cdef, which operates on units of 8x8 luma pixels.
Wan-Teh Chang071e3792022-09-02 13:28:50 -070061 const int aligned_size = ALIGN_POWER_OF_TWO(size, 3);
62 return aligned_size >> MI_SIZE_LOG2;
63}
Satish Kumar Suman897b7942020-06-11 11:44:29 +053064
Wan-Teh Chang071e3792022-09-02 13:28:50 -070065static AOM_INLINE void set_mb_mi(CommonModeInfoParams *mi_params, int width,
66 int height) {
67 mi_params->mi_cols = size_in_mi(width);
68 mi_params->mi_rows = size_in_mi(height);
Satish Kumar Suman897b7942020-06-11 11:44:29 +053069 mi_params->mi_stride = calc_mi_size(mi_params->mi_cols);
70
Wan-Teh Changee8848a2022-09-07 16:49:38 -070071 mi_params->mb_cols = ROUND_POWER_OF_TWO(mi_params->mi_cols, 2);
72 mi_params->mb_rows = ROUND_POWER_OF_TWO(mi_params->mi_rows, 2);
Satish Kumar Suman897b7942020-06-11 11:44:29 +053073 mi_params->MBs = mi_params->mb_rows * mi_params->mb_cols;
74
75 const int mi_alloc_size_1d = mi_size_wide[mi_params->mi_alloc_bsize];
76 mi_params->mi_alloc_stride =
77 (mi_params->mi_stride + mi_alloc_size_1d - 1) / mi_alloc_size_1d;
78
79 assert(mi_size_wide[mi_params->mi_alloc_bsize] ==
80 mi_size_high[mi_params->mi_alloc_bsize]);
Satish Kumar Suman897b7942020-06-11 11:44:29 +053081}
82
83static AOM_INLINE void enc_free_mi(CommonModeInfoParams *mi_params) {
84 aom_free(mi_params->mi_alloc);
85 mi_params->mi_alloc = NULL;
86 aom_free(mi_params->mi_grid_base);
87 mi_params->mi_grid_base = NULL;
88 mi_params->mi_alloc_size = 0;
89 aom_free(mi_params->tx_type_map);
90 mi_params->tx_type_map = NULL;
91}
92
93static AOM_INLINE void enc_set_mb_mi(CommonModeInfoParams *mi_params, int width,
Jayasanker Jfb666962022-03-29 18:56:42 +053094 int height,
Aniket Wanareb7d55292021-11-02 14:07:51 +053095 BLOCK_SIZE min_partition_size) {
Jayasanker Jfb666962022-03-29 18:56:42 +053096 mi_params->mi_alloc_bsize = min_partition_size;
Satish Kumar Suman897b7942020-06-11 11:44:29 +053097
98 set_mb_mi(mi_params, width, height);
99}
100
101static AOM_INLINE void stat_stage_set_mb_mi(CommonModeInfoParams *mi_params,
Jayasanker Jfb666962022-03-29 18:56:42 +0530102 int width, int height,
Aniket Wanareb7d55292021-11-02 14:07:51 +0530103 BLOCK_SIZE min_partition_size) {
Aniket Wanareb7d55292021-11-02 14:07:51 +0530104 (void)min_partition_size;
Satish Kumar Suman897b7942020-06-11 11:44:29 +0530105 mi_params->mi_alloc_bsize = BLOCK_16X16;
106
107 set_mb_mi(mi_params, width, height);
108}
109
110static AOM_INLINE void enc_setup_mi(CommonModeInfoParams *mi_params) {
111 const int mi_grid_size =
112 mi_params->mi_stride * calc_mi_size(mi_params->mi_rows);
113 memset(mi_params->mi_alloc, 0,
114 mi_params->mi_alloc_size * sizeof(*mi_params->mi_alloc));
115 memset(mi_params->mi_grid_base, 0,
116 mi_grid_size * sizeof(*mi_params->mi_grid_base));
117 memset(mi_params->tx_type_map, 0,
118 mi_grid_size * sizeof(*mi_params->tx_type_map));
119}
120
Satish Kumar Suman897b7942020-06-11 11:44:29 +0530121static AOM_INLINE void init_buffer_indices(
122 ForceIntegerMVInfo *const force_intpel_info, int *const remapped_ref_idx) {
123 int fb_idx;
124 for (fb_idx = 0; fb_idx < REF_FRAMES; ++fb_idx)
125 remapped_ref_idx[fb_idx] = fb_idx;
126 force_intpel_info->rate_index = 0;
127 force_intpel_info->rate_size = 0;
128}
129
chiyotsaia4c4f182022-12-05 14:41:05 -0800130#define HIGHBD_BFP(BT, SDF, SDAF, VF, SVF, SVAF, SDX4DF, SDX3DF, JSDAF, JSVAF) \
131 ppi->fn_ptr[BT].sdf = SDF; \
132 ppi->fn_ptr[BT].sdaf = SDAF; \
133 ppi->fn_ptr[BT].vf = VF; \
134 ppi->fn_ptr[BT].svf = SVF; \
135 ppi->fn_ptr[BT].svaf = SVAF; \
136 ppi->fn_ptr[BT].sdx4df = SDX4DF; \
137 ppi->fn_ptr[BT].sdx3df = SDX3DF; \
138 ppi->fn_ptr[BT].jsdaf = JSDAF; \
Mufaddal Chakera16796272021-02-24 14:03:29 +0530139 ppi->fn_ptr[BT].jsvaf = JSVAF;
Satish Kumar Suman897b7942020-06-11 11:44:29 +0530140
Satish Kumar Sumane52cc7d2020-06-12 11:51:06 +0530141#define HIGHBD_BFP_WRAPPER(WIDTH, HEIGHT, BD) \
142 HIGHBD_BFP( \
143 BLOCK_##WIDTH##X##HEIGHT, aom_highbd_sad##WIDTH##x##HEIGHT##_bits##BD, \
144 aom_highbd_sad##WIDTH##x##HEIGHT##_avg_bits##BD, \
145 aom_highbd_##BD##_variance##WIDTH##x##HEIGHT, \
146 aom_highbd_##BD##_sub_pixel_variance##WIDTH##x##HEIGHT, \
147 aom_highbd_##BD##_sub_pixel_avg_variance##WIDTH##x##HEIGHT, \
148 aom_highbd_sad##WIDTH##x##HEIGHT##x4d_bits##BD, \
chiyotsaia4c4f182022-12-05 14:41:05 -0800149 aom_highbd_sad##WIDTH##x##HEIGHT##x3d_bits##BD, \
Satish Kumar Sumane52cc7d2020-06-12 11:51:06 +0530150 aom_highbd_dist_wtd_sad##WIDTH##x##HEIGHT##_avg_bits##BD, \
151 aom_highbd_##BD##_dist_wtd_sub_pixel_avg_variance##WIDTH##x##HEIGHT)
152
Satish Kumar Suman897b7942020-06-11 11:44:29 +0530153#define MAKE_BFP_SAD_WRAPPER(fnname) \
154 static unsigned int fnname##_bits8(const uint8_t *src_ptr, \
155 int source_stride, \
156 const uint8_t *ref_ptr, int ref_stride) { \
157 return fnname(src_ptr, source_stride, ref_ptr, ref_stride); \
158 } \
159 static unsigned int fnname##_bits10( \
160 const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, \
161 int ref_stride) { \
162 return fnname(src_ptr, source_stride, ref_ptr, ref_stride) >> 2; \
163 } \
164 static unsigned int fnname##_bits12( \
165 const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, \
166 int ref_stride) { \
167 return fnname(src_ptr, source_stride, ref_ptr, ref_stride) >> 4; \
168 }
169
170#define MAKE_BFP_SADAVG_WRAPPER(fnname) \
171 static unsigned int fnname##_bits8( \
172 const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, \
173 int ref_stride, const uint8_t *second_pred) { \
174 return fnname(src_ptr, source_stride, ref_ptr, ref_stride, second_pred); \
175 } \
176 static unsigned int fnname##_bits10( \
177 const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, \
178 int ref_stride, const uint8_t *second_pred) { \
179 return fnname(src_ptr, source_stride, ref_ptr, ref_stride, second_pred) >> \
180 2; \
181 } \
182 static unsigned int fnname##_bits12( \
183 const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, \
184 int ref_stride, const uint8_t *second_pred) { \
185 return fnname(src_ptr, source_stride, ref_ptr, ref_stride, second_pred) >> \
186 4; \
187 }
188
189#define MAKE_BFP_SAD4D_WRAPPER(fnname) \
190 static void fnname##_bits8(const uint8_t *src_ptr, int source_stride, \
191 const uint8_t *const ref_ptr[], int ref_stride, \
192 unsigned int *sad_array) { \
193 fnname(src_ptr, source_stride, ref_ptr, ref_stride, sad_array); \
194 } \
195 static void fnname##_bits10(const uint8_t *src_ptr, int source_stride, \
196 const uint8_t *const ref_ptr[], int ref_stride, \
197 unsigned int *sad_array) { \
198 int i; \
199 fnname(src_ptr, source_stride, ref_ptr, ref_stride, sad_array); \
200 for (i = 0; i < 4; i++) sad_array[i] >>= 2; \
201 } \
202 static void fnname##_bits12(const uint8_t *src_ptr, int source_stride, \
203 const uint8_t *const ref_ptr[], int ref_stride, \
204 unsigned int *sad_array) { \
205 int i; \
206 fnname(src_ptr, source_stride, ref_ptr, ref_stride, sad_array); \
207 for (i = 0; i < 4; i++) sad_array[i] >>= 4; \
208 }
209
210#define MAKE_BFP_JSADAVG_WRAPPER(fnname) \
211 static unsigned int fnname##_bits8( \
212 const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, \
213 int ref_stride, const uint8_t *second_pred, \
214 const DIST_WTD_COMP_PARAMS *jcp_param) { \
215 return fnname(src_ptr, source_stride, ref_ptr, ref_stride, second_pred, \
216 jcp_param); \
217 } \
218 static unsigned int fnname##_bits10( \
219 const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, \
220 int ref_stride, const uint8_t *second_pred, \
221 const DIST_WTD_COMP_PARAMS *jcp_param) { \
222 return fnname(src_ptr, source_stride, ref_ptr, ref_stride, second_pred, \
223 jcp_param) >> \
224 2; \
225 } \
226 static unsigned int fnname##_bits12( \
227 const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, \
228 int ref_stride, const uint8_t *second_pred, \
229 const DIST_WTD_COMP_PARAMS *jcp_param) { \
230 return fnname(src_ptr, source_stride, ref_ptr, ref_stride, second_pred, \
231 jcp_param) >> \
232 4; \
233 }
234
235#if CONFIG_AV1_HIGHBITDEPTH
236MAKE_BFP_SAD_WRAPPER(aom_highbd_sad128x128)
237MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad128x128_avg)
238MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad128x128x4d)
chiyotsaia4c4f182022-12-05 14:41:05 -0800239MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad128x128x3d)
Satish Kumar Suman897b7942020-06-11 11:44:29 +0530240MAKE_BFP_SAD_WRAPPER(aom_highbd_sad128x64)
241MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad128x64_avg)
242MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad128x64x4d)
chiyotsaia4c4f182022-12-05 14:41:05 -0800243MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad128x64x3d)
Satish Kumar Suman897b7942020-06-11 11:44:29 +0530244MAKE_BFP_SAD_WRAPPER(aom_highbd_sad64x128)
245MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad64x128_avg)
246MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad64x128x4d)
chiyotsaia4c4f182022-12-05 14:41:05 -0800247MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad64x128x3d)
Satish Kumar Suman897b7942020-06-11 11:44:29 +0530248MAKE_BFP_SAD_WRAPPER(aom_highbd_sad32x16)
249MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad32x16_avg)
250MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad32x16x4d)
chiyotsaia4c4f182022-12-05 14:41:05 -0800251MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad32x16x3d)
Satish Kumar Suman897b7942020-06-11 11:44:29 +0530252MAKE_BFP_SAD_WRAPPER(aom_highbd_sad16x32)
253MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad16x32_avg)
254MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad16x32x4d)
chiyotsaia4c4f182022-12-05 14:41:05 -0800255MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad16x32x3d)
Satish Kumar Suman897b7942020-06-11 11:44:29 +0530256MAKE_BFP_SAD_WRAPPER(aom_highbd_sad64x32)
257MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad64x32_avg)
258MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad64x32x4d)
chiyotsaia4c4f182022-12-05 14:41:05 -0800259MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad64x32x3d)
Satish Kumar Suman897b7942020-06-11 11:44:29 +0530260MAKE_BFP_SAD_WRAPPER(aom_highbd_sad32x64)
261MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad32x64_avg)
262MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad32x64x4d)
chiyotsaia4c4f182022-12-05 14:41:05 -0800263MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad32x64x3d)
Satish Kumar Suman897b7942020-06-11 11:44:29 +0530264MAKE_BFP_SAD_WRAPPER(aom_highbd_sad32x32)
265MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad32x32_avg)
266MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad32x32x4d)
chiyotsaia4c4f182022-12-05 14:41:05 -0800267MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad32x32x3d)
Satish Kumar Suman897b7942020-06-11 11:44:29 +0530268MAKE_BFP_SAD_WRAPPER(aom_highbd_sad64x64)
269MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad64x64_avg)
270MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad64x64x4d)
chiyotsaia4c4f182022-12-05 14:41:05 -0800271MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad64x64x3d)
Satish Kumar Suman897b7942020-06-11 11:44:29 +0530272MAKE_BFP_SAD_WRAPPER(aom_highbd_sad16x16)
273MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad16x16_avg)
274MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad16x16x4d)
chiyotsaia4c4f182022-12-05 14:41:05 -0800275MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad16x16x3d)
Satish Kumar Suman897b7942020-06-11 11:44:29 +0530276MAKE_BFP_SAD_WRAPPER(aom_highbd_sad16x8)
277MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad16x8_avg)
278MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad16x8x4d)
chiyotsaia4c4f182022-12-05 14:41:05 -0800279MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad16x8x3d)
Satish Kumar Suman897b7942020-06-11 11:44:29 +0530280MAKE_BFP_SAD_WRAPPER(aom_highbd_sad8x16)
281MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad8x16_avg)
282MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad8x16x4d)
chiyotsaia4c4f182022-12-05 14:41:05 -0800283MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad8x16x3d)
Satish Kumar Suman897b7942020-06-11 11:44:29 +0530284MAKE_BFP_SAD_WRAPPER(aom_highbd_sad8x8)
285MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad8x8_avg)
286MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad8x8x4d)
chiyotsaia4c4f182022-12-05 14:41:05 -0800287MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad8x8x3d)
Satish Kumar Suman897b7942020-06-11 11:44:29 +0530288MAKE_BFP_SAD_WRAPPER(aom_highbd_sad8x4)
289MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad8x4_avg)
290MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad8x4x4d)
chiyotsaia4c4f182022-12-05 14:41:05 -0800291MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad8x4x3d)
Satish Kumar Suman897b7942020-06-11 11:44:29 +0530292MAKE_BFP_SAD_WRAPPER(aom_highbd_sad4x8)
293MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad4x8_avg)
294MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad4x8x4d)
chiyotsaia4c4f182022-12-05 14:41:05 -0800295MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad4x8x3d)
Satish Kumar Suman897b7942020-06-11 11:44:29 +0530296MAKE_BFP_SAD_WRAPPER(aom_highbd_sad4x4)
297MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad4x4_avg)
298MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad4x4x4d)
chiyotsaia4c4f182022-12-05 14:41:05 -0800299MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad4x4x3d)
Satish Kumar Suman897b7942020-06-11 11:44:29 +0530300
Jerome Jiangc381ba82020-10-30 14:55:57 -0700301#if !CONFIG_REALTIME_ONLY
Satish Kumar Suman897b7942020-06-11 11:44:29 +0530302MAKE_BFP_SAD_WRAPPER(aom_highbd_sad4x16)
303MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad4x16_avg)
304MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad4x16x4d)
chiyotsaia4c4f182022-12-05 14:41:05 -0800305MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad4x16x3d)
Satish Kumar Suman897b7942020-06-11 11:44:29 +0530306MAKE_BFP_SAD_WRAPPER(aom_highbd_sad16x4)
307MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad16x4_avg)
308MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad16x4x4d)
chiyotsaia4c4f182022-12-05 14:41:05 -0800309MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad16x4x3d)
Satish Kumar Suman897b7942020-06-11 11:44:29 +0530310MAKE_BFP_SAD_WRAPPER(aom_highbd_sad8x32)
311MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad8x32_avg)
312MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad8x32x4d)
chiyotsaia4c4f182022-12-05 14:41:05 -0800313MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad8x32x3d)
Satish Kumar Suman897b7942020-06-11 11:44:29 +0530314MAKE_BFP_SAD_WRAPPER(aom_highbd_sad32x8)
315MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad32x8_avg)
316MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad32x8x4d)
chiyotsaia4c4f182022-12-05 14:41:05 -0800317MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad32x8x3d)
Satish Kumar Suman897b7942020-06-11 11:44:29 +0530318MAKE_BFP_SAD_WRAPPER(aom_highbd_sad16x64)
319MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad16x64_avg)
320MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad16x64x4d)
chiyotsaia4c4f182022-12-05 14:41:05 -0800321MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad16x64x3d)
Satish Kumar Suman897b7942020-06-11 11:44:29 +0530322MAKE_BFP_SAD_WRAPPER(aom_highbd_sad64x16)
323MAKE_BFP_SADAVG_WRAPPER(aom_highbd_sad64x16_avg)
324MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad64x16x4d)
chiyotsaia4c4f182022-12-05 14:41:05 -0800325MAKE_BFP_SAD4D_WRAPPER(aom_highbd_sad64x16x3d)
Jerome Jiangc381ba82020-10-30 14:55:57 -0700326#endif
Satish Kumar Suman897b7942020-06-11 11:44:29 +0530327
328MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad128x128_avg)
329MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad128x64_avg)
330MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad64x128_avg)
331MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad32x16_avg)
332MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad16x32_avg)
333MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad64x32_avg)
334MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad32x64_avg)
335MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad32x32_avg)
336MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad64x64_avg)
337MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad16x16_avg)
338MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad16x8_avg)
339MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad8x16_avg)
340MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad8x8_avg)
341MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad8x4_avg)
342MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad4x8_avg)
343MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad4x4_avg)
Jerome Jiangc381ba82020-10-30 14:55:57 -0700344#if !CONFIG_REALTIME_ONLY
Satish Kumar Suman897b7942020-06-11 11:44:29 +0530345MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad4x16_avg)
346MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad16x4_avg)
347MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad8x32_avg)
348MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad32x8_avg)
349MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad16x64_avg)
350MAKE_BFP_JSADAVG_WRAPPER(aom_highbd_dist_wtd_sad64x16_avg)
Jerome Jiangc381ba82020-10-30 14:55:57 -0700351#endif
Satish Kumar Suman897b7942020-06-11 11:44:29 +0530352#endif // CONFIG_AV1_HIGHBITDEPTH
353
354#define HIGHBD_MBFP(BT, MCSDF, MCSVF) \
Mufaddal Chakera16796272021-02-24 14:03:29 +0530355 ppi->fn_ptr[BT].msdf = MCSDF; \
356 ppi->fn_ptr[BT].msvf = MCSVF;
Satish Kumar Suman897b7942020-06-11 11:44:29 +0530357
Satish Kumar Sumane52cc7d2020-06-12 11:51:06 +0530358#define HIGHBD_MBFP_WRAPPER(WIDTH, HEIGHT, BD) \
359 HIGHBD_MBFP(BLOCK_##WIDTH##X##HEIGHT, \
360 aom_highbd_masked_sad##WIDTH##x##HEIGHT##_bits##BD, \
361 aom_highbd_##BD##_masked_sub_pixel_variance##WIDTH##x##HEIGHT)
362
Satish Kumar Suman897b7942020-06-11 11:44:29 +0530363#define MAKE_MBFP_COMPOUND_SAD_WRAPPER(fnname) \
364 static unsigned int fnname##_bits8( \
365 const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, \
366 int ref_stride, const uint8_t *second_pred_ptr, const uint8_t *m, \
367 int m_stride, int invert_mask) { \
368 return fnname(src_ptr, source_stride, ref_ptr, ref_stride, \
369 second_pred_ptr, m, m_stride, invert_mask); \
370 } \
371 static unsigned int fnname##_bits10( \
372 const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, \
373 int ref_stride, const uint8_t *second_pred_ptr, const uint8_t *m, \
374 int m_stride, int invert_mask) { \
375 return fnname(src_ptr, source_stride, ref_ptr, ref_stride, \
376 second_pred_ptr, m, m_stride, invert_mask) >> \
377 2; \
378 } \
379 static unsigned int fnname##_bits12( \
380 const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, \
381 int ref_stride, const uint8_t *second_pred_ptr, const uint8_t *m, \
382 int m_stride, int invert_mask) { \
383 return fnname(src_ptr, source_stride, ref_ptr, ref_stride, \
384 second_pred_ptr, m, m_stride, invert_mask) >> \
385 4; \
386 }
387
388#if CONFIG_AV1_HIGHBITDEPTH
389MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad128x128)
390MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad128x64)
391MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad64x128)
392MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad64x64)
393MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad64x32)
394MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad32x64)
395MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad32x32)
396MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad32x16)
397MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad16x32)
398MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad16x16)
399MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad16x8)
400MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad8x16)
401MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad8x8)
402MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad8x4)
403MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad4x8)
404MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad4x4)
Jerome Jiangc381ba82020-10-30 14:55:57 -0700405#if !CONFIG_REALTIME_ONLY
Satish Kumar Suman897b7942020-06-11 11:44:29 +0530406MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad4x16)
407MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad16x4)
408MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad8x32)
409MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad32x8)
410MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad16x64)
411MAKE_MBFP_COMPOUND_SAD_WRAPPER(aom_highbd_masked_sad64x16)
412#endif
Jerome Jiangc381ba82020-10-30 14:55:57 -0700413#endif
Satish Kumar Suman897b7942020-06-11 11:44:29 +0530414
Aasaipriya Cda788c72020-09-17 13:40:55 +0530415#define HIGHBD_SDSFP(BT, SDSF, SDSX4DF) \
Mufaddal Chakera16796272021-02-24 14:03:29 +0530416 ppi->fn_ptr[BT].sdsf = SDSF; \
417 ppi->fn_ptr[BT].sdsx4df = SDSX4DF;
Aasaipriya Cda788c72020-09-17 13:40:55 +0530418
419#define HIGHBD_SDSFP_WRAPPER(WIDTH, HEIGHT, BD) \
420 HIGHBD_SDSFP(BLOCK_##WIDTH##X##HEIGHT, \
421 aom_highbd_sad_skip_##WIDTH##x##HEIGHT##_bits##BD, \
422 aom_highbd_sad_skip_##WIDTH##x##HEIGHT##x4d##_bits##BD)
423
424#define MAKE_SDSF_SKIP_SAD_WRAPPER(fnname) \
425 static unsigned int fnname##_bits8(const uint8_t *src, int src_stride, \
426 const uint8_t *ref, int ref_stride) { \
427 return fnname(src, src_stride, ref, ref_stride); \
428 } \
429 static unsigned int fnname##_bits10(const uint8_t *src, int src_stride, \
430 const uint8_t *ref, int ref_stride) { \
431 return fnname(src, src_stride, ref, ref_stride) >> 2; \
432 } \
433 static unsigned int fnname##_bits12(const uint8_t *src, int src_stride, \
434 const uint8_t *ref, int ref_stride) { \
435 return fnname(src, src_stride, ref, ref_stride) >> 4; \
436 }
437
438#define MAKE_SDSF_SKIP_SAD_4D_WRAPPER(fnname) \
439 static void fnname##_bits8(const uint8_t *src_ptr, int source_stride, \
440 const uint8_t *const ref_ptr[], int ref_stride, \
441 unsigned int *sad_array) { \
442 fnname(src_ptr, source_stride, ref_ptr, ref_stride, sad_array); \
443 } \
444 static void fnname##_bits10(const uint8_t *src_ptr, int source_stride, \
445 const uint8_t *const ref_ptr[], int ref_stride, \
446 unsigned int *sad_array) { \
447 int i; \
448 fnname(src_ptr, source_stride, ref_ptr, ref_stride, sad_array); \
449 for (i = 0; i < 4; i++) sad_array[i] >>= 2; \
450 } \
451 static void fnname##_bits12(const uint8_t *src_ptr, int source_stride, \
452 const uint8_t *const ref_ptr[], int ref_stride, \
453 unsigned int *sad_array) { \
454 int i; \
455 fnname(src_ptr, source_stride, ref_ptr, ref_stride, sad_array); \
456 for (i = 0; i < 4; i++) sad_array[i] >>= 4; \
457 }
458
459#if CONFIG_AV1_HIGHBITDEPTH
460MAKE_SDSF_SKIP_SAD_WRAPPER(aom_highbd_sad_skip_128x128)
461MAKE_SDSF_SKIP_SAD_WRAPPER(aom_highbd_sad_skip_128x64)
462MAKE_SDSF_SKIP_SAD_WRAPPER(aom_highbd_sad_skip_64x128)
463MAKE_SDSF_SKIP_SAD_WRAPPER(aom_highbd_sad_skip_64x64)
464MAKE_SDSF_SKIP_SAD_WRAPPER(aom_highbd_sad_skip_64x32)
Aasaipriya Cda788c72020-09-17 13:40:55 +0530465MAKE_SDSF_SKIP_SAD_WRAPPER(aom_highbd_sad_skip_32x64)
466MAKE_SDSF_SKIP_SAD_WRAPPER(aom_highbd_sad_skip_32x32)
467MAKE_SDSF_SKIP_SAD_WRAPPER(aom_highbd_sad_skip_32x16)
Aasaipriya Cda788c72020-09-17 13:40:55 +0530468MAKE_SDSF_SKIP_SAD_WRAPPER(aom_highbd_sad_skip_16x32)
469MAKE_SDSF_SKIP_SAD_WRAPPER(aom_highbd_sad_skip_16x16)
470MAKE_SDSF_SKIP_SAD_WRAPPER(aom_highbd_sad_skip_16x8)
471MAKE_SDSF_SKIP_SAD_WRAPPER(aom_highbd_sad_skip_8x16)
472MAKE_SDSF_SKIP_SAD_WRAPPER(aom_highbd_sad_skip_8x8)
Aasaipriya Cda788c72020-09-17 13:40:55 +0530473MAKE_SDSF_SKIP_SAD_WRAPPER(aom_highbd_sad_skip_4x8)
Jerome Jiangc381ba82020-10-30 14:55:57 -0700474
475#if !CONFIG_REALTIME_ONLY
476MAKE_SDSF_SKIP_SAD_WRAPPER(aom_highbd_sad_skip_64x16)
477MAKE_SDSF_SKIP_SAD_WRAPPER(aom_highbd_sad_skip_32x8)
478MAKE_SDSF_SKIP_SAD_WRAPPER(aom_highbd_sad_skip_16x64)
479MAKE_SDSF_SKIP_SAD_WRAPPER(aom_highbd_sad_skip_4x16)
Aasaipriya Cda788c72020-09-17 13:40:55 +0530480MAKE_SDSF_SKIP_SAD_WRAPPER(aom_highbd_sad_skip_8x32)
Jerome Jiangc381ba82020-10-30 14:55:57 -0700481#endif
Aasaipriya Cda788c72020-09-17 13:40:55 +0530482
483MAKE_SDSF_SKIP_SAD_4D_WRAPPER(aom_highbd_sad_skip_128x128x4d)
484MAKE_SDSF_SKIP_SAD_4D_WRAPPER(aom_highbd_sad_skip_128x64x4d)
485MAKE_SDSF_SKIP_SAD_4D_WRAPPER(aom_highbd_sad_skip_64x128x4d)
486MAKE_SDSF_SKIP_SAD_4D_WRAPPER(aom_highbd_sad_skip_64x64x4d)
487MAKE_SDSF_SKIP_SAD_4D_WRAPPER(aom_highbd_sad_skip_64x32x4d)
Aasaipriya Cda788c72020-09-17 13:40:55 +0530488MAKE_SDSF_SKIP_SAD_4D_WRAPPER(aom_highbd_sad_skip_32x64x4d)
489MAKE_SDSF_SKIP_SAD_4D_WRAPPER(aom_highbd_sad_skip_32x32x4d)
490MAKE_SDSF_SKIP_SAD_4D_WRAPPER(aom_highbd_sad_skip_32x16x4d)
Aasaipriya Cda788c72020-09-17 13:40:55 +0530491MAKE_SDSF_SKIP_SAD_4D_WRAPPER(aom_highbd_sad_skip_16x32x4d)
492MAKE_SDSF_SKIP_SAD_4D_WRAPPER(aom_highbd_sad_skip_16x16x4d)
493MAKE_SDSF_SKIP_SAD_4D_WRAPPER(aom_highbd_sad_skip_16x8x4d)
494MAKE_SDSF_SKIP_SAD_4D_WRAPPER(aom_highbd_sad_skip_8x16x4d)
495MAKE_SDSF_SKIP_SAD_4D_WRAPPER(aom_highbd_sad_skip_8x8x4d)
Aasaipriya Cda788c72020-09-17 13:40:55 +0530496MAKE_SDSF_SKIP_SAD_4D_WRAPPER(aom_highbd_sad_skip_4x8x4d)
Jerome Jiangc381ba82020-10-30 14:55:57 -0700497
498#if !CONFIG_REALTIME_ONLY
499MAKE_SDSF_SKIP_SAD_4D_WRAPPER(aom_highbd_sad_skip_64x16x4d)
500MAKE_SDSF_SKIP_SAD_4D_WRAPPER(aom_highbd_sad_skip_32x8x4d)
501MAKE_SDSF_SKIP_SAD_4D_WRAPPER(aom_highbd_sad_skip_16x64x4d)
502MAKE_SDSF_SKIP_SAD_4D_WRAPPER(aom_highbd_sad_skip_4x16x4d)
Aasaipriya Cda788c72020-09-17 13:40:55 +0530503MAKE_SDSF_SKIP_SAD_4D_WRAPPER(aom_highbd_sad_skip_8x32x4d)
504#endif
Jerome Jiangc381ba82020-10-30 14:55:57 -0700505#endif
Aasaipriya Cda788c72020-09-17 13:40:55 +0530506
Jerome Jiang4567c352020-10-29 13:10:31 -0700507#if !CONFIG_REALTIME_ONLY
508
Jerome Jiang4567c352020-10-29 13:10:31 -0700509#if CONFIG_AV1_HIGHBITDEPTH
Jerome Jiang5a1b33b2021-02-10 11:37:44 -0800510#define HIGHBD_OBFP_WRAPPER_8(WIDTH, HEIGHT) \
511 HIGHBD_OBFP(BLOCK_##WIDTH##X##HEIGHT, \
512 aom_highbd_obmc_sad##WIDTH##x##HEIGHT##_bits8, \
Gerda Zsejke More476a7642023-07-14 15:36:42 +0200513 aom_highbd_8_obmc_variance##WIDTH##x##HEIGHT, \
514 aom_highbd_8_obmc_sub_pixel_variance##WIDTH##x##HEIGHT)
Jerome Jiang5a1b33b2021-02-10 11:37:44 -0800515
Satish Kumar Suman897b7942020-06-11 11:44:29 +0530516#define HIGHBD_OBFP(BT, OSDF, OVF, OSVF) \
Mufaddal Chakera16796272021-02-24 14:03:29 +0530517 ppi->fn_ptr[BT].osdf = OSDF; \
518 ppi->fn_ptr[BT].ovf = OVF; \
519 ppi->fn_ptr[BT].osvf = OSVF;
Satish Kumar Suman897b7942020-06-11 11:44:29 +0530520
Satish Kumar Sumane52cc7d2020-06-12 11:51:06 +0530521#define HIGHBD_OBFP_WRAPPER(WIDTH, HEIGHT, BD) \
522 HIGHBD_OBFP(BLOCK_##WIDTH##X##HEIGHT, \
523 aom_highbd_obmc_sad##WIDTH##x##HEIGHT##_bits##BD, \
524 aom_highbd_##BD##_obmc_variance##WIDTH##x##HEIGHT, \
525 aom_highbd_##BD##_obmc_sub_pixel_variance##WIDTH##x##HEIGHT)
526
Satish Kumar Suman897b7942020-06-11 11:44:29 +0530527#define MAKE_OBFP_SAD_WRAPPER(fnname) \
Jerome Jiang5a1b33b2021-02-10 11:37:44 -0800528 static unsigned int fnname##_bits8(const uint8_t *ref, int ref_stride, \
529 const int32_t *wsrc, \
530 const int32_t *msk) { \
531 return fnname(ref, ref_stride, wsrc, msk); \
532 } \
Satish Kumar Suman897b7942020-06-11 11:44:29 +0530533 static unsigned int fnname##_bits10(const uint8_t *ref, int ref_stride, \
534 const int32_t *wsrc, \
535 const int32_t *msk) { \
536 return fnname(ref, ref_stride, wsrc, msk) >> 2; \
537 } \
538 static unsigned int fnname##_bits12(const uint8_t *ref, int ref_stride, \
539 const int32_t *wsrc, \
540 const int32_t *msk) { \
541 return fnname(ref, ref_stride, wsrc, msk) >> 4; \
542 }
Jerome Jiang4567c352020-10-29 13:10:31 -0700543#endif // CONFIG_AV1_HIGHBITDEPTH
544#endif // !CONFIG_REALTIME_ONLY
Satish Kumar Suman897b7942020-06-11 11:44:29 +0530545
546#if CONFIG_AV1_HIGHBITDEPTH
Jerome Jiang4567c352020-10-29 13:10:31 -0700547#if !CONFIG_REALTIME_ONLY
Satish Kumar Suman897b7942020-06-11 11:44:29 +0530548MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad128x128)
549MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad128x64)
550MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad64x128)
551MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad64x64)
552MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad64x32)
553MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad32x64)
554MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad32x32)
555MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad32x16)
556MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad16x32)
557MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad16x16)
558MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad16x8)
559MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad8x16)
560MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad8x8)
561MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad8x4)
562MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad4x8)
563MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad4x4)
564MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad4x16)
565MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad16x4)
566MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad8x32)
567MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad32x8)
568MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad16x64)
569MAKE_OBFP_SAD_WRAPPER(aom_highbd_obmc_sad64x16)
Jerome Jiang4567c352020-10-29 13:10:31 -0700570#endif
Satish Kumar Sumanee14de92020-06-12 15:42:05 +0530571
Mufaddal Chakera16796272021-02-24 14:03:29 +0530572static AOM_INLINE void highbd_set_var_fns(AV1_PRIMARY *const ppi) {
573 SequenceHeader *const seq_params = &ppi->seq_params;
574 if (seq_params->use_highbitdepth) {
575 switch (seq_params->bit_depth) {
Satish Kumar Sumanee14de92020-06-12 15:42:05 +0530576 case AOM_BITS_8:
Jerome Jiangc381ba82020-10-30 14:55:57 -0700577#if !CONFIG_REALTIME_ONLY
Satish Kumar Sumanee14de92020-06-12 15:42:05 +0530578 HIGHBD_BFP_WRAPPER(64, 16, 8)
579 HIGHBD_BFP_WRAPPER(16, 64, 8)
580 HIGHBD_BFP_WRAPPER(32, 8, 8)
581 HIGHBD_BFP_WRAPPER(8, 32, 8)
582 HIGHBD_BFP_WRAPPER(16, 4, 8)
583 HIGHBD_BFP_WRAPPER(4, 16, 8)
Jerome Jiangc381ba82020-10-30 14:55:57 -0700584#endif
Satish Kumar Sumanee14de92020-06-12 15:42:05 +0530585 HIGHBD_BFP_WRAPPER(32, 16, 8)
586 HIGHBD_BFP_WRAPPER(16, 32, 8)
587 HIGHBD_BFP_WRAPPER(64, 32, 8)
588 HIGHBD_BFP_WRAPPER(32, 64, 8)
589 HIGHBD_BFP_WRAPPER(32, 32, 8)
590 HIGHBD_BFP_WRAPPER(64, 64, 8)
591 HIGHBD_BFP_WRAPPER(16, 16, 8)
592 HIGHBD_BFP_WRAPPER(16, 8, 8)
593 HIGHBD_BFP_WRAPPER(8, 16, 8)
594 HIGHBD_BFP_WRAPPER(8, 8, 8)
595 HIGHBD_BFP_WRAPPER(8, 4, 8)
596 HIGHBD_BFP_WRAPPER(4, 8, 8)
597 HIGHBD_BFP_WRAPPER(4, 4, 8)
598 HIGHBD_BFP_WRAPPER(128, 128, 8)
599 HIGHBD_BFP_WRAPPER(128, 64, 8)
600 HIGHBD_BFP_WRAPPER(64, 128, 8)
601
602 HIGHBD_MBFP_WRAPPER(128, 128, 8)
603 HIGHBD_MBFP_WRAPPER(128, 64, 8)
604 HIGHBD_MBFP_WRAPPER(64, 128, 8)
605 HIGHBD_MBFP_WRAPPER(64, 64, 8)
606 HIGHBD_MBFP_WRAPPER(64, 32, 8)
607 HIGHBD_MBFP_WRAPPER(32, 64, 8)
608 HIGHBD_MBFP_WRAPPER(32, 32, 8)
609 HIGHBD_MBFP_WRAPPER(32, 16, 8)
610 HIGHBD_MBFP_WRAPPER(16, 32, 8)
611 HIGHBD_MBFP_WRAPPER(16, 16, 8)
612 HIGHBD_MBFP_WRAPPER(8, 16, 8)
613 HIGHBD_MBFP_WRAPPER(16, 8, 8)
614 HIGHBD_MBFP_WRAPPER(8, 8, 8)
615 HIGHBD_MBFP_WRAPPER(4, 8, 8)
616 HIGHBD_MBFP_WRAPPER(8, 4, 8)
617 HIGHBD_MBFP_WRAPPER(4, 4, 8)
Jerome Jiangc381ba82020-10-30 14:55:57 -0700618#if !CONFIG_REALTIME_ONLY
Satish Kumar Sumanee14de92020-06-12 15:42:05 +0530619 HIGHBD_MBFP_WRAPPER(64, 16, 8)
620 HIGHBD_MBFP_WRAPPER(16, 64, 8)
621 HIGHBD_MBFP_WRAPPER(32, 8, 8)
622 HIGHBD_MBFP_WRAPPER(8, 32, 8)
623 HIGHBD_MBFP_WRAPPER(16, 4, 8)
624 HIGHBD_MBFP_WRAPPER(4, 16, 8)
Jerome Jiangc381ba82020-10-30 14:55:57 -0700625#endif
Satish Kumar Sumanee14de92020-06-12 15:42:05 +0530626
Jerome Jiangc381ba82020-10-30 14:55:57 -0700627// OBMC excluded from realtime only build.
Jerome Jiang4567c352020-10-29 13:10:31 -0700628#if !CONFIG_REALTIME_ONLY
Jerome Jiang5a1b33b2021-02-10 11:37:44 -0800629 HIGHBD_OBFP_WRAPPER_8(128, 128)
630 HIGHBD_OBFP_WRAPPER_8(128, 64)
631 HIGHBD_OBFP_WRAPPER_8(64, 128)
632 HIGHBD_OBFP_WRAPPER_8(64, 64)
633 HIGHBD_OBFP_WRAPPER_8(64, 32)
634 HIGHBD_OBFP_WRAPPER_8(32, 64)
635 HIGHBD_OBFP_WRAPPER_8(32, 32)
636 HIGHBD_OBFP_WRAPPER_8(32, 16)
637 HIGHBD_OBFP_WRAPPER_8(16, 32)
638 HIGHBD_OBFP_WRAPPER_8(16, 16)
639 HIGHBD_OBFP_WRAPPER_8(8, 16)
640 HIGHBD_OBFP_WRAPPER_8(16, 8)
641 HIGHBD_OBFP_WRAPPER_8(8, 8)
642 HIGHBD_OBFP_WRAPPER_8(4, 8)
643 HIGHBD_OBFP_WRAPPER_8(8, 4)
644 HIGHBD_OBFP_WRAPPER_8(4, 4)
645 HIGHBD_OBFP_WRAPPER_8(64, 16)
646 HIGHBD_OBFP_WRAPPER_8(16, 64)
647 HIGHBD_OBFP_WRAPPER_8(32, 8)
648 HIGHBD_OBFP_WRAPPER_8(8, 32)
649 HIGHBD_OBFP_WRAPPER_8(16, 4)
650 HIGHBD_OBFP_WRAPPER_8(4, 16)
Jerome Jiang4567c352020-10-29 13:10:31 -0700651#endif
Aasaipriya Cda788c72020-09-17 13:40:55 +0530652
James Zernf2658a32022-02-09 10:18:38 -0800653 HIGHBD_SDSFP_WRAPPER(128, 128, 8)
654 HIGHBD_SDSFP_WRAPPER(128, 64, 8)
655 HIGHBD_SDSFP_WRAPPER(64, 128, 8)
656 HIGHBD_SDSFP_WRAPPER(64, 64, 8)
657 HIGHBD_SDSFP_WRAPPER(64, 32, 8)
658 HIGHBD_SDSFP_WRAPPER(32, 64, 8)
659 HIGHBD_SDSFP_WRAPPER(32, 32, 8)
660 HIGHBD_SDSFP_WRAPPER(32, 16, 8)
661 HIGHBD_SDSFP_WRAPPER(16, 32, 8)
662 HIGHBD_SDSFP_WRAPPER(16, 16, 8)
663 HIGHBD_SDSFP_WRAPPER(16, 8, 8)
664 HIGHBD_SDSFP_WRAPPER(8, 16, 8)
665 HIGHBD_SDSFP_WRAPPER(8, 8, 8)
666 HIGHBD_SDSFP_WRAPPER(4, 8, 8)
Jerome Jiangc381ba82020-10-30 14:55:57 -0700667#if !CONFIG_REALTIME_ONLY
James Zernf2658a32022-02-09 10:18:38 -0800668 HIGHBD_SDSFP_WRAPPER(64, 16, 8)
669 HIGHBD_SDSFP_WRAPPER(32, 8, 8)
670 HIGHBD_SDSFP_WRAPPER(16, 64, 8)
671 HIGHBD_SDSFP_WRAPPER(8, 32, 8)
672 HIGHBD_SDSFP_WRAPPER(4, 16, 8)
Jerome Jiangc381ba82020-10-30 14:55:57 -0700673#endif
Satish Kumar Sumanee14de92020-06-12 15:42:05 +0530674 break;
675
676 case AOM_BITS_10:
Jerome Jiangc381ba82020-10-30 14:55:57 -0700677#if !CONFIG_REALTIME_ONLY
Satish Kumar Sumanee14de92020-06-12 15:42:05 +0530678 HIGHBD_BFP_WRAPPER(64, 16, 10)
679 HIGHBD_BFP_WRAPPER(16, 64, 10)
680 HIGHBD_BFP_WRAPPER(32, 8, 10)
681 HIGHBD_BFP_WRAPPER(8, 32, 10)
682 HIGHBD_BFP_WRAPPER(16, 4, 10)
683 HIGHBD_BFP_WRAPPER(4, 16, 10)
Jerome Jiangc381ba82020-10-30 14:55:57 -0700684#endif
Satish Kumar Sumanee14de92020-06-12 15:42:05 +0530685 HIGHBD_BFP_WRAPPER(32, 16, 10)
686 HIGHBD_BFP_WRAPPER(16, 32, 10)
687 HIGHBD_BFP_WRAPPER(64, 32, 10)
688 HIGHBD_BFP_WRAPPER(32, 64, 10)
689 HIGHBD_BFP_WRAPPER(32, 32, 10)
690 HIGHBD_BFP_WRAPPER(64, 64, 10)
691 HIGHBD_BFP_WRAPPER(16, 16, 10)
692 HIGHBD_BFP_WRAPPER(16, 8, 10)
693 HIGHBD_BFP_WRAPPER(8, 16, 10)
694 HIGHBD_BFP_WRAPPER(8, 8, 10)
695 HIGHBD_BFP_WRAPPER(8, 4, 10)
696 HIGHBD_BFP_WRAPPER(4, 8, 10)
697 HIGHBD_BFP_WRAPPER(4, 4, 10)
698 HIGHBD_BFP_WRAPPER(128, 128, 10)
699 HIGHBD_BFP_WRAPPER(128, 64, 10)
700 HIGHBD_BFP_WRAPPER(64, 128, 10)
701
702 HIGHBD_MBFP_WRAPPER(128, 128, 10)
703 HIGHBD_MBFP_WRAPPER(128, 64, 10)
704 HIGHBD_MBFP_WRAPPER(64, 128, 10)
705 HIGHBD_MBFP_WRAPPER(64, 64, 10)
706 HIGHBD_MBFP_WRAPPER(64, 32, 10)
707 HIGHBD_MBFP_WRAPPER(32, 64, 10)
708 HIGHBD_MBFP_WRAPPER(32, 32, 10)
709 HIGHBD_MBFP_WRAPPER(32, 16, 10)
710 HIGHBD_MBFP_WRAPPER(16, 32, 10)
711 HIGHBD_MBFP_WRAPPER(16, 16, 10)
712 HIGHBD_MBFP_WRAPPER(8, 16, 10)
713 HIGHBD_MBFP_WRAPPER(16, 8, 10)
714 HIGHBD_MBFP_WRAPPER(8, 8, 10)
715 HIGHBD_MBFP_WRAPPER(4, 8, 10)
716 HIGHBD_MBFP_WRAPPER(8, 4, 10)
717 HIGHBD_MBFP_WRAPPER(4, 4, 10)
Jerome Jiangc381ba82020-10-30 14:55:57 -0700718#if !CONFIG_REALTIME_ONLY
Satish Kumar Sumanee14de92020-06-12 15:42:05 +0530719 HIGHBD_MBFP_WRAPPER(64, 16, 10)
720 HIGHBD_MBFP_WRAPPER(16, 64, 10)
721 HIGHBD_MBFP_WRAPPER(32, 8, 10)
722 HIGHBD_MBFP_WRAPPER(8, 32, 10)
723 HIGHBD_MBFP_WRAPPER(16, 4, 10)
724 HIGHBD_MBFP_WRAPPER(4, 16, 10)
Jerome Jiangc381ba82020-10-30 14:55:57 -0700725#endif
Satish Kumar Sumanee14de92020-06-12 15:42:05 +0530726
Jerome Jiangc381ba82020-10-30 14:55:57 -0700727// OBMC excluded from realtime only build.
Jerome Jiang4567c352020-10-29 13:10:31 -0700728#if !CONFIG_REALTIME_ONLY
Satish Kumar Sumanee14de92020-06-12 15:42:05 +0530729 HIGHBD_OBFP_WRAPPER(128, 128, 10)
730 HIGHBD_OBFP_WRAPPER(128, 64, 10)
731 HIGHBD_OBFP_WRAPPER(64, 128, 10)
732 HIGHBD_OBFP_WRAPPER(64, 64, 10)
733 HIGHBD_OBFP_WRAPPER(64, 32, 10)
734 HIGHBD_OBFP_WRAPPER(32, 64, 10)
735 HIGHBD_OBFP_WRAPPER(32, 32, 10)
736 HIGHBD_OBFP_WRAPPER(32, 16, 10)
737 HIGHBD_OBFP_WRAPPER(16, 32, 10)
738 HIGHBD_OBFP_WRAPPER(16, 16, 10)
739 HIGHBD_OBFP_WRAPPER(8, 16, 10)
740 HIGHBD_OBFP_WRAPPER(16, 8, 10)
741 HIGHBD_OBFP_WRAPPER(8, 8, 10)
742 HIGHBD_OBFP_WRAPPER(4, 8, 10)
743 HIGHBD_OBFP_WRAPPER(8, 4, 10)
744 HIGHBD_OBFP_WRAPPER(4, 4, 10)
745 HIGHBD_OBFP_WRAPPER(64, 16, 10)
746 HIGHBD_OBFP_WRAPPER(16, 64, 10)
747 HIGHBD_OBFP_WRAPPER(32, 8, 10)
748 HIGHBD_OBFP_WRAPPER(8, 32, 10)
749 HIGHBD_OBFP_WRAPPER(16, 4, 10)
750 HIGHBD_OBFP_WRAPPER(4, 16, 10)
Jerome Jiang4567c352020-10-29 13:10:31 -0700751#endif
Aasaipriya Cda788c72020-09-17 13:40:55 +0530752
James Zernf2658a32022-02-09 10:18:38 -0800753 HIGHBD_SDSFP_WRAPPER(128, 128, 10)
754 HIGHBD_SDSFP_WRAPPER(128, 64, 10)
755 HIGHBD_SDSFP_WRAPPER(64, 128, 10)
756 HIGHBD_SDSFP_WRAPPER(64, 64, 10)
757 HIGHBD_SDSFP_WRAPPER(64, 32, 10)
758 HIGHBD_SDSFP_WRAPPER(32, 64, 10)
759 HIGHBD_SDSFP_WRAPPER(32, 32, 10)
760 HIGHBD_SDSFP_WRAPPER(32, 16, 10)
761 HIGHBD_SDSFP_WRAPPER(16, 32, 10)
762 HIGHBD_SDSFP_WRAPPER(16, 16, 10)
763 HIGHBD_SDSFP_WRAPPER(16, 8, 10)
764 HIGHBD_SDSFP_WRAPPER(8, 16, 10)
765 HIGHBD_SDSFP_WRAPPER(8, 8, 10)
766 HIGHBD_SDSFP_WRAPPER(4, 8, 10)
Jerome Jiangc381ba82020-10-30 14:55:57 -0700767
768#if !CONFIG_REALTIME_ONLY
James Zernf2658a32022-02-09 10:18:38 -0800769 HIGHBD_SDSFP_WRAPPER(64, 16, 10)
770 HIGHBD_SDSFP_WRAPPER(32, 8, 10)
771 HIGHBD_SDSFP_WRAPPER(16, 64, 10)
772 HIGHBD_SDSFP_WRAPPER(8, 32, 10)
773 HIGHBD_SDSFP_WRAPPER(4, 16, 10)
Jerome Jiangc381ba82020-10-30 14:55:57 -0700774#endif
Satish Kumar Sumanee14de92020-06-12 15:42:05 +0530775 break;
776
777 case AOM_BITS_12:
Jerome Jiangc381ba82020-10-30 14:55:57 -0700778#if !CONFIG_REALTIME_ONLY
Satish Kumar Sumanee14de92020-06-12 15:42:05 +0530779 HIGHBD_BFP_WRAPPER(64, 16, 12)
780 HIGHBD_BFP_WRAPPER(16, 64, 12)
781 HIGHBD_BFP_WRAPPER(32, 8, 12)
782 HIGHBD_BFP_WRAPPER(8, 32, 12)
783 HIGHBD_BFP_WRAPPER(16, 4, 12)
784 HIGHBD_BFP_WRAPPER(4, 16, 12)
Jerome Jiangc381ba82020-10-30 14:55:57 -0700785#endif
Satish Kumar Sumanee14de92020-06-12 15:42:05 +0530786 HIGHBD_BFP_WRAPPER(32, 16, 12)
787 HIGHBD_BFP_WRAPPER(16, 32, 12)
788 HIGHBD_BFP_WRAPPER(64, 32, 12)
789 HIGHBD_BFP_WRAPPER(32, 64, 12)
790 HIGHBD_BFP_WRAPPER(32, 32, 12)
791 HIGHBD_BFP_WRAPPER(64, 64, 12)
792 HIGHBD_BFP_WRAPPER(16, 16, 12)
793 HIGHBD_BFP_WRAPPER(16, 8, 12)
794 HIGHBD_BFP_WRAPPER(8, 16, 12)
795 HIGHBD_BFP_WRAPPER(8, 8, 12)
796 HIGHBD_BFP_WRAPPER(8, 4, 12)
797 HIGHBD_BFP_WRAPPER(4, 8, 12)
798 HIGHBD_BFP_WRAPPER(4, 4, 12)
799 HIGHBD_BFP_WRAPPER(128, 128, 12)
800 HIGHBD_BFP_WRAPPER(128, 64, 12)
801 HIGHBD_BFP_WRAPPER(64, 128, 12)
802
803 HIGHBD_MBFP_WRAPPER(128, 128, 12)
804 HIGHBD_MBFP_WRAPPER(128, 64, 12)
805 HIGHBD_MBFP_WRAPPER(64, 128, 12)
806 HIGHBD_MBFP_WRAPPER(64, 64, 12)
807 HIGHBD_MBFP_WRAPPER(64, 32, 12)
808 HIGHBD_MBFP_WRAPPER(32, 64, 12)
809 HIGHBD_MBFP_WRAPPER(32, 32, 12)
810 HIGHBD_MBFP_WRAPPER(32, 16, 12)
811 HIGHBD_MBFP_WRAPPER(16, 32, 12)
812 HIGHBD_MBFP_WRAPPER(16, 16, 12)
813 HIGHBD_MBFP_WRAPPER(8, 16, 12)
814 HIGHBD_MBFP_WRAPPER(16, 8, 12)
815 HIGHBD_MBFP_WRAPPER(8, 8, 12)
816 HIGHBD_MBFP_WRAPPER(4, 8, 12)
817 HIGHBD_MBFP_WRAPPER(8, 4, 12)
818 HIGHBD_MBFP_WRAPPER(4, 4, 12)
Jerome Jiangc381ba82020-10-30 14:55:57 -0700819#if !CONFIG_REALTIME_ONLY
Satish Kumar Sumanee14de92020-06-12 15:42:05 +0530820 HIGHBD_MBFP_WRAPPER(64, 16, 12)
821 HIGHBD_MBFP_WRAPPER(16, 64, 12)
822 HIGHBD_MBFP_WRAPPER(32, 8, 12)
823 HIGHBD_MBFP_WRAPPER(8, 32, 12)
824 HIGHBD_MBFP_WRAPPER(16, 4, 12)
825 HIGHBD_MBFP_WRAPPER(4, 16, 12)
Jerome Jiangc381ba82020-10-30 14:55:57 -0700826#endif
Satish Kumar Sumanee14de92020-06-12 15:42:05 +0530827
Jerome Jiangc381ba82020-10-30 14:55:57 -0700828// OBMC excluded from realtime only build.
Jerome Jiang4567c352020-10-29 13:10:31 -0700829#if !CONFIG_REALTIME_ONLY
Satish Kumar Sumanee14de92020-06-12 15:42:05 +0530830 HIGHBD_OBFP_WRAPPER(128, 128, 12)
831 HIGHBD_OBFP_WRAPPER(128, 64, 12)
832 HIGHBD_OBFP_WRAPPER(64, 128, 12)
833 HIGHBD_OBFP_WRAPPER(64, 64, 12)
834 HIGHBD_OBFP_WRAPPER(64, 32, 12)
835 HIGHBD_OBFP_WRAPPER(32, 64, 12)
836 HIGHBD_OBFP_WRAPPER(32, 32, 12)
837 HIGHBD_OBFP_WRAPPER(32, 16, 12)
838 HIGHBD_OBFP_WRAPPER(16, 32, 12)
839 HIGHBD_OBFP_WRAPPER(16, 16, 12)
840 HIGHBD_OBFP_WRAPPER(8, 16, 12)
841 HIGHBD_OBFP_WRAPPER(16, 8, 12)
842 HIGHBD_OBFP_WRAPPER(8, 8, 12)
843 HIGHBD_OBFP_WRAPPER(4, 8, 12)
844 HIGHBD_OBFP_WRAPPER(8, 4, 12)
845 HIGHBD_OBFP_WRAPPER(4, 4, 12)
846 HIGHBD_OBFP_WRAPPER(64, 16, 12)
847 HIGHBD_OBFP_WRAPPER(16, 64, 12)
848 HIGHBD_OBFP_WRAPPER(32, 8, 12)
849 HIGHBD_OBFP_WRAPPER(8, 32, 12)
850 HIGHBD_OBFP_WRAPPER(16, 4, 12)
851 HIGHBD_OBFP_WRAPPER(4, 16, 12)
Jerome Jiang4567c352020-10-29 13:10:31 -0700852#endif
Aasaipriya Cda788c72020-09-17 13:40:55 +0530853
James Zernf2658a32022-02-09 10:18:38 -0800854 HIGHBD_SDSFP_WRAPPER(128, 128, 12)
855 HIGHBD_SDSFP_WRAPPER(128, 64, 12)
856 HIGHBD_SDSFP_WRAPPER(64, 128, 12)
857 HIGHBD_SDSFP_WRAPPER(64, 64, 12)
858 HIGHBD_SDSFP_WRAPPER(64, 32, 12)
859 HIGHBD_SDSFP_WRAPPER(32, 64, 12)
860 HIGHBD_SDSFP_WRAPPER(32, 32, 12)
861 HIGHBD_SDSFP_WRAPPER(32, 16, 12)
862 HIGHBD_SDSFP_WRAPPER(16, 32, 12)
863 HIGHBD_SDSFP_WRAPPER(16, 16, 12)
864 HIGHBD_SDSFP_WRAPPER(16, 8, 12)
865 HIGHBD_SDSFP_WRAPPER(8, 16, 12)
866 HIGHBD_SDSFP_WRAPPER(8, 8, 12)
867 HIGHBD_SDSFP_WRAPPER(4, 8, 12)
Jerome Jiangc381ba82020-10-30 14:55:57 -0700868
869#if !CONFIG_REALTIME_ONLY
James Zernf2658a32022-02-09 10:18:38 -0800870 HIGHBD_SDSFP_WRAPPER(64, 16, 12)
871 HIGHBD_SDSFP_WRAPPER(32, 8, 12)
872 HIGHBD_SDSFP_WRAPPER(16, 64, 12)
873 HIGHBD_SDSFP_WRAPPER(8, 32, 12)
874 HIGHBD_SDSFP_WRAPPER(4, 16, 12)
Jerome Jiangc381ba82020-10-30 14:55:57 -0700875#endif
Satish Kumar Sumanee14de92020-06-12 15:42:05 +0530876 break;
877
878 default:
879 assert(0 &&
Tarundeep Singh4243e622021-04-20 16:10:22 +0530880 "cm->seq_params->bit_depth should be AOM_BITS_8, "
Satish Kumar Sumanee14de92020-06-12 15:42:05 +0530881 "AOM_BITS_10 or AOM_BITS_12");
882 }
883 }
884}
Satish Kumar Suman897b7942020-06-11 11:44:29 +0530885#endif // CONFIG_AV1_HIGHBITDEPTH
886
Satish Kumar Suman897b7942020-06-11 11:44:29 +0530887static AOM_INLINE void copy_frame_prob_info(AV1_COMP *cpi) {
Aasaipriyae2ac66e2021-07-06 17:38:12 +0530888 FrameProbInfo *const frame_probs = &cpi->ppi->frame_probs;
Satish Kumar Suman897b7942020-06-11 11:44:29 +0530889 if (cpi->sf.tx_sf.tx_type_search.prune_tx_type_using_stats) {
890 av1_copy(frame_probs->tx_type_probs, default_tx_type_probs);
891 }
Akshata Jadhav26b751a2021-01-18 16:58:46 +0530892 if (cpi->sf.inter_sf.prune_obmc_prob_thresh > 0 &&
893 cpi->sf.inter_sf.prune_obmc_prob_thresh < INT_MAX) {
Satish Kumar Suman897b7942020-06-11 11:44:29 +0530894 av1_copy(frame_probs->obmc_probs, default_obmc_probs);
895 }
896 if (cpi->sf.inter_sf.prune_warped_prob_thresh > 0) {
897 av1_copy(frame_probs->warped_probs, default_warped_probs);
898 }
899 if (cpi->sf.interp_sf.adaptive_interp_filter_search == 2) {
900 av1_copy(frame_probs->switchable_interp_probs,
901 default_switchable_interp_probs);
902 }
Remya Prakasan6566bc82021-11-05 23:21:12 +0530903
Remya Prakasanffeb4972022-06-21 20:00:28 +0530904#if CONFIG_FPMT_TEST
Remya Prakasan6566bc82021-11-05 23:21:12 +0530905 if (cpi->ppi->fpmt_unit_test_cfg == PARALLEL_SIMULATION_ENCODE) {
906 FrameProbInfo *const temp_frame_probs = &cpi->ppi->temp_frame_probs;
907 if (cpi->sf.tx_sf.tx_type_search.prune_tx_type_using_stats) {
908 av1_copy(temp_frame_probs->tx_type_probs, default_tx_type_probs);
909 }
910 if (cpi->sf.inter_sf.prune_obmc_prob_thresh > 0 &&
911 cpi->sf.inter_sf.prune_obmc_prob_thresh < INT_MAX) {
912 av1_copy(temp_frame_probs->obmc_probs, default_obmc_probs);
913 }
914 if (cpi->sf.inter_sf.prune_warped_prob_thresh > 0) {
915 av1_copy(temp_frame_probs->warped_probs, default_warped_probs);
916 }
917 if (cpi->sf.interp_sf.adaptive_interp_filter_search == 2) {
918 av1_copy(temp_frame_probs->switchable_interp_probs,
919 default_switchable_interp_probs);
920 }
921
922 FrameProbInfo *const temp_frame_probs_simulation =
923 &cpi->ppi->temp_frame_probs_simulation;
924 if (cpi->sf.tx_sf.tx_type_search.prune_tx_type_using_stats) {
925 av1_copy(temp_frame_probs_simulation->tx_type_probs,
926 default_tx_type_probs);
927 }
928 if (cpi->sf.inter_sf.prune_obmc_prob_thresh > 0 &&
929 cpi->sf.inter_sf.prune_obmc_prob_thresh < INT_MAX) {
930 av1_copy(temp_frame_probs_simulation->obmc_probs, default_obmc_probs);
931 }
932 if (cpi->sf.inter_sf.prune_warped_prob_thresh > 0) {
933 av1_copy(temp_frame_probs_simulation->warped_probs, default_warped_probs);
934 }
935 if (cpi->sf.interp_sf.adaptive_interp_filter_search == 2) {
936 av1_copy(temp_frame_probs_simulation->switchable_interp_probs,
937 default_switchable_interp_probs);
938 }
939 }
940#endif
Satish Kumar Suman897b7942020-06-11 11:44:29 +0530941}
942
Vishnu Teja Manyam1d17bfe2021-03-10 18:23:29 +0530943static AOM_INLINE void restore_cdef_coding_context(CdefInfo *const dst,
944 const CdefInfo *const src) {
945 dst->cdef_bits = src->cdef_bits;
946 dst->cdef_damping = src->cdef_damping;
947 av1_copy(dst->cdef_strengths, src->cdef_strengths);
948 av1_copy(dst->cdef_uv_strengths, src->cdef_uv_strengths);
949 dst->nb_cdef_strengths = src->nb_cdef_strengths;
950}
951
Satish Kumar Suman897b7942020-06-11 11:44:29 +0530952// Coding context that only needs to be restored when recode loop includes
953// filtering (deblocking, CDEF, superres post-encode upscale and/or loop
954// restoraton).
955static AOM_INLINE void restore_extra_coding_context(AV1_COMP *cpi) {
956 CODING_CONTEXT *const cc = &cpi->coding_context;
957 AV1_COMMON *cm = &cpi->common;
958 cm->lf = cc->lf;
Vishnu Teja Manyam1d17bfe2021-03-10 18:23:29 +0530959 restore_cdef_coding_context(&cm->cdef_info, &cc->cdef_info);
Satish Kumar Suman897b7942020-06-11 11:44:29 +0530960 cpi->rc = cc->rc;
Aasaipriya Chandranbe8ccad2021-05-25 20:37:01 +0530961 cpi->ppi->mv_stats = cc->mv_stats;
Satish Kumar Suman897b7942020-06-11 11:44:29 +0530962}
963
Satish Kumar Suman897b7942020-06-11 11:44:29 +0530964static AOM_INLINE int equal_dimensions_and_border(const YV12_BUFFER_CONFIG *a,
965 const YV12_BUFFER_CONFIG *b) {
966 return a->y_height == b->y_height && a->y_width == b->y_width &&
967 a->uv_height == b->uv_height && a->uv_width == b->uv_width &&
968 a->y_stride == b->y_stride && a->uv_stride == b->uv_stride &&
969 a->border == b->border &&
970 (a->flags & YV12_FLAG_HIGHBITDEPTH) ==
971 (b->flags & YV12_FLAG_HIGHBITDEPTH);
972}
973
Satish Kumar Suman329de4d2020-06-16 10:48:32 +0530974static AOM_INLINE int update_entropy(bool *ext_refresh_frame_context,
975 bool *ext_refresh_frame_context_pending,
976 bool update) {
977 *ext_refresh_frame_context = update;
978 *ext_refresh_frame_context_pending = 1;
979 return 0;
980}
981
982#if !CONFIG_REALTIME_ONLY
983static AOM_INLINE int combine_prior_with_tpl_boost(double min_factor,
984 double max_factor,
985 int prior_boost,
986 int tpl_boost,
987 int frames_to_key) {
988 double factor = sqrt((double)frames_to_key);
989 double range = max_factor - min_factor;
990 factor = AOMMIN(factor, max_factor);
991 factor = AOMMAX(factor, min_factor);
992 factor -= min_factor;
993 int boost =
994 (int)((factor * prior_boost + (range - factor) * tpl_boost) / range);
995 return boost;
996}
997#endif
998
Jayasanker Jdee179d2020-07-10 23:47:37 +0530999static AOM_INLINE void set_size_independent_vars(AV1_COMP *cpi) {
1000 int i;
1001 AV1_COMMON *const cm = &cpi->common;
Ranjit Kumar Tulabandu19b1f442022-09-07 17:14:54 +05301002 FeatureFlags *const features = &cm->features;
Jayasanker Jdee179d2020-07-10 23:47:37 +05301003 for (i = LAST_FRAME; i <= ALTREF_FRAME; ++i) {
1004 cm->global_motion[i] = default_warp_params;
1005 }
1006 cpi->gm_info.search_done = 0;
1007
1008 av1_set_speed_features_framesize_independent(cpi, cpi->speed);
1009 av1_set_rd_speed_thresholds(cpi);
Ranjit Kumar Tulabandu19b1f442022-09-07 17:14:54 +05301010 features->interp_filter = SWITCHABLE;
1011 features->switchable_motion_mode = is_switchable_motion_mode_allowed(
1012 features->allow_warped_motion, cpi->oxcf.motion_mode_cfg.enable_obmc);
Jayasanker Jdee179d2020-07-10 23:47:37 +05301013}
1014
1015static AOM_INLINE void release_scaled_references(AV1_COMP *cpi) {
1016 // TODO(isbs): only refresh the necessary frames, rather than all of them
1017 for (int i = 0; i < INTER_REFS_PER_FRAME; ++i) {
1018 RefCntBuffer *const buf = cpi->scaled_ref_buf[i];
1019 if (buf != NULL) {
1020 --buf->ref_count;
1021 cpi->scaled_ref_buf[i] = NULL;
1022 }
1023 }
1024}
1025
Jayasanker Jdee179d2020-07-10 23:47:37 +05301026static AOM_INLINE void restore_all_coding_context(AV1_COMP *cpi) {
Jayasanker Jdee179d2020-07-10 23:47:37 +05301027 restore_extra_coding_context(cpi);
1028 if (!frame_is_intra_only(&cpi->common)) release_scaled_references(cpi);
1029}
Jayasanker Jdee179d2020-07-10 23:47:37 +05301030
Deepa K G10058f62022-07-15 13:36:44 +05301031static AOM_INLINE int reduce_num_ref_buffers(const AV1_COMP *cpi) {
1032 const SequenceHeader *const seq_params = cpi->common.seq_params;
1033 return is_one_pass_rt_params(cpi) &&
Marco Paniconi1a3a74a2022-08-28 22:26:48 -07001034 use_rtc_reference_structure_one_layer(cpi) &&
Deepa K G10058f62022-07-15 13:36:44 +05301035 (seq_params->order_hint_info.enable_order_hint == 0) &&
1036 cpi->rt_reduce_num_ref_buffers;
1037}
1038
Jayasanker Jdee179d2020-07-10 23:47:37 +05301039// Refresh reference frame buffers according to refresh_frame_flags.
1040static AOM_INLINE void refresh_reference_frames(AV1_COMP *cpi) {
1041 AV1_COMMON *const cm = &cpi->common;
1042 // All buffers are refreshed for shown keyframes and S-frames.
Deepa K G10058f62022-07-15 13:36:44 +05301043 // In case of RT, golden frame refreshes the 6th slot and other reference
1044 // frames refresh slots 0 to 5. Slot 7 is not refreshed by any reference
1045 // frame. Thus, only 7 buffers are refreshed for keyframes and S-frames
1046 // instead of 8.
1047 int num_ref_buffers = REF_FRAMES;
1048 if (reduce_num_ref_buffers(cpi)) {
1049 const int refresh_all_bufs =
1050 (cpi->ppi->gf_group.refbuf_state[cpi->gf_frame_index] == REFBUF_RESET ||
1051 frame_is_sframe(cm));
1052 assert(IMPLIES(((cm->current_frame.refresh_frame_flags >> 7) & 1) == 1,
1053 refresh_all_bufs));
1054 (void)refresh_all_bufs;
1055 num_ref_buffers--;
1056 }
Jayasanker Jdee179d2020-07-10 23:47:37 +05301057
Deepa K G10058f62022-07-15 13:36:44 +05301058 for (int ref_frame = 0; ref_frame < num_ref_buffers; ref_frame++) {
Jayasanker Jdee179d2020-07-10 23:47:37 +05301059 if (((cm->current_frame.refresh_frame_flags >> ref_frame) & 1) == 1) {
1060 assign_frame_buffer_p(&cm->ref_frame_map[ref_frame], cm->cur_frame);
1061 }
1062 }
1063}
1064
Tarundeep Singh9e77b302021-03-19 16:07:48 +05301065void av1_update_film_grain_parameters_seq(struct AV1_PRIMARY *ppi,
1066 const AV1EncoderConfig *oxcf);
Jayasanker Jdee179d2020-07-10 23:47:37 +05301067void av1_update_film_grain_parameters(struct AV1_COMP *cpi,
1068 const AV1EncoderConfig *oxcf);
1069
1070void av1_scale_references(AV1_COMP *cpi, const InterpFilter filter,
1071 const int phase, const int use_optimized_scaler);
1072
1073void av1_setup_frame(AV1_COMP *cpi);
1074
Tarundeep Singh49128692021-04-07 12:37:21 +05301075BLOCK_SIZE av1_select_sb_size(const AV1EncoderConfig *const oxcf, int width,
1076 int height, int number_spatial_layers);
Jayasanker Jdee179d2020-07-10 23:47:37 +05301077
1078void av1_apply_active_map(AV1_COMP *cpi);
1079
1080#if !CONFIG_REALTIME_ONLY
1081uint16_t av1_setup_interp_filter_search_mask(AV1_COMP *cpi);
1082
1083void av1_determine_sc_tools_with_encoding(AV1_COMP *cpi, const int q_orig);
Jayasanker Jdee179d2020-07-10 23:47:37 +05301084#endif
1085
1086void av1_set_size_dependent_vars(AV1_COMP *cpi, int *q, int *bottom_index,
1087 int *top_index);
1088
1089void av1_finalize_encoded_frame(AV1_COMP *const cpi);
1090
1091int av1_is_integer_mv(const YV12_BUFFER_CONFIG *cur_picture,
1092 const YV12_BUFFER_CONFIG *last_picture,
1093 ForceIntegerMVInfo *const force_intpel_info);
1094
1095void av1_set_mb_ssim_rdmult_scaling(AV1_COMP *cpi);
1096
Jayasanker Jdee179d2020-07-10 23:47:37 +05301097void av1_save_all_coding_context(AV1_COMP *cpi);
Jayasanker Jdee179d2020-07-10 23:47:37 +05301098
1099#if DUMP_RECON_FRAMES == 1
1100void av1_dump_filtered_recon_frames(AV1_COMP *cpi);
1101#endif
1102
chiyotsaib6daca72022-05-25 11:01:09 -07001103static AOM_INLINE int av1_get_enc_border_size(bool resize, bool all_intra,
1104 BLOCK_SIZE sb_size) {
1105 // For allintra encoding mode, inter-frame motion search is not applicable and
1106 // the intraBC motion vectors are restricted within the tile boundaries. Hence
1107 // a smaller frame border size (AOM_ENC_ALLINTRA_BORDER) is used in this case.
1108 if (resize) {
1109 return AOM_BORDER_IN_PIXELS;
chiyotsaib6daca72022-05-25 11:01:09 -07001110 }
Wan-Teh Changba460b42022-06-23 11:43:40 -07001111 if (all_intra) {
1112 return AOM_ENC_ALLINTRA_BORDER;
1113 }
1114 return block_size_wide[sb_size] + 32;
chiyotsaib6daca72022-05-25 11:01:09 -07001115}
1116
1117static AOM_INLINE bool av1_is_resize_needed(const AV1EncoderConfig *oxcf) {
1118 const ResizeCfg *resize_cfg = &oxcf->resize_cfg;
1119 const SuperResCfg *superres_cfg = &oxcf->superres_cfg;
1120 return resize_cfg->resize_mode || superres_cfg->superres_mode;
1121}
1122
Satish Kumar Suman897b7942020-06-11 11:44:29 +05301123#ifdef __cplusplus
1124} // extern "C"
1125#endif
1126
1127#endif // AOM_AV1_ENCODER_ENCODER_UTILS_H_