Commit 9d0c03d6 authored by Hui Su's avatar Hui Su

Remove probablity model for the comp_inter flag

Change-Id: I7c7f193dea8e99be31d048b3fe2b198887a52822
parent 5ef90ceb
...@@ -1397,10 +1397,6 @@ static const aom_cdf_prob default_intra_inter_cdf[INTRA_INTER_CONTEXTS] ...@@ -1397,10 +1397,6 @@ static const aom_cdf_prob default_intra_inter_cdf[INTRA_INTER_CONTEXTS]
{ AOM_CDF2(26240) } { AOM_CDF2(26240) }
}; };
static const aom_prob default_comp_inter_p[COMP_INTER_CONTEXTS] = {
190, 156, 91, 77, 22
};
static const aom_cdf_prob default_comp_inter_cdf[COMP_INTER_CONTEXTS][CDF_SIZE( static const aom_cdf_prob default_comp_inter_cdf[COMP_INTER_CONTEXTS][CDF_SIZE(
2)] = { { AOM_CDF2(24290) }, 2)] = { { AOM_CDF2(24290) },
{ AOM_CDF2(19956) }, { AOM_CDF2(19956) },
...@@ -3302,7 +3298,6 @@ static const aom_cdf_prob default_angle_delta_cdf[DIRECTIONAL_MODES][CDF_SIZE( ...@@ -3302,7 +3298,6 @@ static const aom_cdf_prob default_angle_delta_cdf[DIRECTIONAL_MODES][CDF_SIZE(
#endif // CONFIG_EXT_INTRA_MOD #endif // CONFIG_EXT_INTRA_MOD
static void init_mode_probs(FRAME_CONTEXT *fc) { static void init_mode_probs(FRAME_CONTEXT *fc) {
av1_copy(fc->comp_inter_prob, default_comp_inter_p);
av1_copy(fc->palette_y_size_cdf, default_palette_y_size_cdf); av1_copy(fc->palette_y_size_cdf, default_palette_y_size_cdf);
av1_copy(fc->palette_uv_size_cdf, default_palette_uv_size_cdf); av1_copy(fc->palette_uv_size_cdf, default_palette_uv_size_cdf);
av1_copy(fc->palette_y_color_index_cdf, default_palette_y_color_index_cdf); av1_copy(fc->palette_y_color_index_cdf, default_palette_y_color_index_cdf);
...@@ -3417,10 +3412,6 @@ void av1_adapt_inter_frame_probs(AV1_COMMON *cm) { ...@@ -3417,10 +3412,6 @@ void av1_adapt_inter_frame_probs(AV1_COMMON *cm) {
const FRAME_CONTEXT *pre_fc = cm->pre_fc; const FRAME_CONTEXT *pre_fc = cm->pre_fc;
const FRAME_COUNTS *counts = &cm->counts; const FRAME_COUNTS *counts = &cm->counts;
for (i = 0; i < COMP_INTER_CONTEXTS; i++)
fc->comp_inter_prob[i] = av1_mode_mv_merge_probs(pre_fc->comp_inter_prob[i],
counts->comp_inter[i]);
#if CONFIG_EXT_COMP_REFS #if CONFIG_EXT_COMP_REFS
for (i = 0; i < COMP_REF_TYPE_CONTEXTS; i++) for (i = 0; i < COMP_REF_TYPE_CONTEXTS; i++)
fc->comp_ref_type_prob[i] = av1_mode_mv_merge_probs( fc->comp_ref_type_prob[i] = av1_mode_mv_merge_probs(
......
...@@ -147,7 +147,6 @@ typedef struct frame_contexts { ...@@ -147,7 +147,6 @@ typedef struct frame_contexts {
[CDF_SIZE(INTERINTRA_MODES)]; [CDF_SIZE(INTERINTRA_MODES)];
aom_cdf_prob motion_mode_cdf[BLOCK_SIZES_ALL][CDF_SIZE(MOTION_MODES)]; aom_cdf_prob motion_mode_cdf[BLOCK_SIZES_ALL][CDF_SIZE(MOTION_MODES)];
aom_cdf_prob obmc_cdf[BLOCK_SIZES_ALL][CDF_SIZE(2)]; aom_cdf_prob obmc_cdf[BLOCK_SIZES_ALL][CDF_SIZE(2)];
aom_prob comp_inter_prob[COMP_INTER_CONTEXTS];
aom_cdf_prob palette_y_size_cdf[PALATTE_BSIZE_CTXS][CDF_SIZE(PALETTE_SIZES)]; aom_cdf_prob palette_y_size_cdf[PALATTE_BSIZE_CTXS][CDF_SIZE(PALETTE_SIZES)];
aom_cdf_prob palette_uv_size_cdf[PALATTE_BSIZE_CTXS][CDF_SIZE(PALETTE_SIZES)]; aom_cdf_prob palette_uv_size_cdf[PALATTE_BSIZE_CTXS][CDF_SIZE(PALETTE_SIZES)];
aom_cdf_prob palette_y_color_index_cdf[PALETTE_SIZES] aom_cdf_prob palette_y_color_index_cdf[PALETTE_SIZES]
...@@ -320,7 +319,9 @@ typedef struct FRAME_COUNTS { ...@@ -320,7 +319,9 @@ typedef struct FRAME_COUNTS {
unsigned int motion_mode[BLOCK_SIZES_ALL][MOTION_MODES]; unsigned int motion_mode[BLOCK_SIZES_ALL][MOTION_MODES];
unsigned int obmc[BLOCK_SIZES_ALL][2]; unsigned int obmc[BLOCK_SIZES_ALL][2];
unsigned int intra_inter[INTRA_INTER_CONTEXTS][2]; unsigned int intra_inter[INTRA_INTER_CONTEXTS][2];
#if CONFIG_ENTROPY_STATS
unsigned int comp_inter[COMP_INTER_CONTEXTS][2]; unsigned int comp_inter[COMP_INTER_CONTEXTS][2];
#endif // CONFIG_ENTROPY_STATS
#if CONFIG_EXT_COMP_REFS #if CONFIG_EXT_COMP_REFS
unsigned int comp_ref_type[COMP_REF_TYPE_CONTEXTS][2]; unsigned int comp_ref_type[COMP_REF_TYPE_CONTEXTS][2];
unsigned int uni_comp_ref[UNI_COMP_REF_CONTEXTS][UNIDIR_COMP_REFS - 1][2]; unsigned int uni_comp_ref[UNI_COMP_REF_CONTEXTS][UNIDIR_COMP_REFS - 1][2];
......
...@@ -192,10 +192,6 @@ int av1_get_intra_inter_context(const MACROBLOCKD *xd); ...@@ -192,10 +192,6 @@ int av1_get_intra_inter_context(const MACROBLOCKD *xd);
int av1_get_reference_mode_context(const AV1_COMMON *cm, const MACROBLOCKD *xd); int av1_get_reference_mode_context(const AV1_COMMON *cm, const MACROBLOCKD *xd);
static INLINE aom_prob av1_get_reference_mode_prob(const AV1_COMMON *cm,
const MACROBLOCKD *xd) {
return cm->fc->comp_inter_prob[av1_get_reference_mode_context(cm, xd)];
}
static INLINE aom_cdf_prob *av1_get_reference_mode_cdf(const AV1_COMMON *cm, static INLINE aom_cdf_prob *av1_get_reference_mode_cdf(const AV1_COMMON *cm,
const MACROBLOCKD *xd) { const MACROBLOCKD *xd) {
return xd->tile_ctx->comp_inter_cdf[av1_get_reference_mode_context(cm, xd)]; return xd->tile_ctx->comp_inter_cdf[av1_get_reference_mode_context(cm, xd)];
......
...@@ -3137,8 +3137,6 @@ static void debug_check_frame_counts(const AV1_COMMON *const cm) { ...@@ -3137,8 +3137,6 @@ static void debug_check_frame_counts(const AV1_COMMON *const cm) {
sizeof(cm->counts.motion_mode))); sizeof(cm->counts.motion_mode)));
assert(!memcmp(cm->counts.intra_inter, zero_counts.intra_inter, assert(!memcmp(cm->counts.intra_inter, zero_counts.intra_inter,
sizeof(cm->counts.intra_inter))); sizeof(cm->counts.intra_inter)));
assert(!memcmp(cm->counts.comp_inter, zero_counts.comp_inter,
sizeof(cm->counts.comp_inter)));
#if CONFIG_EXT_COMP_REFS #if CONFIG_EXT_COMP_REFS
assert(!memcmp(cm->counts.comp_ref_type, zero_counts.comp_ref_type, assert(!memcmp(cm->counts.comp_ref_type, zero_counts.comp_ref_type,
sizeof(cm->counts.comp_ref_type))); sizeof(cm->counts.comp_ref_type)));
......
...@@ -1268,8 +1268,6 @@ static REFERENCE_MODE read_block_reference_mode(AV1_COMMON *cm, ...@@ -1268,8 +1268,6 @@ static REFERENCE_MODE read_block_reference_mode(AV1_COMMON *cm,
const int ctx = av1_get_reference_mode_context(cm, xd); const int ctx = av1_get_reference_mode_context(cm, xd);
const REFERENCE_MODE mode = (REFERENCE_MODE)aom_read_symbol( const REFERENCE_MODE mode = (REFERENCE_MODE)aom_read_symbol(
r, xd->tile_ctx->comp_inter_cdf[ctx], 2, ACCT_STR); r, xd->tile_ctx->comp_inter_cdf[ctx], 2, ACCT_STR);
FRAME_COUNTS *counts = xd->counts;
if (counts) ++counts->comp_inter[ctx][mode];
return mode; // SINGLE_REFERENCE or COMPOUND_REFERENCE return mode; // SINGLE_REFERENCE or COMPOUND_REFERENCE
} else { } else {
#if CONFIG_REF_ADAPT #if CONFIG_REF_ADAPT
......
...@@ -283,6 +283,7 @@ struct macroblock { ...@@ -283,6 +283,7 @@ struct macroblock {
int refmv_mode_cost[REFMV_MODE_CONTEXTS][2]; int refmv_mode_cost[REFMV_MODE_CONTEXTS][2];
int drl_mode_cost0[DRL_MODE_CONTEXTS][2]; int drl_mode_cost0[DRL_MODE_CONTEXTS][2];
int comp_inter_cost[COMP_INTER_CONTEXTS][2];
int inter_compound_mode_cost[INTER_MODE_CONTEXTS][INTER_COMPOUND_MODES]; int inter_compound_mode_cost[INTER_MODE_CONTEXTS][INTER_COMPOUND_MODES];
#if CONFIG_JNT_COMP #if CONFIG_JNT_COMP
int compound_type_cost[BLOCK_SIZES_ALL][COMPOUND_TYPES - 1]; int compound_type_cost[BLOCK_SIZES_ALL][COMPOUND_TYPES - 1];
......
...@@ -885,8 +885,10 @@ static void update_stats(const AV1_COMMON *const cm, TileDataEnc *tile_data, ...@@ -885,8 +885,10 @@ static void update_stats(const AV1_COMMON *const cm, TileDataEnc *tile_data,
rdc->single_ref_used_flag = 1; rdc->single_ref_used_flag = 1;
#endif // !CONFIG_REF_ADAPT #endif // !CONFIG_REF_ADAPT
if (is_comp_ref_allowed(bsize)) { if (is_comp_ref_allowed(bsize)) {
#if CONFIG_ENTROPY_STATS
counts->comp_inter[av1_get_reference_mode_context(cm, xd)] counts->comp_inter[av1_get_reference_mode_context(cm, xd)]
[has_second_ref(mbmi)]++; [has_second_ref(mbmi)]++;
#endif // CONFIG_ENTROPY_STATS
if (allow_update_cdf) if (allow_update_cdf)
update_cdf(av1_get_reference_mode_cdf(cm, xd), update_cdf(av1_get_reference_mode_cdf(cm, xd),
has_second_ref(mbmi), 2); has_second_ref(mbmi), 2);
...@@ -3906,7 +3908,6 @@ void av1_encode_frame(AV1_COMP *cpi) { ...@@ -3906,7 +3908,6 @@ void av1_encode_frame(AV1_COMP *cpi) {
if (cpi->sf.frame_parameter_update) { if (cpi->sf.frame_parameter_update) {
int i; int i;
RD_OPT *const rd_opt = &cpi->rd; RD_OPT *const rd_opt = &cpi->rd;
FRAME_COUNTS *counts = cpi->td.counts;
RD_COUNTS *const rdc = &cpi->td.rd_counts; RD_COUNTS *const rdc = &cpi->td.rd_counts;
// This code does a single RD pass over the whole frame assuming // This code does a single RD pass over the whole frame assuming
...@@ -3961,12 +3962,16 @@ void av1_encode_frame(AV1_COMP *cpi) { ...@@ -3961,12 +3962,16 @@ void av1_encode_frame(AV1_COMP *cpi) {
// Use a flag that includes 4x4 blocks // Use a flag that includes 4x4 blocks
if (rdc->compound_ref_used_flag == 0) { if (rdc->compound_ref_used_flag == 0) {
cm->reference_mode = SINGLE_REFERENCE; cm->reference_mode = SINGLE_REFERENCE;
av1_zero(counts->comp_inter); #if CONFIG_ENTROPY_STATS
av1_zero(cpi->td.counts->comp_inter);
#endif // CONFIG_ENTROPY_STATS
#if !CONFIG_REF_ADAPT #if !CONFIG_REF_ADAPT
// Use a flag that includes 4x4 blocks // Use a flag that includes 4x4 blocks
} else if (rdc->single_ref_used_flag == 0) { } else if (rdc->single_ref_used_flag == 0) {
cm->reference_mode = COMPOUND_REFERENCE; cm->reference_mode = COMPOUND_REFERENCE;
av1_zero(counts->comp_inter); #if CONFIG_ENTROPY_STATS
av1_zero(cpi->td.counts->comp_inter);
#endif // CONFIG_ENTROPY_STATS
#endif // !CONFIG_REF_ADAPT #endif // !CONFIG_REF_ADAPT
} }
} }
......
...@@ -226,6 +226,11 @@ void av1_fill_mode_rates(AV1_COMMON *const cm, MACROBLOCK *x, ...@@ -226,6 +226,11 @@ void av1_fill_mode_rates(AV1_COMMON *const cm, MACROBLOCK *x,
#endif // CONFIG_INTRABC #endif // CONFIG_INTRABC
if (!frame_is_intra_only(cm)) { if (!frame_is_intra_only(cm)) {
for (i = 0; i < COMP_INTER_CONTEXTS; ++i) {
av1_cost_tokens_from_cdf(x->comp_inter_cost[i], fc->comp_inter_cdf[i],
NULL);
}
for (i = 0; i < INTRA_INTER_CONTEXTS; ++i) { for (i = 0; i < INTRA_INTER_CONTEXTS; ++i) {
av1_cost_tokens_from_cdf(x->intra_inter_cost[i], fc->intra_inter_cdf[i], av1_cost_tokens_from_cdf(x->intra_inter_cost[i], fc->intra_inter_cdf[i],
NULL); NULL);
......
...@@ -5785,11 +5785,11 @@ static void estimate_ref_frame_costs( ...@@ -5785,11 +5785,11 @@ static void estimate_ref_frame_costs(
const AV1_COMMON *cm, const MACROBLOCKD *xd, const MACROBLOCK *x, const AV1_COMMON *cm, const MACROBLOCKD *xd, const MACROBLOCK *x,
int segment_id, unsigned int *ref_costs_single, int segment_id, unsigned int *ref_costs_single,
#if CONFIG_EXT_COMP_REFS #if CONFIG_EXT_COMP_REFS
unsigned int (*ref_costs_comp)[TOTAL_REFS_PER_FRAME], unsigned int (*ref_costs_comp)[TOTAL_REFS_PER_FRAME]
#else #else
unsigned int *ref_costs_comp, unsigned int *ref_costs_comp
#endif // CONFIG_EXT_COMP_REFS #endif // CONFIG_EXT_COMP_REFS
aom_prob *comp_mode_p) { ) {
int seg_ref_active = int seg_ref_active =
segfeature_active(&cm->seg, segment_id, SEG_LVL_REF_FRAME); segfeature_active(&cm->seg, segment_id, SEG_LVL_REF_FRAME);
if (seg_ref_active) { if (seg_ref_active) {
...@@ -5803,19 +5803,9 @@ static void estimate_ref_frame_costs( ...@@ -5803,19 +5803,9 @@ static void estimate_ref_frame_costs(
#else #else
memset(ref_costs_comp, 0, TOTAL_REFS_PER_FRAME * sizeof(*ref_costs_comp)); memset(ref_costs_comp, 0, TOTAL_REFS_PER_FRAME * sizeof(*ref_costs_comp));
#endif // CONFIG_EXT_COMP_REFS #endif // CONFIG_EXT_COMP_REFS
*comp_mode_p = 128;
} else { } else {
int intra_inter_ctx = av1_get_intra_inter_context(xd); int intra_inter_ctx = av1_get_intra_inter_context(xd);
if (cm->reference_mode == REFERENCE_MODE_SELECT) {
*comp_mode_p = av1_get_reference_mode_prob(cm, xd);
} else {
*comp_mode_p = 128;
}
ref_costs_single[INTRA_FRAME] = x->intra_inter_cost[intra_inter_ctx][0]; ref_costs_single[INTRA_FRAME] = x->intra_inter_cost[intra_inter_ctx][0];
unsigned int base_cost = x->intra_inter_cost[intra_inter_ctx][1]; unsigned int base_cost = x->intra_inter_cost[intra_inter_ctx][1];
#if !CONFIG_REF_ADAPT #if !CONFIG_REF_ADAPT
...@@ -8843,7 +8833,8 @@ void av1_rd_pick_inter_mode_sb(const AV1_COMP *cpi, TileDataEnc *tile_data, ...@@ -8843,7 +8833,8 @@ void av1_rd_pick_inter_mode_sb(const AV1_COMP *cpi, TileDataEnc *tile_data,
#else #else
unsigned int ref_costs_comp[TOTAL_REFS_PER_FRAME]; unsigned int ref_costs_comp[TOTAL_REFS_PER_FRAME];
#endif // CONFIG_EXT_COMP_REFS #endif // CONFIG_EXT_COMP_REFS
aom_prob comp_mode_p; int *comp_inter_cost =
x->comp_inter_cost[av1_get_reference_mode_context(cm, xd)];
int64_t best_intra_rd = INT64_MAX; int64_t best_intra_rd = INT64_MAX;
unsigned int best_pred_sse = UINT_MAX; unsigned int best_pred_sse = UINT_MAX;
PREDICTION_MODE best_intra_mode = DC_PRED; PREDICTION_MODE best_intra_mode = DC_PRED;
...@@ -8927,7 +8918,7 @@ void av1_rd_pick_inter_mode_sb(const AV1_COMP *cpi, TileDataEnc *tile_data, ...@@ -8927,7 +8918,7 @@ void av1_rd_pick_inter_mode_sb(const AV1_COMP *cpi, TileDataEnc *tile_data,
} }
estimate_ref_frame_costs(cm, xd, x, segment_id, ref_costs_single, estimate_ref_frame_costs(cm, xd, x, segment_id, ref_costs_single,
ref_costs_comp, &comp_mode_p); ref_costs_comp);
for (i = 0; i < REFERENCE_MODES; ++i) best_pred_rd[i] = INT64_MAX; for (i = 0; i < REFERENCE_MODES; ++i) best_pred_rd[i] = INT64_MAX;
for (i = 0; i < TX_SIZES_ALL; i++) rate_uv_intra[i] = INT_MAX; for (i = 0; i < TX_SIZES_ALL; i++) rate_uv_intra[i] = INT_MAX;
...@@ -9919,7 +9910,7 @@ void av1_rd_pick_inter_mode_sb(const AV1_COMP *cpi, TileDataEnc *tile_data, ...@@ -9919,7 +9910,7 @@ void av1_rd_pick_inter_mode_sb(const AV1_COMP *cpi, TileDataEnc *tile_data,
if (this_rd == INT64_MAX) continue; if (this_rd == INT64_MAX) continue;
if (is_comp_ref_allowed(mbmi->sb_type)) if (is_comp_ref_allowed(mbmi->sb_type))
compmode_cost = av1_cost_bit(comp_mode_p, comp_pred); compmode_cost = comp_inter_cost[comp_pred];
if (cm->reference_mode == REFERENCE_MODE_SELECT) rate2 += compmode_cost; if (cm->reference_mode == REFERENCE_MODE_SELECT) rate2 += compmode_cost;
} }
...@@ -10567,7 +10558,8 @@ void av1_rd_pick_inter_mode_sb_seg_skip(const AV1_COMP *cpi, ...@@ -10567,7 +10558,8 @@ void av1_rd_pick_inter_mode_sb_seg_skip(const AV1_COMP *cpi,
#else #else
unsigned int ref_costs_comp[TOTAL_REFS_PER_FRAME]; unsigned int ref_costs_comp[TOTAL_REFS_PER_FRAME];
#endif // CONFIG_EXT_COMP_REFS #endif // CONFIG_EXT_COMP_REFS
aom_prob comp_mode_p; int *comp_inter_cost =
x->comp_inter_cost[av1_get_reference_mode_context(cm, xd)];
InterpFilter best_filter = SWITCHABLE; InterpFilter best_filter = SWITCHABLE;
int64_t this_rd = INT64_MAX; int64_t this_rd = INT64_MAX;
int rate2 = 0; int rate2 = 0;
...@@ -10576,7 +10568,7 @@ void av1_rd_pick_inter_mode_sb_seg_skip(const AV1_COMP *cpi, ...@@ -10576,7 +10568,7 @@ void av1_rd_pick_inter_mode_sb_seg_skip(const AV1_COMP *cpi,
(void)mi_col; (void)mi_col;
estimate_ref_frame_costs(cm, xd, x, segment_id, ref_costs_single, estimate_ref_frame_costs(cm, xd, x, segment_id, ref_costs_single,
ref_costs_comp, &comp_mode_p); ref_costs_comp);
for (i = 0; i < TOTAL_REFS_PER_FRAME; ++i) x->pred_sse[i] = INT_MAX; for (i = 0; i < TOTAL_REFS_PER_FRAME; ++i) x->pred_sse[i] = INT_MAX;
for (i = LAST_FRAME; i < TOTAL_REFS_PER_FRAME; ++i) for (i = LAST_FRAME; i < TOTAL_REFS_PER_FRAME; ++i)
...@@ -10657,7 +10649,7 @@ void av1_rd_pick_inter_mode_sb_seg_skip(const AV1_COMP *cpi, ...@@ -10657,7 +10649,7 @@ void av1_rd_pick_inter_mode_sb_seg_skip(const AV1_COMP *cpi,
rate2 += av1_get_switchable_rate(cm, x, xd); rate2 += av1_get_switchable_rate(cm, x, xd);
if (cm->reference_mode == REFERENCE_MODE_SELECT) if (cm->reference_mode == REFERENCE_MODE_SELECT)
rate2 += av1_cost_bit(comp_mode_p, comp_pred); rate2 += comp_inter_cost[comp_pred];
// Estimate the reference frame signaling cost and add it // Estimate the reference frame signaling cost and add it
// to the rolling cost variable. // to the rolling cost variable.
......
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