From fb9186d68d498919b290d7f444560f44a1d8d1df Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Tue, 22 Mar 2016 10:33:34 -0700 Subject: [PATCH] ANS experiment: Use ANS everywhere. Use ANS for all entropy coded data in VP10 including the compressed header and modes and motion vectors. ANS tokens continue to be used for DCT tokens. Change-Id: Idf709a747150601e4d95d81ecfb3dc7253d349df --- vp10/decoder/decodeframe.c | 112 ++++++++------- vp10/decoder/decodemv.c | 180 ++++++++++++------------ vp10/decoder/decodemv.h | 4 +- vp10/decoder/decoder.h | 15 +- vp10/decoder/detokenize.c | 26 ++-- vp10/decoder/detokenize.h | 4 +- vp10/decoder/dsubexp.c | 24 ++-- vp10/decoder/dsubexp.h | 4 +- vp10/encoder/bitstream.c | 277 +++++++++++++++++++------------------ vp10/encoder/encodemv.c | 16 +-- vp10/encoder/encodemv.h | 4 +- vp10/encoder/subexp.c | 30 ++-- vp10/encoder/subexp.h | 6 +- 13 files changed, 356 insertions(+), 346 deletions(-) diff --git a/vp10/decoder/decodeframe.c b/vp10/decoder/decodeframe.c index f23a18a23..b6f1a3b0f 100644 --- a/vp10/decoder/decodeframe.c +++ b/vp10/decoder/decodeframe.c @@ -16,7 +16,7 @@ #include "./vpx_scale_rtcd.h" #include "vpx_dsp/bitreader_buffer.h" -#include "vpx_dsp/bitreader.h" +#include "vp10/decoder/bitreader.h" #include "vpx_dsp/vpx_dsp_common.h" #include "vpx_mem/vpx_mem.h" #include "vpx_ports/mem.h" @@ -100,14 +100,14 @@ static TX_MODE read_tx_mode(struct vpx_read_bit_buffer *rb) { return vpx_rb_read_bit(rb) ? TX_MODE_SELECT : vpx_rb_read_literal(rb, 2); } -static void read_switchable_interp_probs(FRAME_CONTEXT *fc, vpx_reader *r) { +static void read_switchable_interp_probs(FRAME_CONTEXT *fc, vp10_reader *r) { int i, j; for (j = 0; j < SWITCHABLE_FILTER_CONTEXTS; ++j) for (i = 0; i < SWITCHABLE_FILTERS - 1; ++i) vp10_diff_update_prob(r, &fc->switchable_interp_prob[j][i]); } -static void read_inter_mode_probs(FRAME_CONTEXT *fc, vpx_reader *r) { +static void read_inter_mode_probs(FRAME_CONTEXT *fc, vp10_reader *r) { int i; #if CONFIG_REF_MV for (i = 0; i < NEWMV_MODE_CONTEXTS; ++i) @@ -130,9 +130,9 @@ static void read_inter_mode_probs(FRAME_CONTEXT *fc, vpx_reader *r) { } #if CONFIG_EXT_INTER -static void read_inter_compound_mode_probs(FRAME_CONTEXT *fc, vpx_reader *r) { +static void read_inter_compound_mode_probs(FRAME_CONTEXT *fc, vp10_reader *r) { int i, j; - if (vpx_read(r, GROUP_DIFF_UPDATE_PROB)) { + if (vp10_read(r, GROUP_DIFF_UPDATE_PROB)) { for (j = 0; j < INTER_MODE_CONTEXTS; ++j) { for (i = 0; i < INTER_COMPOUND_MODES - 1; ++i) { vp10_diff_update_prob(r, &fc->inter_compound_mode_probs[j][i]); @@ -153,7 +153,7 @@ static REFERENCE_MODE read_frame_reference_mode(const VP10_COMMON *cm, } } -static void read_frame_reference_mode_probs(VP10_COMMON *cm, vpx_reader *r) { +static void read_frame_reference_mode_probs(VP10_COMMON *cm, vp10_reader *r) { FRAME_CONTEXT *const fc = cm->fc; int i, j; @@ -178,13 +178,13 @@ static void read_frame_reference_mode_probs(VP10_COMMON *cm, vpx_reader *r) { } } -static void update_mv_probs(vpx_prob *p, int n, vpx_reader *r) { +static void update_mv_probs(vpx_prob *p, int n, vp10_reader *r) { int i; for (i = 0; i < n; ++i) vp10_diff_update_prob(r, &p[i]); } -static void read_mv_probs(nmv_context *ctx, int allow_hp, vpx_reader *r) { +static void read_mv_probs(nmv_context *ctx, int allow_hp, vp10_reader *r) { int i, j; update_mv_probs(ctx->joints, MV_JOINTS - 1, r); @@ -262,7 +262,7 @@ static void predict_and_reconstruct_intra_block(MACROBLOCKD *const xd, const rans_dec_lut *const token_tab, struct AnsDecoder *const r, #else - vpx_reader *r, + vp10_reader *r, #endif // CONFIG_ANS MB_MODE_INFO *const mbmi, int plane, @@ -298,7 +298,7 @@ static void predict_and_reconstruct_intra_block(MACROBLOCKD *const xd, } #if CONFIG_VAR_TX -static void decode_reconstruct_tx(MACROBLOCKD *const xd, vpx_reader *r, +static void decode_reconstruct_tx(MACROBLOCKD *const xd, vp10_reader *r, MB_MODE_INFO *const mbmi, int plane, BLOCK_SIZE plane_bsize, int block, int blk_row, int blk_col, @@ -360,7 +360,7 @@ static int reconstruct_inter_block(MACROBLOCKD *const xd, const rans_dec_lut *const token_tab, struct AnsDecoder *const r, #else - vpx_reader *r, + vp10_reader *r, #endif MB_MODE_INFO *const mbmi, int plane, int row, int col, TX_SIZE tx_size) { @@ -1808,7 +1808,7 @@ static void decode_block(VP10Decoder *const pbi, MACROBLOCKD *const xd, int supertx_enabled, #endif // CONFIG_SUPERTX int mi_row, int mi_col, - vpx_reader *r, + vp10_reader *r, #if CONFIG_ANS struct AnsDecoder *const tok, #endif // CONFIG_ANS @@ -2008,7 +2008,7 @@ static void decode_block(VP10Decoder *const pbi, MACROBLOCKD *const xd, } #endif // CONFIG_SUPERTX - xd->corrupted |= vpx_reader_has_error(r); + xd->corrupted |= vp10_reader_has_error(r); } static INLINE int dec_partition_plane_context(const MACROBLOCKD *xd, @@ -2042,7 +2042,7 @@ static INLINE void dec_update_partition_context(MACROBLOCKD *xd, #endif // !CONFIG_EXT_PARTITION_TYPES static PARTITION_TYPE read_partition(VP10_COMMON *cm, MACROBLOCKD *xd, - int mi_row, int mi_col, vpx_reader *r, + int mi_row, int mi_col, vp10_reader *r, int has_rows, int has_cols, #if CONFIG_EXT_PARTITION_TYPES BLOCK_SIZE bsize, @@ -2056,16 +2056,16 @@ static PARTITION_TYPE read_partition(VP10_COMMON *cm, MACROBLOCKD *xd, if (has_rows && has_cols) #if CONFIG_EXT_PARTITION_TYPES if (bsize <= BLOCK_8X8) - p = (PARTITION_TYPE)vpx_read_tree(r, vp10_partition_tree, probs); + p = (PARTITION_TYPE)vp10_read_tree(r, vp10_partition_tree, probs); else - p = (PARTITION_TYPE)vpx_read_tree(r, vp10_ext_partition_tree, probs); + p = (PARTITION_TYPE)vp10_read_tree(r, vp10_ext_partition_tree, probs); #else - p = (PARTITION_TYPE)vpx_read_tree(r, vp10_partition_tree, probs); + p = (PARTITION_TYPE)vp10_read_tree(r, vp10_partition_tree, probs); #endif // CONFIG_EXT_PARTITION_TYPES else if (!has_rows && has_cols) - p = vpx_read(r, probs[1]) ? PARTITION_SPLIT : PARTITION_HORZ; + p = vp10_read(r, probs[1]) ? PARTITION_SPLIT : PARTITION_HORZ; else if (has_rows && !has_cols) - p = vpx_read(r, probs[2]) ? PARTITION_SPLIT : PARTITION_VERT; + p = vp10_read(r, probs[2]) ? PARTITION_SPLIT : PARTITION_VERT; else p = PARTITION_SPLIT; @@ -2077,9 +2077,9 @@ static PARTITION_TYPE read_partition(VP10_COMMON *cm, MACROBLOCKD *xd, #if CONFIG_SUPERTX static int read_skip_without_seg(VP10_COMMON *cm, const MACROBLOCKD *xd, - vpx_reader *r) { + vp10_reader *r) { const int ctx = vp10_get_skip_context(xd); - const int skip = vpx_read(r, cm->fc->skip_probs[ctx]); + const int skip = vp10_read(r, cm->fc->skip_probs[ctx]); FRAME_COUNTS *counts = xd->counts; if (counts) ++counts->skip[ctx][skip]; @@ -2093,7 +2093,7 @@ static void decode_partition(VP10Decoder *const pbi, MACROBLOCKD *const xd, int supertx_enabled, #endif int mi_row, int mi_col, - vpx_reader* r, + vp10_reader* r, #if CONFIG_ANS struct AnsDecoder *const tok, #endif // CONFIG_ANS @@ -2134,7 +2134,7 @@ static void decode_partition(VP10Decoder *const pbi, MACROBLOCKD *const xd, !xd->lossless[0]) { const int supertx_context = partition_supertx_context_lookup[partition]; - supertx_enabled = vpx_read( + supertx_enabled = vp10_read( r, cm->fc->supertx_prob[supertx_context][supertx_size]); if (xd->counts) xd->counts->supertx[supertx_context][supertx_size][supertx_enabled]++; @@ -2156,7 +2156,7 @@ static void decode_partition(VP10Decoder *const pbi, MACROBLOCKD *const xd, if (get_ext_tx_types(supertx_size, bsize, 1) > 1) { int eset = get_ext_tx_set(supertx_size, bsize, 1); if (eset > 0) { - txfm = vpx_read_tree(r, vp10_ext_tx_inter_tree[eset], + txfm = vp10_read_tree(r, vp10_ext_tx_inter_tree[eset], cm->fc->inter_ext_tx_prob[eset][supertx_size]); if (xd->counts) ++xd->counts->inter_ext_tx[eset][supertx_size][txfm]; @@ -2164,7 +2164,7 @@ static void decode_partition(VP10Decoder *const pbi, MACROBLOCKD *const xd, } #else if (supertx_size < TX_32X32) { - txfm = vpx_read_tree(r, vp10_ext_tx_tree, + txfm = vp10_read_tree(r, vp10_ext_tx_tree, cm->fc->inter_ext_tx_prob[supertx_size]); if (xd->counts) ++xd->counts->inter_ext_tx[supertx_size][txfm]; @@ -2514,11 +2514,12 @@ static void decode_partition(VP10Decoder *const pbi, MACROBLOCKD *const xd, #endif // CONFIG_EXT_PARTITION_TYPES } +#if !CONFIG_ANS static void setup_bool_decoder(const uint8_t *data, const uint8_t *data_end, const size_t read_size, struct vpx_internal_error_info *error_info, - vpx_reader *r, + vp10_reader *r, vpx_decrypt_cb decrypt_cb, void *decrypt_state) { // Validate the calculated partition length. If the buffer @@ -2532,7 +2533,7 @@ static void setup_bool_decoder(const uint8_t *data, vpx_internal_error(error_info, VPX_CODEC_MEM_ERROR, "Failed to allocate bool decoder %d", 1); } -#if CONFIG_ANS +#else static void setup_token_decoder(const uint8_t *data, const uint8_t *data_end, const size_t read_size, @@ -2556,10 +2557,10 @@ static void setup_token_decoder(const uint8_t *data, #endif static void read_coef_probs_common(vp10_coeff_probs_model *coef_probs, - vpx_reader *r) { + vp10_reader *r) { int i, j, k, l, m; - if (vpx_read_bit(r)) + if (vp10_read_bit(r)) for (i = 0; i < PLANE_TYPES; ++i) for (j = 0; j < REF_TYPES; ++j) for (k = 0; k < COEF_BANDS; ++k) @@ -2569,7 +2570,7 @@ static void read_coef_probs_common(vp10_coeff_probs_model *coef_probs, } static void read_coef_probs(FRAME_CONTEXT *fc, TX_MODE tx_mode, - vpx_reader *r) { + vp10_reader *r) { const TX_SIZE max_tx_size = tx_mode_to_biggest_tx_size[tx_mode]; TX_SIZE tx_size; for (tx_size = TX_4X4; tx_size <= max_tx_size; ++tx_size) @@ -3239,14 +3240,18 @@ static const uint8_t *decode_tiles(VP10Decoder *pbi, &cm->counts : NULL; vp10_zero(td->dqcoeff); vp10_tile_init(&td->xd.tile, td->cm, tile_row, tile_col); +#if !CONFIG_ANS setup_bool_decoder(buf->data, data_end, buf->size, &cm->error, - &td->bit_reader, - pbi->decrypt_cb, pbi->decrypt_state); -#if CONFIG_ANS + &td->bit_reader, pbi->decrypt_cb, + pbi->decrypt_state); +#else + if (buf->size < 3 || !read_is_valid(buf->data, buf->size, data_end)) + vpx_internal_error(&cm->error, VPX_CODEC_CORRUPT_FRAME, + "Truncated packet or corrupt tile length"); setup_token_decoder(buf->data, data_end, buf->size, &cm->error, - &td->token_ans, - pbi->decrypt_cb, pbi->decrypt_state); -#endif // CONFIG_ANS + &td->bit_reader, pbi->decrypt_cb, + pbi->decrypt_state); +#endif vp10_init_macroblockd(cm, &td->xd, td->dqcoeff); td->xd.plane[0].color_index_map = td->color_index_map[0]; td->xd.plane[1].color_index_map = td->color_index_map[1]; @@ -3281,7 +3286,7 @@ static const uint8_t *decode_tiles(VP10Decoder *pbi, #endif // CONFIG_SUPERTX mi_row, mi_col, &td->bit_reader, #if CONFIG_ANS - &td->token_ans, + &td->bit_reader, #endif // CONFIG_ANS BLOCK_LARGEST, MAX_SB_SIZE_LOG2 - 2); } @@ -3396,7 +3401,7 @@ static int tile_worker_hook(TileWorkerData *const tile_data, #endif mi_row, mi_col, &tile_data->bit_reader, #if CONFIG_ANS - &tile_data->token_ans, + &tile_data->bit_reader, #endif // CONFIG_ANS BLOCK_LARGEST, MAX_SB_SIZE_LOG2 - 2); } @@ -3537,12 +3542,13 @@ static const uint8_t *decode_tiles_mt(VP10Decoder *pbi, vp10_zero(twd->dqcoeff); vp10_tile_init(tile_info, cm, tile_row, buf->col); vp10_tile_init(&twd->xd.tile, cm, tile_row, buf->col); +#if !CONFIG_ANS setup_bool_decoder(buf->data, data_end, buf->size, &cm->error, &twd->bit_reader, pbi->decrypt_cb, pbi->decrypt_state); -#if CONFIG_ANS +#else setup_token_decoder(buf->data, data_end, buf->size, &cm->error, - &twd->token_ans, pbi->decrypt_cb, + &twd->bit_reader, pbi->decrypt_cb, pbi->decrypt_state); #endif // CONFIG_ANS vp10_init_macroblockd(cm, &twd->xd, twd->dqcoeff); @@ -3900,11 +3906,11 @@ static size_t read_uncompressed_header(VP10Decoder *pbi, } #if CONFIG_EXT_TX -static void read_ext_tx_probs(FRAME_CONTEXT *fc, vpx_reader *r) { +static void read_ext_tx_probs(FRAME_CONTEXT *fc, vp10_reader *r) { int i, j, k; int s; for (s = 1; s < EXT_TX_SETS_INTER; ++s) { - if (vpx_read(r, GROUP_DIFF_UPDATE_PROB)) { + if (vp10_read(r, GROUP_DIFF_UPDATE_PROB)) { for (i = TX_4X4; i < EXT_TX_SIZES; ++i) { if (!use_inter_ext_tx_for_txsize[s][i]) continue; for (j = 0; j < num_ext_tx_set_inter[s] - 1; ++j) @@ -3914,7 +3920,7 @@ static void read_ext_tx_probs(FRAME_CONTEXT *fc, vpx_reader *r) { } for (s = 1; s < EXT_TX_SETS_INTRA; ++s) { - if (vpx_read(r, GROUP_DIFF_UPDATE_PROB)) { + if (vp10_read(r, GROUP_DIFF_UPDATE_PROB)) { for (i = TX_4X4; i < EXT_TX_SIZES; ++i) { if (!use_intra_ext_tx_for_txsize[s][i]) continue; for (j = 0; j < INTRA_MODES; ++j) @@ -3927,16 +3933,16 @@ static void read_ext_tx_probs(FRAME_CONTEXT *fc, vpx_reader *r) { #else -static void read_ext_tx_probs(FRAME_CONTEXT *fc, vpx_reader *r) { +static void read_ext_tx_probs(FRAME_CONTEXT *fc, vp10_reader *r) { int i, j, k; - if (vpx_read(r, GROUP_DIFF_UPDATE_PROB)) { + if (vp10_read(r, GROUP_DIFF_UPDATE_PROB)) { for (i = TX_4X4; i < EXT_TX_SIZES; ++i) { for (j = 0; j < TX_TYPES; ++j) for (k = 0; k < TX_TYPES - 1; ++k) vp10_diff_update_prob(r, &fc->intra_ext_tx_prob[i][j][k]); } } - if (vpx_read(r, GROUP_DIFF_UPDATE_PROB)) { + if (vp10_read(r, GROUP_DIFF_UPDATE_PROB)) { for (i = TX_4X4; i < EXT_TX_SIZES; ++i) { for (k = 0; k < TX_TYPES - 1; ++k) vp10_diff_update_prob(r, &fc->inter_ext_tx_prob[i][k]); @@ -3946,9 +3952,9 @@ static void read_ext_tx_probs(FRAME_CONTEXT *fc, vpx_reader *r) { #endif // CONFIG_EXT_TX #if CONFIG_SUPERTX -static void read_supertx_probs(FRAME_CONTEXT *fc, vpx_reader *r) { +static void read_supertx_probs(FRAME_CONTEXT *fc, vp10_reader *r) { int i, j; - if (vpx_read(r, GROUP_DIFF_UPDATE_PROB)) { + if (vp10_read(r, GROUP_DIFF_UPDATE_PROB)) { for (i = 0; i < PARTITION_SUPERTX_CONTEXTS; ++i) { for (j = 1; j < TX_SIZES; ++j) { vp10_diff_update_prob(r, &fc->supertx_prob[i][j]); @@ -3965,13 +3971,19 @@ static int read_compressed_header(VP10Decoder *pbi, const uint8_t *data, MACROBLOCKD *const xd = &pbi->mb; #endif FRAME_CONTEXT *const fc = cm->fc; - vpx_reader r; + vp10_reader r; int k, i, j; +#if !CONFIG_ANS if (vpx_reader_init(&r, data, partition_size, pbi->decrypt_cb, pbi->decrypt_state)) vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, "Failed to allocate bool decoder 0"); +#else + if (ans_read_init(&r, data, partition_size)) + vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, + "Failed to allocate compressed header ANS decoder"); +#endif // !CONFIG_ANS if (cm->tx_mode == TX_MODE_SELECT) { for (i = 0; i < TX_SIZES - 1; ++i) @@ -4093,7 +4105,7 @@ static int read_compressed_header(VP10Decoder *pbi, const uint8_t *data, #endif } - return vpx_reader_has_error(&r); + return vp10_reader_has_error(&r); } #ifdef NDEBUG diff --git a/vp10/decoder/decodemv.c b/vp10/decoder/decodemv.c index 5cecb1e62..a1b348ab6 100644 --- a/vp10/decoder/decodemv.c +++ b/vp10/decoder/decodemv.c @@ -24,25 +24,25 @@ #include "vpx_dsp/vpx_dsp_common.h" -static INLINE int read_uniform(vpx_reader *r, int n) { +static INLINE int read_uniform(vp10_reader *r, int n) { int l = get_unsigned_bits(n); int m = (1 << l) - n; - int v = vpx_read_literal(r, l-1); + int v = vp10_read_literal(r, l-1); assert(l != 0); if (v < m) return v; else - return (v << 1) - m + vpx_read_literal(r, 1); + return (v << 1) - m + vp10_read_literal(r, 1); } -static PREDICTION_MODE read_intra_mode(vpx_reader *r, const vpx_prob *p) { - return (PREDICTION_MODE)vpx_read_tree(r, vp10_intra_mode_tree, p); +static PREDICTION_MODE read_intra_mode(vp10_reader *r, const vpx_prob *p) { + return (PREDICTION_MODE)vp10_read_tree(r, vp10_intra_mode_tree, p); } static PREDICTION_MODE read_intra_mode_y(VP10_COMMON *cm, MACROBLOCKD *xd, - vpx_reader *r, int size_group) { + vp10_reader *r, int size_group) { const PREDICTION_MODE y_mode = read_intra_mode(r, cm->fc->y_mode_prob[size_group]); FRAME_COUNTS *counts = xd->counts; @@ -52,7 +52,7 @@ static PREDICTION_MODE read_intra_mode_y(VP10_COMMON *cm, MACROBLOCKD *xd, } static PREDICTION_MODE read_intra_mode_uv(VP10_COMMON *cm, MACROBLOCKD *xd, - vpx_reader *r, + vp10_reader *r, PREDICTION_MODE y_mode) { const PREDICTION_MODE uv_mode = read_intra_mode(r, cm->fc->uv_mode_prob[y_mode]); @@ -79,13 +79,13 @@ static PREDICTION_MODE read_inter_mode(VP10_COMMON *cm, MACROBLOCKD *xd, #if CONFIG_REF_MV && CONFIG_EXT_INTER MB_MODE_INFO *mbmi, #endif - vpx_reader *r, int16_t ctx) { + vp10_reader *r, int16_t ctx) { #if CONFIG_REF_MV FRAME_COUNTS *counts = xd->counts; int16_t mode_ctx = ctx & NEWMV_CTX_MASK; vpx_prob mode_prob = cm->fc->newmv_prob[mode_ctx]; - if (vpx_read(r, mode_prob) == 0) { + if (vp10_read(r, mode_prob) == 0) { if (counts) ++counts->newmv_mode[mode_ctx][0]; @@ -96,7 +96,7 @@ static PREDICTION_MODE read_inter_mode(VP10_COMMON *cm, MACROBLOCKD *xd, #if CONFIG_EXT_INTER } else { mode_prob = cm->fc->new2mv_prob; - if (vpx_read(r, mode_prob) == 0) { + if (vp10_read(r, mode_prob) == 0) { if (counts) ++counts->new2mv_mode[0]; return NEWMV; @@ -117,7 +117,7 @@ static PREDICTION_MODE read_inter_mode(VP10_COMMON *cm, MACROBLOCKD *xd, mode_ctx = (ctx >> ZEROMV_OFFSET) & ZEROMV_CTX_MASK; mode_prob = cm->fc->zeromv_prob[mode_ctx]; - if (vpx_read(r, mode_prob) == 0) { + if (vp10_read(r, mode_prob) == 0) { if (counts) ++counts->zeromv_mode[mode_ctx][0]; return ZEROMV; @@ -136,7 +136,7 @@ static PREDICTION_MODE read_inter_mode(VP10_COMMON *cm, MACROBLOCKD *xd, mode_prob = cm->fc->refmv_prob[mode_ctx]; - if (vpx_read(r, mode_prob) == 0) { + if (vp10_read(r, mode_prob) == 0) { if (counts) ++counts->refmv_mode[mode_ctx][0]; @@ -150,7 +150,7 @@ static PREDICTION_MODE read_inter_mode(VP10_COMMON *cm, MACROBLOCKD *xd, // Invalid prediction mode. assert(0); #else - const int mode = vpx_read_tree(r, vp10_inter_mode_tree, + const int mode = vp10_read_tree(r, vp10_inter_mode_tree, cm->fc->inter_mode_probs[ctx]); FRAME_COUNTS *counts = xd->counts; if (counts) @@ -164,7 +164,7 @@ static PREDICTION_MODE read_inter_mode(VP10_COMMON *cm, MACROBLOCKD *xd, static void read_drl_idx(const VP10_COMMON *cm, MACROBLOCKD *xd, MB_MODE_INFO *mbmi, - vpx_reader *r) { + vp10_reader *r) { uint8_t ref_frame_type = vp10_ref_frame_type(mbmi->ref_frame); mbmi->ref_mv_idx = 0; @@ -174,7 +174,7 @@ static void read_drl_idx(const VP10_COMMON *cm, if (xd->ref_mv_count[ref_frame_type] > idx + 1) { uint8_t drl_ctx = vp10_drl_ctx(xd->ref_mv_stack[ref_frame_type], idx); vpx_prob drl_prob = cm->fc->drl_prob[drl_ctx]; - if (!vpx_read(r, drl_prob)) { + if (!vp10_read(r, drl_prob)) { mbmi->ref_mv_idx = idx; if (xd->counts) ++xd->counts->drl_mode[drl_ctx][0]; @@ -196,7 +196,7 @@ static void read_drl_idx(const VP10_COMMON *cm, if (xd->ref_mv_count[ref_frame_type] > idx + 1) { uint8_t drl_ctx = vp10_drl_ctx(xd->ref_mv_stack[ref_frame_type], idx); vpx_prob drl_prob = cm->fc->drl_prob[drl_ctx]; - if (!vpx_read(r, drl_prob)) { + if (!vp10_read(r, drl_prob)) { mbmi->ref_mv_idx = idx - 1; if (xd->counts) ++xd->counts->drl_mode[drl_ctx][0]; @@ -214,8 +214,8 @@ static void read_drl_idx(const VP10_COMMON *cm, #if CONFIG_EXT_INTER static PREDICTION_MODE read_inter_compound_mode(VP10_COMMON *cm, MACROBLOCKD *xd, - vpx_reader *r, int16_t ctx) { - const int mode = vpx_read_tree(r, vp10_inter_compound_mode_tree, + vp10_reader *r, int16_t ctx) { + const int mode = vp10_read_tree(r, vp10_inter_compound_mode_tree, cm->fc->inter_compound_mode_probs[ctx]); FRAME_COUNTS *counts = xd->counts; @@ -227,16 +227,16 @@ static PREDICTION_MODE read_inter_compound_mode(VP10_COMMON *cm, } #endif // CONFIG_EXT_INTER -static int read_segment_id(vpx_reader *r, +static int read_segment_id(vp10_reader *r, const struct segmentation_probs *segp) { - return vpx_read_tree(r, vp10_segment_tree, segp->tree_probs); + return vp10_read_tree(r, vp10_segment_tree, segp->tree_probs); } #if CONFIG_VAR_TX static void read_tx_size_inter(VP10_COMMON *cm, MACROBLOCKD *xd, MB_MODE_INFO *mbmi, FRAME_COUNTS *counts, TX_SIZE tx_size, int blk_row, int blk_col, - vpx_reader *r) { + vp10_reader *r) { int is_split = 0; const int tx_row = blk_row >> 1; const int tx_col = blk_col >> 1; @@ -256,7 +256,7 @@ static void read_tx_size_inter(VP10_COMMON *cm, MACROBLOCKD *xd, if (blk_row >= max_blocks_high || blk_col >= max_blocks_wide) return; - is_split = vpx_read(r, cm->fc->txfm_partition_prob[ctx]); + is_split = vp10_read(r, cm->fc->txfm_partition_prob[ctx]); if (is_split) { BLOCK_SIZE bsize = txsize_to_bsize[tx_size]; @@ -298,11 +298,11 @@ static void read_tx_size_inter(VP10_COMMON *cm, MACROBLOCKD *xd, #endif static TX_SIZE read_selected_tx_size(VP10_COMMON *cm, MACROBLOCKD *xd, - TX_SIZE max_tx_size, vpx_reader *r) { + TX_SIZE max_tx_size, vp10_reader *r) { FRAME_COUNTS *counts = xd->counts; const int ctx = get_tx_size_context(xd); const int tx_size_cat = max_tx_size - TX_8X8; - int tx_size = vpx_read_tree(r, vp10_tx_size_tree[tx_size_cat], + int tx_size = vp10_read_tree(r, vp10_tx_size_tree[tx_size_cat], cm->fc->tx_size_probs[tx_size_cat][ctx]); if (counts) ++counts->tx_size[tx_size_cat][ctx][tx_size]; @@ -310,7 +310,7 @@ static TX_SIZE read_selected_tx_size(VP10_COMMON *cm, MACROBLOCKD *xd, } static TX_SIZE read_tx_size(VP10_COMMON *cm, MACROBLOCKD *xd, - int allow_select, vpx_reader *r) { + int allow_select, vp10_reader *r) { TX_MODE tx_mode = cm->tx_mode; BLOCK_SIZE bsize = xd->mi[0]->mbmi.sb_type; const TX_SIZE max_tx_size = max_txsize_lookup[bsize]; @@ -348,7 +348,7 @@ static void set_segment_id(VP10_COMMON *cm, int mi_offset, static int read_intra_segment_id(VP10_COMMON *const cm, MACROBLOCKD *const xd, int mi_offset, int x_mis, int y_mis, - vpx_reader *r) { + vp10_reader *r) { struct segmentation *const seg = &cm->seg; FRAME_COUNTS *counts = xd->counts; struct segmentation_probs *const segp = &cm->fc->seg; @@ -379,7 +379,7 @@ static void copy_segment_id(const VP10_COMMON *cm, } static int read_inter_segment_id(VP10_COMMON *const cm, MACROBLOCKD *const xd, - int mi_row, int mi_col, vpx_reader *r) { + int mi_row, int mi_col, vp10_reader *r) { struct segmentation *const seg = &cm->seg; FRAME_COUNTS *counts = xd->counts; struct segmentation_probs *const segp = &cm->fc->seg; @@ -409,7 +409,7 @@ static int read_inter_segment_id(VP10_COMMON *const cm, MACROBLOCKD *const xd, if (seg->temporal_update) { const int ctx = vp10_get_pred_context_seg_id(xd); const vpx_prob pred_prob = segp->pred_probs[ctx]; - mbmi->seg_id_predicted = vpx_read(r, pred_prob); + mbmi->seg_id_predicted = vp10_read(r, pred_prob); if (counts) ++counts->seg.pred[ctx][mbmi->seg_id_predicted]; if (mbmi->seg_id_predicted) { @@ -429,12 +429,12 @@ static int read_inter_segment_id(VP10_COMMON *const cm, MACROBLOCKD *const xd, } static int read_skip(VP10_COMMON *cm, const MACROBLOCKD *xd, - int segment_id, vpx_reader *r) { + int segment_id, vp10_reader *r) { if (segfeature_active(&cm->seg, segment_id, SEG_LVL_SKIP)) { return 1; } else { const int ctx = vp10_get_skip_context(xd); - const int skip = vpx_read(r, cm->fc->skip_probs[ctx]); + const int skip = vp10_read(r, cm->fc->skip_probs[ctx]); FRAME_COUNTS *counts = xd->counts; if (counts) ++counts->skip[ctx][skip]; @@ -444,7 +444,7 @@ static int read_skip(VP10_COMMON *cm, const MACROBLOCKD *xd, static void read_palette_mode_info(VP10_COMMON *const cm, MACROBLOCKD *const xd, - vpx_reader *r) { + vp10_reader *r) { MODE_INFO *const mi = xd->mi[0]; MB_MODE_INFO *const mbmi = &mi->mbmi; const MODE_INFO *const above_mi = xd->above_mi; @@ -458,14 +458,14 @@ static void read_palette_mode_info(VP10_COMMON *const cm, palette_ctx += (above_mi->mbmi.palette_mode_info.palette_size[0] > 0); if (left_mi) palette_ctx += (left_mi->mbmi.palette_mode_info.palette_size[0] > 0); - if (vpx_read(r, vp10_default_palette_y_mode_prob[bsize - BLOCK_8X8] + if (vp10_read(r, vp10_default_palette_y_mode_prob[bsize - BLOCK_8X8] [palette_ctx])) { pmi->palette_size[0] = - vpx_read_tree(r, vp10_palette_size_tree, + vp10_read_tree(r, vp10_palette_size_tree, vp10_default_palette_y_size_prob[bsize - BLOCK_8X8]) + 2; n = pmi->palette_size[0]; for (i = 0; i < n; ++i) - pmi->palette_colors[i] = vpx_read_literal(r, cm->bit_depth); + pmi->palette_colors[i] = vp10_read_literal(r, cm->bit_depth); xd->plane[0].color_index_map[0] = read_uniform(r, n); assert(xd->plane[0].color_index_map[0] < n); @@ -473,18 +473,18 @@ static void read_palette_mode_info(VP10_COMMON *const cm, } if (mbmi->uv_mode == DC_PRED) { - if (vpx_read(r, + if (vp10_read(r, vp10_default_palette_uv_mode_prob[pmi->palette_size[0] > 0])) { pmi->palette_size[1] = - vpx_read_tree(r, vp10_palette_size_tree, + vp10_read_tree(r, vp10_palette_size_tree, vp10_default_palette_uv_size_prob[bsize - BLOCK_8X8]) + 2; n = pmi->palette_size[1]; for (i = 0; i < n; ++i) { pmi->palette_colors[PALETTE_MAX_SIZE + i] = - vpx_read_literal(r, cm->bit_depth); + vp10_read_literal(r, cm->bit_depth); pmi->palette_colors[2 * PALETTE_MAX_SIZE + i] = - vpx_read_literal(r, cm->bit_depth); + vp10_read_literal(r, cm->bit_depth); } xd->plane[1].color_index_map[0] = read_uniform(r, n); assert(xd->plane[1].color_index_map[0] < n); @@ -494,7 +494,7 @@ static void read_palette_mode_info(VP10_COMMON *const cm, #if CONFIG_EXT_INTRA static void read_ext_intra_mode_info(VP10_COMMON *const cm, - MACROBLOCKD *const xd, vpx_reader *r) { + MACROBLOCKD *const xd, vp10_reader *r) { MODE_INFO *const mi = xd->mi[0]; MB_MODE_INFO *const mbmi = &mi->mbmi; FRAME_COUNTS *counts = xd->counts; @@ -505,7 +505,7 @@ static void read_ext_intra_mode_info(VP10_COMMON *const cm, if (mbmi->mode == DC_PRED && mbmi->palette_mode_info.palette_size[0] == 0) { mbmi->ext_intra_mode_info.use_ext_intra_mode[0] = - vpx_read(r, cm->fc->ext_intra_probs[0]); + vp10_read(r, cm->fc->ext_intra_probs[0]); if (mbmi->ext_intra_mode_info.use_ext_intra_mode[0]) { mbmi->ext_intra_mode_info.ext_intra_mode[0] = read_uniform(r, FILTER_INTRA_MODES); @@ -516,7 +516,7 @@ static void read_ext_intra_mode_info(VP10_COMMON *const cm, if (mbmi->uv_mode == DC_PRED && mbmi->palette_mode_info.palette_size[1] == 0) { mbmi->ext_intra_mode_info.use_ext_intra_mode[1] = - vpx_read(r, cm->fc->ext_intra_probs[1]); + vp10_read(r, cm->fc->ext_intra_probs[1]); if (mbmi->ext_intra_mode_info.use_ext_intra_mode[1]) { mbmi->ext_intra_mode_info.ext_intra_mode[1] = read_uniform(r, FILTER_INTRA_MODES); @@ -529,7 +529,7 @@ static void read_ext_intra_mode_info(VP10_COMMON *const cm, static void read_intra_frame_mode_info(VP10_COMMON *const cm, MACROBLOCKD *const xd, - int mi_row, int mi_col, vpx_reader *r) { + int mi_row, int mi_col, vp10_reader *r) { MODE_INFO *const mi = xd->mi[0]; MB_MODE_INFO *const mbmi = &mi->mbmi; const MODE_INFO *above_mi = xd->above_mi; @@ -582,7 +582,7 @@ static void read_intra_frame_mode_info(VP10_COMMON *const cm, mbmi->angle_delta[0] * ANGLE_STEP; if (pick_intra_filter(p_angle)) { FRAME_COUNTS *counts = xd->counts; - mbmi->intra_filter = vpx_read_tree(r, vp10_intra_filter_tree, + mbmi->intra_filter = vp10_read_tree(r, vp10_intra_filter_tree, cm->fc->intra_filter_probs[ctx]); if (counts) ++counts->intra_filter[ctx][mbmi->intra_filter]; @@ -615,7 +615,7 @@ static void read_intra_frame_mode_info(VP10_COMMON *const cm, FRAME_COUNTS *counts = xd->counts; int eset = get_ext_tx_set(mbmi->tx_size, mbmi->sb_type, 0); if (eset > 0) { - mbmi->tx_type = vpx_read_tree( + mbmi->tx_type = vp10_read_tree( r, vp10_ext_tx_intra_tree[eset], cm->fc->intra_ext_tx_prob[eset][mbmi->tx_size][mbmi->mode]); if (counts) @@ -631,7 +631,7 @@ static void read_intra_frame_mode_info(VP10_COMMON *const cm, !segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) { FRAME_COUNTS *counts = xd->counts; TX_TYPE tx_type_nom = intra_mode_to_tx_type_context[mbmi->mode]; - mbmi->tx_type = vpx_read_tree( + mbmi->tx_type = vp10_read_tree( r, vp10_ext_tx_tree, cm->fc->intra_ext_tx_prob[mbmi->tx_size][tx_type_nom]); if (counts) @@ -650,16 +650,16 @@ static void read_intra_frame_mode_info(VP10_COMMON *const cm, #endif // CONFIG_EXT_INTRA } -static int read_mv_component(vpx_reader *r, +static int read_mv_component(vp10_reader *r, const nmv_component *mvcomp, int usehp) { int mag, d, fr, hp; - const int sign = vpx_read(r, mvcomp->sign); - const int mv_class = vpx_read_tree(r, vp10_mv_class_tree, mvcomp->classes); + const int sign = vp10_read(r, mvcomp->sign); + const int mv_class = vp10_read_tree(r, vp10_mv_class_tree, mvcomp->classes); const int class0 = mv_class == MV_CLASS_0; // Integer part if (class0) { - d = vpx_read_tree(r, vp10_mv_class0_tree, mvcomp->class0); + d = vp10_read_tree(r, vp10_mv_class0_tree, mvcomp->class0); mag = 0; } else { int i; @@ -667,16 +667,16 @@ static int read_mv_component(vpx_reader *r, d = 0; for (i = 0; i < n; ++i) - d |= vpx_read(r, mvcomp->bits[i]) << i; + d |= vp10_read(r, mvcomp->bits[i]) << i; mag = CLASS0_SIZE << (mv_class + 2); } // Fractional part - fr = vpx_read_tree(r, vp10_mv_fp_tree, class0 ? mvcomp->class0_fp[d] + fr = vp10_read_tree(r, vp10_mv_fp_tree, class0 ? mvcomp->class0_fp[d] : mvcomp->fp); // High precision part (if hp is not used, the default value of the hp is 1) - hp = usehp ? vpx_read(r, class0 ? mvcomp->class0_hp : mvcomp->hp) + hp = usehp ? vp10_read(r, class0 ? mvcomp->class0_hp : mvcomp->hp) : 1; // Result @@ -684,11 +684,11 @@ static int read_mv_component(vpx_reader *r, return sign ? -mag : mag; } -static INLINE void read_mv(vpx_reader *r, MV *mv, const MV *ref, +static INLINE void read_mv(vp10_reader *r, MV *mv, const MV *ref, const nmv_context *ctx, nmv_context_counts *counts, int allow_hp) { const MV_JOINT_TYPE joint_type = - (MV_JOINT_TYPE)vpx_read_tree(r, vp10_mv_joint_tree, ctx->joints); + (MV_JOINT_TYPE)vp10_read_tree(r, vp10_mv_joint_tree, ctx->joints); const int use_hp = allow_hp && vp10_use_mv_hp(ref); MV diff = {0, 0}; @@ -706,11 +706,11 @@ static INLINE void read_mv(vpx_reader *r, MV *mv, const MV *ref, static REFERENCE_MODE read_block_reference_mode(VP10_COMMON *cm, const MACROBLOCKD *xd, - vpx_reader *r) { + vp10_reader *r) { if (cm->reference_mode == REFERENCE_MODE_SELECT) { const int ctx = vp10_get_reference_mode_context(cm, xd); const REFERENCE_MODE mode = - (REFERENCE_MODE)vpx_read(r, cm->fc->comp_inter_prob[ctx]); + (REFERENCE_MODE)vp10_read(r, cm->fc->comp_inter_prob[ctx]); FRAME_COUNTS *counts = xd->counts; if (counts) ++counts->comp_inter[ctx][mode]; @@ -722,7 +722,7 @@ static REFERENCE_MODE read_block_reference_mode(VP10_COMMON *cm, // Read the referncence frame static void read_ref_frames(VP10_COMMON *const cm, MACROBLOCKD *const xd, - vpx_reader *r, + vp10_reader *r, int segment_id, MV_REFERENCE_FRAME ref_frame[2]) { FRAME_CONTEXT *const fc = cm->fc; FRAME_COUNTS *counts = xd->counts; @@ -737,7 +737,7 @@ static void read_ref_frames(VP10_COMMON *const cm, MACROBLOCKD *const xd, if (mode == COMPOUND_REFERENCE) { const int idx = cm->ref_frame_sign_bias[cm->comp_fixed_ref]; const int ctx = vp10_get_pred_context_comp_ref_p(cm, xd); - const int bit = vpx_read(r, fc->comp_ref_prob[ctx][0]); + const int bit = vp10_read(r, fc->comp_ref_prob[ctx][0]); if (counts) ++counts->comp_ref[ctx][0][bit]; ref_frame[idx] = cm->comp_fixed_ref; @@ -745,18 +745,18 @@ static void read_ref_frames(VP10_COMMON *const cm, MACROBLOCKD *const xd, #if CONFIG_EXT_REFS if (!bit) { const int ctx1 = vp10_get_pred_context_comp_ref_p1(cm, xd); - const int bit1 = vpx_read(r, fc->comp_ref_prob[ctx1][1]); + const int bit1 = vp10_read(r, fc->comp_ref_prob[ctx1][1]); if (counts) ++counts->comp_ref[ctx1][1][bit1]; ref_frame[!idx] = cm->comp_var_ref[bit1 ? 0 : 1]; } else { const int ctx2 = vp10_get_pred_context_comp_ref_p2(cm, xd); - const int bit2 = vpx_read(r, fc->comp_ref_prob[ctx2][2]); + const int bit2 = vp10_read(r, fc->comp_ref_prob[ctx2][2]); if (counts) ++counts->comp_ref[ctx2][2][bit2]; if (!bit2) { const int ctx3 = vp10_get_pred_context_comp_ref_p3(cm, xd); - const int bit3 = vpx_read(r, fc->comp_ref_prob[ctx3][3]); + const int bit3 = vp10_read(r, fc->comp_ref_prob[ctx3][3]); if (counts) ++counts->comp_ref[ctx3][3][bit3]; ref_frame[!idx] = cm->comp_var_ref[bit3 ? 2 : 3]; @@ -770,29 +770,29 @@ static void read_ref_frames(VP10_COMMON *const cm, MACROBLOCKD *const xd, } else if (mode == SINGLE_REFERENCE) { #if CONFIG_EXT_REFS const int ctx0 = vp10_get_pred_context_single_ref_p1(xd); - const int bit0 = vpx_read(r, fc->single_ref_prob[ctx0][0]); + const int bit0 = vp10_read(r, fc->single_ref_prob[ctx0][0]); if (counts) ++counts->single_ref[ctx0][0][bit0]; if (bit0) { const int ctx1 = vp10_get_pred_context_single_ref_p2(xd); - const int bit1 = vpx_read(r, fc->single_ref_prob[ctx1][1]); + const int bit1 = vp10_read(r, fc->single_ref_prob[ctx1][1]); if (counts) ++counts->single_ref[ctx1][1][bit1]; ref_frame[0] = bit1 ? ALTREF_FRAME : GOLDEN_FRAME; } else { const int ctx2 = vp10_get_pred_context_single_ref_p3(xd); - const int bit2 = vpx_read(r, fc->single_ref_prob[ctx2][2]); + const int bit2 = vp10_read(r, fc->single_ref_prob[ctx2][2]); if (counts) ++counts->single_ref[ctx2][2][bit2]; if (bit2) { const int ctx4 = vp10_get_pred_context_single_ref_p5(xd); - const int bit4 = vpx_read(r, fc->single_ref_prob[ctx4][4]); + const int bit4 = vp10_read(r, fc->single_ref_prob[ctx4][4]); if (counts) ++counts->single_ref[ctx4][4][bit4]; ref_frame[0] = bit4 ? LAST4_FRAME : LAST3_FRAME; } else { const int ctx3 = vp10_get_pred_context_single_ref_p4(xd); - const int bit3 = vpx_read(r, fc->single_ref_prob[ctx3][3]); + const int bit3 = vp10_read(r, fc->single_ref_prob[ctx3][3]); if (counts) ++counts->single_ref[ctx3][3][bit3]; ref_frame[0] = bit3 ? LAST2_FRAME : LAST_FRAME; @@ -800,12 +800,12 @@ static void read_ref_frames(VP10_COMMON *const cm, MACROBLOCKD *const xd, } #else const int ctx0 = vp10_get_pred_context_single_ref_p1(xd); - const int bit0 = vpx_read(r, fc->single_ref_prob[ctx0][0]); + const int bit0 = vp10_read(r, fc->single_ref_prob[ctx0][0]); if (counts) ++counts->single_ref[ctx0][0][bit0]; if (bit0) { const int ctx1 = vp10_get_pred_context_single_ref_p2(xd); - const int bit1 = vpx_read(r, fc->single_ref_prob[ctx1][1]); + const int bit1 = vp10_read(r, fc->single_ref_prob[ctx1][1]); if (counts) ++counts->single_ref[ctx1][1][bit1]; ref_frame[0] = bit1 ? ALTREF_FRAME : GOLDEN_FRAME; @@ -824,13 +824,13 @@ static void read_ref_frames(VP10_COMMON *const cm, MACROBLOCKD *const xd, #if CONFIG_OBMC static int read_is_obmc_block(VP10_COMMON *const cm, MACROBLOCKD *const xd, - vpx_reader *r) { + vp10_reader *r) { BLOCK_SIZE bsize = xd->mi[0]->mbmi.sb_type; FRAME_COUNTS *counts = xd->counts; int is_obmc; if (is_obmc_allowed(&xd->mi[0]->mbmi)) { - is_obmc = vpx_read(r, cm->fc->obmc_prob[bsize]); + is_obmc = vp10_read(r, cm->fc->obmc_prob[bsize]); if (counts) ++counts->obmc[bsize][is_obmc]; return is_obmc; @@ -842,14 +842,14 @@ static int read_is_obmc_block(VP10_COMMON *const cm, MACROBLOCKD *const xd, static INLINE INTERP_FILTER read_switchable_interp_filter( VP10_COMMON *const cm, MACROBLOCKD *const xd, - vpx_reader *r) { + vp10_reader *r) { const int ctx = vp10_get_pred_context_switchable_interp(xd); FRAME_COUNTS *counts = xd->counts; INTERP_FILTER type; #if CONFIG_EXT_INTERP if (!vp10_is_interp_needed(xd)) return EIGHTTAP_REGULAR; #endif - type = (INTERP_FILTER)vpx_read_tree(r, vp10_switchable_interp_tree, + type = (INTERP_FILTER)vp10_read_tree(r, vp10_switchable_interp_tree, cm->fc->switchable_interp_prob[ctx]); if (counts) ++counts->switchable_interp[ctx][type]; @@ -858,7 +858,7 @@ static INLINE INTERP_FILTER read_switchable_interp_filter( static void read_intra_block_mode_info(VP10_COMMON *const cm, MACROBLOCKD *const xd, MODE_INFO *mi, - vpx_reader *r) { + vp10_reader *r) { MB_MODE_INFO *const mbmi = &mi->mbmi; const BLOCK_SIZE bsize = mi->mbmi.sb_type; int i; @@ -897,7 +897,7 @@ static void read_intra_block_mode_info(VP10_COMMON *const cm, if (pick_intra_filter(p_angle)) { FRAME_COUNTS *counts = xd->counts; const int ctx = vp10_get_pred_context_intra_interp(xd); - mbmi->intra_filter = vpx_read_tree(r, vp10_intra_filter_tree, + mbmi->intra_filter = vp10_read_tree(r, vp10_intra_filter_tree, cm->fc->intra_filter_probs[ctx]); if (counts) ++counts->intra_filter[ctx][mbmi->intra_filter]; @@ -939,7 +939,7 @@ static INLINE int assign_mv(VP10_COMMON *cm, MACROBLOCKD *xd, #endif int_mv mv[2], int_mv ref_mv[2], int_mv nearest_mv[2], int_mv near_mv[2], - int is_compound, int allow_hp, vpx_reader *r) { + int is_compound, int allow_hp, vp10_reader *r) { int i; int ret = 1; #if CONFIG_REF_MV @@ -1154,12 +1154,12 @@ static INLINE int assign_mv(VP10_COMMON *cm, MACROBLOCKD *xd, } static int read_is_inter_block(VP10_COMMON *const cm, MACROBLOCKD *const xd, - int segment_id, vpx_reader *r) { + int segment_id, vp10_reader *r) { if (segfeature_active(&cm->seg, segment_id, SEG_LVL_REF_FRAME)) { return get_segdata(&cm->seg, segment_id, SEG_LVL_REF_FRAME) != INTRA_FRAME; } else { const int ctx = vp10_get_intra_inter_context(xd); - const int is_inter = vpx_read(r, cm->fc->intra_inter_prob[ctx]); + const int is_inter = vp10_read(r, cm->fc->intra_inter_prob[ctx]); FRAME_COUNTS *counts = xd->counts; if (counts) ++counts->intra_inter[ctx][is_inter]; @@ -1177,10 +1177,10 @@ static void read_inter_block_mode_info(VP10Decoder *const pbi, MACROBLOCKD *const xd, MODE_INFO *const mi, #if (CONFIG_OBMC || CONFIG_EXT_INTER) && CONFIG_SUPERTX - int mi_row, int mi_col, vpx_reader *r, + int mi_row, int mi_col, vp10_reader *r, int supertx_enabled) { #else - int mi_row, int mi_col, vpx_reader *r) { + int mi_row, int mi_col, vp10_reader *r) { #endif // CONFIG_OBMC && CONFIG_SUPERTX VP10_COMMON *const cm = &pbi->common; MB_MODE_INFO *const mbmi = &mi->mbmi; @@ -1526,7 +1526,7 @@ static void read_inter_block_mode_info(VP10Decoder *const pbi, !supertx_enabled && #endif is_interintra_allowed(mbmi)) { - const int interintra = vpx_read(r, cm->fc->interintra_prob[bsize]); + const int interintra = vp10_read(r, cm->fc->interintra_prob[bsize]); if (xd->counts) xd->counts->interintra[bsize][interintra]++; assert(mbmi->ref_frame[1] == NONE); @@ -1545,13 +1545,13 @@ static void read_inter_block_mode_info(VP10Decoder *const pbi, #endif // CONFIG_EXT_INTRA if (get_wedge_bits(bsize)) { mbmi->use_wedge_interintra = - vpx_read(r, cm->fc->wedge_interintra_prob[bsize]); + vp10_read(r, cm->fc->wedge_interintra_prob[bsize]); if (xd->counts) xd->counts->wedge_interintra[bsize][mbmi->use_wedge_interintra]++; if (mbmi->use_wedge_interintra) { mbmi->interintra_wedge_index = mbmi->interintra_uv_wedge_index = - vpx_read_literal(r, get_wedge_bits(bsize)); + vp10_read_literal(r, get_wedge_bits(bsize)); } } } @@ -1563,12 +1563,12 @@ static void read_inter_block_mode_info(VP10Decoder *const pbi, #endif // CONFIG_OBMC get_wedge_bits(bsize)) { mbmi->use_wedge_interinter = - vpx_read(r, cm->fc->wedge_interinter_prob[bsize]); + vp10_read(r, cm->fc->wedge_interinter_prob[bsize]); if (xd->counts) xd->counts->wedge_interinter[bsize][mbmi->use_wedge_interinter]++; if (mbmi->use_wedge_interinter) { mbmi->interinter_wedge_index = - vpx_read_literal(r, get_wedge_bits(bsize)); + vp10_read_literal(r, get_wedge_bits(bsize)); } } #endif // CONFIG_EXT_INTER @@ -1585,7 +1585,7 @@ static void read_inter_frame_mode_info(VP10Decoder *const pbi, #if CONFIG_SUPERTX int supertx_enabled, #endif // CONFIG_SUPERTX - int mi_row, int mi_col, vpx_reader *r) { + int mi_row, int mi_col, vp10_reader *r) { VP10_COMMON *const cm = &pbi->common; MODE_INFO *const mi = xd->mi[0]; MB_MODE_INFO *const mbmi = &mi->mbmi; @@ -1682,14 +1682,14 @@ static void read_inter_frame_mode_info(VP10Decoder *const pbi, if (inter_block) { if (eset > 0) { mbmi->tx_type = - vpx_read_tree(r, vp10_ext_tx_inter_tree[eset], + vp10_read_tree(r, vp10_ext_tx_inter_tree[eset], cm->fc->inter_ext_tx_prob[eset][mbmi->tx_size]); if (counts) ++counts->inter_ext_tx[eset][mbmi->tx_size][mbmi->tx_type]; } } else if (ALLOW_INTRA_EXT_TX) { if (eset > 0) { - mbmi->tx_type = vpx_read_tree(r, vp10_ext_tx_intra_tree[eset], + mbmi->tx_type = vp10_read_tree(r, vp10_ext_tx_intra_tree[eset], cm->fc->intra_ext_tx_prob[eset] [mbmi->tx_size][mbmi->mode]); if (counts) @@ -1709,14 +1709,14 @@ static void read_inter_frame_mode_info(VP10Decoder *const pbi, !segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP)) { FRAME_COUNTS *counts = xd->counts; if (inter_block) { - mbmi->tx_type = vpx_read_tree( + mbmi->tx_type = vp10_read_tree( r, vp10_ext_tx_tree, cm->fc->inter_ext_tx_prob[mbmi->tx_size]); if (counts) ++counts->inter_ext_tx[mbmi->tx_size][mbmi->tx_type]; } else { const TX_TYPE tx_type_nom = intra_mode_to_tx_type_context[mbmi->mode]; - mbmi->tx_type = vpx_read_tree( + mbmi->tx_type = vp10_read_tree( r, vp10_ext_tx_tree, cm->fc->intra_ext_tx_prob[mbmi->tx_size][tx_type_nom]); if (counts) @@ -1733,7 +1733,7 @@ void vp10_read_mode_info(VP10Decoder *const pbi, MACROBLOCKD *xd, #if CONFIG_SUPERTX int supertx_enabled, #endif // CONFIG_SUPERTX - int mi_row, int mi_col, vpx_reader *r, + int mi_row, int mi_col, vp10_reader *r, int x_mis, int y_mis) { VP10_COMMON *const cm = &pbi->common; MODE_INFO *const mi = xd->mi[0]; diff --git a/vp10/decoder/decodemv.h b/vp10/decoder/decodemv.h index 959a0010f..c10c6bf38 100644 --- a/vp10/decoder/decodemv.h +++ b/vp10/decoder/decodemv.h @@ -11,7 +11,7 @@ #ifndef VP10_DECODER_DECODEMV_H_ #define VP10_DECODER_DECODEMV_H_ -#include "vpx_dsp/bitreader.h" +#include "vp10/decoder/bitreader.h" #include "vp10/decoder/decoder.h" @@ -24,7 +24,7 @@ void vp10_read_mode_info(VP10Decoder *const pbi, MACROBLOCKD *xd, int supertx_enabled, #endif - int mi_row, int mi_col, vpx_reader *r, + int mi_row, int mi_col, vp10_reader *r, int x_mis, int y_mis); #ifdef __cplusplus diff --git a/vp10/decoder/decoder.h b/vp10/decoder/decoder.h index 23c742421..c349252a4 100644 --- a/vp10/decoder/decoder.h +++ b/vp10/decoder/decoder.h @@ -14,13 +14,10 @@ #include "./vpx_config.h" #include "vpx/vpx_codec.h" -#include "vpx_dsp/bitreader.h" +#include "vp10/decoder/bitreader.h" #include "vpx_scale/yv12config.h" #include "vpx_util/vpx_thread.h" -#if CONFIG_ANS -#include "vp10/common/ans.h" -#endif #include "vp10/common/thread_common.h" #include "vp10/common/onyxc_int.h" #include "vp10/common/ppflags.h" @@ -33,10 +30,7 @@ extern "C" { // TODO(hkuang): combine this with TileWorkerData. typedef struct TileData { VP10_COMMON *cm; - vpx_reader bit_reader; -#if CONFIG_ANS - struct AnsDecoder token_ans; -#endif // CONFIG_ANS + vp10_reader bit_reader; DECLARE_ALIGNED(16, MACROBLOCKD, xd); /* dqcoeff are shared by all the planes. So planes must be decoded serially */ DECLARE_ALIGNED(16, tran_low_t, dqcoeff[MAX_TX_SQUARE]); @@ -45,10 +39,7 @@ typedef struct TileData { typedef struct TileWorkerData { struct VP10Decoder *pbi; - vpx_reader bit_reader; -#if CONFIG_ANS - struct AnsDecoder token_ans; -#endif // CONFIG_ANS + vp10_reader bit_reader; FRAME_COUNTS counts; DECLARE_ALIGNED(16, MACROBLOCKD, xd); /* dqcoeff are shared by all the planes. So planes must be decoded serially */ diff --git a/vp10/decoder/detokenize.c b/vp10/decoder/detokenize.c index bf4822197..b8d409a3d 100644 --- a/vp10/decoder/detokenize.c +++ b/vp10/decoder/detokenize.c @@ -40,10 +40,10 @@ } while (0) #if !CONFIG_ANS -static INLINE int read_coeff(const vpx_prob *probs, int n, vpx_reader *r) { +static INLINE int read_coeff(const vpx_prob *probs, int n, vp10_reader *r) { int i, val = 0; for (i = 0; i < n; ++i) - val = (val << 1) | vpx_read(r, probs[i]); + val = (val << 1) | vp10_read(r, probs[i]); return val; } @@ -51,7 +51,7 @@ static int decode_coefs(const MACROBLOCKD *xd, PLANE_TYPE type, tran_low_t *dqcoeff, TX_SIZE tx_size, const int16_t *dq, int ctx, const int16_t *scan, const int16_t *nb, - vpx_reader *r) { + vp10_reader *r) { FRAME_COUNTS *counts = xd->counts; const int max_eob = 16 << (tx_size << 1); const FRAME_CONTEXT *const fc = xd->fc; @@ -129,12 +129,12 @@ static int decode_coefs(const MACROBLOCKD *xd, prob = coef_probs[band][ctx]; if (counts) ++eob_branch_count[band][ctx]; - if (!vpx_read(r, prob[EOB_CONTEXT_NODE])) { + if (!vp10_read(r, prob[EOB_CONTEXT_NODE])) { INCREMENT_COUNT(EOB_MODEL_TOKEN); break; } - while (!vpx_read(r, prob[ZERO_CONTEXT_NODE])) { + while (!vp10_read(r, prob[ZERO_CONTEXT_NODE])) { INCREMENT_COUNT(ZERO_TOKEN); dqv = dq[1]; token_cache[scan[c]] = 0; @@ -146,13 +146,13 @@ static int decode_coefs(const MACROBLOCKD *xd, prob = coef_probs[band][ctx]; } - if (!vpx_read(r, prob[ONE_CONTEXT_NODE])) { + if (!vp10_read(r, prob[ONE_CONTEXT_NODE])) { INCREMENT_COUNT(ONE_TOKEN); token = ONE_TOKEN; val = 1; } else { INCREMENT_COUNT(TWO_TOKEN); - token = vpx_read_tree(r, vp10_coef_con_tree, + token = vp10_read_tree(r, vp10_coef_con_tree, vp10_pareto8_full[prob[PIVOT_NODE] - 1]); switch (token) { case TWO_TOKEN: @@ -203,13 +203,13 @@ static int decode_coefs(const MACROBLOCKD *xd, v = (val * dqv) >> dq_shift; #if CONFIG_COEFFICIENT_RANGE_CHECKING #if CONFIG_VP9_HIGHBITDEPTH - dqcoeff[scan[c]] = highbd_check_range((vpx_read_bit(r) ? -v : v), + dqcoeff[scan[c]] = highbd_check_range((vp10_read_bit(r) ? -v : v), xd->bd); #else - dqcoeff[scan[c]] = check_range(vpx_read_bit(r) ? -v : v); + dqcoeff[scan[c]] = check_range(vp10_read_bit(r) ? -v : v); #endif // CONFIG_VP9_HIGHBITDEPTH #else - dqcoeff[scan[c]] = vpx_read_bit(r) ? -v : v; + dqcoeff[scan[c]] = vp10_read_bit(r) ? -v : v; #endif // CONFIG_COEFFICIENT_RANGE_CHECKING token_cache[scan[c]] = vp10_pt_energy_class[token]; ++c; @@ -445,7 +445,7 @@ void dec_set_contexts(const MACROBLOCKD *xd, struct macroblockd_plane *pd, } void vp10_decode_palette_tokens(MACROBLOCKD *const xd, int plane, - vpx_reader *r) { + vp10_reader *r) { MODE_INFO *const mi = xd->mi[0]; MB_MODE_INFO *const mbmi = &mi->mbmi; const BLOCK_SIZE bsize = mbmi->sb_type; @@ -465,7 +465,7 @@ void vp10_decode_palette_tokens(MACROBLOCKD *const xd, int plane, for (j = (i == 0 ? 1 : 0); j < cols; ++j) { color_ctx = vp10_get_palette_color_context(color_map, cols, i, j, n, color_order); - color_idx = vpx_read_tree(r, vp10_palette_color_tree[n - 2], + color_idx = vp10_read_tree(r, vp10_palette_color_tree[n - 2], prob[n - 2][color_ctx]); assert(color_idx >= 0 && color_idx < n); color_map[i * cols + j] = color_order[color_idx]; @@ -483,7 +483,7 @@ int vp10_decode_block_tokens(MACROBLOCKD *const xd, #if CONFIG_ANS struct AnsDecoder *const r, #else - vpx_reader *r, + vp10_reader *r, #endif // CONFIG_ANS int seg_id) { struct macroblockd_plane *const pd = &xd->plane[plane]; diff --git a/vp10/decoder/detokenize.h b/vp10/decoder/detokenize.h index f87c6f028..4688d0a20 100644 --- a/vp10/decoder/detokenize.h +++ b/vp10/decoder/detokenize.h @@ -21,7 +21,7 @@ extern "C" { #endif void vp10_decode_palette_tokens(MACROBLOCKD *const xd, int plane, - vpx_reader *r); + vp10_reader *r); int vp10_decode_block_tokens(MACROBLOCKD *const xd, #if CONFIG_ANS const rans_dec_lut *const token_tab, @@ -32,7 +32,7 @@ int vp10_decode_block_tokens(MACROBLOCKD *const xd, #if CONFIG_ANS struct AnsDecoder *const r, #else - vpx_reader *r, + vp10_reader *r, #endif // CONFIG_ANS int seg_id); diff --git a/vp10/decoder/dsubexp.c b/vp10/decoder/dsubexp.c index 7d2872e1f..4d53e12c7 100644 --- a/vp10/decoder/dsubexp.c +++ b/vp10/decoder/dsubexp.c @@ -21,11 +21,11 @@ static int inv_recenter_nonneg(int v, int m) { return (v & 1) ? m - ((v + 1) >> 1) : m + (v >> 1); } -static int decode_uniform(vpx_reader *r) { +static int decode_uniform(vp10_reader *r) { const int l = 8; const int m = (1 << l) - 190; - const int v = vpx_read_literal(r, l - 1); - return v < m ? v : (v << 1) - m + vpx_read_bit(r); + const int v = vp10_read_literal(r, l - 1); + return v < m ? v : (v << 1) - m + vp10_read_bit(r); } static int inv_remap_prob(int v, int m) { @@ -58,18 +58,18 @@ static int inv_remap_prob(int v, int m) { } } -static int decode_term_subexp(vpx_reader *r) { - if (!vpx_read_bit(r)) - return vpx_read_literal(r, 4); - if (!vpx_read_bit(r)) - return vpx_read_literal(r, 4) + 16; - if (!vpx_read_bit(r)) - return vpx_read_literal(r, 5) + 32; +static int decode_term_subexp(vp10_reader *r) { + if (!vp10_read_bit(r)) + return vp10_read_literal(r, 4); + if (!vp10_read_bit(r)) + return vp10_read_literal(r, 4) + 16; + if (!vp10_read_bit(r)) + return vp10_read_literal(r, 5) + 32; return decode_uniform(r) + 64; } -void vp10_diff_update_prob(vpx_reader *r, vpx_prob* p) { - if (vpx_read(r, DIFF_UPDATE_PROB)) { +void vp10_diff_update_prob(vp10_reader *r, vpx_prob* p) { + if (vp10_read(r, DIFF_UPDATE_PROB)) { const int delp = decode_term_subexp(r); *p = (vpx_prob)inv_remap_prob(delp, *p); } diff --git a/vp10/decoder/dsubexp.h b/vp10/decoder/dsubexp.h index 1a7ed9910..c05ec6e9f 100644 --- a/vp10/decoder/dsubexp.h +++ b/vp10/decoder/dsubexp.h @@ -12,13 +12,13 @@ #ifndef VP10_DECODER_DSUBEXP_H_ #define VP10_DECODER_DSUBEXP_H_ -#include "vpx_dsp/bitreader.h" +#include "vp10/decoder/bitreader.h" #ifdef __cplusplus extern "C" { #endif -void vp10_diff_update_prob(vpx_reader *r, vpx_prob* p); +void vp10_diff_update_prob(vp10_reader *r, vpx_prob* p); #ifdef __cplusplus } // extern "C" diff --git a/vp10/encoder/bitstream.c b/vp10/encoder/bitstream.c index 046231185..a5fbc200f 100644 --- a/vp10/encoder/bitstream.c +++ b/vp10/encoder/bitstream.c @@ -93,16 +93,16 @@ tx_size_encodings[TX_SIZES - 1][TX_SIZES] = { {{0, 1}, {2, 2}, {6, 3}, {7, 3}}, // Max tx_size is 32X32 }; -static INLINE void write_uniform(vpx_writer *w, int n, int v) { +static INLINE void write_uniform(vp10_writer *w, int n, int v) { int l = get_unsigned_bits(n); int m = (1 << l) - n; if (l == 0) return; if (v < m) { - vpx_write_literal(w, v, l - 1); + vp10_write_literal(w, v, l - 1); } else { - vpx_write_literal(w, m + ((v - m) >> 1), l - 1); - vpx_write_literal(w, (v - m) & 1, 1); + vp10_write_literal(w, m + ((v - m) >> 1), l - 1); + vp10_write_literal(w, (v - m) & 1, 1); } } @@ -139,7 +139,7 @@ void vp10_encode_token_init() { #endif // CONFIG_EXT_INTER } -static void write_intra_mode(vpx_writer *w, PREDICTION_MODE mode, +static void write_intra_mode(vp10_writer *w, PREDICTION_MODE mode, const vpx_prob *probs) { vp10_write_token(w, vp10_intra_mode_tree, probs, &intra_mode_encodings[mode]); } @@ -153,7 +153,7 @@ static void write_interintra_mode(vpx_writer *w, INTERINTRA_MODE mode, #endif // CONFIG_EXT_INTER static void write_inter_mode(VP10_COMMON *cm, - vpx_writer *w, PREDICTION_MODE mode, + vp10_writer *w, PREDICTION_MODE mode, #if CONFIG_REF_MV && CONFIG_EXT_INTER int is_compound, #endif // CONFIG_REF_MV && CONFIG_EXT_INTER @@ -162,14 +162,14 @@ static void write_inter_mode(VP10_COMMON *cm, const int16_t newmv_ctx = mode_ctx & NEWMV_CTX_MASK; const vpx_prob newmv_prob = cm->fc->newmv_prob[newmv_ctx]; #if CONFIG_EXT_INTER - vpx_write(w, mode != NEWMV && mode != NEWFROMNEARMV, newmv_prob); + vp10_write(w, mode != NEWMV && mode != NEWFROMNEARMV, newmv_prob); if (!is_compound && (mode == NEWMV || mode == NEWFROMNEARMV)) - vpx_write(w, mode == NEWFROMNEARMV, cm->fc->new2mv_prob); + vp10_write(w, mode == NEWFROMNEARMV, cm->fc->new2mv_prob); if (mode != NEWMV && mode != NEWFROMNEARMV) { #else - vpx_write(w, mode != NEWMV, newmv_prob); + vp10_write(w, mode != NEWMV, newmv_prob); if (mode != NEWMV) { #endif // CONFIG_EXT_INTER @@ -181,7 +181,7 @@ static void write_inter_mode(VP10_COMMON *cm, return; } - vpx_write(w, mode != ZEROMV, zeromv_prob); + vp10_write(w, mode != ZEROMV, zeromv_prob); if (mode != ZEROMV) { int16_t refmv_ctx = (mode_ctx >> REFMV_OFFSET) & REFMV_CTX_MASK; @@ -195,7 +195,7 @@ static void write_inter_mode(VP10_COMMON *cm, refmv_ctx = 8; refmv_prob = cm->fc->refmv_prob[refmv_ctx]; - vpx_write(w, mode != NEARESTMV, refmv_prob); + vp10_write(w, mode != NEARESTMV, refmv_prob); } } #else @@ -210,7 +210,7 @@ static void write_inter_mode(VP10_COMMON *cm, static void write_drl_idx(const VP10_COMMON *cm, const MB_MODE_INFO *mbmi, const MB_MODE_INFO_EXT *mbmi_ext, - vpx_writer *w) { + vp10_writer *w) { uint8_t ref_frame_type = vp10_ref_frame_type(mbmi->ref_frame); assert(mbmi->ref_mv_idx < 3); @@ -223,7 +223,7 @@ static void write_drl_idx(const VP10_COMMON *cm, vp10_drl_ctx(mbmi_ext->ref_mv_stack[ref_frame_type], idx); vpx_prob drl_prob = cm->fc->drl_prob[drl_ctx]; - vpx_write(w, mbmi->ref_mv_idx != idx, drl_prob); + vp10_write(w, mbmi->ref_mv_idx != idx, drl_prob); if (mbmi->ref_mv_idx == idx) return; } @@ -240,7 +240,7 @@ static void write_drl_idx(const VP10_COMMON *cm, vp10_drl_ctx(mbmi_ext->ref_mv_stack[ref_frame_type], idx); vpx_prob drl_prob = cm->fc->drl_prob[drl_ctx]; - vpx_write(w, mbmi->ref_mv_idx != (idx - 1), drl_prob); + vp10_write(w, mbmi->ref_mv_idx != (idx - 1), drl_prob); if (mbmi->ref_mv_idx == (idx - 1)) return; } @@ -251,7 +251,7 @@ static void write_drl_idx(const VP10_COMMON *cm, #endif #if CONFIG_EXT_INTER -static void write_inter_compound_mode(VP10_COMMON *cm, vpx_writer *w, +static void write_inter_compound_mode(VP10_COMMON *cm, vp10_writer *w, PREDICTION_MODE mode, const int16_t mode_ctx) { const vpx_prob *const inter_compound_probs = @@ -271,7 +271,7 @@ static void encode_unsigned_max(struct vpx_write_bit_buffer *wb, static void prob_diff_update(const vpx_tree_index *tree, vpx_prob probs[/*n - 1*/], const unsigned int counts[/*n - 1*/], - int n, vpx_writer *w) { + int n, vp10_writer *w) { int i; unsigned int branch_ct[32][2]; @@ -306,7 +306,7 @@ static void write_tx_size_inter(const VP10_COMMON *cm, const MACROBLOCKD *xd, const MB_MODE_INFO *mbmi, TX_SIZE tx_size, int blk_row, int blk_col, - vpx_writer *w) { + vp10_writer *w) { const int tx_row = blk_row >> 1; const int tx_col = blk_col >> 1; int max_blocks_high = num_4x4_blocks_high_lookup[mbmi->sb_type]; @@ -324,14 +324,14 @@ static void write_tx_size_inter(const VP10_COMMON *cm, return; if (tx_size == mbmi->inter_tx_size[tx_row][tx_col]) { - vpx_write(w, 0, cm->fc->txfm_partition_prob[ctx]); + vp10_write(w, 0, cm->fc->txfm_partition_prob[ctx]); txfm_partition_update(xd->above_txfm_context + tx_col, xd->left_txfm_context + tx_row, tx_size); } else { const BLOCK_SIZE bsize = txsize_to_bsize[tx_size]; int bsl = b_width_log2_lookup[bsize]; int i; - vpx_write(w, 1, cm->fc->txfm_partition_prob[ctx]); + vp10_write(w, 1, cm->fc->txfm_partition_prob[ctx]); if (tx_size == TX_8X8) { txfm_partition_update(xd->above_txfm_context + tx_col, @@ -349,7 +349,7 @@ static void write_tx_size_inter(const VP10_COMMON *cm, } } -static void update_txfm_partition_probs(VP10_COMMON *cm, vpx_writer *w, +static void update_txfm_partition_probs(VP10_COMMON *cm, vp10_writer *w, FRAME_COUNTS *counts) { int k; for (k = 0; k < TXFM_PARTITION_CONTEXTS; ++k) @@ -359,7 +359,7 @@ static void update_txfm_partition_probs(VP10_COMMON *cm, vpx_writer *w, #endif static void write_selected_tx_size(const VP10_COMMON *cm, - const MACROBLOCKD *xd, vpx_writer *w) { + const MACROBLOCKD *xd, vp10_writer *w) { TX_SIZE tx_size = xd->mi[0]->mbmi.tx_size; BLOCK_SIZE bsize = xd->mi[0]->mbmi.sb_type; const TX_SIZE max_tx_size = max_txsize_lookup[bsize]; @@ -372,7 +372,7 @@ static void write_selected_tx_size(const VP10_COMMON *cm, } #if CONFIG_REF_MV -static void update_inter_mode_probs(VP10_COMMON *cm, vpx_writer *w, +static void update_inter_mode_probs(VP10_COMMON *cm, vp10_writer *w, FRAME_COUNTS *counts) { int i; for (i = 0; i < NEWMV_MODE_CONTEXTS; ++i) @@ -394,7 +394,7 @@ static void update_inter_mode_probs(VP10_COMMON *cm, vpx_writer *w, #endif #if CONFIG_EXT_INTER -static void update_inter_compound_mode_probs(VP10_COMMON *cm, vpx_writer *w) { +static void update_inter_compound_mode_probs(VP10_COMMON *cm, vp10_writer *w) { const int savings_thresh = vp10_cost_one(GROUP_DIFF_UPDATE_PROB) - vp10_cost_zero(GROUP_DIFF_UPDATE_PROB); int i; @@ -407,7 +407,7 @@ static void update_inter_compound_mode_probs(VP10_COMMON *cm, vpx_writer *w) { INTER_COMPOUND_MODES); } do_update = savings > savings_thresh; - vpx_write(w, do_update, GROUP_DIFF_UPDATE_PROB); + vp10_write(w, do_update, GROUP_DIFF_UPDATE_PROB); if (do_update) { for (i = 0; i < INTER_MODE_CONTEXTS; ++i) { prob_diff_update(vp10_inter_compound_mode_tree, @@ -420,17 +420,17 @@ static void update_inter_compound_mode_probs(VP10_COMMON *cm, vpx_writer *w) { #endif // CONFIG_EXT_INTER static int write_skip(const VP10_COMMON *cm, const MACROBLOCKD *xd, - int segment_id, const MODE_INFO *mi, vpx_writer *w) { + int segment_id, const MODE_INFO *mi, vp10_writer *w) { if (segfeature_active(&cm->seg, segment_id, SEG_LVL_SKIP)) { return 1; } else { const int skip = mi->mbmi.skip; - vpx_write(w, skip, vp10_get_skip_prob(cm, xd)); + vp10_write(w, skip, vp10_get_skip_prob(cm, xd)); return skip; } } -static void update_skip_probs(VP10_COMMON *cm, vpx_writer *w, +static void update_skip_probs(VP10_COMMON *cm, vp10_writer *w, FRAME_COUNTS *counts) { int k; @@ -438,7 +438,7 @@ static void update_skip_probs(VP10_COMMON *cm, vpx_writer *w, vp10_cond_prob_diff_update(w, &cm->fc->skip_probs[k], counts->skip[k]); } -static void update_switchable_interp_probs(VP10_COMMON *cm, vpx_writer *w, +static void update_switchable_interp_probs(VP10_COMMON *cm, vp10_writer *w, FRAME_COUNTS *counts) { int j; for (j = 0; j < SWITCHABLE_FILTER_CONTEXTS; ++j) @@ -449,7 +449,7 @@ static void update_switchable_interp_probs(VP10_COMMON *cm, vpx_writer *w, #if CONFIG_EXT_TX -static void update_ext_tx_probs(VP10_COMMON *cm, vpx_writer *w) { +static void update_ext_tx_probs(VP10_COMMON *cm, vp10_writer *w) { const int savings_thresh = vp10_cost_one(GROUP_DIFF_UPDATE_PROB) - vp10_cost_zero(GROUP_DIFF_UPDATE_PROB); int i, j; @@ -464,7 +464,7 @@ static void update_ext_tx_probs(VP10_COMMON *cm, vpx_writer *w) { cm->counts.inter_ext_tx[s][i], num_ext_tx_set_inter[s]); } do_update = savings > savings_thresh; - vpx_write(w, do_update, GROUP_DIFF_UPDATE_PROB); + vp10_write(w, do_update, GROUP_DIFF_UPDATE_PROB); if (do_update) { for (i = TX_4X4; i < EXT_TX_SIZES; ++i) { if (!use_inter_ext_tx_for_txsize[s][i]) continue; @@ -487,7 +487,7 @@ static void update_ext_tx_probs(VP10_COMMON *cm, vpx_writer *w) { cm->counts.intra_ext_tx[s][i][j], num_ext_tx_set_intra[s]); } do_update = savings > savings_thresh; - vpx_write(w, do_update, GROUP_DIFF_UPDATE_PROB); + vp10_write(w, do_update, GROUP_DIFF_UPDATE_PROB); if (do_update) { for (i = TX_4X4; i < EXT_TX_SIZES; ++i) { if (!use_intra_ext_tx_for_txsize[s][i]) continue; @@ -503,7 +503,7 @@ static void update_ext_tx_probs(VP10_COMMON *cm, vpx_writer *w) { #else -static void update_ext_tx_probs(VP10_COMMON *cm, vpx_writer *w) { +static void update_ext_tx_probs(VP10_COMMON *cm, vp10_writer *w) { const int savings_thresh = vp10_cost_one(GROUP_DIFF_UPDATE_PROB) - vp10_cost_zero(GROUP_DIFF_UPDATE_PROB); int i, j; @@ -517,7 +517,7 @@ static void update_ext_tx_probs(VP10_COMMON *cm, vpx_writer *w) { cm->counts.intra_ext_tx[i][j], TX_TYPES); } do_update = savings > savings_thresh; - vpx_write(w, do_update, GROUP_DIFF_UPDATE_PROB); + vp10_write(w, do_update, GROUP_DIFF_UPDATE_PROB); if (do_update) { for (i = TX_4X4; i < EXT_TX_SIZES; ++i) { for (j = 0; j < TX_TYPES; ++j) @@ -535,7 +535,7 @@ static void update_ext_tx_probs(VP10_COMMON *cm, vpx_writer *w) { cm->counts.inter_ext_tx[i], TX_TYPES); } do_update = savings > savings_thresh; - vpx_write(w, do_update, GROUP_DIFF_UPDATE_PROB); + vp10_write(w, do_update, GROUP_DIFF_UPDATE_PROB); if (do_update) { for (i = TX_4X4; i < EXT_TX_SIZES; ++i) { prob_diff_update(vp10_ext_tx_tree, @@ -547,7 +547,7 @@ static void update_ext_tx_probs(VP10_COMMON *cm, vpx_writer *w) { } #endif // CONFIG_EXT_TX -static void pack_palette_tokens(vpx_writer *w, const TOKENEXTRA **tp, +static void pack_palette_tokens(vp10_writer *w, const TOKENEXTRA **tp, int n, int num) { int i; const TOKENEXTRA *p = *tp; @@ -562,7 +562,7 @@ static void pack_palette_tokens(vpx_writer *w, const TOKENEXTRA **tp, } #if CONFIG_SUPERTX -static void update_supertx_probs(VP10_COMMON *cm, vpx_writer *w) { +static void update_supertx_probs(VP10_COMMON *cm, vp10_writer *w) { const int savings_thresh = vp10_cost_one(GROUP_DIFF_UPDATE_PROB) - vp10_cost_zero(GROUP_DIFF_UPDATE_PROB); int i, j; @@ -575,7 +575,7 @@ static void update_supertx_probs(VP10_COMMON *cm, vpx_writer *w) { } } do_update = savings > savings_thresh; - vpx_write(w, do_update, GROUP_DIFF_UPDATE_PROB); + vp10_write(w, do_update, GROUP_DIFF_UPDATE_PROB); if (do_update) { for (i = 0; i < PARTITION_SUPERTX_CONTEXTS; ++i) { for (j = 1; j < TX_SIZES; ++j) { @@ -588,7 +588,7 @@ static void update_supertx_probs(VP10_COMMON *cm, vpx_writer *w) { #endif // CONFIG_SUPERTX #if !CONFIG_ANS -static void pack_mb_tokens(vpx_writer *w, +static void pack_mb_tokens(vp10_writer *w, const TOKENEXTRA **tp, const TOKENEXTRA *const stop, vpx_bit_depth_t bit_depth, const TX_SIZE tx) { const TOKENEXTRA *p = *tp; @@ -619,13 +619,13 @@ static void pack_mb_tokens(vpx_writer *w, if (p->skip_eob_node) n -= p->skip_eob_node; else - vpx_write(w, t != EOB_TOKEN, p->context_tree[0]); + vp10_write(w, t != EOB_TOKEN, p->context_tree[0]); if (t != EOB_TOKEN) { - vpx_write(w, t != ZERO_TOKEN, p->context_tree[1]); + vp10_write(w, t != ZERO_TOKEN, p->context_tree[1]); if (t != ZERO_TOKEN) { - vpx_write(w, t != ONE_TOKEN, p->context_tree[2]); + vp10_write(w, t != ONE_TOKEN, p->context_tree[2]); if (t != ONE_TOKEN) { int len = UNCONSTRAINED_NODES - p->skip_eob_node; @@ -653,13 +653,13 @@ static void pack_mb_tokens(vpx_writer *w, skip_bits--; assert(!bb); } else { - vpx_write(w, bb, pb[i >> 1]); + vp10_write(w, bb, pb[i >> 1]); } i = b->tree[i + bb]; } while (n); } - vpx_write_bit(w, e & 1); + vp10_write_bit(w, e & 1); } ++p; @@ -756,7 +756,7 @@ static void pack_mb_tokens_ans(struct BufAnsCoder *ans, #endif // !CONFIG_ANS #if CONFIG_VAR_TX -static void pack_txb_tokens(vpx_writer *w, +static void pack_txb_tokens(vp10_writer *w, const TOKENEXTRA **tp, const TOKENEXTRA *const tok_end, MACROBLOCKD *xd, MB_MODE_INFO *mbmi, int plane, @@ -807,7 +807,7 @@ static void pack_txb_tokens(vpx_writer *w, } #endif -static void write_segment_id(vpx_writer *w, const struct segmentation *seg, +static void write_segment_id(vp10_writer *w, const struct segmentation *seg, const struct segmentation_probs *segp, int segment_id) { if (seg->enabled && seg->update_map) @@ -816,7 +816,7 @@ static void write_segment_id(vpx_writer *w, const struct segmentation *seg, // This function encodes the reference frame static void write_ref_frames(const VP10_COMMON *cm, const MACROBLOCKD *xd, - vpx_writer *w) { + vp10_writer *w) { const MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; const int is_compound = has_second_ref(mbmi); const int segment_id = mbmi->segment_id; @@ -831,7 +831,7 @@ static void write_ref_frames(const VP10_COMMON *cm, const MACROBLOCKD *xd, // does the feature use compound prediction or not // (if not specified at the frame/segment level) if (cm->reference_mode == REFERENCE_MODE_SELECT) { - vpx_write(w, is_compound, vp10_get_reference_mode_prob(cm, xd)); + vp10_write(w, is_compound, vp10_get_reference_mode_prob(cm, xd)); } else { assert(!is_compound == (cm->reference_mode == SINGLE_REFERENCE)); } @@ -844,18 +844,18 @@ static void write_ref_frames(const VP10_COMMON *cm, const MACROBLOCKD *xd, #else const int bit = mbmi->ref_frame[0] == GOLDEN_FRAME; #endif // CONFIG_EXT_REFS - vpx_write(w, bit, vp10_get_pred_prob_comp_ref_p(cm, xd)); + vp10_write(w, bit, vp10_get_pred_prob_comp_ref_p(cm, xd)); #if CONFIG_EXT_REFS if (!bit) { const int bit1 = mbmi->ref_frame[0] == LAST_FRAME; - vpx_write(w, bit1, vp10_get_pred_prob_comp_ref_p1(cm, xd)); + vp10_write(w, bit1, vp10_get_pred_prob_comp_ref_p1(cm, xd)); } else { const int bit2 = mbmi->ref_frame[0] == GOLDEN_FRAME; - vpx_write(w, bit2, vp10_get_pred_prob_comp_ref_p2(cm, xd)); + vp10_write(w, bit2, vp10_get_pred_prob_comp_ref_p2(cm, xd)); if (!bit2) { const int bit3 = mbmi->ref_frame[0] == LAST3_FRAME; - vpx_write(w, bit3, vp10_get_pred_prob_comp_ref_p3(cm, xd)); + vp10_write(w, bit3, vp10_get_pred_prob_comp_ref_p3(cm, xd)); } } #endif // CONFIG_EXT_REFS @@ -863,30 +863,30 @@ static void write_ref_frames(const VP10_COMMON *cm, const MACROBLOCKD *xd, #if CONFIG_EXT_REFS const int bit0 = (mbmi->ref_frame[0] == GOLDEN_FRAME || mbmi->ref_frame[0] == ALTREF_FRAME); - vpx_write(w, bit0, vp10_get_pred_prob_single_ref_p1(cm, xd)); + vp10_write(w, bit0, vp10_get_pred_prob_single_ref_p1(cm, xd)); if (bit0) { const int bit1 = mbmi->ref_frame[0] != GOLDEN_FRAME; - vpx_write(w, bit1, vp10_get_pred_prob_single_ref_p2(cm, xd)); + vp10_write(w, bit1, vp10_get_pred_prob_single_ref_p2(cm, xd)); } else { const int bit2 = (mbmi->ref_frame[0] == LAST3_FRAME || mbmi->ref_frame[0] == LAST4_FRAME); - vpx_write(w, bit2, vp10_get_pred_prob_single_ref_p3(cm, xd)); + vp10_write(w, bit2, vp10_get_pred_prob_single_ref_p3(cm, xd)); if (!bit2) { const int bit3 = mbmi->ref_frame[0] != LAST_FRAME; - vpx_write(w, bit3, vp10_get_pred_prob_single_ref_p4(cm, xd)); + vp10_write(w, bit3, vp10_get_pred_prob_single_ref_p4(cm, xd)); } else { const int bit4 = mbmi->ref_frame[0] != LAST3_FRAME; - vpx_write(w, bit4, vp10_get_pred_prob_single_ref_p5(cm, xd)); + vp10_write(w, bit4, vp10_get_pred_prob_single_ref_p5(cm, xd)); } } #else const int bit0 = mbmi->ref_frame[0] != LAST_FRAME; - vpx_write(w, bit0, vp10_get_pred_prob_single_ref_p1(cm, xd)); + vp10_write(w, bit0, vp10_get_pred_prob_single_ref_p1(cm, xd)); if (bit0) { const int bit1 = mbmi->ref_frame[0] != GOLDEN_FRAME; - vpx_write(w, bit1, vp10_get_pred_prob_single_ref_p2(cm, xd)); + vp10_write(w, bit1, vp10_get_pred_prob_single_ref_p2(cm, xd)); } #endif // CONFIG_EXT_REFS } @@ -896,13 +896,13 @@ static void write_ref_frames(const VP10_COMMON *cm, const MACROBLOCKD *xd, #if CONFIG_EXT_INTRA static void write_ext_intra_mode_info(const VP10_COMMON *const cm, const MB_MODE_INFO *const mbmi, - vpx_writer *w) { + vp10_writer *w) { #if !ALLOW_FILTER_INTRA_MODES return; #endif if (mbmi->mode == DC_PRED && mbmi->palette_mode_info.palette_size[0] == 0) { - vpx_write(w, mbmi->ext_intra_mode_info.use_ext_intra_mode[0], + vp10_write(w, mbmi->ext_intra_mode_info.use_ext_intra_mode[0], cm->fc->ext_intra_probs[0]); if (mbmi->ext_intra_mode_info.use_ext_intra_mode[0]) { EXT_INTRA_MODE mode = mbmi->ext_intra_mode_info.ext_intra_mode[0]; @@ -911,7 +911,7 @@ static void write_ext_intra_mode_info(const VP10_COMMON *const cm, } if (mbmi->uv_mode == DC_PRED && mbmi->palette_mode_info.palette_size[1] == 0) { - vpx_write(w, mbmi->ext_intra_mode_info.use_ext_intra_mode[1], + vp10_write(w, mbmi->ext_intra_mode_info.use_ext_intra_mode[1], cm->fc->ext_intra_probs[1]); if (mbmi->ext_intra_mode_info.use_ext_intra_mode[1]) { EXT_INTRA_MODE mode = mbmi->ext_intra_mode_info.ext_intra_mode[1]; @@ -923,7 +923,7 @@ static void write_ext_intra_mode_info(const VP10_COMMON *const cm, static void write_switchable_interp_filter(VP10_COMP *cpi, const MACROBLOCKD *xd, - vpx_writer *w) { + vp10_writer *w) { VP10_COMMON *const cm = &cpi->common; const MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi; if (cm->interp_filter == SWITCHABLE) { @@ -944,7 +944,7 @@ static void write_switchable_interp_filter(VP10_COMP *cpi, static void write_palette_mode_info(const VP10_COMMON *cm, const MACROBLOCKD *xd, const MODE_INFO *const mi, - vpx_writer *w) { + vp10_writer *w) { const MB_MODE_INFO *const mbmi = &mi->mbmi; const MODE_INFO *const above_mi = xd->above_mi; const MODE_INFO *const left_mi = xd->left_mi; @@ -959,30 +959,30 @@ static void write_palette_mode_info(const VP10_COMMON *cm, palette_ctx += (above_mi->mbmi.palette_mode_info.palette_size[0] > 0); if (left_mi) palette_ctx += (left_mi->mbmi.palette_mode_info.palette_size[0] > 0); - vpx_write(w, n > 0, + vp10_write(w, n > 0, vp10_default_palette_y_mode_prob[bsize - BLOCK_8X8][palette_ctx]); if (n > 0) { vp10_write_token(w, vp10_palette_size_tree, vp10_default_palette_y_size_prob[bsize - BLOCK_8X8], &palette_size_encodings[n - 2]); for (i = 0; i < n; ++i) - vpx_write_literal(w, pmi->palette_colors[i], cm->bit_depth); + vp10_write_literal(w, pmi->palette_colors[i], cm->bit_depth); write_uniform(w, n, pmi->palette_first_color_idx[0]); } } if (mbmi->uv_mode == DC_PRED) { n = pmi->palette_size[1]; - vpx_write(w, n > 0, + vp10_write(w, n > 0, vp10_default_palette_uv_mode_prob[pmi->palette_size[0] > 0]); if (n > 0) { vp10_write_token(w, vp10_palette_size_tree, vp10_default_palette_uv_size_prob[bsize - BLOCK_8X8], &palette_size_encodings[n - 2]); for (i = 0; i < n; ++i) { - vpx_write_literal(w, pmi->palette_colors[PALETTE_MAX_SIZE + i], + vp10_write_literal(w, pmi->palette_colors[PALETTE_MAX_SIZE + i], cm->bit_depth); - vpx_write_literal(w, pmi->palette_colors[2 * PALETTE_MAX_SIZE + i], + vp10_write_literal(w, pmi->palette_colors[2 * PALETTE_MAX_SIZE + i], cm->bit_depth); } write_uniform(w, n, pmi->palette_first_color_idx[1]); @@ -994,7 +994,7 @@ static void pack_inter_mode_mvs(VP10_COMP *cpi, const MODE_INFO *mi, #if CONFIG_SUPERTX int supertx_enabled, #endif - vpx_writer *w) { + vp10_writer *w) { VP10_COMMON *const cm = &cpi->common; #if !CONFIG_REF_MV const nmv_context *nmvc = &cm->fc->nmvc; @@ -1017,7 +1017,7 @@ static void pack_inter_mode_mvs(VP10_COMP *cpi, const MODE_INFO *mi, if (seg->temporal_update) { const int pred_flag = mbmi->seg_id_predicted; vpx_prob pred_prob = vp10_get_pred_prob_seg_id(segp, xd); - vpx_write(w, pred_flag, pred_prob); + vp10_write(w, pred_flag, pred_prob); if (!pred_flag) write_segment_id(w, seg, segp, segment_id); } else { @@ -1038,7 +1038,7 @@ static void pack_inter_mode_mvs(VP10_COMP *cpi, const MODE_INFO *mi, if (!supertx_enabled) #endif // CONFIG_SUPERTX if (!segfeature_active(seg, segment_id, SEG_LVL_REF_FRAME)) - vpx_write(w, is_inter, vp10_get_intra_inter_prob(cm, xd)); + vp10_write(w, is_inter, vp10_get_intra_inter_prob(cm, xd)); if (bsize >= BLOCK_8X8 && cm->tx_mode == TX_MODE_SELECT && #if CONFIG_SUPERTX @@ -1120,7 +1120,7 @@ static void pack_inter_mode_mvs(VP10_COMP *cpi, const MODE_INFO *mi, if (!supertx_enabled) #endif // CONFIG_SUPERTX if (is_obmc_allowed(mbmi)) - vpx_write(w, mbmi->obmc, cm->fc->obmc_prob[bsize]); + vp10_write(w, mbmi->obmc, cm->fc->obmc_prob[bsize]); #endif // CONFIG_OBMC #if CONFIG_REF_MV @@ -1294,17 +1294,17 @@ static void pack_inter_mode_mvs(VP10_COMP *cpi, const MODE_INFO *mi, #endif // CONFIG_SUPERTX is_interintra_allowed(mbmi)) { const int interintra = mbmi->ref_frame[1] == INTRA_FRAME; - vpx_write(w, interintra, cm->fc->interintra_prob[bsize]); + vp10_write(w, interintra, cm->fc->interintra_prob[bsize]); if (interintra) { write_interintra_mode( w, mbmi->interintra_mode, cm->fc->interintra_mode_prob[size_group_lookup[bsize]]); assert(mbmi->interintra_mode == mbmi->interintra_uv_mode); if (get_wedge_bits(bsize)) { - vpx_write(w, mbmi->use_wedge_interintra, + vp10_write(w, mbmi->use_wedge_interintra, cm->fc->wedge_interintra_prob[bsize]); if (mbmi->use_wedge_interintra) { - vpx_write_literal(w, mbmi->interintra_wedge_index, + vp10_write_literal(w, mbmi->interintra_wedge_index, get_wedge_bits(bsize)); } } @@ -1316,10 +1316,10 @@ static void pack_inter_mode_mvs(VP10_COMP *cpi, const MODE_INFO *mi, !(is_obmc_allowed(mbmi) && mbmi->obmc) && #endif // CONFIG_OBMC get_wedge_bits(bsize)) { - vpx_write(w, mbmi->use_wedge_interinter, + vp10_write(w, mbmi->use_wedge_interinter, cm->fc->wedge_interinter_prob[bsize]); if (mbmi->use_wedge_interinter) - vpx_write_literal(w, mbmi->interinter_wedge_index, + vp10_write_literal(w, mbmi->interinter_wedge_index, get_wedge_bits(bsize)); } #endif // CONFIG_EXT_INTER @@ -1383,7 +1383,7 @@ static void pack_inter_mode_mvs(VP10_COMP *cpi, const MODE_INFO *mi, } static void write_mb_modes_kf(const VP10_COMMON *cm, const MACROBLOCKD *xd, - MODE_INFO **mi_8x8, vpx_writer *w) { + MODE_INFO **mi_8x8, vp10_writer *w) { const struct segmentation *const seg = &cm->seg; const struct segmentation_probs *const segp = &cm->fc->seg; const MODE_INFO *const mi = mi_8x8[0]; @@ -1495,7 +1495,7 @@ static void write_mb_modes_kf(const VP10_COMMON *cm, const MACROBLOCKD *xd, #endif // CONFIG_ANS && CONFIG_SUPERTX static void write_modes_b(VP10_COMP *cpi, const TileInfo *const tile, - vpx_writer *w, + vp10_writer *w, #if CONFIG_ANS struct BufAnsCoder *ans, #endif // CONFIG_ANS @@ -1616,7 +1616,8 @@ static void write_modes_b(VP10_COMP *cpi, const TileInfo *const tile, static void write_partition(const VP10_COMMON *const cm, const MACROBLOCKD *const xd, int hbs, int mi_row, int mi_col, - PARTITION_TYPE p, BLOCK_SIZE bsize, vpx_writer *w) { + PARTITION_TYPE p, BLOCK_SIZE bsize, + vp10_writer *w) { const int ctx = partition_plane_context(xd, mi_row, mi_col, bsize); const vpx_prob *const probs = cm->fc->partition_prob[ctx]; const int has_rows = (mi_row + hbs) < cm->mi_rows; @@ -1634,10 +1635,10 @@ static void write_partition(const VP10_COMMON *const cm, #endif // CONFIG_EXT_PARTITION_TYPES } else if (!has_rows && has_cols) { assert(p == PARTITION_SPLIT || p == PARTITION_HORZ); - vpx_write(w, p == PARTITION_SPLIT, probs[1]); + vp10_write(w, p == PARTITION_SPLIT, probs[1]); } else if (has_rows && !has_cols) { assert(p == PARTITION_SPLIT || p == PARTITION_VERT); - vpx_write(w, p == PARTITION_SPLIT, probs[2]); + vp10_write(w, p == PARTITION_SPLIT, probs[2]); } else { assert(p == PARTITION_SPLIT); } @@ -1665,7 +1666,7 @@ static void write_partition(const VP10_COMMON *const cm, static void write_modes_sb(VP10_COMP *const cpi, const TileInfo *const tile, - vpx_writer *const w, + vp10_writer *const w, #if CONFIG_ANS struct BufAnsCoder *ans, #endif // CONFIG_ANS @@ -1716,9 +1717,9 @@ static void write_modes_sb(VP10_COMP *const cpi, prob = cm->fc->supertx_prob[partition_supertx_context_lookup[partition]] [supertx_size]; supertx_enabled = (xd->mi[0]->mbmi.tx_size == supertx_size); - vpx_write(w, supertx_enabled, prob); + vp10_write(w, supertx_enabled, prob); if (supertx_enabled) { - vpx_write(w, xd->mi[0]->mbmi.skip, vp10_get_skip_prob(cm, xd)); + vp10_write(w, xd->mi[0]->mbmi.skip, vp10_get_skip_prob(cm, xd)); #if CONFIG_EXT_TX if (get_ext_tx_types(supertx_size, bsize, 1) > 1 && !xd->mi[0]->mbmi.skip) { @@ -1852,7 +1853,7 @@ static void write_modes_sb(VP10_COMP *const cpi, static void write_modes(VP10_COMP *const cpi, const TileInfo *const tile, - vpx_writer *const w, + vp10_writer *const w, #if CONFIG_ANS struct BufAnsCoder *ans, #endif // CONFIG_ANS @@ -1905,7 +1906,7 @@ static void build_tree_distribution(VP10_COMP *cpi, TX_SIZE tx_size, } } -static void update_coef_probs_common(vpx_writer* const bc, VP10_COMP *cpi, +static void update_coef_probs_common(vp10_writer* const bc, VP10_COMP *cpi, TX_SIZE tx_size, vp10_coeff_stats *frame_branch_ct, vp10_coeff_probs_model *new_coef_probs) { @@ -1951,10 +1952,10 @@ static void update_coef_probs_common(vpx_writer* const bc, VP10_COMP *cpi, /* Is coef updated at all */ if (update[1] == 0 || savings < 0) { - vpx_write_bit(bc, 0); + vp10_write_bit(bc, 0); return; } - vpx_write_bit(bc, 1); + vp10_write_bit(bc, 1); for (i = 0; i < PLANE_TYPES; ++i) { for (j = 0; j < REF_TYPES; ++j) { for (k = 0; k < COEF_BANDS; ++k) { @@ -1976,7 +1977,7 @@ static void update_coef_probs_common(vpx_writer* const bc, VP10_COMP *cpi, *oldp, &newp, upd); if (s > 0 && newp != *oldp) u = 1; - vpx_write(bc, u, upd); + vp10_write(bc, u, upd); if (u) { /* send/use new probability */ vp10_write_prob_diff_update(bc, newp, *oldp); @@ -2024,11 +2025,11 @@ static void update_coef_probs_common(vpx_writer* const bc, VP10_COMP *cpi, if (u == 1 && updates == 1) { int v; // first update - vpx_write_bit(bc, 1); + vp10_write_bit(bc, 1); for (v = 0; v < noupdates_before_first; ++v) - vpx_write(bc, 0, upd); + vp10_write(bc, 0, upd); } - vpx_write(bc, u, upd); + vp10_write(bc, u, upd); if (u) { /* send/use new probability */ vp10_write_prob_diff_update(bc, newp, *oldp); @@ -2040,7 +2041,7 @@ static void update_coef_probs_common(vpx_writer* const bc, VP10_COMP *cpi, } } if (updates == 0) { - vpx_write_bit(bc, 0); // no updates + vp10_write_bit(bc, 0); // no updates } return; } @@ -2098,7 +2099,7 @@ static void get_coef_counts_diff(VP10_COMP *cpi, int index, } } -static void update_coef_probs_subframe(vpx_writer* const bc, VP10_COMP *cpi, +static void update_coef_probs_subframe(vp10_writer* const bc, VP10_COMP *cpi, TX_SIZE tx_size, vp10_coeff_stats branch_ct[COEF_PROBS_BUFS][TX_SIZES] @@ -2157,10 +2158,10 @@ static void update_coef_probs_subframe(vpx_writer* const bc, VP10_COMP *cpi, /* Is coef updated at all */ if (update[1] == 0 || savings < 0) { - vpx_write_bit(bc, 0); + vp10_write_bit(bc, 0); return; } - vpx_write_bit(bc, 1); + vp10_write_bit(bc, 1); for (i = 0; i < PLANE_TYPES; ++i) { for (j = 0; j < REF_TYPES; ++j) { for (k = 0; k < COEF_BANDS; ++k) { @@ -2189,7 +2190,7 @@ static void update_coef_probs_subframe(vpx_writer* const bc, VP10_COMP *cpi, max_idx); if (s > 0 && newp != *oldp) u = 1; - vpx_write(bc, u, upd); + vp10_write(bc, u, upd); if (u) { /* send/use new probability */ vp10_write_prob_diff_update(bc, newp, *oldp); @@ -2241,11 +2242,11 @@ static void update_coef_probs_subframe(vpx_writer* const bc, VP10_COMP *cpi, if (u == 1 && updates == 1) { int v; // first update - vpx_write_bit(bc, 1); + vp10_write_bit(bc, 1); for (v = 0; v < noupdates_before_first; ++v) - vpx_write(bc, 0, upd); + vp10_write(bc, 0, upd); } - vpx_write(bc, u, upd); + vp10_write(bc, u, upd); if (u) { /* send/use new probability */ vp10_write_prob_diff_update(bc, newp, *oldp); @@ -2257,7 +2258,7 @@ static void update_coef_probs_subframe(vpx_writer* const bc, VP10_COMP *cpi, } } if (updates == 0) { - vpx_write_bit(bc, 0); // no updates + vp10_write_bit(bc, 0); // no updates } return; } @@ -2267,7 +2268,7 @@ static void update_coef_probs_subframe(vpx_writer* const bc, VP10_COMP *cpi, } #endif // CONFIG_ENTROPY -static void update_coef_probs(VP10_COMP *cpi, vpx_writer* w) { +static void update_coef_probs(VP10_COMP *cpi, vp10_writer* w) { const TX_MODE tx_mode = cpi->common.tx_mode; const TX_SIZE max_tx_size = tx_mode_to_biggest_tx_size[tx_mode]; TX_SIZE tx_size; @@ -2298,7 +2299,7 @@ static void update_coef_probs(VP10_COMP *cpi, vpx_writer* w) { vp10_coeff_probs_model frame_coef_probs[PLANE_TYPES]; if (cpi->td.counts->tx_size_totals[tx_size] <= 20 || (tx_size >= TX_16X16 && cpi->sf.tx_size_search_method == USE_TX_8X8)) { - vpx_write_bit(w, 0); + vp10_write_bit(w, 0); } else { #if CONFIG_ENTROPY if (cm->do_subframe_update && @@ -2492,7 +2493,7 @@ static void encode_segmentation(VP10_COMMON *cm, MACROBLOCKD *xd, } } -static void update_seg_probs(VP10_COMP *cpi, vpx_writer *w) { +static void update_seg_probs(VP10_COMP *cpi, vp10_writer *w) { VP10_COMMON *cm = &cpi->common; if (!cpi->common.seg.enabled) @@ -2520,7 +2521,7 @@ static void write_txfm_mode(TX_MODE mode, struct vpx_write_bit_buffer *wb) { } -static void update_txfm_probs(VP10_COMMON *cm, vpx_writer *w, +static void update_txfm_probs(VP10_COMMON *cm, vp10_writer *w, FRAME_COUNTS *counts) { if (cm->tx_mode == TX_MODE_SELECT) { int i, j; @@ -2694,10 +2695,9 @@ static uint32_t write_tiles(VP10_COMP *const cpi, unsigned int *max_tile_size, unsigned int *max_tile_col_size) { VP10_COMMON *const cm = &cpi->common; - vpx_writer mode_bc; + vp10_writer mode_bc; #if CONFIG_ANS struct AnsCoder token_ans; - struct BufAnsCoder buffered_ans; #endif // CONFIG_ANS int tile_row, tile_col; TOKENEXTRA *(*const tok_buffers)[MAX_TILE_COLS] = cpi->tile_tok; @@ -2738,6 +2738,7 @@ static uint32_t write_tiles(VP10_COMP *const cpi, unsigned int tile_size; const TOKENEXTRA *tok = tok_buffers[tile_row][tile_col]; const TOKENEXTRA *tok_end = tok + cpi->tok_count[tile_row][tile_col]; + const int data_offset = have_tiles ? 4 : 0; vp10_tile_set_row(&tile_info, cm, tile_row); @@ -2745,28 +2746,20 @@ static uint32_t write_tiles(VP10_COMP *const cpi, // Is CONFIG_EXT_TILE = 1, every tile in the row has a header, // even for the last one, unless no tiling is used at all. - if (have_tiles) { - total_size += 4; - vpx_start_encode(&mode_bc, buf->data + 4); - } else { - vpx_start_encode(&mode_bc, buf->data); - } - + total_size += data_offset; #if !CONFIG_ANS + vpx_start_encode(&mode_bc, buf->data + data_offset); write_modes(cpi, &tile_info, &mode_bc, &tok, tok_end); assert(tok == tok_end); vpx_stop_encode(&mode_bc); tile_size = mode_bc.pos; #else - buf_ans_write_init(&buffered_ans, uco_ans_buf, ans_window_size); - write_modes(cpi, &tile_info, &mode_bc, &buffered_ans, &tok, tok_end); + buf_ans_write_init(&mode_bc, uco_ans_buf, ans_window_size); + write_modes(cpi, &tile_info, &mode_bc, &mode_bc, &tok, tok_end); assert(tok == tok_end); - vpx_stop_encode(&mode_bc); - tile_size = mode_bc.pos; - - ans_write_init(&token_ans, dst + total_size + tile_size); - buf_ans_flush(&buffered_ans, &token_ans); - tile_size += ans_write_end(&token_ans); + ans_write_init(&token_ans, buf->data + data_offset); + buf_ans_flush(&mode_bc, &token_ans); + tile_size = ans_write_end(&token_ans); #endif // !CONFIG_ANS buf->size = tile_size; @@ -2830,23 +2823,19 @@ static uint32_t write_tiles(VP10_COMP *const cpi, if (!is_last_tile) total_size += 4; - vpx_start_encode(&mode_bc, dst + total_size); - #if !CONFIG_ANS + vpx_start_encode(&mode_bc, dst + total_size); write_modes(cpi, &tile_info, &mode_bc, &tok, tok_end); assert(tok == tok_end); vpx_stop_encode(&mode_bc); tile_size = mode_bc.pos; #else - buf_ans_write_init(&buffered_ans, uco_ans_buf, ans_window_size); - write_modes(cpi, &tile_info, &mode_bc, &buffered_ans, &tok, tok_end); + buf_ans_write_init(&mode_bc, uco_ans_buf, ans_window_size); + write_modes(cpi, &tile_info, &mode_bc, &mode_bc, &tok, tok_end); assert(tok == tok_end); - vpx_stop_encode(&mode_bc); - tile_size = mode_bc.pos; - - ans_write_init(&token_ans, dst + total_size + tile_size); - buf_ans_flush(&buffered_ans, &token_ans); - tile_size += ans_write_end(&token_ans); + ans_write_init(&token_ans, dst + total_size); + buf_ans_flush(&mode_bc, &token_ans); + tile_size = ans_write_end(&token_ans); #endif // !CONFIG_ANS assert(tile_size > 0); @@ -3068,10 +3057,20 @@ static uint32_t write_compressed_header(VP10_COMP *cpi, uint8_t *data) { #endif // CONFIG_SUPERTX FRAME_CONTEXT *const fc = cm->fc; FRAME_COUNTS *counts = cpi->td.counts; - vpx_writer header_bc; + vp10_writer header_bc; int i, j; +#if CONFIG_ANS + struct AnsCoder header_ans; + struct buffered_ans_symbol *uco_ans_buf; + const int ans_window_size = 50000; // TODO(aconverse): revisit window size + int header_size; + CHECK_MEM_ERROR(cm, uco_ans_buf, + vpx_malloc(ans_window_size * sizeof(*uco_ans_buf))); + buf_ans_write_init(&header_bc, uco_ans_buf, ans_window_size); +#else vpx_start_encode(&header_bc, data); +#endif update_txfm_probs(cm, &header_bc, counts); update_coef_probs(cpi, &header_bc); @@ -3209,10 +3208,18 @@ static uint32_t write_compressed_header(VP10_COMP *cpi, uint8_t *data) { #endif // CONFIG_SUPERTX } +#if CONFIG_ANS + ans_write_init(&header_ans, data); + buf_ans_flush(&header_bc, &header_ans); + vpx_free(uco_ans_buf); + header_size = ans_write_end(&header_ans); + assert(header_size <= 0xffff); + return header_size; +#else vpx_stop_encode(&header_bc); assert(header_bc.pos <= 0xffff); - return header_bc.pos; +#endif // CONFIG_ANS } static int choose_size_bytes(uint32_t size, int spare_msbs) { diff --git a/vp10/encoder/encodemv.c b/vp10/encoder/encodemv.c index a5bfd1afa..a2d0659a1 100644 --- a/vp10/encoder/encodemv.c +++ b/vp10/encoder/encodemv.c @@ -31,7 +31,7 @@ void vp10_entropy_mv_init(void) { vp10_tokens_from_tree(mv_fp_encodings, vp10_mv_fp_tree); } -static void encode_mv_component(vpx_writer* w, int comp, +static void encode_mv_component(vp10_writer* w, int comp, const nmv_component* mvcomp, int usehp) { int offset; const int sign = comp < 0; @@ -44,7 +44,7 @@ static void encode_mv_component(vpx_writer* w, int comp, assert(comp != 0); // Sign - vpx_write(w, sign, mvcomp->sign); + vp10_write(w, sign, mvcomp->sign); // Class vp10_write_token(w, vp10_mv_class_tree, mvcomp->classes, @@ -58,7 +58,7 @@ static void encode_mv_component(vpx_writer* w, int comp, int i; const int n = mv_class + CLASS0_BITS - 1; // number of bits for (i = 0; i < n; ++i) - vpx_write(w, (d >> i) & 1, mvcomp->bits[i]); + vp10_write(w, (d >> i) & 1, mvcomp->bits[i]); } // Fractional bits @@ -68,7 +68,7 @@ static void encode_mv_component(vpx_writer* w, int comp, // High precision bit if (usehp) - vpx_write(w, hp, + vp10_write(w, hp, mv_class == MV_CLASS_0 ? mvcomp->class0_hp : mvcomp->hp); } @@ -135,7 +135,7 @@ static void build_nmv_component_cost_table(int *mvcost, } } -static void update_mv(vpx_writer *w, const unsigned int ct[2], vpx_prob *cur_p, +static void update_mv(vp10_writer *w, const unsigned int ct[2], vpx_prob *cur_p, vpx_prob upd_p) { (void) upd_p; vp10_cond_prob_diff_update(w, cur_p, ct); @@ -144,7 +144,7 @@ static void update_mv(vpx_writer *w, const unsigned int ct[2], vpx_prob *cur_p, static void write_mv_update(const vpx_tree_index *tree, vpx_prob probs[/*n - 1*/], const unsigned int counts[/*n - 1*/], - int n, vpx_writer *w) { + int n, vp10_writer *w) { int i; unsigned int branch_ct[32][2]; @@ -156,7 +156,7 @@ static void write_mv_update(const vpx_tree_index *tree, update_mv(w, branch_ct[i], &probs[i], MV_UPDATE_PROB); } -void vp10_write_nmv_probs(VP10_COMMON *cm, int usehp, vpx_writer *w, +void vp10_write_nmv_probs(VP10_COMMON *cm, int usehp, vp10_writer *w, nmv_context_counts *const nmv_counts) { int i, j; #if CONFIG_REF_MV @@ -235,7 +235,7 @@ void vp10_write_nmv_probs(VP10_COMMON *cm, int usehp, vpx_writer *w, #endif } -void vp10_encode_mv(VP10_COMP* cpi, vpx_writer* w, +void vp10_encode_mv(VP10_COMP* cpi, vp10_writer* w, const MV* mv, const MV* ref, const nmv_context* mvctx, int usehp) { const MV diff = {mv->row - ref->row, diff --git a/vp10/encoder/encodemv.h b/vp10/encoder/encodemv.h index c753d349f..a026b0413 100644 --- a/vp10/encoder/encodemv.h +++ b/vp10/encoder/encodemv.h @@ -20,10 +20,10 @@ extern "C" { void vp10_entropy_mv_init(void); -void vp10_write_nmv_probs(VP10_COMMON *cm, int usehp, vpx_writer *w, +void vp10_write_nmv_probs(VP10_COMMON *cm, int usehp, vp10_writer *w, nmv_context_counts *const counts); -void vp10_encode_mv(VP10_COMP *cpi, vpx_writer* w, const MV* mv, const MV* ref, +void vp10_encode_mv(VP10_COMP *cpi, vp10_writer* w, const MV* mv, const MV* ref, const nmv_context* mvctx, int usehp); void vp10_build_nmv_cost_table(int *mvjoint, int *mvcost[2], diff --git a/vp10/encoder/subexp.c b/vp10/encoder/subexp.c index d944d0137..6d9c45f44 100644 --- a/vp10/encoder/subexp.c +++ b/vp10/encoder/subexp.c @@ -7,7 +7,7 @@ * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree. */ -#include "vpx_dsp/bitwriter.h" +#include "vp10/encoder/bitwriter.h" #include "vp10/common/common.h" #include "vp10/common/entropy.h" @@ -83,35 +83,35 @@ static int prob_diff_update_cost(vpx_prob newp, vpx_prob oldp) { return update_bits[delp] << VP9_PROB_COST_SHIFT; } -static void encode_uniform(vpx_writer *w, int v) { +static void encode_uniform(vp10_writer *w, int v) { const int l = 8; const int m = (1 << l) - 190; if (v < m) { - vpx_write_literal(w, v, l - 1); + vp10_write_literal(w, v, l - 1); } else { - vpx_write_literal(w, m + ((v - m) >> 1), l - 1); - vpx_write_literal(w, (v - m) & 1, 1); + vp10_write_literal(w, m + ((v - m) >> 1), l - 1); + vp10_write_literal(w, (v - m) & 1, 1); } } -static INLINE int write_bit_gte(vpx_writer *w, int word, int test) { - vpx_write_literal(w, word >= test, 1); +static INLINE int write_bit_gte(vp10_writer *w, int word, int test) { + vp10_write_literal(w, word >= test, 1); return word >= test; } -static void encode_term_subexp(vpx_writer *w, int word) { +static void encode_term_subexp(vp10_writer *w, int word) { if (!write_bit_gte(w, word, 16)) { - vpx_write_literal(w, word, 4); + vp10_write_literal(w, word, 4); } else if (!write_bit_gte(w, word, 32)) { - vpx_write_literal(w, word - 16, 4); + vp10_write_literal(w, word - 16, 4); } else if (!write_bit_gte(w, word, 64)) { - vpx_write_literal(w, word - 32, 5); + vp10_write_literal(w, word - 32, 5); } else { encode_uniform(w, word - 64); } } -void vp10_write_prob_diff_update(vpx_writer *w, vpx_prob newp, vpx_prob oldp) { +void vp10_write_prob_diff_update(vp10_writer *w, vpx_prob newp, vpx_prob oldp) { const int delp = remap_prob(newp, oldp); encode_term_subexp(w, delp); } @@ -262,7 +262,7 @@ int vp10_prob_update_search_model_subframe(unsigned int ct[ENTROPY_NODES] } #endif // CONFIG_ENTROPY -void vp10_cond_prob_diff_update(vpx_writer *w, vpx_prob *oldp, +void vp10_cond_prob_diff_update(vp10_writer *w, vpx_prob *oldp, const unsigned int ct[2]) { const vpx_prob upd = DIFF_UPDATE_PROB; vpx_prob newp = get_binary_prob(ct[0], ct[1]); @@ -270,11 +270,11 @@ void vp10_cond_prob_diff_update(vpx_writer *w, vpx_prob *oldp, upd); assert(newp >= 1); if (savings > 0) { - vpx_write(w, 1, upd); + vp10_write(w, 1, upd); vp10_write_prob_diff_update(w, newp, *oldp); *oldp = newp; } else { - vpx_write(w, 0, upd); + vp10_write(w, 0, upd); } } diff --git a/vp10/encoder/subexp.h b/vp10/encoder/subexp.h index 0f9227c5b..756b499e5 100644 --- a/vp10/encoder/subexp.h +++ b/vp10/encoder/subexp.h @@ -18,12 +18,12 @@ extern "C" { #include "vpx_dsp/prob.h" -struct vpx_writer; +struct vp10_writer; -void vp10_write_prob_diff_update(struct vpx_writer *w, +void vp10_write_prob_diff_update(struct vp10_writer *w, vpx_prob newp, vpx_prob oldp); -void vp10_cond_prob_diff_update(struct vpx_writer *w, vpx_prob *oldp, +void vp10_cond_prob_diff_update(struct vp10_writer *w, vpx_prob *oldp, const unsigned int ct[2]); int vp10_prob_diff_update_savings_search(const unsigned int *ct, -- 2.40.0