Move more features from AV1_COMMON to FeatureFlags
- bool switchable_motion_mode
- TX_MODE tx_mode
- InterpFilter interp_filter
- int primary_ref_frame
- int byte_alignment
BUG=aomedia:2610
Change-Id: I2265d9da62f700953f3b58f8cb9a1444140404e5
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index 0902bd6..fc8a1de 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -269,7 +269,7 @@
const MB_MODE_INFO *mbmi,
aom_writer *w) {
MOTION_MODE last_motion_mode_allowed =
- cm->switchable_motion_mode
+ cm->features.switchable_motion_mode
? motion_mode_allowed(cm->global_motion, xd, mbmi,
cm->features.allow_warped_motion)
: SIMPLE_TRANSLATION;
@@ -603,21 +603,20 @@
2 * MAX_ANGLE_DELTA + 1);
}
-static AOM_INLINE void write_mb_interp_filter(AV1_COMP *cpi,
+static AOM_INLINE void write_mb_interp_filter(AV1_COMMON *const cm,
const MACROBLOCKD *xd,
aom_writer *w) {
- AV1_COMMON *const cm = &cpi->common;
const MB_MODE_INFO *const mbmi = xd->mi[0];
FRAME_CONTEXT *ec_ctx = xd->tile_ctx;
if (!av1_is_interp_needed(xd)) {
- int_interpfilters filters =
- av1_broadcast_interp_filter(av1_unswitchable_filter(cm->interp_filter));
+ int_interpfilters filters = av1_broadcast_interp_filter(
+ av1_unswitchable_filter(cm->features.interp_filter));
assert(mbmi->interp_filters.as_int == filters.as_int);
(void)filters;
return;
}
- if (cm->interp_filter == SWITCHABLE) {
+ if (cm->features.interp_filter == SWITCHABLE) {
int dir;
for (dir = 0; dir < 2; ++dir) {
const int ctx = av1_get_pred_context_switchable_interp(xd, dir);
@@ -1214,7 +1213,7 @@
}
}
}
- write_mb_interp_filter(cpi, xd, w);
+ write_mb_interp_filter(cm, xd, w);
}
}
@@ -1514,7 +1513,7 @@
const int is_inter_tx = is_inter_block(mbmi);
const int skip = mbmi->skip;
const int segment_id = mbmi->segment_id;
- if (cm->tx_mode == TX_MODE_SELECT && block_signals_txsize(bsize) &&
+ if (cm->features.tx_mode == TX_MODE_SELECT && block_signals_txsize(bsize) &&
!(is_inter_tx && skip) && !xd->lossless[segment_id]) {
if (is_inter_tx) { // This implies skip flag is 0.
const TX_SIZE max_tx_size = get_vartx_max_txsize(xd, bsize, 0);
@@ -2064,7 +2063,7 @@
if (!seg->enabled) return;
// Write update flags
- if (cm->primary_ref_frame == PRIMARY_REF_NONE) {
+ if (cm->features.primary_ref_frame == PRIMARY_REF_NONE) {
assert(seg->update_map == 1);
seg->temporal_update = 0;
assert(seg->update_data == 1);
@@ -2923,7 +2922,7 @@
seq_params->order_hint_info.order_hint_bits_minus_1 + 1);
if (!features->error_resilient_mode && !frame_is_intra_only(cm)) {
- aom_wb_write_literal(wb, cm->primary_ref_frame, PRIMARY_REF_BITS);
+ aom_wb_write_literal(wb, features->primary_ref_frame, PRIMARY_REF_BITS);
}
}
@@ -3047,8 +3046,8 @@
if (!features->cur_frame_force_integer_mv)
aom_wb_write_bit(wb, features->allow_high_precision_mv);
- write_frame_interp_filter(cm->interp_filter, wb);
- aom_wb_write_bit(wb, cm->switchable_motion_mode);
+ write_frame_interp_filter(features->interp_filter, wb);
+ aom_wb_write_bit(wb, features->switchable_motion_mode);
if (frame_might_allow_ref_frame_mvs(cm)) {
aom_wb_write_bit(wb, features->allow_ref_frame_mvs);
} else {
@@ -3060,11 +3059,11 @@
const int might_bwd_adapt = !(seq_params->reduced_still_picture_hdr) &&
!(features->disable_cdf_update);
if (cm->tiles.large_scale)
- assert(cm->refresh_frame_context == REFRESH_FRAME_CONTEXT_DISABLED);
+ assert(features->refresh_frame_context == REFRESH_FRAME_CONTEXT_DISABLED);
if (might_bwd_adapt) {
aom_wb_write_bit(
- wb, cm->refresh_frame_context == REFRESH_FRAME_CONTEXT_DISABLED);
+ wb, features->refresh_frame_context == REFRESH_FRAME_CONTEXT_DISABLED);
}
write_tile_info(cm, saved_wb, wb);
@@ -3102,9 +3101,9 @@
// Write TX mode
if (features->coded_lossless)
- assert(cm->tx_mode == ONLY_4X4);
+ assert(features->tx_mode == ONLY_4X4);
else
- aom_wb_write_bit(wb, cm->tx_mode == TX_MODE_SELECT);
+ aom_wb_write_bit(wb, features->tx_mode == TX_MODE_SELECT);
if (!frame_is_intra_only(cm)) {
const int use_hybrid_pred =
diff --git a/av1/encoder/encode_strategy.c b/av1/encoder/encode_strategy.c
index d61e787..900c9ae 100644
--- a/av1/encoder/encode_strategy.c
+++ b/av1/encoder/encode_strategy.c
@@ -202,7 +202,7 @@
}
if (cpi->ext_refresh_frame_context_pending) {
- cm->refresh_frame_context = cpi->ext_refresh_frame_context;
+ cm->features.refresh_frame_context = cpi->ext_refresh_frame_context;
cpi->ext_refresh_frame_context_pending = 0;
}
cm->features.allow_ref_frame_mvs = cpi->ext_use_ref_frame_mvs;
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index d0db89a..4533204 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -648,7 +648,7 @@
update_global_motion_used(mi_addr->mode, bsize, mi_addr, rdc);
}
- if (cm->interp_filter == SWITCHABLE &&
+ if (cm->features.interp_filter == SWITCHABLE &&
mi_addr->motion_mode != WARPED_CAUSAL &&
!is_nontrans_global_motion(xd, xd->mi[0])) {
update_filter_type_count(td->counts, xd, mi_addr);
@@ -1342,7 +1342,7 @@
}
const MOTION_MODE motion_allowed =
- cm->switchable_motion_mode
+ cm->features.switchable_motion_mode
? motion_mode_allowed(xd->global_motion, xd, mbmi,
cm->features.allow_warped_motion)
: SIMPLE_TRANSLATION;
@@ -1409,7 +1409,7 @@
}
}
- if (inter_block && cm->interp_filter == SWITCHABLE &&
+ if (inter_block && cm->features.interp_filter == SWITCHABLE &&
mbmi->motion_mode != WARPED_CAUSAL &&
!is_nontrans_global_motion(xd, mbmi)) {
update_filter_type_cdf(xd, mbmi);
@@ -1657,7 +1657,7 @@
segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_REF_FRAME);
if (!seg_ref_active && inter_block) {
const MOTION_MODE motion_allowed =
- cm->switchable_motion_mode
+ cm->features.switchable_motion_mode
? motion_mode_allowed(xd->global_motion, xd, mbmi,
cm->features.allow_warped_motion)
: SIMPLE_TRANSLATION;
@@ -5900,7 +5900,7 @@
const TX_SIZE_SEARCH_METHOD tx_search_type =
cpi->tx_size_search_methods[eval_type];
assert(cpi->oxcf.enable_tx64 || tx_search_type != USE_LARGESTALL);
- cm->tx_mode = select_tx_mode(cpi, tx_search_type);
+ features->tx_mode = select_tx_mode(cpi, tx_search_type);
if (cpi->sf.tx_sf.tx_type_search.prune_tx_type_using_stats) {
const FRAME_UPDATE_TYPE update_type = get_frame_update_type(&cpi->gf_group);
@@ -5952,7 +5952,7 @@
if (cm->current_frame.frame_type != KEY_FRAME &&
cpi->sf.interp_sf.adaptive_interp_filter_search == 2 &&
- cm->interp_filter == SWITCHABLE) {
+ features->interp_filter == SWITCHABLE) {
const FRAME_UPDATE_TYPE update_type = get_frame_update_type(&cpi->gf_group);
for (i = 0; i < SWITCHABLE_FILTER_CONTEXTS; i++) {
@@ -5986,10 +5986,11 @@
void av1_encode_frame(AV1_COMP *cpi) {
AV1_COMMON *const cm = &cpi->common;
CurrentFrame *const current_frame = &cm->current_frame;
+ FeatureFlags *const features = &cm->features;
const int num_planes = av1_num_planes(cm);
// Indicates whether or not to use a default reduced set for ext-tx
// rather than the potential full set of 16 transforms
- cm->features.reduced_tx_set_used = cpi->oxcf.reduced_tx_type_set;
+ features->reduced_tx_set_used = cpi->oxcf.reduced_tx_type_set;
// Make sure segment_id is no larger than last_active_segid.
if (cm->seg.enabled && cm->seg.update_map) {
@@ -6061,10 +6062,10 @@
else
current_frame->reference_mode = REFERENCE_MODE_SELECT;
- cm->interp_filter = SWITCHABLE;
- if (cm->tiles.large_scale) cm->interp_filter = EIGHTTAP_REGULAR;
+ features->interp_filter = SWITCHABLE;
+ if (cm->tiles.large_scale) features->interp_filter = EIGHTTAP_REGULAR;
- cm->switchable_motion_mode = 1;
+ features->switchable_motion_mode = 1;
rdc->compound_ref_used_flag = 0;
rdc->skip_mode_used_flag = 0;
@@ -6092,8 +6093,9 @@
skip_mode_info->skip_mode_flag = 0;
if (!cm->tiles.large_scale) {
- if (cm->tx_mode == TX_MODE_SELECT && cpi->td.mb.txb_split_count == 0)
- cm->tx_mode = TX_MODE_LARGEST;
+ if (features->tx_mode == TX_MODE_SELECT &&
+ cpi->td.mb.txb_split_count == 0)
+ features->tx_mode = TX_MODE_LARGEST;
}
} else {
encode_frame_internal(cpi);
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index c384f33..84e6372 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -1053,7 +1053,7 @@
&cpi->alt_ref_buffer, oxcf->width, oxcf->height,
seq_params->subsampling_x, seq_params->subsampling_y,
seq_params->use_highbitdepth, cpi->oxcf.border_in_pixels,
- cm->byte_alignment, NULL, NULL, NULL))
+ cm->features.byte_alignment, NULL, NULL, NULL))
aom_internal_error(&cm->error, AOM_CODEC_MEM_ERROR,
"Failed to allocate altref buffer");
}
@@ -1061,10 +1061,11 @@
static void alloc_util_frame_buffers(AV1_COMP *cpi) {
AV1_COMMON *const cm = &cpi->common;
const SequenceHeader *const seq_params = &cm->seq_params;
+ const int byte_alignment = cm->features.byte_alignment;
if (aom_realloc_frame_buffer(
&cpi->last_frame_uf, cm->width, cm->height, seq_params->subsampling_x,
seq_params->subsampling_y, seq_params->use_highbitdepth,
- cpi->oxcf.border_in_pixels, cm->byte_alignment, NULL, NULL, NULL))
+ cpi->oxcf.border_in_pixels, byte_alignment, NULL, NULL, NULL))
aom_internal_error(&cm->error, AOM_CODEC_MEM_ERROR,
"Failed to allocate last frame buffer");
@@ -1072,14 +1073,14 @@
&cpi->trial_frame_rst, cm->superres_upscaled_width,
cm->superres_upscaled_height, seq_params->subsampling_x,
seq_params->subsampling_y, seq_params->use_highbitdepth,
- AOM_RESTORATION_FRAME_BORDER, cm->byte_alignment, NULL, NULL, NULL))
+ AOM_RESTORATION_FRAME_BORDER, byte_alignment, NULL, NULL, NULL))
aom_internal_error(&cm->error, AOM_CODEC_MEM_ERROR,
"Failed to allocate trial restored frame buffer");
if (aom_realloc_frame_buffer(
&cpi->scaled_source, cm->width, cm->height, seq_params->subsampling_x,
seq_params->subsampling_y, seq_params->use_highbitdepth,
- cpi->oxcf.border_in_pixels, cm->byte_alignment, NULL, NULL, NULL))
+ cpi->oxcf.border_in_pixels, byte_alignment, NULL, NULL, NULL))
aom_internal_error(&cm->error, AOM_CODEC_MEM_ERROR,
"Failed to allocate scaled source buffer");
@@ -1087,7 +1088,7 @@
&cpi->scaled_last_source, cm->width, cm->height,
seq_params->subsampling_x, seq_params->subsampling_y,
seq_params->use_highbitdepth, cpi->oxcf.border_in_pixels,
- cm->byte_alignment, NULL, NULL, NULL))
+ byte_alignment, NULL, NULL, NULL))
aom_internal_error(&cm->error, AOM_CODEC_MEM_ERROR,
"Failed to allocate scaled last source buffer");
}
@@ -2841,11 +2842,11 @@
cpi->refresh_golden_frame = 0;
cpi->refresh_bwd_ref_frame = 0;
- cm->refresh_frame_context = (oxcf->frame_parallel_decoding_mode)
- ? REFRESH_FRAME_CONTEXT_DISABLED
- : REFRESH_FRAME_CONTEXT_BACKWARD;
+ cm->features.refresh_frame_context = (oxcf->frame_parallel_decoding_mode)
+ ? REFRESH_FRAME_CONTEXT_DISABLED
+ : REFRESH_FRAME_CONTEXT_BACKWARD;
if (oxcf->large_scale_tile)
- cm->refresh_frame_context = REFRESH_FRAME_CONTEXT_DISABLED;
+ cm->features.refresh_frame_context = REFRESH_FRAME_CONTEXT_DISABLED;
if (x->palette_buffer == NULL) {
CHECK_MEM_ERROR(cm, x->palette_buffer,
@@ -2889,8 +2890,9 @@
rc->worst_quality = cpi->oxcf.worst_allowed_q;
rc->best_quality = cpi->oxcf.best_allowed_q;
- cm->interp_filter = oxcf->large_scale_tile ? EIGHTTAP_REGULAR : SWITCHABLE;
- cm->switchable_motion_mode = 1;
+ cm->features.interp_filter =
+ oxcf->large_scale_tile ? EIGHTTAP_REGULAR : SWITCHABLE;
+ cm->features.switchable_motion_mode = 1;
if (cpi->oxcf.render_width > 0 && cpi->oxcf.render_height > 0) {
cm->render_width = cpi->oxcf.render_width;
@@ -2976,11 +2978,11 @@
aom_calloc(cpi->tpl_stats_buffer[frame].width *
cpi->tpl_stats_buffer[frame].height,
sizeof(*cpi->tpl_stats_buffer[frame].tpl_stats_ptr)));
- if (aom_alloc_frame_buffer(&cpi->tpl_rec_pool[frame], cm->width, cm->height,
- cm->seq_params.subsampling_x,
- cm->seq_params.subsampling_y,
- cm->seq_params.use_highbitdepth,
- AOM_ENC_NO_SCALE_BORDER, cm->byte_alignment))
+ if (aom_alloc_frame_buffer(
+ &cpi->tpl_rec_pool[frame], cm->width, cm->height,
+ cm->seq_params.subsampling_x, cm->seq_params.subsampling_y,
+ cm->seq_params.use_highbitdepth, AOM_ENC_NO_SCALE_BORDER,
+ cm->features.byte_alignment))
aom_internal_error(&cm->error, AOM_CODEC_MEM_ERROR,
"Failed to allocate frame buffer");
}
@@ -3864,8 +3866,8 @@
ref->border < AOM_BORDER_IN_PIXELS) {
RefCntBuffer *ref_fb = get_ref_frame_buf(cm, ref_frame);
if (aom_yv12_realloc_with_new_border(
- &ref_fb->buf, AOM_BORDER_IN_PIXELS, cm->byte_alignment,
- num_planes) != 0) {
+ &ref_fb->buf, AOM_BORDER_IN_PIXELS,
+ cm->features.byte_alignment, num_planes) != 0) {
aom_internal_error(&cm->error, AOM_CODEC_MEM_ERROR,
"Failed to allocate frame buffer");
}
@@ -3888,7 +3890,7 @@
&new_fb->buf, cm->width, cm->height,
cm->seq_params.subsampling_x, cm->seq_params.subsampling_y,
cm->seq_params.use_highbitdepth, AOM_BORDER_IN_PIXELS,
- cm->byte_alignment, NULL, NULL, NULL)) {
+ cm->features.byte_alignment, NULL, NULL, NULL)) {
if (force_scaling) {
// Release the reference acquired in the get_free_fb() call above.
--new_fb->ref_count;
@@ -4031,8 +4033,8 @@
av1_set_speed_features_framesize_independent(cpi, cpi->speed);
av1_set_rd_speed_thresholds(cpi);
- cm->interp_filter = SWITCHABLE;
- cm->switchable_motion_mode = 1;
+ cm->features.interp_filter = SWITCHABLE;
+ cm->features.switchable_motion_mode = 1;
}
#if !CONFIG_REALTIME_ONLY
@@ -4354,7 +4356,8 @@
if (aom_realloc_frame_buffer(
&cm->cur_frame->buf, cm->width, cm->height, seq_params->subsampling_x,
seq_params->subsampling_y, seq_params->use_highbitdepth,
- cpi->oxcf.border_in_pixels, cm->byte_alignment, NULL, NULL, NULL))
+ cpi->oxcf.border_in_pixels, cm->features.byte_alignment, NULL, NULL,
+ NULL))
aom_internal_error(&cm->error, AOM_CODEC_MEM_ERROR,
"Failed to allocate frame buffer");
@@ -4726,7 +4729,8 @@
&cpi->scaled_source, cm->superres_upscaled_width,
cm->superres_upscaled_height, cm->seq_params.subsampling_x,
cm->seq_params.subsampling_y, cm->seq_params.use_highbitdepth,
- AOM_BORDER_IN_PIXELS, cm->byte_alignment, NULL, NULL, NULL))
+ AOM_BORDER_IN_PIXELS, cm->features.byte_alignment, NULL, NULL,
+ NULL))
aom_internal_error(
&cm->error, AOM_CODEC_MEM_ERROR,
"Failed to reallocate scaled source buffer for superres");
@@ -4908,7 +4912,7 @@
}
}
- fix_interp_filter(&cm->interp_filter, cpi->td.counts);
+ fix_interp_filter(&cm->features.interp_filter, cpi->td.counts);
}
static int get_regulated_q_overshoot(AV1_COMP *const cpi, int q_low, int q_high,
@@ -5725,7 +5729,7 @@
ybf->y_crop_height, ybf->subsampling_x,
ybf->subsampling_y,
ybf->flags & YV12_FLAG_HIGHBITDEPTH, ybf->border,
- cm->byte_alignment) != AOM_CODEC_OK) {
+ cm->features.byte_alignment) != AOM_CODEC_OK) {
aom_internal_error(
&cm->error, AOM_CODEC_MEM_ERROR,
"Failed to allocate copy buffer for saving coding context");
@@ -6429,7 +6433,7 @@
av1_accumulate_frame_counts(&aggregate_fc, &cpi->counts);
#endif // CONFIG_ENTROPY_STATS
- if (cm->refresh_frame_context == REFRESH_FRAME_CONTEXT_BACKWARD) {
+ if (features->refresh_frame_context == REFRESH_FRAME_CONTEXT_BACKWARD) {
*cm->fc = cpi->tile_data[largest_tile_id].tctx;
av1_reset_cdf_symbol_counters(cm->fc);
}
@@ -6502,7 +6506,7 @@
current_frame->refresh_frame_flags = frame_params->refresh_frame_flags;
cm->features.error_resilient_mode = frame_params->error_resilient_mode;
- cm->primary_ref_frame = frame_params->primary_ref_frame;
+ cm->features.primary_ref_frame = frame_params->primary_ref_frame;
cm->current_frame.frame_type = frame_params->frame_type;
cm->show_frame = frame_params->show_frame;
cpi->ref_frame_flags = frame_params->ref_frame_flags;
@@ -6773,11 +6777,11 @@
av1_set_high_precision_mv(cpi, 1, 0);
// Normal defaults
- cm->refresh_frame_context = oxcf->frame_parallel_decoding_mode
- ? REFRESH_FRAME_CONTEXT_DISABLED
- : REFRESH_FRAME_CONTEXT_BACKWARD;
+ cm->features.refresh_frame_context = oxcf->frame_parallel_decoding_mode
+ ? REFRESH_FRAME_CONTEXT_DISABLED
+ : REFRESH_FRAME_CONTEXT_BACKWARD;
if (oxcf->large_scale_tile)
- cm->refresh_frame_context = REFRESH_FRAME_CONTEXT_DISABLED;
+ cm->features.refresh_frame_context = REFRESH_FRAME_CONTEXT_DISABLED;
// Initialize fields related to forward keyframes
cpi->no_show_kf = 0;
diff --git a/av1/encoder/interp_search.c b/av1/encoder/interp_search.c
index 1b94651..7fc2672 100644
--- a/av1/encoder/interp_search.c
+++ b/av1/encoder/interp_search.c
@@ -612,7 +612,7 @@
av1_init_rd_stats(&rd_stats);
int match_found_idx = -1;
- const InterpFilter assign_filter = cm->interp_filter;
+ const InterpFilter assign_filter = cm->features.interp_filter;
match_found_idx = av1_find_interp_filter_match(
mbmi, cpi, assign_filter, need_search, args->interp_filter_stats,
diff --git a/av1/encoder/nonrd_pickmode.c b/av1/encoder/nonrd_pickmode.c
index 902420d..d0eb08b 100644
--- a/av1/encoder/nonrd_pickmode.c
+++ b/av1/encoder/nonrd_pickmode.c
@@ -917,7 +917,7 @@
mbmi->motion_mode = SIMPLE_TRANSLATION;
mbmi->num_proj_ref = 1;
mbmi->interintra_mode = 0;
- set_default_interp_filters(mbmi, cm->interp_filter);
+ set_default_interp_filters(mbmi, cm->features.interp_filter);
}
#if CONFIG_INTERNAL_STATS
@@ -1333,7 +1333,7 @@
else
model_rd_for_sb_y(cpi, bsize, x, xd, &pf_rate[i], &pf_dist[i],
&skip_txfm[i], NULL, &pf_var[i], &pf_sse[i], 1);
- pf_rate[i] += av1_get_switchable_rate(cm, x, xd);
+ pf_rate[i] += av1_get_switchable_rate(x, xd, cm->features.interp_filter);
cost = RDCOST(x->rdmult, pf_rate[i], pf_dist[i]);
pf_tx_size[i] = mi->tx_size;
if (cost < best_cost) {
@@ -1592,7 +1592,7 @@
// filter_ref, we use a less strict condition on assigning filter_ref.
// This is to reduce the probabily of entering the flow of not assigning
// filter_ref and then skip filter search.
- filter_ref = cm->interp_filter;
+ filter_ref = cm->features.interp_filter;
// initialize mode decisions
av1_invalid_rd_stats(&best_rdc);
diff --git a/av1/encoder/picklpf.c b/av1/encoder/picklpf.c
index 2b4addb..78cb1c8 100644
--- a/av1/encoder/picklpf.c
+++ b/av1/encoder/picklpf.c
@@ -147,7 +147,7 @@
bias = (bias * cpi->twopass.section_intra_rating) / 20;
// yx, bias less for large block size
- if (cm->tx_mode != ONLY_4X4) bias >>= 1;
+ if (cm->features.tx_mode != ONLY_4X4) bias >>= 1;
if (filt_direction <= 0 && filt_low != filt_mid) {
// Get Low filter error score
diff --git a/av1/encoder/rd.c b/av1/encoder/rd.c
index b7b0cd9..20e2ab2 100644
--- a/av1/encoder/rd.c
+++ b/av1/encoder/rd.c
@@ -1065,9 +1065,9 @@
: NULL;
}
-int av1_get_switchable_rate(const AV1_COMMON *const cm, MACROBLOCK *x,
- const MACROBLOCKD *xd) {
- if (cm->interp_filter == SWITCHABLE) {
+int av1_get_switchable_rate(const MACROBLOCK *x, const MACROBLOCKD *xd,
+ InterpFilter interp_filter) {
+ if (interp_filter == SWITCHABLE) {
const MB_MODE_INFO *const mbmi = xd->mi[0];
int inter_filter_cost = 0;
int dir;
diff --git a/av1/encoder/rd.h b/av1/encoder/rd.h
index e1d5bd9..cac8c5b 100644
--- a/av1/encoder/rd.h
+++ b/av1/encoder/rd.h
@@ -230,8 +230,8 @@
void av1_model_rd_surffit(BLOCK_SIZE bsize, double sse_norm, double xm,
double yl, double *rate_f, double *distbysse_f);
-int av1_get_switchable_rate(const AV1_COMMON *const cm, MACROBLOCK *x,
- const MACROBLOCKD *xd);
+int av1_get_switchable_rate(const MACROBLOCK *x, const MACROBLOCKD *xd,
+ InterpFilter interp_filter);
YV12_BUFFER_CONFIG *av1_get_scaled_ref_frame(const struct AV1_COMP *cpi,
int ref_frame);
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index 8022137..268f08f 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -1229,6 +1229,7 @@
const BUFFER_SET *orig_dst, int64_t *best_est_rd, int do_tx_search,
InterModesInfo *inter_modes_info, int eval_motion_mode) {
const AV1_COMMON *const cm = &cpi->common;
+ const FeatureFlags *const features = &cm->features;
const int num_planes = av1_num_planes(cm);
MACROBLOCKD *xd = &x->e_mbd;
MB_MODE_INFO *mbmi = xd->mi[0];
@@ -1252,9 +1253,9 @@
aom_clear_system_state();
mbmi->num_proj_ref = 1; // assume num_proj_ref >=1
MOTION_MODE last_motion_mode_allowed = SIMPLE_TRANSLATION;
- if (cm->switchable_motion_mode) {
+ if (features->switchable_motion_mode) {
last_motion_mode_allowed = motion_mode_allowed(
- xd->global_motion, xd, mbmi, cm->features.allow_warped_motion);
+ xd->global_motion, xd, mbmi, features->allow_warped_motion);
}
if (last_motion_mode_allowed == WARPED_CAUSAL) {
@@ -1268,8 +1269,10 @@
const MB_MODE_INFO base_mbmi = *mbmi;
MB_MODE_INFO best_mbmi;
SimpleRDState *const simple_states = &args->simple_rd_state[mbmi->ref_mv_idx];
+ const int interp_filter = features->interp_filter;
const int switchable_rate =
- av1_is_interp_needed(xd) ? av1_get_switchable_rate(cm, x, xd) : 0;
+ av1_is_interp_needed(xd) ? av1_get_switchable_rate(x, xd, interp_filter)
+ : 0;
int64_t best_rd = INT64_MAX;
int best_rate_mv = rate_mv0;
const int mi_row = xd->mi_row;
@@ -1351,8 +1354,8 @@
int pts[SAMPLES_ARRAY_SIZE], pts_inref[SAMPLES_ARRAY_SIZE];
mbmi->motion_mode = WARPED_CAUSAL;
mbmi->wm_params.wmtype = DEFAULT_WMTYPE;
- mbmi->interp_filters = av1_broadcast_interp_filter(
- av1_unswitchable_filter(cm->interp_filter));
+ mbmi->interp_filters =
+ av1_broadcast_interp_filter(av1_unswitchable_filter(interp_filter));
memcpy(pts, pts0, total_samples * 2 * sizeof(*pts0));
memcpy(pts_inref, pts_inref0, total_samples * 2 * sizeof(*pts_inref0));
@@ -1569,8 +1572,8 @@
if (this_mode == GLOBALMV || this_mode == GLOBAL_GLOBALMV) {
if (is_nontrans_global_motion(xd, xd->mi[0])) {
- mbmi->interp_filters = av1_broadcast_interp_filter(
- av1_unswitchable_filter(cm->interp_filter));
+ mbmi->interp_filters =
+ av1_broadcast_interp_filter(av1_unswitchable_filter(interp_filter));
}
}
@@ -1944,7 +1947,7 @@
mbmi->comp_group_idx = 0;
mbmi->compound_idx = 1;
}
- set_default_interp_filters(mbmi, cm->interp_filter);
+ set_default_interp_filters(mbmi, cm->features.interp_filter);
const int mi_row = xd->mi_row;
const int mi_col = xd->mi_col;
@@ -2485,7 +2488,7 @@
if (is_comp_pred) {
// Find matching interp filter or set to default interp filter
const int need_search = av1_is_interp_needed(xd);
- const InterpFilter assign_filter = cm->interp_filter;
+ const InterpFilter assign_filter = cm->features.interp_filter;
int is_luma_interp_done = 0;
av1_find_interp_filter_match(mbmi, cpi, assign_filter, need_search,
args->interp_filter_stats,
@@ -2961,7 +2964,7 @@
mbmi->ref_mv_idx = 0;
mbmi->skip_mode = mbmi->skip = 1;
- set_default_interp_filters(mbmi, cm->interp_filter);
+ set_default_interp_filters(mbmi, cm->features.interp_filter);
set_ref_ptrs(cm, xd, mbmi->ref_frame[0], mbmi->ref_frame[1]);
for (int i = 0; i < num_planes; i++) {
@@ -3029,7 +3032,8 @@
(INTERINTRA_MODE)(II_DC_PRED - 1);
search_state->best_mbmode.filter_intra_mode_info.use_filter_intra = 0;
- set_default_interp_filters(&search_state->best_mbmode, cm->interp_filter);
+ set_default_interp_filters(&search_state->best_mbmode,
+ cm->features.interp_filter);
search_state->best_mode_index = mode_index;
@@ -3793,7 +3797,7 @@
mbmi->mv[0].as_int = mbmi->mv[1].as_int = 0;
mbmi->motion_mode = SIMPLE_TRANSLATION;
mbmi->interintra_mode = (INTERINTRA_MODE)(II_DC_PRED - 1);
- set_default_interp_filters(mbmi, cm->interp_filter);
+ set_default_interp_filters(mbmi, cm->features.interp_filter);
}
static AOM_INLINE void collect_single_states(MACROBLOCK *x,
@@ -4188,6 +4192,7 @@
const BLOCK_SIZE bsize, PICK_MODE_CONTEXT *ctx,
int64_t best_rd_so_far) {
AV1_COMMON *const cm = &cpi->common;
+ const FeatureFlags *const features = &cm->features;
const int num_planes = av1_num_planes(cm);
const SPEED_FEATURES *const sf = &cpi->sf;
MACROBLOCKD *const xd = &x->e_mbd;
@@ -4707,20 +4712,20 @@
const NN_CONFIG *nn_config = (AOMMIN(cm->width, cm->height) <= 480)
? &av1_intrap_nn_config
: &av1_intrap_hd_nn_config;
- float features[6];
+ float nn_features[6];
float scores[2] = { 0.0f };
float probs[2] = { 0.0f };
- features[0] = (float)search_state.best_mbmode.skip;
- features[1] = (float)mi_size_wide_log2[bsize];
- features[2] = (float)mi_size_high_log2[bsize];
- features[3] = (float)intra_cost;
- features[4] = (float)inter_cost;
+ nn_features[0] = (float)search_state.best_mbmode.skip;
+ nn_features[1] = (float)mi_size_wide_log2[bsize];
+ nn_features[2] = (float)mi_size_high_log2[bsize];
+ nn_features[3] = (float)intra_cost;
+ nn_features[4] = (float)inter_cost;
const int ac_q = av1_ac_quant_QTX(x->qindex, 0, xd->bd);
const int ac_q_max = av1_ac_quant_QTX(255, 0, xd->bd);
- features[5] = (float)(ac_q_max / ac_q);
+ nn_features[5] = (float)(ac_q_max / ac_q);
- av1_nn_predict(features, nn_config, 1, scores);
+ av1_nn_predict(nn_features, nn_config, 1, scores);
aom_clear_system_state();
av1_nn_softmax(scores, probs, 2);
@@ -4799,8 +4804,7 @@
// Only try palette mode when the best mode so far is an intra mode.
const int try_palette =
cpi->oxcf.enable_palette &&
- av1_allow_palette(cm->features.allow_screen_content_tools,
- mbmi->sb_type) &&
+ av1_allow_palette(features->allow_screen_content_tools, mbmi->sb_type) &&
!is_inter_mode(search_state.best_mbmode.mode);
PALETTE_MODE_INFO *const pmi = &mbmi->palette_mode_info;
RD_STATS this_rd_cost;
@@ -4851,12 +4855,13 @@
return;
}
- assert((cm->interp_filter == SWITCHABLE) ||
- (cm->interp_filter ==
+ const InterpFilter interp_filter = features->interp_filter;
+ assert((interp_filter == SWITCHABLE) ||
+ (interp_filter ==
search_state.best_mbmode.interp_filters.as_filters.y_filter) ||
!is_inter_block(&search_state.best_mbmode));
- assert((cm->interp_filter == SWITCHABLE) ||
- (cm->interp_filter ==
+ assert((interp_filter == SWITCHABLE) ||
+ (interp_filter ==
search_state.best_mbmode.interp_filters.as_filters.x_filter) ||
!is_inter_block(&search_state.best_mbmode));
@@ -4875,8 +4880,8 @@
if (mbmi->mode == GLOBALMV || mbmi->mode == GLOBAL_GLOBALMV) {
// Correct the interp filters for GLOBALMV
if (is_nontrans_global_motion(xd, xd->mi[0])) {
- int_interpfilters filters = av1_broadcast_interp_filter(
- av1_unswitchable_filter(cm->interp_filter));
+ int_interpfilters filters =
+ av1_broadcast_interp_filter(av1_unswitchable_filter(interp_filter));
assert(mbmi->interp_filters.as_int == filters.as_int);
(void)filters;
}
@@ -4918,6 +4923,7 @@
PICK_MODE_CONTEXT *ctx,
int64_t best_rd_so_far) {
const AV1_COMMON *const cm = &cpi->common;
+ const FeatureFlags *const features = &cm->features;
MACROBLOCKD *const xd = &x->e_mbd;
MB_MODE_INFO *const mbmi = xd->mi[0];
unsigned char segment_id = mbmi->segment_id;
@@ -4960,8 +4966,8 @@
mbmi->ref_frame[1] = NONE_FRAME;
mbmi->mv[0].as_int =
gm_get_motion_vector(&cm->global_motion[mbmi->ref_frame[0]],
- cm->features.allow_high_precision_mv, bsize, mi_col,
- mi_row, cm->features.cur_frame_force_integer_mv)
+ features->allow_high_precision_mv, bsize, mi_col,
+ mi_row, features->cur_frame_force_integer_mv)
.as_int;
mbmi->tx_size = max_txsize_lookup[bsize];
x->force_skip = 1;
@@ -4979,10 +4985,11 @@
mbmi->num_proj_ref, bsize);
}
- set_default_interp_filters(mbmi, cm->interp_filter);
+ const InterpFilter interp_filter = features->interp_filter;
+ set_default_interp_filters(mbmi, interp_filter);
- if (cm->interp_filter != SWITCHABLE) {
- best_filter = cm->interp_filter;
+ if (interp_filter != SWITCHABLE) {
+ best_filter = interp_filter;
} else {
best_filter = EIGHTTAP_REGULAR;
if (av1_is_interp_needed(xd) &&
@@ -4992,7 +4999,7 @@
int best_rs = INT_MAX;
for (i = 0; i < SWITCHABLE_FILTERS; ++i) {
mbmi->interp_filters = av1_broadcast_interp_filter(i);
- rs = av1_get_switchable_rate(cm, x, xd);
+ rs = av1_get_switchable_rate(x, xd, interp_filter);
if (rs < best_rs) {
best_rs = rs;
best_filter = mbmi->interp_filters.as_filters.y_filter;
@@ -5002,7 +5009,7 @@
}
// Set the appropriate filter
mbmi->interp_filters = av1_broadcast_interp_filter(best_filter);
- rate2 += av1_get_switchable_rate(cm, x, xd);
+ rate2 += av1_get_switchable_rate(x, xd, interp_filter);
if (cm->current_frame.reference_mode == REFERENCE_MODE_SELECT)
rate2 += comp_inter_cost[comp_pred];
@@ -5022,8 +5029,8 @@
return;
}
- assert((cm->interp_filter == SWITCHABLE) ||
- (cm->interp_filter == mbmi->interp_filters.as_filters.y_filter));
+ assert((interp_filter == SWITCHABLE) ||
+ (interp_filter == mbmi->interp_filters.as_filters.y_filter));
if (cpi->sf.inter_sf.adaptive_rd_thresh) {
av1_update_rd_thresh_fact(cm, x->thresh_freq_fact,
diff --git a/av1/encoder/segmentation.c b/av1/encoder/segmentation.c
index c34c3fc..0c029c0 100644
--- a/av1/encoder/segmentation.c
+++ b/av1/encoder/segmentation.c
@@ -216,7 +216,7 @@
no_pred_cost += no_pred_segcounts[i] * seg_id_cost[i];
// Frames without past dependency cannot use temporal prediction
- if (cm->primary_ref_frame != PRIMARY_REF_NONE) {
+ if (cm->features.primary_ref_frame != PRIMARY_REF_NONE) {
int pred_flag_cost[SEG_TEMPORAL_PRED_CTXS][2];
for (int i = 0; i < SEG_TEMPORAL_PRED_CTXS; ++i)
av1_cost_tokens_from_cdf(pred_flag_cost[i], segp->pred_cdf[i], NULL);
diff --git a/av1/encoder/tune_vmaf.c b/av1/encoder/tune_vmaf.c
index 72fd846..997f78e 100644
--- a/av1/encoder/tune_vmaf.c
+++ b/av1/encoder/tune_vmaf.c
@@ -200,9 +200,9 @@
YV12_BUFFER_CONFIG sharpened;
memset(&sharpened, 0, sizeof(sharpened));
- aom_alloc_frame_buffer(&sharpened, width, height, 1, 1,
- cm->seq_params.use_highbitdepth,
- cpi->oxcf.border_in_pixels, cm->byte_alignment);
+ aom_alloc_frame_buffer(
+ &sharpened, width, height, 1, 1, cm->seq_params.use_highbitdepth,
+ cpi->oxcf.border_in_pixels, cm->features.byte_alignment);
const double baseline_variance = frame_average_variance(cpi, source);
double unsharp_amount;
@@ -245,12 +245,12 @@
YV12_BUFFER_CONFIG source_extended, blurred;
memset(&source_extended, 0, sizeof(source_extended));
memset(&blurred, 0, sizeof(blurred));
- aom_alloc_frame_buffer(&source_extended, width, height, 1, 1,
- cm->seq_params.use_highbitdepth,
- cpi->oxcf.border_in_pixels, cm->byte_alignment);
- aom_alloc_frame_buffer(&blurred, width, height, 1, 1,
- cm->seq_params.use_highbitdepth,
- cpi->oxcf.border_in_pixels, cm->byte_alignment);
+ aom_alloc_frame_buffer(
+ &source_extended, width, height, 1, 1, cm->seq_params.use_highbitdepth,
+ cpi->oxcf.border_in_pixels, cm->features.byte_alignment);
+ aom_alloc_frame_buffer(
+ &blurred, width, height, 1, 1, cm->seq_params.use_highbitdepth,
+ cpi->oxcf.border_in_pixels, cm->features.byte_alignment);
av1_copy_and_extend_frame(source, &source_extended);
gaussian_blur(bit_depth, &source_extended, &blurred);
@@ -276,12 +276,12 @@
YV12_BUFFER_CONFIG source_extended, blurred;
memset(&blurred, 0, sizeof(blurred));
memset(&source_extended, 0, sizeof(source_extended));
- aom_alloc_frame_buffer(&blurred, width, height, 1, 1,
- cm->seq_params.use_highbitdepth,
- cpi->oxcf.border_in_pixels, cm->byte_alignment);
- aom_alloc_frame_buffer(&source_extended, width, height, 1, 1,
- cm->seq_params.use_highbitdepth,
- cpi->oxcf.border_in_pixels, cm->byte_alignment);
+ aom_alloc_frame_buffer(
+ &blurred, width, height, 1, 1, cm->seq_params.use_highbitdepth,
+ cpi->oxcf.border_in_pixels, cm->features.byte_alignment);
+ aom_alloc_frame_buffer(
+ &source_extended, width, height, 1, 1, cm->seq_params.use_highbitdepth,
+ cpi->oxcf.border_in_pixels, cm->features.byte_alignment);
av1_copy_and_extend_frame(source, &source_extended);
gaussian_blur(bit_depth, &source_extended, &blurred);
@@ -304,12 +304,12 @@
YV12_BUFFER_CONFIG source_block, blurred_block;
memset(&source_block, 0, sizeof(source_block));
memset(&blurred_block, 0, sizeof(blurred_block));
- aom_alloc_frame_buffer(&source_block, block_w, block_h, 1, 1,
- cm->seq_params.use_highbitdepth,
- cpi->oxcf.border_in_pixels, cm->byte_alignment);
- aom_alloc_frame_buffer(&blurred_block, block_w, block_h, 1, 1,
- cm->seq_params.use_highbitdepth,
- cpi->oxcf.border_in_pixels, cm->byte_alignment);
+ aom_alloc_frame_buffer(
+ &source_block, block_w, block_h, 1, 1, cm->seq_params.use_highbitdepth,
+ cpi->oxcf.border_in_pixels, cm->features.byte_alignment);
+ aom_alloc_frame_buffer(
+ &blurred_block, block_w, block_h, 1, 1, cm->seq_params.use_highbitdepth,
+ cpi->oxcf.border_in_pixels, cm->features.byte_alignment);
for (int row = 0; row < num_rows; ++row) {
for (int col = 0; col < num_cols; ++col) {
@@ -510,10 +510,10 @@
aom_clear_system_state();
YV12_BUFFER_CONFIG resized_source;
memset(&resized_source, 0, sizeof(resized_source));
- aom_alloc_frame_buffer(&resized_source, y_width / resize_factor,
- y_height / resize_factor, 1, 1,
- cm->seq_params.use_highbitdepth,
- cpi->oxcf.border_in_pixels, cm->byte_alignment);
+ aom_alloc_frame_buffer(
+ &resized_source, y_width / resize_factor, y_height / resize_factor, 1, 1,
+ cm->seq_params.use_highbitdepth, cpi->oxcf.border_in_pixels,
+ cm->features.byte_alignment);
av1_resize_and_extend_frame(cpi->source, &resized_source, bit_depth,
av1_num_planes(cm));
@@ -530,7 +530,8 @@
memset(&blurred, 0, sizeof(blurred));
aom_alloc_frame_buffer(&blurred, resized_y_width, resized_y_height, 1, 1,
cm->seq_params.use_highbitdepth,
- cpi->oxcf.border_in_pixels, cm->byte_alignment);
+ cpi->oxcf.border_in_pixels,
+ cm->features.byte_alignment);
gaussian_blur(bit_depth, &resized_source, &blurred);
double *scores = aom_malloc(sizeof(*scores) * (num_rows * num_cols));
@@ -674,15 +675,15 @@
memset(&blurred_last, 0, sizeof(blurred_last));
memset(&blurred_next, 0, sizeof(blurred_next));
- aom_alloc_frame_buffer(&blurred_cur, y_width, y_height, 1, 1,
- cm->seq_params.use_highbitdepth,
- cpi->oxcf.border_in_pixels, cm->byte_alignment);
- aom_alloc_frame_buffer(&blurred_last, y_width, y_height, 1, 1,
- cm->seq_params.use_highbitdepth,
- cpi->oxcf.border_in_pixels, cm->byte_alignment);
- aom_alloc_frame_buffer(&blurred_next, y_width, y_height, 1, 1,
- cm->seq_params.use_highbitdepth,
- cpi->oxcf.border_in_pixels, cm->byte_alignment);
+ aom_alloc_frame_buffer(
+ &blurred_cur, y_width, y_height, 1, 1, cm->seq_params.use_highbitdepth,
+ cpi->oxcf.border_in_pixels, cm->features.byte_alignment);
+ aom_alloc_frame_buffer(
+ &blurred_last, y_width, y_height, 1, 1, cm->seq_params.use_highbitdepth,
+ cpi->oxcf.border_in_pixels, cm->features.byte_alignment);
+ aom_alloc_frame_buffer(
+ &blurred_next, y_width, y_height, 1, 1, cm->seq_params.use_highbitdepth,
+ cpi->oxcf.border_in_pixels, cm->features.byte_alignment);
gaussian_blur(bit_depth, cur, &blurred_cur);
gaussian_blur(bit_depth, last, &blurred_last);