Commit fdaa55ed authored by Jingning Han's avatar Jingning Han
Browse files

Initialize lv-map syntax probability model

Initialize the cdf model for level map syntax elements.

Change-Id: I3865e07c126eb4c856803c12485b05782dea6526
parent 3897e2df
......@@ -46,6 +46,8 @@ typedef uint16_t aom_cdf_prob;
#define MAX_PROB 255
#define LV_MAP_PROB 1
#define aom_prob_half ((aom_prob)128)
typedef int8_t aom_tree_index;
......
......@@ -4651,6 +4651,10 @@ static void init_mode_probs(FRAME_CONTEXT *fc) {
av1_copy(fc->dc_sign, default_dc_sign);
av1_copy(fc->coeff_base, default_coeff_base);
av1_copy(fc->coeff_lps, default_coeff_lps);
#if LV_MAP_PROB
av1_init_txb_probs(fc);
#endif // LV_MAP_PROB
#endif
#if CONFIG_EXT_REFS
av1_copy(fc->comp_bwdref_prob, default_comp_bwdref_p);
......
......@@ -177,6 +177,19 @@ typedef struct frame_contexts {
aom_prob coeff_base[TX_SIZES][PLANE_TYPES][NUM_BASE_LEVELS]
[COEFF_BASE_CONTEXTS];
aom_prob coeff_lps[TX_SIZES][PLANE_TYPES][LEVEL_CONTEXTS];
#if LV_MAP_PROB
aom_cdf_prob txb_skip_cdf[TX_SIZES][TXB_SKIP_CONTEXTS][CDF_SIZE(2)];
aom_cdf_prob nz_map_cdf[TX_SIZES][PLANE_TYPES][SIG_COEF_CONTEXTS]
[CDF_SIZE(2)];
aom_cdf_prob eob_flag_cdf[TX_SIZES][PLANE_TYPES][EOB_COEF_CONTEXTS]
[CDF_SIZE(2)];
aom_cdf_prob dc_sign_cdf[PLANE_TYPES][DC_SIGN_CONTEXTS][CDF_SIZE(2)];
aom_cdf_prob coeff_base_cdf[TX_SIZES][PLANE_TYPES][NUM_BASE_LEVELS]
[COEFF_BASE_CONTEXTS][CDF_SIZE(2)];
aom_cdf_prob coeff_lps_cdf[TX_SIZES][PLANE_TYPES][LEVEL_CONTEXTS]
[CDF_SIZE(2)];
#endif // LV_MAP_PROB
#endif
aom_prob newmv_prob[NEWMV_MODE_CONTEXTS];
......
......@@ -10,9 +10,7 @@
*/
#include "aom/aom_integer.h"
#include "av1/common/onyxc_int.h"
#if CONFIG_LV_MAP
#include "av1/common/txb_common.h"
#endif
const int16_t av1_coeff_band_4x4[16] = { 0, 1, 2, 3, 4, 5, 6, 7,
8, 9, 10, 11, 12, 13, 14, 15 };
......@@ -98,6 +96,75 @@ const int16_t av1_coeff_band_32x32[1024] = {
22, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24,
};
#if LV_MAP_PROB
void av1_init_txb_probs(FRAME_CONTEXT *fc) {
TX_SIZE tx_size;
int plane, ctx, level;
// Update probability models for transform block skip flag
for (tx_size = 0; tx_size < TX_SIZES; ++tx_size) {
for (ctx = 0; ctx < TXB_SKIP_CONTEXTS; ++ctx) {
fc->txb_skip_cdf[tx_size][ctx][0] =
AOM_ICDF(128 * (aom_cdf_prob)fc->txb_skip[tx_size][ctx]);
fc->txb_skip_cdf[tx_size][ctx][1] = AOM_ICDF(32768);
fc->txb_skip_cdf[tx_size][ctx][2] = 0;
}
}
for (plane = 0; plane < PLANE_TYPES; ++plane) {
for (ctx = 0; ctx < DC_SIGN_CONTEXTS; ++ctx) {
fc->dc_sign_cdf[plane][ctx][0] =
AOM_ICDF(128 * (aom_cdf_prob)fc->dc_sign[plane][ctx]);
fc->dc_sign_cdf[plane][ctx][1] = AOM_ICDF(32768);
fc->dc_sign_cdf[plane][ctx][2] = 0;
}
}
// Update probability models for non-zero coefficient map and eob flag.
for (tx_size = 0; tx_size < TX_SIZES; ++tx_size) {
for (plane = 0; plane < PLANE_TYPES; ++plane) {
for (level = 0; level < NUM_BASE_LEVELS; ++level) {
for (ctx = 0; ctx < COEFF_BASE_CONTEXTS; ++ctx) {
fc->coeff_base_cdf[tx_size][plane][level][ctx][0] = AOM_ICDF(
128 * (aom_cdf_prob)fc->coeff_base[tx_size][plane][level][ctx]);
fc->coeff_base_cdf[tx_size][plane][level][ctx][1] = AOM_ICDF(32768);
fc->coeff_base_cdf[tx_size][plane][level][ctx][2] = 0;
}
}
}
}
for (tx_size = 0; tx_size < TX_SIZES; ++tx_size) {
for (plane = 0; plane < PLANE_TYPES; ++plane) {
for (ctx = 0; ctx < SIG_COEF_CONTEXTS; ++ctx) {
fc->nz_map_cdf[tx_size][plane][ctx][0] =
AOM_ICDF(128 * (aom_cdf_prob)fc->nz_map[tx_size][plane][ctx]);
fc->nz_map_cdf[tx_size][plane][ctx][1] = AOM_ICDF(32768);
fc->nz_map_cdf[tx_size][plane][ctx][2] = 0;
}
for (ctx = 0; ctx < EOB_COEF_CONTEXTS; ++ctx) {
fc->eob_flag_cdf[tx_size][plane][ctx][0] =
AOM_ICDF(128 * (aom_cdf_prob)fc->eob_flag[tx_size][plane][ctx]);
fc->eob_flag_cdf[tx_size][plane][ctx][1] = AOM_ICDF(32768);
fc->eob_flag_cdf[tx_size][plane][ctx][2] = 0;
}
}
}
for (tx_size = 0; tx_size < TX_SIZES; ++tx_size) {
for (plane = 0; plane < PLANE_TYPES; ++plane) {
for (ctx = 0; ctx < LEVEL_CONTEXTS; ++ctx) {
fc->coeff_lps_cdf[tx_size][plane][ctx][0] =
AOM_ICDF(128 * (aom_cdf_prob)fc->coeff_lps[tx_size][plane][ctx]);
fc->coeff_lps_cdf[tx_size][plane][ctx][1] = AOM_ICDF(32768);
fc->coeff_lps_cdf[tx_size][plane][ctx][2] = 0;
}
}
}
}
#endif
void av1_adapt_txb_probs(AV1_COMMON *cm, unsigned int count_sat,
unsigned int update_factor) {
FRAME_CONTEXT *fc = cm->fc;
......
......@@ -425,6 +425,10 @@ static INLINE void get_txb_ctx(BLOCK_SIZE plane_bsize, TX_SIZE tx_size,
}
}
#if LV_MAP_PROB
void av1_init_txb_probs(FRAME_CONTEXT *fc);
#endif // LV_MAP_PROB
void av1_adapt_txb_probs(AV1_COMMON *cm, unsigned int count_sat,
unsigned int update_factor);
......
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