#include "av1/common/av1_common_int.h"
#include "av1/common/cfl.h"
#include "av1/common/reconintra.h"
#include "av1/encoder/intra_mode_search.h"
#include "av1/encoder/intra_mode_search_utils.h"
#include "av1/encoder/palette.h"
#include "av1/encoder/speed_features.h"
#include "av1/encoder/tx_search.h"
#define SIZE_OF_ANGLE_DELTA_RD_COST_ARRAY …
static const int8_t luma_delta_angles_order[2 * MAX_ANGLE_DELTA] = …;
static const PREDICTION_MODE intra_rd_search_mode_order[INTRA_MODES] = …;
static const UV_PREDICTION_MODE uv_rd_search_mode_order[UV_INTRA_MODES] = …;
static const uint8_t av1_derived_filter_intra_mode_used_flag[INTRA_MODES] = …;
static const uint16_t av1_derived_chroma_intra_mode_used_flag[INTRA_MODES] = …;
DECLARE_ALIGNED(16, static const uint8_t, all_zeros[MAX_SB_SIZE]) = …;
DECLARE_ALIGNED(16, static const uint16_t,
highbd_all_zeros[MAX_SB_SIZE]) = …;
int av1_calc_normalized_variance(aom_variance_fn_t vf, const uint8_t *const buf,
const int stride, const int is_hbd) { … }
static void compute_avg_log_variance(const AV1_COMP *const cpi, MACROBLOCK *x,
const BLOCK_SIZE bs,
double *avg_log_src_variance,
double *avg_log_recon_variance) { … }
static double intra_rd_variance_factor(const AV1_COMP *cpi, MACROBLOCK *x,
BLOCK_SIZE bs) { … }
static int rd_pick_filter_intra_sby(const AV1_COMP *const cpi, MACROBLOCK *x,
int *rate, int *rate_tokenonly,
int64_t *distortion, uint8_t *skippable,
BLOCK_SIZE bsize, int mode_cost,
PREDICTION_MODE best_mode_so_far,
int64_t *best_rd, int64_t *best_model_rd,
PICK_MODE_CONTEXT *ctx) { … }
void av1_count_colors(const uint8_t *src, int stride, int rows, int cols,
int *val_count, int *num_colors) { … }
void av1_count_colors_highbd(const uint8_t *src8, int stride, int rows,
int cols, int bit_depth, int *val_count,
int *bin_val_count, int *num_color_bins,
int *num_colors) { … }
void set_y_mode_and_delta_angle(const int mode_idx, MB_MODE_INFO *const mbmi,
int reorder_delta_angle_eval) { … }
static inline int get_model_rd_index_for_pruning(
const MACROBLOCK *const x,
const INTRA_MODE_SPEED_FEATURES *const intra_sf) { … }
static int prune_intra_y_mode(int64_t this_model_rd, int64_t *best_model_rd,
int64_t top_intra_model_rd[],
int max_model_cnt_allowed,
int model_rd_index_for_pruning) { … }
static int64_t pick_intra_angle_routine_sbuv(
const AV1_COMP *const cpi, MACROBLOCK *x, BLOCK_SIZE bsize,
int rate_overhead, int64_t best_rd_in, int *rate, RD_STATS *rd_stats,
int *best_angle_delta, int64_t *best_rd) { … }
static int rd_pick_intra_angle_sbuv(const AV1_COMP *const cpi, MACROBLOCK *x,
BLOCK_SIZE bsize, int rate_overhead,
int64_t best_rd, int *rate,
RD_STATS *rd_stats) { … }
#define PLANE_SIGN_TO_JOINT_SIGN(plane, a, b) …
static void cfl_idx_to_sign_and_alpha(int cfl_idx, CFL_SIGN_TYPE *cfl_sign,
int *cfl_alpha) { … }
static int64_t cfl_compute_rd(const AV1_COMP *const cpi, MACROBLOCK *x,
int plane, TX_SIZE tx_size,
BLOCK_SIZE plane_bsize, int cfl_idx,
int fast_mode, RD_STATS *rd_stats) { … }
static const int cfl_dir_ls[2] = …;
static int cfl_pick_plane_parameter(const AV1_COMP *const cpi, MACROBLOCK *x,
int plane, TX_SIZE tx_size,
int cfl_search_range) { … }
static inline void set_invalid_cfl_parameters(uint8_t *best_cfl_alpha_idx,
int8_t *best_cfl_alpha_signs) { … }
static void cfl_pick_plane_rd(const AV1_COMP *const cpi, MACROBLOCK *x,
int plane, TX_SIZE tx_size, int cfl_search_range,
RD_STATS cfl_rd_arr[CFL_MAGS_SIZE],
int est_best_cfl_idx) { … }
static int cfl_rd_pick_alpha(MACROBLOCK *const x, const AV1_COMP *const cpi,
TX_SIZE tx_size, int64_t ref_best_rd,
int cfl_search_range, RD_STATS *best_rd_stats,
uint8_t *best_cfl_alpha_idx,
int8_t *best_cfl_alpha_signs) { … }
static bool should_prune_chroma_smooth_pred_based_on_source_variance(
const AV1_COMP *cpi, const MACROBLOCK *x, BLOCK_SIZE bsize) { … }
int64_t av1_rd_pick_intra_sbuv_mode(const AV1_COMP *const cpi, MACROBLOCK *x,
int *rate, int *rate_tokenonly,
int64_t *distortion, uint8_t *skippable,
BLOCK_SIZE bsize, TX_SIZE max_tx_size) { … }
int av1_search_palette_mode(IntraModeSearchState *intra_search_state,
const AV1_COMP *cpi, MACROBLOCK *x,
BLOCK_SIZE bsize, unsigned int ref_frame_cost,
PICK_MODE_CONTEXT *ctx, RD_STATS *this_rd_cost,
int64_t best_rd) { … }
void av1_search_palette_mode_luma(const AV1_COMP *cpi, MACROBLOCK *x,
BLOCK_SIZE bsize, unsigned int ref_frame_cost,
PICK_MODE_CONTEXT *ctx,
RD_STATS *this_rd_cost, int64_t best_rd) { … }
static inline int intra_block_yrd(const AV1_COMP *const cpi, MACROBLOCK *x,
BLOCK_SIZE bsize, const int *bmode_costs,
int64_t *best_rd, int *rate,
int *rate_tokenonly, int64_t *distortion,
uint8_t *skippable, MB_MODE_INFO *best_mbmi,
PICK_MODE_CONTEXT *ctx) { … }
static inline void handle_filter_intra_mode(const AV1_COMP *cpi, MACROBLOCK *x,
BLOCK_SIZE bsize,
const PICK_MODE_CONTEXT *ctx,
RD_STATS *rd_stats_y, int mode_cost,
int64_t best_rd,
int64_t best_rd_so_far) { … }
int av1_handle_intra_y_mode(IntraModeSearchState *intra_search_state,
const AV1_COMP *cpi, MACROBLOCK *x,
BLOCK_SIZE bsize, unsigned int ref_frame_cost,
const PICK_MODE_CONTEXT *ctx, RD_STATS *rd_stats_y,
int64_t best_rd, int *mode_cost_y, int64_t *rd_y,
int64_t *best_model_rd,
int64_t top_intra_model_rd[]) { … }
int av1_search_intra_uv_modes_in_interframe(
IntraModeSearchState *intra_search_state, const AV1_COMP *cpi,
MACROBLOCK *x, BLOCK_SIZE bsize, RD_STATS *rd_stats,
const RD_STATS *rd_stats_y, RD_STATS *rd_stats_uv, int64_t best_rd) { … }
static inline int prune_luma_odd_delta_angles_using_rd_cost(
const MB_MODE_INFO *const mbmi, const int64_t *const intra_modes_rd_cost,
int64_t best_rd, int prune_luma_odd_delta_angles_in_intra) { … }
int64_t av1_rd_pick_intra_sby_mode(const AV1_COMP *const cpi, MACROBLOCK *x,
int *rate, int *rate_tokenonly,
int64_t *distortion, uint8_t *skippable,
BLOCK_SIZE bsize, int64_t best_rd,
PICK_MODE_CONTEXT *ctx) { … }