Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions av2/encoder/intra_mode_search.c
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,18 @@ int64_t av2_rd_pick_intra_sbuv_mode(const AV2_COMP *const cpi, MACROBLOCK *x,
return best_rd;
}

// Shared palette-mode gate used at the several palette-search entry points.
static AVM_INLINE bool should_try_palette(const AV2_COMP *const cpi,
const MB_MODE_INFO *const mbmi,
int plane_type) {
const FeatureFlags *const features = &cpi->common.features;
return cpi->oxcf.tool_cfg.enable_palette &&
!(cpi->sf.intra_sf.disable_palette &&
!features->is_scc_content_by_detector) &&
av2_allow_palette(plane_type, features->allow_screen_content_tools,
mbmi->sb_type[PLANE_TYPE_Y]);
}

// Searches palette mode for luma channel in inter frame.
int av2_search_palette_mode(IntraModeSearchState *intra_search_state,
const AV2_COMP *cpi, MACROBLOCK *x,
Expand All @@ -822,15 +834,12 @@ int av2_search_palette_mode(IntraModeSearchState *intra_search_state,
if (!is_intra_mode_allowed) return 0;

const AV2_COMMON *const cm = &cpi->common;
const FeatureFlags *const features = &cm->features;
MB_MODE_INFO *const mbmi = x->e_mbd.mi[0];

// Only try palette mode when the best mode so far is an intra mode.
int search_palette_mode =
cpi->oxcf.tool_cfg.enable_palette &&
av2_allow_palette(PLANE_TYPE_Y, features->allow_screen_content_tools,
mbmi->sb_type[PLANE_TYPE_Y]) &&
!is_inter_mode(best_mbmode->mode) && rd_cost->rate < INT_MAX;
int search_palette_mode = should_try_palette(cpi, mbmi, PLANE_TYPE_Y) &&
!is_inter_mode(best_mbmode->mode) &&
rd_cost->rate < INT_MAX;
const MB_MODE_INFO *cached_mode = x->inter_mode_cache[0];
if (should_reuse_mode(x, REUSE_INTRA_MODE_IN_INTERFRAME_FLAG) &&
cached_mode &&
Expand Down Expand Up @@ -1300,14 +1309,8 @@ int64_t av2_handle_intra_mode(IntraModeSearchState *intra_search_state,
av2_init_rd_stats(rd_stats_uv);
const int num_planes = av2_num_planes(cm);
if (num_planes > 1) {
// TODO(chiyotsai@google.com): Consolidate the chroma search code here
// with the one in av2_search_palette_mode.
PALETTE_MODE_INFO *const pmi = &mbmi->palette_mode_info;
const int try_palette =
cpi->oxcf.tool_cfg.enable_palette &&
av2_allow_palette(PLANE_TYPE_UV,
cm->features.allow_screen_content_tools,
mbmi->sb_type[PLANE_TYPE_Y]);
const int try_palette = should_try_palette(cpi, mbmi, PLANE_TYPE_UV);
// If no good uv-predictor had been found, search for it.
const int rate_y = rd_stats_y->rate;
const int64_t rdy =
Expand Down Expand Up @@ -1747,10 +1750,7 @@ int64_t av2_rd_pick_intra_sby_mode(const AV2_COMP *const cpi, ThreadData *td,
// this function.
int beat_best_rd = 0;
PALETTE_MODE_INFO *const pmi = &mbmi->palette_mode_info;
const bool try_palette =
cpi->oxcf.tool_cfg.enable_palette &&
av2_allow_palette(PLANE_TYPE_Y, cm->features.allow_screen_content_tools,
mbmi->sb_type[PLANE_TYPE_Y]);
const bool try_palette = should_try_palette(cpi, mbmi, PLANE_TYPE_Y);
uint8_t *best_palette_color_map =
try_palette ? x->palette_buffer->best_palette_color_map : NULL;
const int context = get_y_mode_idx_ctx(xd);
Expand Down
7 changes: 5 additions & 2 deletions av2/encoder/rdopt.c
Original file line number Diff line number Diff line change
Expand Up @@ -7122,7 +7122,9 @@ static AVM_INLINE void rd_pick_skip_mode(
assert(second_ref_frame != NONE_FRAME);
const PREDICTION_MODE this_mode = NEAR_NEARMV;

if (!cpi->oxcf.ref_frm_cfg.enable_onesided_comp && cpi->all_one_sided_refs) {
if ((!cpi->oxcf.ref_frm_cfg.enable_onesided_comp ||
cpi->sf.inter_sf.disable_onesided_comp) &&
cpi->all_one_sided_refs) {
return;
}

Expand Down Expand Up @@ -7707,7 +7709,8 @@ static AVM_INLINE int prune_ref_frame(const AV2_COMP *cpi, const MACROBLOCK *x,
av2_set_ref_frame(rf, ref_frame);
const int comp_pred = is_inter_ref_frame(rf[1]);
if (comp_pred) {
if (!cpi->oxcf.ref_frm_cfg.enable_onesided_comp) {
if (!cpi->oxcf.ref_frm_cfg.enable_onesided_comp ||
cpi->sf.inter_sf.disable_onesided_comp) {
// Disable all compound references
if (cpi->all_one_sided_refs) return 1;
// If both references are on the same side prune
Expand Down
11 changes: 9 additions & 2 deletions av2/encoder/speed_features.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ static void set_good_speed_feature_framesize_dependent(
}

static void set_good_speed_features_framesize_independent(
const AV2_COMP *const cpi, SPEED_FEATURES *const sf, int speed) {
AV2_COMP *const cpi, SPEED_FEATURES *const sf, int speed) {
const AV2_COMMON *const cm = &cpi->common;
const int is_480p_or_larger = AVMMIN(cm->width, cm->height) >= 480;
const GF_GROUP *const gf_group = &cpi->gf_group;
Expand Down Expand Up @@ -679,8 +679,11 @@ static void set_good_speed_features_framesize_independent(

if (speed >= 5) {
sf->intra_sf.intra_mode_prune_top = 2;
sf->intra_sf.disable_palette = true;
sf->part_sf.simple_motion_search_prune_agg = 3;
sf->inter_sf.disable_interinter_wedge = 1;
sf->inter_sf.disable_onesided_comp = true;
cpi->oxcf.tool_cfg.enable_tip_refinemv = 0;
sf->inter_sf.prune_inter_modes_if_skippable = 1;

// TODO(any): Extend multi-winner mode processing support for inter frames
Expand Down Expand Up @@ -768,7 +771,7 @@ static void set_good_speed_features_lc_dec_framesize_independent(
}

static void set_rt_speed_features_framesize_independent(
const AV2_COMP *const cpi, SPEED_FEATURES *const sf, int speed) {
AV2_COMP *const cpi, SPEED_FEATURES *const sf, int speed) {
// Set this good features as default for now.
set_good_speed_features_framesize_independent(cpi, sf, speed);
if (speed >= 6) {
Expand Down Expand Up @@ -965,6 +968,7 @@ static AVM_INLINE void init_inter_sf(INTER_MODE_SPEED_FEATURES *inter_sf) {
inter_sf->prune_comp_type_by_model_rd = 0;
inter_sf->perform_best_rd_based_gating_for_chroma = 0;
inter_sf->disable_interinter_wedge = 0;
inter_sf->disable_onesided_comp = false;
inter_sf->prune_ref_mv_idx_search = 0;
inter_sf->prune_warped_prob_thresh = 0;
inter_sf->reuse_compound_type_data = 0;
Expand Down Expand Up @@ -994,6 +998,7 @@ static AVM_INLINE void init_intra_sf(INTRA_MODE_SPEED_FEATURES *intra_sf) {
intra_sf->intra_mode_prune_top = TOP_INTRA_MODEL_COUNT;
intra_sf->src_var_thresh_intra_skip = 1;
intra_sf->prune_palette_search_level = 0;
intra_sf->disable_palette = false;
intra_sf->reuse_uv_mode_rd_info = false;
intra_sf->include_dip_for_top_n_model_rd_pruning = false;
intra_sf->skip_intra_dip_search = false;
Expand Down Expand Up @@ -1380,6 +1385,8 @@ void av2_set_speed_features_framesize_independent(AV2_COMP *cpi, int speed) {
}

if (!cpi->seq_params_locked) {
cpi->common.seq_params.enable_tip_refinemv =
cpi->oxcf.tool_cfg.enable_tip_refinemv;
cpi->common.seq_params.enable_restoration &= !sf->lpf_sf.disable_lr_filter;

cpi->common.seq_params.enable_masked_compound &=
Expand Down
5 changes: 5 additions & 0 deletions av2/encoder/speed_features.h
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,9 @@ typedef struct INTER_MODE_SPEED_FEATURES {
// Disable interinter_wedge
int disable_interinter_wedge;

// Disable one-sided compound at the speed >= 5 preset.
bool disable_onesided_comp;

// Whether to override and disable sb level coeff cost updates, if
// cpi->oxcf.cost_upd_freq.coeff = COST_UPD_SB (i.e. set at SB level)
int disable_sb_level_coeff_cost_upd;
Expand Down Expand Up @@ -918,6 +921,8 @@ typedef struct INTRA_MODE_SPEED_FEATURES {
// colors to remaining colors) and terminate the search if current number of
// palette colors is not the winner.
int prune_palette_search_level;
// Disable palette for speed >= 5 preset when it is not screen content.
bool disable_palette;
// Reuse chroma mode rate and distortion info during intra modes evaluation
// in inter frames.
// False: No reuse
Expand Down
Loading