Commit 894cc813 authored by Thomas Davies's avatar Thomas Davies

NEW_MULTISYMBOL: adapt comp_ref and bwd_ref.

Change-Id: I711cd173af501ba955e889d1e2205125615a99fd
parent 243b66bc
......@@ -5692,9 +5692,10 @@ void av1_average_tile_inter_cdfs(AV1_COMMON *cm, FRAME_CONTEXT *fc,
#if CONFIG_NEW_MULTISYMBOL
AVERAGE_TILE_CDFS(comp_inter_cdf)
#if CONFIG_EXT_REFS
AVERAGE_TILE_CDFS(comp_bwdref_cdf)
#endif
#endif
// FIXME: comp_ref_cdf and comp_bwd_ref not defined
#if CONFIG_NEW_MULTISYMBOL
AVERAGE_TILE_CDFS(single_ref_cdf)
......
......@@ -1428,10 +1428,49 @@ 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] = {
{ 16 }, { 74 }, { 142 }, { 170 }, { 247 }
};
#if CONFIG_NEW_MULTISYMBOL
static const aom_cdf_prob
default_comp_ref_cdf[REF_CONTEXTS][FWD_REFS - 1][CDF_SIZE(2)] = {
// TODO(zoeliu): To adjust the initial prob values.
{ { AOM_ICDF(33 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(16 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(16 * 128), AOM_ICDF(32768), 0 } },
{ { AOM_ICDF(77 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(74 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(74 * 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(172 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(170 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(170 * 128), AOM_ICDF(32768), 0 } },
{ { AOM_ICDF(238 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(247 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(247 * 128), AOM_ICDF(32768), 0 } }
};
static const aom_cdf_prob
default_comp_bwdref_cdf[REF_CONTEXTS][BWD_REFS - 1][CDF_SIZE(2)] = {
{ { 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 } }
};
#endif // CONFIG_NEW_MULTISYMBOL
#else
static const aom_prob default_comp_ref_p[REF_CONTEXTS][COMP_REFS - 1] = {
{ 50 }, { 126 }, { 123 }, { 221 }, { 226 }
};
#if CONFIG_NEW_MULTISYMBOL
static const aom_cdf_prob
default_comp_ref_cdf[REF_CONTEXTS][COMP_REFS - 1][CDF_SIZE(2)] = {
{ { AOM_ICDF(50 * 128), AOM_ICDF(32768), 0 } },
{ { AOM_ICDF(126 * 128), AOM_ICDF(32768), 0 } },
{ { AOM_ICDF(123 * 128), AOM_ICDF(32768), 0 } },
{ { AOM_ICDF(221 * 128), AOM_ICDF(32768), 0 } },
{ { AOM_ICDF(226 * 128), AOM_ICDF(32768), 0 } }
};
#endif // CONFIG_NEW_MULTISYMBOL
#endif // CONFIG_EXT_REFS
static const aom_prob default_single_ref_p[REF_CONTEXTS][SINGLE_REFS - 1] = {
......@@ -4605,6 +4644,9 @@ static void init_mode_probs(FRAME_CONTEXT *fc) {
av1_copy(fc->uni_comp_ref_prob, default_uni_comp_ref_p);
#endif // CONFIG_EXT_COMP_REFS
av1_copy(fc->comp_ref_prob, default_comp_ref_p);
#if CONFIG_NEW_MULTISYMBOL
av1_copy(fc->comp_ref_cdf, default_comp_ref_cdf);
#endif
#if CONFIG_LV_MAP
av1_copy(fc->txb_skip, default_txb_skip);
av1_copy(fc->nz_map, default_nz_map);
......@@ -4615,6 +4657,9 @@ static void init_mode_probs(FRAME_CONTEXT *fc) {
#endif
#if CONFIG_EXT_REFS
av1_copy(fc->comp_bwdref_prob, default_comp_bwdref_p);
#if CONFIG_NEW_MULTISYMBOL
av1_copy(fc->comp_bwdref_cdf, default_comp_bwdref_cdf);
#endif
#endif // CONFIG_EXT_REFS
av1_copy(fc->single_ref_prob, default_single_ref_p);
#if CONFIG_NEW_MULTISYMBOL
......
......@@ -234,6 +234,14 @@ typedef struct frame_contexts {
#else
aom_prob comp_ref_prob[REF_CONTEXTS][COMP_REFS - 1];
#endif // CONFIG_EXT_REFS
#if CONFIG_NEW_MULTISYMBOL
#if CONFIG_EXT_REFS
aom_cdf_prob comp_ref_cdf[REF_CONTEXTS][FWD_REFS - 1][CDF_SIZE(2)];
aom_cdf_prob comp_bwdref_cdf[REF_CONTEXTS][BWD_REFS - 1][CDF_SIZE(2)];
#else
aom_cdf_prob comp_ref_cdf[REF_CONTEXTS][COMP_REFS - 1][CDF_SIZE(2)];
#endif // CONFIG_EXT_REFS
#endif
#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
aom_prob comp_inter_mode_prob[COMP_INTER_MODE_CONTEXTS];
#endif // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
......
......@@ -140,6 +140,14 @@ av1_get_pred_prob_uni_comp_ref_p1(const AV1_COMMON *cm, const MACROBLOCKD *xd) {
int av1_get_pred_context_comp_ref_p(const AV1_COMMON *cm,
const MACROBLOCKD *xd);
#if CONFIG_NEW_MULTISYMBOL
static INLINE aom_cdf_prob *av1_get_pred_cdf_comp_ref_p(const AV1_COMMON *cm,
const MACROBLOCKD *xd) {
const int pred_context = av1_get_pred_context_comp_ref_p(cm, xd);
return xd->tile_ctx->comp_ref_cdf[pred_context][0];
}
#endif
static INLINE aom_prob av1_get_pred_prob_comp_ref_p(const AV1_COMMON *cm,
const MACROBLOCKD *xd) {
const int pred_context = av1_get_pred_context_comp_ref_p(cm, xd);
......@@ -150,6 +158,14 @@ static INLINE aom_prob av1_get_pred_prob_comp_ref_p(const AV1_COMMON *cm,
int av1_get_pred_context_comp_ref_p1(const AV1_COMMON *cm,
const MACROBLOCKD *xd);
#if CONFIG_NEW_MULTISYMBOL
static INLINE aom_cdf_prob *av1_get_pred_cdf_comp_ref_p1(
const AV1_COMMON *cm, const MACROBLOCKD *xd) {
const int pred_context = av1_get_pred_context_comp_ref_p1(cm, xd);
return xd->tile_ctx->comp_ref_cdf[pred_context][1];
}
#endif
static INLINE aom_prob av1_get_pred_prob_comp_ref_p1(const AV1_COMMON *cm,
const MACROBLOCKD *xd) {
const int pred_context = av1_get_pred_context_comp_ref_p1(cm, xd);
......@@ -159,6 +175,14 @@ static INLINE aom_prob av1_get_pred_prob_comp_ref_p1(const AV1_COMMON *cm,
int av1_get_pred_context_comp_ref_p2(const AV1_COMMON *cm,
const MACROBLOCKD *xd);
#if CONFIG_NEW_MULTISYMBOL
static INLINE aom_cdf_prob *av1_get_pred_cdf_comp_ref_p2(
const AV1_COMMON *cm, const MACROBLOCKD *xd) {
const int pred_context = av1_get_pred_context_comp_ref_p2(cm, xd);
return xd->tile_ctx->comp_ref_cdf[pred_context][2];
}
#endif
static INLINE aom_prob av1_get_pred_prob_comp_ref_p2(const AV1_COMMON *cm,
const MACROBLOCKD *xd) {
const int pred_context = av1_get_pred_context_comp_ref_p2(cm, xd);
......@@ -168,6 +192,13 @@ static INLINE aom_prob av1_get_pred_prob_comp_ref_p2(const AV1_COMMON *cm,
int av1_get_pred_context_comp_bwdref_p(const AV1_COMMON *cm,
const MACROBLOCKD *xd);
#if CONFIG_NEW_MULTISYMBOL
static INLINE aom_cdf_prob *av1_get_pred_cdf_comp_bwdref_p(
const AV1_COMMON *cm, const MACROBLOCKD *xd) {
const int pred_context = av1_get_pred_context_comp_bwdref_p(cm, xd);
return xd->tile_ctx->comp_bwdref_cdf[pred_context][0];
}
#endif // CONFIG_NEW_MULTISYMBOL
static INLINE aom_prob av1_get_pred_prob_comp_bwdref_p(const AV1_COMMON *cm,
const MACROBLOCKD *xd) {
const int pred_context = av1_get_pred_context_comp_bwdref_p(cm, xd);
......@@ -214,31 +245,38 @@ static INLINE aom_prob av1_get_pred_prob_single_ref_p5(const AV1_COMMON *cm,
#if CONFIG_NEW_MULTISYMBOL
static INLINE aom_cdf_prob *av1_get_pred_cdf_single_ref_p1(
const MACROBLOCKD *xd) {
const AV1_COMMON *cm, const MACROBLOCKD *xd) {
(void)cm;
return xd->tile_ctx
->single_ref_cdf[av1_get_pred_context_single_ref_p1(xd)][0];
}
static INLINE aom_cdf_prob *av1_get_pred_cdf_single_ref_p2(
const MACROBLOCKD *xd) {
const AV1_COMMON *cm, const MACROBLOCKD *xd) {
(void)cm;
return xd->tile_ctx
->single_ref_cdf[av1_get_pred_context_single_ref_p2(xd)][1];
}
#if CONFIG_EXT_REFS
static INLINE aom_cdf_prob *av1_get_pred_cdf_single_ref_p3(
const MACROBLOCKD *xd) {
const AV1_COMMON *cm, const MACROBLOCKD *xd) {
(void)cm;
return xd->tile_ctx
->single_ref_cdf[av1_get_pred_context_single_ref_p3(xd)][2];
}
static INLINE aom_cdf_prob *av1_get_pred_cdf_single_ref_p4(
const MACROBLOCKD *xd) {
const AV1_COMMON *cm, const MACROBLOCKD *xd) {
(void)cm;
return xd->tile_ctx
->single_ref_cdf[av1_get_pred_context_single_ref_p4(xd)][3];
}
static INLINE aom_cdf_prob *av1_get_pred_cdf_single_ref_p5(
const MACROBLOCKD *xd) {
const AV1_COMMON *cm, const MACROBLOCKD *xd) {
(void)cm;
return xd->tile_ctx
->single_ref_cdf[av1_get_pred_context_single_ref_p5(xd)][4];
}
#endif
#endif // CONFIG_EXT_REFS
#endif // CONFIG_NEW_MULTISYMBOL
#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
int av1_get_inter_mode_context(const MACROBLOCKD *xd);
......
......@@ -272,8 +272,12 @@ static REFERENCE_MODE read_frame_reference_mode(
}
static void read_frame_reference_mode_probs(AV1_COMMON *cm, aom_reader *r) {
#if CONFIG_NEW_MULTISYMBOL && !CONFIG_EXT_COMP_REFS
(void)r;
#else
FRAME_CONTEXT *const fc = cm->fc;
int i, j;
int i;
#endif
#if !CONFIG_NEW_MULTISYMBOL
if (cm->reference_mode == REFERENCE_MODE_SELECT)
......@@ -282,6 +286,7 @@ static void read_frame_reference_mode_probs(AV1_COMMON *cm, aom_reader *r) {
if (cm->reference_mode != COMPOUND_REFERENCE) {
for (i = 0; i < REF_CONTEXTS; ++i) {
int j;
for (j = 0; j < (SINGLE_REFS - 1); ++j) {
av1_diff_update_prob(r, &fc->single_ref_prob[i][j], ACCT_STR);
}
......@@ -294,12 +299,16 @@ static void read_frame_reference_mode_probs(AV1_COMMON *cm, aom_reader *r) {
for (i = 0; i < COMP_REF_TYPE_CONTEXTS; ++i)
av1_diff_update_prob(r, &fc->comp_ref_type_prob[i], ACCT_STR);
for (i = 0; i < UNI_COMP_REF_CONTEXTS; ++i)
for (i = 0; i < UNI_COMP_REF_CONTEXTS; ++i) {
int j;
for (j = 0; j < (UNIDIR_COMP_REFS - 1); ++j)
av1_diff_update_prob(r, &fc->uni_comp_ref_prob[i][j], ACCT_STR);
}
#endif // CONFIG_EXT_COMP_REFS
#if !CONFIG_NEW_MULTISYMBOL
for (i = 0; i < REF_CONTEXTS; ++i) {
int j;
#if CONFIG_EXT_REFS
for (j = 0; j < (FWD_REFS - 1); ++j)
av1_diff_update_prob(r, &fc->comp_ref_prob[i][j], ACCT_STR);
......@@ -310,6 +319,7 @@ static void read_frame_reference_mode_probs(AV1_COMMON *cm, aom_reader *r) {
av1_diff_update_prob(r, &fc->comp_ref_prob[i][j], ACCT_STR);
#endif // CONFIG_EXT_REFS
}
#endif // CONFIG_NEW_MULTISYMBOL
}
}
......
......@@ -1311,7 +1311,7 @@ static REFERENCE_MODE read_block_reference_mode(AV1_COMMON *cm,
#if CONFIG_NEW_MULTISYMBOL
#define READ_REF_BIT(pname) \
aom_read_symbol(r, av1_get_pred_cdf_##pname(xd), 2, ACCT_STR)
aom_read_symbol(r, av1_get_pred_cdf_##pname(cm, xd), 2, ACCT_STR)
#else
#define READ_REF_BIT(pname) \
aom_read(r, av1_get_pred_prob_##pname(cm, xd), ACCT_STR)
......@@ -1339,7 +1339,9 @@ static REFERENCE_MODE read_comp_reference_type(AV1_COMMON *cm,
static void read_ref_frames(AV1_COMMON *const cm, MACROBLOCKD *const xd,
aom_reader *r, int segment_id,
MV_REFERENCE_FRAME ref_frame[2]) {
#if CONFIG_EXT_COMP_REFS
FRAME_CONTEXT *const fc = cm->fc;
#endif
FRAME_COUNTS *counts = xd->counts;
if (segfeature_active(&cm->seg, segment_id, SEG_LVL_REF_FRAME)) {
......@@ -1402,11 +1404,11 @@ static void read_ref_frames(AV1_COMMON *const cm, MACROBLOCKD *const xd,
int bit;
// Test need to explicitly code (L,L2) vs (L3,G) branch node in tree
if (L_OR_L2(cm) && L3_OR_G(cm))
bit = aom_read(r, fc->comp_ref_prob[ctx][0], ACCT_STR);
bit = READ_REF_BIT(comp_ref_p);
else
bit = L3_OR_G(cm);
#else // !CONFIG_VAR_REFS
const int bit = aom_read(r, fc->comp_ref_prob[ctx][0], ACCT_STR);
const int bit = READ_REF_BIT(comp_ref_p);
#endif // CONFIG_VAR_REFS
if (counts) ++counts->comp_ref[ctx][0][bit];
......@@ -1418,11 +1420,11 @@ static void read_ref_frames(AV1_COMMON *const cm, MACROBLOCKD *const xd,
int bit1;
// Test need to explicitly code (L) vs (L2) branch node in tree
if (L_AND_L2(cm))
bit1 = aom_read(r, fc->comp_ref_prob[ctx1][1], ACCT_STR);
bit1 = READ_REF_BIT(comp_ref_p1);
else
bit1 = LAST_IS_VALID(cm);
#else // !CONFIG_VAR_REFS
const int bit1 = aom_read(r, fc->comp_ref_prob[ctx1][1], ACCT_STR);
const int bit1 = READ_REF_BIT(comp_ref_p1);
#endif // CONFIG_VAR_REFS
if (counts) ++counts->comp_ref[ctx1][1][bit1];
ref_frame[!idx] = cm->comp_fwd_ref[bit1 ? 0 : 1];
......@@ -1432,11 +1434,11 @@ static void read_ref_frames(AV1_COMMON *const cm, MACROBLOCKD *const xd,
int bit2;
// Test need to explicitly code (L3) vs (G) branch node in tree
if (L3_AND_G(cm))
bit2 = aom_read(r, fc->comp_ref_prob[ctx2][2], ACCT_STR);
bit2 = READ_REF_BIT(comp_ref_p2);
else
bit2 = GOLDEN_IS_VALID(cm);
#else // !CONFIG_VAR_REFS
const int bit2 = aom_read(r, fc->comp_ref_prob[ctx2][2], ACCT_STR);
const int bit2 = READ_REF_BIT(comp_ref_p2);
#endif // CONFIG_VAR_REFS
if (counts) ++counts->comp_ref[ctx2][2][bit2];
ref_frame[!idx] = cm->comp_fwd_ref[bit2 ? 3 : 2];
......@@ -1448,12 +1450,11 @@ static void read_ref_frames(AV1_COMMON *const cm, MACROBLOCKD *const xd,
int bit_bwd;
// Test need to explicitly code (BWD) vs (ALT) branch node in tree
if (BWD_AND_ALT(cm))
bit_bwd = aom_read(r, fc->comp_bwdref_prob[ctx_bwd][0], ACCT_STR);
bit_bwd = READ_REF_BIT(comp_bwdref_p);
else
bit_bwd = ALTREF_IS_VALID(cm);
#else // !CONFIG_VAR_REFS
const int bit_bwd =
aom_read(r, fc->comp_bwdref_prob[ctx_bwd][0], ACCT_STR);
#else // !CONFIG_VAR_REFS
const int bit_bwd = READ_REF_BIT(comp_bwdref_p);
#endif // CONFIG_VAR_REFS
if (counts) ++counts->comp_bwdref[ctx_bwd][0][bit_bwd];
ref_frame[idx] = cm->comp_bwd_ref[bit_bwd];
......
......@@ -1248,7 +1248,7 @@ static void write_segment_id(aom_writer *w, const struct segmentation *seg,
#if CONFIG_NEW_MULTISYMBOL
#define WRITE_REF_BIT(bname, pname) \
aom_write_symbol(w, bname, av1_get_pred_cdf_##pname(xd), 2)
aom_write_symbol(w, bname, av1_get_pred_cdf_##pname(cm, xd), 2)
#else
#define WRITE_REF_BIT(bname, pname) \
aom_write(w, bname, av1_get_pred_prob_##pname(cm, xd))
......@@ -1315,7 +1315,7 @@ static void write_ref_frames(const AV1_COMMON *cm, const MACROBLOCKD *xd,
// Test need to explicitly code (L,L2) vs (L3,G) branch node in tree
if (L_OR_L2(cm) && L3_OR_G(cm))
#endif // CONFIG_VAR_REFS
aom_write(w, bit, av1_get_pred_prob_comp_ref_p(cm, xd));
WRITE_REF_BIT(bit, comp_ref_p);
if (!bit) {
#if CONFIG_VAR_REFS
......@@ -1323,7 +1323,7 @@ static void write_ref_frames(const AV1_COMMON *cm, const MACROBLOCKD *xd,
if (L_AND_L2(cm)) {
#endif // CONFIG_VAR_REFS
const int bit1 = mbmi->ref_frame[0] == LAST_FRAME;
aom_write(w, bit1, av1_get_pred_prob_comp_ref_p1(cm, xd));
WRITE_REF_BIT(bit1, comp_ref_p1);
#if CONFIG_VAR_REFS
}
#endif // CONFIG_VAR_REFS
......@@ -1333,7 +1333,7 @@ static void write_ref_frames(const AV1_COMMON *cm, const MACROBLOCKD *xd,
if (L3_AND_G(cm)) {
#endif // CONFIG_VAR_REFS
const int bit2 = mbmi->ref_frame[0] == GOLDEN_FRAME;
aom_write(w, bit2, av1_get_pred_prob_comp_ref_p2(cm, xd));
WRITE_REF_BIT(bit2, comp_ref_p2);
#if CONFIG_VAR_REFS
}
#endif // CONFIG_VAR_REFS
......@@ -1344,14 +1344,14 @@ static void write_ref_frames(const AV1_COMMON *cm, const MACROBLOCKD *xd,
if (BWD_AND_ALT(cm)) {
#endif // CONFIG_VAR_REFS
const int bit_bwd = mbmi->ref_frame[1] == ALTREF_FRAME;
aom_write(w, bit_bwd, av1_get_pred_prob_comp_bwdref_p(cm, xd));
WRITE_REF_BIT(bit_bwd, comp_bwdref_p);
#if CONFIG_VAR_REFS
}
#endif // CONFIG_VAR_REFS
#else // !CONFIG_EXT_REFS
const int bit = mbmi->ref_frame[0] == GOLDEN_FRAME;
aom_write(w, bit, av1_get_pred_prob_comp_ref_p(cm, xd));
WRITE_REF_BIT(bit, comp_ref_p);
#endif // CONFIG_EXT_REFS
} else {
#if CONFIG_EXT_REFS
......@@ -4960,7 +4960,10 @@ static uint32_t write_compressed_header(AV1_COMP *cpi, uint8_t *data) {
FRAME_CONTEXT *const fc = cm->fc;
FRAME_COUNTS *counts = cpi->td.counts;
aom_writer *header_bc;
int i, j;
int i;
#if !CONFIG_NEW_MULTISYMBOL
int j;
#endif
#if CONFIG_TILE_GROUPS
const int probwt = cm->num_tg;
......@@ -5182,6 +5185,7 @@ static uint32_t write_compressed_header(AV1_COMP *cpi, uint8_t *data) {
counts->uni_comp_ref[i][j], probwt);
#endif // CONFIG_EXT_COMP_REFS
#if !CONFIG_NEW_MULTISYMBOL
for (i = 0; i < REF_CONTEXTS; i++) {
#if CONFIG_EXT_REFS
for (j = 0; j < (FWD_REFS - 1); j++) {
......@@ -5199,6 +5203,7 @@ static uint32_t write_compressed_header(AV1_COMP *cpi, uint8_t *data) {
}
#endif // CONFIG_EXT_REFS
}
#endif // CONFIG_NEW_MULTISYMBOL
}
#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
......
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