Commit 043c227b authored by Zoe Liu's avatar Zoe Liu

Add decoder support to ALTREF2

Change-Id: I11abc5448622265183abd0a58268c190b5891576
parent ea10ad45
...@@ -114,8 +114,13 @@ static void setup_compound_reference_mode(AV1_COMMON *cm) { ...@@ -114,8 +114,13 @@ static void setup_compound_reference_mode(AV1_COMMON *cm) {
cm->comp_fwd_ref[3] = GOLDEN_FRAME; cm->comp_fwd_ref[3] = GOLDEN_FRAME;
cm->comp_bwd_ref[0] = BWDREF_FRAME; cm->comp_bwd_ref[0] = BWDREF_FRAME;
#if CONFIG_ALTREF2
cm->comp_bwd_ref[1] = ALTREF2_FRAME;
cm->comp_bwd_ref[2] = ALTREF_FRAME;
#else // !CONFIG_ALTREF2
cm->comp_bwd_ref[1] = ALTREF_FRAME; cm->comp_bwd_ref[1] = ALTREF_FRAME;
#else #endif // CONFIG_ALTREF2
#else // !CONFIG_EXT_REFS
if (cm->ref_frame_sign_bias[LAST_FRAME] == if (cm->ref_frame_sign_bias[LAST_FRAME] ==
cm->ref_frame_sign_bias[GOLDEN_FRAME]) { cm->ref_frame_sign_bias[GOLDEN_FRAME]) {
cm->comp_fixed_ref = ALTREF_FRAME; cm->comp_fixed_ref = ALTREF_FRAME;
......
...@@ -1534,8 +1534,13 @@ static void read_ref_frames(AV1_COMMON *const cm, MACROBLOCKD *const xd, ...@@ -1534,8 +1534,13 @@ static void read_ref_frames(AV1_COMMON *const cm, MACROBLOCKD *const xd,
const int ctx_bwd = av1_get_pred_context_comp_bwdref_p(cm, xd); const int ctx_bwd = av1_get_pred_context_comp_bwdref_p(cm, xd);
#if CONFIG_VAR_REFS #if CONFIG_VAR_REFS
int bit_bwd; int bit_bwd;
// Test need to explicitly code (BWD) vs (ALT) branch node in tree // Test need to explicitly code (BWD/ALT2) vs (ALT) branch node in tree
if (BWD_AND_ALT(cm)) #if CONFIG_ALTREF2
const int bit_bwd_uncertain = BWD_OR_ALT2(cm) && ALTREF_IS_VALID(cm);
#else // !CONFIG_ALTREF2
const int bit_bwd_uncertain = BWD_AND_ALT(cm);
#endif // CONFIG_ALTREF2
if (bit_bwd_uncertain)
bit_bwd = READ_REF_BIT(comp_bwdref_p); bit_bwd = READ_REF_BIT(comp_bwdref_p);
else else
bit_bwd = ALTREF_IS_VALID(cm); bit_bwd = ALTREF_IS_VALID(cm);
...@@ -1543,7 +1548,26 @@ static void read_ref_frames(AV1_COMMON *const cm, MACROBLOCKD *const xd, ...@@ -1543,7 +1548,26 @@ static void read_ref_frames(AV1_COMMON *const cm, MACROBLOCKD *const xd,
const int bit_bwd = READ_REF_BIT(comp_bwdref_p); const int bit_bwd = READ_REF_BIT(comp_bwdref_p);
#endif // CONFIG_VAR_REFS #endif // CONFIG_VAR_REFS
if (counts) ++counts->comp_bwdref[ctx_bwd][0][bit_bwd]; if (counts) ++counts->comp_bwdref[ctx_bwd][0][bit_bwd];
#if CONFIG_ALTREF2
if (!bit_bwd) {
const int ctx1_bwd = av1_get_pred_context_comp_bwdref_p1(cm, xd);
#if CONFIG_VAR_REFS
int bit1_bwd;
if (BWD_AND_ALT2(cm))
bit1_bwd = READ_REF_BIT(comp_bwdref_p1);
else
bit1_bwd = ALTREF2_IS_VALID(cm);
#else // !CONFIG_VAR_REFS
const int bit1_bwd = READ_REF_BIT(comp_bwdref_p1);
#endif // CONFIG_VAR_REFS
if (counts) ++counts->comp_bwdref[ctx1_bwd][1][bit1_bwd];
ref_frame[idx] = cm->comp_bwd_ref[bit1_bwd];
} else {
ref_frame[idx] = cm->comp_bwd_ref[2];
}
#else // !CONFIG_ALTREF2
ref_frame[idx] = cm->comp_bwd_ref[bit_bwd]; ref_frame[idx] = cm->comp_bwd_ref[bit_bwd];
#endif // CONFIG_ALTREF2
#else // !CONFIG_EXT_REFS #else // !CONFIG_EXT_REFS
ref_frame[!idx] = cm->comp_var_ref[bit]; ref_frame[!idx] = cm->comp_var_ref[bit];
ref_frame[idx] = cm->comp_fixed_ref; ref_frame[idx] = cm->comp_fixed_ref;
...@@ -1568,8 +1592,13 @@ static void read_ref_frames(AV1_COMMON *const cm, MACROBLOCKD *const xd, ...@@ -1568,8 +1592,13 @@ static void read_ref_frames(AV1_COMMON *const cm, MACROBLOCKD *const xd,
const int ctx1 = av1_get_pred_context_single_ref_p2(xd); const int ctx1 = av1_get_pred_context_single_ref_p2(xd);
#if CONFIG_VAR_REFS #if CONFIG_VAR_REFS
int bit1; int bit1;
// Test need to explicitly code (BWD) vs (ALT) branch node in tree // Test need to explicitly code (BWD/ALT2) vs (ALT) branch node in tree
if (BWD_AND_ALT(cm)) #if CONFIG_ALTREF2
const int bit1_uncertain = BWD_OR_ALT2(cm) && ALTREF_IS_VALID(cm);
#else // !CONFIG_ALTREF2
const int bit1_uncertain = BWD_AND_ALT(cm);
#endif // CONFIG_ALTREF2
if (bit1_uncertain)
bit1 = READ_REF_BIT(single_ref_p2); bit1 = READ_REF_BIT(single_ref_p2);
else else
bit1 = ALTREF_IS_VALID(cm); bit1 = ALTREF_IS_VALID(cm);
...@@ -1577,7 +1606,26 @@ static void read_ref_frames(AV1_COMMON *const cm, MACROBLOCKD *const xd, ...@@ -1577,7 +1606,26 @@ static void read_ref_frames(AV1_COMMON *const cm, MACROBLOCKD *const xd,
const int bit1 = READ_REF_BIT(single_ref_p2); const int bit1 = READ_REF_BIT(single_ref_p2);
#endif // CONFIG_VAR_REFS #endif // CONFIG_VAR_REFS
if (counts) ++counts->single_ref[ctx1][1][bit1]; if (counts) ++counts->single_ref[ctx1][1][bit1];
#if CONFIG_ALTREF2
if (!bit1) {
const int ctx5 = av1_get_pred_context_single_ref_p6(xd);
#if CONFIG_VAR_REFS
int bit5;
if (BWD_AND_ALT2(cm))
bit5 = READ_REF_BIT(single_ref_p6);
else
bit5 = ALTREF2_IS_VALID(cm);
#else // !CONFIG_VAR_REFS
const int bit5 = READ_REF_BIT(single_ref_p6);
#endif // CONFIG_VAR_REFS
if (counts) ++counts->single_ref[ctx5][5][bit5];
ref_frame[0] = bit5 ? ALTREF2_FRAME : BWDREF_FRAME;
} else {
ref_frame[0] = ALTREF_FRAME;
}
#else // !CONFIG_ALTREF2
ref_frame[0] = bit1 ? ALTREF_FRAME : BWDREF_FRAME; ref_frame[0] = bit1 ? ALTREF_FRAME : BWDREF_FRAME;
#endif // CONFIG_ALTREF2
} else { } else {
const int ctx2 = av1_get_pred_context_single_ref_p3(xd); const int ctx2 = av1_get_pred_context_single_ref_p3(xd);
#if CONFIG_VAR_REFS #if CONFIG_VAR_REFS
......
...@@ -232,7 +232,12 @@ aom_codec_err_t av1_set_reference_dec(AV1_COMMON *cm, ...@@ -232,7 +232,12 @@ aom_codec_err_t av1_set_reference_dec(AV1_COMMON *cm,
// cpi->lst3_fb_idx = 2; // cpi->lst3_fb_idx = 2;
// cpi->gld_fb_idx = 3; // cpi->gld_fb_idx = 3;
// cpi->bwd_fb_idx = 4; // cpi->bwd_fb_idx = 4;
// #if CONFIG_ALTREF2
// cpi->alt2_fb_idx = 5;
// cpi->alt_fb_idx = 6;
// #else // !CONFIG_ALTREF2
// cpi->alt_fb_idx = 5; // cpi->alt_fb_idx = 5;
// #endif // CONFIG_ALTREF2
// #else // CONFIG_EXT_REFS // #else // CONFIG_EXT_REFS
// cpi->gld_fb_idx = 1; // cpi->gld_fb_idx = 1;
// cpi->alt_fb_idx = 2; // cpi->alt_fb_idx = 2;
...@@ -251,9 +256,16 @@ aom_codec_err_t av1_set_reference_dec(AV1_COMMON *cm, ...@@ -251,9 +256,16 @@ aom_codec_err_t av1_set_reference_dec(AV1_COMMON *cm,
idx = cm->ref_frame_map[3]; idx = cm->ref_frame_map[3];
} else if (ref_frame_flag == AOM_BWD_FLAG) { } else if (ref_frame_flag == AOM_BWD_FLAG) {
idx = cm->ref_frame_map[4]; idx = cm->ref_frame_map[4];
#if CONFIG_ALTREF2
} else if (ref_frame_flag == AOM_ALT2_FLAG) {
idx = cm->ref_frame_map[5];
} else if (ref_frame_flag == AOM_ALT_FLAG) {
idx = cm->ref_frame_map[6];
#else // !CONFIG_ALTREF2
} else if (ref_frame_flag == AOM_ALT_FLAG) { } else if (ref_frame_flag == AOM_ALT_FLAG) {
idx = cm->ref_frame_map[5]; idx = cm->ref_frame_map[5];
#else #endif // CONFIG_ALTREF2
#else // !CONFIG_EXT_REFS
} else if (ref_frame_flag == AOM_GOLD_FLAG) { } else if (ref_frame_flag == AOM_GOLD_FLAG) {
idx = cm->ref_frame_map[1]; idx = cm->ref_frame_map[1];
} else if (ref_frame_flag == AOM_ALT_FLAG) { } else if (ref_frame_flag == AOM_ALT_FLAG) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment