Commit 3b353474 authored by Zoe Liu's avatar Zoe Liu

[NORMATIVE] Unify context design for single ref

The CL makes the context design for single reference frame coding the
same as that for the compound reference frame coding. There are 3
contexts designed for each of the binary symbols for the single
reference frame scenario, and the designed contexts simply rely on the
counts of the references used in the neighboring two blocks.

Once this CL is merged, the coding of the reference frames, regardless
of single prediction or compound prediction, will all follow the same
context design pattern for all the binary symbols. The design logic is
much simpler and the lines of code for each binary symbol context
identification are reduced by 80%.

Further, this CL has obtained a small coding gain for 30 frames with
the default coding tools:

lowres: avg_psnr -0.015%; ovr_psnr -0.021%; ssim -0.002%
midres: avg_psnr -0.108%; ovr_psnr -0.139%; ssim -0.135%

BUG=aomedia:1402
BUG=aomedia:973

Change-Id: Ia72a1d18e85ac3a05308675b60b95f80f2219c46
parent 3ffa0fef
......@@ -235,51 +235,40 @@ static const aom_cdf_prob
#endif // CONFIG_EXT_COMP_REFS
static const aom_cdf_prob
default_comp_ref_cdf[COMP_REF_CONTEXTS][FWD_REFS - 1][CDF_SIZE(2)] = {
default_comp_ref_cdf[REF_CONTEXTS][FWD_REFS - 1][CDF_SIZE(2)] = {
{ { AOM_CDF2(4412) }, { AOM_CDF2(11499) }, { AOM_CDF2(478) } },
{ { AOM_CDF2(17926) }, { AOM_CDF2(26419) }, { AOM_CDF2(8615) } },
{ { AOM_CDF2(30449) }, { AOM_CDF2(31477) }, { AOM_CDF2(28035) } }
};
static const aom_cdf_prob
default_comp_bwdref_cdf[COMP_REF_CONTEXTS][BWD_REFS - 1][CDF_SIZE(2)] = {
default_comp_bwdref_cdf[REF_CONTEXTS][BWD_REFS - 1][CDF_SIZE(2)] = {
{ { AOM_CDF2(2762) }, { AOM_CDF2(1614) } },
{ { AOM_CDF2(17976) }, { AOM_CDF2(15912) } },
{ { AOM_CDF2(30894) }, { AOM_CDF2(30639) } },
};
// TODO(zoelu): To use aom_entropy_optimizer to update the following defaults.
static const aom_cdf_prob default_single_ref_cdf[REF_CONTEXTS][SINGLE_REFS - 1]
[CDF_SIZE(2)] = {
{ { AOM_CDF2(4623) },
{ AOM_CDF2(2110) },
{ AOM_CDF2(4132) },
{ AOM_CDF2(7309) },
{ AOM_CDF2(1392) },
{ AOM_CDF2(1781) } },
{ { AOM_CDF2(8659) },
{ AOM_CDF2(16372) },
{ AOM_CDF2(9371) },
{ AOM_CDF2(16322) },
{ AOM_CDF2(6216) },
{ AOM_CDF2(15834) } },
{ { AOM_CDF2(17353) },
{ AOM_CDF2(30182) },
{ AOM_CDF2(16300) },
{ AOM_CDF2(21702) },
{ AOM_CDF2(10365) },
{ AOM_CDF2(30486) } },
{ { AOM_CDF2(16384) },
{ AOM_CDF2(16384) },
{ AOM_CDF2(24426) },
{ AOM_CDF2(26972) },
{ AOM_CDF2(14760) },
{ AOM_CDF2(16384) } },
{ { AOM_CDF2(28634) },
{ AOM_CDF2(16384) },
{ AOM_CDF2(29425) },
{ AOM_CDF2(30969) },
{ AOM_CDF2(26676) },
{ AOM_CDF2(16384) } }
{ { AOM_CDF2(6500) },
{ AOM_CDF2(3089) },
{ AOM_CDF2(4026) },
{ AOM_CDF2(8549) },
{ AOM_CDF2(184) },
{ AOM_CDF2(2264) } },
{ { AOM_CDF2(17037) },
{ AOM_CDF2(19408) },
{ AOM_CDF2(15521) },
{ AOM_CDF2(27640) },
{ AOM_CDF2(5047) },
{ AOM_CDF2(16251) } },
{ { AOM_CDF2(28292) },
{ AOM_CDF2(30427) },
{ AOM_CDF2(29003) },
{ AOM_CDF2(31436) },
{ AOM_CDF2(28466) },
{ AOM_CDF2(29371) } }
};
// TODO(huisu): tune these cdfs
......
......@@ -132,8 +132,8 @@ typedef struct frame_contexts {
aom_cdf_prob uni_comp_ref_cdf[UNI_COMP_REF_CONTEXTS][UNIDIR_COMP_REFS - 1]
[CDF_SIZE(2)];
#endif // CONFIG_EXT_COMP_REFS
aom_cdf_prob comp_ref_cdf[COMP_REF_CONTEXTS][FWD_REFS - 1][CDF_SIZE(2)];
aom_cdf_prob comp_bwdref_cdf[COMP_REF_CONTEXTS][BWD_REFS - 1][CDF_SIZE(2)];
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)];
aom_cdf_prob txfm_partition_cdf[TXFM_PARTITION_CONTEXTS][CDF_SIZE(2)];
#if CONFIG_JNT_COMP
aom_cdf_prob compound_index_cdf[COMP_INDEX_CONTEXTS][CDF_SIZE(2)];
......@@ -274,8 +274,8 @@ typedef struct FRAME_COUNTS {
unsigned int uni_comp_ref[UNI_COMP_REF_CONTEXTS][UNIDIR_COMP_REFS - 1][2];
#endif // CONFIG_EXT_COMP_REFS
unsigned int single_ref[REF_CONTEXTS][SINGLE_REFS - 1][2];
unsigned int comp_ref[COMP_REF_CONTEXTS][FWD_REFS - 1][2];
unsigned int comp_bwdref[COMP_REF_CONTEXTS][BWD_REFS - 1][2];
unsigned int comp_ref[REF_CONTEXTS][FWD_REFS - 1][2];
unsigned int comp_bwdref[REF_CONTEXTS][BWD_REFS - 1][2];
#if CONFIG_INTRABC
unsigned int intrabc[2];
#endif // CONFIG_INTRABC
......
......@@ -579,8 +579,7 @@ typedef enum ATTRIBUTE_PACKED {
#define INTRA_INTER_CONTEXTS 4
#define COMP_INTER_CONTEXTS 5
#define COMP_REF_CONTEXTS 3
#define REF_CONTEXTS 5
#define REF_CONTEXTS 3
#if CONFIG_EXT_COMP_REFS
#define COMP_REF_TYPE_CONTEXTS 5
......
This diff is collapsed.
......@@ -299,10 +299,10 @@ struct macroblock {
#endif // CONFIG_EXT_COMP_REFS
// Cost for signaling ref_frame[0] (LAST_FRAME, LAST2_FRAME, LAST3_FRAME or
// GOLDEN_FRAME) in bidir-comp mode.
int comp_ref_cost[COMP_REF_CONTEXTS][FWD_REFS - 1][2];
int comp_ref_cost[REF_CONTEXTS][FWD_REFS - 1][2];
// Cost for signaling ref_frame[1] (ALTREF_FRAME, ALTREF2_FRAME, or
// BWDREF_FRAME) in bidir-comp mode.
int comp_bwdref_cost[COMP_REF_CONTEXTS][BWD_REFS - 1][2];
int comp_bwdref_cost[REF_CONTEXTS][BWD_REFS - 1][2];
int inter_compound_mode_cost[INTER_MODE_CONTEXTS][INTER_COMPOUND_MODES];
#if CONFIG_JNT_COMP
int compound_type_cost[BLOCK_SIZES_ALL][COMPOUND_TYPES - 1];
......
......@@ -270,14 +270,14 @@ void av1_fill_mode_rates(AV1_COMMON *const cm, MACROBLOCK *x,
}
#endif // CONFIG_EXT_COMP_REFS
for (i = 0; i < COMP_REF_CONTEXTS; ++i) {
for (i = 0; i < REF_CONTEXTS; ++i) {
for (j = 0; j < FWD_REFS - 1; ++j) {
av1_cost_tokens_from_cdf(x->comp_ref_cost[i][j], fc->comp_ref_cdf[i][j],
NULL);
}
}
for (i = 0; i < COMP_REF_CONTEXTS; ++i) {
for (i = 0; i < REF_CONTEXTS; ++i) {
for (j = 0; j < BWD_REFS - 1; ++j) {
av1_cost_tokens_from_cdf(x->comp_bwdref_cost[i][j],
fc->comp_bwdref_cdf[i][j], NULL);
......
......@@ -470,21 +470,21 @@ int main(int argc, const char **argv) {
"default_single_ref_cdf[REF_CONTEXTS][SINGLE_REFS - 1][CDF_SIZE(2)]");
/* ext_refs experiment */
cts_each_dim[0] = COMP_REF_CONTEXTS;
cts_each_dim[0] = REF_CONTEXTS;
cts_each_dim[1] = FWD_REFS - 1;
cts_each_dim[2] = 2;
optimize_cdf_table(
&fc.comp_ref[0][0][0], probsfile, 3, cts_each_dim,
"static const aom_cdf_prob\n"
"default_comp_ref_cdf[COMP_REF_CONTEXTS][FWD_REFS - 1][CDF_SIZE(2)]");
"default_comp_ref_cdf[REF_CONTEXTS][FWD_REFS - 1][CDF_SIZE(2)]");
cts_each_dim[0] = COMP_REF_CONTEXTS;
cts_each_dim[0] = REF_CONTEXTS;
cts_each_dim[1] = BWD_REFS - 1;
cts_each_dim[2] = 2;
optimize_cdf_table(
&fc.comp_bwdref[0][0][0], probsfile, 3, cts_each_dim,
"static const aom_cdf_prob\n"
"default_comp_bwdref_cdf[COMP_REF_CONTEXTS][BWD_REFS - 1][CDF_SIZE(2)]");
"default_comp_bwdref_cdf[REF_CONTEXTS][BWD_REFS - 1][CDF_SIZE(2)]");
/* Transform size */
cts_each_dim[0] = TXFM_PARTITION_CONTEXTS;
......
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