From ef4d9a4843b16a55a9161b4597edddd3ac7b1d8c Mon Sep 17 00:00:00 2001 From: Dmitry Kovalev Date: Tue, 16 Apr 2013 16:23:17 -0700 Subject: [PATCH] Adding vp9_write_prob function (macro for now). Change-Id: Ic795cf6fc202bf32c9b5b0b3cef9ac422af53cd0 --- vp9/encoder/vp9_bitstream.c | 34 +++++++++++++++++----------------- vp9/encoder/vp9_treewriter.h | 3 ++- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/vp9/encoder/vp9_bitstream.c b/vp9/encoder/vp9_bitstream.c index 406bfd2..f9cef45 100644 --- a/vp9/encoder/vp9_bitstream.c +++ b/vp9/encoder/vp9_bitstream.c @@ -191,7 +191,7 @@ static void update_switchable_interp_probs(VP9_COMP *cpi, for (i = 0; i < VP9_SWITCHABLE_FILTERS - 1; ++i) { if (pc->fc.switchable_interp_prob[j][i] < 1) pc->fc.switchable_interp_prob[j][i] = 1; - vp9_write_literal(bc, pc->fc.switchable_interp_prob[j][i], 8); + vp9_write_prob(bc, pc->fc.switchable_interp_prob[j][i]); } } } @@ -444,7 +444,7 @@ static void vp9_cond_prob_update(vp9_writer *bc, vp9_prob *oldp, vp9_prob upd, savings = prob_update_savings(ct, *oldp, newp, upd); if (savings > 0) { vp9_write(bc, 1, upd); - vp9_write_literal(bc, newp, 8); + vp9_write_prob(bc, newp); *oldp = newp; } else { vp9_write(bc, 0, upd); @@ -2407,7 +2407,7 @@ void vp9_pack_bitstream(VP9_COMP *cpi, unsigned char *dest, const int prob = xd->mb_segment_tree_probs[i]; if (prob != 255) { vp9_write_bit(&header_bc, 1); - vp9_write_literal(&header_bc, prob, 8); + vp9_write_prob(&header_bc, prob); } else { vp9_write_bit(&header_bc, 0); } @@ -2420,7 +2420,7 @@ void vp9_pack_bitstream(VP9_COMP *cpi, unsigned char *dest, const int prob = pc->segment_pred_probs[i]; if (prob != 255) { vp9_write_bit(&header_bc, 1); - vp9_write_literal(&header_bc, prob, 8); + vp9_write_prob(&header_bc, prob); } else { vp9_write_bit(&header_bc, 0); } @@ -2475,7 +2475,7 @@ void vp9_pack_bitstream(VP9_COMP *cpi, unsigned char *dest, for (i = 0; i < PREDICTION_PROBS; i++) { if (cpi->ref_pred_probs_update[i]) { vp9_write_bit(&header_bc, 1); - vp9_write_literal(&header_bc, pc->ref_pred_probs[i], 8); + vp9_write_prob(&header_bc, pc->ref_pred_probs[i]); } else { vp9_write_bit(&header_bc, 0); } @@ -2483,9 +2483,9 @@ void vp9_pack_bitstream(VP9_COMP *cpi, unsigned char *dest, } pc->prob_sb64_coded = get_binary_prob(cpi->sb64_count[0], cpi->sb64_count[1]); - vp9_write_literal(&header_bc, pc->prob_sb64_coded, 8); + vp9_write_prob(&header_bc, pc->prob_sb64_coded); pc->prob_sb32_coded = get_binary_prob(cpi->sb32_count[0], cpi->sb32_count[1]); - vp9_write_literal(&header_bc, pc->prob_sb32_coded, 8); + vp9_write_prob(&header_bc, pc->prob_sb32_coded); vp9_write_bit(&header_bc, cpi->mb.e_mbd.lossless); if (cpi->mb.e_mbd.lossless) { @@ -2524,9 +2524,9 @@ void vp9_pack_bitstream(VP9_COMP *cpi, unsigned char *dest, vp9_write_bit(&header_bc, pc->txfm_mode == TX_MODE_SELECT); } if (pc->txfm_mode == TX_MODE_SELECT) { - vp9_write_literal(&header_bc, pc->prob_tx[0], 8); - vp9_write_literal(&header_bc, pc->prob_tx[1], 8); - vp9_write_literal(&header_bc, pc->prob_tx[2], 8); + vp9_write_prob(&header_bc, pc->prob_tx[0]); + vp9_write_prob(&header_bc, pc->prob_tx[1]); + vp9_write_prob(&header_bc, pc->prob_tx[2]); } } @@ -2723,7 +2723,7 @@ void vp9_pack_bitstream(VP9_COMP *cpi, unsigned char *dest, for (j = 0; j < 4; j++) { if (new_context[i][j] != pc->fc.vp9_mode_contexts[i][j]) { vp9_write(&header_bc, 1, 252); - vp9_write_literal(&header_bc, new_context[i][j], 8); + vp9_write_prob(&header_bc, new_context[i][j]); // Only update the persistent copy if this is the "real pack" if (!cpi->dummy_packing) { @@ -2753,7 +2753,7 @@ void vp9_pack_bitstream(VP9_COMP *cpi, unsigned char *dest, for (j = 0; j < MAX_MV_REF_CANDIDATES - 1; ++j) { if (new_mvref_probs[i][j] != xd->mb_mv_ref_probs[i][j]) { vp9_write(&header_bc, 1, VP9_MVREF_UPDATE_PROB); - vp9_write_literal(&header_bc, new_mvref_probs[i][j], 8); + vp9_write_prob(&header_bc, new_mvref_probs[i][j]); // Only update the persistent copy if this is the "real pack" if (!cpi->dummy_packing) { @@ -2827,7 +2827,7 @@ void vp9_pack_bitstream(VP9_COMP *cpi, unsigned char *dest, vp9_update_skip_probs(cpi); for (i = 0; i < MBSKIP_CONTEXTS; ++i) { - vp9_write_literal(&header_bc, pc->mbskip_pred_probs[i], 8); + vp9_write_prob(&header_bc, pc->mbskip_pred_probs[i]); } if (pc->frame_type == KEY_FRAME) { @@ -2854,9 +2854,9 @@ void vp9_pack_bitstream(VP9_COMP *cpi, unsigned char *dest, } #endif - vp9_write_literal(&header_bc, pc->prob_intra_coded, 8); - vp9_write_literal(&header_bc, pc->prob_last_coded, 8); - vp9_write_literal(&header_bc, pc->prob_gf_coded, 8); + vp9_write_prob(&header_bc, pc->prob_intra_coded); + vp9_write_prob(&header_bc, pc->prob_last_coded); + vp9_write_prob(&header_bc, pc->prob_gf_coded); { const int comp_pred_mode = cpi->common.comp_pred_mode; @@ -2870,7 +2870,7 @@ void vp9_pack_bitstream(VP9_COMP *cpi, unsigned char *dest, for (i = 0; i < COMP_PRED_CONTEXTS; i++) { pc->prob_comppred[i] = get_binary_prob(cpi->single_pred_count[i], cpi->comp_pred_count[i]); - vp9_write_literal(&header_bc, pc->prob_comppred[i], 8); + vp9_write_prob(&header_bc, pc->prob_comppred[i]); } } } diff --git a/vp9/encoder/vp9_treewriter.h b/vp9/encoder/vp9_treewriter.h index d11a5dd..af2c122 100644 --- a/vp9/encoder/vp9_treewriter.h +++ b/vp9/encoder/vp9_treewriter.h @@ -23,7 +23,8 @@ typedef BOOL_CODER vp9_writer; #define vp9_write encode_bool #define vp9_write_literal vp9_encode_value -#define vp9_write_bit(W, V) vp9_write(W, V, vp9_prob_half) +#define vp9_write_bit(w, v) vp9_write((w), (v), vp9_prob_half) +#define vp9_write_prob(w, v) vp9_write_literal((w), (v), 8) /* Approximate length of an encoded bool in 256ths of a bit at given prob */ -- 2.7.4