#ifndef AOM_AV1_ENCODER_RD_H_
#define AOM_AV1_ENCODER_RD_H_
#include <limits.h>
#include "av1/common/blockd.h"
#include "av1/encoder/block.h"
#include "av1/encoder/context_tree.h"
#include "av1/encoder/cost.h"
#include "av1/encoder/ratectrl.h"
#include "config/aom_config.h"
#ifdef __cplusplus
extern "C" {
#endif
#define RDDIV_BITS …
#define RD_EPB_SHIFT …
#define RDCOST(RM, R, D) …
#define RDCOST_NEG_R(RM, R, D) …
#define RDCOST_DBL_WITH_NATIVE_BD_DIST(RM, R, D, BD) …
#define QIDX_SKIP_THRESH …
#define MV_COST_WEIGHT …
#define MV_COST_WEIGHT_SUB …
#define RD_THRESH_FAC_FRAC_BITS …
#define RD_THRESH_FAC_FRAC_VAL …
#define RD_THRESH_MAX_FACT …
#define RD_THRESH_LOG_DEC_FACTOR …
#define RD_THRESH_INC …
#define SWITCHABLE_INTERP_RATE_FACTOR …
#define RESOLUTION_288P …
#define RESOLUTION_360P …
#define RESOLUTION_480P …
#define RESOLUTION_720P …
#define RESOLUTION_1080P …
#define RESOLUTION_1440P …
#define RESOLUTION_4K …
#define RTC_REFS …
static const MV_REFERENCE_FRAME real_time_ref_combos[RTC_REFS][2] = …;
static inline int mode_offset(const PREDICTION_MODE mode) { … }
enum { … } UENUM1BYTE(…) …;
RD_OPT;
static inline void av1_init_rd_stats(RD_STATS *rd_stats) { … }
static inline void av1_invalid_rd_stats(RD_STATS *rd_stats) { … }
static inline void av1_merge_rd_stats(RD_STATS *rd_stats_dst,
const RD_STATS *rd_stats_src) { … }
static inline void av1_accumulate_rd_stats(RD_STATS *rd_stats, int64_t dist,
int rate, int skip_txfm, int64_t sse,
int zero_rate) { … }
static inline int64_t av1_calculate_rd_cost(int mult, int rate, int64_t dist) { … }
static inline void av1_rd_cost_update(int mult, RD_STATS *rd_cost) { … }
static inline void av1_rd_stats_subtraction(int mult,
const RD_STATS *const left,
const RD_STATS *const right,
RD_STATS *result) { … }
struct TileInfo;
struct TileDataEnc;
struct AV1_COMP;
struct macroblock;
int av1_compute_rd_mult_based_on_qindex(aom_bit_depth_t bit_depth,
FRAME_UPDATE_TYPE update_type,
int qindex);
int av1_compute_rd_mult(const int qindex, const aom_bit_depth_t bit_depth,
const FRAME_UPDATE_TYPE update_type,
const int layer_depth, const int boost_index,
const FRAME_TYPE frame_type,
const int use_fixed_qp_offsets,
const int is_stat_consumption_stage);
void av1_initialize_rd_consts(struct AV1_COMP *cpi);
void av1_set_sad_per_bit(const struct AV1_COMP *cpi, int *sadperbit,
int qindex);
void av1_model_rd_from_var_lapndz(int64_t var, unsigned int n,
unsigned int qstep, int *rate, int64_t *dist);
void av1_model_rd_curvfit(BLOCK_SIZE bsize, double sse_norm, double xqr,
double *rate_f, double *distbysse_f);
int av1_get_switchable_rate(const MACROBLOCK *x, const MACROBLOCKD *xd,
InterpFilter interp_filter, int dual_filter);
YV12_BUFFER_CONFIG *av1_get_scaled_ref_frame(const struct AV1_COMP *cpi,
int ref_frame);
void av1_init_me_luts(void);
void av1_set_mvcost(MACROBLOCK *x, int ref, int ref_mv_idx);
void av1_get_entropy_contexts(BLOCK_SIZE plane_bsize,
const struct macroblockd_plane *pd,
ENTROPY_CONTEXT t_above[MAX_MIB_SIZE],
ENTROPY_CONTEXT t_left[MAX_MIB_SIZE]);
void av1_set_rd_speed_thresholds(struct AV1_COMP *cpi);
void av1_update_rd_thresh_fact(const AV1_COMMON *const cm,
int (*fact)[MAX_MODES], int rd_thresh,
BLOCK_SIZE bsize, THR_MODES best_mode_index,
THR_MODES inter_mode_start,
THR_MODES inter_mode_end,
THR_MODES intra_mode_start,
THR_MODES intra_mode_end);
static inline void reset_thresh_freq_fact(MACROBLOCK *const x) { … }
static inline int rd_less_than_thresh(int64_t best_rd, int64_t thresh,
int thresh_fact) { … }
void av1_mv_pred(const struct AV1_COMP *cpi, MACROBLOCK *x,
uint8_t *ref_y_buffer, int ref_y_stride, int ref_frame,
BLOCK_SIZE block_size);
static inline void av1_set_error_per_bit(int *errorperbit, int rdmult) { … }
static inline void get_rd_opt_coeff_thresh(
const uint32_t (*const coeff_opt_threshold)[2],
TxfmSearchParams *txfm_params, int enable_winner_mode_for_coeff_opt,
int is_winner_mode) { … }
static inline void reset_mb_rd_record(MB_RD_RECORD *const mb_rd_record) { … }
void av1_setup_pred_block(const MACROBLOCKD *xd,
struct buf_2d dst[MAX_MB_PLANE],
const YV12_BUFFER_CONFIG *src,
const struct scale_factors *scale,
const struct scale_factors *scale_uv,
const int num_planes);
int av1_get_intra_cost_penalty(int qindex, int qdelta,
aom_bit_depth_t bit_depth);
void av1_fill_mode_rates(AV1_COMMON *const cm, ModeCosts *mode_costs,
FRAME_CONTEXT *fc);
#if !CONFIG_REALTIME_ONLY
void av1_fill_lr_rates(ModeCosts *mode_costs, FRAME_CONTEXT *fc);
#endif
void av1_fill_coeff_costs(CoeffCosts *coeff_costs, FRAME_CONTEXT *fc,
const int num_planes);
void av1_fill_mv_costs(const nmv_context *nmvc, int integer_mv, int usehp,
MvCosts *mv_costs);
void av1_fill_dv_costs(const nmv_context *ndvc, IntraBCMVCosts *dv_costs);
#if !CONFIG_REALTIME_ONLY
int av1_get_adaptive_rdmult(const struct AV1_COMP *cpi, double beta);
#endif
int av1_get_deltaq_offset(aom_bit_depth_t bit_depth, int qindex, double beta);
int av1_adjust_q_from_delta_q_res(int delta_q_res, int prev_qindex,
int curr_qindex);
#ifdef __cplusplus
}
#endif
#endif