blob: 5e9bfcd75881c3012e73ed4d274eecb7d95c5efa [file] [log] [blame]
Yaowu Xuc27fc142016-08-22 16:08:15 -07001/*
Yaowu Xu2ab7ff02016-09-02 12:04:54 -07002 * Copyright (c) 2016, Alliance for Open Media. All rights reserved
Yaowu Xuc27fc142016-08-22 16:08:15 -07003 *
Yaowu Xu2ab7ff02016-09-02 12:04:54 -07004 * 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.
Yaowu Xuc27fc142016-08-22 16:08:15 -070010 */
11
James Zerne1cbb132018-08-22 14:10:36 -070012#ifndef AOM_AV1_ENCODER_RD_H_
13#define AOM_AV1_ENCODER_RD_H_
Yaowu Xuc27fc142016-08-22 16:08:15 -070014
15#include <limits.h>
16
Yaowu Xuc27fc142016-08-22 16:08:15 -070017#include "av1/common/blockd.h"
18
19#include "av1/encoder/block.h"
20#include "av1/encoder/context_tree.h"
21#include "av1/encoder/cost.h"
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27#define RDDIV_BITS 7
28#define RD_EPB_SHIFT 6
29
Angie Chiange4ea7482018-03-15 11:36:41 -070030#define RDCOST(RM, R, D) \
31 (ROUND_POWER_OF_TWO(((int64_t)(R)) * (RM), AV1_PROB_COST_SHIFT) + \
32 ((D) * (1 << RDDIV_BITS)))
Yaowu Xuc27fc142016-08-22 16:08:15 -070033
sdeng256c4d32019-06-11 12:19:48 -070034#define RDCOST_NEG_R(RM, R, D) \
35 (((D) * (1 << RDDIV_BITS)) - \
36 ROUND_POWER_OF_TWO(((int64_t)(R)) * (RM), AV1_PROB_COST_SHIFT))
37
Nithya V S5bff0a02020-09-16 14:07:24 +053038#define RDCOST_DBL_WITH_NATIVE_BD_DIST(RM, R, D, BD) \
Yaowu Xuf883b422016-08-30 14:01:10 -070039 (((((double)(R)) * (RM)) / (double)(1 << AV1_PROB_COST_SHIFT)) + \
Nithya V S5bff0a02020-09-16 14:07:24 +053040 ((double)((D) >> (2 * (BD - 8))) * (1 << RDDIV_BITS)))
Yaowu Xuc27fc142016-08-22 16:08:15 -070041
42#define QIDX_SKIP_THRESH 115
43
44#define MV_COST_WEIGHT 108
45#define MV_COST_WEIGHT_SUB 120
46
chiyotsai0b642602020-01-08 13:31:44 -080047// The fractional part of rd_thresh factor is stored with 5 bits. The maximum
48// factor that we allow is two, which is stored as 2 ** (5+1) = 64
49#define RD_THRESH_FAC_FRAC_BITS (5)
50#define RD_THRESH_FAC_FRAC_VAL (1 << (RD_THRESH_FAC_FRAC_BITS))
51#define RD_THRESH_MAX_FACT ((RD_THRESH_FAC_FRAC_VAL) << 1)
52#define RD_THRESH_LOG_DEC_FACTOR (4)
53#define RD_THRESH_INC (1)
Yaowu Xuc27fc142016-08-22 16:08:15 -070054
Peng Binc7101aa2018-06-22 20:47:05 +080055// Factor to weigh the rate for switchable interp filters.
56#define SWITCHABLE_INTERP_RATE_FACTOR 1
57
Cherma Rajan A628efce2019-09-18 18:55:12 +053058enum {
chiyotsaif271f9f2019-11-25 16:44:25 -080059 // Default initialization when we are not using winner mode framework. e.g.
60 // intrabc
Cherma Rajan A628efce2019-09-18 18:55:12 +053061 DEFAULT_EVAL = 0,
chiyotsaif271f9f2019-11-25 16:44:25 -080062 // Initialization for selecting winner mode
Cherma Rajan A628efce2019-09-18 18:55:12 +053063 MODE_EVAL,
64 // Initialization for winner mode evaluation
65 WINNER_MODE_EVAL,
66 // All mode evaluation types
67 MODE_EVAL_TYPES,
68} UENUM1BYTE(MODE_EVAL_TYPE);
69
Yaowu Xuc27fc142016-08-22 16:08:15 -070070typedef struct RD_OPT {
71 // Thresh_mult is used to set a threshold for the rd score. A higher value
72 // means that we will accept the best mode so far more often. This number
73 // is used in combination with the current block size, and thresh_freq_fact
74 // to pick a threshold.
75 int thresh_mult[MAX_MODES];
Yaowu Xuc27fc142016-08-22 16:08:15 -070076
Rupert Swarbrick93c39e92017-07-12 11:11:02 +010077 int threshes[MAX_SEGMENTS][BLOCK_SIZES_ALL][MAX_MODES];
Yaowu Xuc27fc142016-08-22 16:08:15 -070078
Yaowu Xuc27fc142016-08-22 16:08:15 -070079 int RDMULT;
Yue Chen7cae98f2018-08-24 10:43:16 -070080
Jingning Han94b28542020-08-03 23:11:27 -070081 double r0;
Yaowu Xuc27fc142016-08-22 16:08:15 -070082} RD_OPT;
83
Deepa K G06f2c622020-04-12 12:24:35 +053084typedef struct {
85 // Cost of transmitting the actual motion vector.
86 // mv_component[0][i] is the cost of motion vector with horizontal component
87 // (mv_row) equal to i - MV_MAX.
88 // mv_component[1][i] is the cost of motion vector with vertical component
89 // (mv_col) equal to i - MV_MAX.
90 int mv_component[2][MV_VALS];
91
92 // joint_mv[i] is the cost of transmitting joint mv(MV_JOINT_TYPE) of
93 // type i.
94 // TODO(huisu@google.com): we can update dv_joint_cost per SB.
95 int joint_mv[MV_JOINTS];
96} IntraBCMVCosts;
97
Angie Chiang2a2a7dd2017-04-25 16:08:47 -070098static INLINE void av1_init_rd_stats(RD_STATS *rd_stats) {
99#if CONFIG_RD_DEBUG
100 int plane;
101#endif
102 rd_stats->rate = 0;
103 rd_stats->dist = 0;
104 rd_stats->rdcost = 0;
105 rd_stats->sse = 0;
chiyotsai8c004e12020-04-17 15:52:08 -0700106 rd_stats->skip_txfm = 1;
Jingning Han3bce7542017-07-25 10:53:57 -0700107 rd_stats->zero_rate = 0;
Angie Chiang2a2a7dd2017-04-25 16:08:47 -0700108#if CONFIG_RD_DEBUG
Imdad Sardharwallaaf8e2642018-01-19 11:46:34 +0000109 // This may run into problems when monochrome video is
110 // encoded, as there will only be 1 plane
Angie Chiang2a2a7dd2017-04-25 16:08:47 -0700111 for (plane = 0; plane < MAX_MB_PLANE; ++plane) {
112 rd_stats->txb_coeff_cost[plane] = 0;
Angie Chiang2a2a7dd2017-04-25 16:08:47 -0700113 {
114 int r, c;
115 for (r = 0; r < TXB_COEFF_COST_MAP_SIZE; ++r)
116 for (c = 0; c < TXB_COEFF_COST_MAP_SIZE; ++c)
117 rd_stats->txb_coeff_cost_map[plane][r][c] = 0;
118 }
Angie Chiang2a2a7dd2017-04-25 16:08:47 -0700119 }
120#endif
121}
Yaowu Xuc27fc142016-08-22 16:08:15 -0700122
Angie Chiang2a2a7dd2017-04-25 16:08:47 -0700123static INLINE void av1_invalid_rd_stats(RD_STATS *rd_stats) {
124#if CONFIG_RD_DEBUG
125 int plane;
126#endif
127 rd_stats->rate = INT_MAX;
128 rd_stats->dist = INT64_MAX;
129 rd_stats->rdcost = INT64_MAX;
130 rd_stats->sse = INT64_MAX;
chiyotsai8c004e12020-04-17 15:52:08 -0700131 rd_stats->skip_txfm = 0;
Jingning Han3bce7542017-07-25 10:53:57 -0700132 rd_stats->zero_rate = 0;
Angie Chiang2a2a7dd2017-04-25 16:08:47 -0700133#if CONFIG_RD_DEBUG
Imdad Sardharwallaaf8e2642018-01-19 11:46:34 +0000134 // This may run into problems when monochrome video is
135 // encoded, as there will only be 1 plane
Angie Chiang2a2a7dd2017-04-25 16:08:47 -0700136 for (plane = 0; plane < MAX_MB_PLANE; ++plane) {
137 rd_stats->txb_coeff_cost[plane] = INT_MAX;
Angie Chiang2a2a7dd2017-04-25 16:08:47 -0700138 {
139 int r, c;
140 for (r = 0; r < TXB_COEFF_COST_MAP_SIZE; ++r)
141 for (c = 0; c < TXB_COEFF_COST_MAP_SIZE; ++c)
Jingning Han46564ea2019-10-28 15:29:54 -0700142 rd_stats->txb_coeff_cost_map[plane][r][c] = INT16_MAX;
Angie Chiang2a2a7dd2017-04-25 16:08:47 -0700143 }
Angie Chiang2a2a7dd2017-04-25 16:08:47 -0700144 }
145#endif
146}
147
148static INLINE void av1_merge_rd_stats(RD_STATS *rd_stats_dst,
149 const RD_STATS *rd_stats_src) {
Hui Sucd735502019-04-08 11:23:02 -0700150 assert(rd_stats_dst->rate != INT_MAX && rd_stats_src->rate != INT_MAX);
Venkat72481752019-07-01 16:33:49 +0530151 rd_stats_dst->rate = (int)AOMMIN(
152 ((int64_t)rd_stats_dst->rate + (int64_t)rd_stats_src->rate), INT_MAX);
Debargha Mukherjeede80e762017-11-30 13:58:56 -0800153 if (!rd_stats_dst->zero_rate)
154 rd_stats_dst->zero_rate = rd_stats_src->zero_rate;
Angie Chiang2a2a7dd2017-04-25 16:08:47 -0700155 rd_stats_dst->dist += rd_stats_src->dist;
156 rd_stats_dst->sse += rd_stats_src->sse;
chiyotsai8c004e12020-04-17 15:52:08 -0700157 rd_stats_dst->skip_txfm &= rd_stats_src->skip_txfm;
Angie Chiang2a2a7dd2017-04-25 16:08:47 -0700158#if CONFIG_RD_DEBUG
Imdad Sardharwallaaf8e2642018-01-19 11:46:34 +0000159 // This may run into problems when monochrome video is
160 // encoded, as there will only be 1 plane
Hui Sucd735502019-04-08 11:23:02 -0700161 for (int plane = 0; plane < MAX_MB_PLANE; ++plane) {
Angie Chiang2a2a7dd2017-04-25 16:08:47 -0700162 rd_stats_dst->txb_coeff_cost[plane] += rd_stats_src->txb_coeff_cost[plane];
Angie Chiang2a2a7dd2017-04-25 16:08:47 -0700163 {
164 // TODO(angiebird): optimize this part
165 int r, c;
166 int ref_txb_coeff_cost = 0;
167 for (r = 0; r < TXB_COEFF_COST_MAP_SIZE; ++r)
168 for (c = 0; c < TXB_COEFF_COST_MAP_SIZE; ++c) {
169 rd_stats_dst->txb_coeff_cost_map[plane][r][c] +=
170 rd_stats_src->txb_coeff_cost_map[plane][r][c];
171 ref_txb_coeff_cost += rd_stats_dst->txb_coeff_cost_map[plane][r][c];
172 }
173 assert(ref_txb_coeff_cost == rd_stats_dst->txb_coeff_cost[plane]);
174 }
Angie Chiang2a2a7dd2017-04-25 16:08:47 -0700175 }
176#endif
177}
Yaowu Xuc27fc142016-08-22 16:08:15 -0700178
Venkatd5d823c2019-06-25 16:48:23 +0530179static INLINE void av1_accumulate_rd_stats(RD_STATS *rd_stats, int64_t dist,
chiyotsai8c004e12020-04-17 15:52:08 -0700180 int rate, int skip_txfm, int64_t sse,
Venkatd5d823c2019-06-25 16:48:23 +0530181 int zero_rate) {
182 assert(rd_stats->rate != INT_MAX && rate != INT_MAX);
183 rd_stats->rate += rate;
184 if (!rd_stats->zero_rate) rd_stats->zero_rate = zero_rate;
185 rd_stats->dist += dist;
chiyotsai8c004e12020-04-17 15:52:08 -0700186 rd_stats->skip_txfm &= skip_txfm;
Venkatd5d823c2019-06-25 16:48:23 +0530187 rd_stats->sse += sse;
188}
189
sdeng256c4d32019-06-11 12:19:48 -0700190static INLINE int64_t av1_calculate_rd_cost(int mult, int rate, int64_t dist) {
191 assert(mult >= 0);
192 if (rate >= 0) {
193 return RDCOST(mult, rate, dist);
194 }
195 return RDCOST_NEG_R(mult, -rate, dist);
196}
197
198static INLINE void av1_rd_cost_update(int mult, RD_STATS *rd_cost) {
sdengafdb8512019-06-12 16:15:56 -0700199 if (rd_cost->rate < INT_MAX && rd_cost->dist < INT64_MAX &&
200 rd_cost->rdcost < INT64_MAX) {
sdeng256c4d32019-06-11 12:19:48 -0700201 rd_cost->rdcost = av1_calculate_rd_cost(mult, rd_cost->rate, rd_cost->dist);
202 } else {
203 av1_invalid_rd_stats(rd_cost);
204 }
205}
206
sdengafdb8512019-06-12 16:15:56 -0700207static INLINE void av1_rd_stats_subtraction(int mult,
208 const RD_STATS *const left,
sdengeff3bb42019-06-11 15:56:04 -0700209 const RD_STATS *const right,
210 RD_STATS *result) {
211 if (left->rate == INT_MAX || right->rate == INT_MAX ||
212 left->dist == INT64_MAX || right->dist == INT64_MAX ||
213 left->rdcost == INT64_MAX || right->rdcost == INT64_MAX) {
214 av1_invalid_rd_stats(result);
215 } else {
216 result->rate = left->rate - right->rate;
217 result->dist = left->dist - right->dist;
sdengafdb8512019-06-12 16:15:56 -0700218 result->rdcost = av1_calculate_rd_cost(mult, result->rate, result->dist);
sdengeff3bb42019-06-11 15:56:04 -0700219 }
220}
221
Yaowu Xuc27fc142016-08-22 16:08:15 -0700222struct TileInfo;
223struct TileDataEnc;
Yaowu Xuf883b422016-08-30 14:01:10 -0700224struct AV1_COMP;
Yaowu Xuc27fc142016-08-22 16:08:15 -0700225struct macroblock;
226
Yaowu Xuea8a6ca2018-11-07 14:53:46 -0800227int av1_compute_rd_mult_based_on_qindex(const struct AV1_COMP *cpi, int qindex);
Ravi Chaudhary95492052018-10-24 11:51:28 +0530228
Yaowu Xuf883b422016-08-30 14:01:10 -0700229int av1_compute_rd_mult(const struct AV1_COMP *cpi, int qindex);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700230
Yaowu Xuf883b422016-08-30 14:01:10 -0700231void av1_initialize_rd_consts(struct AV1_COMP *cpi);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700232
chiyotsaic95e3642020-04-10 13:17:06 -0700233// Sets the multiplier to convert mv cost to l1 error during motion search.
chiyotsai9a06d182020-05-01 17:12:12 -0700234void av1_set_sad_per_bit(const struct AV1_COMP *cpi, MvCosts *mv_costs,
chiyotsaic95e3642020-04-10 13:17:06 -0700235 int qindex);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700236
Yaowu Xuf883b422016-08-30 14:01:10 -0700237void av1_model_rd_from_var_lapndz(int64_t var, unsigned int n,
238 unsigned int qstep, int *rate, int64_t *dist);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700239
Debargha Mukherjee00079832019-01-17 11:28:52 -0800240void av1_model_rd_curvfit(BLOCK_SIZE bsize, double sse_norm, double xqr,
Debargha Mukherjeea7b37312019-01-14 15:15:49 -0800241 double *rate_f, double *distbysse_f);
Debargha Mukherjee00079832019-01-17 11:28:52 -0800242void av1_model_rd_surffit(BLOCK_SIZE bsize, double sse_norm, double xm,
243 double yl, double *rate_f, double *distbysse_f);
Debargha Mukherjee483e2952018-07-25 07:34:26 -0700244
Urvang Joshi6237b882020-03-26 15:02:26 -0700245int av1_get_switchable_rate(const MACROBLOCK *x, const MACROBLOCKD *xd,
Hui Su321b1752020-11-06 11:11:27 -0800246#if !CONFIG_REMOVE_DUAL_FILTER
247 int dual_filter,
248#endif // !CONFIG_REMOVE_DUAL_FILTER
Urvang Joshi6237b882020-03-26 15:02:26 -0700249 InterpFilter interp_filter);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700250
Yaowu Xuf883b422016-08-30 14:01:10 -0700251YV12_BUFFER_CONFIG *av1_get_scaled_ref_frame(const struct AV1_COMP *cpi,
252 int ref_frame);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700253
Yaowu Xuf883b422016-08-30 14:01:10 -0700254void av1_init_me_luts(void);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700255
Yaowu Xu901d6222018-02-21 21:40:48 -0800256void av1_set_mvcost(MACROBLOCK *x, int ref, int ref_mv_idx);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700257
Hui Su56e838f2019-12-04 14:48:30 -0800258void av1_get_entropy_contexts(BLOCK_SIZE plane_bsize,
Yaowu Xuf883b422016-08-30 14:01:10 -0700259 const struct macroblockd_plane *pd,
Wan-Teh Chang660f8ed2018-05-11 17:28:08 -0700260 ENTROPY_CONTEXT t_above[MAX_MIB_SIZE],
261 ENTROPY_CONTEXT t_left[MAX_MIB_SIZE]);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700262
Yaowu Xuf883b422016-08-30 14:01:10 -0700263void av1_set_rd_speed_thresholds(struct AV1_COMP *cpi);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700264
Yaowu Xuf883b422016-08-30 14:01:10 -0700265void av1_update_rd_thresh_fact(const AV1_COMMON *const cm,
chiyotsai0b642602020-01-08 13:31:44 -0800266 int (*fact)[MAX_MODES], int rd_thresh,
267 BLOCK_SIZE bsize, THR_MODES best_mode_index);
268
269static INLINE void reset_thresh_freq_fact(MACROBLOCK *const x) {
270 for (int i = 0; i < BLOCK_SIZES_ALL; ++i) {
271 for (int j = 0; j < MAX_MODES; ++j) {
272 x->thresh_freq_fact[i][j] = RD_THRESH_FAC_FRAC_VAL;
273 }
274 }
275}
Yaowu Xuc27fc142016-08-22 16:08:15 -0700276
Yaowu Xuc27fc142016-08-22 16:08:15 -0700277static INLINE int rd_less_than_thresh(int64_t best_rd, int thresh,
278 int thresh_fact) {
279 return best_rd < ((int64_t)thresh * thresh_fact >> 5) || thresh == INT_MAX;
280}
281
Urvang Joshi52648442016-10-13 17:27:51 -0700282void av1_mv_pred(const struct AV1_COMP *cpi, MACROBLOCK *x,
283 uint8_t *ref_y_buffer, int ref_y_stride, int ref_frame,
284 BLOCK_SIZE block_size);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700285
chiyotsaic95e3642020-04-10 13:17:06 -0700286// Sets the multiplier to convert mv cost to l2 error during motion search.
chiyotsai9a06d182020-05-01 17:12:12 -0700287static INLINE void av1_set_error_per_bit(MvCosts *mv_costs, int rdmult) {
288 mv_costs->errorperbit = AOMMAX(rdmult >> RD_EPB_SHIFT, 1);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700289}
290
Ranjit Kumar Tulabandu824f9db2019-07-05 15:16:37 +0530291// Get the threshold for R-D optimization of coefficients depending upon mode
292// decision/winner mode processing
293static INLINE uint32_t get_rd_opt_coeff_thresh(
294 const uint32_t *const coeff_opt_dist_threshold,
295 int enable_winner_mode_for_coeff_opt, int is_winner_mode) {
296 // Default initialization of threshold
Cherma Rajan A628efce2019-09-18 18:55:12 +0530297 uint32_t coeff_opt_thresh = coeff_opt_dist_threshold[DEFAULT_EVAL];
Ranjit Kumar Tulabandu824f9db2019-07-05 15:16:37 +0530298 // TODO(any): Experiment with coeff_opt_dist_threshold values when
299 // enable_winner_mode_for_coeff_opt is ON
300 // TODO(any): Skip the winner mode processing for blocks with lower residual
301 // energy as R-D optimization of coefficients would have been enabled during
302 // mode decision
303 if (enable_winner_mode_for_coeff_opt) {
304 // Use conservative threshold during mode decision and perform R-D
305 // optimization of coeffs always for winner modes
306 if (is_winner_mode)
Cherma Rajan A628efce2019-09-18 18:55:12 +0530307 coeff_opt_thresh = coeff_opt_dist_threshold[WINNER_MODE_EVAL];
Ranjit Kumar Tulabandu824f9db2019-07-05 15:16:37 +0530308 else
Cherma Rajan A628efce2019-09-18 18:55:12 +0530309 coeff_opt_thresh = coeff_opt_dist_threshold[MODE_EVAL];
Ranjit Kumar Tulabandu824f9db2019-07-05 15:16:37 +0530310 }
311 return coeff_opt_thresh;
312}
313
Ranjit Kumar Tulabanduc9717302019-07-08 15:08:09 +0530314// Used to reset the state of tx/mb rd hash information
chiyotsai4c1e5c62020-04-30 17:54:14 -0700315static INLINE void reset_hash_records(TxfmSearchInfo *const txfm_info,
Vishesh593ef1b2019-11-25 15:52:15 +0530316 int use_inter_txb_hash) {
Ranjit Kumar Tulabanduc9717302019-07-08 15:08:09 +0530317 int32_t record_idx;
318
319 // Reset the state for use_inter_txb_hash
Vishesh593ef1b2019-11-25 15:52:15 +0530320 if (use_inter_txb_hash) {
321 for (record_idx = 0;
322 record_idx < ((MAX_MIB_SIZE >> 1) * (MAX_MIB_SIZE >> 1)); record_idx++)
chiyotsai4c1e5c62020-04-30 17:54:14 -0700323 txfm_info->txb_rd_record_8X8[record_idx].num =
324 txfm_info->txb_rd_record_8X8[record_idx].index_start = 0;
Vishesh593ef1b2019-11-25 15:52:15 +0530325 for (record_idx = 0;
326 record_idx < ((MAX_MIB_SIZE >> 2) * (MAX_MIB_SIZE >> 2)); record_idx++)
chiyotsai4c1e5c62020-04-30 17:54:14 -0700327 txfm_info->txb_rd_record_16X16[record_idx].num =
328 txfm_info->txb_rd_record_16X16[record_idx].index_start = 0;
Vishesh593ef1b2019-11-25 15:52:15 +0530329 for (record_idx = 0;
330 record_idx < ((MAX_MIB_SIZE >> 3) * (MAX_MIB_SIZE >> 3)); record_idx++)
chiyotsai4c1e5c62020-04-30 17:54:14 -0700331 txfm_info->txb_rd_record_32X32[record_idx].num =
332 txfm_info->txb_rd_record_32X32[record_idx].index_start = 0;
Vishesh593ef1b2019-11-25 15:52:15 +0530333 for (record_idx = 0;
334 record_idx < ((MAX_MIB_SIZE >> 4) * (MAX_MIB_SIZE >> 4)); record_idx++)
chiyotsai4c1e5c62020-04-30 17:54:14 -0700335 txfm_info->txb_rd_record_64X64[record_idx].num =
336 txfm_info->txb_rd_record_64X64[record_idx].index_start = 0;
Vishesh593ef1b2019-11-25 15:52:15 +0530337 }
Ranjit Kumar Tulabanduc9717302019-07-08 15:08:09 +0530338
339 // Reset the state for use_intra_txb_hash
chiyotsai4c1e5c62020-04-30 17:54:14 -0700340 txfm_info->txb_rd_record_intra.num =
341 txfm_info->txb_rd_record_intra.index_start = 0;
Ranjit Kumar Tulabanduc9717302019-07-08 15:08:09 +0530342
343 // Reset the state for use_mb_rd_hash
chiyotsai4c1e5c62020-04-30 17:54:14 -0700344 txfm_info->mb_rd_record.num = txfm_info->mb_rd_record.index_start = 0;
Ranjit Kumar Tulabanduc9717302019-07-08 15:08:09 +0530345}
346
Yaowu Xuf883b422016-08-30 14:01:10 -0700347void av1_setup_pred_block(const MACROBLOCKD *xd,
348 struct buf_2d dst[MAX_MB_PLANE],
Hui Sub94cd5e2019-11-06 12:05:47 -0800349 const YV12_BUFFER_CONFIG *src,
Yaowu Xuf883b422016-08-30 14:01:10 -0700350 const struct scale_factors *scale,
Imdad Sardharwallaaf8e2642018-01-19 11:46:34 +0000351 const struct scale_factors *scale_uv,
352 const int num_planes);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700353
Yaowu Xuf883b422016-08-30 14:01:10 -0700354int av1_get_intra_cost_penalty(int qindex, int qdelta,
355 aom_bit_depth_t bit_depth);
Yaowu Xuc27fc142016-08-22 16:08:15 -0700356
chiyotsai9a06d182020-05-01 17:12:12 -0700357void av1_fill_mode_rates(AV1_COMMON *const cm, ModeCosts *mode_costs,
Yue Chenb23d00a2017-07-28 17:01:21 -0700358 FRAME_CONTEXT *fc);
359
Mufaddal Chakeraec449062020-06-03 16:57:56 +0530360void av1_fill_lr_rates(ModeCosts *mode_costs, FRAME_CONTEXT *fc);
361
chiyotsai9a06d182020-05-01 17:12:12 -0700362void av1_fill_coeff_costs(CoeffCosts *coeff_costs, FRAME_CONTEXT *fc,
Imdad Sardharwallaaf8e2642018-01-19 11:46:34 +0000363 const int num_planes);
Jingning Handfd72322017-08-09 14:04:12 -0700364
Wan-Teh Changec5cb192019-09-16 08:50:06 -0700365void av1_fill_mv_costs(const FRAME_CONTEXT *fc, int integer_mv, int usehp,
chiyotsai9a06d182020-05-01 17:12:12 -0700366 MvCosts *mv_costs);
Debargha Mukherjee8d273412019-09-11 10:36:50 -0700367
Yue Chen7cae98f2018-08-24 10:43:16 -0700368int av1_get_adaptive_rdmult(const struct AV1_COMP *cpi, double beta);
369
Debargha Mukherjeecfcd5ad2019-05-20 20:27:17 -0700370int av1_get_deltaq_offset(const struct AV1_COMP *cpi, int qindex, double beta);
371
Yaowu Xuc27fc142016-08-22 16:08:15 -0700372#ifdef __cplusplus
373} // extern "C"
374#endif
375
James Zerne1cbb132018-08-22 14:10:36 -0700376#endif // AOM_AV1_ENCODER_RD_H_