Commit 885cf816 authored by Ronald S. Bultje's avatar Ronald S. Bultje
Browse files

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
parent c456b35f
......@@ -12,10 +12,7 @@
/*Generated file, included by vp9_entropy.c*/
static const vp9_prob default_coef_probs [BLOCK_TYPES]
[COEF_BANDS]
[PREV_COEF_CONTEXTS]
[ENTROPY_NODES] = {
static const vp9_coeff_probs default_coef_probs_4x4[BLOCK_TYPES_4X4] = {
{
/* 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]
[COEF_BANDS]
[PREV_COEF_CONTEXTS]
[ENTROPY_NODES] = {
static const vp9_coeff_probs default_hybrid_coef_probs_4x4[BLOCK_TYPES_4X4] = {
{
/* Block Type ( 0 ) */
{
......@@ -496,11 +490,7 @@ static const vp9_prob default_hybrid_coef_probs [BLOCK_TYPES]
}
};
static const vp9_prob
default_coef_probs_8x8[BLOCK_TYPES_8X8]
[COEF_BANDS]
[PREV_COEF_CONTEXTS]
[ENTROPY_NODES] = {
static const vp9_coeff_probs default_coef_probs_8x8[BLOCK_TYPES_8X8] = {
{
/* block Type 0 */
{
......@@ -729,11 +719,7 @@ default_coef_probs_8x8[BLOCK_TYPES_8X8]
}
};
static const vp9_prob
default_hybrid_coef_probs_8x8[BLOCK_TYPES_8X8]
[COEF_BANDS]
[PREV_COEF_CONTEXTS]
[ENTROPY_NODES] = {
static const vp9_coeff_probs default_hybrid_coef_probs_8x8[BLOCK_TYPES_8X8] = {
{
/* block Type 0 */
{
......@@ -962,11 +948,7 @@ default_hybrid_coef_probs_8x8[BLOCK_TYPES_8X8]
}
};
static const vp9_prob
default_coef_probs_16x16[BLOCK_TYPES_16X16]
[COEF_BANDS]
[PREV_COEF_CONTEXTS]
[ENTROPY_NODES] = {
static const vp9_coeff_probs default_coef_probs_16x16[BLOCK_TYPES_16X16] = {
{ /* block Type 0 */
{ /* Coeff Band 0 */
{ 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128},
......@@ -1169,11 +1151,8 @@ static const vp9_prob
}
};
static const vp9_prob
default_hybrid_coef_probs_16x16[BLOCK_TYPES_16X16]
[COEF_BANDS]
[PREV_COEF_CONTEXTS]
[ENTROPY_NODES] = {
static const vp9_coeff_probs
default_hybrid_coef_probs_16x16[BLOCK_TYPES_16X16] = {
{ /* block Type 0 */
{ /* Coeff Band 0 */
{ 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128},
......
......@@ -307,10 +307,10 @@ vp9_extra_bit_struct vp9_extra_bits[12] = {
#include "vp9/common/vp9_default_coef_probs.h"
void vp9_default_coef_probs(VP9_COMMON *pc) {
vpx_memcpy(pc->fc.coef_probs, default_coef_probs,
sizeof(pc->fc.coef_probs));
vpx_memcpy(pc->fc.hybrid_coef_probs, default_hybrid_coef_probs,
sizeof(pc->fc.hybrid_coef_probs));
vpx_memcpy(pc->fc.coef_probs_4x4, default_coef_probs_4x4,
sizeof(pc->fc.coef_probs_4x4));
vpx_memcpy(pc->fc.hybrid_coef_probs_4x4, default_hybrid_coef_probs_4x4,
sizeof(pc->fc.hybrid_coef_probs_4x4));
vpx_memcpy(pc->fc.coef_probs_8x8, default_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_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;
unsigned int branch_ct[ENTROPY_NODES][2];
vp9_prob coef_probs[ENTROPY_NODES];
int update_factor; /* denominator 256 */
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 update_factor; /* denominator 256 */
// printf("Frame type: %d\n", cm->frame_type);
if (cm->frame_type == KEY_FRAME) {
......@@ -422,159 +451,30 @@ void vp9_adapt_coef_probs(VP9_COMMON *cm) {
}
#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,
coef_probs, branch_ct, cm->fc.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_coef_probs[i][j][k][t] * (256 - factor) +
(int)coef_probs[t] * factor + 128) >> 8;
if (prob <= 0) cm->fc.coef_probs[i][j][k][t] = 1;
else if (prob > 255) cm->fc.coef_probs[i][j][k][t] = 255;
else cm->fc.coef_probs[i][j][k][t] = prob;
}
}
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;
}
}
update_coef_probs(cm->fc.coef_probs_4x4, cm->fc.pre_coef_probs_4x4,
BLOCK_TYPES_4X4, cm->fc.coef_counts_4x4,
count_sat, update_factor);
update_coef_probs(cm->fc.hybrid_coef_probs_4x4,
cm->fc.pre_hybrid_coef_probs_4x4,
BLOCK_TYPES_4X4, cm->fc.hybrid_coef_counts_4x4,
count_sat, update_factor);
update_coef_probs(cm->fc.coef_probs_8x8, cm->fc.pre_coef_probs_8x8,
BLOCK_TYPES_8X8, cm->fc.coef_counts_8x8,
count_sat, update_factor);
update_coef_probs(cm->fc.hybrid_coef_probs_8x8,
cm->fc.pre_hybrid_coef_probs_8x8,
BLOCK_TYPES_8X8, cm->fc.hybrid_coef_counts_8x8,
count_sat, update_factor);
update_coef_probs(cm->fc.coef_probs_16x16, cm->fc.pre_coef_probs_16x16,
BLOCK_TYPES_16X16, cm->fc.coef_counts_16x16,
count_sat, update_factor);
update_coef_probs(cm->fc.hybrid_coef_probs_16x16,
cm->fc.pre_hybrid_coef_probs_16x16,
BLOCK_TYPES_16X16, cm->fc.hybrid_coef_counts_16x16,
count_sat, update_factor);
#if CONFIG_TX32X32 && CONFIG_SUPERBLOCKS
for (i = 0; i < BLOCK_TYPES_32X32; ++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_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;
}
}
update_coef_probs(cm->fc.coef_probs_32x32, cm->fc.pre_coef_probs_32x32,
BLOCK_TYPES_32X32, cm->fc.coef_counts_32x32,
count_sat, update_factor);
#endif
}
......@@ -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. */
/* 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
......@@ -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 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 MODULUS_PARAM 13 /* Modulus parameter */
......
......@@ -52,14 +52,14 @@ typedef struct frame_contexts {
vp9_prob i8x8_mode_prob[VP9_I8X8_MODES - 1];
vp9_prob sub_mv_ref_prob[SUBMVREF_COUNT][VP9_SUBMVREFS - 1];
vp9_prob mbsplit_prob[VP9_NUMMBSPLITS - 1];
vp9_prob coef_probs [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES];
vp9_prob hybrid_coef_probs [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [ENTROPY_NODES];
vp9_prob coef_probs_8x8 [BLOCK_TYPES_8X8] [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];
vp9_coeff_probs coef_probs_4x4[BLOCK_TYPES_4X4];
vp9_coeff_probs hybrid_coef_probs_4x4[BLOCK_TYPES_4X4];
vp9_coeff_probs coef_probs_8x8[BLOCK_TYPES_8X8];
vp9_coeff_probs hybrid_coef_probs_8x8[BLOCK_TYPES_8X8];
vp9_coeff_probs coef_probs_16x16[BLOCK_TYPES_16X16];
vp9_coeff_probs hybrid_coef_probs_16x16[BLOCK_TYPES_16X16];
#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
nmv_context nmvc;
......@@ -83,44 +83,24 @@ typedef struct frame_contexts {
unsigned int sub_mv_ref_counts[SUBMVREF_COUNT][VP9_SUBMVREFS];
unsigned int mbsplit_counts[VP9_NUMMBSPLITS];
vp9_prob pre_coef_probs [BLOCK_TYPES] [COEF_BANDS]
[PREV_COEF_CONTEXTS] [ENTROPY_NODES];
vp9_prob pre_hybrid_coef_probs [BLOCK_TYPES] [COEF_BANDS]
[PREV_COEF_CONTEXTS] [ENTROPY_NODES];
vp9_prob pre_coef_probs_8x8 [BLOCK_TYPES_8X8] [COEF_BANDS]
[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];
vp9_coeff_probs pre_coef_probs_4x4[BLOCK_TYPES_4X4];
vp9_coeff_probs pre_hybrid_coef_probs_4x4[BLOCK_TYPES_4X4];
vp9_coeff_probs pre_coef_probs_8x8[BLOCK_TYPES_8X8];
vp9_coeff_probs pre_hybrid_coef_probs_8x8[BLOCK_TYPES_8X8];
vp9_coeff_probs pre_coef_probs_16x16[BLOCK_TYPES_16X16];
vp9_coeff_probs pre_hybrid_coef_probs_16x16[BLOCK_TYPES_16X16];
#if CONFIG_TX32X32 && CONFIG_SUPERBLOCKS
vp9_prob pre_coef_probs_32x32 [BLOCK_TYPES_32X32] [COEF_BANDS]
[PREV_COEF_CONTEXTS] [ENTROPY_NODES];
vp9_coeff_probs pre_coef_probs_32x32[BLOCK_TYPES_32X32];
#endif
unsigned int coef_counts [BLOCK_TYPES] [COEF_BANDS]
[PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS];
unsigned int hybrid_coef_counts [BLOCK_TYPES] [COEF_BANDS]
[PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS];
unsigned int coef_counts_8x8 [BLOCK_TYPES_8X8] [COEF_BANDS]
[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];
vp9_coeff_count coef_counts_4x4[BLOCK_TYPES_4X4];
vp9_coeff_count hybrid_coef_counts_4x4[BLOCK_TYPES_4X4];
vp9_coeff_count coef_counts_8x8[BLOCK_TYPES_8X8];
vp9_coeff_count hybrid_coef_counts_8x8[BLOCK_TYPES_8X8];
vp9_coeff_count coef_counts_16x16[BLOCK_TYPES_16X16];
vp9_coeff_count hybrid_coef_counts_16x16[BLOCK_TYPES_16X16];
#if CONFIG_TX32X32 && CONFIG_SUPERBLOCKS
unsigned int coef_counts_32x32 [BLOCK_TYPES_32X32] [COEF_BANDS]
[PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS];
vp9_coeff_count coef_counts_32x32[BLOCK_TYPES_32X32];
#endif
nmv_context_counts NMVcount;
......
......@@ -1231,14 +1231,13 @@ static void init_frame(VP9D_COMP *pbi) {
}
static void read_coef_probs_common(
BOOL_DECODER* const bc,
vp9_prob coef_probs[BLOCK_TYPES][COEF_BANDS]
[PREV_COEF_CONTEXTS][ENTROPY_NODES]) {
static void read_coef_probs_common(BOOL_DECODER* const bc,
vp9_coeff_probs *coef_probs,
int block_types) {
int i, j, k, l;
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++) {
/* NB: This j loop starts from 1 on block type i == 0 */
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) {
VP9_COMMON *const pc = &pbi->common;
read_coef_probs_common(bc, pc->fc.coef_probs);
read_coef_probs_common(bc, pc->fc.hybrid_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_4x4, BLOCK_TYPES_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.hybrid_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, BLOCK_TYPES_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.hybrid_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,
BLOCK_TYPES_16X16);
}
#if CONFIG_TX32X32 && CONFIG_SUPERBLOCKS
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
}
......@@ -1619,10 +1619,10 @@ int vp9_decode_frame(VP9D_COMP *pbi, const unsigned char **p_data_end) {
fclose(z);
}
vp9_copy(pbi->common.fc.pre_coef_probs,
pbi->common.fc.coef_probs);
vp9_copy(pbi->common.fc.pre_hybrid_coef_probs,
pbi->common.fc.hybrid_coef_probs);
vp9_copy(pbi->common.fc.pre_coef_probs_4x4,
pbi->common.fc.coef_probs_4x4);
vp9_copy(pbi->common.fc.pre_hybrid_coef_probs_4x4,
pbi->common.fc.hybrid_coef_probs_4x4);
vp9_copy(pbi->common.fc.pre_coef_probs_8x8,
pbi->common.fc.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;
#endif
pbi->common.fc.pre_nmvc = pbi->common.fc.nmvc;
vp9_zero(pbi->common.fc.coef_counts);
vp9_zero(pbi->common.fc.hybrid_coef_counts);
vp9_zero(pbi->common.fc.coef_counts_4x4);
vp9_zero(pbi->common.fc.hybrid_coef_counts_4x4);
vp9_zero(pbi->common.fc.coef_counts_8x8);
vp9_zero(pbi->common.fc.hybrid_coef_counts_8x8);
vp9_zero(pbi->common.fc.coef_counts_16x16);
......
......@@ -100,10 +100,10 @@ static int get_signed(BOOL_DECODER *br, int value_to_sign) {
return v;
}
#define INCREMENT_COUNT(token) \
do { \
coef_counts[coef_bands[c]][pt][token]++; \
pt = vp9_prev_token_class[token]; \
#define INCREMENT_COUNT(token) \
do { \
coef_counts[type][coef_bands[c]][pt][token]++; \
pt = vp9_prev_token_class[token]; \
} while (0)
#define WRITE_COEF_CONTINUE(val, token) \
......@@ -130,42 +130,43 @@ static int decode_coefs(VP9D_COMP *dx, const MACROBLOCKD *xd,
const int *coef_bands) {
FRAME_CONTEXT *const fc = &dx->common.fc;
int pt, c = (type == PLANE_TYPE_Y_NO_DC);
vp9_prob (*coef_probs)[PREV_COEF_CONTEXTS][ENTROPY_NODES], *prob;
unsigned int (*coef_counts)[PREV_COEF_CONTEXTS][MAX_ENTROPY_TOKENS];
vp9_coeff_probs *coef_probs;
vp9_prob *prob;
vp9_coeff_count *coef_counts;
switch (txfm_size) {
default:
case TX_4X4:
if (tx_type == DCT_DCT) {
coef_probs = fc->coef_probs[type];
coef_counts = fc->coef_counts[type];
coef_probs = fc->coef_probs_4x4;
coef_counts = fc->coef_counts_4x4;
} else {
coef_probs = fc->hybrid_coef_probs[type];
coef_counts = fc->hybrid_coef_counts[type];
coef_probs = fc->hybrid_coef_probs_4x4;
coef_counts = fc->hybrid_coef_counts_4x4;
}
break;
case TX_8X8:
if (tx_type == DCT_DCT) {
coef_probs = fc->coef_probs_8x8[type];
coef_counts = fc->coef_counts_8x8[type];
coef_probs = fc->coef_probs_8x8;
coef_counts = fc->coef_counts_8x8;
} else {
coef_probs = fc->hybrid_coef_probs_8x8[type];
coef_counts = fc->hybrid_coef_counts_8x8[type];
coef_probs = fc->hybrid_coef_probs_8x8;
coef_counts = fc->hybrid_coef_counts_8x8;
}
break;
case TX_16X16:
if (tx_type == DCT_DCT) {
coef_probs = fc->coef_probs_16x16[type];
coef_counts = fc->coef_counts_16x16[type];
coef_probs = fc->coef_probs_16x16;
coef_counts = fc->coef_counts_16x16;
} else {
coef_probs = fc->hybrid_coef_probs_16x16[type];
coef_counts = fc->hybrid_coef_counts_16x16[type];
coef_probs = fc->hybrid_coef_probs_16x16;
coef_counts = fc->hybrid_coef_counts_16x16;
}
break;
#if CONFIG_TX32X32 && CONFIG_SUPERBLOCKS
case TX_32X32:
coef_probs = fc->coef_probs_32x32[type];
coef_counts = fc->coef_counts_32x32[type];
coef_probs = fc->coef_probs_32x32;
coef_counts = fc->coef_counts_32x32;
break;
#endif
}
......@@ -175,7 +176,7 @@ static int decode_coefs(VP9D_COMP *dx, const MACROBLOCKD *xd,
int val;
const uint8_t *cat6 = cat6_prob;
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]))
break;
SKIP_START:
......@@ -183,7 +184,7 @@ SKIP_START:
if (!vp9_read(br, prob[ZERO_CONTEXT_NODE])) {
INCREMENT_COUNT(ZERO_TOKEN);
++c;