Commit 94cea4ac authored by Jingning Han's avatar Jingning Han

Experiment probability precision for lv-map coding

Experiment probability precision for binary coding in the lv-map
coding system.

Change-Id: I8d9c49eee6dc7ca7970390fa5febe25b80bfab3c
parent 237cf1b2
......@@ -50,6 +50,11 @@
#define aom_read_symbol(r, cdf, nsymbs, ACCT_STR_NAME) \
aom_read_symbol_(r, cdf, nsymbs ACCT_STR_ARG(ACCT_STR_NAME))
#if CONFIG_LV_MAP
#define aom_read_bin(r, cdf, nsymbs, ACCT_STR_NAME) \
aom_read_bin_(r, cdf, nsymbs ACCT_STR_ARG(ACCT_STR_NAME))
#endif
#ifdef __cplusplus
extern "C" {
#endif
......@@ -198,6 +203,16 @@ static INLINE int aom_read_symbol_(aom_reader *r, aom_cdf_prob *cdf,
return ret;
}
#if CONFIG_LV_MAP
static INLINE int aom_read_bin_(aom_reader *r, aom_cdf_prob *cdf,
int nsymbs ACCT_STR_PARAM) {
int ret;
ret = aom_read_cdf(r, cdf, nsymbs, ACCT_STR_NAME);
update_cdf(cdf, ret, nsymbs);
return ret;
}
#endif
static INLINE int aom_read_tree_as_cdf(aom_reader *r,
const aom_tree_index *tree,
const aom_prob *probs) {
......
......@@ -142,6 +142,14 @@ static INLINE void aom_write_symbol(aom_writer *w, int symb, aom_cdf_prob *cdf,
update_cdf(cdf, symb, nsymbs);
}
#if CONFIG_LV_MAP
static INLINE void aom_write_bin(aom_writer *w, int symb, aom_cdf_prob *cdf,
int nsymbs) {
aom_write_cdf(w, symb, cdf, nsymbs);
update_cdf(cdf, symb, nsymbs);
}
#endif
static INLINE void aom_write_tree_as_cdf(aom_writer *w,
const aom_tree_index *tree,
const aom_prob *probs, int bits,
......
......@@ -195,6 +195,12 @@ static INLINE void update_cdf(aom_cdf_prob *cdf, int val, int nsymbs) {
cdf[nsymbs] += (cdf[nsymbs] < 32);
}
#if CONFIG_LV_MAP
static INLINE void update_bin(aom_cdf_prob *cdf, int val, int nsymbs) {
update_cdf(cdf, val, nsymbs);
}
#endif
#ifdef __cplusplus
} // extern "C"
#endif
......
......@@ -76,7 +76,7 @@ static INLINE int read_nz_map(aom_reader *r, tran_low_t *tcoeffs, int plane,
if (c < seg_eob - 1) {
#if LV_MAP_PROB
is_nz = av1_read_record_symbol(
is_nz = av1_read_record_bin(
counts, r, fc->nz_map_cdf[txs_ctx][plane_type][coeff_ctx], 2,
ACCT_STR);
#else
......@@ -98,7 +98,7 @@ static INLINE int read_nz_map(aom_reader *r, tran_low_t *tcoeffs, int plane,
if (is_nz) {
#if LV_MAP_PROB
int is_eob = av1_read_record_symbol(
int is_eob = av1_read_record_bin(
counts, r, fc->eob_flag_cdf[txs_ctx][plane_type][eob_ctx], 2,
ACCT_STR);
#else
......@@ -130,7 +130,7 @@ static INLINE int read_nz_map_vert(aom_reader *r, tran_low_t *tcoeffs,
for (int col = 0; col < width; ++col) {
int el_ctx = get_empty_line_ctx(col, eob_ls);
#if LV_MAP_PROB
int empty_line = av1_read_record_symbol(
int empty_line = av1_read_record_bin(
counts, r, fc->empty_line_cdf[txs_ctx][plane_type][tx_class][el_ctx], 2,
ACCT_STR);
#else
......@@ -147,7 +147,7 @@ static INLINE int read_nz_map_vert(aom_reader *r, tran_low_t *tcoeffs,
get_nz_map_ctx(tcoeffs, coeff_idx, bwl, height, tx_type);
if (row + 1 != height) {
#if LV_MAP_PROB
int is_nz = av1_read_record_symbol(
int is_nz = av1_read_record_bin(
counts, r, fc->nz_map_cdf[txs_ctx][plane_type][coeff_ctx], 2,
ACCT_STR);
#else
......@@ -160,7 +160,7 @@ static INLINE int read_nz_map_vert(aom_reader *r, tran_low_t *tcoeffs,
if (row + 1 != height) {
int eob_ctx = get_hv_eob_ctx(col, row, eob_ls);
#if LV_MAP_PROB
int is_eob = av1_read_record_symbol(
int is_eob = av1_read_record_bin(
counts, r,
fc->hv_eob_cdf[txs_ctx][plane_type][tx_class][eob_ctx], 2,
ACCT_STR);
......@@ -206,7 +206,7 @@ static INLINE int read_nz_map_horiz(aom_reader *r, tran_low_t *tcoeffs,
for (int row = 0; row < height; ++row) {
int el_ctx = get_empty_line_ctx(row, eob_ls);
#if LV_MAP_PROB
int empty_line = av1_read_record_symbol(
int empty_line = av1_read_record_bin(
counts, r, fc->empty_line_cdf[txs_ctx][plane_type][tx_class][el_ctx], 2,
ACCT_STR);
#else
......@@ -223,7 +223,7 @@ static INLINE int read_nz_map_horiz(aom_reader *r, tran_low_t *tcoeffs,
get_nz_map_ctx(tcoeffs, coeff_idx, bwl, height, tx_type);
if (col + 1 != width) {
#if LV_MAP_PROB
int is_nz = av1_read_record_symbol(
int is_nz = av1_read_record_bin(
counts, r, fc->nz_map_cdf[txs_ctx][plane_type][coeff_ctx], 2,
ACCT_STR);
#else
......@@ -235,7 +235,7 @@ static INLINE int read_nz_map_horiz(aom_reader *r, tran_low_t *tcoeffs,
eob = AOMMAX(eob, iscan[coeff_idx] + 1);
int eob_ctx = get_hv_eob_ctx(row, col, eob_ls);
#if LV_MAP_PROB
int is_eob = av1_read_record_symbol(
int is_eob = av1_read_record_bin(
counts, r,
fc->hv_eob_cdf[txs_ctx][plane_type][tx_class][eob_ctx], 2,
ACCT_STR);
......@@ -286,7 +286,7 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
memset(tcoeffs, 0, sizeof(*tcoeffs) * seg_eob);
#if LV_MAP_PROB
int all_zero = av1_read_record_symbol(
int all_zero = av1_read_record_bin(
counts, r, ec_ctx->txb_skip_cdf[txs_ctx][txb_ctx->txb_skip_ctx], 2,
ACCT_STR);
#else
......@@ -324,7 +324,7 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
read_nz_map(r, tcoeffs, plane, scan, tx_size, tx_type, ec_ctx, counts);
} else {
#if LV_MAP_PROB
const int eob_mode = av1_read_record_symbol(
const int eob_mode = av1_read_record_bin(
counts, r, ec_ctx->eob_mode_cdf[txs_ctx][plane_type][tx_class], 2,
ACCT_STR);
#else
......@@ -366,7 +366,7 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
ctx = get_base_ctx(tcoeffs, scan[c], bwl, height, i + 1);
#if LV_MAP_PROB
if (av1_read_record_symbol(
if (av1_read_record_bin(
counts, r, ec_ctx->coeff_base_cdf[txs_ctx][plane_type][i][ctx], 2,
ACCT_STR))
#else
......@@ -381,7 +381,7 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
if (c == 0) {
int dc_sign_ctx = txb_ctx->dc_sign_ctx;
#if LV_MAP_PROB
sign = av1_read_record_symbol(
sign = av1_read_record_bin(
counts, r, ec_ctx->dc_sign_cdf[plane_type][dc_sign_ctx], 2,
ACCT_STR);
#else
......@@ -414,7 +414,7 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
if (c == 0) {
int dc_sign_ctx = txb_ctx->dc_sign_ctx;
#if LV_MAP_PROB
sign = av1_read_record_symbol(
sign = av1_read_record_bin(
counts, r, ec_ctx->dc_sign_cdf[plane_type][dc_sign_ctx], 2, ACCT_STR);
#else
sign = aom_read(r, ec_ctx->dc_sign[plane_type][dc_sign_ctx], ACCT_STR);
......@@ -431,7 +431,7 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
#if BR_NODE
for (idx = 0; idx < BASE_RANGE_SETS; ++idx) {
#if LV_MAP_PROB
if (av1_read_record_symbol(
if (av1_read_record_bin(
counts, r, ec_ctx->coeff_br_cdf[txs_ctx][plane_type][idx][ctx], 2,
ACCT_STR))
#else // LV_MAP_PROB
......@@ -446,7 +446,7 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
if (counts) ++counts->coeff_br[txs_ctx][plane_type][idx][ctx][1];
for (tok = 0; tok < extra_bits; ++tok) {
#if LV_MAP_PROB
if (av1_read_record_symbol(
if (av1_read_record_bin(
counts, r, ec_ctx->coeff_lps_cdf[txs_ctx][plane_type][ctx], 2,
ACCT_STR))
#else
......@@ -476,9 +476,9 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
#else
for (idx = 0; idx < COEFF_BASE_RANGE; ++idx) {
#if LV_MAP_PROB
if (av1_read_record_symbol(
counts, r, ec_ctx->coeff_lps_cdf[txs_ctx][plane_type][ctx], 2,
ACCT_STR))
if (av1_read_record_bin(counts, r,
ec_ctx->coeff_lps_cdf[txs_ctx][plane_type][ctx],
2, ACCT_STR))
#else
if (aom_read(r, ec_ctx->coeff_lps[txs_ctx][plane_type][ctx], ACCT_STR))
#endif
......
......@@ -28,6 +28,16 @@ static INLINE int av1_read_record_symbol(FRAME_COUNTS *counts, aom_reader *r,
return aom_read_symbol(r, cdf, nsymbs, str);
}
#if CONFIG_LV_MAP
static INLINE int av1_read_record_bin(FRAME_COUNTS *counts, aom_reader *r,
aom_cdf_prob *cdf, int nsymbs,
const char *str) {
(void)str;
if (counts) ++counts->symbol_num[0];
return aom_read_bin(r, cdf, nsymbs, str);
}
#endif
static INLINE int av1_read_record(FRAME_COUNTS *counts, aom_reader *r, int prob,
const char *str) {
(void)str;
......@@ -59,6 +69,11 @@ static INLINE void av1_record_coeff(FRAME_COUNTS *counts, tran_low_t qcoeff) {
#define av1_read_record_symbol(counts, r, cdf, nsymbs, ACCT_STR_NAME) \
aom_read_symbol(r, cdf, nsymbs, ACCT_STR_NAME)
#if CONFIG_LV_MAP
#define av1_read_record_bin(counts, r, cdf, nsymbs, ACCT_STR_NAME) \
aom_read_bin(r, cdf, nsymbs, ACCT_STR_NAME)
#endif
#define av1_read_record(counts, r, prob, ACCT_STR_NAME) \
aom_read(r, prob, ACCT_STR_NAME)
......
This diff is collapsed.
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