Commit 855f0fc7 authored by Cheng Chen's avatar Cheng Chen
Browse files

Train LPF_SB cdf

Count filter level reuse, sign, and delta. And use counts to train
default cdfs.
Default cdf tables updated.

Change-Id: If4fbf3e06ec7d568d940ca7b170bbbb4b778f176
parent 4bd0b2f8
......@@ -702,6 +702,10 @@ static uint8_t get_filter_level(const AV1_COMMON *cm,
#else
static uint8_t get_filter_level(const loop_filter_info_n *lfi_n,
const MB_MODE_INFO *mbmi) {
#if CONFIG_LPF_SB
return mbmi->filt_lvl;
#endif
#if CONFIG_SUPERTX
const int segment_id = AOMMIN(mbmi->segment_id, mbmi->segment_id_supertx);
assert(
......
......@@ -5641,35 +5641,35 @@ const aom_cdf_prob default_kf_y_mode_cdf[INTRA_MODES][INTRA_MODES][CDF_SIZE(
#if CONFIG_LPF_SB
static const aom_cdf_prob default_lpf_reuse_cdf[LPF_REUSE_CONTEXT][CDF_SIZE(
2)] = { { AOM_ICDF(8192), AOM_ICDF(32768), 0 },
{ AOM_ICDF(4096), AOM_ICDF(32768), 0 } };
2)] = { { AOM_ICDF(4259), AOM_ICDF(32768), 0 },
{ AOM_ICDF(728), AOM_ICDF(32768), 0 } };
static const aom_cdf_prob
default_lpf_delta_cdf[LPF_DELTA_CONTEXT][CDF_SIZE(DELTA_RANGE)] = {
{ AOM_ICDF(4096), AOM_ICDF(7680), AOM_ICDF(10816), AOM_ICDF(13560),
AOM_ICDF(15961), AOM_ICDF(18062), AOM_ICDF(19900), AOM_ICDF(32768), 0 },
{ AOM_ICDF(4096), AOM_ICDF(7680), AOM_ICDF(10816), AOM_ICDF(13560),
AOM_ICDF(15961), AOM_ICDF(18062), AOM_ICDF(19900), AOM_ICDF(32768), 0 },
{ AOM_ICDF(4096), AOM_ICDF(7680), AOM_ICDF(10816), AOM_ICDF(13560),
AOM_ICDF(15961), AOM_ICDF(18062), AOM_ICDF(19900), AOM_ICDF(32768), 0 },
{ AOM_ICDF(4096), AOM_ICDF(7680), AOM_ICDF(10816), AOM_ICDF(13560),
AOM_ICDF(15961), AOM_ICDF(18062), AOM_ICDF(19900), AOM_ICDF(32768), 0 },
{ AOM_ICDF(4096), AOM_ICDF(7680), AOM_ICDF(10816), AOM_ICDF(13560),
AOM_ICDF(15961), AOM_ICDF(18062), AOM_ICDF(19900), AOM_ICDF(32768), 0 },
{ AOM_ICDF(4096), AOM_ICDF(7680), AOM_ICDF(10816), AOM_ICDF(13560),
AOM_ICDF(15961), AOM_ICDF(18062), AOM_ICDF(19900), AOM_ICDF(32768), 0 },
{ AOM_ICDF(4096), AOM_ICDF(7680), AOM_ICDF(10816), AOM_ICDF(13560),
AOM_ICDF(15961), AOM_ICDF(18062), AOM_ICDF(19900), AOM_ICDF(32768), 0 },
{ AOM_ICDF(4096), AOM_ICDF(7680), AOM_ICDF(10816), AOM_ICDF(13560),
AOM_ICDF(15961), AOM_ICDF(18062), AOM_ICDF(19900), AOM_ICDF(32768), 0 }
{ AOM_ICDF(100), AOM_ICDF(688), AOM_ICDF(2128), AOM_ICDF(4642),
AOM_ICDF(7895), AOM_ICDF(11851), AOM_ICDF(17050), AOM_ICDF(32768), 0 },
{ AOM_ICDF(100), AOM_ICDF(1291), AOM_ICDF(4358), AOM_ICDF(7425),
AOM_ICDF(10654), AOM_ICDF(13559), AOM_ICDF(18563), AOM_ICDF(32768), 0 },
{ AOM_ICDF(100), AOM_ICDF(1086), AOM_ICDF(4982), AOM_ICDF(9134),
AOM_ICDF(13031), AOM_ICDF(16991), AOM_ICDF(23123), AOM_ICDF(32768), 0 },
{ AOM_ICDF(100), AOM_ICDF(1068), AOM_ICDF(3395), AOM_ICDF(7973),
AOM_ICDF(12512), AOM_ICDF(17967), AOM_ICDF(22812), AOM_ICDF(32768), 0 },
{ AOM_ICDF(100), AOM_ICDF(442), AOM_ICDF(2809), AOM_ICDF(7178),
AOM_ICDF(12535), AOM_ICDF(17450), AOM_ICDF(22417), AOM_ICDF(32768), 0 },
{ AOM_ICDF(100), AOM_ICDF(561), AOM_ICDF(2246), AOM_ICDF(6050),
AOM_ICDF(11103), AOM_ICDF(16592), AOM_ICDF(21353), AOM_ICDF(32768), 0 },
{ AOM_ICDF(100), AOM_ICDF(345), AOM_ICDF(2399), AOM_ICDF(5559),
AOM_ICDF(9682), AOM_ICDF(13992), AOM_ICDF(20126), AOM_ICDF(32768), 0 },
{ AOM_ICDF(100), AOM_ICDF(337), AOM_ICDF(1540), AOM_ICDF(3573),
AOM_ICDF(6438), AOM_ICDF(10196), AOM_ICDF(16320), AOM_ICDF(32768), 0 }
};
static const aom_cdf_prob
default_lpf_sign_cdf[LPF_REUSE_CONTEXT][LPF_SIGN_CONTEXT][CDF_SIZE(2)] = {
{ { AOM_ICDF(6554), AOM_ICDF(32768), 0 },
{ AOM_ICDF(26214), AOM_ICDF(32768), 0 } },
{ { AOM_ICDF(16384), AOM_ICDF(32768), 0 },
{ AOM_ICDF(16384), AOM_ICDF(32768), 0 } }
{ { AOM_ICDF(100), AOM_ICDF(32768), 0 },
{ AOM_ICDF(11932), AOM_ICDF(32768), 0 } },
{ { AOM_ICDF(14785), AOM_ICDF(32768), 0 },
{ AOM_ICDF(8145), AOM_ICDF(32768), 0 } }
};
#endif // CONFIG_LPF_SB
......
......@@ -573,7 +573,7 @@ typedef struct FRAME_COUNTS {
#if CONFIG_LPF_SB
unsigned int lpf_reuse[LPF_REUSE_CONTEXT][2];
unsigned int lpf_delta[LPF_DELTA_CONTEXT][DELTA_RANGE];
unsigned int lpf_sign[LPF_SIGN_CONTEXT][2];
unsigned int lpf_sign[LPF_REUSE_CONTEXT][LPF_SIGN_CONTEXT][2];
#endif // CONFIG_LPF_SB
} FRAME_COUNTS;
......
......@@ -3197,6 +3197,7 @@ static void write_modes_sb(AV1_COMP *const cpi, const TileInfo *const tile,
curr_mbmi->reuse_sb_lvl = reuse_prev_lvl;
aom_write_symbol(w, reuse_prev_lvl,
xd->tile_ctx->lpf_reuse_cdf[reuse_ctx], 2);
cpi->td.counts->lpf_reuse[reuse_ctx][reuse_prev_lvl]++;
if (reuse_prev_lvl) {
curr_mbmi->delta = 0;
......@@ -3207,6 +3208,7 @@ static void write_modes_sb(AV1_COMP *const cpi, const TileInfo *const tile,
curr_mbmi->delta = delta;
aom_write_symbol(w, delta, xd->tile_ctx->lpf_delta_cdf[delta_ctx],
DELTA_RANGE);
cpi->td.counts->lpf_delta[delta_ctx][delta]++;
if (delta) {
const int sign = curr_lvl > prev_lvl;
......@@ -3214,6 +3216,7 @@ static void write_modes_sb(AV1_COMP *const cpi, const TileInfo *const tile,
curr_mbmi->sign = sign;
aom_write_symbol(w, sign,
xd->tile_ctx->lpf_sign_cdf[reuse_ctx][sign_ctx], 2);
cpi->td.counts->lpf_sign[reuse_ctx][sign_ctx][sign]++;
} else {
curr_mbmi->sign = 0;
}
......
......@@ -934,6 +934,28 @@ int main(int argc, const char **argv) {
"[LGT_SIZES][2]");
}
#endif // CONFIG_LGT_FROM_PRED
#if CONFIG_LPF_SB
cts_each_dim[0] = LPF_REUSE_CONTEXT;
cts_each_dim[1] = 2;
optimize_cdf_table(&fc.lpf_reuse[0][0], probsfile, 2, cts_each_dim,
"static const aom_cdf_prob "
"default_lpf_reuse_cdf[LPF_REUSE_CONTEXT][CDF_SIZE(2)]");
cts_each_dim[0] = LPF_DELTA_CONTEXT;
cts_each_dim[1] = DELTA_RANGE;
optimize_cdf_table(&fc.lpf_delta[0][0], probsfile, 2, cts_each_dim,
"static const aom_cdf_prob "
"default_lpf_delta_cdf[LPF_DELTA_CONTEXT][CDF_SIZE(DELTA_"
"RANGE)]");
cts_each_dim[0] = LPF_REUSE_CONTEXT;
cts_each_dim[1] = LPF_SIGN_CONTEXT;
cts_each_dim[2] = 2;
optimize_cdf_table(&fc.lpf_delta[0][0], probsfile, 3, cts_each_dim,
"static const aom_cdf_prob "
"default_lpf_sign_cdf[LPF_REUSE_CONTEXT][LPF_SIGN_CONTEXT]"
"[CDF_SIZE(2)]");
#endif
fclose(statsfile);
fclose(logfile);
......
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