From 98c192ae83a4a5f470ac63162af321b6085994f3 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Thu, 30 May 2013 09:58:53 -0700 Subject: Merge all intra mode coding trees into a single one. Also merge all counters. This removes a few unused probability updates from the bitstream. Change-Id: I20f58853e9dac84d8c0d9703ae012c55917516eb --- vp9/encoder/vp9_bitstream.c | 103 ++++++++------------------------------------ 1 file changed, 18 insertions(+), 85 deletions(-) (limited to 'vp9/encoder/vp9_bitstream.c') diff --git a/vp9/encoder/vp9_bitstream.c b/vp9/encoder/vp9_bitstream.c index e4db5c1dc..aede81a04 100644 --- a/vp9/encoder/vp9_bitstream.c +++ b/vp9/encoder/vp9_bitstream.c @@ -248,12 +248,9 @@ static void update_mbintra_mode_probs(VP9_COMP* const cpi, vp9_prob pnew[VP9_YMODES - 1]; unsigned int bct[VP9_YMODES - 1][2]; - update_mode(bc, VP9_YMODES, vp9_ymode_encodings, vp9_ymode_tree, pnew, - cm->fc.ymode_prob, bct, (unsigned int *)cpi->ymode_count); - - update_mode(bc, VP9_I32X32_MODES, vp9_sb_ymode_encodings, - vp9_sb_ymode_tree, pnew, cm->fc.sb_ymode_prob, bct, - (unsigned int *)cpi->sb_ymode_count); + update_mode(bc, VP9_YMODES, vp9_intra_mode_encodings, + vp9_intra_mode_tree, pnew, + cm->fc.y_mode_prob, bct, (unsigned int *)cpi->y_mode_count); } void vp9_update_skip_probs(VP9_COMP *cpi) { @@ -350,28 +347,8 @@ static void update_inter_mode_probs(VP9_COMMON *cm, } } -static void write_ymode(vp9_writer *bc, int m, const vp9_prob *p) { - write_token(bc, vp9_ymode_tree, p, vp9_ymode_encodings + m); -} - -static void kfwrite_ymode(vp9_writer *bc, int m, const vp9_prob *p) { - write_token(bc, vp9_kf_ymode_tree, p, vp9_kf_ymode_encodings + m); -} - -static void write_sb_ymode(vp9_writer *bc, int m, const vp9_prob *p) { - write_token(bc, vp9_sb_ymode_tree, p, vp9_sb_ymode_encodings + m); -} - -static void sb_kfwrite_ymode(vp9_writer *bc, int m, const vp9_prob *p) { - write_token(bc, vp9_uv_mode_tree, p, vp9_sb_kf_ymode_encodings + m); -} - -static void write_uv_mode(vp9_writer *bc, int m, const vp9_prob *p) { - write_token(bc, vp9_uv_mode_tree, p, vp9_uv_mode_encodings + m); -} - -static void write_kf_bmode(vp9_writer *bc, int m, const vp9_prob *p) { - write_token(bc, vp9_bmode_tree, p, vp9_kf_bmode_encodings + m); +static void write_intra_mode(vp9_writer *bc, int m, const vp9_prob *p) { + write_token(bc, vp9_intra_mode_tree, p, vp9_intra_mode_encodings + m); } static int prob_update_savings(const unsigned int *ct, @@ -716,20 +693,19 @@ static void pack_inter_mode_mvs(VP9_COMP *cpi, MODE_INFO *m, active_section = 6; #endif - if (m->mbmi.sb_type >= BLOCK_SIZE_SB8X8) - write_sb_ymode(bc, mode, pc->fc.sb_ymode_prob); - - if (m->mbmi.sb_type < BLOCK_SIZE_SB8X8) { + if (m->mbmi.sb_type >= BLOCK_SIZE_SB8X8) { + write_intra_mode(bc, mode, pc->fc.y_mode_prob); + } else { int idx, idy; int bw = 1 << b_width_log2(mi->sb_type); int bh = 1 << b_height_log2(mi->sb_type); for (idy = 0; idy < 2; idy += bh) for (idx = 0; idx < 2; idx += bw) - write_sb_ymode(bc, m->bmi[idy * 2 + idx].as_mode.first, - pc->fc.sb_ymode_prob); + write_intra_mode(bc, m->bmi[idy * 2 + idx].as_mode.first, + pc->fc.y_mode_prob); } - write_uv_mode(bc, mi->uv_mode, - pc->fc.uv_mode_prob[mode]); + write_intra_mode(bc, mi->uv_mode, + pc->fc.uv_mode_prob[mode]); } else { vp9_prob mv_ref_p[VP9_MVREFS - 1]; @@ -855,10 +831,8 @@ static void write_mb_modes_kf(const VP9_COMP *cpi, const MB_PREDICTION_MODE A = above_block_mode(m, 0, mis); const MB_PREDICTION_MODE L = xd->left_available ? left_block_mode(m, 0) : DC_PRED; - write_kf_bmode(bc, ym, c->kf_bmode_prob[A][L]); - } - - if (m->mbmi.sb_type < BLOCK_SIZE_SB8X8) { + write_intra_mode(bc, ym, c->kf_y_mode_prob[A][L]); + } else { int idx, idy; int bw = 1 << b_width_log2(m->mbmi.sb_type); int bh = 1 << b_height_log2(m->mbmi.sb_type); @@ -872,12 +846,12 @@ static void write_mb_modes_kf(const VP9_COMP *cpi, #ifdef ENTROPY_STATS ++intra_mode_stats[A][L][bm]; #endif - write_kf_bmode(bc, bm, c->kf_bmode_prob[A][L]); + write_intra_mode(bc, bm, c->kf_y_mode_prob[A][L]); } } } - write_uv_mode(bc, m->mbmi.uv_mode, c->kf_uv_mode_prob[ym]); + write_intra_mode(bc, m->mbmi.uv_mode, c->kf_uv_mode_prob[ym]); } static void write_modes_b(VP9_COMP *cpi, MODE_INFO *m, vp9_writer *bc, @@ -1290,33 +1264,6 @@ static void update_coef_probs(VP9_COMP* const cpi, vp9_writer* const bc) { } } -static void decide_kf_ymode_entropy(VP9_COMP *cpi) { - int mode_cost[MB_MODE_COUNT]; - int bestcost = INT_MAX; - int bestindex = 0; - int i, j; - - for (i = 0; i < 8; i++) { - int cost = 0; - - vp9_cost_tokens(mode_cost, cpi->common.kf_ymode_prob[i], vp9_kf_ymode_tree); - - for (j = 0; j < VP9_YMODES; j++) - cost += mode_cost[j] * cpi->ymode_count[j]; - - vp9_cost_tokens(mode_cost, cpi->common.sb_kf_ymode_prob[i], - vp9_sb_ymode_tree); - for (j = 0; j < VP9_I32X32_MODES; j++) - cost += mode_cost[j] * cpi->sb_ymode_count[j]; - - if (cost < bestcost) { - bestindex = i; - bestcost = cost; - } - } - cpi->common.kf_ymode_probs_index = bestindex; - -} static void segment_reference_frames(VP9_COMP *cpi) { VP9_COMMON *oci = &cpi->common; MODE_INFO *mi = oci->mi; @@ -1734,10 +1681,8 @@ void vp9_pack_bitstream(VP9_COMP *cpi, uint8_t *dest, unsigned long *size) { vp9_copy(cpi->common.fc.pre_coef_probs_32x32, cpi->common.fc.coef_probs_32x32); - vp9_copy(cpi->common.fc.pre_sb_ymode_prob, cpi->common.fc.sb_ymode_prob); - vp9_copy(cpi->common.fc.pre_ymode_prob, cpi->common.fc.ymode_prob); + vp9_copy(cpi->common.fc.pre_y_mode_prob, cpi->common.fc.y_mode_prob); vp9_copy(cpi->common.fc.pre_uv_mode_prob, cpi->common.fc.uv_mode_prob); - vp9_copy(cpi->common.fc.pre_bmode_prob, cpi->common.fc.bmode_prob); vp9_copy(cpi->common.fc.pre_partition_prob, cpi->common.fc.partition_prob); cpi->common.fc.pre_nmvc = cpi->common.fc.nmvc; vp9_zero(cpi->common.fc.mv_ref_ct); @@ -1753,11 +1698,7 @@ void vp9_pack_bitstream(VP9_COMP *cpi, uint8_t *dest, unsigned long *size) { vp9_write_prob(&header_bc, pc->mbskip_pred_probs[i]); } - if (pc->frame_type == KEY_FRAME) { - if (!pc->kf_ymode_probs_update) { - vp9_write_literal(&header_bc, pc->kf_ymode_probs_index, 3); - } - } else { + if (pc->frame_type != KEY_FRAME) { // Update the probabilities used to encode reference frame data update_ref_probs(cpi); @@ -1829,14 +1770,6 @@ void vp9_pack_bitstream(VP9_COMP *cpi, uint8_t *dest, unsigned long *size) { vp9_wb_write_literal(&first_partition_size_wb, header_bc.pos, 16); *size = bytes_packed + header_bc.pos; - if (pc->frame_type == KEY_FRAME) { - decide_kf_ymode_entropy(cpi); - } else { - /* This is not required if the counts in cpi are consistent with the - * final packing pass */ - // if (!cpi->dummy_packing) vp9_zero(cpi->NMVcount); - } - { int tile_row, tile_col, total_size = 0; unsigned char *data_ptr = cx_data + header_bc.pos; -- cgit v1.2.3