Commit e2d8f183 authored by Dake He's avatar Dake He

[lv_map_multi] BR coding

1. Use separate contexts for transforms of size 32x32 and above.
2. Initialize cdf directly

Change-Id: I3373143788e81b2547d99e420e591892ef2641a2
parent 8be58fad
This diff is collapsed.
......@@ -282,6 +282,8 @@ typedef struct FRAME_COUNTS {
#else
unsigned int coeff_lps[TX_SIZES][PLANE_TYPES][BR_CDF_SIZE - 1][LEVEL_CONTEXTS]
[2];
unsigned int coeff_lps_multi[TX_SIZES][PLANE_TYPES][LEVEL_CONTEXTS]
[BR_CDF_SIZE];
#endif
#endif // CONFIG_LV_MAP
......
......@@ -320,6 +320,7 @@ void av1_init_txb_probs(FRAME_CONTEXT *fc) {
for (plane = 0; plane < PLANE_TYPES; ++plane) {
#if CONFIG_LV_MAP_MULTI
for (ctx = 0; ctx < LEVEL_CONTEXTS; ++ctx) {
#if 0
int p = 32768 - fc->coeff_lps[tx_size][plane][0][ctx] * 128;
int sum = p;
fc->coeff_br_cdf[tx_size][plane][ctx][0] = AOM_ICDF(sum);
......@@ -335,6 +336,9 @@ void av1_init_txb_probs(FRAME_CONTEXT *fc) {
// fc->coeff_br_cdf[tx_size][plane][ctx][0] >> 7,
// fc->coeff_br_cdf[tx_size][plane][ctx][1] >> 7,
// fc->coeff_br_cdf[tx_size][plane][ctx][2] >> 7);
#else
(void)ctx; // coeff_br_cdf is initialized in init_mode_probs
#endif
}
#else
for (ctx = 0; ctx < LEVEL_CONTEXTS; ++ctx) {
......
......@@ -303,17 +303,28 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *const xd,
ctx = get_br_ctx(levels, pos, bwl, level_counts[pos]);
#endif
for (idx = 0; idx < COEFF_BASE_RANGE / (BR_CDF_SIZE - 1); ++idx) {
int k = av1_read_record_symbol(
counts, r,
int k = av1_read_record_symbol(counts, r,
#if 0
ec_ctx->coeff_br_cdf[AOMMIN(txs_ctx, TX_16X16)][plane_type][ctx],
BR_CDF_SIZE, ACCT_STR);
#else
ec_ctx->coeff_br_cdf[AOMMIN(
txs_ctx, TX_32X32)][plane_type][ctx],
#endif
BR_CDF_SIZE, ACCT_STR);
*level += k;
if (counts) {
for (int lps = 0; lps < BR_CDF_SIZE - 1; lps++) {
#if 0
++counts->coeff_lps[AOMMIN(txs_ctx, TX_16X16)][plane_type][lps][ctx]
[lps == k];
#else
++counts->coeff_lps[AOMMIN(txs_ctx, TX_32X32)][plane_type][lps][ctx]
[lps == k];
#endif
if (lps == k) break;
}
++counts->coeff_lps_multi[AOMMIN(txs_ctx, TX_32X32)][plane_type][ctx]
[k];
}
if (k < BR_CDF_SIZE - 1) break;
}
......
......@@ -478,10 +478,14 @@ void av1_write_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
#endif
for (idx = 0; idx < COEFF_BASE_RANGE; idx += BR_CDF_SIZE - 1) {
const int k = AOMMIN(base_range - idx, BR_CDF_SIZE - 1);
aom_write_symbol(
w, k,
aom_write_symbol(w, k,
#if 0
ec_ctx->coeff_br_cdf[AOMMIN(txs_ctx, TX_16X16)][plane_type][ctx],
BR_CDF_SIZE);
#else
ec_ctx->coeff_br_cdf[AOMMIN(txs_ctx, TX_32X32)]
[plane_type][ctx],
#endif
BR_CDF_SIZE);
if (k < BR_CDF_SIZE - 1) break;
}
if (base_range < COEFF_BASE_RANGE) continue;
......@@ -2258,13 +2262,24 @@ void av1_update_and_record_txb_context(int plane, int block, int blk_row,
for (idx = 0; idx < COEFF_BASE_RANGE; idx += BR_CDF_SIZE - 1) {
const int k = AOMMIN(base_range - idx, BR_CDF_SIZE - 1);
update_cdf(
#if 0
ec_ctx->coeff_br_cdf[AOMMIN(txsize_ctx, TX_16X16)][plane_type][ctx],
#else
ec_ctx->coeff_br_cdf[AOMMIN(txsize_ctx, TX_32X32)][plane_type][ctx],
#endif
k, BR_CDF_SIZE);
for (int lps = 0; lps < BR_CDF_SIZE - 1; lps++) {
#if 0
++td->counts->coeff_lps[AOMMIN(txsize_ctx, TX_16X16)][plane_type][lps]
[ctx][lps == k];
#else
++td->counts->coeff_lps[AOMMIN(txsize_ctx, TX_32X32)][plane_type][lps]
[ctx][lps == k];
#endif
if (lps == k) break;
}
++td->counts->coeff_lps_multi[AOMMIN(txsize_ctx, TX_32X32)][plane_type]
[ctx][k];
if (k < BR_CDF_SIZE - 1) break;
}
......
......@@ -695,6 +695,15 @@ int main(int argc, const char **argv) {
"static const aom_prob "
"default_coeff_lps[TX_SIZES][PLANE_TYPES][BR_CDF_SIZE-"
"1][LEVEL_CONTEXTS]");
cts_each_dim[0] = TX_SIZES;
cts_each_dim[1] = PLANE_TYPES;
cts_each_dim[2] = LEVEL_CONTEXTS;
cts_each_dim[3] = BR_CDF_SIZE;
optimize_cdf_table(&fc.coeff_lps_multi[0][0][0][0], probsfile, 4,
cts_each_dim,
"static const aom_cdf_prob "
"default_coeff_lps_multi[TX_SIZES][PLANE_TYPES][LEVEL_"
"CONTEXTS][CDF_SIZE(BR_CDF_SIZE)]");
#else
cts_each_dim[0] = TX_SIZES;
cts_each_dim[1] = PLANE_TYPES;
......
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