Commit a7e3bfe1 authored by Hui Su's avatar Hui Su Committed by Sebastien Alaiwan
Browse files

Remove probability model for uni_comp_ref

Change-Id: I7c09b63aadefef3350d713e03b822447c9472509
parent ac123e07
......@@ -1405,11 +1405,6 @@ static const aom_cdf_prob default_comp_inter_cdf[COMP_INTER_CONTEXTS][CDF_SIZE(
{ AOM_CDF2(2842) } };
#if CONFIG_EXT_COMP_REFS
static const aom_prob
default_uni_comp_ref_p[UNI_COMP_REF_CONTEXTS][UNIDIR_COMP_REFS - 1] = {
{ 88, 30, 28 }, { 218, 97, 105 }, { 254, 180, 196 }
};
static const aom_cdf_prob default_comp_ref_type_cdf[COMP_REF_TYPE_CONTEXTS]
[CDF_SIZE(2)] = {
{ AOM_CDF2(8 * 128) },
......@@ -3280,7 +3275,6 @@ static void init_mode_probs(FRAME_CONTEXT *fc) {
#endif // CONFIG_EXT_INTRA_MOD
av1_copy(fc->comp_inter_cdf, default_comp_inter_cdf);
#if CONFIG_EXT_COMP_REFS
av1_copy(fc->uni_comp_ref_prob, default_uni_comp_ref_p);
av1_copy(fc->comp_ref_type_cdf, default_comp_ref_type_cdf);
av1_copy(fc->uni_comp_ref_cdf, default_uni_comp_ref_cdf);
#endif // CONFIG_EXT_COMP_REFS
......@@ -3382,13 +3376,6 @@ void av1_adapt_inter_frame_probs(AV1_COMMON *cm) {
const FRAME_CONTEXT *pre_fc = cm->pre_fc;
const FRAME_COUNTS *counts = &cm->counts;
#if CONFIG_EXT_COMP_REFS
for (i = 0; i < UNI_COMP_REF_CONTEXTS; i++)
for (j = 0; j < (UNIDIR_COMP_REFS - 1); j++)
fc->uni_comp_ref_prob[i][j] = av1_mode_mv_merge_probs(
pre_fc->uni_comp_ref_prob[i][j], counts->uni_comp_ref[i][j]);
#endif // CONFIG_EXT_COMP_REFS
for (i = 0; i < REF_CONTEXTS; i++)
for (j = 0; j < (FWD_REFS - 1); j++)
fc->comp_ref_prob[i][j] = mode_mv_merge_probs(pre_fc->comp_ref_prob[i][j],
......
......@@ -161,7 +161,6 @@ typedef struct frame_contexts {
aom_cdf_prob comp_inter_cdf[COMP_INTER_CONTEXTS][CDF_SIZE(2)];
aom_cdf_prob single_ref_cdf[REF_CONTEXTS][SINGLE_REFS - 1][CDF_SIZE(2)];
#if CONFIG_EXT_COMP_REFS
aom_prob uni_comp_ref_prob[UNI_COMP_REF_CONTEXTS][UNIDIR_COMP_REFS - 1];
aom_cdf_prob comp_ref_type_cdf[COMP_REF_TYPE_CONTEXTS][CDF_SIZE(2)];
aom_cdf_prob uni_comp_ref_cdf[UNI_COMP_REF_CONTEXTS][UNIDIR_COMP_REFS - 1]
[CDF_SIZE(2)];
......@@ -319,13 +318,11 @@ typedef struct FRAME_COUNTS {
unsigned int intra_inter[INTRA_INTER_CONTEXTS][2];
#if CONFIG_ENTROPY_STATS
unsigned int comp_inter[COMP_INTER_CONTEXTS][2];
#endif // CONFIG_ENTROPY_STATS
#if CONFIG_EXT_COMP_REFS
#if CONFIG_ENTROPY_STATS
unsigned int comp_ref_type[COMP_REF_TYPE_CONTEXTS][2];
#endif // CONFIG_ENTROPY_STATS
unsigned int uni_comp_ref[UNI_COMP_REF_CONTEXTS][UNIDIR_COMP_REFS - 1][2];
#endif // CONFIG_EXT_COMP_REFS
#endif // CONFIG_ENTROPY_STATS
#if CONFIG_ENTROPY_STATS
unsigned int single_ref[REF_CONTEXTS][SINGLE_REFS - 1][2];
#endif // CONFIG_ENTROPY_STATS
......
......@@ -202,28 +202,10 @@ int av1_get_comp_reference_type_context(const MACROBLOCKD *xd);
int av1_get_pred_context_uni_comp_ref_p(const MACROBLOCKD *xd);
static INLINE aom_prob av1_get_pred_prob_uni_comp_ref_p(const AV1_COMMON *cm,
const MACROBLOCKD *xd) {
const int pred_context = av1_get_pred_context_uni_comp_ref_p(xd);
return cm->fc->uni_comp_ref_prob[pred_context][0];
}
int av1_get_pred_context_uni_comp_ref_p1(const MACROBLOCKD *xd);
static INLINE aom_prob
av1_get_pred_prob_uni_comp_ref_p1(const AV1_COMMON *cm, const MACROBLOCKD *xd) {
const int pred_context = av1_get_pred_context_uni_comp_ref_p1(xd);
return cm->fc->uni_comp_ref_prob[pred_context][1];
}
int av1_get_pred_context_uni_comp_ref_p2(const MACROBLOCKD *xd);
static INLINE aom_prob
av1_get_pred_prob_uni_comp_ref_p2(const AV1_COMMON *cm, const MACROBLOCKD *xd) {
const int pred_context = av1_get_pred_context_uni_comp_ref_p2(xd);
return cm->fc->uni_comp_ref_prob[pred_context][2];
}
static INLINE aom_cdf_prob *av1_get_comp_reference_type_cdf(
const MACROBLOCKD *xd) {
const int pred_context = av1_get_comp_reference_type_context(xd);
......
......@@ -3125,10 +3125,6 @@ static void debug_check_frame_counts(const AV1_COMMON *const cm) {
sizeof(cm->counts.motion_mode)));
assert(!memcmp(cm->counts.intra_inter, zero_counts.intra_inter,
sizeof(cm->counts.intra_inter)));
#if CONFIG_EXT_COMP_REFS
assert(!memcmp(cm->counts.uni_comp_ref, zero_counts.uni_comp_ref,
sizeof(cm->counts.uni_comp_ref)));
#endif // CONFIG_EXT_COMP_REFS
assert(!memcmp(cm->counts.comp_ref, zero_counts.comp_ref,
sizeof(cm->counts.comp_ref)));
assert(!memcmp(cm->counts.comp_bwdref, zero_counts.comp_bwdref,
......
......@@ -1336,23 +1336,14 @@ static void read_ref_frames(AV1_COMMON *const cm, MACROBLOCKD *const xd,
const COMP_REFERENCE_TYPE comp_ref_type = read_comp_reference_type(xd, r);
if (comp_ref_type == UNIDIR_COMP_REFERENCE) {
const int ctx = av1_get_pred_context_uni_comp_ref_p(xd);
const int bit = READ_REF_BIT2(uni_comp_ref_p);
if (counts) ++counts->uni_comp_ref[ctx][0][bit];
if (bit) {
ref_frame[0] = BWDREF_FRAME;
ref_frame[1] = ALTREF_FRAME;
} else {
const int ctx1 = av1_get_pred_context_uni_comp_ref_p1(xd);
const int bit1 = READ_REF_BIT2(uni_comp_ref_p1);
if (counts) ++counts->uni_comp_ref[ctx1][1][bit1];
if (bit1) {
const int ctx2 = av1_get_pred_context_uni_comp_ref_p2(xd);
const int bit2 = READ_REF_BIT2(uni_comp_ref_p2);
if (counts) ++counts->uni_comp_ref[ctx2][2][bit2];
if (bit2) {
ref_frame[0] = LAST_FRAME;
ref_frame[1] = GOLDEN_FRAME;
......
......@@ -288,6 +288,8 @@ struct macroblock {
#if CONFIG_EXT_COMP_REFS
int comp_ref_type_cost[COMP_REF_TYPE_CONTEXTS]
[CDF_SIZE(COMP_REFERENCE_TYPES)];
int uni_comp_ref_cost[UNI_COMP_REF_CONTEXTS][UNIDIR_COMP_REFS - 1]
[CDF_SIZE(2)];
#endif // CONFIG_EXT_COMP_REFS
int inter_compound_mode_cost[INTER_MODE_CONTEXTS][INTER_COMPOUND_MODES];
#if CONFIG_JNT_COMP
......
......@@ -912,15 +912,29 @@ static void update_stats(const AV1_COMMON *const cm, TileDataEnc *tile_data,
if (comp_ref_type == UNIDIR_COMP_REFERENCE) {
const int bit = (ref0 == BWDREF_FRAME);
if (allow_update_cdf)
update_cdf(av1_get_pred_cdf_uni_comp_ref_p(xd), bit, 2);
#if CONFIG_ENTROPY_STATS
counts->uni_comp_ref[av1_get_pred_context_uni_comp_ref_p(xd)][0]
[bit]++;
#endif // CONFIG_ENTROPY_STATS
if (!bit) {
const int bit1 = (ref1 == LAST3_FRAME || ref1 == GOLDEN_FRAME);
if (allow_update_cdf)
update_cdf(av1_get_pred_cdf_uni_comp_ref_p1(xd), bit1, 2);
#if CONFIG_ENTROPY_STATS
counts->uni_comp_ref[av1_get_pred_context_uni_comp_ref_p1(xd)][1]
[bit1]++;
#endif // CONFIG_ENTROPY_STATS
if (bit1) {
if (allow_update_cdf) {
update_cdf(av1_get_pred_cdf_uni_comp_ref_p2(xd),
ref1 == GOLDEN_FRAME, 2);
}
#if CONFIG_ENTROPY_STATS
counts->uni_comp_ref[av1_get_pred_context_uni_comp_ref_p2(xd)]
[2][ref1 == GOLDEN_FRAME]++;
#endif // CONFIG_ENTROPY_STATS
}
}
} else {
......
......@@ -243,6 +243,13 @@ void av1_fill_mode_rates(AV1_COMMON *const cm, MACROBLOCK *x,
av1_cost_tokens_from_cdf(x->comp_ref_type_cost[i],
fc->comp_ref_type_cdf[i], NULL);
}
for (i = 0; i < UNI_COMP_REF_CONTEXTS; ++i) {
for (j = 0; j < UNIDIR_COMP_REFS - 1; ++j) {
av1_cost_tokens_from_cdf(x->uni_comp_ref_cost[i][j],
fc->uni_comp_ref_cdf[i][j], NULL);
}
}
#endif // CONFIG_EXT_COMP_REFS
for (i = 0; i < INTRA_INTER_CONTEXTS; ++i) {
......
......@@ -5919,25 +5919,26 @@ static void estimate_ref_frame_costs(
}
}
aom_prob uni_comp_ref_p = av1_get_pred_prob_uni_comp_ref_p(cm, xd);
aom_prob uni_comp_ref_p1 = av1_get_pred_prob_uni_comp_ref_p1(cm, xd);
aom_prob uni_comp_ref_p2 = av1_get_pred_prob_uni_comp_ref_p2(cm, xd);
const int uni_comp_ref_ctx_p = av1_get_pred_context_uni_comp_ref_p(xd);
const int uni_comp_ref_ctx_p1 = av1_get_pred_context_uni_comp_ref_p1(xd);
const int uni_comp_ref_ctx_p2 = av1_get_pred_context_uni_comp_ref_p2(xd);
ref_costs_comp[LAST_FRAME][LAST2_FRAME] =
base_cost + x->comp_ref_type_cost[comp_ref_type_ctx][0] +
av1_cost_bit(uni_comp_ref_p, 0) + av1_cost_bit(uni_comp_ref_p1, 0);
x->uni_comp_ref_cost[uni_comp_ref_ctx_p][0][0] +
x->uni_comp_ref_cost[uni_comp_ref_ctx_p1][1][0];
ref_costs_comp[LAST_FRAME][LAST3_FRAME] =
base_cost + x->comp_ref_type_cost[comp_ref_type_ctx][0] +
av1_cost_bit(uni_comp_ref_p, 0) + av1_cost_bit(uni_comp_ref_p1, 1) +
av1_cost_bit(uni_comp_ref_p2, 0);
x->uni_comp_ref_cost[uni_comp_ref_ctx_p][0][0] +
x->uni_comp_ref_cost[uni_comp_ref_ctx_p1][1][1] +
x->uni_comp_ref_cost[uni_comp_ref_ctx_p2][2][0];
ref_costs_comp[LAST_FRAME][GOLDEN_FRAME] =
base_cost + x->comp_ref_type_cost[comp_ref_type_ctx][0] +
av1_cost_bit(uni_comp_ref_p, 0) + av1_cost_bit(uni_comp_ref_p1, 1) +
av1_cost_bit(uni_comp_ref_p2, 1);
x->uni_comp_ref_cost[uni_comp_ref_ctx_p][0][0] +
x->uni_comp_ref_cost[uni_comp_ref_ctx_p1][1][1] +
x->uni_comp_ref_cost[uni_comp_ref_ctx_p2][2][1];
ref_costs_comp[BWDREF_FRAME][ALTREF_FRAME] =
base_cost + x->comp_ref_type_cost[comp_ref_type_ctx][0] +
av1_cost_bit(uni_comp_ref_p, 1);
x->uni_comp_ref_cost[uni_comp_ref_ctx_p][0][1];
#else // !CONFIG_EXT_COMP_REFS
ref_costs_comp[LAST_FRAME] = ref_costs_comp[LAST2_FRAME] =
......
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