Commit 0e141b56 authored by Yunqing Wang's avatar Yunqing Wang

Allow to disable the probability update

Added the function of allowing to disable the probability update while
needed. This would be needed while encoding in multiple tiles, and
enabling/disabling probability update can be set separately for every
individual tile.

Change-Id: Ic3c64e6cebac89c483d48b874761bd2e902d81e6
parent 2d9bd32e
......@@ -42,6 +42,7 @@ struct AnsDecoder {
#if CONFIG_ACCOUNTING
Accounting *accounting;
#endif
uint8_t allow_update_cdf;
};
static INLINE int ans_read_reinit(struct AnsDecoder *const ans);
......
......@@ -199,7 +199,7 @@ static INLINE int aom_read_symbol_(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);
if (r->allow_update_cdf) update_cdf(cdf, ret, nsymbs);
return ret;
}
......@@ -210,7 +210,7 @@ static INLINE int aom_read_bin_(aom_reader *r, aom_cdf_prob *cdf,
aom_cdf_prob this_cdf[3] = { (aom_cdf_prob)((cdf[0] >> 8) << 8), 0, 0 };
this_cdf[0] = clamp(this_cdf[0], (1 << 8), (127 << 8));
ret = aom_read_cdf(r, this_cdf, nsymbs, ACCT_STR_NAME);
update_bin(cdf, ret, nsymbs);
if (r->allow_update_cdf) update_bin(cdf, ret, nsymbs);
return ret;
}
#endif
......
......@@ -135,7 +135,7 @@ static INLINE void aom_write_cdf(aom_writer *w, int symb,
static INLINE void aom_write_symbol(aom_writer *w, int symb, aom_cdf_prob *cdf,
int nsymbs) {
aom_write_cdf(w, symb, cdf, nsymbs);
update_cdf(cdf, symb, nsymbs);
if (w->allow_update_cdf) update_cdf(cdf, symb, nsymbs);
}
#if CONFIG_LV_MAP
......@@ -144,7 +144,7 @@ static INLINE void aom_write_bin(aom_writer *w, int symb, aom_cdf_prob *cdf,
aom_cdf_prob this_cdf[3] = { (aom_cdf_prob)((cdf[0] >> 8) << 8), 0, 0 };
this_cdf[0] = clamp(this_cdf[0], (1 << 8), (127 << 8));
aom_write_cdf(w, symb, this_cdf, nsymbs);
update_bin(cdf, symb, nsymbs);
if (w->allow_update_cdf) update_bin(cdf, symb, nsymbs);
}
#endif
......
......@@ -47,6 +47,7 @@ struct BufAnsCoder {
int window_size;
#endif
int pos; // Dummy variable to store the output buffer after closing
uint8_t allow_update_cdf;
};
// Allocate a buffered ANS coder to store size symbols.
......
......@@ -34,6 +34,7 @@ struct daala_reader {
#if CONFIG_ACCOUNTING
Accounting *accounting;
#endif
uint8_t allow_update_cdf;
};
typedef struct daala_reader daala_reader;
......
......@@ -28,6 +28,7 @@ struct daala_writer {
unsigned int pos;
uint8_t *buffer;
od_ec_enc ec;
uint8_t allow_update_cdf;
};
typedef struct daala_writer daala_writer;
......
......@@ -1137,7 +1137,7 @@ static void decode_partition(AV1Decoder *const pbi, MACROBLOCKD *const xd,
static void setup_bool_decoder(const uint8_t *data, const uint8_t *data_end,
const size_t read_size,
struct aom_internal_error_info *error_info,
aom_reader *r,
aom_reader *r, uint8_t allow_update_cdf,
#if CONFIG_ANS && ANS_MAX_SYMBOLS
int window_size,
#endif // CONFIG_ANS && ANS_MAX_SYMBOLS
......@@ -1155,6 +1155,8 @@ static void setup_bool_decoder(const uint8_t *data, const uint8_t *data_end,
if (aom_reader_init(r, data, read_size, decrypt_cb, decrypt_state))
aom_internal_error(error_info, AOM_CODEC_MEM_ERROR,
"Failed to allocate bool decoder %d", 1);
r->allow_update_cdf = allow_update_cdf;
}
static void setup_segmentation(AV1_COMMON *const cm,
......@@ -2251,6 +2253,7 @@ static const uint8_t *decode_tiles(AV1Decoder *pbi, const uint8_t *data,
int inv_col_order;
int inv_row_order;
int tile_row, tile_col;
uint8_t allow_update_cdf;
#if CONFIG_EXT_TILE
if (cm->large_scale_tile) {
......@@ -2260,6 +2263,7 @@ static const uint8_t *decode_tiles(AV1Decoder *pbi, const uint8_t *data,
tile_cols_end = single_col ? tile_cols_start + 1 : tile_cols;
inv_col_order = pbi->inv_tile_order && !single_col;
inv_row_order = pbi->inv_tile_order && !single_row;
allow_update_cdf = 0;
} else {
#endif // CONFIG_EXT_TILE
tile_rows_start = 0;
......@@ -2268,6 +2272,7 @@ static const uint8_t *decode_tiles(AV1Decoder *pbi, const uint8_t *data,
tile_cols_end = tile_cols;
inv_col_order = pbi->inv_tile_order;
inv_row_order = pbi->inv_tile_order;
allow_update_cdf = 1;
#if CONFIG_EXT_TILE
}
#endif // CONFIG_EXT_TILE
......@@ -2334,7 +2339,7 @@ static const uint8_t *decode_tiles(AV1Decoder *pbi, const uint8_t *data,
av1_zero(td->dqcoeff);
av1_tile_init(&td->xd.tile, td->cm, tile_row, tile_col);
setup_bool_decoder(buf->data, data_end, buf->size, &cm->error,
&td->bit_reader,
&td->bit_reader, allow_update_cdf,
#if CONFIG_ANS && ANS_MAX_SYMBOLS
1 << cm->ans_window_size_log2,
#endif // CONFIG_ANS && ANS_MAX_SYMBOLS
......
......@@ -350,7 +350,7 @@ static PREDICTION_MODE read_inter_compound_mode(AV1_COMMON *cm, MACROBLOCKD *xd,
? (NEAREST_NEARESTMV - NEAREST_NEARESTMV)
: aom_read_symbol(r, ec_ctx->inter_compound_mode_cdf[ctx],
INTER_COMPOUND_MODES, ACCT_STR);
if (xd->mi[0]->mbmi.skip_mode)
if (xd->mi[0]->mbmi.skip_mode && r->allow_update_cdf)
update_cdf(ec_ctx->inter_compound_mode_cdf[ctx], mode,
INTER_COMPOUND_MODES);
#else
......@@ -1407,12 +1407,14 @@ static REFERENCE_MODE read_block_reference_mode(AV1_COMMON *cm,
#if CONFIG_EXT_SKIP
static void update_block_reference_mode(AV1_COMMON *cm, const MACROBLOCKD *xd,
REFERENCE_MODE mode) {
REFERENCE_MODE mode,
uint8_t allow_update_cdf) {
if (cm->reference_mode == REFERENCE_MODE_SELECT) {
assert(mode == SINGLE_REFERENCE || mode == COMPOUND_REFERENCE);
const int ctx = av1_get_reference_mode_context(cm, xd);
#if CONFIG_NEW_MULTISYMBOL
update_cdf(xd->tile_ctx->comp_inter_cdf[ctx], mode, 2);
if (allow_update_cdf)
update_cdf(xd->tile_ctx->comp_inter_cdf[ctx], mode, 2);
#endif // CONFIG_NEW_MULTISYMBOL
FRAME_COUNTS *counts = xd->counts;
if (counts) ++counts->comp_inter[ctx][mode];
......@@ -1455,13 +1457,15 @@ static COMP_REFERENCE_TYPE read_comp_reference_type(AV1_COMMON *cm,
#if CONFIG_EXT_SKIP
#if CONFIG_EXT_COMP_REFS
static void update_comp_reference_type(AV1_COMMON *cm, const MACROBLOCKD *xd,
COMP_REFERENCE_TYPE comp_ref_type) {
COMP_REFERENCE_TYPE comp_ref_type,
uint8_t allow_update_cdf) {
assert(comp_ref_type == UNIDIR_COMP_REFERENCE ||
comp_ref_type == BIDIR_COMP_REFERENCE);
(void)cm;
const int ctx = av1_get_comp_reference_type_context(xd);
#if CONFIG_NEW_MULTISYMBOL
update_cdf(xd->tile_ctx->comp_ref_type_cdf[ctx], comp_ref_type, 2);
if (allow_update_cdf)
update_cdf(xd->tile_ctx->comp_ref_type_cdf[ctx], comp_ref_type, 2);
#endif // CONFIG_NEW_MULTISYMBOL
FRAME_COUNTS *counts = xd->counts;
if (counts) ++counts->comp_ref_type[ctx][comp_ref_type];
......@@ -1470,25 +1474,27 @@ static void update_comp_reference_type(AV1_COMMON *cm, const MACROBLOCKD *xd,
static void set_ref_frames_for_skip_mode(AV1_COMMON *const cm,
MACROBLOCKD *const xd,
MV_REFERENCE_FRAME ref_frame[2]) {
MV_REFERENCE_FRAME ref_frame[2],
uint8_t allow_update_cdf) {
assert(xd->mi[0]->mbmi.skip_mode);
ref_frame[0] = LAST_FRAME + cm->ref_frame_idx_0;
ref_frame[1] = LAST_FRAME + cm->ref_frame_idx_1;
const REFERENCE_MODE mode = COMPOUND_REFERENCE;
update_block_reference_mode(cm, xd, mode);
update_block_reference_mode(cm, xd, mode, allow_update_cdf);
#if CONFIG_EXT_COMP_REFS
const COMP_REFERENCE_TYPE comp_ref_type = BIDIR_COMP_REFERENCE;
update_comp_reference_type(cm, xd, comp_ref_type);
update_comp_reference_type(cm, xd, comp_ref_type, allow_update_cdf);
#endif // CONFIG_EXT_COMP_REFS
// Update stats for both forward and backward references
#if CONFIG_NEW_MULTISYMBOL
#define UPDATE_REF_BIT(bname, pname, cname, iname) \
update_cdf(av1_get_pred_cdf_##pname(cm, xd), bname, 2); \
if (counts) \
#define UPDATE_REF_BIT(bname, pname, cname, iname) \
if (allow_update_cdf) \
update_cdf(av1_get_pred_cdf_##pname(cm, xd), bname, 2); \
if (counts) \
++counts->comp_##cname[av1_get_pred_context_##pname(cm, xd)][iname][bname];
#else
#define UPDATE_REF_BIT(bname, pname, cname, iname) \
......@@ -1537,7 +1543,7 @@ static void read_ref_frames(AV1_COMMON *const cm, MACROBLOCKD *const xd,
} else {
#if CONFIG_EXT_SKIP
if (xd->mi[0]->mbmi.skip_mode) {
set_ref_frames_for_skip_mode(cm, xd, ref_frame);
set_ref_frames_for_skip_mode(cm, xd, ref_frame, r->allow_update_cdf);
return;
}
#endif // CONFIG_EXT_SKIP
......@@ -2060,12 +2066,13 @@ static int read_is_inter_block(AV1_COMMON *const cm, MACROBLOCKD *const xd,
#if CONFIG_EXT_SKIP
static void update_block_intra_inter(AV1_COMMON *const cm,
MACROBLOCKD *const xd, int segment_id,
const int is_inter) {
const int is_inter,
uint8_t allow_update_cdf) {
if (!segfeature_active(&cm->seg, segment_id, SEG_LVL_REF_FRAME)) {
const int ctx = av1_get_intra_inter_context(xd);
#if CONFIG_NEW_MULTISYMBOL
FRAME_CONTEXT *ec_ctx = xd->tile_ctx;
update_cdf(ec_ctx->intra_inter_cdf[ctx], is_inter, 2);
if (allow_update_cdf) update_cdf(ec_ctx->intra_inter_cdf[ctx], is_inter, 2);
#endif // CONFIG_NEW_MULTISYMBOL
FRAME_COUNTS *counts = xd->counts;
if (counts) ++counts->intra_inter[ctx][is_inter];
......@@ -2635,7 +2642,8 @@ static void read_inter_frame_mode_info(AV1Decoder *const pbi,
#endif // CONFIG_EXT_DELTA_Q
}
update_block_intra_inter(cm, xd, mbmi->segment_id, inter_block);
update_block_intra_inter(cm, xd, mbmi->segment_id, inter_block,
r->allow_update_cdf);
} else {
#endif // CONFIG_EXT_SKIP
mbmi->skip = read_skip(cm, xd, mbmi->segment_id, r);
......
......@@ -3181,6 +3181,7 @@ static uint32_t write_tiles(AV1_COMP *const cpi, uint8_t *const dst,
#if CONFIG_ANS
mode_bc.size = 1 << cpi->common.ans_window_size_log2;
#endif
mode_bc.allow_update_cdf = !cm->large_scale_tile;
#if CONFIG_LOOP_RESTORATION
for (int p = 0; p < MAX_MB_PLANE; ++p) {
set_default_wiener(cpi->td.mb.e_mbd.wiener_info + p);
......@@ -3367,6 +3368,7 @@ static uint32_t write_tiles(AV1_COMP *const cpi, uint8_t *const dst,
#if CONFIG_ANS
mode_bc.size = 1 << cpi->common.ans_window_size_log2;
#endif // CONFIG_ANS
mode_bc.allow_update_cdf = 1;
#if CONFIG_LOOP_RESTORATION
for (int p = 0; p < MAX_MB_PLANE; ++p) {
set_default_wiener(cpi->td.mb.e_mbd.wiener_info + p);
......@@ -4851,6 +4853,7 @@ static uint32_t write_tiles_in_tg_obus(AV1_COMP *const cpi, uint8_t *const dst,
#if CONFIG_ANS
mode_bc.size = 1 << cpi->common.ans_window_size_log2;
#endif
mode_bc.allow_update_cdf = !cm->large_scale_tile;
aom_start_encode(&mode_bc, buf->data + data_offset);
write_modes(cpi, &tile_info, &mode_bc, &tok, tok_end);
assert(tok == tok_end);
......@@ -4972,6 +4975,7 @@ static uint32_t write_tiles_in_tg_obus(AV1_COMP *const cpi, uint8_t *const dst,
#if CONFIG_ANS
mode_bc.size = 1 << cpi->common.ans_window_size_log2;
#endif // CONFIG_ANS
mode_bc.allow_update_cdf = 1;
#if CONFIG_LOOP_RESTORATION
for (int p = 0; p < MAX_MB_PLANE; ++p) {
set_default_wiener(cpi->td.mb.e_mbd.wiener_info + p);
......
This diff is collapsed.
......@@ -40,7 +40,7 @@ void av1_update_tx_type_count(const struct AV1Common *cm, MACROBLOCKD *xd,
int blk_row, int blk_col, int block, int plane,
#endif
BLOCK_SIZE bsize, TX_SIZE tx_size,
FRAME_COUNTS *counts);
FRAME_COUNTS *counts, uint8_t allow_update_cdf);
#ifdef __cplusplus
} // extern "C"
#endif
......
......@@ -320,6 +320,7 @@ typedef struct TileDataEnc {
CFL_CTX cfl;
#endif
DECLARE_ALIGNED(16, FRAME_CONTEXT, tctx);
uint8_t allow_update_cdf;
} TileDataEnc;
typedef struct RD_COUNTS {
......
......@@ -132,7 +132,8 @@ static INLINE int64_t get_coeff_dist(tran_low_t tcoeff, tran_low_t dqcoeff,
void av1_update_eob_context(int eob, int seg_eob, TX_SIZE tx_size,
TX_TYPE tx_type, PLANE_TYPE plane,
FRAME_CONTEXT *ec_ctx, FRAME_COUNTS *counts) {
FRAME_CONTEXT *ec_ctx, FRAME_COUNTS *counts,
uint8_t allow_update_cdf) {
int16_t eob_extra;
int16_t eob_pt = get_eob_pos_token(eob, &eob_extra);
int16_t dummy;
......@@ -142,8 +143,9 @@ void av1_update_eob_context(int eob, int seg_eob, TX_SIZE tx_size,
for (int i = 1; i < max_eob_pt; i++) {
int eob_pos_ctx = av1_get_eob_pos_ctx(tx_type, i);
counts->eob_flag[txs_ctx][plane][eob_pos_ctx][eob_pt == i]++;
update_cdf(ec_ctx->eob_flag_cdf[txs_ctx][plane][eob_pos_ctx], eob_pt == i,
2);
if (allow_update_cdf)
update_cdf(ec_ctx->eob_flag_cdf[txs_ctx][plane][eob_pos_ctx], eob_pt == i,
2);
if (eob_pt == i) {
break;
}
......@@ -153,7 +155,8 @@ void av1_update_eob_context(int eob, int seg_eob, TX_SIZE tx_size,
int eob_shift = k_eob_offset_bits[eob_pt] - 1;
int bit = (eob_extra & (1 << eob_shift)) ? 1 : 0;
counts->eob_extra[txs_ctx][plane][eob_pt][bit]++;
update_cdf(ec_ctx->eob_extra_cdf[txs_ctx][plane][eob_pt], bit, 2);
if (allow_update_cdf)
update_cdf(ec_ctx->eob_extra_cdf[txs_ctx][plane][eob_pt], bit, 2);
}
}
......@@ -1974,6 +1977,7 @@ void av1_update_and_record_txb_context(int plane, int block, int blk_row,
const int height = tx_size_high[tx_size];
uint8_t levels[64 * 64];
int8_t signs[64 * 64];
const uint8_t allow_update_cdf = args->allow_update_cdf;
TX_SIZE txsize_ctx = get_txsize_context(tx_size);
FRAME_CONTEXT *ec_ctx = xd->tile_ctx;
......@@ -1981,8 +1985,9 @@ void av1_update_and_record_txb_context(int plane, int block, int blk_row,
memcpy(tcoeff, qcoeff, sizeof(*tcoeff) * seg_eob);
++td->counts->txb_skip[txsize_ctx][txb_ctx.txb_skip_ctx][eob == 0];
update_bin(ec_ctx->txb_skip_cdf[txsize_ctx][txb_ctx.txb_skip_ctx], eob == 0,
2);
if (allow_update_cdf)
update_bin(ec_ctx->txb_skip_cdf[txsize_ctx][txb_ctx.txb_skip_ctx], eob == 0,
2);
x->mbmi_ext->txb_skip_ctx[plane][block] = txb_ctx.txb_skip_ctx;
x->mbmi_ext->eobs[plane][block] = eob;
......@@ -1999,13 +2004,14 @@ void av1_update_and_record_txb_context(int plane, int block, int blk_row,
#if CONFIG_TXK_SEL
av1_update_tx_type_count(cm, xd, blk_row, blk_col, block, plane,
mbmi->sb_type, get_min_tx_size(tx_size), td->counts);
mbmi->sb_type, get_min_tx_size(tx_size), td->counts,
allow_update_cdf);
#endif
unsigned int(*nz_map_count)[SIG_COEF_CONTEXTS][2] =
&(td->counts->nz_map[txsize_ctx][plane_type]);
av1_update_eob_context(eob, seg_eob, tx_size, tx_type, plane_type, ec_ctx,
td->counts);
td->counts, allow_update_cdf);
#if USE_CAUSAL_BASE_CTX
int coeff_ctx = 0;
update_eob = eob - 1;
......@@ -2018,8 +2024,9 @@ void av1_update_and_record_txb_context(int plane, int block, int blk_row,
coeff_ctx = get_nz_map_ctx(tcoeff, c, scan, bwl, height, tx_type, 0);
if (c < eob - 1) {
++(*nz_map_count)[coeff_ctx][is_nz];
update_cdf(ec_ctx->nz_map_cdf[txsize_ctx][plane_type][coeff_ctx], is_nz,
2);
if (allow_update_cdf)
update_cdf(ec_ctx->nz_map_cdf[txsize_ctx][plane_type][coeff_ctx], is_nz,
2);
}
if (is_nz) {
......@@ -2029,8 +2036,9 @@ void av1_update_and_record_txb_context(int plane, int block, int blk_row,
int is_k = (abs(v) > (k + 1));
++td->counts->coeff_base[txsize_ctx][plane_type][k][ctx][is_k];
update_bin(ec_ctx->coeff_base_cdf[txsize_ctx][plane_type][k][ctx], is_k,
2);
if (allow_update_cdf)
update_bin(ec_ctx->coeff_base_cdf[txsize_ctx][plane_type][k][ctx],
is_k, 2);
if (is_k == 0) break;
}
}
......@@ -2040,7 +2048,9 @@ void av1_update_and_record_txb_context(int plane, int block, int blk_row,
if (c == eob - 1) continue;
++(*nz_map_count)[coeff_ctx][is_nz];
update_cdf(ec_ctx->nz_map_cdf[txsize_ctx][plane_type][coeff_ctx], is_nz, 2);
if (allow_update_cdf)
update_cdf(ec_ctx->nz_map_cdf[txsize_ctx][plane_type][coeff_ctx], is_nz,
2);
#endif
}
......@@ -2058,12 +2068,15 @@ void av1_update_and_record_txb_context(int plane, int block, int blk_row,
if (level == i + 1) {
++td->counts->coeff_base[txsize_ctx][plane_type][i][ctx][1];
update_bin(ec_ctx->coeff_base_cdf[txsize_ctx][plane_type][i][ctx], 1,
2);
if (allow_update_cdf)
update_bin(ec_ctx->coeff_base_cdf[txsize_ctx][plane_type][i][ctx], 1,
2);
continue;
}
++td->counts->coeff_base[txsize_ctx][plane_type][i][ctx][0];
update_bin(ec_ctx->coeff_base_cdf[txsize_ctx][plane_type][i][ctx], 0, 2);
if (allow_update_cdf)
update_bin(ec_ctx->coeff_base_cdf[txsize_ctx][plane_type][i][ctx], 0,
2);
update_eob = AOMMAX(update_eob, c);
}
}
......@@ -2076,7 +2089,8 @@ void av1_update_and_record_txb_context(int plane, int block, int blk_row,
++td->counts->dc_sign[plane_type][dc_sign_ctx][sign];
#if LV_MAP_PROB
update_bin(ec_ctx->dc_sign_cdf[plane_type][dc_sign_ctx], sign, 2);
if (allow_update_cdf)
update_bin(ec_ctx->dc_sign_cdf[plane_type][dc_sign_ctx], sign, 2);
#endif
x->mbmi_ext->dc_sign_ctx[plane][block] = dc_sign_ctx;
}
......@@ -2101,23 +2115,29 @@ void av1_update_and_record_txb_context(int plane, int block, int blk_row,
int br_base = br_index_to_coeff[br_set_idx];
int br_offset = base_range - br_base;
++td->counts->coeff_br[txsize_ctx][plane_type][idx][ctx][1];
update_bin(ec_ctx->coeff_br_cdf[txsize_ctx][plane_type][idx][ctx], 1,
2);
if (allow_update_cdf)
update_bin(ec_ctx->coeff_br_cdf[txsize_ctx][plane_type][idx][ctx], 1,
2);
int extra_bits = (1 << br_extra_bits[idx]) - 1;
for (int tok = 0; tok < extra_bits; ++tok) {
if (br_offset == tok) {
++td->counts->coeff_lps[txsize_ctx][plane_type][ctx][1];
update_bin(ec_ctx->coeff_lps_cdf[txsize_ctx][plane_type][ctx], 1,
2);
if (allow_update_cdf)
update_bin(ec_ctx->coeff_lps_cdf[txsize_ctx][plane_type][ctx], 1,
2);
break;
}
++td->counts->coeff_lps[txsize_ctx][plane_type][ctx][0];
update_bin(ec_ctx->coeff_lps_cdf[txsize_ctx][plane_type][ctx], 0, 2);
if (allow_update_cdf)
update_bin(ec_ctx->coeff_lps_cdf[txsize_ctx][plane_type][ctx], 0,
2);
}
break;
}
++td->counts->coeff_br[txsize_ctx][plane_type][idx][ctx][0];
update_bin(ec_ctx->coeff_br_cdf[txsize_ctx][plane_type][idx][ctx], 0, 2);
if (allow_update_cdf)
update_bin(ec_ctx->coeff_br_cdf[txsize_ctx][plane_type][idx][ctx], 0,
2);
}
// use 0-th order Golomb code to handle the residual level.
}
......@@ -2137,11 +2157,11 @@ void av1_update_and_record_txb_context(int plane, int block, int blk_row,
void av1_update_txb_context(const AV1_COMP *cpi, ThreadData *td,
RUN_TYPE dry_run, BLOCK_SIZE bsize, int *rate,
int mi_row, int mi_col) {
int mi_row, int mi_col, uint8_t allow_update_cdf) {
MACROBLOCK *const x = &td->mb;
MACROBLOCKD *const xd = &x->e_mbd;
MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
struct tokenize_b_args arg = { cpi, td, NULL, 0 };
struct tokenize_b_args arg = { cpi, td, NULL, 0, allow_update_cdf };
(void)rate;
(void)mi_row;
(void)mi_col;
......
......@@ -82,7 +82,8 @@ int av1_get_txb_entropy_context(const tran_low_t *qcoeff,
const SCAN_ORDER *scan_order, int eob);
void av1_update_txb_context(const AV1_COMP *cpi, ThreadData *td,
RUN_TYPE dry_run, BLOCK_SIZE bsize, int *rate,
const int mi_row, const int mi_col);
const int mi_row, const int mi_col,
uint8_t allow_update_cdf);
void av1_update_txb_context_b(int plane, int block, int blk_row, int blk_col,
BLOCK_SIZE plane_bsize, TX_SIZE tx_size,
......
......@@ -306,7 +306,7 @@ static INLINE void add_token(TOKENEXTRA **t,
aom_cdf_prob (*tail_cdf)[CDF_SIZE(ENTROPY_TOKENS)],
aom_cdf_prob (*head_cdf)[CDF_SIZE(ENTROPY_TOKENS)],
int8_t eob_val, int8_t first_val, int32_t extra,
uint8_t token) {
uint8_t token, uint8_t allow_update_cdf) {
(*t)->token = token;
(*t)->extra = extra;
(*t)->tail_cdf = tail_cdf;
......@@ -315,15 +315,17 @@ static INLINE void add_token(TOKENEXTRA **t,
(*t)->first_val = first_val;
(*t)++;
if (token == BLOCK_Z_TOKEN) {
update_cdf(*head_cdf, 0, HEAD_TOKENS + 1);
} else {
if (eob_val != LAST_EOB) {
const int symb = 2 * AOMMIN(token, TWO_TOKEN) - eob_val + first_val;
update_cdf(*head_cdf, symb, HEAD_TOKENS + first_val);
if (allow_update_cdf) {
if (token == BLOCK_Z_TOKEN) {
update_cdf(*head_cdf, 0, HEAD_TOKENS + 1);
} else {
if (eob_val != LAST_EOB) {
const int symb = 2 * AOMMIN(token, TWO_TOKEN) - eob_val + first_val;
update_cdf(*head_cdf, symb, HEAD_TOKENS + first_val);
}
if (token > ONE_TOKEN)
update_cdf(*tail_cdf, token - TWO_TOKEN, TAIL_TOKENS);
}
if (token > ONE_TOKEN)
update_cdf(*tail_cdf, token - TWO_TOKEN, TAIL_TOKENS);
}
}
......@@ -455,6 +457,7 @@ static void tokenize_b(int plane, int block, int blk_row, int blk_col,
MACROBLOCK *const x = &td->mb;
MACROBLOCKD *const xd = &x->e_mbd;
TOKENEXTRA **tp = args->tp;
const uint8_t allow_update_cdf = args->allow_update_cdf;
uint8_t token_cache[MAX_TX_SQUARE];
struct macroblock_plane *p = &x->plane[plane];
struct macroblockd_plane *pd = &xd->plane[plane];
......@@ -498,7 +501,7 @@ static void tokenize_b(int plane, int block, int blk_row, int blk_col,
if (eob == 0)
add_token(&t, &coef_tail_cdfs[band[c]][pt], &coef_head_cdfs[band[c]][pt], 1,
1, 0, BLOCK_Z_TOKEN);
1, 0, BLOCK_Z_TOKEN, allow_update_cdf);
while (c < eob) {
int v = qcoeff[scan[c]];
......@@ -506,14 +509,14 @@ static void tokenize_b(int plane, int block, int blk_row, int blk_col,
if (!v) {
add_token(&t, &coef_tail_cdfs[band[c]][pt], &coef_head_cdfs[band[c]][pt],
0, first_val, 0, ZERO_TOKEN);
0, first_val, 0, ZERO_TOKEN, allow_update_cdf);
token_cache[scan[c]] = 0;
} else {
eob_val =
(c + 1 == eob) ? (c + 1 == seg_eob ? LAST_EOB : EARLY_EOB) : NO_EOB;
av1_get_token_extra(v, &token, &extra);
add_token(&t, &coef_tail_cdfs[band[c]][pt], &coef_head_cdfs[band[c]][pt],
eob_val, first_val, extra, (uint8_t)token);
eob_val, first_val, extra, (uint8_t)token, allow_update_cdf);
token_cache[scan[c]] = av1_pt_energy_class[token];
}
++c;
......@@ -641,7 +644,8 @@ void tokenize_vartx(ThreadData *td, TOKENEXTRA **t, RUN_TYPE dry_run,
void av1_tokenize_sb_vartx(const AV1_COMP *cpi, ThreadData *td, TOKENEXTRA **t,
RUN_TYPE dry_run, int mi_row, int mi_col,
BLOCK_SIZE bsize, int *rate) {
BLOCK_SIZE bsize, int *rate,
uint8_t allow_update_cdf) {
const AV1_COMMON *const cm = &cpi->common;
MACROBLOCK *const x = &td->mb;
MACROBLOCKD *const xd = &x->e_mbd;
......@@ -651,7 +655,7 @@ void av1_tokenize_sb_vartx(const AV1_COMP *cpi, ThreadData *td, TOKENEXTRA **t,
#else
TOKENEXTRA *t_backup = *t;
#endif
struct tokenize_b_args arg = { cpi, td, t, 0 };
struct tokenize_b_args arg = { cpi, td, t, 0, allow_update_cdf };
int plane;
if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) return;
......@@ -729,11 +733,12 @@ void av1_tokenize_sb_vartx(const AV1_COMP *cpi, ThreadData *td, TOKENEXTRA **t,
void av1_tokenize_sb(const AV1_COMP *cpi, ThreadData *td, TOKENEXTRA **t,
RUN_TYPE dry_run, BLOCK_SIZE bsize, int *rate,
const int mi_row, const int mi_col) {
const int mi_row, const int mi_col,
uint8_t allow_update_cdf) {
MACROBLOCK *const x = &td->mb;
MACROBLOCKD *const xd = &x->e_mbd;
MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
struct tokenize_b_args arg = { cpi, td, t, 0 };
struct tokenize_b_args arg = { cpi, td, t, 0, allow_update_cdf };
if (mbmi->skip) {
av1_reset_skip_context(xd, mi_row, mi_col, bsize);
return;
......
......@@ -59,6 +59,7 @@ struct tokenize_b_args {
struct ThreadData *td;
TOKENEXTRA **tp;
int this_rate;
uint8_t allow_update_cdf;
};
typedef enum {
......@@ -72,7 +73,8 @@ typedef enum {
// otherwise rate is not incremented.
void av1_tokenize_sb_vartx(const struct AV1_COMP *cpi, struct ThreadData *td,
TOKENEXTRA **t, RUN_TYPE dry_run, int mi_row,
int mi_col, BLOCK_SIZE bsize, int *rate);
int mi_col, BLOCK_SIZE bsize, int *rate,
uint8_t allow_update_cdf);
int av1_cost_color_map(const MACROBLOCK *const x, int plane, int block,
BLOCK_SIZE bsize, TX_SIZE tx_size, COLOR_MAP_TYPE type);
......@@ -83,7 +85,8 @@ void av1_tokenize_color_map(const MACROBLOCK *const x, int plane, int block,
void av1_tokenize_sb(const struct AV1_COMP *cpi, struct ThreadData *td,
TOKENEXTRA **t, RUN_TYPE dry_run, BLOCK_SIZE bsize,
int *rate, const int mi_row, const int mi_col);
int *rate, const int mi_row, const int mi_col,
uint8_t allow_update_cdf);
extern const int16_t *av1_dct_value_cost_ptr;
/* TODO: The Token field should be broken out into a separate char array to
......
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