Commit 6ef805eb authored by Ronald S. Bultje's avatar Ronald S. Bultje

Change ref frame coding.

Code intra/inter, then comp/single, then the ref frame selection.
Use contextualization for all steps. Don't code two past frames
in comp pred mode.

Change-Id: I4639a78cd5cccb283023265dbcc07898c3e7cf95
parent 9062b92b
......@@ -24,11 +24,8 @@
#define BLOCK_SIZE_GROUPS 4
#define MAX_MB_SEGMENTS 8
#define MB_SEG_TREE_PROBS (MAX_MB_SEGMENTS-1)
#define PREDICTION_PROBS 3
#define DEFAULT_PRED_PROB_0 120
#define DEFAULT_PRED_PROB_1 80
#define DEFAULT_PRED_PROB_2 40
#define PREDICTION_PROBS 3
#define MBSKIP_CONTEXTS 3
......@@ -40,6 +37,10 @@
#define SEGMENT_ABSDATA 1
#define MAX_MV_REF_CANDIDATES 2
#define INTRA_INTER_CONTEXTS 4
#define COMP_INTER_CONTEXTS 5
#define REF_CONTEXTS 5
typedef enum {
PLANE_TYPE_Y_WITH_DC,
PLANE_TYPE_UV,
......@@ -200,7 +201,7 @@ static INLINE int mi_height_log2(BLOCK_SIZE_TYPE sb_type) {
typedef struct {
MB_PREDICTION_MODE mode, uv_mode;
MV_REFERENCE_FRAME ref_frame, second_ref_frame;
MV_REFERENCE_FRAME ref_frame[2];
TX_SIZE txfm_size;
int_mv mv[2]; // for each reference frame used
int_mv ref_mvs[MAX_REF_FRAMES][MAX_MV_REF_CANDIDATES];
......@@ -215,7 +216,6 @@ typedef struct {
// Flags used for prediction status of various bistream signals
unsigned char seg_id_predicted;
unsigned char ref_predicted;
// Indicates if the mb is part of the image (1) vs border (0)
// This can be useful in determining whether the MB provides
......@@ -526,7 +526,7 @@ static TX_TYPE get_tx_type_4x4(const MACROBLOCKD *xd, int ib) {
TX_TYPE tx_type;
MODE_INFO *mi = xd->mode_info_context;
MB_MODE_INFO *const mbmi = &mi->mbmi;
if (xd->lossless || mbmi->ref_frame != INTRA_FRAME)
if (xd->lossless || mbmi->ref_frame[0] != INTRA_FRAME)
return DCT_DCT;
if (mbmi->sb_type < BLOCK_SIZE_SB8X8) {
tx_type = txfm_map(mi->bmi[ib].as_mode.first);
......
......@@ -129,6 +129,26 @@ struct vp9_token vp9_sb_mv_ref_encoding_array[VP9_INTER_MODES];
struct vp9_token vp9_partition_encodings[PARTITION_TYPES];
static const vp9_prob default_intra_inter_p[INTRA_INTER_CONTEXTS] = {
6, 87, 165, 213
};
static const vp9_prob default_comp_inter_p[COMP_INTER_CONTEXTS] = {
25, 66, 106, 142, 183
};
static const vp9_prob default_comp_ref_p[REF_CONTEXTS] = {
36, 93, 136, 205, 236
};
static const vp9_prob default_single_ref_p[REF_CONTEXTS][2] = {
{ 30, 17 },
{ 80, 66 },
{ 142, 129 },
{ 192, 178 },
{ 235, 248 },
};
void vp9_init_mbmode_probs(VP9_COMMON *x) {
vpx_memcpy(x->fc.uv_mode_prob, default_if_uv_probs,
sizeof(default_if_uv_probs));
......@@ -143,9 +163,14 @@ void vp9_init_mbmode_probs(VP9_COMMON *x) {
vpx_memcpy(x->fc.partition_prob, vp9_partition_probs,
sizeof(vp9_partition_probs));
x->ref_pred_probs[0] = DEFAULT_PRED_PROB_0;
x->ref_pred_probs[1] = DEFAULT_PRED_PROB_1;
x->ref_pred_probs[2] = DEFAULT_PRED_PROB_2;
vpx_memcpy(x->fc.intra_inter_prob, default_intra_inter_p,
sizeof(default_intra_inter_p));
vpx_memcpy(x->fc.comp_inter_prob, default_comp_inter_p,
sizeof(default_comp_inter_p));
vpx_memcpy(x->fc.comp_ref_prob, default_comp_ref_p,
sizeof(default_comp_ref_p));
vpx_memcpy(x->fc.single_ref_prob, default_single_ref_p,
sizeof(default_single_ref_p));
}
#if VP9_SWITCHABLE_FILTERS == 3
......@@ -246,6 +271,14 @@ void vp9_adapt_mode_context(VP9_COMMON *pc) {
#define MODE_COUNT_SAT 20
#define MODE_MAX_UPDATE_FACTOR 144
static int update_mode_ct(int pre_prob, int prob,
unsigned int branch_ct[2]) {
int factor, count = branch_ct[0] + branch_ct[1];
count = count > MODE_COUNT_SAT ? MODE_COUNT_SAT : count;
factor = (MODE_MAX_UPDATE_FACTOR * count / MODE_COUNT_SAT);
return weighted_prob(pre_prob, prob, factor);
}
static void update_mode_probs(int n_modes,
const vp9_tree_index *tree, unsigned int *cnt,
vp9_prob *pre_probs, vp9_prob *dst_probs,
......@@ -253,21 +286,22 @@ static void update_mode_probs(int n_modes,
#define MAX_PROBS 32
vp9_prob probs[MAX_PROBS];
unsigned int branch_ct[MAX_PROBS][2];
int t, count, factor;
int t;
assert(n_modes - 1 < MAX_PROBS);
vp9_tree_probs_from_distribution(tree, probs, branch_ct, cnt, tok0_offset);
for (t = 0; t < n_modes - 1; ++t) {
count = branch_ct[t][0] + branch_ct[t][1];
count = count > MODE_COUNT_SAT ? MODE_COUNT_SAT : count;
factor = (MODE_MAX_UPDATE_FACTOR * count / MODE_COUNT_SAT);
dst_probs[t] = weighted_prob(pre_probs[t], probs[t], factor);
}
for (t = 0; t < n_modes - 1; ++t)
dst_probs[t] = update_mode_ct(pre_probs[t], probs[t], branch_ct[t]);
}
static int update_mode_ct2(int pre_prob, unsigned int branch_ct[2]) {
return update_mode_ct(pre_prob, get_binary_prob(branch_ct[0],
branch_ct[1]), branch_ct);
}
// #define MODE_COUNT_TESTING
void vp9_adapt_mode_probs(VP9_COMMON *cm) {
int i;
int i, j;
FRAME_CONTEXT *fc = &cm->fc;
#ifdef MODE_COUNT_TESTING
int t;
......@@ -303,6 +337,20 @@ void vp9_adapt_mode_probs(VP9_COMMON *cm) {
printf("};\n");
#endif
for (i = 0; i < INTRA_INTER_CONTEXTS; i++)
fc->intra_inter_prob[i] = update_mode_ct2(fc->pre_intra_inter_prob[i],
fc->intra_inter_count[i]);
for (i = 0; i < COMP_INTER_CONTEXTS; i++)
fc->comp_inter_prob[i] = update_mode_ct2(fc->pre_comp_inter_prob[i],
fc->comp_inter_count[i]);
for (i = 0; i < REF_CONTEXTS; i++)
fc->comp_ref_prob[i] = update_mode_ct2(fc->pre_comp_ref_prob[i],
fc->comp_ref_count[i]);
for (i = 0; i < REF_CONTEXTS; i++)
for (j = 0; j < 2; j++)
fc->single_ref_prob[i][j] = update_mode_ct2(fc->pre_single_ref_prob[i][j],
fc->single_ref_count[i][j]);
for (i = 0; i < BLOCK_SIZE_GROUPS; i++)
update_mode_probs(VP9_INTRA_MODES, vp9_intra_mode_tree,
fc->y_mode_counts[i], fc->pre_y_mode_prob[i],
......
......@@ -59,7 +59,7 @@ void vp9_append_sub8x8_mvs_for_idx(VP9_COMMON *cm, MACROBLOCKD *xd,
vp9_find_mv_refs_idx(cm, xd, xd->mode_info_context,
xd->prev_mode_info_context,
ref_idx ? mbmi->second_ref_frame : mbmi->ref_frame,
mbmi->ref_frame[ref_idx],
mv_list, cm->ref_frame_sign_bias, block_idx);
dst_list[1].as_int = 0;
......
......@@ -87,7 +87,7 @@ static MB_PREDICTION_MODE left_block_mode(const MODE_INFO *cur_mb, int b) {
/* On L edge, get from MB to left of us */
--cur_mb;
if (cur_mb->mbmi.ref_frame != INTRA_FRAME) {
if (cur_mb->mbmi.ref_frame[0] != INTRA_FRAME) {
return DC_PRED;
} else if (cur_mb->mbmi.sb_type < BLOCK_SIZE_SB8X8) {
return ((cur_mb->bmi + 1 + b)->as_mode.first);
......@@ -105,7 +105,7 @@ static MB_PREDICTION_MODE above_block_mode(const MODE_INFO *cur_mb,
/* On top edge, get from MB above us */
cur_mb -= mi_stride;
if (cur_mb->mbmi.ref_frame != INTRA_FRAME) {
if (cur_mb->mbmi.ref_frame[0] != INTRA_FRAME) {
return DC_PRED;
} else if (cur_mb->mbmi.sb_type < BLOCK_SIZE_SB8X8) {
return ((cur_mb->bmi + 2 + b)->as_mode.first);
......
......@@ -140,11 +140,11 @@ void segment_via_mode_info(VP9_COMMON *oci, int how) {
break;
case SEGMENT_MV:
n = mi[mb_index].mbmi.mv[0].as_int;
if (mi[mb_index].mbmi.ref_frame == INTRA_FRAME)
if (mi[mb_index].mbmi.ref_frame[0] == INTRA_FRAME)
n = -9999999;
break;
case SEGMENT_REFFRAME:
n = mi[mb_index].mbmi.ref_frame;
n = mi[mb_index].mbmi.ref_frame[0];
break;
case SEGMENT_SKIPPED:
n = mi[mb_index].mbmi.mb_skip_coeff;
......
......@@ -177,8 +177,8 @@ static int sb_mb_lf_skip(const MODE_INFO *const mip0,
const MB_MODE_INFO *mbmi0 = &mip0->mbmi;
const MB_MODE_INFO *mbmi1 = &mip1->mbmi;
return mb_lf_skip(mbmi0) && mb_lf_skip(mbmi1) &&
mbmi0->ref_frame != INTRA_FRAME &&
mbmi1->ref_frame != INTRA_FRAME;
mbmi0->ref_frame[0] != INTRA_FRAME &&
mbmi1->ref_frame[0] != INTRA_FRAME;
}
static void lpf_mb(VP9_COMMON *cm, const MODE_INFO *mi,
......@@ -191,7 +191,7 @@ static void lpf_mb(VP9_COMMON *cm, const MODE_INFO *mi,
int mode = mi->mbmi.mode;
int mode_index = lfi_n->mode_lf_lut[mode];
int seg = mi->mbmi.segment_id;
int ref_frame = mi->mbmi.ref_frame;
MV_REFERENCE_FRAME ref_frame = mi->mbmi.ref_frame[0];
int filter_level = lfi_n->lvl[seg][ref_frame][mode_index];
if (filter_level) {
......
......@@ -47,12 +47,12 @@ static void clamp_mv_ref(const MACROBLOCKD *xd, int_mv *mv) {
static int get_matching_candidate(const MODE_INFO *candidate_mi,
MV_REFERENCE_FRAME ref_frame,
int_mv *c_mv, int block_idx) {
if (ref_frame == candidate_mi->mbmi.ref_frame) {
if (ref_frame == candidate_mi->mbmi.ref_frame[0]) {
if (block_idx >= 0 && candidate_mi->mbmi.sb_type < BLOCK_SIZE_SB8X8)
c_mv->as_int = candidate_mi->bmi[block_idx].as_mv[0].as_int;
else
c_mv->as_int = candidate_mi->mbmi.mv[0].as_int;
} else if (ref_frame == candidate_mi->mbmi.second_ref_frame) {
} else if (ref_frame == candidate_mi->mbmi.ref_frame[1]) {
if (block_idx >= 0 && candidate_mi->mbmi.sb_type < BLOCK_SIZE_SB8X8)
c_mv->as_int = candidate_mi->bmi[block_idx].as_mv[1].as_int;
else
......@@ -79,18 +79,18 @@ static void get_non_matching_candidates(const MODE_INFO *candidate_mi,
*c2_ref_frame = INTRA_FRAME;
// If first candidate not valid neither will be.
if (candidate_mi->mbmi.ref_frame > INTRA_FRAME) {
if (candidate_mi->mbmi.ref_frame[0] > INTRA_FRAME) {
// First candidate
if (candidate_mi->mbmi.ref_frame != ref_frame) {
*c_ref_frame = candidate_mi->mbmi.ref_frame;
if (candidate_mi->mbmi.ref_frame[0] != ref_frame) {
*c_ref_frame = candidate_mi->mbmi.ref_frame[0];
c_mv->as_int = candidate_mi->mbmi.mv[0].as_int;
}
// Second candidate
if ((candidate_mi->mbmi.second_ref_frame > INTRA_FRAME) &&
(candidate_mi->mbmi.second_ref_frame != ref_frame) &&
if ((candidate_mi->mbmi.ref_frame[1] > INTRA_FRAME) &&
(candidate_mi->mbmi.ref_frame[1] != ref_frame) &&
(candidate_mi->mbmi.mv[1].as_int != candidate_mi->mbmi.mv[0].as_int)) {
*c2_ref_frame = candidate_mi->mbmi.second_ref_frame;
*c2_ref_frame = candidate_mi->mbmi.ref_frame[1];
c2_mv->as_int = candidate_mi->mbmi.mv[1].as_int;
}
}
......@@ -226,7 +226,7 @@ void vp9_find_mv_refs_idx(VP9_COMMON *cm, MACROBLOCKD *xd, MODE_INFO *here,
&refmv_count, c_refmv, 16);
}
split_count += (candidate_mi->mbmi.sb_type < BLOCK_SIZE_SB8X8 &&
candidate_mi->mbmi.ref_frame != INTRA_FRAME);
candidate_mi->mbmi.ref_frame[0] != INTRA_FRAME);
// Count number of neihgbours coded intra and zeromv
intra_count += (candidate_mi->mbmi.mode < NEARESTMV);
......
......@@ -40,8 +40,6 @@
#define NUM_FRAME_CONTEXTS_LG2 2
#define NUM_FRAME_CONTEXTS (1 << NUM_FRAME_CONTEXTS_LG2)
#define COMP_PRED_CONTEXTS 2
#define MAX_LAG_BUFFERS 25
typedef struct frame_contexts {
......@@ -78,6 +76,19 @@ typedef struct frame_contexts {
vp9_prob inter_mode_probs[INTER_MODE_CONTEXTS][VP9_INTER_MODES - 1];
vp9_prob pre_inter_mode_probs[INTER_MODE_CONTEXTS][VP9_INTER_MODES - 1];
unsigned int inter_mode_counts[INTER_MODE_CONTEXTS][VP9_INTER_MODES - 1][2];
vp9_prob intra_inter_prob[INTRA_INTER_CONTEXTS];
vp9_prob comp_inter_prob[COMP_INTER_CONTEXTS];
vp9_prob single_ref_prob[REF_CONTEXTS][2];
vp9_prob comp_ref_prob[REF_CONTEXTS];
vp9_prob pre_intra_inter_prob[INTRA_INTER_CONTEXTS];
vp9_prob pre_comp_inter_prob[COMP_INTER_CONTEXTS];
vp9_prob pre_single_ref_prob[REF_CONTEXTS][2];
vp9_prob pre_comp_ref_prob[REF_CONTEXTS];
unsigned int intra_inter_count[INTRA_INTER_CONTEXTS][2];
unsigned int comp_inter_count[COMP_INTER_CONTEXTS][2];
unsigned int single_ref_count[REF_CONTEXTS][2][2];
unsigned int comp_ref_count[REF_CONTEXTS][2];
} FRAME_CONTEXT;
typedef enum {
......@@ -162,7 +173,6 @@ typedef struct VP9Common {
/* profile settings */
int experimental;
TXFM_MODE txfm_mode;
COMPPREDMODE_TYPE comp_pred_mode;
int no_lpf;
int use_bilinear_mc_filter;
......@@ -219,20 +229,15 @@ typedef struct VP9Common {
[VP9_INTRA_MODES - 1];
vp9_prob kf_uv_mode_prob[VP9_INTRA_MODES] [VP9_INTRA_MODES - 1];
vp9_prob prob_intra_coded;
vp9_prob prob_last_coded;
vp9_prob prob_gf_coded;
// Context probabilities when using predictive coding of segment id
vp9_prob segment_pred_probs[PREDICTION_PROBS];
unsigned char temporal_update;
// Context probabilities for reference frame prediction
unsigned char ref_scores[MAX_REF_FRAMES];
vp9_prob ref_pred_probs[PREDICTION_PROBS];
vp9_prob mod_refprobs[MAX_REF_FRAMES][PREDICTION_PROBS];
vp9_prob prob_comppred[COMP_PRED_CONTEXTS];
int allow_comp_inter_inter;
MV_REFERENCE_FRAME comp_fixed_ref;
MV_REFERENCE_FRAME comp_var_ref[2];
COMPPREDMODE_TYPE comp_pred_mode;
// FIXME contextualize
vp9_prob prob_tx[TX_SIZE_MAX_SB - 1];
......
This diff is collapsed.
......@@ -17,10 +17,13 @@
// Predicted items
typedef enum {
PRED_SEG_ID = 0, // Segment identifier
PRED_REF = 1,
PRED_COMP = 2,
PRED_MBSKIP = 3,
PRED_SWITCHABLE_INTERP = 4
PRED_MBSKIP = 1,
PRED_SWITCHABLE_INTERP = 2,
PRED_INTRA_INTER = 3,
PRED_COMP_INTER_INTER = 4,
PRED_SINGLE_REF_P1 = 5,
PRED_SINGLE_REF_P2 = 6,
PRED_COMP_REF_P = 7,
} PRED_ID;
unsigned char vp9_get_pred_context(const VP9_COMMON *const cm,
......@@ -46,9 +49,4 @@ void vp9_set_pred_flag(MACROBLOCKD *const xd,
int vp9_get_pred_mi_segid(VP9_COMMON *cm, BLOCK_SIZE_TYPE sb_type,
int mi_row, int mi_col);
MV_REFERENCE_FRAME vp9_get_pred_ref(const VP9_COMMON *const cm,
const MACROBLOCKD *const xd);
void vp9_compute_mod_refprobs(VP9_COMMON *const cm);
#endif // VP9_COMMON_VP9_PRED_COMMON_H_
......@@ -171,8 +171,8 @@ void vp9_setup_interp_filters(MACROBLOCKD *xd,
MB_MODE_INFO *mbmi = &xd->mode_info_context->mbmi;
set_scale_factors(xd,
mbmi->ref_frame - 1,
mbmi->second_ref_frame - 1,
mbmi->ref_frame[0] - 1,
mbmi->ref_frame[1] - 1,
cm->active_ref_scale);
}
......@@ -386,7 +386,7 @@ static void build_inter_predictors(int plane, int block,
const int bhl = b_height_log2(bsize) - xd->plane[plane].subsampling_y;
const int bh = 4 << bhl, bw = 4 << bwl;
const int x = 4 * (block & ((1 << bwl) - 1)), y = 4 * (block >> bwl);
const int use_second_ref = xd->mode_info_context->mbmi.second_ref_frame > 0;
const int use_second_ref = xd->mode_info_context->mbmi.ref_frame[1] > 0;
int which_mv;
assert(x < bw);
......
This diff is collapsed.
......@@ -281,7 +281,7 @@ static void decode_atom(VP9D_COMP *pbi, MACROBLOCKD *xd,
vp9_reader *r, BLOCK_SIZE_TYPE bsize) {
MB_MODE_INFO *const mbmi = &xd->mode_info_context->mbmi;
assert(mbmi->ref_frame != INTRA_FRAME);
assert(mbmi->ref_frame[0] != INTRA_FRAME);
if (pbi->common.frame_type != KEY_FRAME)
vp9_setup_interp_filters(xd, mbmi->interp_filter, &pbi->common);
......@@ -334,7 +334,7 @@ static void decode_sb(VP9D_COMP *pbi, MACROBLOCKD *xd, int mi_row, int mi_col,
const int mis = pc->mode_info_stride;
assert(mbmi->sb_type == bsize);
assert(mbmi->ref_frame != INTRA_FRAME);
assert(mbmi->ref_frame[0] != INTRA_FRAME);
if (pbi->common.frame_type != KEY_FRAME)
vp9_setup_interp_filters(xd, mbmi->interp_filter, pc);
......@@ -401,22 +401,22 @@ static void set_refs(VP9D_COMP *pbi, int mi_row, int mi_col) {
MACROBLOCKD *const xd = &pbi->mb;
MB_MODE_INFO *const mbmi = &xd->mode_info_context->mbmi;
if (mbmi->ref_frame > INTRA_FRAME) {
if (mbmi->ref_frame[0] > INTRA_FRAME) {
// Select the appropriate reference frame for this MB
const int fb_idx = cm->active_ref_idx[mbmi->ref_frame - 1];
const int fb_idx = cm->active_ref_idx[mbmi->ref_frame[0] - 1];
const YV12_BUFFER_CONFIG *cfg = &cm->yv12_fb[fb_idx];
xd->scale_factor[0] = cm->active_ref_scale[mbmi->ref_frame - 1];
xd->scale_factor_uv[0] = cm->active_ref_scale[mbmi->ref_frame - 1];
xd->scale_factor[0] = cm->active_ref_scale[mbmi->ref_frame[0] - 1];
xd->scale_factor_uv[0] = cm->active_ref_scale[mbmi->ref_frame[0] - 1];
setup_pre_planes(xd, cfg, NULL, mi_row, mi_col,
xd->scale_factor, xd->scale_factor_uv);
xd->corrupted |= cfg->corrupted;
if (mbmi->second_ref_frame > INTRA_FRAME) {
if (mbmi->ref_frame[1] > INTRA_FRAME) {
// Select the appropriate reference frame for this MB
const int second_fb_idx = cm->active_ref_idx[mbmi->second_ref_frame - 1];
const int second_fb_idx = cm->active_ref_idx[mbmi->ref_frame[1] - 1];
const YV12_BUFFER_CONFIG *second_cfg = &cm->yv12_fb[second_fb_idx];
xd->scale_factor[1] = cm->active_ref_scale[mbmi->second_ref_frame - 1];
xd->scale_factor_uv[1] = cm->active_ref_scale[mbmi->second_ref_frame - 1];
xd->scale_factor[1] = cm->active_ref_scale[mbmi->ref_frame[1] - 1];
xd->scale_factor_uv[1] = cm->active_ref_scale[mbmi->ref_frame[1] - 1];
setup_pre_planes(xd, NULL, second_cfg, mi_row, mi_col,
xd->scale_factor, xd->scale_factor_uv);
xd->corrupted |= second_cfg->corrupted;
......@@ -435,7 +435,7 @@ static void decode_modes_b(VP9D_COMP *pbi, int mi_row, int mi_col,
vp9_decode_mb_mode_mv(pbi, xd, mi_row, mi_col, r);
set_refs(pbi, mi_row, mi_col);
if (xd->mode_info_context->mbmi.ref_frame == INTRA_FRAME)
if (xd->mode_info_context->mbmi.ref_frame[0] == INTRA_FRAME)
decode_sb_intra(pbi, xd, mi_row, mi_col, r, (bsize < BLOCK_SIZE_SB8X8) ?
BLOCK_SIZE_SB8X8 : bsize);
else if (bsize < BLOCK_SIZE_SB8X8)
......@@ -772,6 +772,10 @@ static void update_frame_context(FRAME_CONTEXT *fc) {
vp9_copy(fc->pre_y_mode_prob, fc->y_mode_prob);
vp9_copy(fc->pre_uv_mode_prob, fc->uv_mode_prob);
vp9_copy(fc->pre_partition_prob, fc->partition_prob[1]);
vp9_copy(fc->pre_intra_inter_prob, fc->intra_inter_prob);
vp9_copy(fc->pre_comp_inter_prob, fc->comp_inter_prob);
vp9_copy(fc->pre_single_ref_prob, fc->single_ref_prob);
vp9_copy(fc->pre_comp_ref_prob, fc->comp_ref_prob);
fc->pre_nmvc = fc->nmvc;
vp9_copy(fc->pre_switchable_interp_prob, fc->switchable_interp_prob);
vp9_copy(fc->pre_inter_mode_probs, fc->inter_mode_probs);
......@@ -784,6 +788,10 @@ static void update_frame_context(FRAME_CONTEXT *fc) {
vp9_zero(fc->inter_mode_counts);
vp9_zero(fc->partition_counts);
vp9_zero(fc->switchable_interp_count);
vp9_zero(fc->intra_inter_count);
vp9_zero(fc->comp_inter_count);
vp9_zero(fc->single_ref_count);
vp9_zero(fc->comp_ref_count);
}
static void decode_tile(VP9D_COMP *pbi, vp9_reader *r) {
......@@ -942,10 +950,6 @@ size_t read_uncompressed_header(VP9D_COMP *pbi,
for (i = 0; i < ALLOWED_REFS_PER_FRAME; ++i)
cm->active_ref_idx[i] = cm->new_fb_idx;
cm->ref_pred_probs[0] = DEFAULT_PRED_PROB_0;
cm->ref_pred_probs[1] = DEFAULT_PRED_PROB_1;
cm->ref_pred_probs[2] = DEFAULT_PRED_PROB_2;
} else {
if (cm->error_resilient_mode)
vp9_setup_past_independence(cm, xd);
......@@ -958,12 +962,31 @@ size_t read_uncompressed_header(VP9D_COMP *pbi,
vp9_setup_scale_factors(cm, i);
}
for (i = 0; i < ALLOWED_REFS_PER_FRAME; ++i)
// Read the sign bias for each reference frame buffer.
cm->allow_comp_inter_inter = 0;
for (i = 0; i < ALLOWED_REFS_PER_FRAME; ++i) {
cm->ref_frame_sign_bias[i + 1] = vp9_rb_read_bit(rb);
for (i = 0; i < PREDICTION_PROBS; ++i)
if (vp9_rb_read_bit(rb))
cm->ref_pred_probs[i] = vp9_rb_read_literal(rb, 8);
cm->allow_comp_inter_inter |= i > 0 &&
cm->ref_frame_sign_bias[i + 1] != cm->ref_frame_sign_bias[1];
}
if (cm->allow_comp_inter_inter) {
// which one is always-on in comp inter-inter?
if (cm->ref_frame_sign_bias[LAST_FRAME] ==
cm->ref_frame_sign_bias[GOLDEN_FRAME]) {
cm->comp_fixed_ref = ALTREF_FRAME;
cm->comp_var_ref[0] = LAST_FRAME;
cm->comp_var_ref[1] = GOLDEN_FRAME;
} else if (cm->ref_frame_sign_bias[LAST_FRAME] ==
cm->ref_frame_sign_bias[ALTREF_FRAME]) {
cm->comp_fixed_ref = GOLDEN_FRAME;
cm->comp_var_ref[0] = LAST_FRAME;
cm->comp_var_ref[1] = ALTREF_FRAME;
} else {
cm->comp_fixed_ref = LAST_FRAME;
cm->comp_var_ref[0] = GOLDEN_FRAME;
cm->comp_var_ref[1] = ALTREF_FRAME;
}
}
xd->allow_high_precision_mv = vp9_rb_read_bit(rb);
cm->mcomp_filter_type = read_interp_filter_type(rb);
......
......@@ -111,7 +111,7 @@ static int decode_coefs(VP9D_COMP *dx, const MACROBLOCKD *xd,
vp9_prob *prob;
vp9_coeff_count_model *coef_counts;
const int ref = xd->mode_info_context->mbmi.ref_frame != INTRA_FRAME;
const int ref = xd->mode_info_context->mbmi.ref_frame[0] != INTRA_FRAME;
TX_TYPE tx_type = DCT_DCT;
const int *scan, *nb;
uint8_t token_cache[1024];
......
This diff is collapsed.
This diff is collapsed.
......@@ -20,7 +20,7 @@ int vp9_encode_intra(VP9_COMP *cpi, MACROBLOCK *x, int use_16x16_pred) {
MB_MODE_INFO * mbmi = &x->e_mbd.mode_info_context->mbmi;
(void) cpi;
mbmi->mode = DC_PRED;
mbmi->ref_frame = INTRA_FRAME;
mbmi->ref_frame[0] = INTRA_FRAME;
if (use_16x16_pred) {
mbmi->txfm_size = TX_16X16;
vp9_encode_intra_block_y(&cpi->common, x, BLOCK_SIZE_MB16X16);
......
......@@ -118,7 +118,7 @@ static void optimize_b(VP9_COMMON *const cm, MACROBLOCK *mb,
int plane, int block, BLOCK_SIZE_TYPE bsize,
ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l,
TX_SIZE tx_size) {
const int ref = mb->e_mbd.mode_info_context->mbmi.ref_frame != INTRA_FRAME;
const int ref = mb->e_mbd.mode_info_context->mbmi.ref_frame[0] != INTRA_FRAME;
MACROBLOCKD *const xd = &mb->e_mbd;
vp9_token_state tokens[1025][2];
unsigned best_index[1025][2];
......@@ -179,7 +179,7 @@ static void optimize_b(VP9_COMMON *const cm, MACROBLOCK *mb,
/* Now set up a Viterbi trellis to evaluate alternative roundings. */
rdmult = mb->rdmult * err_mult;
if (mb->e_mbd.mode_info_context->mbmi.ref_frame == INTRA_FRAME)
if (mb->e_mbd.mode_info_context->mbmi.ref_frame[0] == INTRA_FRAME)
rdmult = (rdmult * 9) >> 4;
rddiv = mb->rddiv;
memset(best_index, 0, sizeof(best_index));
......@@ -622,7 +622,7 @@ static void encode_block_intra(int plane, int block, BLOCK_SIZE_TYPE bsize,
mode = plane == 0? mbmi->mode: mbmi->uv_mode;
if (plane == 0 &&
mbmi->sb_type < BLOCK_SIZE_SB8X8 &&
mbmi->ref_frame == INTRA_FRAME)
mbmi->ref_frame[0] == INTRA_FRAME)
b_mode = xd->mode_info_context->bmi[ib].as_mode.first;
else
b_mode = mode;
......
......@@ -584,7 +584,7 @@ void vp9_update_nmv_count(VP9_COMP *cpi, MACROBLOCK *x,
mv.col = (pi->bmi[i].mv.as_mv.col - best_ref_mv->as_mv.col);
vp9_increment_nmv(&mv, &best_ref_mv->as_mv, &cpi->NMVcount,
x->e_mbd.allow_high_precision_mv);
if (x->e_mbd.mode_info_context->mbmi.second_ref_frame > 0) {
if (x->e_mbd.mode_info_context->mbmi.ref_frame[1] > INTRA_FRAME) {
mv.row = pi->bmi[i].second_mv.as_mv.row -
second_best_ref_mv->as_mv.row;
mv.col = pi->bmi[i].second_mv.as_mv.col -
......@@ -600,7 +600,7 @@ void vp9_update_nmv_count(VP9_COMP *cpi, MACROBLOCK *x,
mv.col = (mbmi->mv[0].as_mv.col - best_ref_mv->as_mv.col);
vp9_increment_nmv(&mv, &best_ref_mv->as_mv, &cpi->NMVcount,
x->e_mbd.allow_high_precision_mv);
if (mbmi->second_ref_frame > 0) {
if (mbmi->ref_frame[1] > INTRA_FRAME) {
mv.row = (mbmi->mv[1].as_mv.row - second_best_ref_mv->as_mv.row);
mv.col = (mbmi->mv[1].as_mv.col - second_best_ref_mv->as_mv.col);
vp9_increment_nmv(&mv, &second_best_ref_mv->as_mv, &cpi->NMVcount,
......
......@@ -523,7 +523,7 @@ void vp9_first_pass(VP9_COMP *cpi) {
xd->left_available = (mb_col != 0);
xd->mode_info_context->mbmi.sb_type = BLOCK_SIZE_MB16X16;
xd->mode_info_context->mbmi.ref_frame = INTRA_FRAME;
xd->mode_info_context->mbmi.ref_frame[0] = INTRA_FRAME;
// do intra 16x16 prediction
this_error = vp9_encode_intra(cpi, x, use_dc_pred);
......@@ -620,7 +620,8 @@ void vp9_first_pass(VP9_COMP *cpi) {
this_error = motion_error;
vp9_set_mbmode_and_mvs(x, NEWMV, &mv);
xd->mode_info_context->mbmi.txfm_size = TX_4X4;
xd->mode_info_context->mbmi.ref_frame = LAST_FRAME;
xd->mode_info_context->mbmi.ref_frame[0] = LAST_FRAME;
xd->mode_info_context->mbmi.ref_frame[1] = NONE;
vp9_build_inter_predictors_sby(xd, mb_row << 1,
mb_col << 1,
BLOCK_SIZE_MB16X16);
......
......@@ -623,25 +623,20 @@ static void set_rd_speed_thresholds(VP9_COMP *cpi, int mode, int speed) {
sf->thresh_mult[THR_SPLITG ] += speed_multiplier * 2500;
sf->thresh_mult[THR_SPLITA ] += speed_multiplier * 2500;
sf->thresh_mult[THR_COMP_ZEROLG ] += speed_multiplier * 1500;
sf->thresh_mult[THR_COMP_ZEROLA ] += speed_multiplier * 1500;
sf->thresh_mult[THR_COMP_ZEROGA ] += speed_multiplier * 1500;
sf->thresh_mult[THR_COMP_NEARESTLG] += speed_multiplier * 1500;
sf->thresh_mult[THR_COMP_NEARESTLA] += speed_multiplier * 1500;
sf->thresh_mult[THR_COMP_NEARESTGA] += speed_multiplier * 1500;
sf->thresh_mult[THR_COMP_NEARLG ] += speed_multiplier * 1500;
sf->thresh_mult[THR_COMP_NEARLA ] += speed_multiplier * 1500;
sf->thresh_mult[THR_COMP_NEARGA ] += speed_multiplier * 1500;
sf->thresh_mult[THR_COMP_NEWLG ] += speed_multiplier * 2000;
sf->thresh_mult[THR_COMP_NEWLA ] += speed_multiplier * 2000;