From d8c0989d56d21e2d72a95b8855b2ddd218c5b068 Mon Sep 17 00:00:00 2001 From: Deb Mukherjee Date: Tue, 28 May 2013 16:25:43 -0700 Subject: [PATCH] Clean up related to coefficient modeling Uses reduced arrays for probabilities and branch counts in the encoder. No change in bitstream. Change-Id: Iec605446f44db4cd325eb45fa12a3003a6ee29db --- vp9/common/vp9_entropy.c | 24 +++++++++++++----------- vp9/common/vp9_entropy.h | 2 ++ vp9/encoder/vp9_bitstream.c | 14 ++++++++------ vp9/encoder/vp9_onyx_int.h | 16 ++++++++-------- 4 files changed, 31 insertions(+), 25 deletions(-) diff --git a/vp9/common/vp9_entropy.c b/vp9/common/vp9_entropy.c index 1b7da6c..847fee6 100644 --- a/vp9/common/vp9_entropy.c +++ b/vp9/common/vp9_entropy.c @@ -642,6 +642,17 @@ void vp9_coef_tree_initialize() { #define COEF_COUNT_SAT_AFTER_KEY 24 #define COEF_MAX_UPDATE_FACTOR_AFTER_KEY 128 +void vp9_full_to_model_count(unsigned int *model_count, + unsigned int *full_count) { + int n; + model_count[ZERO_TOKEN] = full_count[ZERO_TOKEN]; + model_count[ONE_TOKEN] = full_count[ONE_TOKEN]; + model_count[TWO_TOKEN] = full_count[TWO_TOKEN]; + for (n = THREE_TOKEN; n < DCT_EOB_TOKEN; ++n) + model_count[TWO_TOKEN] += full_count[n]; + model_count[DCT_EOB_MODEL_TOKEN] = full_count[DCT_EOB_TOKEN]; +} + void vp9_full_to_model_counts( vp9_coeff_count_model *model_count, vp9_coeff_count *full_count) { int i, j, k, l; @@ -649,19 +660,10 @@ void vp9_full_to_model_counts( for (j = 0; j < REF_TYPES; ++j) for (k = 0; k < COEF_BANDS; ++k) for (l = 0; l < PREV_COEF_CONTEXTS; ++l) { - int n; if (l >= 3 && k == 0) continue; - model_count[i][j][k][l][ZERO_TOKEN] = - full_count[i][j][k][l][ZERO_TOKEN]; - model_count[i][j][k][l][ONE_TOKEN] = - full_count[i][j][k][l][ONE_TOKEN]; - model_count[i][j][k][l][TWO_TOKEN] = - full_count[i][j][k][l][TWO_TOKEN]; - for (n = THREE_TOKEN; n < DCT_EOB_TOKEN; ++n) - model_count[i][j][k][l][TWO_TOKEN] += full_count[i][j][k][l][n]; - model_count[i][j][k][l][DCT_EOB_MODEL_TOKEN] = - full_count[i][j][k][l][DCT_EOB_TOKEN]; + vp9_full_to_model_count(model_count[i][j][k][l], + full_count[i][j][k][l]); } } diff --git a/vp9/common/vp9_entropy.h b/vp9/common/vp9_entropy.h index 5d57f14..e76211a 100644 --- a/vp9/common/vp9_entropy.h +++ b/vp9/common/vp9_entropy.h @@ -174,6 +174,8 @@ typedef unsigned int vp9_coeff_count_model[REF_TYPES][COEF_BANDS] typedef unsigned int vp9_coeff_stats_model[REF_TYPES][COEF_BANDS] [PREV_COEF_CONTEXTS] [UNCONSTRAINED_NODES][2]; +extern void vp9_full_to_model_count(unsigned int *model_count, + unsigned int *full_count); extern void vp9_full_to_model_counts( vp9_coeff_count_model *model_count, vp9_coeff_count *full_count); diff --git a/vp9/encoder/vp9_bitstream.c b/vp9/encoder/vp9_bitstream.c index a2d7d4e..98cdb15 100644 --- a/vp9/encoder/vp9_bitstream.c +++ b/vp9/encoder/vp9_bitstream.c @@ -1067,7 +1067,7 @@ static void print_prob_tree(vp9_coeff_probs *coef_probs, int block_types) { fclose(f); } -static void build_tree_distribution(vp9_coeff_probs *coef_probs, +static void build_tree_distribution(vp9_coeff_probs_model *coef_probs, vp9_coeff_count *coef_counts, unsigned int (*eob_branch_ct)[REF_TYPES] [COEF_BANDS] @@ -1076,12 +1076,13 @@ static void build_tree_distribution(vp9_coeff_probs *coef_probs, VP9_COMP *cpi, vp9_coeff_accum *context_counters, #endif - vp9_coeff_stats *coef_branch_ct, + vp9_coeff_stats_model *coef_branch_ct, int block_types) { int i, j, k, l; #ifdef ENTROPY_STATS int t = 0; #endif + unsigned int model_counts[UNCONSTRAINED_NODES + 1]; for (i = 0; i < block_types; ++i) { for (j = 0; j < REF_TYPES; ++j) { @@ -1089,10 +1090,11 @@ static void build_tree_distribution(vp9_coeff_probs *coef_probs, for (l = 0; l < PREV_COEF_CONTEXTS; ++l) { if (l >= 3 && k == 0) continue; - vp9_tree_probs_from_distribution(vp9_coef_tree, + vp9_full_to_model_count(model_counts, coef_counts[i][j][k][l]); + vp9_tree_probs_from_distribution(vp9_coefmodel_tree, coef_probs[i][j][k][l], coef_branch_ct[i][j][k][l], - coef_counts[i][j][k][l], 0); + model_counts, 0); coef_branch_ct[i][j][k][l][0][1] = eob_branch_ct[i][j][k][l] - coef_branch_ct[i][j][k][l][0][0]; coef_probs[i][j][k][l][0] = @@ -1149,9 +1151,9 @@ static void update_coef_probs_common( #ifdef ENTROPY_STATS vp9_coeff_stats *tree_update_hist, #endif - vp9_coeff_probs *new_frame_coef_probs, + vp9_coeff_probs_model *new_frame_coef_probs, vp9_coeff_probs_model *old_frame_coef_probs, - vp9_coeff_stats *frame_branch_ct, + vp9_coeff_stats_model *frame_branch_ct, TX_SIZE tx_size) { int i, j, k, l, t; int update[2] = {0, 0}; diff --git a/vp9/encoder/vp9_onyx_int.h b/vp9/encoder/vp9_onyx_int.h index e3e95ed..f45a7e8 100644 --- a/vp9/encoder/vp9_onyx_int.h +++ b/vp9/encoder/vp9_onyx_int.h @@ -424,20 +424,20 @@ typedef struct VP9_COMP { nmv_context_counts NMVcount; vp9_coeff_count coef_counts_4x4[BLOCK_TYPES]; - vp9_coeff_probs frame_coef_probs_4x4[BLOCK_TYPES]; - vp9_coeff_stats frame_branch_ct_4x4[BLOCK_TYPES]; + vp9_coeff_probs_model frame_coef_probs_4x4[BLOCK_TYPES]; + vp9_coeff_stats_model frame_branch_ct_4x4[BLOCK_TYPES]; vp9_coeff_count coef_counts_8x8[BLOCK_TYPES]; - vp9_coeff_probs frame_coef_probs_8x8[BLOCK_TYPES]; - vp9_coeff_stats frame_branch_ct_8x8[BLOCK_TYPES]; + vp9_coeff_probs_model frame_coef_probs_8x8[BLOCK_TYPES]; + vp9_coeff_stats_model frame_branch_ct_8x8[BLOCK_TYPES]; vp9_coeff_count coef_counts_16x16[BLOCK_TYPES]; - vp9_coeff_probs frame_coef_probs_16x16[BLOCK_TYPES]; - vp9_coeff_stats frame_branch_ct_16x16[BLOCK_TYPES]; + vp9_coeff_probs_model frame_coef_probs_16x16[BLOCK_TYPES]; + vp9_coeff_stats_model frame_branch_ct_16x16[BLOCK_TYPES]; vp9_coeff_count coef_counts_32x32[BLOCK_TYPES]; - vp9_coeff_probs frame_coef_probs_32x32[BLOCK_TYPES]; - vp9_coeff_stats frame_branch_ct_32x32[BLOCK_TYPES]; + vp9_coeff_probs_model frame_coef_probs_32x32[BLOCK_TYPES]; + vp9_coeff_stats_model frame_branch_ct_32x32[BLOCK_TYPES]; int gfu_boost; int last_boost; -- 2.7.4