int ref_frame[8];
int internal_delta_q[MAX_SEGMENTS];
int i;
- static const int flag_list[4] = { 0, VP9_LAST_FLAG, VP9_GOLD_FLAG,
- VP9_ALT_FLAG };
// TODO(jianj): Investigate why ROI not working in speed < 5 or in non
// realtime mode.
valid_ref = 0;
// If GOLDEN is selected, make sure it's set as reference.
if (ref_frame[i] == GOLDEN_FRAME &&
- !(cpi->ref_frame_flags & flag_list[ref_frame[i]])) {
+ !(cpi->ref_frame_flags & ref_frame_to_flag(ref_frame[i]))) {
valid_ref = 0;
}
// GOLDEN was updated in previous encoded frame, so GOLDEN and LAST are
(cpi->refresh_golden_frame && !cpi->rc.is_src_frame_alt_ref);
}
+static INLINE int ref_frame_to_flag(int8_t ref_frame) {
+ static const int kVp9RefFlagList[4] = { 0, VP9_LAST_FLAG, VP9_GOLD_FLAG,
+ VP9_ALT_FLAG };
+ assert(ref_frame >= LAST_FRAME && ref_frame <= ALTREF_FRAME);
+ return kVp9RefFlagList[ref_frame];
+}
+
static INLINE int get_ref_frame_map_idx(const VP9_COMP *cpi,
MV_REFERENCE_FRAME ref_frame) {
if (ref_frame == LAST_FRAME) {
VP9_COMP *cpi, MACROBLOCK *x, MV_REFERENCE_FRAME ref_frame,
int_mv frame_mv[MB_MODE_COUNT][MAX_REF_FRAMES],
int const_motion[MAX_REF_FRAMES], int *ref_frame_skip_mask,
- const int flag_list[4], TileDataEnc *tile_data, int mi_row, int mi_col,
+ TileDataEnc *tile_data, int mi_row, int mi_col,
struct buf_2d yv12_mb[4][MAX_MB_PLANE], BLOCK_SIZE bsize,
int force_skip_low_temp_var, int comp_pred_allowed) {
VP9_COMMON *const cm = &cpi->common;
frame_mv[NEWMV][ref_frame].as_int = INVALID_MV;
frame_mv[ZEROMV][ref_frame].as_int = 0;
// this needs various further optimizations. to be continued..
- if ((cpi->ref_frame_flags & flag_list[ref_frame]) && (yv12 != NULL)) {
+ if ((cpi->ref_frame_flags & ref_frame_to_flag(ref_frame)) && (yv12 != NULL)) {
int_mv *const candidates = x->mbmi_ext->ref_mvs[ref_frame];
const struct scale_factors *const sf = &cm->frame_refs[ref_frame - 1].sf;
vp9_setup_pred_block(xd, yv12_mb[ref_frame], yv12, mi_row, mi_col, sf, sf);
int_mv frame_mv[MB_MODE_COUNT][MAX_REF_FRAMES];
uint8_t mode_checked[MB_MODE_COUNT][MAX_REF_FRAMES];
struct buf_2d yv12_mb[4][MAX_MB_PLANE];
- static const int flag_list[4] = { 0, VP9_LAST_FLAG, VP9_GOLD_FLAG,
- VP9_ALT_FLAG };
RD_COST this_rdc, best_rdc;
// var_y and sse_y are saved to be used in skipping checking
unsigned int var_y = UINT_MAX;
// constrain the inter mode to only test zero motion.
if (cpi->use_svc && svc->force_zero_mode_spatial_ref &&
svc->spatial_layer_id > 0 && !gf_temporal_ref) {
- if (cpi->ref_frame_flags & flag_list[LAST_FRAME]) {
+ if (cpi->ref_frame_flags & VP9_LAST_FLAG) {
struct scale_factors *const sf = &cm->frame_refs[LAST_FRAME - 1].sf;
if (vp9_is_scaled(sf)) {
svc_force_zero_mode[LAST_FRAME - 1] = 1;
inter_layer_ref = LAST_FRAME;
}
}
- if (cpi->ref_frame_flags & flag_list[GOLDEN_FRAME]) {
+ if (cpi->ref_frame_flags & VP9_GOLD_FLAG) {
struct scale_factors *const sf = &cm->frame_refs[GOLDEN_FRAME - 1].sf;
if (vp9_is_scaled(sf)) {
svc_force_zero_mode[GOLDEN_FRAME - 1] = 1;
cpi->rc.avg_frame_low_motion < 60))
usable_ref_frame = LAST_FRAME;
- if (!((cpi->ref_frame_flags & flag_list[GOLDEN_FRAME]) &&
+ if (!((cpi->ref_frame_flags & VP9_GOLD_FLAG) &&
!svc_force_zero_mode[GOLDEN_FRAME - 1] && !force_skip_low_temp_var))
use_golden_nonzeromv = 0;
// Skip find_predictor if the reference frame is not in the
// ref_frame_flags (i.e., not used as a reference for this frame).
skip_ref_find_pred[ref_frame] =
- !(cpi->ref_frame_flags & flag_list[ref_frame]);
+ !(cpi->ref_frame_flags & ref_frame_to_flag(ref_frame));
if (!skip_ref_find_pred[ref_frame]) {
find_predictors(cpi, x, ref_frame, frame_mv, const_motion,
- &ref_frame_skip_mask, flag_list, tile_data, mi_row,
- mi_col, yv12_mb, bsize, force_skip_low_temp_var,
- comp_modes > 0);
+ &ref_frame_skip_mask, tile_data, mi_row, mi_col, yv12_mb,
+ bsize, force_skip_low_temp_var, comp_modes > 0);
}
}
// than current layer: force check of GF-ZEROMV before early exit
// due to skip flag.
if (svc->spatial_layer_id > 0 && no_scaling &&
- (cpi->ref_frame_flags & flag_list[GOLDEN_FRAME]) &&
+ (cpi->ref_frame_flags & VP9_GOLD_FLAG) &&
cm->base_qindex > svc->lower_layer_qindex + 10)
force_test_gf_zeromv = 1;
if (comp_pred) {
if (!cpi->allow_comp_inter_inter) continue;
// Skip compound inter modes if ARF is not available.
- if (!(cpi->ref_frame_flags & flag_list[second_ref_frame])) continue;
+ if (!(cpi->ref_frame_flags & ref_frame_to_flag(second_ref_frame)))
+ continue;
// Do not allow compound prediction if the segment level reference frame
// feature is in use as in this case there can only be one reference.
if (segfeature_active(seg, mi->segment_id, SEG_LVL_REF_FRAME)) continue;
(!cpi->use_svc && sse_zeromv_normalized < thresh_skip_golden)))
continue;
- if (!(cpi->ref_frame_flags & flag_list[ref_frame])) continue;
+ if (!(cpi->ref_frame_flags & ref_frame_to_flag(ref_frame))) continue;
// For screen content. If zero_temp_sad source is computed: skip
// non-zero motion check for stationary blocks. If the superblock is
if (usable_ref_frame < ALTREF_FRAME) {
if (!force_skip_low_temp_var && usable_ref_frame > LAST_FRAME) {
i = (ref_frame == LAST_FRAME) ? GOLDEN_FRAME : LAST_FRAME;
- if ((cpi->ref_frame_flags & flag_list[i]))
+ if ((cpi->ref_frame_flags & ref_frame_to_flag(i)))
if (x->pred_mv_sad[ref_frame] > (x->pred_mv_sad[i] << 1))
ref_frame_skip_mask |= (1 << ref_frame);
}
ref_frame == ALTREF_FRAME)) {
int ref1 = (ref_frame == GOLDEN_FRAME) ? LAST_FRAME : GOLDEN_FRAME;
int ref2 = (ref_frame == ALTREF_FRAME) ? LAST_FRAME : ALTREF_FRAME;
- if (((cpi->ref_frame_flags & flag_list[ref1]) &&
+ if (((cpi->ref_frame_flags & ref_frame_to_flag(ref1)) &&
(x->pred_mv_sad[ref_frame] > (x->pred_mv_sad[ref1] << 1))) ||
- ((cpi->ref_frame_flags & flag_list[ref2]) &&
+ ((cpi->ref_frame_flags & ref_frame_to_flag(ref2)) &&
(x->pred_mv_sad[ref_frame] > (x->pred_mv_sad[ref2] << 1))))
ref_frame_skip_mask |= (1 << ref_frame);
}
perform_intra_pred =
svc->temporal_layer_id == 0 ||
svc->layer_context[svc->temporal_layer_id].is_key_frame ||
- !(cpi->ref_frame_flags & flag_list[GOLDEN_FRAME]) ||
+ !(cpi->ref_frame_flags & VP9_GOLD_FLAG) ||
(!svc->layer_context[svc->temporal_layer_id].is_key_frame &&
svc_force_zero_mode[best_pickmode.best_ref_frame - 1]);
inter_mode_thresh = (inter_mode_thresh << 1) + inter_mode_thresh;
MV_REFERENCE_FRAME best_ref_frame = NONE;
unsigned char segment_id = mi->segment_id;
struct buf_2d yv12_mb[4][MAX_MB_PLANE];
- static const int flag_list[4] = { 0, VP9_LAST_FLAG, VP9_GOLD_FLAG,
- VP9_ALT_FLAG };
int64_t best_rd = INT64_MAX;
b_mode_info bsi[MAX_REF_FRAMES][4];
int ref_frame_skip_mask = 0;
int_mv dummy_mv[2];
x->pred_mv_sad[ref_frame] = INT_MAX;
- if ((cpi->ref_frame_flags & flag_list[ref_frame]) && (yv12 != NULL)) {
+ if ((cpi->ref_frame_flags & ref_frame_to_flag(ref_frame)) &&
+ (yv12 != NULL)) {
int_mv *const candidates = mbmi_ext->ref_mvs[ref_frame];
const struct scale_factors *const sf = &cm->frame_refs[ref_frame - 1].sf;
vp9_setup_pred_block(xd, yv12_mb[ref_frame], yv12, mi_row, mi_col, sf,
int_mv single_newmv[MAX_REF_FRAMES] = { { 0 } };
INTERP_FILTER single_inter_filter[MB_MODE_COUNT][MAX_REF_FRAMES];
int single_skippable[MB_MODE_COUNT][MAX_REF_FRAMES];
- static const int flag_list[4] = { 0, VP9_LAST_FLAG, VP9_GOLD_FLAG,
- VP9_ALT_FLAG };
int64_t best_rd = best_rd_so_far;
int64_t best_pred_diff[REFERENCE_MODES];
int64_t best_pred_rd[REFERENCE_MODES];
for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ++ref_frame) {
x->pred_mv_sad[ref_frame] = INT_MAX;
- if ((cpi->ref_frame_flags & flag_list[ref_frame]) &&
+ if ((cpi->ref_frame_flags & ref_frame_to_flag(ref_frame)) &&
!(is_rect_partition && (ctx->skip_ref_frame_mask & (1 << ref_frame)))) {
assert(get_ref_frame_buffer(cpi, ref_frame) != NULL);
setup_buffer_inter(cpi, x, ref_frame, bsize, mi_row, mi_col,
}
for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ++ref_frame) {
- if (!(cpi->ref_frame_flags & flag_list[ref_frame])) {
+ if (!(cpi->ref_frame_flags & ref_frame_to_flag(ref_frame))) {
// Skip checking missing references in both single and compound reference
// modes. Note that a mode will be skipped if both reference frames
// are masked out.
continue;
// Skip compound inter modes if ARF is not available.
- if (!(cpi->ref_frame_flags & flag_list[second_ref_frame])) continue;
+ if (!(cpi->ref_frame_flags & ref_frame_to_flag(second_ref_frame)))
+ continue;
// Do not allow compound prediction if the segment level reference frame
// feature is in use as in this case there can only be one reference.
int comp_pred, i;
int_mv frame_mv[MB_MODE_COUNT][MAX_REF_FRAMES];
struct buf_2d yv12_mb[4][MAX_MB_PLANE];
- static const int flag_list[4] = { 0, VP9_LAST_FLAG, VP9_GOLD_FLAG,
- VP9_ALT_FLAG };
int64_t best_rd = best_rd_so_far;
int64_t best_yrd = best_rd_so_far; // FIXME(rbultje) more precise
int64_t best_pred_diff[REFERENCE_MODES];
rd_cost->rate = INT_MAX;
for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ref_frame++) {
- if (cpi->ref_frame_flags & flag_list[ref_frame]) {
+ if (cpi->ref_frame_flags & ref_frame_to_flag(ref_frame)) {
setup_buffer_inter(cpi, x, ref_frame, bsize, mi_row, mi_col,
frame_mv[NEARESTMV], frame_mv[NEARMV], yv12_mb);
} else {
cm->ref_frame_sign_bias[second_ref_frame])
continue;
- if (!(cpi->ref_frame_flags & flag_list[second_ref_frame])) continue;
+ if (!(cpi->ref_frame_flags & ref_frame_to_flag(second_ref_frame)))
+ continue;
// Do not allow compound prediction if the segment level reference frame
// feature is in use as in this case there can only be one reference.
if (segfeature_active(seg, segment_id, SEG_LVL_REF_FRAME)) continue;
(cpi->external_resize == 1 ||
cpi->oxcf.resize_mode == RESIZE_DYNAMIC)) {
MV_REFERENCE_FRAME ref_frame;
- static const int flag_list[4] = { 0, VP9_LAST_FLAG, VP9_GOLD_FLAG,
- VP9_ALT_FLAG };
for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ++ref_frame) {
const YV12_BUFFER_CONFIG *yv12 = get_ref_frame_buffer(cpi, ref_frame);
- if (yv12 != NULL && (cpi->ref_frame_flags & flag_list[ref_frame])) {
+ if (yv12 != NULL &&
+ (cpi->ref_frame_flags & ref_frame_to_flag(ref_frame))) {
const struct scale_factors *const scale_fac =
&cm->frame_refs[ref_frame - 1].sf;
if (vp9_is_scaled(scale_fac)) sf->reference_masking = 0;
// fb_idx for that reference to the first one used/referenced.
// This is to avoid setting fb_idx for a reference to a slot that is not
// used/needed (i.e., since that reference is not referenced or refreshed).
- static const int flag_list[4] = { 0, VP9_LAST_FLAG, VP9_GOLD_FLAG,
- VP9_ALT_FLAG };
MV_REFERENCE_FRAME ref_frame;
MV_REFERENCE_FRAME first_ref = 0;
int first_fb_idx = 0;
int fb_idx[3] = { cpi->lst_fb_idx, cpi->gld_fb_idx, cpi->alt_fb_idx };
for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ref_frame++) {
- if (cpi->ref_frame_flags & flag_list[ref_frame]) {
+ if (cpi->ref_frame_flags & ref_frame_to_flag(ref_frame)) {
first_ref = ref_frame;
first_fb_idx = fb_idx[ref_frame - 1];
break;
}
}
if (first_ref > 0) {
- if (first_ref != LAST_FRAME &&
- !(cpi->ref_frame_flags & flag_list[LAST_FRAME]) &&
+ if (first_ref != LAST_FRAME && !(cpi->ref_frame_flags & VP9_LAST_FLAG) &&
!cpi->ext_refresh_last_frame)
cpi->lst_fb_idx = first_fb_idx;
else if (first_ref != GOLDEN_FRAME &&
- !(cpi->ref_frame_flags & flag_list[GOLDEN_FRAME]) &&
+ !(cpi->ref_frame_flags & VP9_GOLD_FLAG) &&
!cpi->ext_refresh_golden_frame)
cpi->gld_fb_idx = first_fb_idx;
else if (first_ref != ALTREF_FRAME &&
- !(cpi->ref_frame_flags & flag_list[ALTREF_FRAME]) &&
+ !(cpi->ref_frame_flags & VP9_ALT_FLAG) &&
!cpi->ext_refresh_alt_ref_frame)
cpi->alt_fb_idx = first_fb_idx;
}
void vp9_copy_flags_ref_update_idx(VP9_COMP *const cpi) {
SVC *const svc = &cpi->svc;
- static const int flag_list[4] = { 0, VP9_LAST_FLAG, VP9_GOLD_FLAG,
- VP9_ALT_FLAG };
int sl = svc->spatial_layer_id;
svc->lst_fb_idx[sl] = cpi->lst_fb_idx;
svc->gld_fb_idx[sl] = cpi->gld_fb_idx;
svc->update_golden[sl] = (uint8_t)cpi->refresh_golden_frame;
svc->update_altref[sl] = (uint8_t)cpi->refresh_alt_ref_frame;
- svc->reference_last[sl] =
- (uint8_t)(cpi->ref_frame_flags & flag_list[LAST_FRAME]);
- svc->reference_golden[sl] =
- (uint8_t)(cpi->ref_frame_flags & flag_list[GOLDEN_FRAME]);
- svc->reference_altref[sl] =
- (uint8_t)(cpi->ref_frame_flags & flag_list[ALTREF_FRAME]);
+ svc->reference_last[sl] = (uint8_t)(cpi->ref_frame_flags & VP9_LAST_FLAG);
+ svc->reference_golden[sl] = (uint8_t)(cpi->ref_frame_flags & VP9_GOLD_FLAG);
+ svc->reference_altref[sl] = (uint8_t)(cpi->ref_frame_flags & VP9_ALT_FLAG);
}
int vp9_one_pass_cbr_svc_start_layer(VP9_COMP *const cpi) {
svc->disable_inter_layer_pred == INTER_LAYER_PRED_OFF ||
svc->drop_spatial_layer[sl - 1]) {
MV_REFERENCE_FRAME ref_frame;
- static const int flag_list[4] = { 0, VP9_LAST_FLAG, VP9_GOLD_FLAG,
- VP9_ALT_FLAG };
for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ++ref_frame) {
const YV12_BUFFER_CONFIG *yv12 = get_ref_frame_buffer(cpi, ref_frame);
- if (yv12 != NULL && (cpi->ref_frame_flags & flag_list[ref_frame])) {
+ if (yv12 != NULL &&
+ (cpi->ref_frame_flags & ref_frame_to_flag(ref_frame))) {
const struct scale_factors *const scale_fac =
&cm->frame_refs[ref_frame - 1].sf;
if (vp9_is_scaled(scale_fac)) {
- cpi->ref_frame_flags &= (~flag_list[ref_frame]);
+ cpi->ref_frame_flags &= (~ref_frame_to_flag(ref_frame));
// Point golden/altref frame buffer index to last.
if (!svc->simulcast_mode) {
if (ref_frame == GOLDEN_FRAME)