Introduce vp9_coeff_probs/counts/stats/accum types.

Use these, instead of the 4/5-dimensional arrays, to hold statistics,
counts, accumulations and probabilities for coefficient tokens. This
commit also re-allows ENTROPY_STATS to compile.

Change-Id: If441ffac936f52a3af91d8f2922ea8a0ceabdaa5
This commit is contained in:
Ronald S. Bultje 2012-12-07 16:09:59 -08:00
parent c456b35fdf
commit 885cf816eb
17 changed files with 509 additions and 796 deletions

View File

@ -12,10 +12,7 @@
/*Generated file, included by vp9_entropy.c*/ /*Generated file, included by vp9_entropy.c*/
static const vp9_prob default_coef_probs [BLOCK_TYPES] static const vp9_coeff_probs default_coef_probs_4x4[BLOCK_TYPES_4X4] = {
[COEF_BANDS]
[PREV_COEF_CONTEXTS]
[ENTROPY_NODES] = {
{ {
/* Block Type ( 0 ) */ /* Block Type ( 0 ) */
{ {
@ -254,10 +251,7 @@ static const vp9_prob default_coef_probs [BLOCK_TYPES]
} }
}; };
static const vp9_prob default_hybrid_coef_probs [BLOCK_TYPES] static const vp9_coeff_probs default_hybrid_coef_probs_4x4[BLOCK_TYPES_4X4] = {
[COEF_BANDS]
[PREV_COEF_CONTEXTS]
[ENTROPY_NODES] = {
{ {
/* Block Type ( 0 ) */ /* Block Type ( 0 ) */
{ {
@ -496,11 +490,7 @@ static const vp9_prob default_hybrid_coef_probs [BLOCK_TYPES]
} }
}; };
static const vp9_prob static const vp9_coeff_probs default_coef_probs_8x8[BLOCK_TYPES_8X8] = {
default_coef_probs_8x8[BLOCK_TYPES_8X8]
[COEF_BANDS]
[PREV_COEF_CONTEXTS]
[ENTROPY_NODES] = {
{ {
/* block Type 0 */ /* block Type 0 */
{ {
@ -729,11 +719,7 @@ default_coef_probs_8x8[BLOCK_TYPES_8X8]
} }
}; };
static const vp9_prob static const vp9_coeff_probs default_hybrid_coef_probs_8x8[BLOCK_TYPES_8X8] = {
default_hybrid_coef_probs_8x8[BLOCK_TYPES_8X8]
[COEF_BANDS]
[PREV_COEF_CONTEXTS]
[ENTROPY_NODES] = {
{ {
/* block Type 0 */ /* block Type 0 */
{ {
@ -962,11 +948,7 @@ default_hybrid_coef_probs_8x8[BLOCK_TYPES_8X8]
} }
}; };
static const vp9_prob static const vp9_coeff_probs default_coef_probs_16x16[BLOCK_TYPES_16X16] = {
default_coef_probs_16x16[BLOCK_TYPES_16X16]
[COEF_BANDS]
[PREV_COEF_CONTEXTS]
[ENTROPY_NODES] = {
{ /* block Type 0 */ { /* block Type 0 */
{ /* Coeff Band 0 */ { /* Coeff Band 0 */
{ 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128}, { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128},
@ -1169,11 +1151,8 @@ static const vp9_prob
} }
}; };
static const vp9_prob static const vp9_coeff_probs
default_hybrid_coef_probs_16x16[BLOCK_TYPES_16X16] default_hybrid_coef_probs_16x16[BLOCK_TYPES_16X16] = {
[COEF_BANDS]
[PREV_COEF_CONTEXTS]
[ENTROPY_NODES] = {
{ /* block Type 0 */ { /* block Type 0 */
{ /* Coeff Band 0 */ { /* Coeff Band 0 */
{ 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128}, { 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128},

View File

@ -307,10 +307,10 @@ vp9_extra_bit_struct vp9_extra_bits[12] = {
#include "vp9/common/vp9_default_coef_probs.h" #include "vp9/common/vp9_default_coef_probs.h"
void vp9_default_coef_probs(VP9_COMMON *pc) { void vp9_default_coef_probs(VP9_COMMON *pc) {
vpx_memcpy(pc->fc.coef_probs, default_coef_probs, vpx_memcpy(pc->fc.coef_probs_4x4, default_coef_probs_4x4,
sizeof(pc->fc.coef_probs)); sizeof(pc->fc.coef_probs_4x4));
vpx_memcpy(pc->fc.hybrid_coef_probs, default_hybrid_coef_probs, vpx_memcpy(pc->fc.hybrid_coef_probs_4x4, default_hybrid_coef_probs_4x4,
sizeof(pc->fc.hybrid_coef_probs)); sizeof(pc->fc.hybrid_coef_probs_4x4));
vpx_memcpy(pc->fc.coef_probs_8x8, default_coef_probs_8x8, vpx_memcpy(pc->fc.coef_probs_8x8, default_coef_probs_8x8,
sizeof(pc->fc.coef_probs_8x8)); sizeof(pc->fc.coef_probs_8x8));
@ -343,13 +343,42 @@ void vp9_coef_tree_initialize() {
#define COEF_COUNT_SAT_AFTER_KEY 24 #define COEF_COUNT_SAT_AFTER_KEY 24
#define COEF_MAX_UPDATE_FACTOR_AFTER_KEY 128 #define COEF_MAX_UPDATE_FACTOR_AFTER_KEY 128
void vp9_adapt_coef_probs(VP9_COMMON *cm) { static void update_coef_probs(vp9_coeff_probs *dst_coef_probs,
vp9_coeff_probs *pre_coef_probs,
int block_types, vp9_coeff_count *coef_counts,
int count_sat, int update_factor) {
int t, i, j, k, count; int t, i, j, k, count;
unsigned int branch_ct[ENTROPY_NODES][2]; unsigned int branch_ct[ENTROPY_NODES][2];
vp9_prob coef_probs[ENTROPY_NODES]; vp9_prob coef_probs[ENTROPY_NODES];
int update_factor; /* denominator 256 */
int factor; int factor;
for (i = 0; i < block_types; ++i)
for (j = 0; j < COEF_BANDS; ++j)
for (k = 0; k < PREV_COEF_CONTEXTS; ++k) {
if (k >= 3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
continue;
vp9_tree_probs_from_distribution(MAX_ENTROPY_TOKENS,
vp9_coef_encodings, vp9_coef_tree,
coef_probs, branch_ct,
coef_counts[i][j][k], 256, 1);
for (t = 0; t < ENTROPY_NODES; ++t) {
int prob;
count = branch_ct[t][0] + branch_ct[t][1];
count = count > count_sat ? count_sat : count;
factor = (update_factor * count / count_sat);
prob = ((int)pre_coef_probs[i][j][k][t] * (256 - factor) +
(int)coef_probs[t] * factor + 128) >> 8;
dst_coef_probs[i][j][k][t] = clip_prob(prob);
}
}
}
void vp9_adapt_coef_probs(VP9_COMMON *cm) {
#ifdef COEF_COUNT_TESTING
int t, i, j, k;
#endif
int count_sat; int count_sat;
int update_factor; /* denominator 256 */
// printf("Frame type: %d\n", cm->frame_type); // printf("Frame type: %d\n", cm->frame_type);
if (cm->frame_type == KEY_FRAME) { if (cm->frame_type == KEY_FRAME) {
@ -422,159 +451,30 @@ void vp9_adapt_coef_probs(VP9_COMMON *cm) {
} }
#endif #endif
for (i = 0; i < BLOCK_TYPES; ++i) update_coef_probs(cm->fc.coef_probs_4x4, cm->fc.pre_coef_probs_4x4,
for (j = 0; j < COEF_BANDS; ++j) BLOCK_TYPES_4X4, cm->fc.coef_counts_4x4,
for (k = 0; k < PREV_COEF_CONTEXTS; ++k) { count_sat, update_factor);
if (k >= 3 && ((i == 0 && j == 1) || (i > 0 && j == 0))) update_coef_probs(cm->fc.hybrid_coef_probs_4x4,
continue; cm->fc.pre_hybrid_coef_probs_4x4,
vp9_tree_probs_from_distribution( BLOCK_TYPES_4X4, cm->fc.hybrid_coef_counts_4x4,
MAX_ENTROPY_TOKENS, vp9_coef_encodings, vp9_coef_tree, count_sat, update_factor);
coef_probs, branch_ct, cm->fc.coef_counts [i][j][k], update_coef_probs(cm->fc.coef_probs_8x8, cm->fc.pre_coef_probs_8x8,
256, 1); BLOCK_TYPES_8X8, cm->fc.coef_counts_8x8,
for (t = 0; t < ENTROPY_NODES; ++t) { count_sat, update_factor);
int prob; update_coef_probs(cm->fc.hybrid_coef_probs_8x8,
count = branch_ct[t][0] + branch_ct[t][1]; cm->fc.pre_hybrid_coef_probs_8x8,
count = count > count_sat ? count_sat : count; BLOCK_TYPES_8X8, cm->fc.hybrid_coef_counts_8x8,
factor = (update_factor * count / count_sat); count_sat, update_factor);
prob = ((int)cm->fc.pre_coef_probs[i][j][k][t] * (256 - factor) + update_coef_probs(cm->fc.coef_probs_16x16, cm->fc.pre_coef_probs_16x16,
(int)coef_probs[t] * factor + 128) >> 8; BLOCK_TYPES_16X16, cm->fc.coef_counts_16x16,
if (prob <= 0) cm->fc.coef_probs[i][j][k][t] = 1; count_sat, update_factor);
else if (prob > 255) cm->fc.coef_probs[i][j][k][t] = 255; update_coef_probs(cm->fc.hybrid_coef_probs_16x16,
else cm->fc.coef_probs[i][j][k][t] = prob; cm->fc.pre_hybrid_coef_probs_16x16,
} BLOCK_TYPES_16X16, cm->fc.hybrid_coef_counts_16x16,
} count_sat, update_factor);
for (i = 0; i < BLOCK_TYPES; ++i)
for (j = 0; j < COEF_BANDS; ++j)
for (k = 0; k < PREV_COEF_CONTEXTS; ++k) {
if (k >= 3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
continue;
vp9_tree_probs_from_distribution(
MAX_ENTROPY_TOKENS, vp9_coef_encodings, vp9_coef_tree,
coef_probs, branch_ct, cm->fc.hybrid_coef_counts [i][j][k],
256, 1);
for (t = 0; t < ENTROPY_NODES; ++t) {
int prob;
count = branch_ct[t][0] + branch_ct[t][1];
count = count > count_sat ? count_sat : count;
factor = (update_factor * count / count_sat);
prob = ((int)cm->fc.pre_hybrid_coef_probs[i][j][k][t] * (256 - factor) +
(int)coef_probs[t] * factor + 128) >> 8;
if (prob <= 0) cm->fc.hybrid_coef_probs[i][j][k][t] = 1;
else if (prob > 255) cm->fc.hybrid_coef_probs[i][j][k][t] = 255;
else cm->fc.hybrid_coef_probs[i][j][k][t] = prob;
}
}
for (i = 0; i < BLOCK_TYPES_8X8; ++i)
for (j = 0; j < COEF_BANDS; ++j)
for (k = 0; k < PREV_COEF_CONTEXTS; ++k) {
if (k >= 3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
continue;
vp9_tree_probs_from_distribution(
MAX_ENTROPY_TOKENS, vp9_coef_encodings, vp9_coef_tree,
coef_probs, branch_ct, cm->fc.coef_counts_8x8 [i][j][k],
256, 1);
for (t = 0; t < ENTROPY_NODES; ++t) {
int prob;
count = branch_ct[t][0] + branch_ct[t][1];
count = count > count_sat ? count_sat : count;
factor = (update_factor * count / count_sat);
prob = ((int)cm->fc.pre_coef_probs_8x8[i][j][k][t] * (256 - factor) +
(int)coef_probs[t] * factor + 128) >> 8;
if (prob <= 0) cm->fc.coef_probs_8x8[i][j][k][t] = 1;
else if (prob > 255) cm->fc.coef_probs_8x8[i][j][k][t] = 255;
else cm->fc.coef_probs_8x8[i][j][k][t] = prob;
}
}
for (i = 0; i < BLOCK_TYPES_8X8; ++i)
for (j = 0; j < COEF_BANDS; ++j)
for (k = 0; k < PREV_COEF_CONTEXTS; ++k) {
if (k >= 3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
continue;
vp9_tree_probs_from_distribution(
MAX_ENTROPY_TOKENS, vp9_coef_encodings, vp9_coef_tree,
coef_probs, branch_ct, cm->fc.hybrid_coef_counts_8x8 [i][j][k],
256, 1);
for (t = 0; t < ENTROPY_NODES; ++t) {
int prob;
count = branch_ct[t][0] + branch_ct[t][1];
count = count > count_sat ? count_sat : count;
factor = (update_factor * count / count_sat);
prob = ((int)cm->fc.pre_hybrid_coef_probs_8x8[i][j][k][t] *
(256 - factor) +
(int)coef_probs[t] * factor + 128) >> 8;
if (prob <= 0) cm->fc.hybrid_coef_probs_8x8[i][j][k][t] = 1;
else if (prob > 255) cm->fc.hybrid_coef_probs_8x8[i][j][k][t] = 255;
else cm->fc.hybrid_coef_probs_8x8[i][j][k][t] = prob;
}
}
for (i = 0; i < BLOCK_TYPES_16X16; ++i)
for (j = 0; j < COEF_BANDS; ++j)
for (k = 0; k < PREV_COEF_CONTEXTS; ++k) {
if (k >= 3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
continue;
vp9_tree_probs_from_distribution(
MAX_ENTROPY_TOKENS, vp9_coef_encodings, vp9_coef_tree,
coef_probs, branch_ct, cm->fc.coef_counts_16x16[i][j][k], 256, 1);
for (t = 0; t < ENTROPY_NODES; ++t) {
int prob;
count = branch_ct[t][0] + branch_ct[t][1];
count = count > count_sat ? count_sat : count;
factor = (update_factor * count / count_sat);
prob = ((int)cm->fc.pre_coef_probs_16x16[i][j][k][t] *
(256 - factor) +
(int)coef_probs[t] * factor + 128) >> 8;
if (prob <= 0) cm->fc.coef_probs_16x16[i][j][k][t] = 1;
else if (prob > 255) cm->fc.coef_probs_16x16[i][j][k][t] = 255;
else cm->fc.coef_probs_16x16[i][j][k][t] = prob;
}
}
for (i = 0; i < BLOCK_TYPES_16X16; ++i)
for (j = 0; j < COEF_BANDS; ++j)
for (k = 0; k < PREV_COEF_CONTEXTS; ++k) {
if (k >= 3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
continue;
vp9_tree_probs_from_distribution(
MAX_ENTROPY_TOKENS, vp9_coef_encodings, vp9_coef_tree,
coef_probs, branch_ct, cm->fc.hybrid_coef_counts_16x16[i][j][k], 256, 1);
for (t = 0; t < ENTROPY_NODES; ++t) {
int prob;
count = branch_ct[t][0] + branch_ct[t][1];
count = count > count_sat ? count_sat : count;
factor = (update_factor * count / count_sat);
prob = ((int)cm->fc.pre_hybrid_coef_probs_16x16[i][j][k][t] * (256 - factor) +
(int)coef_probs[t] * factor + 128) >> 8;
if (prob <= 0) cm->fc.hybrid_coef_probs_16x16[i][j][k][t] = 1;
else if (prob > 255) cm->fc.hybrid_coef_probs_16x16[i][j][k][t] = 255;
else cm->fc.hybrid_coef_probs_16x16[i][j][k][t] = prob;
}
}
#if CONFIG_TX32X32 && CONFIG_SUPERBLOCKS #if CONFIG_TX32X32 && CONFIG_SUPERBLOCKS
for (i = 0; i < BLOCK_TYPES_32X32; ++i) update_coef_probs(cm->fc.coef_probs_32x32, cm->fc.pre_coef_probs_32x32,
for (j = 0; j < COEF_BANDS; ++j) BLOCK_TYPES_32X32, cm->fc.coef_counts_32x32,
for (k = 0; k < PREV_COEF_CONTEXTS; ++k) { count_sat, update_factor);
if (k >= 3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
continue;
vp9_tree_probs_from_distribution(
MAX_ENTROPY_TOKENS, vp9_coef_encodings, vp9_coef_tree,
coef_probs, branch_ct, cm->fc.coef_counts_32x32[i][j][k], 256, 1);
for (t = 0; t < ENTROPY_NODES; ++t) {
int prob;
count = branch_ct[t][0] + branch_ct[t][1];
count = count > count_sat ? count_sat : count;
factor = (update_factor * count / count_sat);
prob = ((int)cm->fc.pre_coef_probs_32x32[i][j][k][t] *
(256 - factor) +
(int)coef_probs[t] * factor + 128) >> 8;
if (prob <= 0) cm->fc.coef_probs_32x32[i][j][k][t] = 1;
else if (prob > 255) cm->fc.coef_probs_32x32[i][j][k][t] = 255;
else cm->fc.coef_probs_32x32[i][j][k][t] = prob;
}
}
#endif #endif
} }

View File

@ -60,7 +60,7 @@ extern vp9_extra_bit_struct vp9_extra_bits[12]; /* indexed by token value */
/* Coefficients are predicted via a 3-dimensional probability table. */ /* Coefficients are predicted via a 3-dimensional probability table. */
/* Outside dimension. 0 = Y no DC, 1 = Y2, 2 = UV, 3 = Y with DC */ /* Outside dimension. 0 = Y no DC, 1 = Y2, 2 = UV, 3 = Y with DC */
#define BLOCK_TYPES 4 #define BLOCK_TYPES_4X4 4
#define BLOCK_TYPES_8X8 4 #define BLOCK_TYPES_8X8 4
@ -100,6 +100,13 @@ extern DECLARE_ALIGNED(16, const int, vp9_coef_bands_32x32[1024]);
/*# define DC_TOKEN_CONTEXTS 3*/ /* 00, 0!0, !0!0 */ /*# define DC_TOKEN_CONTEXTS 3*/ /* 00, 0!0, !0!0 */
#define PREV_COEF_CONTEXTS 4 #define PREV_COEF_CONTEXTS 4
typedef unsigned int vp9_coeff_count[COEF_BANDS][PREV_COEF_CONTEXTS]
[MAX_ENTROPY_TOKENS];
typedef unsigned int vp9_coeff_stats[COEF_BANDS][PREV_COEF_CONTEXTS]
[ENTROPY_NODES][2];
typedef vp9_prob vp9_coeff_probs[COEF_BANDS][PREV_COEF_CONTEXTS]
[ENTROPY_NODES];
#define SUBEXP_PARAM 4 /* Subexponential code parameter */ #define SUBEXP_PARAM 4 /* Subexponential code parameter */
#define MODULUS_PARAM 13 /* Modulus parameter */ #define MODULUS_PARAM 13 /* Modulus parameter */

View File

@ -52,14 +52,14 @@ typedef struct frame_contexts {
vp9_prob i8x8_mode_prob[VP9_I8X8_MODES - 1]; vp9_prob i8x8_mode_prob[VP9_I8X8_MODES - 1];
vp9_prob sub_mv_ref_prob[SUBMVREF_COUNT][VP9_SUBMVREFS - 1]; vp9_prob sub_mv_ref_prob[SUBMVREF_COUNT][VP9_SUBMVREFS - 1];
vp9_prob mbsplit_prob[VP9_NUMMBSPLITS - 1]; vp9_prob mbsplit_prob[VP9_NUMMBSPLITS - 1];
vp9_prob coef_probs [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES]; vp9_coeff_probs coef_probs_4x4[BLOCK_TYPES_4X4];
vp9_prob hybrid_coef_probs [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES]; vp9_coeff_probs hybrid_coef_probs_4x4[BLOCK_TYPES_4X4];
vp9_prob coef_probs_8x8 [BLOCK_TYPES_8X8] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES]; vp9_coeff_probs coef_probs_8x8[BLOCK_TYPES_8X8];
vp9_prob hybrid_coef_probs_8x8 [BLOCK_TYPES_8X8] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES]; vp9_coeff_probs hybrid_coef_probs_8x8[BLOCK_TYPES_8X8];
vp9_prob coef_probs_16x16 [BLOCK_TYPES_16X16] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES]; vp9_coeff_probs coef_probs_16x16[BLOCK_TYPES_16X16];
vp9_prob hybrid_coef_probs_16x16 [BLOCK_TYPES_16X16] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES]; vp9_coeff_probs hybrid_coef_probs_16x16[BLOCK_TYPES_16X16];
#if CONFIG_TX32X32 && CONFIG_SUPERBLOCKS #if CONFIG_TX32X32 && CONFIG_SUPERBLOCKS
vp9_prob coef_probs_32x32 [BLOCK_TYPES_32X32] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES]; vp9_coeff_probs coef_probs_32x32[BLOCK_TYPES_32X32];
#endif #endif
nmv_context nmvc; nmv_context nmvc;
@ -83,44 +83,24 @@ typedef struct frame_contexts {
unsigned int sub_mv_ref_counts[SUBMVREF_COUNT][VP9_SUBMVREFS]; unsigned int sub_mv_ref_counts[SUBMVREF_COUNT][VP9_SUBMVREFS];
unsigned int mbsplit_counts[VP9_NUMMBSPLITS]; unsigned int mbsplit_counts[VP9_NUMMBSPLITS];
vp9_prob pre_coef_probs [BLOCK_TYPES] [COEF_BANDS] vp9_coeff_probs pre_coef_probs_4x4[BLOCK_TYPES_4X4];
[PREV_COEF_CONTEXTS] [ENTROPY_NODES]; vp9_coeff_probs pre_hybrid_coef_probs_4x4[BLOCK_TYPES_4X4];
vp9_prob pre_hybrid_coef_probs [BLOCK_TYPES] [COEF_BANDS] vp9_coeff_probs pre_coef_probs_8x8[BLOCK_TYPES_8X8];
[PREV_COEF_CONTEXTS] [ENTROPY_NODES]; vp9_coeff_probs pre_hybrid_coef_probs_8x8[BLOCK_TYPES_8X8];
vp9_coeff_probs pre_coef_probs_16x16[BLOCK_TYPES_16X16];
vp9_prob pre_coef_probs_8x8 [BLOCK_TYPES_8X8] [COEF_BANDS] vp9_coeff_probs pre_hybrid_coef_probs_16x16[BLOCK_TYPES_16X16];
[PREV_COEF_CONTEXTS] [ENTROPY_NODES];
vp9_prob pre_hybrid_coef_probs_8x8 [BLOCK_TYPES_8X8] [COEF_BANDS]
[PREV_COEF_CONTEXTS] [ENTROPY_NODES];
vp9_prob pre_coef_probs_16x16 [BLOCK_TYPES_16X16] [COEF_BANDS]
[PREV_COEF_CONTEXTS] [ENTROPY_NODES];
vp9_prob pre_hybrid_coef_probs_16x16 [BLOCK_TYPES_16X16] [COEF_BANDS]
[PREV_COEF_CONTEXTS] [ENTROPY_NODES];
#if CONFIG_TX32X32 && CONFIG_SUPERBLOCKS #if CONFIG_TX32X32 && CONFIG_SUPERBLOCKS
vp9_prob pre_coef_probs_32x32 [BLOCK_TYPES_32X32] [COEF_BANDS] vp9_coeff_probs pre_coef_probs_32x32[BLOCK_TYPES_32X32];
[PREV_COEF_CONTEXTS] [ENTROPY_NODES];
#endif #endif
unsigned int coef_counts [BLOCK_TYPES] [COEF_BANDS] vp9_coeff_count coef_counts_4x4[BLOCK_TYPES_4X4];
[PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS]; vp9_coeff_count hybrid_coef_counts_4x4[BLOCK_TYPES_4X4];
unsigned int hybrid_coef_counts [BLOCK_TYPES] [COEF_BANDS] vp9_coeff_count coef_counts_8x8[BLOCK_TYPES_8X8];
[PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS]; vp9_coeff_count hybrid_coef_counts_8x8[BLOCK_TYPES_8X8];
vp9_coeff_count coef_counts_16x16[BLOCK_TYPES_16X16];
unsigned int coef_counts_8x8 [BLOCK_TYPES_8X8] [COEF_BANDS] vp9_coeff_count hybrid_coef_counts_16x16[BLOCK_TYPES_16X16];
[PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS];
unsigned int hybrid_coef_counts_8x8 [BLOCK_TYPES_8X8] [COEF_BANDS]
[PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS];
unsigned int coef_counts_16x16 [BLOCK_TYPES_16X16] [COEF_BANDS]
[PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS];
unsigned int hybrid_coef_counts_16x16 [BLOCK_TYPES_16X16] [COEF_BANDS]
[PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS];
#if CONFIG_TX32X32 && CONFIG_SUPERBLOCKS #if CONFIG_TX32X32 && CONFIG_SUPERBLOCKS
unsigned int coef_counts_32x32 [BLOCK_TYPES_32X32] [COEF_BANDS] vp9_coeff_count coef_counts_32x32[BLOCK_TYPES_32X32];
[PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS];
#endif #endif
nmv_context_counts NMVcount; nmv_context_counts NMVcount;

View File

@ -1231,14 +1231,13 @@ static void init_frame(VP9D_COMP *pbi) {
} }
static void read_coef_probs_common( static void read_coef_probs_common(BOOL_DECODER* const bc,
BOOL_DECODER* const bc, vp9_coeff_probs *coef_probs,
vp9_prob coef_probs[BLOCK_TYPES][COEF_BANDS] int block_types) {
[PREV_COEF_CONTEXTS][ENTROPY_NODES]) {
int i, j, k, l; int i, j, k, l;
if (vp9_read_bit(bc)) { if (vp9_read_bit(bc)) {
for (i = 0; i < BLOCK_TYPES; i++) { for (i = 0; i < block_types; i++) {
for (j = !i; j < COEF_BANDS; j++) { for (j = !i; j < COEF_BANDS; j++) {
/* NB: This j loop starts from 1 on block type i == 0 */ /* NB: This j loop starts from 1 on block type i == 0 */
for (k = 0; k < PREV_COEF_CONTEXTS; k++) { for (k = 0; k < PREV_COEF_CONTEXTS; k++) {
@ -1261,20 +1260,21 @@ static void read_coef_probs_common(
static void read_coef_probs(VP9D_COMP *pbi, BOOL_DECODER* const bc) { static void read_coef_probs(VP9D_COMP *pbi, BOOL_DECODER* const bc) {
VP9_COMMON *const pc = &pbi->common; VP9_COMMON *const pc = &pbi->common;
read_coef_probs_common(bc, pc->fc.coef_probs); read_coef_probs_common(bc, pc->fc.coef_probs_4x4, BLOCK_TYPES_4X4);
read_coef_probs_common(bc, pc->fc.hybrid_coef_probs); read_coef_probs_common(bc, pc->fc.hybrid_coef_probs_4x4, BLOCK_TYPES_4X4);
if (pbi->common.txfm_mode != ONLY_4X4) { if (pbi->common.txfm_mode != ONLY_4X4) {
read_coef_probs_common(bc, pc->fc.coef_probs_8x8); read_coef_probs_common(bc, pc->fc.coef_probs_8x8, BLOCK_TYPES_8X8);
read_coef_probs_common(bc, pc->fc.hybrid_coef_probs_8x8); read_coef_probs_common(bc, pc->fc.hybrid_coef_probs_8x8, BLOCK_TYPES_8X8);
} }
if (pbi->common.txfm_mode > ALLOW_8X8) { if (pbi->common.txfm_mode > ALLOW_8X8) {
read_coef_probs_common(bc, pc->fc.coef_probs_16x16); read_coef_probs_common(bc, pc->fc.coef_probs_16x16, BLOCK_TYPES_16X16);
read_coef_probs_common(bc, pc->fc.hybrid_coef_probs_16x16); read_coef_probs_common(bc, pc->fc.hybrid_coef_probs_16x16,
BLOCK_TYPES_16X16);
} }
#if CONFIG_TX32X32 && CONFIG_SUPERBLOCKS #if CONFIG_TX32X32 && CONFIG_SUPERBLOCKS
if (pbi->common.txfm_mode > ALLOW_16X16) { if (pbi->common.txfm_mode > ALLOW_16X16) {
read_coef_probs_common(bc, pc->fc.coef_probs_32x32); read_coef_probs_common(bc, pc->fc.coef_probs_32x32, BLOCK_TYPES_32X32);
} }
#endif #endif
} }
@ -1619,10 +1619,10 @@ int vp9_decode_frame(VP9D_COMP *pbi, const unsigned char **p_data_end) {
fclose(z); fclose(z);
} }
vp9_copy(pbi->common.fc.pre_coef_probs, vp9_copy(pbi->common.fc.pre_coef_probs_4x4,
pbi->common.fc.coef_probs); pbi->common.fc.coef_probs_4x4);
vp9_copy(pbi->common.fc.pre_hybrid_coef_probs, vp9_copy(pbi->common.fc.pre_hybrid_coef_probs_4x4,
pbi->common.fc.hybrid_coef_probs); pbi->common.fc.hybrid_coef_probs_4x4);
vp9_copy(pbi->common.fc.pre_coef_probs_8x8, vp9_copy(pbi->common.fc.pre_coef_probs_8x8,
pbi->common.fc.coef_probs_8x8); pbi->common.fc.coef_probs_8x8);
vp9_copy(pbi->common.fc.pre_hybrid_coef_probs_8x8, vp9_copy(pbi->common.fc.pre_hybrid_coef_probs_8x8,
@ -1648,8 +1648,8 @@ int vp9_decode_frame(VP9D_COMP *pbi, const unsigned char **p_data_end) {
pbi->common.fc.pre_interintra_prob = pbi->common.fc.interintra_prob; pbi->common.fc.pre_interintra_prob = pbi->common.fc.interintra_prob;
#endif #endif
pbi->common.fc.pre_nmvc = pbi->common.fc.nmvc; pbi->common.fc.pre_nmvc = pbi->common.fc.nmvc;
vp9_zero(pbi->common.fc.coef_counts); vp9_zero(pbi->common.fc.coef_counts_4x4);
vp9_zero(pbi->common.fc.hybrid_coef_counts); vp9_zero(pbi->common.fc.hybrid_coef_counts_4x4);
vp9_zero(pbi->common.fc.coef_counts_8x8); vp9_zero(pbi->common.fc.coef_counts_8x8);
vp9_zero(pbi->common.fc.hybrid_coef_counts_8x8); vp9_zero(pbi->common.fc.hybrid_coef_counts_8x8);
vp9_zero(pbi->common.fc.coef_counts_16x16); vp9_zero(pbi->common.fc.coef_counts_16x16);

View File

@ -102,7 +102,7 @@ static int get_signed(BOOL_DECODER *br, int value_to_sign) {
#define INCREMENT_COUNT(token) \ #define INCREMENT_COUNT(token) \
do { \ do { \
coef_counts[coef_bands[c]][pt][token]++; \ coef_counts[type][coef_bands[c]][pt][token]++; \
pt = vp9_prev_token_class[token]; \ pt = vp9_prev_token_class[token]; \
} while (0) } while (0)
@ -130,42 +130,43 @@ static int decode_coefs(VP9D_COMP *dx, const MACROBLOCKD *xd,
const int *coef_bands) { const int *coef_bands) {
FRAME_CONTEXT *const fc = &dx->common.fc; FRAME_CONTEXT *const fc = &dx->common.fc;
int pt, c = (type == PLANE_TYPE_Y_NO_DC); int pt, c = (type == PLANE_TYPE_Y_NO_DC);
vp9_prob (*coef_probs)[PREV_COEF_CONTEXTS][ENTROPY_NODES], *prob; vp9_coeff_probs *coef_probs;
unsigned int (*coef_counts)[PREV_COEF_CONTEXTS][MAX_ENTROPY_TOKENS]; vp9_prob *prob;
vp9_coeff_count *coef_counts;
switch (txfm_size) { switch (txfm_size) {
default: default:
case TX_4X4: case TX_4X4:
if (tx_type == DCT_DCT) { if (tx_type == DCT_DCT) {
coef_probs = fc->coef_probs[type]; coef_probs = fc->coef_probs_4x4;
coef_counts = fc->coef_counts[type]; coef_counts = fc->coef_counts_4x4;
} else { } else {
coef_probs = fc->hybrid_coef_probs[type]; coef_probs = fc->hybrid_coef_probs_4x4;
coef_counts = fc->hybrid_coef_counts[type]; coef_counts = fc->hybrid_coef_counts_4x4;
} }
break; break;
case TX_8X8: case TX_8X8:
if (tx_type == DCT_DCT) { if (tx_type == DCT_DCT) {
coef_probs = fc->coef_probs_8x8[type]; coef_probs = fc->coef_probs_8x8;
coef_counts = fc->coef_counts_8x8[type]; coef_counts = fc->coef_counts_8x8;
} else { } else {
coef_probs = fc->hybrid_coef_probs_8x8[type]; coef_probs = fc->hybrid_coef_probs_8x8;
coef_counts = fc->hybrid_coef_counts_8x8[type]; coef_counts = fc->hybrid_coef_counts_8x8;
} }
break; break;
case TX_16X16: case TX_16X16:
if (tx_type == DCT_DCT) { if (tx_type == DCT_DCT) {
coef_probs = fc->coef_probs_16x16[type]; coef_probs = fc->coef_probs_16x16;
coef_counts = fc->coef_counts_16x16[type]; coef_counts = fc->coef_counts_16x16;
} else { } else {
coef_probs = fc->hybrid_coef_probs_16x16[type]; coef_probs = fc->hybrid_coef_probs_16x16;
coef_counts = fc->hybrid_coef_counts_16x16[type]; coef_counts = fc->hybrid_coef_counts_16x16;
} }
break; break;
#if CONFIG_TX32X32 && CONFIG_SUPERBLOCKS #if CONFIG_TX32X32 && CONFIG_SUPERBLOCKS
case TX_32X32: case TX_32X32:
coef_probs = fc->coef_probs_32x32[type]; coef_probs = fc->coef_probs_32x32;
coef_counts = fc->coef_counts_32x32[type]; coef_counts = fc->coef_counts_32x32;
break; break;
#endif #endif
} }
@ -175,7 +176,7 @@ static int decode_coefs(VP9D_COMP *dx, const MACROBLOCKD *xd,
int val; int val;
const uint8_t *cat6 = cat6_prob; const uint8_t *cat6 = cat6_prob;
if (c >= seg_eob) break; if (c >= seg_eob) break;
prob = coef_probs[coef_bands[c]][pt]; prob = coef_probs[type][coef_bands[c]][pt];
if (!vp9_read(br, prob[EOB_CONTEXT_NODE])) if (!vp9_read(br, prob[EOB_CONTEXT_NODE]))
break; break;
SKIP_START: SKIP_START:
@ -183,7 +184,7 @@ SKIP_START:
if (!vp9_read(br, prob[ZERO_CONTEXT_NODE])) { if (!vp9_read(br, prob[ZERO_CONTEXT_NODE])) {
INCREMENT_COUNT(ZERO_TOKEN); INCREMENT_COUNT(ZERO_TOKEN);
++c; ++c;
prob = coef_probs[coef_bands[c]][pt]; prob = coef_probs[type][coef_bands[c]][pt];
goto SKIP_START; goto SKIP_START;
} }
// ONE_CONTEXT_NODE_0_ // ONE_CONTEXT_NODE_0_
@ -247,7 +248,7 @@ SKIP_START:
} }
if (c < seg_eob) if (c < seg_eob)
coef_counts[coef_bands[c]][pt][DCT_EOB_TOKEN]++; coef_counts[type][coef_bands[c]][pt][DCT_EOB_TOKEN]++;
a[0] = l[0] = (c > !type); a[0] = l[0] = (c > !type);

View File

@ -46,7 +46,7 @@ typedef struct {
INT16 *qcoeff_start_ptr; INT16 *qcoeff_start_ptr;
vp9_prob const *coef_probs[BLOCK_TYPES]; vp9_prob const *coef_probs_4x4[BLOCK_TYPES_4X4];
vp9_prob const *coef_probs_8x8[BLOCK_TYPES_8X8]; vp9_prob const *coef_probs_8x8[BLOCK_TYPES_8X8];
vp9_prob const *coef_probs_16X16[BLOCK_TYPES_16X16]; vp9_prob const *coef_probs_16X16[BLOCK_TYPES_16X16];

View File

@ -39,30 +39,13 @@ unsigned __int64 Sectionbits[500];
int intra_mode_stats[VP9_KF_BINTRAMODES] int intra_mode_stats[VP9_KF_BINTRAMODES]
[VP9_KF_BINTRAMODES] [VP9_KF_BINTRAMODES]
[VP9_KF_BINTRAMODES]; [VP9_KF_BINTRAMODES];
unsigned int tree_update_hist [BLOCK_TYPES] vp9_coeff_stats tree_update_hist_4x4[BLOCK_TYPES_4X4];
[COEF_BANDS] vp9_coeff_stats hybrid_tree_update_hist_4x4[BLOCK_TYPES_4X4];
[PREV_COEF_CONTEXTS] vp9_coeff_stats tree_update_hist_8x8[BLOCK_TYPES_8X8];
[ENTROPY_NODES][2]; vp9_coeff_stats hybrid_tree_update_hist_8x8[BLOCK_TYPES_8X8];
unsigned int hybrid_tree_update_hist [BLOCK_TYPES] vp9_coeff_stats tree_update_hist_16x16[BLOCK_TYPES_16X16];
[COEF_BANDS] vp9_coeff_stats hybrid_tree_update_hist_16x16[BLOCK_TYPES_16X16];
[PREV_COEF_CONTEXTS] vp9_coeff_stats tree_update_hist_32x32[BLOCK_TYPES_32X32];
[ENTROPY_NODES][2];
unsigned int tree_update_hist_8x8 [BLOCK_TYPES_8X8]
[COEF_BANDS]
[PREV_COEF_CONTEXTS]
[ENTROPY_NODES] [2];
unsigned int hybrid_tree_update_hist_8x8 [BLOCK_TYPES_8X8]
[COEF_BANDS]
[PREV_COEF_CONTEXTS]
[ENTROPY_NODES] [2];
unsigned int tree_update_hist_16x16 [BLOCK_TYPES_16X16]
[COEF_BANDS]
[PREV_COEF_CONTEXTS]
[ENTROPY_NODES] [2];
unsigned int hybrid_tree_update_hist_16x16 [BLOCK_TYPES_16X16]
[COEF_BANDS]
[PREV_COEF_CONTEXTS]
[ENTROPY_NODES] [2];
extern unsigned int active_section; extern unsigned int active_section;
#endif #endif
@ -982,9 +965,9 @@ static void pack_inter_mode_mvs(VP9_COMP *const cpi, vp9_writer *const bc) {
vp9_mv_ref_probs(&cpi->common, mv_ref_p, mi->mb_mode_context[rf]); vp9_mv_ref_probs(&cpi->common, mv_ref_p, mi->mb_mode_context[rf]);
#ifdef ENTROPY_STATS // #ifdef ENTROPY_STATS
accum_mv_refs(mode, ct); // accum_mv_refs(mode, ct);
#endif // #endif
} }
#ifdef ENTROPY_STATS #ifdef ENTROPY_STATS
@ -1419,13 +1402,12 @@ static void write_kfmodes(VP9_COMP* const cpi, vp9_writer* const bc) {
/* This function is used for debugging probability trees. */ /* This function is used for debugging probability trees. */
static void print_prob_tree(vp9_prob static void print_prob_tree(vp9_coeff_probs *coef_probs) {
coef_probs[BLOCK_TYPES][COEF_BANDS][PREV_COEF_CONTEXTS][ENTROPY_NODES]) {
/* print coef probability tree */ /* print coef probability tree */
int i, j, k, l; int i, j, k, l;
FILE *f = fopen("enc_tree_probs.txt", "a"); FILE *f = fopen("enc_tree_probs.txt", "a");
fprintf(f, "{\n"); fprintf(f, "{\n");
for (i = 0; i < BLOCK_TYPES; i++) { for (i = 0; i < BLOCK_TYPES_4X4; i++) {
fprintf(f, " {\n"); fprintf(f, " {\n");
for (j = 0; j < COEF_BANDS; j++) { for (j = 0; j < COEF_BANDS; j++) {
fprintf(f, " {\n"); fprintf(f, " {\n");
@ -1445,176 +1427,95 @@ static void print_prob_tree(vp9_prob
fclose(f); fclose(f);
} }
static void build_coeff_contexts(VP9_COMP *cpi) { static void build_tree_distribution(vp9_coeff_probs *coef_probs,
vp9_coeff_count *coef_counts,
#ifdef ENTROPY_STATS
VP9_COMP *cpi,
vp9_coeff_accum *context_counters,
#endif
vp9_coeff_stats *coef_branch_ct,
int block_types) {
int i = 0, j, k; int i = 0, j, k;
#ifdef ENTROPY_STATS #ifdef ENTROPY_STATS
int t = 0; int t = 0;
#endif #endif
for (i = 0; i < BLOCK_TYPES; ++i) {
for (j = 0; j < COEF_BANDS; ++j) {
for (k = 0; k < PREV_COEF_CONTEXTS; ++k) {
if (k >= 3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
continue;
vp9_tree_probs_from_distribution(
MAX_ENTROPY_TOKENS, vp9_coef_encodings, vp9_coef_tree,
cpi->frame_coef_probs [i][j][k],
cpi->frame_branch_ct [i][j][k],
cpi->coef_counts [i][j][k],
256, 1
);
#ifdef ENTROPY_STATS
if (!cpi->dummy_packing)
for (t = 0; t < MAX_ENTROPY_TOKENS; ++t)
context_counters[i][j][k][t] += cpi->coef_counts[i][j][k][t];
#endif
}
}
}
for (i = 0; i < BLOCK_TYPES; ++i) {
for (j = 0; j < COEF_BANDS; ++j) {
for (k = 0; k < PREV_COEF_CONTEXTS; ++k) {
if (k >= 3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
continue;
vp9_tree_probs_from_distribution(
MAX_ENTROPY_TOKENS, vp9_coef_encodings, vp9_coef_tree,
cpi->frame_hybrid_coef_probs [i][j][k],
cpi->frame_hybrid_branch_ct [i][j][k],
cpi->hybrid_coef_counts [i][j][k],
256, 1
);
#ifdef ENTROPY_STATS
if (!cpi->dummy_packing)
for (t = 0; t < MAX_ENTROPY_TOKENS; ++t)
hybrid_context_counters[i][j][k][t] += cpi->hybrid_coef_counts[i][j][k][t];
#endif
}
}
}
if (cpi->common.txfm_mode != ONLY_4X4) { for (i = 0; i < block_types; ++i) {
for (i = 0; i < BLOCK_TYPES_8X8; ++i) {
for (j = 0; j < COEF_BANDS; ++j) { for (j = 0; j < COEF_BANDS; ++j) {
for (k = 0; k < PREV_COEF_CONTEXTS; ++k) { for (k = 0; k < PREV_COEF_CONTEXTS; ++k) {
/* at every context */
/* calc probs and branch cts for this frame only */
// vp9_prob new_p [ENTROPY_NODES];
// unsigned int branch_ct [ENTROPY_NODES] [2];
if (k >= 3 && ((i == 0 && j == 1) || (i > 0 && j == 0))) if (k >= 3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
continue; continue;
vp9_tree_probs_from_distribution( vp9_tree_probs_from_distribution(MAX_ENTROPY_TOKENS,
MAX_ENTROPY_TOKENS, vp9_coef_encodings, vp9_coef_tree, vp9_coef_encodings, vp9_coef_tree,
cpi->frame_coef_probs_8x8 [i][j][k], coef_probs[i][j][k],
cpi->frame_branch_ct_8x8 [i][j][k], coef_branch_ct[i][j][k],
cpi->coef_counts_8x8 [i][j][k], coef_counts[i][j][k], 256, 1);
256, 1
);
#ifdef ENTROPY_STATS #ifdef ENTROPY_STATS
if (!cpi->dummy_packing) if (!cpi->dummy_packing)
for (t = 0; t < MAX_ENTROPY_TOKENS; ++t) for (t = 0; t < MAX_ENTROPY_TOKENS; ++t)
context_counters_8x8[i][j][k][t] += cpi->coef_counts_8x8[i][j][k][t]; context_counters[i][j][k][t] += coef_counts[i][j][k][t];
#endif #endif
} }
} }
} }
for (i = 0; i < BLOCK_TYPES_8X8; ++i) { }
for (j = 0; j < COEF_BANDS; ++j) {
for (k = 0; k < PREV_COEF_CONTEXTS; ++k) {
/* at every context */
/* calc probs and branch cts for this frame only */
// vp9_prob new_p [ENTROPY_NODES];
// unsigned int branch_ct [ENTROPY_NODES] [2];
if (k >= 3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
continue;
vp9_tree_probs_from_distribution(
MAX_ENTROPY_TOKENS, vp9_coef_encodings, vp9_coef_tree,
cpi->frame_hybrid_coef_probs_8x8 [i][j][k],
cpi->frame_hybrid_branch_ct_8x8 [i][j][k],
cpi->hybrid_coef_counts_8x8 [i][j][k],
256, 1
);
#ifdef ENTROPY_STATS
if (!cpi->dummy_packing)
for (t = 0; t < MAX_ENTROPY_TOKENS; ++t)
hybrid_context_counters_8x8[i][j][k][t] += cpi->hybrid_coef_counts_8x8[i][j][k][t];
#endif
}
}
}
}
if (cpi->common.txfm_mode > ALLOW_8X8) { static void build_coeff_contexts(VP9_COMP *cpi) {
for (i = 0; i < BLOCK_TYPES_16X16; ++i) { build_tree_distribution(cpi->frame_coef_probs_4x4,
for (j = 0; j < COEF_BANDS; ++j) { cpi->coef_counts_4x4,
for (k = 0; k < PREV_COEF_CONTEXTS; ++k) {
if (k >= 3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
continue;
vp9_tree_probs_from_distribution(
MAX_ENTROPY_TOKENS, vp9_coef_encodings, vp9_coef_tree,
cpi->frame_coef_probs_16x16[i][j][k],
cpi->frame_branch_ct_16x16[i][j][k],
cpi->coef_counts_16x16[i][j][k], 256, 1);
#ifdef ENTROPY_STATS #ifdef ENTROPY_STATS
if (!cpi->dummy_packing) cpi, context_counters_4x4,
for (t = 0; t < MAX_ENTROPY_TOKENS; ++t)
context_counters_16x16[i][j][k][t] += cpi->coef_counts_16x16[i][j][k][t];
#endif #endif
} cpi->frame_branch_ct_4x4, BLOCK_TYPES_4X4);
} build_tree_distribution(cpi->frame_hybrid_coef_probs_4x4,
} cpi->hybrid_coef_counts_4x4,
for (i = 0; i < BLOCK_TYPES_16X16; ++i) {
for (j = 0; j < COEF_BANDS; ++j) {
for (k = 0; k < PREV_COEF_CONTEXTS; ++k) {
if (k >= 3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
continue;
vp9_tree_probs_from_distribution(
MAX_ENTROPY_TOKENS, vp9_coef_encodings, vp9_coef_tree,
cpi->frame_hybrid_coef_probs_16x16[i][j][k],
cpi->frame_hybrid_branch_ct_16x16[i][j][k],
cpi->hybrid_coef_counts_16x16[i][j][k], 256, 1);
#ifdef ENTROPY_STATS #ifdef ENTROPY_STATS
if (!cpi->dummy_packing) cpi, hybrid_context_counters_4x4,
for (t = 0; t < MAX_ENTROPY_TOKENS; ++t)
hybrid_context_counters_16x16[i][j][k][t] +=
cpi->hybrid_coef_counts_16x16[i][j][k][t];
#endif #endif
} cpi->frame_hybrid_branch_ct_4x4, BLOCK_TYPES_4X4);
} build_tree_distribution(cpi->frame_coef_probs_8x8,
} cpi->coef_counts_8x8,
} #ifdef ENTROPY_STATS
cpi, context_counters_8x8,
#endif
cpi->frame_branch_ct_8x8, BLOCK_TYPES_8X8);
build_tree_distribution(cpi->frame_hybrid_coef_probs_8x8,
cpi->hybrid_coef_counts_8x8,
#ifdef ENTROPY_STATS
cpi, hybrid_context_counters_8x8,
#endif
cpi->frame_hybrid_branch_ct_8x8, BLOCK_TYPES_8X8);
build_tree_distribution(cpi->frame_coef_probs_16x16,
cpi->coef_counts_16x16,
#ifdef ENTROPY_STATS
cpi, context_counters_16x16,
#endif
cpi->frame_branch_ct_16x16, BLOCK_TYPES_16X16);
build_tree_distribution(cpi->frame_hybrid_coef_probs_16x16,
cpi->hybrid_coef_counts_16x16,
#ifdef ENTROPY_STATS
cpi, hybrid_context_counters_16x16,
#endif
cpi->frame_hybrid_branch_ct_16x16, BLOCK_TYPES_16X16);
#if CONFIG_TX32X32 && CONFIG_SUPERBLOCKS #if CONFIG_TX32X32 && CONFIG_SUPERBLOCKS
if (cpi->common.txfm_mode > ALLOW_16X16) { build_tree_distribution(cpi->frame_coef_probs_32x32,
for (i = 0; i < BLOCK_TYPES_32X32; ++i) { cpi->coef_counts_32x32,
for (j = 0; j < COEF_BANDS; ++j) {
for (k = 0; k < PREV_COEF_CONTEXTS; ++k) {
if (k >= 3 && ((i == 0 && j == 1) || (i > 0 && j == 0)))
continue;
vp9_tree_probs_from_distribution(
MAX_ENTROPY_TOKENS, vp9_coef_encodings, vp9_coef_tree,
cpi->frame_coef_probs_32x32[i][j][k],
cpi->frame_branch_ct_32x32[i][j][k],
cpi->coef_counts_32x32[i][j][k], 256, 1);
#ifdef ENTROPY_STATS #ifdef ENTROPY_STATS
if (!cpi->dummy_packing) cpi, context_counters_32x32,
for (t = 0; t < MAX_ENTROPY_TOKENS; ++t)
context_counters_32x32[i][j][k][t] +=
cpi->coef_counts_32x32[i][j][k][t];
#endif #endif
} cpi->frame_branch_ct_32x32, BLOCK_TYPES_32X32);
}
}
}
#endif #endif
} }
static void update_coef_probs_common( static void update_coef_probs_common(vp9_writer* const bc,
vp9_writer* const bc, #ifdef ENTROPY_STATS
vp9_prob new_frame_coef_probs[BLOCK_TYPES][COEF_BANDS] VP9_COMP *cpi,
[PREV_COEF_CONTEXTS][ENTROPY_NODES], vp9_coeff_stats *tree_update_hist,
vp9_prob old_frame_coef_probs[BLOCK_TYPES][COEF_BANDS] #endif
[PREV_COEF_CONTEXTS][ENTROPY_NODES], vp9_coeff_probs *new_frame_coef_probs,
unsigned int frame_branch_ct[BLOCK_TYPES][COEF_BANDS] vp9_coeff_probs *old_frame_coef_probs,
[PREV_COEF_CONTEXTS][ENTROPY_NODES][2]) { vp9_coeff_stats *frame_branch_ct,
int block_types) {
int i, j, k, t; int i, j, k, t;
int update[2] = {0, 0}; int update[2] = {0, 0};
int savings; int savings;
@ -1622,7 +1523,7 @@ static void update_coef_probs_common(
/* dry run to see if there is any udpate at all needed */ /* dry run to see if there is any udpate at all needed */
savings = 0; savings = 0;
for (i = 0; i < BLOCK_TYPES; ++i) { for (i = 0; i < block_types; ++i) {
for (j = !i; j < COEF_BANDS; ++j) { for (j = !i; j < COEF_BANDS; ++j) {
int prev_coef_savings[ENTROPY_NODES] = {0}; int prev_coef_savings[ENTROPY_NODES] = {0};
for (k = 0; k < PREV_COEF_CONTEXTS; ++k) { for (k = 0; k < PREV_COEF_CONTEXTS; ++k) {
@ -1666,7 +1567,7 @@ static void update_coef_probs_common(
vp9_write_bit(bc, 0); vp9_write_bit(bc, 0);
} else { } else {
vp9_write_bit(bc, 1); vp9_write_bit(bc, 1);
for (i = 0; i < BLOCK_TYPES; ++i) { for (i = 0; i < block_types; ++i) {
for (j = !i; j < COEF_BANDS; ++j) { for (j = !i; j < COEF_BANDS; ++j) {
int prev_coef_savings[ENTROPY_NODES] = {0}; int prev_coef_savings[ENTROPY_NODES] = {0};
for (k = 0; k < PREV_COEF_CONTEXTS; ++k) { for (k = 0; k < PREV_COEF_CONTEXTS; ++k) {
@ -1696,7 +1597,7 @@ static void update_coef_probs_common(
vp9_write(bc, u, upd); vp9_write(bc, u, upd);
#ifdef ENTROPY_STATS #ifdef ENTROPY_STATS
if (!cpi->dummy_packing) if (!cpi->dummy_packing)
++ tree_update_hist [i][j][k][t] [u]; ++tree_update_hist[i][j][k][t][u];
#endif #endif
if (u) { if (u) {
/* send/use new probability */ /* send/use new probability */
@ -1717,45 +1618,80 @@ static void update_coef_probs(VP9_COMP* const cpi, vp9_writer* const bc) {
build_coeff_contexts(cpi); build_coeff_contexts(cpi);
update_coef_probs_common(bc, update_coef_probs_common(bc,
cpi->frame_coef_probs, #ifdef ENTROPY_STATS
cpi->common.fc.coef_probs, cpi,
cpi->frame_branch_ct); tree_update_hist_4x4,
#endif
cpi->frame_coef_probs_4x4,
cpi->common.fc.coef_probs_4x4,
cpi->frame_branch_ct_4x4,
BLOCK_TYPES_4X4);
update_coef_probs_common(bc, update_coef_probs_common(bc,
cpi->frame_hybrid_coef_probs, #ifdef ENTROPY_STATS
cpi->common.fc.hybrid_coef_probs, cpi,
cpi->frame_hybrid_branch_ct); hybrid_tree_update_hist_4x4,
#endif
cpi->frame_hybrid_coef_probs_4x4,
cpi->common.fc.hybrid_coef_probs_4x4,
cpi->frame_hybrid_branch_ct_4x4,
BLOCK_TYPES_4X4);
/* do not do this if not even allowed */ /* do not do this if not even allowed */
if (cpi->common.txfm_mode != ONLY_4X4) { if (cpi->common.txfm_mode != ONLY_4X4) {
update_coef_probs_common(bc, update_coef_probs_common(bc,
#ifdef ENTROPY_STATS
cpi,
tree_update_hist_8x8,
#endif
cpi->frame_coef_probs_8x8, cpi->frame_coef_probs_8x8,
cpi->common.fc.coef_probs_8x8, cpi->common.fc.coef_probs_8x8,
cpi->frame_branch_ct_8x8); cpi->frame_branch_ct_8x8,
BLOCK_TYPES_8X8);
update_coef_probs_common(bc, update_coef_probs_common(bc,
#ifdef ENTROPY_STATS
cpi,
hybrid_tree_update_hist_8x8,
#endif
cpi->frame_hybrid_coef_probs_8x8, cpi->frame_hybrid_coef_probs_8x8,
cpi->common.fc.hybrid_coef_probs_8x8, cpi->common.fc.hybrid_coef_probs_8x8,
cpi->frame_hybrid_branch_ct_8x8); cpi->frame_hybrid_branch_ct_8x8,
BLOCK_TYPES_8X8);
} }
if (cpi->common.txfm_mode > ALLOW_8X8) { if (cpi->common.txfm_mode > ALLOW_8X8) {
update_coef_probs_common(bc, update_coef_probs_common(bc,
#ifdef ENTROPY_STATS
cpi,
tree_update_hist_16x16,
#endif
cpi->frame_coef_probs_16x16, cpi->frame_coef_probs_16x16,
cpi->common.fc.coef_probs_16x16, cpi->common.fc.coef_probs_16x16,
cpi->frame_branch_ct_16x16); cpi->frame_branch_ct_16x16,
BLOCK_TYPES_16X16);
update_coef_probs_common(bc, update_coef_probs_common(bc,
#ifdef ENTROPY_STATS
cpi,
hybrid_tree_update_hist_16x16,
#endif
cpi->frame_hybrid_coef_probs_16x16, cpi->frame_hybrid_coef_probs_16x16,
cpi->common.fc.hybrid_coef_probs_16x16, cpi->common.fc.hybrid_coef_probs_16x16,
cpi->frame_hybrid_branch_ct_16x16); cpi->frame_hybrid_branch_ct_16x16,
BLOCK_TYPES_16X16);
} }
#if CONFIG_TX32X32 && CONFIG_SUPERBLOCKS #if CONFIG_TX32X32 && CONFIG_SUPERBLOCKS
if (cpi->common.txfm_mode > ALLOW_16X16) { if (cpi->common.txfm_mode > ALLOW_16X16) {
update_coef_probs_common(bc, update_coef_probs_common(bc,
#ifdef ENTROPY_STATS
cpi,
tree_update_hist_32x32,
#endif
cpi->frame_coef_probs_32x32, cpi->frame_coef_probs_32x32,
cpi->common.fc.coef_probs_32x32, cpi->common.fc.coef_probs_32x32,
cpi->frame_branch_ct_32x32); cpi->frame_branch_ct_32x32,
BLOCK_TYPES_32X32);
} }
#endif #endif
} }
@ -2223,12 +2159,18 @@ void vp9_pack_bitstream(VP9_COMP *cpi, unsigned char *dest,
vp9_clear_system_state(); // __asm emms; vp9_clear_system_state(); // __asm emms;
vp9_copy(cpi->common.fc.pre_coef_probs, cpi->common.fc.coef_probs); vp9_copy(cpi->common.fc.pre_coef_probs_4x4,
vp9_copy(cpi->common.fc.pre_hybrid_coef_probs, cpi->common.fc.hybrid_coef_probs); cpi->common.fc.coef_probs_4x4);
vp9_copy(cpi->common.fc.pre_coef_probs_8x8, cpi->common.fc.coef_probs_8x8); vp9_copy(cpi->common.fc.pre_hybrid_coef_probs_4x4,
vp9_copy(cpi->common.fc.pre_hybrid_coef_probs_8x8, cpi->common.fc.hybrid_coef_probs_8x8); cpi->common.fc.hybrid_coef_probs_4x4);
vp9_copy(cpi->common.fc.pre_coef_probs_16x16, cpi->common.fc.coef_probs_16x16); vp9_copy(cpi->common.fc.pre_coef_probs_8x8,
vp9_copy(cpi->common.fc.pre_hybrid_coef_probs_16x16, cpi->common.fc.hybrid_coef_probs_16x16); cpi->common.fc.coef_probs_8x8);
vp9_copy(cpi->common.fc.pre_hybrid_coef_probs_8x8,
cpi->common.fc.hybrid_coef_probs_8x8);
vp9_copy(cpi->common.fc.pre_coef_probs_16x16,
cpi->common.fc.coef_probs_16x16);
vp9_copy(cpi->common.fc.pre_hybrid_coef_probs_16x16,
cpi->common.fc.hybrid_coef_probs_16x16);
#if CONFIG_TX32X32 && CONFIG_SUPERBLOCKS #if CONFIG_TX32X32 && CONFIG_SUPERBLOCKS
vp9_copy(cpi->common.fc.pre_coef_probs_32x32, vp9_copy(cpi->common.fc.pre_coef_probs_32x32,
cpi->common.fc.coef_probs_32x32); cpi->common.fc.coef_probs_32x32);
@ -2362,25 +2304,20 @@ void vp9_pack_bitstream(VP9_COMP *cpi, unsigned char *dest,
} }
#ifdef ENTROPY_STATS #ifdef ENTROPY_STATS
void print_tree_update_probs() { static void print_tree_update_for_type(FILE *f,
vp9_coeff_stats *tree_update_hist,
int block_types, const char *header) {
int i, j, k, l; int i, j, k, l;
FILE *f = fopen("coefupdprob.h", "w");
int Sum;
fprintf(f, "\n/* Update probabilities for token entropy tree. */\n\n");
fprintf(f, "const vp9_prob\n" fprintf(f, "const vp9_coeff_prob %s = {\n", header);
"vp9_coef_update_probs[BLOCK_TYPES]\n" for (i = 0; i < block_types; i++) {
" [COEF_BANDS]\n"
" [PREV_COEF_CONTEXTS]\n"
" [ENTROPY_NODES] = {\n");
for (i = 0; i < BLOCK_TYPES; i++) {
fprintf(f, " { \n"); fprintf(f, " { \n");
for (j = 0; j < COEF_BANDS; j++) { for (j = 0; j < COEF_BANDS; j++) {
fprintf(f, " {\n"); fprintf(f, " {\n");
for (k = 0; k < PREV_COEF_CONTEXTS; k++) { for (k = 0; k < PREV_COEF_CONTEXTS; k++) {
fprintf(f, " {"); fprintf(f, " {");
for (l = 0; l < ENTROPY_NODES; l++) { for (l = 0; l < ENTROPY_NODES; l++) {
fprintf(f, "%3ld, ", fprintf(f, "%3d, ",
get_binary_prob(tree_update_hist[i][j][k][l][0], get_binary_prob(tree_update_hist[i][j][k][l][0],
tree_update_hist[i][j][k][l][1])); tree_update_hist[i][j][k][l][1]));
} }
@ -2391,56 +2328,33 @@ void print_tree_update_probs() {
fprintf(f, " },\n"); fprintf(f, " },\n");
} }
fprintf(f, "};\n"); fprintf(f, "};\n");
}
fprintf(f, "const vp9_prob\n" void print_tree_update_probs() {
"vp9_coef_update_probs_8x8[BLOCK_TYPES_8X8]\n" FILE *f = fopen("coefupdprob.h", "w");
" [COEF_BANDS]\n" fprintf(f, "\n/* Update probabilities for token entropy tree. */\n\n");
" [PREV_COEF_CONTEXTS]\n"
" [ENTROPY_NODES] = {\n");
for (i = 0; i < BLOCK_TYPES_8X8; i++) {
fprintf(f, " { \n");
for (j = 0; j < COEF_BANDS; j++) {
fprintf(f, " {\n");
for (k = 0; k < PREV_COEF_CONTEXTS; k++) {
fprintf(f, " {");
for (l = 0; l < MAX_ENTROPY_TOKENS - 1; l++) {
fprintf(f, "%3ld, ",
get_binary_prob(tree_update_hist_8x8[i][j][k][l][0],
tree_update_hist_8x8[i][j][k][l][1]));
}
fprintf(f, "},\n");
}
fprintf(f, " },\n");
}
fprintf(f, " },\n");
}
fprintf(f, "const vp9_prob\n" print_tree_update_for_type(f, tree_update_hist_4x4, BLOCK_TYPES_4X4,
"vp9_coef_update_probs_16x16[BLOCK_TYPES_16X16]\n" "vp9_coef_update_probs_4x4[BLOCK_TYPES_4X4]");
" [COEF_BANDS]\n" print_tree_update_for_type(f, hybrid_tree_update_hist_4x4, BLOCK_TYPES_4X4,
" [PREV_COEF_CONTEXTS]\n" "vp9_coef_update_probs_4x4[BLOCK_TYPES_4X4]");
" [ENTROPY_NODES] = {\n"); print_tree_update_for_type(f, tree_update_hist_8x8, BLOCK_TYPES_8X8,
for (i = 0; i < BLOCK_TYPES_16X16; i++) { "vp9_coef_update_probs_8x8[BLOCK_TYPES_8X8]");
fprintf(f, " { \n"); print_tree_update_for_type(f, hybrid_tree_update_hist_8x8, BLOCK_TYPES_8X8,
for (j = 0; j < COEF_BANDS; j++) { "vp9_coef_update_probs_8x8[BLOCK_TYPES_8X8]");
fprintf(f, " {\n"); print_tree_update_for_type(f, tree_update_hist_16x16, BLOCK_TYPES_16X16,
for (k = 0; k < PREV_COEF_CONTEXTS; k++) { "vp9_coef_update_probs_16x16[BLOCK_TYPES_16X16]");
fprintf(f, " {"); print_tree_update_for_type(f, hybrid_tree_update_hist_16x16,
for (l = 0; l < MAX_ENTROPY_TOKENS - 1; l++) { BLOCK_TYPES_16X16,
fprintf(f, "%3ld, ", "vp9_coef_update_probs_16x16[BLOCK_TYPES_16X16]");
get_binary_prob(tree_update_hist_16x16[i][j][k][l][0], #if CONFIG_TX32X32
tree_update_hist_16x16[i][j][k][l][1])); print_tree_update_for_type(f, tree_update_hist_32x32, BLOCK_TYPES_32X32,
} "vp9_coef_update_probs_32x32[BLOCK_TYPES_32X32]");
fprintf(f, "},\n"); #endif
}
fprintf(f, " },\n");
}
fprintf(f, " },\n");
}
fclose(f); fclose(f);
f = fopen("treeupdate.bin", "wb"); f = fopen("treeupdate.bin", "wb");
fwrite(tree_update_hist, sizeof(tree_update_hist), 1, f); fwrite(tree_update_hist_4x4, sizeof(tree_update_hist_4x4), 1, f);
fwrite(tree_update_hist_8x8, sizeof(tree_update_hist_8x8), 1, f); fwrite(tree_update_hist_8x8, sizeof(tree_update_hist_8x8), 1, f);
fwrite(tree_update_hist_16x16, sizeof(tree_update_hist_16x16), 1, f); fwrite(tree_update_hist_16x16, sizeof(tree_update_hist_16x16), 1, f);
fclose(f); fclose(f);

View File

@ -173,10 +173,8 @@ typedef struct macroblock {
unsigned char *active_ptr; unsigned char *active_ptr;
unsigned int token_costs[TX_SIZE_MAX_SB][BLOCK_TYPES][COEF_BANDS] vp9_coeff_count token_costs[TX_SIZE_MAX_SB][BLOCK_TYPES_4X4];
[PREV_COEF_CONTEXTS][MAX_ENTROPY_TOKENS]; vp9_coeff_count hybrid_token_costs[TX_SIZE_MAX_SB][BLOCK_TYPES_4X4];
unsigned int hybrid_token_costs[TX_SIZE_MAX_SB][BLOCK_TYPES][COEF_BANDS]
[PREV_COEF_CONTEXTS][MAX_ENTROPY_TOKENS];
int optimize; int optimize;

View File

@ -1485,8 +1485,8 @@ static void encode_frame_internal(VP9_COMP *cpi) {
xd->prev_mode_info_context = cm->prev_mi; xd->prev_mode_info_context = cm->prev_mi;
vp9_zero(cpi->NMVcount); vp9_zero(cpi->NMVcount);
vp9_zero(cpi->coef_counts); vp9_zero(cpi->coef_counts_4x4);
vp9_zero(cpi->hybrid_coef_counts); vp9_zero(cpi->hybrid_coef_counts_4x4);
vp9_zero(cpi->coef_counts_8x8); vp9_zero(cpi->coef_counts_8x8);
vp9_zero(cpi->hybrid_coef_counts_8x8); vp9_zero(cpi->hybrid_coef_counts_8x8);
vp9_zero(cpi->coef_counts_16x16); vp9_zero(cpi->coef_counts_16x16);

View File

@ -18,6 +18,7 @@
#ifdef ENTROPY_STATS #ifdef ENTROPY_STATS
extern void init_mv_ref_counts(); extern void init_mv_ref_counts();
extern void accum_mv_refs(MB_PREDICTION_MODE, const int near_mv_ref_cts[4]); extern void accum_mv_refs(MB_PREDICTION_MODE, const int near_mv_ref_cts[4]);
void print_mode_context(void);
#endif #endif

View File

@ -2223,11 +2223,11 @@ void vp9_remove_compressor(VP9_PTR *ptr) {
fprintf(fmode, "[VP9_KF_BINTRAMODES][VP9_KF_BINTRAMODES]" fprintf(fmode, "[VP9_KF_BINTRAMODES][VP9_KF_BINTRAMODES]"
"[VP9_KF_BINTRAMODES] =\n{\n"); "[VP9_KF_BINTRAMODES] =\n{\n");
for (i = 0; i < VP8_KF_BINTRAMODES; i++) { for (i = 0; i < VP9_KF_BINTRAMODES; i++) {
fprintf(fmode, " { // Above Mode : %d\n", i); fprintf(fmode, " { // Above Mode : %d\n", i);
for (j = 0; j < VP8_KF_BINTRAMODES; j++) { for (j = 0; j < VP9_KF_BINTRAMODES; j++) {
fprintf(fmode, " {"); fprintf(fmode, " {");
@ -3691,10 +3691,12 @@ static void encode_frame_to_data_rate
#endif #endif
update_reference_frames(cm); update_reference_frames(cm);
vp9_copy(cpi->common.fc.coef_counts, cpi->coef_counts); vp9_copy(cpi->common.fc.coef_counts_4x4, cpi->coef_counts_4x4);
vp9_copy(cpi->common.fc.hybrid_coef_counts, cpi->hybrid_coef_counts); vp9_copy(cpi->common.fc.hybrid_coef_counts_4x4,
cpi->hybrid_coef_counts_4x4);
vp9_copy(cpi->common.fc.coef_counts_8x8, cpi->coef_counts_8x8); vp9_copy(cpi->common.fc.coef_counts_8x8, cpi->coef_counts_8x8);
vp9_copy(cpi->common.fc.hybrid_coef_counts_8x8, cpi->hybrid_coef_counts_8x8); vp9_copy(cpi->common.fc.hybrid_coef_counts_8x8,
cpi->hybrid_coef_counts_8x8);
vp9_copy(cpi->common.fc.coef_counts_16x16, cpi->coef_counts_16x16); vp9_copy(cpi->common.fc.coef_counts_16x16, cpi->coef_counts_16x16);
vp9_copy(cpi->common.fc.hybrid_coef_counts_16x16, vp9_copy(cpi->common.fc.hybrid_coef_counts_16x16,
cpi->hybrid_coef_counts_16x16); cpi->hybrid_coef_counts_16x16);

View File

@ -94,24 +94,14 @@ typedef struct {
// 0 = BPRED, ZERO_MV, MV, SPLIT // 0 = BPRED, ZERO_MV, MV, SPLIT
signed char last_mode_lf_deltas[MAX_MODE_LF_DELTAS]; signed char last_mode_lf_deltas[MAX_MODE_LF_DELTAS];
vp9_prob coef_probs[BLOCK_TYPES] vp9_coeff_probs coef_probs_4x4[BLOCK_TYPES_4X4];
[COEF_BANDS][PREV_COEF_CONTEXTS][ENTROPY_NODES]; vp9_coeff_probs hybrid_coef_probs_4x4[BLOCK_TYPES_4X4];
vp9_prob hybrid_coef_probs[BLOCK_TYPES] vp9_coeff_probs coef_probs_8x8[BLOCK_TYPES_8X8];
[COEF_BANDS][PREV_COEF_CONTEXTS][ENTROPY_NODES]; vp9_coeff_probs hybrid_coef_probs_8x8[BLOCK_TYPES_8X8];
vp9_coeff_probs coef_probs_16x16[BLOCK_TYPES_16X16];
vp9_prob coef_probs_8x8[BLOCK_TYPES_8X8] vp9_coeff_probs hybrid_coef_probs_16x16[BLOCK_TYPES_16X16];
[COEF_BANDS][PREV_COEF_CONTEXTS][ENTROPY_NODES];
vp9_prob hybrid_coef_probs_8x8[BLOCK_TYPES_8X8]
[COEF_BANDS][PREV_COEF_CONTEXTS][ENTROPY_NODES];
vp9_prob coef_probs_16x16[BLOCK_TYPES_16X16]
[COEF_BANDS][PREV_COEF_CONTEXTS][ENTROPY_NODES];
vp9_prob hybrid_coef_probs_16x16[BLOCK_TYPES_16X16]
[COEF_BANDS][PREV_COEF_CONTEXTS][ENTROPY_NODES];
#if CONFIG_TX32X32 && CONFIG_SUPERBLOCKS #if CONFIG_TX32X32 && CONFIG_SUPERBLOCKS
vp9_prob coef_probs_32x32[BLOCK_TYPES_32X32] vp9_coeff_probs coef_probs_32x32[BLOCK_TYPES_32X32];
[COEF_BANDS][PREV_COEF_CONTEXTS][ENTROPY_NODES];
#endif #endif
#if CONFIG_SUPERBLOCKS #if CONFIG_SUPERBLOCKS
@ -598,31 +588,31 @@ typedef struct VP9_COMP {
nmv_context_counts NMVcount; nmv_context_counts NMVcount;
unsigned int coef_counts [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS]; /* for this frame */ vp9_coeff_count coef_counts_4x4[BLOCK_TYPES_4X4];
vp9_prob frame_coef_probs [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES]; vp9_coeff_probs frame_coef_probs_4x4[BLOCK_TYPES_4X4];
unsigned int frame_branch_ct [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES][2]; vp9_coeff_stats frame_branch_ct_4x4[BLOCK_TYPES_4X4];
unsigned int hybrid_coef_counts [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS]; /* for this frame */ vp9_coeff_count hybrid_coef_counts_4x4[BLOCK_TYPES_4X4];
vp9_prob frame_hybrid_coef_probs [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES]; vp9_coeff_probs frame_hybrid_coef_probs_4x4[BLOCK_TYPES_4X4];
unsigned int frame_hybrid_branch_ct [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES][2]; vp9_coeff_stats frame_hybrid_branch_ct_4x4[BLOCK_TYPES_4X4];
unsigned int coef_counts_8x8 [BLOCK_TYPES_8X8] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS]; /* for this frame */ vp9_coeff_count coef_counts_8x8[BLOCK_TYPES_8X8];
vp9_prob frame_coef_probs_8x8 [BLOCK_TYPES_8X8] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES]; vp9_coeff_probs frame_coef_probs_8x8[BLOCK_TYPES_8X8];
unsigned int frame_branch_ct_8x8 [BLOCK_TYPES_8X8] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES][2]; vp9_coeff_stats frame_branch_ct_8x8[BLOCK_TYPES_8X8];
unsigned int hybrid_coef_counts_8x8 [BLOCK_TYPES_8X8] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS]; /* for this frame */ vp9_coeff_count hybrid_coef_counts_8x8[BLOCK_TYPES_8X8];
vp9_prob frame_hybrid_coef_probs_8x8 [BLOCK_TYPES_8X8] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES]; vp9_coeff_probs frame_hybrid_coef_probs_8x8[BLOCK_TYPES_8X8];
unsigned int frame_hybrid_branch_ct_8x8 [BLOCK_TYPES_8X8] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES][2]; vp9_coeff_stats frame_hybrid_branch_ct_8x8[BLOCK_TYPES_8X8];
unsigned int coef_counts_16x16 [BLOCK_TYPES_16X16] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS]; /* for this frame */ vp9_coeff_count coef_counts_16x16[BLOCK_TYPES_16X16];
vp9_prob frame_coef_probs_16x16 [BLOCK_TYPES_16X16] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES]; vp9_coeff_probs frame_coef_probs_16x16[BLOCK_TYPES_16X16];
unsigned int frame_branch_ct_16x16 [BLOCK_TYPES_16X16] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES][2]; vp9_coeff_stats frame_branch_ct_16x16[BLOCK_TYPES_16X16];
unsigned int hybrid_coef_counts_16x16 [BLOCK_TYPES_16X16] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS]; /* for this frame */ vp9_coeff_count hybrid_coef_counts_16x16[BLOCK_TYPES_16X16];
vp9_prob frame_hybrid_coef_probs_16x16 [BLOCK_TYPES_16X16] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES]; vp9_coeff_probs frame_hybrid_coef_probs_16x16[BLOCK_TYPES_16X16];
unsigned int frame_hybrid_branch_ct_16x16 [BLOCK_TYPES_16X16] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES][2]; vp9_coeff_stats frame_hybrid_branch_ct_16x16[BLOCK_TYPES_16X16];
#if CONFIG_SUPERBLOCKS && CONFIG_TX32X32 #if CONFIG_TX32X32 && CONFIG_SUPERBLOCKS
unsigned int coef_counts_32x32 [BLOCK_TYPES_32X32] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS]; /* for this frame */ vp9_coeff_count coef_counts_32x32[BLOCK_TYPES_32X32];
vp9_prob frame_coef_probs_32x32 [BLOCK_TYPES_32X32] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES]; vp9_coeff_probs frame_coef_probs_32x32[BLOCK_TYPES_32X32];
unsigned int frame_branch_ct_32x32 [BLOCK_TYPES_32X32] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES][2]; vp9_coeff_stats frame_branch_ct_32x32[BLOCK_TYPES_32X32];
#endif #endif
int gfu_boost; int gfu_boost;

View File

@ -169,8 +169,8 @@ void vp9_save_coding_context(VP9_COMP *cpi) {
vp9_copy(cc->last_ref_lf_deltas, xd->last_ref_lf_deltas); vp9_copy(cc->last_ref_lf_deltas, xd->last_ref_lf_deltas);
vp9_copy(cc->last_mode_lf_deltas, xd->last_mode_lf_deltas); vp9_copy(cc->last_mode_lf_deltas, xd->last_mode_lf_deltas);
vp9_copy(cc->coef_probs, cm->fc.coef_probs); vp9_copy(cc->coef_probs_4x4, cm->fc.coef_probs_4x4);
vp9_copy(cc->hybrid_coef_probs, cm->fc.hybrid_coef_probs); vp9_copy(cc->hybrid_coef_probs_4x4, cm->fc.hybrid_coef_probs_4x4);
vp9_copy(cc->coef_probs_8x8, cm->fc.coef_probs_8x8); vp9_copy(cc->coef_probs_8x8, cm->fc.coef_probs_8x8);
vp9_copy(cc->hybrid_coef_probs_8x8, cm->fc.hybrid_coef_probs_8x8); vp9_copy(cc->hybrid_coef_probs_8x8, cm->fc.hybrid_coef_probs_8x8);
vp9_copy(cc->coef_probs_16x16, cm->fc.coef_probs_16x16); vp9_copy(cc->coef_probs_16x16, cm->fc.coef_probs_16x16);
@ -231,8 +231,8 @@ void vp9_restore_coding_context(VP9_COMP *cpi) {
vp9_copy(xd->last_ref_lf_deltas, cc->last_ref_lf_deltas); vp9_copy(xd->last_ref_lf_deltas, cc->last_ref_lf_deltas);
vp9_copy(xd->last_mode_lf_deltas, cc->last_mode_lf_deltas); vp9_copy(xd->last_mode_lf_deltas, cc->last_mode_lf_deltas);
vp9_copy(cm->fc.coef_probs, cc->coef_probs); vp9_copy(cm->fc.coef_probs_4x4, cc->coef_probs_4x4);
vp9_copy(cm->fc.hybrid_coef_probs, cc->hybrid_coef_probs); vp9_copy(cm->fc.hybrid_coef_probs_4x4, cc->hybrid_coef_probs_4x4);
vp9_copy(cm->fc.coef_probs_8x8, cc->coef_probs_8x8); vp9_copy(cm->fc.coef_probs_8x8, cc->coef_probs_8x8);
vp9_copy(cm->fc.hybrid_coef_probs_8x8, cc->hybrid_coef_probs_8x8); vp9_copy(cm->fc.hybrid_coef_probs_8x8, cc->hybrid_coef_probs_8x8);
vp9_copy(cm->fc.coef_probs_16x16, cc->coef_probs_16x16); vp9_copy(cm->fc.coef_probs_16x16, cc->coef_probs_16x16);

View File

@ -239,9 +239,8 @@ const MODE_DEFINITION vp9_mode_order[MAX_MODES] = {
}; };
#endif #endif
static void fill_token_costs( static void fill_token_costs(vp9_coeff_count *c,
unsigned int (*c)[COEF_BANDS][PREV_COEF_CONTEXTS][MAX_ENTROPY_TOKENS], vp9_coeff_probs *p,
const vp9_prob(*p)[COEF_BANDS][PREV_COEF_CONTEXTS][ENTROPY_NODES],
int block_type_counts) { int block_type_counts) {
int i, j, k; int i, j, k;
@ -370,41 +369,24 @@ void vp9_initialize_rd_consts(VP9_COMP *cpi, int QIndex) {
} }
} }
fill_token_costs( fill_token_costs(cpi->mb.token_costs[TX_4X4],
cpi->mb.token_costs[TX_4X4], cpi->common.fc.coef_probs_4x4, BLOCK_TYPES_4X4);
(const vp9_prob( *)[8][PREV_COEF_CONTEXTS][11]) cpi->common.fc.coef_probs, fill_token_costs(cpi->mb.hybrid_token_costs[TX_4X4],
BLOCK_TYPES); cpi->common.fc.hybrid_coef_probs_4x4, BLOCK_TYPES_4X4);
fill_token_costs(
cpi->mb.hybrid_token_costs[TX_4X4],
(const vp9_prob( *)[8][PREV_COEF_CONTEXTS][11])
cpi->common.fc.hybrid_coef_probs,
BLOCK_TYPES);
fill_token_costs( fill_token_costs(cpi->mb.token_costs[TX_8X8],
cpi->mb.token_costs[TX_8X8], cpi->common.fc.coef_probs_8x8, BLOCK_TYPES_8X8);
(const vp9_prob( *)[8][PREV_COEF_CONTEXTS][11]) cpi->common.fc.coef_probs_8x8, fill_token_costs(cpi->mb.hybrid_token_costs[TX_8X8],
BLOCK_TYPES_8X8); cpi->common.fc.hybrid_coef_probs_8x8, BLOCK_TYPES_8X8);
fill_token_costs(
cpi->mb.hybrid_token_costs[TX_8X8],
(const vp9_prob( *)[8][PREV_COEF_CONTEXTS][11])
cpi->common.fc.hybrid_coef_probs_8x8,
BLOCK_TYPES_8X8);
fill_token_costs( fill_token_costs(cpi->mb.token_costs[TX_16X16],
cpi->mb.token_costs[TX_16X16], cpi->common.fc.coef_probs_16x16, BLOCK_TYPES_16X16);
(const vp9_prob(*)[8][PREV_COEF_CONTEXTS][11]) cpi->common.fc.coef_probs_16x16, fill_token_costs(cpi->mb.hybrid_token_costs[TX_16X16],
BLOCK_TYPES_16X16); cpi->common.fc.hybrid_coef_probs_16x16, BLOCK_TYPES_16X16);
fill_token_costs(
cpi->mb.hybrid_token_costs[TX_16X16],
(const vp9_prob(*)[8][PREV_COEF_CONTEXTS][11])
cpi->common.fc.hybrid_coef_probs_16x16,
BLOCK_TYPES_16X16);
#if CONFIG_TX32X32 && CONFIG_SUPERBLOCKS #if CONFIG_TX32X32 && CONFIG_SUPERBLOCKS
fill_token_costs( fill_token_costs(cpi->mb.token_costs[TX_32X32],
cpi->mb.token_costs[TX_32X32], cpi->common.fc.coef_probs_32x32, BLOCK_TYPES_32X32);
(const vp9_prob(*)[8][PREV_COEF_CONTEXTS][11]) cpi->common.fc.coef_probs_32x32,
BLOCK_TYPES_32X32);
#endif #endif
/*rough estimate for costing*/ /*rough estimate for costing*/

View File

@ -25,27 +25,25 @@
compressions, then generating vp9_context.c = initial stats. */ compressions, then generating vp9_context.c = initial stats. */
#ifdef ENTROPY_STATS #ifdef ENTROPY_STATS
INT64 context_counters[BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS]; vp9_coeff_accum context_counters_4x4[BLOCK_TYPES_4X4];
INT64 hybrid_context_counters[BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS]; vp9_coeff_accum hybrid_context_counters_4x4[BLOCK_TYPES_4X4];
vp9_coeff_accum context_counters_8x8[BLOCK_TYPES_8X8];
vp9_coeff_accum hybrid_context_counters_8x8[BLOCK_TYPES_8X8];
vp9_coeff_accum context_counters_16x16[BLOCK_TYPES_16X16];
vp9_coeff_accum hybrid_context_counters_16x16[BLOCK_TYPES_16X16];
#if CONFIG_TX32X32
vp9_coeff_accum context_counters_32x32[BLOCK_TYPES_32X32];
#endif
INT64 context_counters_8x8[BLOCK_TYPES_8X8] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS]; extern vp9_coeff_stats tree_update_hist_4x4[BLOCK_TYPES_4X4];
INT64 hybrid_context_counters_8x8[BLOCK_TYPES_8X8] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS]; extern vp9_coeff_stats hybrid_tree_update_hist_4x4[BLOCK_TYPES_4X4];
extern vp9_coeff_stats tree_update_hist_8x8[BLOCK_TYPES_8X8];
INT64 context_counters_16x16[BLOCK_TYPES_16X16] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS]; extern vp9_coeff_stats hybrid_tree_update_hist_8x8[BLOCK_TYPES_8X8];
INT64 hybrid_context_counters_16x16[BLOCK_TYPES_16X16] [COEF_BANDS] [PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS]; extern vp9_coeff_stats tree_update_hist_16x16[BLOCK_TYPES_16X16];
extern vp9_coeff_stats hybrid_tree_update_hist_16x16[BLOCK_TYPES_16X16];
extern unsigned int tree_update_hist[BLOCK_TYPES][COEF_BANDS] #if CONFIG_TX32X32
[PREV_COEF_CONTEXTS][ENTROPY_NODES][2]; extern vp9_coeff_stats tree_update_hist_32x32[BLOCK_TYPES_32X32];
extern unsigned int hybrid_tree_update_hist[BLOCK_TYPES][COEF_BANDS] #endif
[PREV_COEF_CONTEXTS][ENTROPY_NODES][2];
extern unsigned int tree_update_hist_8x8[BLOCK_TYPES_8X8][COEF_BANDS]
[PREV_COEF_CONTEXTS][ENTROPY_NODES] [2];
extern unsigned int hybrid_tree_update_hist_8x8[BLOCK_TYPES_8X8][COEF_BANDS]
[PREV_COEF_CONTEXTS][ENTROPY_NODES] [2];
extern unsigned int tree_update_hist_16x16[BLOCK_TYPES_16X16][COEF_BANDS]
[PREV_COEF_CONTEXTS][ENTROPY_NODES] [2];
extern unsigned int hybrid_tree_update_hist_16x16[BLOCK_TYPES_16X16][COEF_BANDS]
[PREV_COEF_CONTEXTS][ENTROPY_NODES] [2];
#endif /* ENTROPY_STATS */ #endif /* ENTROPY_STATS */
static TOKENVALUE dct_value_tokens[DCT_MAX_VALUE * 2]; static TOKENVALUE dct_value_tokens[DCT_MAX_VALUE * 2];
@ -123,8 +121,8 @@ static void tokenize_b(VP9_COMP *cpi,
int seg_eob; int seg_eob;
int segment_id = xd->mode_info_context->mbmi.segment_id; int segment_id = xd->mode_info_context->mbmi.segment_id;
const int *bands, *scan; const int *bands, *scan;
unsigned int (*counts)[COEF_BANDS][PREV_COEF_CONTEXTS][MAX_ENTROPY_TOKENS]; vp9_coeff_count *counts;
vp9_prob (*probs)[COEF_BANDS][PREV_COEF_CONTEXTS][ENTROPY_NODES]; vp9_coeff_probs *probs;
const TX_TYPE tx_type = (type == PLANE_TYPE_Y_WITH_DC) ? const TX_TYPE tx_type = (type == PLANE_TYPE_Y_WITH_DC) ?
get_tx_type(xd, b) : DCT_DCT; get_tx_type(xd, b) : DCT_DCT;
@ -136,16 +134,16 @@ static void tokenize_b(VP9_COMP *cpi,
bands = vp9_coef_bands; bands = vp9_coef_bands;
scan = vp9_default_zig_zag1d; scan = vp9_default_zig_zag1d;
if (tx_type != DCT_DCT) { if (tx_type != DCT_DCT) {
counts = cpi->hybrid_coef_counts; counts = cpi->hybrid_coef_counts_4x4;
probs = cpi->common.fc.hybrid_coef_probs; probs = cpi->common.fc.hybrid_coef_probs_4x4;
if (tx_type == ADST_DCT) { if (tx_type == ADST_DCT) {
scan = vp9_row_scan; scan = vp9_row_scan;
} else if (tx_type == DCT_ADST) { } else if (tx_type == DCT_ADST) {
scan = vp9_col_scan; scan = vp9_col_scan;
} }
} else { } else {
counts = cpi->coef_counts; counts = cpi->coef_counts_4x4;
probs = cpi->common.fc.coef_probs; probs = cpi->common.fc.coef_probs_4x4;
} }
break; break;
case TX_8X8: case TX_8X8:
@ -514,40 +512,70 @@ void vp9_tokenize_mb(VP9_COMP *cpi,
void init_context_counters(void) { void init_context_counters(void) {
FILE *f = fopen("context.bin", "rb"); FILE *f = fopen("context.bin", "rb");
if (!f) { if (!f) {
vpx_memset(context_counters, 0, sizeof(context_counters)); vpx_memset(context_counters_4x4, 0, sizeof(context_counters_4x4));
vpx_memset(hybrid_context_counters_4x4, 0,
sizeof(hybrid_context_counters_4x4));
vpx_memset(context_counters_8x8, 0, sizeof(context_counters_8x8)); vpx_memset(context_counters_8x8, 0, sizeof(context_counters_8x8));
vpx_memset(hybrid_context_counters_8x8, 0,
sizeof(hybrid_context_counters_8x8));
vpx_memset(context_counters_16x16, 0, sizeof(context_counters_16x16)); vpx_memset(context_counters_16x16, 0, sizeof(context_counters_16x16));
vpx_memset(hybrid_context_counters_16x16, 0,
sizeof(hybrid_context_counters_16x16));
#if CONFIG_TX32X32
vpx_memset(context_counters_32x32, 0, sizeof(context_counters_32x32));
#endif
} else { } else {
fread(context_counters, sizeof(context_counters), 1, f); fread(context_counters_4x4, sizeof(context_counters_4x4), 1, f);
fread(hybrid_context_counters_4x4,
sizeof(hybrid_context_counters_4x4), 1, f);
fread(context_counters_8x8, sizeof(context_counters_8x8), 1, f); fread(context_counters_8x8, sizeof(context_counters_8x8), 1, f);
fread(hybrid_context_counters_8x8,
sizeof(hybrid_context_counters_8x8), 1, f);
fread(context_counters_16x16, sizeof(context_counters_16x16), 1, f); fread(context_counters_16x16, sizeof(context_counters_16x16), 1, f);
fread(hybrid_context_counters_16x16,
sizeof(hybrid_context_counters_16x16), 1, f);
#if CONFIG_TX32X32
fread(context_counters_32x32, sizeof(context_counters_32x32), 1, f);
#endif
fclose(f); fclose(f);
} }
f = fopen("treeupdate.bin", "rb"); f = fopen("treeupdate.bin", "rb");
if (!f) { if (!f) {
vpx_memset(tree_update_hist, 0, sizeof(tree_update_hist)); vpx_memset(tree_update_hist_4x4, 0, sizeof(tree_update_hist_4x4));
vpx_memset(hybrid_tree_update_hist_4x4, 0,
sizeof(hybrid_tree_update_hist_4x4));
vpx_memset(tree_update_hist_8x8, 0, sizeof(tree_update_hist_8x8)); vpx_memset(tree_update_hist_8x8, 0, sizeof(tree_update_hist_8x8));
vpx_memset(hybrid_tree_update_hist_8x8, 0,
sizeof(hybrid_tree_update_hist_8x8));
vpx_memset(tree_update_hist_16x16, 0, sizeof(tree_update_hist_16x16)); vpx_memset(tree_update_hist_16x16, 0, sizeof(tree_update_hist_16x16));
vpx_memset(hybrid_tree_update_hist_16x16, 0,
sizeof(hybrid_tree_update_hist_16x16));
#if CONFIG_TX32X32
vpx_memset(tree_update_hist_32x32, 0, sizeof(tree_update_hist_32x32));
#endif
} else { } else {
fread(tree_update_hist, sizeof(tree_update_hist), 1, f); fread(tree_update_hist_4x4, sizeof(tree_update_hist_4x4), 1, f);
fread(hybrid_tree_update_hist_4x4,
sizeof(hybrid_tree_update_hist_4x4), 1, f);
fread(tree_update_hist_8x8, sizeof(tree_update_hist_8x8), 1, f); fread(tree_update_hist_8x8, sizeof(tree_update_hist_8x8), 1, f);
fread(hybrid_tree_update_hist_8x8,
sizeof(hybrid_tree_update_hist_8x8), 1, f);
fread(tree_update_hist_16x16, sizeof(tree_update_hist_16x16), 1, f); fread(tree_update_hist_16x16, sizeof(tree_update_hist_16x16), 1, f);
fread(hybrid_tree_update_hist_16x16,
sizeof(hybrid_tree_update_hist_16x16), 1, f);
#if CONFIG_TX32X32
fread(tree_update_hist_32x32, sizeof(tree_update_hist_32x32), 1, f);
#endif
fclose(f); fclose(f);
} }
} }
void print_context_counters() { static void print_counter(FILE *f, vp9_coeff_accum *context_counters,
int block_types, const char *header) {
int type, band, pt, t; int type, band, pt, t;
FILE *f = fopen("vp9_context.c", "w");
fprintf(f, "#include \"vp9_entropy.h\"\n"); fprintf(f, "static const vp9_coeff_count %s = {\n", header);
fprintf(f, "\n/* *** GENERATED FILE: DO NOT EDIT *** */\n\n");
fprintf(f, "static const unsigned int\n"
"vp9_default_coef_counts[BLOCK_TYPES]\n"
" [COEF_BANDS]\n"
" [PREV_COEF_CONTEXTS]\n"
" [MAX_ENTROPY_TOKENS]={\n");
# define Comma( X) (X? ",":"") # define Comma( X) (X? ",":"")
type = 0; type = 0;
@ -564,6 +592,7 @@ void print_context_counters() {
do { do {
const INT64 x = context_counters [type] [band] [pt] [t]; const INT64 x = context_counters [type] [band] [pt] [t];
const int y = (int) x; const int y = (int) x;
assert(x == (INT64) y); /* no overflow handling yet */ assert(x == (INT64) y); /* no overflow handling yet */
fprintf(f, "%s %d", Comma(t), y); fprintf(f, "%s %d", Comma(t), y);
} while (++t < MAX_ENTROPY_TOKENS); } while (++t < MAX_ENTROPY_TOKENS);
@ -572,78 +601,16 @@ void print_context_counters() {
fprintf(f, "\n }"); fprintf(f, "\n }");
} while (++band < COEF_BANDS); } while (++band < COEF_BANDS);
fprintf(f, "\n }"); fprintf(f, "\n }");
} while (++type < BLOCK_TYPES); } while (++type < block_types);
fprintf(f, "\n};\n"); fprintf(f, "\n};\n");
}
fprintf(f, "static const unsigned int\nvp9_default_coef_counts_8x8" static void print_probs(FILE *f, vp9_coeff_accum *context_counters,
"[BLOCK_TYPES_8X8] [COEF_BANDS]" int block_types, const char *header) {
"[PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS] = {"); int type, band, pt, t;
type = 0;
do {
fprintf(f, "%s\n { /* block Type %d */", Comma(type), type);
band = 0;
do {
fprintf(f, "%s\n { /* Coeff Band %d */", Comma(band), band);
pt = 0;
do {
fprintf(f, "%s\n {", Comma(pt));
t = 0;
do {
const INT64 x = context_counters_8x8 [type] [band] [pt] [t];
const int y = (int) x;
assert(x == (INT64) y); /* no overflow handling yet */ fprintf(f, "static const vp9_coeff_probs %s = {\n", header);
fprintf(f, "%s %d", Comma(t), y);
} while (++t < MAX_ENTROPY_TOKENS);
fprintf(f, "}");
} while (++pt < PREV_COEF_CONTEXTS);
fprintf(f, "\n }");
} while (++band < COEF_BANDS);
fprintf(f, "\n }");
} while (++type < BLOCK_TYPES_8X8);
fprintf(f, "\n};\n");
fprintf(f, "static const unsigned int\nvp9_default_coef_counts_16x16"
"[BLOCK_TYPES_16X16] [COEF_BANDS]"
"[PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS] = {");
type = 0;
do {
fprintf(f, "%s\n { /* block Type %d */", Comma(type), type);
band = 0;
do {
fprintf(f, "%s\n { /* Coeff Band %d */", Comma(band), band);
pt = 0;
do {
fprintf(f, "%s\n {", Comma(pt));
t = 0;
do {
const INT64 x = context_counters_16x16 [type] [band] [pt] [t];
const int y = (int) x;
assert(x == (INT64) y); /* no overflow handling yet */
fprintf(f, "%s %d", Comma(t), y);
} while (++t < MAX_ENTROPY_TOKENS);
fprintf(f, "}");
} while (++pt < PREV_COEF_CONTEXTS);
fprintf(f, "\n }");
} while (++band < COEF_BANDS);
fprintf(f, "\n }");
} while (++type < BLOCK_TYPES_16X16);
fprintf(f, "\n};\n");
fprintf(f, "static const vp9_prob\n"
"vp9_default_coef_probs[BLOCK_TYPES] [COEF_BANDS] \n"
"[PREV_COEF_CONTEXTS] [ENTROPY_NODES] = {");
type = 0; type = 0;
do { do {
fprintf(f, "%s\n { /* block Type %d */", Comma(type), type); fprintf(f, "%s\n { /* block Type %d */", Comma(type), type);
@ -655,17 +622,18 @@ void print_context_counters() {
unsigned int branch_ct [ENTROPY_NODES] [2]; unsigned int branch_ct [ENTROPY_NODES] [2];
unsigned int coef_counts[MAX_ENTROPY_TOKENS]; unsigned int coef_counts[MAX_ENTROPY_TOKENS];
vp9_prob coef_probs[ENTROPY_NODES]; vp9_prob coef_probs[ENTROPY_NODES];
for (t = 0; t < MAX_ENTROPY_TOKENS; ++t) for (t = 0; t < MAX_ENTROPY_TOKENS; ++t)
coef_counts[t] = context_counters [type] [band] [pt] [t]; coef_counts[t] = context_counters[type][band][pt][t];
vp9_tree_probs_from_distribution( vp9_tree_probs_from_distribution(MAX_ENTROPY_TOKENS,
MAX_ENTROPY_TOKENS, vp9_coef_encodings, vp9_coef_tree, vp9_coef_encodings, vp9_coef_tree,
coef_probs, branch_ct, coef_counts, 256, 1); coef_probs, branch_ct, coef_counts,
256, 1);
fprintf(f, "%s\n {", Comma(pt)); fprintf(f, "%s\n {", Comma(pt));
t = 0; t = 0;
do { do {
fprintf(f, "%s %d", Comma(t), coef_probs[t]); fprintf(f, "%s %d", Comma(t), coef_probs[t]);
} while (++t < ENTROPY_NODES); } while (++t < ENTROPY_NODES);
fprintf(f, "}"); fprintf(f, "}");
@ -673,81 +641,67 @@ void print_context_counters() {
fprintf(f, "\n }"); fprintf(f, "\n }");
} while (++band < COEF_BANDS); } while (++band < COEF_BANDS);
fprintf(f, "\n }"); fprintf(f, "\n }");
} while (++type < BLOCK_TYPES); } while (++type < block_types);
fprintf(f, "\n};\n"); fprintf(f, "\n};\n");
}
fprintf(f, "static const vp9_prob\n" void print_context_counters() {
"vp9_default_coef_probs_8x8[BLOCK_TYPES_8X8] [COEF_BANDS]\n" FILE *f = fopen("vp9_context.c", "w");
"[PREV_COEF_CONTEXTS] [ENTROPY_NODES] = {");
type = 0;
do {
fprintf(f, "%s\n { /* block Type %d */", Comma(type), type);
band = 0;
do {
fprintf(f, "%s\n { /* Coeff Band %d */", Comma(band), band);
pt = 0;
do {
unsigned int branch_ct [ENTROPY_NODES] [2];
unsigned int coef_counts[MAX_ENTROPY_TOKENS];
vp9_prob coef_probs[ENTROPY_NODES];
for (t = 0; t < MAX_ENTROPY_TOKENS; ++t)
coef_counts[t] = context_counters_8x8[type] [band] [pt] [t];
vp9_tree_probs_from_distribution(
MAX_ENTROPY_TOKENS, vp9_coef_encodings, vp9_coef_tree,
coef_probs, branch_ct, coef_counts, 256, 1);
fprintf(f, "%s\n {", Comma(pt));
t = 0; fprintf(f, "#include \"vp9_entropy.h\"\n");
do { fprintf(f, "\n/* *** GENERATED FILE: DO NOT EDIT *** */\n\n");
fprintf(f, "%s %d", Comma(t), coef_probs[t]);
} while (++t < ENTROPY_NODES);
fprintf(f, "}");
} while (++pt < PREV_COEF_CONTEXTS);
fprintf(f, "\n }");
} while (++band < COEF_BANDS);
fprintf(f, "\n }");
} while (++type < BLOCK_TYPES_8X8);
fprintf(f, "\n};\n");
fprintf(f, "static const vp9_prob\n" /* print counts */
"vp9_default_coef_probs_16x16[BLOCK_TYPES_16X16] [COEF_BANDS]\n" print_counter(f, context_counters_4x4, BLOCK_TYPES_4X4,
"[PREV_COEF_CONTEXTS] [ENTROPY_NODES] = {"); "vp9_default_coef_counts_4x4[BLOCK_TYPES_4X4]");
type = 0; print_counter(f, hybrid_context_counters_4x4, BLOCK_TYPES_4X4,
do { "vp9_default_hybrid_coef_counts_4x4[BLOCK_TYPES_4X4]");
fprintf(f, "%s\n { /* block Type %d */", Comma(type), type); print_counter(f, context_counters_8x8, BLOCK_TYPES_8X8,
band = 0; "vp9_default_coef_counts_8x8[BLOCK_TYPES_8X8]");
do { print_counter(f, hybrid_context_counters_8x8, BLOCK_TYPES_8X8,
fprintf(f, "%s\n { /* Coeff Band %d */", Comma(band), band); "vp9_default_hybrid_coef_counts_8x8[BLOCK_TYPES_8X8]");
pt = 0; print_counter(f, context_counters_16x16, BLOCK_TYPES_16X16,
do { "vp9_default_coef_counts_16x16[BLOCK_TYPES_16X16]");
unsigned int branch_ct [ENTROPY_NODES] [2]; print_counter(f, hybrid_context_counters_16x16, BLOCK_TYPES_16X16,
unsigned int coef_counts[MAX_ENTROPY_TOKENS]; "vp9_default_hybrid_coef_counts_16x16[BLOCK_TYPES_16X16]");
vp9_prob coef_probs[ENTROPY_NODES]; #if CONFIG_TX32X32
for (t = 0; t < MAX_ENTROPY_TOKENS; ++t) print_counter(f, context_counters_32x32, BLOCK_TYPES_32X32,
coef_counts[t] = context_counters_16x16[type] [band] [pt] [t]; "vp9_default_coef_counts_32x32[BLOCK_TYPES_32X32]");
vp9_tree_probs_from_distribution( #endif
MAX_ENTROPY_TOKENS, vp9_coef_encodings, vp9_coef_tree,
coef_probs, branch_ct, coef_counts, 256, 1);
fprintf(f, "%s\n {", Comma(pt));
t = 0; /* print coefficient probabilities */
do { print_probs(f, context_counters_4x4, BLOCK_TYPES_4X4,
fprintf(f, "%s %d", Comma(t), coef_probs[t]); "vp9_default_coef_probs_4x4[BLOCK_TYPES_4X4]");
} while (++t < ENTROPY_NODES); print_probs(f, hybrid_context_counters_4x4, BLOCK_TYPES_4X4,
fprintf(f, "}"); "vp9_default_hybrid_coef_probs_4x4[BLOCK_TYPES_4X4]");
} while (++pt < PREV_COEF_CONTEXTS); print_probs(f, context_counters_8x8, BLOCK_TYPES_8X8,
fprintf(f, "\n }"); "vp9_default_coef_probs_8x8[BLOCK_TYPES_8X8]");
} while (++band < COEF_BANDS); print_probs(f, hybrid_context_counters_8x8, BLOCK_TYPES_8X8,
fprintf(f, "\n }"); "vp9_default_hybrid_coef_probs_8x8[BLOCK_TYPES_8X8]");
} while (++type < BLOCK_TYPES_16X16); print_probs(f, context_counters_16x16, BLOCK_TYPES_16X16,
fprintf(f, "\n};\n"); "vp9_default_coef_probs_16x16[BLOCK_TYPES_16X16]");
print_probs(f, hybrid_context_counters_16x16, BLOCK_TYPES_16X16,
"vp9_default_hybrid_coef_probs_16x16[BLOCK_TYPES_16X16]");
#if CONFIG_TX32X32
print_probs(f, context_counters_32x32, BLOCK_TYPES_32X32,
"vp9_default_coef_probs_32x32[BLOCK_TYPES_32X32]");
#endif
fclose(f); fclose(f);
f = fopen("context.bin", "wb"); f = fopen("context.bin", "wb");
fwrite(context_counters, sizeof(context_counters), 1, f); fwrite(context_counters_4x4, sizeof(context_counters_4x4), 1, f);
fwrite(hybrid_context_counters_4x4,
sizeof(hybrid_context_counters_4x4), 1, f);
fwrite(context_counters_8x8, sizeof(context_counters_8x8), 1, f); fwrite(context_counters_8x8, sizeof(context_counters_8x8), 1, f);
fwrite(hybrid_context_counters_8x8,
sizeof(hybrid_context_counters_8x8), 1, f);
fwrite(context_counters_16x16, sizeof(context_counters_16x16), 1, f); fwrite(context_counters_16x16, sizeof(context_counters_16x16), 1, f);
fwrite(hybrid_context_counters_16x16,
sizeof(hybrid_context_counters_16x16), 1, f);
#if CONFIG_TX32X32
fwrite(context_counters_32x32, sizeof(context_counters_32x32), 1, f);
#endif
fclose(f); fclose(f);
} }
#endif #endif
@ -766,8 +720,8 @@ static __inline void stuff_b(VP9_COMP *cpi,
TX_SIZE tx_size, TX_SIZE tx_size,
int dry_run) { int dry_run) {
const int *bands; const int *bands;
unsigned int (*counts)[COEF_BANDS][PREV_COEF_CONTEXTS][MAX_ENTROPY_TOKENS]; vp9_coeff_count *counts;
vp9_prob (*probs)[COEF_BANDS][PREV_COEF_CONTEXTS][ENTROPY_NODES]; vp9_coeff_probs *probs;
int pt, band; int pt, band;
TOKENEXTRA *t = *tp; TOKENEXTRA *t = *tp;
const TX_TYPE tx_type = (type == PLANE_TYPE_Y_WITH_DC) ? const TX_TYPE tx_type = (type == PLANE_TYPE_Y_WITH_DC) ?
@ -779,11 +733,11 @@ static __inline void stuff_b(VP9_COMP *cpi,
case TX_4X4: case TX_4X4:
bands = vp9_coef_bands; bands = vp9_coef_bands;
if (tx_type != DCT_DCT) { if (tx_type != DCT_DCT) {
counts = cpi->hybrid_coef_counts; counts = cpi->hybrid_coef_counts_4x4;
probs = cpi->common.fc.hybrid_coef_probs; probs = cpi->common.fc.hybrid_coef_probs_4x4;
} else { } else {
counts = cpi->coef_counts; counts = cpi->coef_counts_4x4;
probs = cpi->common.fc.coef_probs; probs = cpi->common.fc.coef_probs_4x4;
} }
break; break;
case TX_8X8: case TX_8X8:

View File

@ -29,6 +29,9 @@ typedef struct {
unsigned char skip_eob_node; unsigned char skip_eob_node;
} TOKENEXTRA; } TOKENEXTRA;
typedef INT64 vp9_coeff_accum[COEF_BANDS][PREV_COEF_CONTEXTS]
[MAX_ENTROPY_TOKENS];
extern int vp9_mby_is_skippable_4x4(MACROBLOCKD *xd, int has_y2_block); extern int vp9_mby_is_skippable_4x4(MACROBLOCKD *xd, int has_y2_block);
extern int vp9_mbuv_is_skippable_4x4(MACROBLOCKD *xd); extern int vp9_mbuv_is_skippable_4x4(MACROBLOCKD *xd);
extern int vp9_mby_is_skippable_8x8(MACROBLOCKD *xd, int has_y2_block); extern int vp9_mby_is_skippable_8x8(MACROBLOCKD *xd, int has_y2_block);
@ -62,12 +65,14 @@ extern void vp9_fix_contexts_sb(MACROBLOCKD *xd);
void init_context_counters(); void init_context_counters();
void print_context_counters(); void print_context_counters();
extern INT64 context_counters[BLOCK_TYPES][COEF_BANDS] extern vp9_coeff_accum context_counters_4x4[BLOCK_TYPES_4X4];
[PREV_COEF_CONTEXTS][MAX_ENTROPY_TOKENS]; extern vp9_coeff_accum context_counters_8x8[BLOCK_TYPES_8X8];
extern INT64 context_counters_8x8[BLOCK_TYPES_8X8][COEF_BANDS] extern vp9_coeff_accum context_counters_16x16[BLOCK_TYPES_16X16];
[PREV_COEF_CONTEXTS][MAX_ENTROPY_TOKENS]; extern vp9_coeff_accum context_counters_32x32[BLOCK_TYPES_32X32];
extern INT64 context_counters_16x16[BLOCK_TYPES_16X16][COEF_BANDS]
[PREV_COEF_CONTEXTS][MAX_ENTROPY_TOKENS]; extern vp9_coeff_accum hybrid_context_counters_4x4[BLOCK_TYPES_4X4];
extern vp9_coeff_accum hybrid_context_counters_8x8[BLOCK_TYPES_8X8];
extern vp9_coeff_accum hybrid_context_counters_16x16[BLOCK_TYPES_16X16];
#endif #endif
extern const int *vp9_dct_value_cost_ptr; extern const int *vp9_dct_value_cost_ptr;