Commit 46970619 authored by Cheng Chen's avatar Cheng Chen

JNT_COMP: Support new_multisymbol

Support cdf for jnt_comp read/write.

Change-Id: I2c29277a8b06b3e9f571355946b70ce0d492fbb2
parent 267e3272
......@@ -1824,4 +1824,9 @@ void av1_average_tile_inter_cdfs(AV1_COMMON *cm, FRAME_CONTEXT *fc,
int j;
for (j = 0; j < Q_SEGMENT_CDF_COUNT; j++) AVERAGE_TILE_CDFS(seg.q_seg_cdf[j]);
#endif
#if CONFIG_JNT_COMP
#if CONFIG_NEW_MULTISYMBOL
AVERAGE_TILE_CDFS(compound_index_cdf);
#endif // CONFIG_NEW_MULTISYMBOL
#endif // CONFIG_JNT_COMP
}
......@@ -1652,6 +1652,20 @@ static const aom_prob default_skip_probs[SKIP_CONTEXTS] = { 192, 128, 64 };
#endif // CONFIG_NEW_MULTISYMBOL
#if CONFIG_JNT_COMP
#if CONFIG_NEW_MULTISYMBOL
static const aom_cdf_prob
default_compound_idx_cdfs[COMP_INDEX_CONTEXTS][CDF_SIZE(2)] = {
{ AOM_ICDF(24576), AOM_ICDF(32768), 0 },
{ AOM_ICDF(16384), AOM_ICDF(32768), 0 },
{ AOM_ICDF(8192), AOM_ICDF(32768), 0 },
{ AOM_ICDF(24576), AOM_ICDF(32768), 0 },
{ AOM_ICDF(16384), AOM_ICDF(32768), 0 },
{ AOM_ICDF(8192), AOM_ICDF(32768), 0 },
{ AOM_ICDF(24576), AOM_ICDF(32768), 0 },
{ AOM_ICDF(16384), AOM_ICDF(32768), 0 },
{ AOM_ICDF(8192), AOM_ICDF(32768), 0 }
};
#endif // CONFIG_NEW_MULTISYMBOL
static const aom_prob default_compound_idx_probs[COMP_INDEX_CONTEXTS] = {
192, 128, 64, 192, 128, 64, 192, 128, 64,
};
......@@ -3446,6 +3460,9 @@ static void init_mode_probs(FRAME_CONTEXT *fc) {
av1_copy(fc->txfm_partition_cdf, default_txfm_partition_cdf);
#endif
#if CONFIG_JNT_COMP
#if CONFIG_NEW_MULTISYMBOL
av1_copy(fc->compound_index_cdf, default_compound_idx_cdfs);
#endif // CONFIG_NEW_MULTISYMBOL
av1_copy(fc->compound_index_probs, default_compound_idx_probs);
#endif // CONFIG_JNT_COMP
av1_copy(fc->newmv_prob, default_newmv_prob);
......
......@@ -266,6 +266,9 @@ typedef struct frame_contexts {
aom_cdf_prob txfm_partition_cdf[TXFM_PARTITION_CONTEXTS][CDF_SIZE(2)];
#endif
#if CONFIG_JNT_COMP
#if CONFIG_NEW_MULTISYMBOL
aom_cdf_prob compound_index_cdf[COMP_INDEX_CONTEXTS][CDF_SIZE(2)];
#endif // CONFIG_NEW_MULTISYMBOL
aom_prob compound_index_probs[COMP_INDEX_CONTEXTS];
#endif // CONFIG_JNT_COMP
#if CONFIG_NEW_MULTISYMBOL
......
......@@ -2161,8 +2161,13 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi,
#if CONFIG_JNT_COMP
if (has_two_sided_comp_refs(cm, mbmi)) {
const int comp_index_ctx = get_comp_index_context(cm, xd);
#if CONFIG_NEW_MULTISYMBOL
mbmi->compound_idx = aom_read_symbol(
r, ec_ctx->compound_index_cdf[comp_index_ctx], 2, ACCT_STR);
#else
mbmi->compound_idx =
aom_read(r, ec_ctx->compound_index_probs[comp_index_ctx], ACCT_STR);
#endif // CONFIG_NEW_MULTISYMBOL
if (xd->counts)
++xd->counts->compound_index[comp_index_ctx][mbmi->compound_idx];
} else {
......
......@@ -1497,11 +1497,19 @@ static void pack_inter_mode_mvs(AV1_COMP *cpi, const int mi_row,
write_ref_frames(cm, xd, w);
#if CONFIG_JNT_COMP
#if CONFIG_NEW_MULTISYMBOL
if (has_two_sided_comp_refs(cm, mbmi)) {
const int comp_index_ctx = get_comp_index_context(cm, xd);
aom_write_symbol(w, mbmi->compound_idx,
ec_ctx->compound_index_cdf[comp_index_ctx], 2);
}
#else
if (has_two_sided_comp_refs(cm, mbmi)) {
const int comp_index_ctx = get_comp_index_context(cm, xd);
aom_write(w, mbmi->compound_idx,
ec_ctx->compound_index_probs[comp_index_ctx]);
}
#endif // CONFIG_NEW_MULTISYMBOL
#endif // CONFIG_JNT_COMP
#if CONFIG_COMPOUND_SINGLEREF
......
......@@ -301,6 +301,9 @@ struct macroblock {
DECLARE_ALIGNED(16, uint8_t, decoded_8x8[8 * 8]);
#endif
#endif // CONFIG_DIST_8X8
#if CONFIG_JNT_COMP
int comp_idx_cost[COMP_INDEX_CONTEXTS][2];
#endif // CONFIG_JNT_COMP
};
#ifdef __cplusplus
......
......@@ -608,10 +608,12 @@ static void update_state(const AV1_COMP *const cpi, TileDataEnc *tile_data,
av1_copy_frame_mvs(cm, mi, mi_row, mi_col, x_mis, y_mis);
#if CONFIG_JNT_COMP
#if !CONFIG_NEW_MULTISYMBOL
if (has_two_sided_comp_refs(cm, mbmi)) {
const int comp_index_ctx = get_comp_index_context(cm, xd);
++td->counts->compound_index[comp_index_ctx][mbmi->compound_idx];
}
#endif // CONFIG_NEW_MULTISYMBOL
#endif // CONFIG_JNT_COMP
}
......@@ -1284,6 +1286,17 @@ static void update_stats(const AV1_COMMON *const cm, TileDataEnc *tile_data,
}
}
}
#if CONFIG_JNT_COMP
#if CONFIG_NEW_MULTISYMBOL
if (has_second_ref(mbmi)) {
const int comp_index_ctx = get_comp_index_context(cm, xd);
++counts->compound_index[comp_index_ctx][mbmi->compound_idx];
update_cdf(fc->compound_index_cdf[comp_index_ctx], mbmi->compound_idx,
2);
}
#endif // CONFIG_NEW_MULTISYMBOL
#endif // CONFIG_JNT_COMP
}
}
}
......
......@@ -379,6 +379,17 @@ void av1_fill_mode_rates(AV1_COMMON *const cm, MACROBLOCK *x,
x->motion_mode_cost1[i][1] = av1_cost_bit(fc->obmc_prob[i], 1);
#endif
}
#if CONFIG_JNT_COMP
for (i = 0; i < COMP_INDEX_CONTEXTS; ++i) {
#if CONFIG_NEW_MULTISYMBOL
av1_cost_tokens_from_cdf(x->comp_idx_cost[i], fc->compound_index_cdf[i],
NULL);
#else
x->comp_idx_cost[i][0] = av1_cost_bit(fc->compound_index_probs[i], 0);
x->comp_idx_cost[i][1] = av1_cost_bit(fc->compound_index_probs[i], 1);
#endif // CONFIG_NEW_MULTISYMBOL
}
#endif // CONFIG_JNT_COMP
}
}
......
......@@ -8249,8 +8249,7 @@ static int64_t handle_inter_mode(const AV1_COMP *const cpi, MACROBLOCK *x,
#if CONFIG_JNT_COMP
if (has_two_sided_comp_refs(cm, mbmi)) {
const int comp_index_ctx = get_comp_index_context(cm, xd);
rd_stats->rate += av1_cost_bit(cm->fc->compound_index_probs[comp_index_ctx],
mbmi->compound_idx);
rd_stats->rate += x->comp_idx_cost[comp_index_ctx][mbmi->compound_idx];
}
#endif // CONFIG_JNT_COMP
......
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