Commit 3ac2093f authored by Zoe Liu's avatar Zoe Liu Committed by Yaowu Xu

Enable altref2 by default and merge it into ext-refs

Change-Id: Ie67266538db41c6aa7d79a5c270c26c021583c48
parent 492c7957
......@@ -51,8 +51,7 @@ struct loopfilter {
uint8_t mode_ref_delta_update;
// 0 = Intra, Last, Last2+Last3(CONFIG_EXT_REFS),
// GF, BRF(CONFIG_EXT_REFS),
// ARF2(CONFIG_EXT_REFS+CONFIG_ALTREF2), ARF
// GF, BRF(CONFIG_EXT_REFS), ARF2(CONFIG_EXT_REFS), ARF
int8_t ref_deltas[TOTAL_REFS_PER_FRAME];
int8_t last_ref_deltas[TOTAL_REFS_PER_FRAME];
......
......@@ -1413,20 +1413,12 @@ static const aom_prob default_comp_ref_p[REF_CONTEXTS][FWD_REFS - 1] = {
};
static const aom_prob default_comp_bwdref_p[REF_CONTEXTS][BWD_REFS - 1] = {
#if CONFIG_ALTREF2
// TODO(zoeliu): ALTREF2 to work with NEW_MULTISYMBOL.
{ 50, 50 },
{ 130, 130 },
{ 210, 210 },
{ 128, 128 },
{ 128, 128 }
#else // !CONFIG_ALTREF2
#if !CONFIG_EXT_COMP_REFS
{ 16 }, { 74 }, { 142 }, { 170 }, { 247 }
#else // CONFIG_EXT_COMP_REFS
{ 7 }, { 56 }, { 29 }, { 230 }, { 220 }
#endif // CONFIG_EXT_COMP_REFS
#endif // CONFIG_ALTREF2
};
#if CONFIG_NEW_MULTISYMBOL
......@@ -1469,19 +1461,16 @@ static const aom_cdf_prob
static const aom_cdf_prob
default_comp_bwdref_cdf[REF_CONTEXTS][BWD_REFS - 1][CDF_SIZE(2)] = {
#if !CONFIG_EXT_COMP_REFS
{ { AOM_ICDF(16 * 128), AOM_ICDF(32768), 0 } },
{ { AOM_ICDF(74 * 128), AOM_ICDF(32768), 0 } },
{ { AOM_ICDF(142 * 128), AOM_ICDF(32768), 0 } },
{ { AOM_ICDF(170 * 128), AOM_ICDF(32768), 0 } },
{ { AOM_ICDF(247 * 128), AOM_ICDF(32768), 0 } }
#else // CONFIG_EXT_COMP_REFS
{ { AOM_ICDF(7 * 128), AOM_ICDF(32768), 0 } },
{ { AOM_ICDF(56 * 128), AOM_ICDF(32768), 0 } },
{ { AOM_ICDF(29 * 128), AOM_ICDF(32768), 0 } },
{ { AOM_ICDF(230 * 128), AOM_ICDF(32768), 0 } },
{ { AOM_ICDF(220 * 128), AOM_ICDF(32768), 0 } }
#endif // !CONFIG_EXT_COMP_REFS
{ { AOM_ICDF(50 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(50 * 128), AOM_ICDF(32768), 0 } },
{ { AOM_ICDF(130 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(130 * 128), AOM_ICDF(32768), 0 } },
{ { AOM_ICDF(210 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(210 * 128), AOM_ICDF(32768), 0 } },
{ { AOM_ICDF(128 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 128), AOM_ICDF(32768), 0 } },
{ { AOM_ICDF(128 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 128), AOM_ICDF(32768), 0 } }
};
#endif // CONFIG_NEW_MULTISYMBOL
......@@ -1504,28 +1493,12 @@ static const aom_cdf_prob
static const aom_prob default_single_ref_p[REF_CONTEXTS][SINGLE_REFS - 1] = {
#if CONFIG_EXT_REFS
#if CONFIG_ALTREF2
// TODO(zoeliu): ALTREF2 to work with NEW_MULTISYMBOL.
{ 33, 50, 16, 16, 16, 50 },
{ 77, 130, 74, 74, 74, 130 },
{ 142, 210, 142, 142, 142, 210 },
{ 172, 128, 170, 170, 170, 128 },
{ 238, 128, 247, 247, 247, 128 }
#else // !CONFIG_ALTREF2
#if !CONFIG_EXT_COMP_REFS
{ 33, 16, 16, 16, 16 },
{ 77, 74, 74, 74, 74 },
{ 142, 142, 142, 142, 142 },
{ 172, 170, 170, 170, 170 },
{ 238, 247, 247, 247, 247 }
#else // CONFIG_EXT_COMP_REFS
{ 36, 2, 28, 58, 9 },
{ 64, 22, 60, 122, 40 },
{ 153, 69, 126, 179, 71 },
{ 128, 174, 189, 216, 101 },
{ 233, 252, 228, 246, 200 }
#endif // !CONFIG_EXT_COMP_REFS
#endif // CONFIG_ALTREF2
#else // !CONFIG_EXT_REFS
{ 31, 25 }, { 72, 80 }, { 147, 148 }, { 197, 191 }, { 235, 247 },
#endif // CONFIG_EXT_REFS
......@@ -1535,59 +1508,36 @@ static const aom_prob default_single_ref_p[REF_CONTEXTS][SINGLE_REFS - 1] = {
static const aom_cdf_prob
default_single_ref_cdf[REF_CONTEXTS][SINGLE_REFS - 1][CDF_SIZE(2)] = {
#if CONFIG_EXT_REFS
#if !CONFIG_EXT_COMP_REFS
{ { AOM_ICDF(33 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(50 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(16 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(16 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(16 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(16 * 128), AOM_ICDF(32768), 0 } },
{ AOM_ICDF(50 * 128), AOM_ICDF(32768), 0 } },
{ { AOM_ICDF(77 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(130 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(74 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(74 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(74 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(74 * 128), AOM_ICDF(32768), 0 } },
{ AOM_ICDF(130 * 128), AOM_ICDF(32768), 0 } },
{ { AOM_ICDF(142 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(210 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(142 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(142 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(142 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(142 * 128), AOM_ICDF(32768), 0 } },
{ AOM_ICDF(210 * 128), AOM_ICDF(32768), 0 } },
{ { AOM_ICDF(172 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(170 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(170 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(170 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(170 * 128), AOM_ICDF(32768), 0 } },
{ AOM_ICDF(128 * 128), AOM_ICDF(32768), 0 } },
{ { AOM_ICDF(238 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(247 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(247 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(247 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(247 * 128), AOM_ICDF(32768), 0 } }
#else // CONFIG_EXT_COMP_REFS
{ { AOM_ICDF(36 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(2 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(28 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(58 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(9 * 128), AOM_ICDF(32768), 0 } },
{ { AOM_ICDF(64 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(22 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(60 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(122 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(40 * 128), AOM_ICDF(32768), 0 } },
{ { AOM_ICDF(153 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(69 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(126 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(179 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(71 * 128), AOM_ICDF(32768), 0 } },
{ { AOM_ICDF(128 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(174 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(189 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(216 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(101 * 128), AOM_ICDF(32768), 0 } },
{ { AOM_ICDF(233 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(252 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(228 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(246 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(200 * 128), AOM_ICDF(32768), 0 } }
#endif // !CONFIG_EXT_COMP_REFS
{ AOM_ICDF(128 * 128), AOM_ICDF(32768), 0 } }
#else // !CONFIG_EXT_REFS
{ { AOM_ICDF(31 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(25 * 128), AOM_ICDF(32768), 0 } },
......@@ -5430,9 +5380,9 @@ static void set_default_lf_deltas(struct loopfilter *lf) {
lf->ref_deltas[BWDREF_FRAME] = lf->ref_deltas[LAST_FRAME];
#endif // CONFIG_EXT_REFS
lf->ref_deltas[GOLDEN_FRAME] = -1;
#if CONFIG_ALTREF2
#if CONFIG_EXT_REFS
lf->ref_deltas[ALTREF2_FRAME] = -1;
#endif // CONFIG_ALTREF2
#endif // CONFIG_EXT_REFS
lf->ref_deltas[ALTREF_FRAME] = -1;
lf->mode_deltas[0] = 0;
......
......@@ -325,14 +325,9 @@ typedef enum {
AOM_LAST3_FLAG = 1 << 2,
AOM_GOLD_FLAG = 1 << 3,
AOM_BWD_FLAG = 1 << 4,
#if CONFIG_ALTREF2
AOM_ALT2_FLAG = 1 << 5,
AOM_ALT_FLAG = 1 << 6,
AOM_REFFRAME_ALL = (1 << 7) - 1
#else // !CONFIG_ALTREF2
AOM_ALT_FLAG = 1 << 5,
AOM_REFFRAME_ALL = (1 << 6) - 1
#endif // CONFIG_ALTREF2
#else // !CONFIG_EXT_REFS
AOM_GOLD_FLAG = 1 << 1,
AOM_ALT_FLAG = 1 << 2,
......@@ -631,14 +626,8 @@ typedef uint8_t TXFM_CONTEXT;
#define LAST3_FRAME 3
#define GOLDEN_FRAME 4
#define BWDREF_FRAME 5
#if CONFIG_ALTREF2
#define ALTREF2_FRAME 6
#define ALTREF_FRAME 7
#else // !CONFIG_ALTREF2
#define ALTREF_FRAME 6
#endif // CONFIG_ALTREF2
#define LAST_REF_FRAMES (LAST3_FRAME - LAST_FRAME + 1)
#else // !CONFIG_EXT_REFS
#define GOLDEN_FRAME 2
......
......@@ -302,10 +302,8 @@ static MV_REFERENCE_FRAME ref_frame_map[COMP_REFS][2] = {
{ LAST_FRAME, BWDREF_FRAME }, { LAST2_FRAME, BWDREF_FRAME },
{ LAST3_FRAME, BWDREF_FRAME }, { GOLDEN_FRAME, BWDREF_FRAME },
#if CONFIG_ALTREF2
{ LAST_FRAME, ALTREF2_FRAME }, { LAST2_FRAME, ALTREF2_FRAME },
{ LAST3_FRAME, ALTREF2_FRAME }, { GOLDEN_FRAME, ALTREF2_FRAME },
#endif // CONFIG_ALTREF2
{ LAST_FRAME, ALTREF_FRAME }, { LAST2_FRAME, ALTREF_FRAME },
{ LAST3_FRAME, ALTREF_FRAME }, { GOLDEN_FRAME, ALTREF_FRAME }
......
......@@ -611,9 +611,7 @@ static INLINE void ensure_mv_buffer(RefCntBuffer *buf, AV1_COMMON *cm) {
#define LAST3_IS_VALID(cm) ((cm)->frame_refs[LAST3_FRAME - 1].is_valid)
#define GOLDEN_IS_VALID(cm) ((cm)->frame_refs[GOLDEN_FRAME - 1].is_valid)
#define BWDREF_IS_VALID(cm) ((cm)->frame_refs[BWDREF_FRAME - 1].is_valid)
#if CONFIG_ALTREF2
#define ALTREF2_IS_VALID(cm) ((cm)->frame_refs[ALTREF2_FRAME - 1].is_valid)
#endif // CONFIG_ALTREF2
#define ALTREF_IS_VALID(cm) ((cm)->frame_refs[ALTREF_FRAME - 1].is_valid)
#define L_OR_L2(cm) (LAST_IS_VALID(cm) || LAST2_IS_VALID(cm))
......@@ -624,10 +622,8 @@ static INLINE void ensure_mv_buffer(RefCntBuffer *buf, AV1_COMMON *cm) {
#define L3_OR_G(cm) (LAST3_IS_VALID(cm) || GOLDEN_IS_VALID(cm))
#define L3_AND_G(cm) (LAST3_IS_VALID(cm) && GOLDEN_IS_VALID(cm))
#if CONFIG_ALTREF2
#define BWD_OR_ALT2(cm) (BWDREF_IS_VALID(cm) || ALTREF2_IS_VALID(cm))
#define BWD_AND_ALT2(cm) (BWDREF_IS_VALID(cm) && ALTREF2_IS_VALID(cm))
#endif // CONFIG_ALTREF2
#define BWD_OR_ALT(cm) (BWDREF_IS_VALID(cm) || ALTREF_IS_VALID(cm))
#define BWD_AND_ALT(cm) (BWDREF_IS_VALID(cm) && ALTREF_IS_VALID(cm))
#endif // CONFIG_VAR_REFS
......
This diff is collapsed.
......@@ -243,17 +243,22 @@ static INLINE aom_prob av1_get_pred_prob_comp_bwdref_p(const AV1_COMMON *cm,
return cm->fc->comp_bwdref_prob[pred_context][0];
}
#if CONFIG_ALTREF2
// TODO(zoeliu): ALTREF2 to work with NEW_MULTISYMBOL
int av1_get_pred_context_comp_bwdref_p1(const AV1_COMMON *cm,
const MACROBLOCKD *xd);
#if CONFIG_NEW_MULTISYMBOL
static INLINE aom_cdf_prob *av1_get_pred_cdf_comp_bwdref_p1(
const AV1_COMMON *cm, const MACROBLOCKD *xd) {
const int pred_context = av1_get_pred_context_comp_bwdref_p1(cm, xd);
return xd->tile_ctx->comp_bwdref_cdf[pred_context][1];
}
#endif // CONFIG_NEW_MULTISYMBOL
static INLINE aom_prob av1_get_pred_prob_comp_bwdref_p1(const AV1_COMMON *cm,
const MACROBLOCKD *xd) {
const int pred_context = av1_get_pred_context_comp_bwdref_p1(cm, xd);
return cm->fc->comp_bwdref_prob[pred_context][1];
}
#endif // CONFIG_ALTREF2
#endif // CONFIG_EXT_REFS
int av1_get_pred_context_single_ref_p1(const MACROBLOCKD *xd);
......@@ -292,14 +297,12 @@ static INLINE aom_prob av1_get_pred_prob_single_ref_p5(const AV1_COMMON *cm,
return cm->fc->single_ref_prob[av1_get_pred_context_single_ref_p5(xd)][4];
}
#if CONFIG_ALTREF2
int av1_get_pred_context_single_ref_p6(const MACROBLOCKD *xd);
static INLINE aom_prob av1_get_pred_prob_single_ref_p6(const AV1_COMMON *cm,
const MACROBLOCKD *xd) {
return cm->fc->single_ref_prob[av1_get_pred_context_single_ref_p6(xd)][5];
}
#endif // CONFIG_ALTREF2
#endif // CONFIG_EXT_REFS
#if CONFIG_NEW_MULTISYMBOL
......@@ -334,6 +337,12 @@ static INLINE aom_cdf_prob *av1_get_pred_cdf_single_ref_p5(
return xd->tile_ctx
->single_ref_cdf[av1_get_pred_context_single_ref_p5(xd)][4];
}
static INLINE aom_cdf_prob *av1_get_pred_cdf_single_ref_p6(
const AV1_COMMON *cm, const MACROBLOCKD *xd) {
(void)cm;
return xd->tile_ctx
->single_ref_cdf[av1_get_pred_context_single_ref_p6(xd)][5];
}
#endif // CONFIG_EXT_REFS
#endif // CONFIG_NEW_MULTISYMBOL
......
......@@ -115,12 +115,8 @@ static void setup_compound_reference_mode(AV1_COMMON *cm) {
cm->comp_fwd_ref[3] = GOLDEN_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;
#endif // CONFIG_ALTREF2
#else // !CONFIG_EXT_REFS
if (cm->ref_frame_sign_bias[LAST_FRAME] ==
cm->ref_frame_sign_bias[GOLDEN_FRAME]) {
......
......@@ -1525,12 +1525,8 @@ 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);
#if CONFIG_VAR_REFS
int bit_bwd;
// Test need to explicitly code (BWD/ALT2) vs (ALT) branch node in tree
#if CONFIG_ALTREF2
// Test need to explicitly code (BWD/ALT2) vs (ALT) branch node in tree
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);
else
......@@ -1539,7 +1535,6 @@ static void read_ref_frames(AV1_COMMON *const cm, MACROBLOCKD *const xd,
const int bit_bwd = READ_REF_BIT(comp_bwdref_p);
#endif // CONFIG_VAR_REFS
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
......@@ -1556,9 +1551,6 @@ static void read_ref_frames(AV1_COMMON *const cm, MACROBLOCKD *const xd,
} else {
ref_frame[idx] = cm->comp_bwd_ref[2];
}
#else // !CONFIG_ALTREF2
ref_frame[idx] = cm->comp_bwd_ref[bit_bwd];
#endif // CONFIG_ALTREF2
#else // !CONFIG_EXT_REFS
ref_frame[!idx] = cm->comp_var_ref[bit];
ref_frame[idx] = cm->comp_fixed_ref;
......@@ -1568,7 +1560,6 @@ static void read_ref_frames(AV1_COMMON *const cm, MACROBLOCKD *const xd,
const int ctx0 = av1_get_pred_context_single_ref_p1(xd);
#if CONFIG_VAR_REFS
int bit0;
#if CONFIG_ALTREF2
// Test need to explicitly code (L,L2,L3,G) vs (BWD,ALT2,ALT) branch node
// in tree
if ((L_OR_L2(cm) || L3_OR_G(cm)) &&
......@@ -1576,14 +1567,6 @@ static void read_ref_frames(AV1_COMMON *const cm, MACROBLOCKD *const xd,
bit0 = READ_REF_BIT(single_ref_p1);
else
bit0 = (BWD_OR_ALT2(cm) || ALTREF_IS_VALID(cm));
#else // !CONFIG_ALTREF2
// Test need to explicitly code (L,L2,L3,G) vs (BWD,ALT) branch node in
// tree
if ((L_OR_L2(cm) || L3_OR_G(cm)) && BWD_OR_ALT(cm))
bit0 = READ_REF_BIT(single_ref_p1);
else
bit0 = BWD_OR_ALT(cm);
#endif // CONFIG_ALTREF2
#else // !CONFIG_VAR_REFS
const int bit0 = READ_REF_BIT(single_ref_p1);
#endif // CONFIG_VAR_REFS
......@@ -1593,13 +1576,8 @@ static void read_ref_frames(AV1_COMMON *const cm, MACROBLOCKD *const xd,
const int ctx1 = av1_get_pred_context_single_ref_p2(xd);
#if CONFIG_VAR_REFS
int bit1;
#if CONFIG_ALTREF2
// Test need to explicitly code (BWD/ALT2) vs (ALT) branch node in tree
const int bit1_uncertain = BWD_OR_ALT2(cm) && ALTREF_IS_VALID(cm);
#else // !CONFIG_ALTREF2
// Test need to explicitly code (BWD) vs (ALT) branch node in tree
const int bit1_uncertain = BWD_AND_ALT(cm);
#endif // CONFIG_ALTREF2
if (bit1_uncertain)
bit1 = READ_REF_BIT(single_ref_p2);
else
......@@ -1608,7 +1586,6 @@ static void read_ref_frames(AV1_COMMON *const cm, MACROBLOCKD *const xd,
const int bit1 = READ_REF_BIT(single_ref_p2);
#endif // CONFIG_VAR_REFS
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
......@@ -1625,9 +1602,6 @@ static void read_ref_frames(AV1_COMMON *const cm, MACROBLOCKD *const xd,
} else {
ref_frame[0] = ALTREF_FRAME;
}
#else // !CONFIG_ALTREF2
ref_frame[0] = bit1 ? ALTREF_FRAME : BWDREF_FRAME;
#endif // CONFIG_ALTREF2
} else {
const int ctx2 = av1_get_pred_context_single_ref_p3(xd);
#if CONFIG_VAR_REFS
......
......@@ -1136,8 +1136,6 @@ static void write_ref_frames(const AV1_COMMON *cm, const MACROBLOCKD *xd,
#endif // CONFIG_VAR_REFS
}
#if CONFIG_ALTREF2
#if CONFIG_VAR_REFS
// Test need to explicitly code (BWD,ALT2) vs (ALT) branch node in tree
if (BWD_OR_ALT2(cm) && ALTREF_IS_VALID(cm)) {
......@@ -1157,20 +1155,6 @@ static void write_ref_frames(const AV1_COMMON *cm, const MACROBLOCKD *xd,
}
#endif // CONFIG_VAR_REFS
#else // !CONFIG_ALTREF2
#if CONFIG_VAR_REFS
// Test need to explicitly code (BWD) vs (ALT) branch node in tree
if (BWD_AND_ALT(cm)) {
#endif // CONFIG_VAR_REFS
const int bit_bwd = mbmi->ref_frame[1] == ALTREF_FRAME;
WRITE_REF_BIT(bit_bwd, comp_bwdref_p);
#if CONFIG_VAR_REFS
}
#endif // CONFIG_VAR_REFS
#endif // CONFIG_ALTREF2
#else // !CONFIG_EXT_REFS
const int bit = mbmi->ref_frame[0] == GOLDEN_FRAME;
WRITE_REF_BIT(bit, comp_ref_p);
......@@ -1180,21 +1164,14 @@ static void write_ref_frames(const AV1_COMMON *cm, const MACROBLOCKD *xd,
const int bit0 = (mbmi->ref_frame[0] <= ALTREF_FRAME &&
mbmi->ref_frame[0] >= BWDREF_FRAME);
#if CONFIG_VAR_REFS
#if CONFIG_ALTREF2
// Test need to explicitly code (L,L2,L3,G) vs (BWD,ALT2,ALT) branch node
// in tree
if ((L_OR_L2(cm) || L3_OR_G(cm)) &&
(BWD_OR_ALT2(cm) || ALTREF_IS_VALID(cm)))
#else // !CONFIG_ALTREF2
// Test need to explicitly code (L,L2,L3,G) vs (BWD,ALT) branch node in
// tree
if ((L_OR_L2(cm) || L3_OR_G(cm)) && BWD_OR_ALT(cm))
#endif // CONFIG_ALTREF2
#endif // CONFIG_VAR_REFS
WRITE_REF_BIT(bit0, single_ref_p1);
if (bit0) {
#if CONFIG_ALTREF2
#if CONFIG_VAR_REFS
// Test need to explicitly code (BWD,ALT2) vs (ALT) branch node in tree
if (BWD_OR_ALT2(cm) && ALTREF_IS_VALID(cm)) {
......@@ -1212,17 +1189,6 @@ static void write_ref_frames(const AV1_COMMON *cm, const MACROBLOCKD *xd,
#if CONFIG_VAR_REFS
}
#endif // CONFIG_VAR_REFS
#else // !CONFIG_ALTREF2
#if CONFIG_VAR_REFS
// Test need to explicitly code (BWD) vs (ALT) branch node in tree
if (BWD_AND_ALT(cm)) {
#endif // CONFIG_VAR_REFS
const int bit1 = mbmi->ref_frame[0] == ALTREF_FRAME;
WRITE_REF_BIT(bit1, single_ref_p2);
#if CONFIG_VAR_REFS
}
#endif // CONFIG_VAR_REFS
#endif // CONFIG_ALTREF2
} else {
const int bit2 = (mbmi->ref_frame[0] == LAST3_FRAME ||
mbmi->ref_frame[0] == GOLDEN_FRAME);
......@@ -3707,17 +3673,8 @@ static int get_refresh_mask(AV1_COMP *cpi) {
refresh_mask |=
(cpi->refresh_last_frame << cpi->lst_fb_idxes[LAST_REF_FRAMES - 1]);
#if CONFIG_ALTREF2
refresh_mask |= (cpi->refresh_bwd_ref_frame << cpi->bwd_fb_idx);
refresh_mask |= (cpi->refresh_alt2_ref_frame << cpi->alt2_fb_idx);
#else // !CONFIG_ALTREF2
if (cpi->rc.is_bwd_ref_frame && cpi->num_extra_arfs) {
// We have swapped the virtual indices
refresh_mask |= (cpi->refresh_bwd_ref_frame << cpi->arf_map[0]);
} else {
refresh_mask |= (cpi->refresh_bwd_ref_frame << cpi->bwd_fb_idx);
}
#endif // CONFIG_ALTREF2
#else // !CONFIG_EXT_REFS
refresh_mask |= (cpi->refresh_last_frame << cpi->lst_fb_idx);
#endif // CONFIG_EXT_REFS
......@@ -3736,12 +3693,7 @@ static int get_refresh_mask(AV1_COMP *cpi) {
return refresh_mask | (cpi->refresh_golden_frame << cpi->alt_fb_idx);
} else {
#if CONFIG_EXT_REFS
#if CONFIG_ALTREF2
const int arf_idx = cpi->alt_fb_idx;
#else // !CONFIG_ALTREF2
const GF_GROUP *const gf_group = &cpi->twopass.gf_group;
const int arf_idx = cpi->arf_map[gf_group->arf_update_idx[gf_group->index]];
#endif // CONFIG_ALTREF2
#else // !CONFIG_EXT_REFS
int arf_idx = cpi->alt_fb_idx;
if ((cpi->oxcf.pass == 2) && cpi->multi_arf_allowed) {
......
......@@ -1488,9 +1488,9 @@ static void rd_pick_sb_modes(const AV1_COMP *const cpi, TileDataEnc *tile_data,
if ((rd_cost->rate != INT_MAX) && (aq_mode == COMPLEXITY_AQ) &&
(bsize >= BLOCK_16X16) &&
(cm->frame_type == KEY_FRAME || cpi->refresh_alt_ref_frame ||
#if CONFIG_ALTREF2
#if CONFIG_EXT_REFS
cpi->refresh_alt2_ref_frame ||
#endif // CONFIG_ALTREF2
#endif // CONFIG_EXT_REFS
(cpi->refresh_golden_frame && !cpi->rc.is_src_frame_alt_ref))) {
av1_caq_select_segment(cpi, x, bsize, mi_row, mi_col, rd_cost->rate);
}
......@@ -1659,11 +1659,9 @@ static void update_stats(const AV1_COMMON *const cm, ThreadData *td, int mi_row,
counts->comp_bwdref[av1_get_pred_context_comp_bwdref_p(cm, xd)][0]
[ref1 == ALTREF_FRAME]++;
#if CONFIG_ALTREF2
if (ref1 != ALTREF_FRAME)
counts->comp_bwdref[av1_get_pred_context_comp_bwdref_p1(cm, xd)]
[1][ref1 == ALTREF2_FRAME]++;
#endif // CONFIG_ALTREF2
#else // !CONFIG_EXT_REFS
counts->comp_ref[av1_get_pred_context_comp_ref_p(cm, xd)][0]
[ref0 == GOLDEN_FRAME]++;
......@@ -1680,11 +1678,9 @@ static void update_stats(const AV1_COMMON *const cm, ThreadData *td, int mi_row,
assert(ref0 <= ALTREF_FRAME);
counts->single_ref[av1_get_pred_context_single_ref_p2(xd)][1]
[ref0 == ALTREF_FRAME]++;
#if CONFIG_ALTREF2
if (ref0 != ALTREF_FRAME)
counts->single_ref[av1_get_pred_context_single_ref_p6(xd)][5]
[ref0 == ALTREF2_FRAME]++;
#endif // CONFIG_ALTREF2
} else {
const int bit1 = !(ref0 == LAST2_FRAME || ref0 == LAST_FRAME);
counts
......@@ -4678,10 +4674,7 @@ static int check_dual_ref_flags(AV1_COMP *cpi) {
return (!!(ref_flags & AOM_GOLD_FLAG) + !!(ref_flags & AOM_LAST_FLAG) +
#if CONFIG_EXT_REFS
!!(ref_flags & AOM_LAST2_FLAG) + !!(ref_flags & AOM_LAST3_FLAG) +
!!(ref_flags & AOM_BWD_FLAG) +
#if CONFIG_ALTREF2
!!(ref_flags & AOM_ALT2_FLAG) +
#endif // CONFIG_ALTREF2
!!(ref_flags & AOM_BWD_FLAG) + !!(ref_flags & AOM_ALT2_FLAG) +
#endif // CONFIG_EXT_REFS
!!(ref_flags & AOM_ALT_FLAG)) >= 2;
}
......@@ -4711,12 +4704,12 @@ static MV_REFERENCE_FRAME get_frame_type(const AV1_COMP *cpi) {
cpi->rc.is_src_frame_ext_arf)
#else
else if (cpi->rc.is_src_frame_alt_ref && cpi->refresh_golden_frame)
#endif
#endif // CONFIG_EXT_REFS
return ALTREF_FRAME;
else if (cpi->refresh_golden_frame ||
#if CONFIG_ALTREF2
#if CONFIG_EXT_REFS
cpi->refresh_alt2_ref_frame ||
#endif // CONFIG_ALTREF2
#endif // CONFIG_EXT_REFS
cpi->refresh_alt_ref_frame)
return GOLDEN_FRAME;
else
......@@ -5419,17 +5412,13 @@ void av1_encode_frame(AV1_COMP *cpi) {
cm->comp_fwd_ref[2] = LAST3_FRAME;
cm->comp_fwd_ref[3] = GOLDEN_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;
#endif // CONFIG_ALTREF2
#else // CONFIG_EXT_REFS
#else // !CONFIG_EXT_REFS
cm->comp_fixed_ref = ALTREF_FRAME;
cm->comp_var_ref[0] = LAST_FRAME;
cm->comp_var_ref[1] = GOLDEN_FRAME;
#endif // CONFIG_EXT_REFS
#endif // CONFIG_EXT_REFS
#if !CONFIG_ONE_SIDED_COMPOUND // Normative in encoder
}
#endif // !CONFIG_ONE_SIDED_COMPOUND
......
This diff is collapsed.
......@@ -107,9 +107,7 @@ typedef enum {
FRAMEFLAGS_GOLDEN = 1 << 1,
#if CONFIG_EXT_REFS
FRAMEFLAGS_BWDREF = 1 << 2,
#if CONFIG_ALTREF2
// TODO(zoeliu): To determine whether a frame flag is needed for ALTREF2_FRAME
#endif // CONFIG_ALTREF2
// TODO(zoeliu): To determine whether a frame flag is needed for ALTREF2_FRAME
FRAMEFLAGS_ALTREF = 1 << 3,
#else // !CONFIG_EXT_REFS
FRAMEFLAGS_ALTREF = 1 << 2,
......@@ -412,10 +410,8 @@ typedef struct AV1_COMP {
#endif // CONFIG_EXT_REFS
int gld_fb_idx;
#if CONFIG_EXT_REFS
int bwd_fb_idx; // BWDREF_FRAME
#if CONFIG_ALTREF2
int bwd_fb_idx; // BWDREF_FRAME
int alt2_fb_idx; // ALTREF2_FRAME
#endif // CONFIG_ALTREF2
#endif // CONFIG_EXT_REFS
int alt_fb_idx;
......@@ -425,9 +421,7 @@ typedef struct AV1_COMP {
int refresh_golden_frame;
#if CONFIG_EXT_REFS
int refresh_bwd_ref_frame;
#if CONFIG_ALTREF2
int refresh_alt2_ref_frame;
#endif // CONFIG_ALTREF2
#endif // CONFIG_EXT_REFS
int refresh_alt_ref_frame;
......@@ -677,10 +671,8 @@ static INLINE int get_ref_frame_map_idx(const AV1_COMP *cpi,
#if CONFIG_EXT_REFS
else if (ref_frame == BWDREF_FRAME)
return cpi->bwd_fb_idx;
#if CONFIG_ALTREF2
else if (ref_frame == ALTREF2_FRAME)
return cpi->alt2_fb_idx;
#endif // CONFIG_ALTREF2
#endif // CONFIG_EXT_REFS
else
return cpi->alt_fb_idx;
......
......@@ -1818,13 +1818,7 @@ static void allocate_gf_group_bits(AV1_COMP *cpi, int64_t gf_group_bits,
// Insert an extra ARF
// === [frame_index == 2] ===
if (cpi->num_extra_arfs) {
#if CONFIG_ALTREF2
gf_group->update_type[frame_index] = INTNL_ARF_UPDATE;
#else // !CONFIG_ALTREF2
gf_group->update_type[frame_index] = ARF_UPDATE;
// Note (weitinglin): GF_ARF_LOW is also used as an identifier
// for internal ALT_REF's:
#endif // CONFIG_ALTREF2
gf_group->rf_level[frame_index] = GF_ARF_LOW;
gf_group->arf_src_offset[frame_index] = ext_arf_interval;
gf_group->arf_update_idx[frame_index] = which_arf;
......@@ -1978,11 +1972,7 @@ static void allocate_gf_group_bits(AV1_COMP *cpi, int64_t gf_group_bits,
bipred_group_end = 0;
// Insert another extra ARF after the overlay frame
if (which_arf) {
#if CONFIG_ALTREF2
gf_group->update_type[frame_index] = INTNL_ARF_UPDATE;
#else // !CONFIG_ALTREF2
gf_group->update_type[frame_index] = ARF_UPDATE;
#endif // CONFIG_ALTREF2
gf_group->rf_level[frame_index] = GF_ARF_LOW;
gf_group->arf_src_offset[frame_index] = ext_arf_interval;
gf_group->arf_update_idx[frame_index] = which_arf;
......@@ -2773,9 +2763,7 @@ static void configure_buffer_updates(AV1_COMP *cpi) {
case KF_UPDATE: cpi->refresh_last_frame = 1; cpi->refresh_golden_frame = 1;
#if CONFIG_EXT_REFS
cpi->refresh_bwd_ref_frame = 1;
#if CONFIG_ALTREF2
cpi->refresh_alt2_ref_frame = 1;
#endif // CONFIG_ALTREF2
#endif // CONFIG_EXT_REFS
cpi->refresh_alt_ref_frame = 1;
break;
......@@ -2783,26 +2771,9 @@ static void configure_buffer_updates(AV1_COMP *cpi) {
case LF_UPDATE: cpi->refresh_last_frame = 1; cpi->refresh_golden_frame = 0;
#if CONFIG_EXT_REFS
cpi->refresh_bwd_ref_frame = 0;
#if CONFIG_ALTREF2
cpi->refresh_alt2_ref_frame = 0;
#endif // CONFIG_ALTREF2
#endif // CONFIG_EXT_REFS
cpi->refresh_alt_ref_frame = 0;
#if CONFIG_EXT_REFS && !CONFIG_ALTREF2
// If we have extra ALT_REFs, we may use the farthest ALT (ALT0) as
// the BWDREF_FRAME, as LF_UPDATE frames do not have BWDREF_FRAME
// available as their reference.
if (cpi->num_extra_arfs) {
int tmp = cpi->bwd_fb_idx;
cpi->bwd_fb_idx = cpi->alt_fb_idx;
cpi->alt_fb_idx = cpi->arf_map[0];
cpi->arf_map[0] = tmp;
cpi->rc.is_bwd_ref_frame = 1;
}
#endif // CONFIG_EXT_REFS && !CONFIG_ALTREF2
break;
case GF_UPDATE:
......@@ -2812,9 +2783,7 @@ static void configure_buffer_updates(AV1_COMP *cpi) {
cpi->refresh_golden_frame = 1;
#if CONFIG_EXT_REFS
cpi->refresh_bwd_ref_frame = 0;
#if CONFIG_ALTREF2
cpi->refresh_alt2_ref_frame = 0;
#endif // CONFIG_ALTREF2
#endif // CONFIG_EXT_REFS
cpi->refresh_alt_ref_frame = 0;
break;
......@@ -2824,9 +2793,7 @@ static void configure_buffer_updates(AV1_COMP *cpi) {
cpi->refresh_golden_frame = 1;
#if CONFIG_EXT_REFS
cpi->refresh_bwd_ref_frame = 0;
#if CONFIG_ALTREF2
cpi->refresh_alt2_ref_frame = 0;
#endif // CONFIG_ALTREF2
#endif // CONFIG_EXT_REFS
cpi->refresh_alt_ref_frame = 0;
......@@ -2835,13 +2802,9 @@ static void configure_buffer_updates(AV1_COMP *cpi) {
case ARF_UPDATE: cpi->refresh_last_frame = 0; cpi->refresh_golden_frame = 0;
#if CONFIG_EXT_REFS
#if CONFIG_ALTREF2
// NOTE: BWDREF does not get updated along with ALTREF_FRAME.
cpi->refresh_bwd_ref_frame = 0;
cpi->refresh_alt2_ref_frame = 0;
#else // !CONFIG_ALTREF2
cpi->refresh_bwd_ref_frame = 1;
#endif // CONFIG_ALTREF2
#endif // CONFIG_EXT_REFS
cpi->refresh_alt_ref_frame = 1;
break;
......@@ -2851,24 +2814,9 @@ static void configure_buffer_updates(AV1_COMP *cpi) {
cpi->refresh_last_frame = 0;
cpi->refresh_golden_frame = 0;
cpi->refresh_bwd_ref_frame = 1;
#if CONFIG_ALTREF2
cpi->refresh_alt2_ref_frame = 0;
#endif // CONFIG_ALTREF2
cpi->refresh_alt_ref_frame = 0;
#if !CONFIG_ALTREF2
if (cpi->num_extra_arfs) {