Split coefficient token tables intra vs. inter.

Change-Id: I5416455f8f129ca0f450d00e48358d2012605072
This commit is contained in:
Ronald S. Bultje 2013-02-19 13:36:38 -08:00
parent c17672a33d
commit 0c9e2e9a1d
17 changed files with 876 additions and 1036 deletions

File diff suppressed because it is too large Load Diff

View File

@ -255,19 +255,10 @@ int vp9_get_coef_context(int * recent_energy, int token) {
void vp9_default_coef_probs(VP9_COMMON *pc) {
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));
vpx_memcpy(pc->fc.hybrid_coef_probs_8x8, default_hybrid_coef_probs_8x8,
sizeof(pc->fc.hybrid_coef_probs_8x8));
vpx_memcpy(pc->fc.coef_probs_16x16, default_coef_probs_16x16,
sizeof(pc->fc.coef_probs_16x16));
vpx_memcpy(pc->fc.hybrid_coef_probs_16x16,
default_hybrid_coef_probs_16x16,
sizeof(pc->fc.hybrid_coef_probs_16x16));
vpx_memcpy(pc->fc.coef_probs_32x32, default_coef_probs_32x32,
sizeof(pc->fc.coef_probs_32x32));
}
@ -290,28 +281,30 @@ 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, l, count;
unsigned int branch_ct[ENTROPY_NODES][2];
vp9_prob coef_probs[ENTROPY_NODES];
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 && 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]);
for (t = 0; t < ENTROPY_NODES; ++t) {
count = branch_ct[t][0] + branch_ct[t][1];
count = count > count_sat ? count_sat : count;
factor = (update_factor * count / count_sat);
dst_coef_probs[i][j][k][t] = weighted_prob(pre_coef_probs[i][j][k][t],
coef_probs[t], factor);
for (j = 0; j < REF_TYPES; ++j)
for (k = 0; k < COEF_BANDS; ++k)
for (l = 0; l < PREV_COEF_CONTEXTS; ++l) {
if (l >= 3 && k == 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][l]);
for (t = 0; t < ENTROPY_NODES; ++t) {
count = branch_ct[t][0] + branch_ct[t][1];
count = count > count_sat ? count_sat : count;
factor = (update_factor * count / count_sat);
dst_coef_probs[i][j][k][l][t] =
weighted_prob(pre_coef_probs[i][j][k][l][t],
coef_probs[t], factor);
}
}
}
}
void vp9_adapt_coef_probs(VP9_COMMON *cm) {
@ -333,85 +326,14 @@ void vp9_adapt_coef_probs(VP9_COMMON *cm) {
count_sat = COEF_COUNT_SAT;
}
#ifdef COEF_COUNT_TESTING
{
printf("static const unsigned int\ncoef_counts"
"[BLOCK_TYPES] [COEF_BANDS]"
"[PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS] = {\n");
for (i = 0; i < BLOCK_TYPES; ++i) {
printf(" {\n");
for (j = 0; j < COEF_BANDS; ++j) {
printf(" {\n");
for (k = 0; k < PREV_COEF_CONTEXTS; ++k) {
printf(" {");
for (t = 0; t < MAX_ENTROPY_TOKENS; ++t)
printf("%d, ", cm->fc.coef_counts[i][j][k][t]);
printf("},\n");
}
printf(" },\n");
}
printf(" },\n");
}
printf("};\n");
printf("static const unsigned int\ncoef_counts_8x8"
"[BLOCK_TYPES_8X8] [COEF_BANDS]"
"[PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS] = {\n");
for (i = 0; i < BLOCK_TYPES_8X8; ++i) {
printf(" {\n");
for (j = 0; j < COEF_BANDS; ++j) {
printf(" {\n");
for (k = 0; k < PREV_COEF_CONTEXTS; ++k) {
printf(" {");
for (t = 0; t < MAX_ENTROPY_TOKENS; ++t)
printf("%d, ", cm->fc.coef_counts_8x8[i][j][k][t]);
printf("},\n");
}
printf(" },\n");
}
printf(" },\n");
}
printf("};\n");
printf("static const unsigned int\nhybrid_coef_counts"
"[BLOCK_TYPES] [COEF_BANDS]"
"[PREV_COEF_CONTEXTS] [MAX_ENTROPY_TOKENS] = {\n");
for (i = 0; i < BLOCK_TYPES; ++i) {
printf(" {\n");
for (j = 0; j < COEF_BANDS; ++j) {
printf(" {\n");
for (k = 0; k < PREV_COEF_CONTEXTS; ++k) {
printf(" {");
for (t = 0; t < MAX_ENTROPY_TOKENS; ++t)
printf("%d, ", cm->fc.hybrid_coef_counts[i][j][k][t]);
printf("},\n");
}
printf(" },\n");
}
printf(" },\n");
}
printf("};\n");
}
#endif
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_HYBRID, cm->fc.hybrid_coef_counts_4x4,
BLOCK_TYPES, cm->fc.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_HYBRID, cm->fc.hybrid_coef_counts_8x8,
BLOCK_TYPES, cm->fc.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_HYBRID, cm->fc.hybrid_coef_counts_16x16,
BLOCK_TYPES, cm->fc.coef_counts_16x16,
count_sat, update_factor);
update_coef_probs(cm->fc.coef_probs_32x32, cm->fc.pre_coef_probs_32x32,
BLOCK_TYPES_32X32, cm->fc.coef_counts_32x32,

View File

@ -60,16 +60,9 @@ 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 with DC, 1 = UV */
#define BLOCK_TYPES_4X4 2
#define BLOCK_TYPES_4X4_HYBRID 1
#define BLOCK_TYPES_8X8 2
#define BLOCK_TYPES_8X8_HYBRID 1
#define BLOCK_TYPES_16X16 2
#define BLOCK_TYPES_16X16_HYBRID 1
#define BLOCK_TYPES 2
#define BLOCK_TYPES_32X32 1
#define REF_TYPES 2 // intra=0, inter=1
/* Middle dimension reflects the coefficient position within the transform. */
#define COEF_BANDS 6
@ -93,11 +86,11 @@ extern vp9_extra_bit_struct vp9_extra_bits[12]; /* indexed by token value */
/*# define DC_TOKEN_CONTEXTS 3*/ /* 00, 0!0, !0!0 */
#define PREV_COEF_CONTEXTS 6
typedef unsigned int vp9_coeff_count[COEF_BANDS][PREV_COEF_CONTEXTS]
typedef unsigned int vp9_coeff_count[REF_TYPES][COEF_BANDS][PREV_COEF_CONTEXTS]
[MAX_ENTROPY_TOKENS];
typedef unsigned int vp9_coeff_stats[COEF_BANDS][PREV_COEF_CONTEXTS]
typedef unsigned int vp9_coeff_stats[REF_TYPES][COEF_BANDS][PREV_COEF_CONTEXTS]
[ENTROPY_NODES][2];
typedef vp9_prob vp9_coeff_probs[COEF_BANDS][PREV_COEF_CONTEXTS]
typedef vp9_prob vp9_coeff_probs[REF_TYPES][COEF_BANDS][PREV_COEF_CONTEXTS]
[ENTROPY_NODES];
#define SUBEXP_PARAM 4 /* Subexponential code parameter */

View File

@ -54,12 +54,9 @@ 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_coeff_probs coef_probs_4x4[BLOCK_TYPES_4X4];
vp9_coeff_probs hybrid_coef_probs_4x4[BLOCK_TYPES_4X4_HYBRID];
vp9_coeff_probs coef_probs_8x8[BLOCK_TYPES_8X8];
vp9_coeff_probs hybrid_coef_probs_8x8[BLOCK_TYPES_8X8_HYBRID];
vp9_coeff_probs coef_probs_16x16[BLOCK_TYPES_16X16];
vp9_coeff_probs hybrid_coef_probs_16x16[BLOCK_TYPES_16X16_HYBRID];
vp9_coeff_probs coef_probs_4x4[BLOCK_TYPES];
vp9_coeff_probs coef_probs_8x8[BLOCK_TYPES];
vp9_coeff_probs coef_probs_16x16[BLOCK_TYPES];
vp9_coeff_probs coef_probs_32x32[BLOCK_TYPES_32X32];
nmv_context nmvc;
@ -79,20 +76,14 @@ typedef struct frame_contexts {
unsigned int sub_mv_ref_counts[SUBMVREF_COUNT][VP9_SUBMVREFS];
unsigned int mbsplit_counts[VP9_NUMMBSPLITS];
vp9_coeff_probs pre_coef_probs_4x4[BLOCK_TYPES_4X4];
vp9_coeff_probs pre_hybrid_coef_probs_4x4[BLOCK_TYPES_4X4_HYBRID];
vp9_coeff_probs pre_coef_probs_8x8[BLOCK_TYPES_8X8];
vp9_coeff_probs pre_hybrid_coef_probs_8x8[BLOCK_TYPES_8X8_HYBRID];
vp9_coeff_probs pre_coef_probs_16x16[BLOCK_TYPES_16X16];
vp9_coeff_probs pre_hybrid_coef_probs_16x16[BLOCK_TYPES_16X16_HYBRID];
vp9_coeff_probs pre_coef_probs_4x4[BLOCK_TYPES];
vp9_coeff_probs pre_coef_probs_8x8[BLOCK_TYPES];
vp9_coeff_probs pre_coef_probs_16x16[BLOCK_TYPES];
vp9_coeff_probs pre_coef_probs_32x32[BLOCK_TYPES_32X32];
vp9_coeff_count coef_counts_4x4[BLOCK_TYPES_4X4];
vp9_coeff_count hybrid_coef_counts_4x4[BLOCK_TYPES_4X4_HYBRID];
vp9_coeff_count coef_counts_8x8[BLOCK_TYPES_8X8];
vp9_coeff_count hybrid_coef_counts_8x8[BLOCK_TYPES_8X8_HYBRID];
vp9_coeff_count coef_counts_16x16[BLOCK_TYPES_16X16];
vp9_coeff_count hybrid_coef_counts_16x16[BLOCK_TYPES_16X16_HYBRID];
vp9_coeff_count coef_counts_4x4[BLOCK_TYPES];
vp9_coeff_count coef_counts_8x8[BLOCK_TYPES];
vp9_coeff_count coef_counts_16x16[BLOCK_TYPES];
vp9_coeff_count coef_counts_32x32[BLOCK_TYPES_32X32];
nmv_context_counts NMVcount;

View File

@ -143,6 +143,8 @@ static void kfread_modes(VP9D_COMP *pbi,
int map_index = mb_row * pbi->common.mb_cols + mb_col;
MB_PREDICTION_MODE y_mode;
m->mbmi.ref_frame = INTRA_FRAME;
// Read the Macroblock segmentation map if it is being updated explicitly
// this frame (reset to 0 by default).
m->mbmi.segment_id = 0;

View File

@ -1170,20 +1170,21 @@ static void init_frame(VP9D_COMP *pbi) {
static void read_coef_probs_common(BOOL_DECODER* const bc,
vp9_coeff_probs *coef_probs,
int block_types) {
int i, j, k, l;
int i, j, k, l, m;
if (vp9_read_bit(bc)) {
for (i = 0; i < block_types; i++) {
for (j = 0; j < COEF_BANDS; j++) {
/* NB: This j loop starts from 1 on block type i == 0 */
for (k = 0; k < PREV_COEF_CONTEXTS; k++) {
if (k >= 3 && j == 0)
continue;
for (l = 0; l < ENTROPY_NODES; l++) {
vp9_prob *const p = coef_probs[i][j][k] + l;
for (j = 0; j < REF_TYPES; j++) {
for (k = 0; k < COEF_BANDS; k++) {
for (l = 0; l < PREV_COEF_CONTEXTS; l++) {
if (l >= 3 && k == 0)
continue;
for (m = 0; m < ENTROPY_NODES; m++) {
vp9_prob *const p = coef_probs[i][j][k][l] + m;
if (vp9_read(bc, COEF_UPDATE_PROB)) {
*p = read_prob_diff_update(bc, *p);
if (vp9_read(bc, COEF_UPDATE_PROB)) {
*p = read_prob_diff_update(bc, *p);
}
}
}
}
@ -1195,19 +1196,13 @@ static void read_coef_probs_common(BOOL_DECODER* const bc,
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_4x4, BLOCK_TYPES_4X4);
read_coef_probs_common(bc, pc->fc.hybrid_coef_probs_4x4,
BLOCK_TYPES_4X4_HYBRID);
read_coef_probs_common(bc, pc->fc.coef_probs_4x4, BLOCK_TYPES);
if (pbi->common.txfm_mode != ONLY_4X4) {
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_HYBRID);
read_coef_probs_common(bc, pc->fc.coef_probs_8x8, BLOCK_TYPES);
}
if (pbi->common.txfm_mode > ALLOW_8X8) {
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_HYBRID);
read_coef_probs_common(bc, pc->fc.coef_probs_16x16, BLOCK_TYPES);
}
if (pbi->common.txfm_mode > ALLOW_16X16) {
read_coef_probs_common(bc, pc->fc.coef_probs_32x32, BLOCK_TYPES_32X32);
@ -1582,16 +1577,10 @@ int vp9_decode_frame(VP9D_COMP *pbi, const unsigned char **p_data_end) {
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,
pbi->common.fc.hybrid_coef_probs_8x8);
vp9_copy(pbi->common.fc.pre_coef_probs_16x16,
pbi->common.fc.coef_probs_16x16);
vp9_copy(pbi->common.fc.pre_hybrid_coef_probs_16x16,
pbi->common.fc.hybrid_coef_probs_16x16);
vp9_copy(pbi->common.fc.pre_coef_probs_32x32,
pbi->common.fc.coef_probs_32x32);
vp9_copy(pbi->common.fc.pre_ymode_prob, pbi->common.fc.ymode_prob);
@ -1606,11 +1595,8 @@ int vp9_decode_frame(VP9D_COMP *pbi, const unsigned char **p_data_end) {
#endif
pbi->common.fc.pre_nmvc = pbi->common.fc.nmvc;
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);
vp9_zero(pbi->common.fc.hybrid_coef_counts_16x16);
vp9_zero(pbi->common.fc.coef_counts_32x32);
vp9_zero(pbi->common.fc.ymode_counts);
vp9_zero(pbi->common.fc.sb_ymode_counts);

View File

@ -65,7 +65,7 @@ static int get_signed(BOOL_DECODER *br, int value_to_sign) {
#define INCREMENT_COUNT(token) \
do { \
coef_counts[type][get_coef_band(txfm_size, c)][pt][token]++; \
coef_counts[type][ref][get_coef_band(txfm_size, c)][pt][token]++; \
pt = vp9_get_coef_context(&recent_energy, token); \
} while (0)
@ -99,39 +99,25 @@ static int decode_coefs(VP9D_COMP *dx, const MACROBLOCKD *xd,
vp9_coeff_probs *coef_probs;
vp9_prob *prob;
vp9_coeff_count *coef_counts;
const int ref = xd->mode_info_context->mbmi.ref_frame != INTRA_FRAME;
switch (txfm_size) {
default:
case TX_4X4:
if (tx_type == DCT_DCT) {
coef_probs = fc->coef_probs_4x4;
coef_counts = fc->coef_counts_4x4;
} else {
coef_probs = fc->hybrid_coef_probs_4x4;
coef_counts = fc->hybrid_coef_counts_4x4;
}
coef_probs = fc->coef_probs_4x4;
coef_counts = fc->coef_counts_4x4;
break;
case TX_8X8:
if (tx_type == DCT_DCT) {
coef_probs = fc->coef_probs_8x8;
coef_counts = fc->coef_counts_8x8;
} else {
coef_probs = fc->hybrid_coef_probs_8x8;
coef_counts = fc->hybrid_coef_counts_8x8;
}
coef_probs = fc->coef_probs_8x8;
coef_counts = fc->coef_counts_8x8;
#if CONFIG_CNVCONTEXT
above_ec = (A0[aidx] + A0[aidx + 1]) != 0;
left_ec = (L0[lidx] + L0[lidx + 1]) != 0;
#endif
break;
case TX_16X16:
if (tx_type == DCT_DCT) {
coef_probs = fc->coef_probs_16x16;
coef_counts = fc->coef_counts_16x16;
} else {
coef_probs = fc->hybrid_coef_probs_16x16;
coef_counts = fc->hybrid_coef_counts_16x16;
}
coef_probs = fc->coef_probs_16x16;
coef_counts = fc->coef_counts_16x16;
#if CONFIG_CNVCONTEXT
if (type == PLANE_TYPE_UV) {
ENTROPY_CONTEXT *A1 = (ENTROPY_CONTEXT *) (xd->above_context + 1);
@ -176,7 +162,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[type][get_coef_band(txfm_size, c)][pt];
prob = coef_probs[type][ref][get_coef_band(txfm_size, c)][pt];
if (!vp9_read(br, prob[EOB_CONTEXT_NODE]))
break;
SKIP_START:
@ -184,7 +170,7 @@ SKIP_START:
if (!vp9_read(br, prob[ZERO_CONTEXT_NODE])) {
INCREMENT_COUNT(ZERO_TOKEN);
++c;
prob = coef_probs[type][get_coef_band(txfm_size, c)][pt];
prob = coef_probs[type][ref][get_coef_band(txfm_size, c)][pt];
goto SKIP_START;
}
// ONE_CONTEXT_NODE_0_
@ -248,7 +234,7 @@ SKIP_START:
}
if (c < seg_eob)
coef_counts[type][get_coef_band(txfm_size, c)][pt][DCT_EOB_TOKEN]++;
coef_counts[type][ref][get_coef_band(txfm_size, c)][pt][DCT_EOB_TOKEN]++;
A0[aidx] = L0[lidx] = (c > 0);
if (txfm_size >= TX_8X8) {

View File

@ -42,12 +42,9 @@ unsigned __int64 Sectionbits[500];
int intra_mode_stats[VP9_KF_BINTRAMODES]
[VP9_KF_BINTRAMODES]
[VP9_KF_BINTRAMODES];
vp9_coeff_stats tree_update_hist_4x4[BLOCK_TYPES_4X4];
vp9_coeff_stats hybrid_tree_update_hist_4x4[BLOCK_TYPES_4X4_HYBRID];
vp9_coeff_stats tree_update_hist_8x8[BLOCK_TYPES_8X8];
vp9_coeff_stats hybrid_tree_update_hist_8x8[BLOCK_TYPES_8X8_HYBRID];
vp9_coeff_stats tree_update_hist_16x16[BLOCK_TYPES_16X16];
vp9_coeff_stats hybrid_tree_update_hist_16x16[BLOCK_TYPES_16X16_HYBRID];
vp9_coeff_stats tree_update_hist_4x4[BLOCK_TYPES];
vp9_coeff_stats tree_update_hist_8x8[BLOCK_TYPES];
vp9_coeff_stats tree_update_hist_16x16[BLOCK_TYPES];
vp9_coeff_stats tree_update_hist_32x32[BLOCK_TYPES_32X32];
extern unsigned int active_section;
@ -1145,20 +1142,23 @@ static void write_modes(VP9_COMP *cpi, vp9_writer* const bc,
/* This function is used for debugging probability trees. */
static void print_prob_tree(vp9_coeff_probs *coef_probs) {
static void print_prob_tree(vp9_coeff_probs *coef_probs, int block_types) {
/* print coef probability tree */
int i, j, k, l;
int i, j, k, l, m;
FILE *f = fopen("enc_tree_probs.txt", "a");
fprintf(f, "{\n");
for (i = 0; i < BLOCK_TYPES_4X4; i++) {
for (i = 0; i < block_types; 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 < ENTROPY_NODES; l++) {
fprintf(f, "%3u, ",
(unsigned int)(coef_probs [i][j][k][l]));
for (j = 0; j < REF_TYPES; ++j) {
fprintf(f, " {\n");
for (k = 0; k < COEF_BANDS; k++) {
fprintf(f, " {\n");
for (l = 0; l < PREV_COEF_CONTEXTS; l++) {
fprintf(f, " {");
for (m = 0; m < ENTROPY_NODES; m++) {
fprintf(f, "%3u, ",
(unsigned int)(coef_probs[i][j][k][l][m]));
}
}
fprintf(f, " }\n");
}
@ -1178,26 +1178,28 @@ static void build_tree_distribution(vp9_coeff_probs *coef_probs,
#endif
vp9_coeff_stats *coef_branch_ct,
int block_types) {
int i = 0, j, k;
int i, j, k, l;
#ifdef ENTROPY_STATS
int t = 0;
#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 && j == 0)
continue;
vp9_tree_probs_from_distribution(MAX_ENTROPY_TOKENS,
vp9_coef_encodings, vp9_coef_tree,
coef_probs[i][j][k],
coef_branch_ct[i][j][k],
coef_counts[i][j][k]);
for (j = 0; j < REF_TYPES; ++j) {
for (k = 0; k < COEF_BANDS; ++k) {
for (l = 0; l < PREV_COEF_CONTEXTS; ++l) {
if (l >= 3 && k == 0)
continue;
vp9_tree_probs_from_distribution(MAX_ENTROPY_TOKENS,
vp9_coef_encodings, vp9_coef_tree,
coef_probs[i][j][k][l],
coef_branch_ct[i][j][k][l],
coef_counts[i][j][k][l]);
#ifdef ENTROPY_STATS
if (!cpi->dummy_packing)
for (t = 0; t < MAX_ENTROPY_TOKENS; ++t)
context_counters[i][j][k][t] += coef_counts[i][j][k][t];
context_counters[i][j][k][l][t] += coef_counts[i][j][k][l][t];
#endif
}
}
}
}
@ -1209,40 +1211,19 @@ static void build_coeff_contexts(VP9_COMP *cpi) {
#ifdef ENTROPY_STATS
cpi, context_counters_4x4,
#endif
cpi->frame_branch_ct_4x4, BLOCK_TYPES_4X4);
build_tree_distribution(cpi->frame_hybrid_coef_probs_4x4,
cpi->hybrid_coef_counts_4x4,
#ifdef ENTROPY_STATS
cpi, hybrid_context_counters_4x4,
#endif
cpi->frame_hybrid_branch_ct_4x4,
BLOCK_TYPES_4X4_HYBRID);
cpi->frame_branch_ct_4x4, BLOCK_TYPES);
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_HYBRID);
cpi->frame_branch_ct_8x8, BLOCK_TYPES);
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_HYBRID);
cpi->frame_branch_ct_16x16, BLOCK_TYPES);
build_tree_distribution(cpi->frame_coef_probs_32x32,
cpi->coef_counts_32x32,
#ifdef ENTROPY_STATS
@ -1260,7 +1241,7 @@ static void update_coef_probs_common(vp9_writer* const bc,
vp9_coeff_probs *old_frame_coef_probs,
vp9_coeff_stats *frame_branch_ct,
int block_types) {
int i, j, k, t;
int i, j, k, l, t;
int update[2] = {0, 0};
int savings;
// vp9_prob bestupd = find_coef_update_prob(cpi);
@ -1268,39 +1249,39 @@ static void update_coef_probs_common(vp9_writer* const bc,
/* dry run to see if there is any udpate at all needed */
savings = 0;
for (i = 0; i < block_types; ++i) {
for (j = 0; j < COEF_BANDS; ++j) {
int prev_coef_savings[ENTROPY_NODES] = {0};
for (k = 0; k < PREV_COEF_CONTEXTS; ++k) {
for (t = 0; t < ENTROPY_NODES; ++t) {
vp9_prob newp = new_frame_coef_probs[i][j][k][t];
const vp9_prob oldp = old_frame_coef_probs[i][j][k][t];
const vp9_prob upd = COEF_UPDATE_PROB;
int s = prev_coef_savings[t];
int u = 0;
for (j = 0; j < REF_TYPES; ++j) {
for (k = 0; k < COEF_BANDS; ++k) {
int prev_coef_savings[ENTROPY_NODES] = {0};
for (l = 0; l < PREV_COEF_CONTEXTS; ++l) {
for (t = 0; t < ENTROPY_NODES; ++t) {
vp9_prob newp = new_frame_coef_probs[i][j][k][l][t];
const vp9_prob oldp = old_frame_coef_probs[i][j][k][l][t];
const vp9_prob upd = COEF_UPDATE_PROB;
int s = prev_coef_savings[t];
int u = 0;
if (k >= 3 && j == 0)
continue;
if (l >= 3 && k == 0)
continue;
#if defined(SEARCH_NEWP)
s = prob_diff_update_savings_search(
frame_branch_ct[i][j][k][t],
oldp, &newp, upd);
if (s > 0 && newp != oldp)
u = 1;
if (u)
savings += s - (int)(vp9_cost_zero(upd));
else
savings -= (int)(vp9_cost_zero(upd));
s = prob_diff_update_savings_search(frame_branch_ct[i][j][k][l][t],
oldp, &newp, upd);
if (s > 0 && newp != oldp)
u = 1;
if (u)
savings += s - (int)(vp9_cost_zero(upd));
else
savings -= (int)(vp9_cost_zero(upd));
#else
s = prob_update_savings(
frame_branch_ct[i][j][k][t],
oldp, newp, upd);
if (s > 0)
u = 1;
if (u)
savings += s;
s = prob_update_savings(frame_branch_ct[i][j][k][l][t],
oldp, newp, upd);
if (s > 0)
u = 1;
if (u)
savings += s;
#endif
update[u]++;
update[u]++;
}
}
}
}
@ -1313,41 +1294,42 @@ static void update_coef_probs_common(vp9_writer* const bc,
} else {
vp9_write_bit(bc, 1);
for (i = 0; i < block_types; ++i) {
for (j = 0; j < COEF_BANDS; ++j) {
int prev_coef_savings[ENTROPY_NODES] = {0};
for (k = 0; k < PREV_COEF_CONTEXTS; ++k) {
// calc probs and branch cts for this frame only
for (t = 0; t < ENTROPY_NODES; ++t) {
vp9_prob newp = new_frame_coef_probs[i][j][k][t];
vp9_prob *oldp = old_frame_coef_probs[i][j][k] + t;
const vp9_prob upd = COEF_UPDATE_PROB;
int s = prev_coef_savings[t];
int u = 0;
if (k >= 3 && j == 0)
continue;
for (j = 0; j < REF_TYPES; ++j) {
for (k = 0; k < COEF_BANDS; ++k) {
int prev_coef_savings[ENTROPY_NODES] = {0};
for (l = 0; l < PREV_COEF_CONTEXTS; ++l) {
// calc probs and branch cts for this frame only
for (t = 0; t < ENTROPY_NODES; ++t) {
vp9_prob newp = new_frame_coef_probs[i][j][k][l][t];
vp9_prob *oldp = old_frame_coef_probs[i][j][k][l] + t;
const vp9_prob upd = COEF_UPDATE_PROB;
int s = prev_coef_savings[t];
int u = 0;
if (l >= 3 && k == 0)
continue;
#if defined(SEARCH_NEWP)
s = prob_diff_update_savings_search(
frame_branch_ct[i][j][k][t],
*oldp, &newp, upd);
if (s > 0 && newp != *oldp)
u = 1;
s = prob_diff_update_savings_search(
frame_branch_ct[i][j][k][l][t],
*oldp, &newp, upd);
if (s > 0 && newp != *oldp)
u = 1;
#else
s = prob_update_savings(
frame_branch_ct[i][j][k][t],
*oldp, newp, upd);
if (s > 0)
u = 1;
s = prob_update_savings(frame_branch_ct[i][j][k][l][t],
*oldp, newp, upd);
if (s > 0)
u = 1;
#endif
vp9_write(bc, u, upd);
vp9_write(bc, u, upd);
#ifdef ENTROPY_STATS
if (!cpi->dummy_packing)
++tree_update_hist[i][j][k][t][u];
if (!cpi->dummy_packing)
++tree_update_hist[i][j][k][l][t][u];
#endif
if (u) {
/* send/use new probability */
write_prob_diff_update(bc, newp, *oldp);
*oldp = newp;
if (u) {
/* send/use new probability */
write_prob_diff_update(bc, newp, *oldp);
*oldp = newp;
}
}
}
}
@ -1370,17 +1352,7 @@ static void update_coef_probs(VP9_COMP* const cpi, vp9_writer* const bc) {
cpi->frame_coef_probs_4x4,
cpi->common.fc.coef_probs_4x4,
cpi->frame_branch_ct_4x4,
BLOCK_TYPES_4X4);
update_coef_probs_common(bc,
#ifdef ENTROPY_STATS
cpi,
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_HYBRID);
BLOCK_TYPES);
/* do not do this if not even allowed */
if (cpi->common.txfm_mode != ONLY_4X4) {
@ -1392,17 +1364,7 @@ static void update_coef_probs(VP9_COMP* const cpi, vp9_writer* const bc) {
cpi->frame_coef_probs_8x8,
cpi->common.fc.coef_probs_8x8,
cpi->frame_branch_ct_8x8,
BLOCK_TYPES_8X8);
update_coef_probs_common(bc,
#ifdef ENTROPY_STATS
cpi,
hybrid_tree_update_hist_8x8,
#endif
cpi->frame_hybrid_coef_probs_8x8,
cpi->common.fc.hybrid_coef_probs_8x8,
cpi->frame_hybrid_branch_ct_8x8,
BLOCK_TYPES_8X8_HYBRID);
BLOCK_TYPES);
}
if (cpi->common.txfm_mode > ALLOW_8X8) {
@ -1414,16 +1376,7 @@ static void update_coef_probs(VP9_COMP* const cpi, vp9_writer* const bc) {
cpi->frame_coef_probs_16x16,
cpi->common.fc.coef_probs_16x16,
cpi->frame_branch_ct_16x16,
BLOCK_TYPES_16X16);
update_coef_probs_common(bc,
#ifdef ENTROPY_STATS
cpi,
hybrid_tree_update_hist_16x16,
#endif
cpi->frame_hybrid_coef_probs_16x16,
cpi->common.fc.hybrid_coef_probs_16x16,
cpi->frame_hybrid_branch_ct_16x16,
BLOCK_TYPES_16X16_HYBRID);
BLOCK_TYPES);
}
if (cpi->common.txfm_mode > ALLOW_16X16) {
@ -1938,16 +1891,10 @@ void vp9_pack_bitstream(VP9_COMP *cpi, unsigned char *dest,
vp9_copy(cpi->common.fc.pre_coef_probs_4x4,
cpi->common.fc.coef_probs_4x4);
vp9_copy(cpi->common.fc.pre_hybrid_coef_probs_4x4,
cpi->common.fc.hybrid_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_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);
vp9_copy(cpi->common.fc.pre_coef_probs_32x32,
cpi->common.fc.coef_probs_32x32);
vp9_copy(cpi->common.fc.pre_sb_ymode_prob, cpi->common.fc.sb_ymode_prob);
@ -2124,19 +2071,23 @@ void vp9_pack_bitstream(VP9_COMP *cpi, unsigned char *dest,
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, m;
fprintf(f, "const vp9_coeff_prob %s = {\n", header);
for (i = 0; i < block_types; 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 < ENTROPY_NODES; l++) {
fprintf(f, "%3d, ",
get_binary_prob(tree_update_hist[i][j][k][l][0],
tree_update_hist[i][j][k][l][1]));
for (j = 0; j < REF_TYPES; j++) {
fprintf(f, " { \n");
for (k = 0; k < COEF_BANDS; k++) {
fprintf(f, " {\n");
for (l = 0; l < PREV_COEF_CONTEXTS; l++) {
fprintf(f, " {");
for (m = 0; m < ENTROPY_NODES; m++) {
fprintf(f, "%3d, ",
get_binary_prob(tree_update_hist[i][j][k][l][m][0],
tree_update_hist[i][j][k][l][m][1]));
}
fprintf(f, "},\n");
}
fprintf(f, "},\n");
}
@ -2151,24 +2102,12 @@ void print_tree_update_probs() {
FILE *f = fopen("coefupdprob.h", "w");
fprintf(f, "\n/* Update probabilities for token entropy tree. */\n\n");
print_tree_update_for_type(f, tree_update_hist_4x4, BLOCK_TYPES_4X4,
print_tree_update_for_type(f, tree_update_hist_4x4, BLOCK_TYPES,
"vp9_coef_update_probs_4x4[BLOCK_TYPES_4X4]");
print_tree_update_for_type(f, hybrid_tree_update_hist_4x4,
BLOCK_TYPES_4X4_HYBRID,
"vp9_coef_update_probs_4x4"
"[BLOCK_TYPES_4X4_HYBRID]");
print_tree_update_for_type(f, tree_update_hist_8x8, BLOCK_TYPES_8X8,
print_tree_update_for_type(f, tree_update_hist_8x8, BLOCK_TYPES,
"vp9_coef_update_probs_8x8[BLOCK_TYPES_8X8]");
print_tree_update_for_type(f, hybrid_tree_update_hist_8x8,
BLOCK_TYPES_8X8_HYBRID,
"vp9_coef_update_probs_8x8"
"[BLOCK_TYPES_8X8_HYBRID]");
print_tree_update_for_type(f, tree_update_hist_16x16, BLOCK_TYPES_16X16,
print_tree_update_for_type(f, tree_update_hist_16x16, BLOCK_TYPES,
"vp9_coef_update_probs_16x16[BLOCK_TYPES_16X16]");
print_tree_update_for_type(f, hybrid_tree_update_hist_16x16,
BLOCK_TYPES_16X16_HYBRID,
"vp9_coef_update_probs_16x16"
"[BLOCK_TYPES_16X16_HYBRID]");
print_tree_update_for_type(f, tree_update_hist_32x32, BLOCK_TYPES_32X32,
"vp9_coef_update_probs_32x32[BLOCK_TYPES_32X32]");
@ -2177,6 +2116,7 @@ void print_tree_update_probs() {
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_16x16, sizeof(tree_update_hist_16x16), 1, f);
fwrite(tree_update_hist_32x32, sizeof(tree_update_hist_32x32), 1, f);
fclose(f);
}
#endif

View File

@ -156,8 +156,7 @@ typedef struct macroblock {
unsigned char *active_ptr;
vp9_coeff_count token_costs[TX_SIZE_MAX_SB][BLOCK_TYPES_4X4];
vp9_coeff_count hybrid_token_costs[TX_SIZE_MAX_SB][BLOCK_TYPES_4X4_HYBRID];
vp9_coeff_count token_costs[TX_SIZE_MAX_SB][BLOCK_TYPES];
int optimize;

View File

@ -1291,11 +1291,8 @@ static void encode_frame_internal(VP9_COMP *cpi) {
vp9_zero(cpi->NMVcount);
vp9_zero(cpi->coef_counts_4x4);
vp9_zero(cpi->hybrid_coef_counts_4x4);
vp9_zero(cpi->coef_counts_8x8);
vp9_zero(cpi->hybrid_coef_counts_8x8);
vp9_zero(cpi->coef_counts_16x16);
vp9_zero(cpi->hybrid_coef_counts_16x16);
vp9_zero(cpi->coef_counts_32x32);
#if CONFIG_NEW_MVREF
vp9_zero(cpi->mb_mv_ref_count);

View File

@ -330,6 +330,7 @@ static int trellis_get_coeff_context(int token) {
static void optimize_b(MACROBLOCK *mb, int i, PLANE_TYPE type,
ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l,
int tx_size) {
const int ref = mb->e_mbd.mode_info_context->mbmi.ref_frame != INTRA_FRAME;
BLOCK *b = &mb->block[i];
BLOCKD *d = &mb->e_mbd.block[i];
vp9_token_state tokens[257][2];
@ -418,9 +419,9 @@ static void optimize_b(MACROBLOCK *mb, int i, PLANE_TYPE type,
band = get_coef_band(tx_size, i + 1);
pt = trellis_get_coeff_context(t0);
rate0 +=
mb->token_costs[tx_size][type][band][pt][tokens[next][0].token];
mb->token_costs[tx_size][type][ref][band][pt][tokens[next][0].token];
rate1 +=
mb->token_costs[tx_size][type][band][pt][tokens[next][1].token];
mb->token_costs[tx_size][type][ref][band][pt][tokens[next][1].token];
}
UPDATE_RD_COST();
/* And pick the best. */
@ -465,12 +466,12 @@ static void optimize_b(MACROBLOCK *mb, int i, PLANE_TYPE type,
band = get_coef_band(tx_size, i + 1);
if (t0 != DCT_EOB_TOKEN) {
pt = trellis_get_coeff_context(t0);
rate0 += mb->token_costs[tx_size][type][band][pt][
rate0 += mb->token_costs[tx_size][type][ref][band][pt][
tokens[next][0].token];
}
if (t1 != DCT_EOB_TOKEN) {
pt = trellis_get_coeff_context(t1);
rate1 += mb->token_costs[tx_size][type][band][pt][
rate1 += mb->token_costs[tx_size][type][ref][band][pt][
tokens[next][1].token];
}
}
@ -502,11 +503,13 @@ static void optimize_b(MACROBLOCK *mb, int i, PLANE_TYPE type,
t1 = tokens[next][1].token;
/* Update the cost of each path if we're past the EOB token. */
if (t0 != DCT_EOB_TOKEN) {
tokens[next][0].rate += mb->token_costs[tx_size][type][band][0][t0];
tokens[next][0].rate +=
mb->token_costs[tx_size][type][ref][band][0][t0];
tokens[next][0].token = ZERO_TOKEN;
}
if (t1 != DCT_EOB_TOKEN) {
tokens[next][1].rate += mb->token_costs[tx_size][type][band][0][t1];
tokens[next][1].rate +=
mb->token_costs[tx_size][type][ref][band][0][t1];
tokens[next][1].token = ZERO_TOKEN;
}
/* Don't update next, because we didn't add a new node. */
@ -522,8 +525,8 @@ static void optimize_b(MACROBLOCK *mb, int i, PLANE_TYPE type,
error1 = tokens[next][1].error;
t0 = tokens[next][0].token;
t1 = tokens[next][1].token;
rate0 += mb->token_costs[tx_size][type][band][pt][t0];
rate1 += mb->token_costs[tx_size][type][band][pt][t1];
rate0 += mb->token_costs[tx_size][type][ref][band][pt][t0];
rate1 += mb->token_costs[tx_size][type][ref][band][pt][t1];
UPDATE_RD_COST();
best = rd_cost1 < rd_cost0;
final_eob = i0 - 1;

View File

@ -3233,14 +3233,8 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
update_reference_frames(cpi);
vp9_copy(cpi->common.fc.coef_counts_4x4, cpi->coef_counts_4x4);
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.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.hybrid_coef_counts_16x16,
cpi->hybrid_coef_counts_16x16);
vp9_copy(cpi->common.fc.coef_counts_32x32, cpi->coef_counts_32x32);
if (!cpi->common.error_resilient_mode &&
!cpi->common.frame_parallel_decoding_mode)

View File

@ -85,12 +85,9 @@ typedef struct {
// 0 = BPRED, ZERO_MV, MV, SPLIT
signed char last_mode_lf_deltas[MAX_MODE_LF_DELTAS];
vp9_coeff_probs coef_probs_4x4[BLOCK_TYPES_4X4];
vp9_coeff_probs hybrid_coef_probs_4x4[BLOCK_TYPES_4X4_HYBRID];
vp9_coeff_probs coef_probs_8x8[BLOCK_TYPES_8X8];
vp9_coeff_probs hybrid_coef_probs_8x8[BLOCK_TYPES_8X8_HYBRID];
vp9_coeff_probs coef_probs_16x16[BLOCK_TYPES_16X16];
vp9_coeff_probs hybrid_coef_probs_16x16[BLOCK_TYPES_16X16_HYBRID];
vp9_coeff_probs coef_probs_4x4[BLOCK_TYPES];
vp9_coeff_probs coef_probs_8x8[BLOCK_TYPES];
vp9_coeff_probs coef_probs_16x16[BLOCK_TYPES];
vp9_coeff_probs coef_probs_32x32[BLOCK_TYPES_32X32];
vp9_prob sb_ymode_prob[VP9_I32X32_MODES - 1];
@ -462,26 +459,17 @@ typedef struct VP9_COMP {
nmv_context_counts NMVcount;
vp9_coeff_count coef_counts_4x4[BLOCK_TYPES_4X4];
vp9_coeff_probs frame_coef_probs_4x4[BLOCK_TYPES_4X4];
vp9_coeff_stats frame_branch_ct_4x4[BLOCK_TYPES_4X4];
vp9_coeff_count hybrid_coef_counts_4x4[BLOCK_TYPES_4X4_HYBRID];
vp9_coeff_probs frame_hybrid_coef_probs_4x4[BLOCK_TYPES_4X4_HYBRID];
vp9_coeff_stats frame_hybrid_branch_ct_4x4[BLOCK_TYPES_4X4_HYBRID];
vp9_coeff_count coef_counts_4x4[BLOCK_TYPES];
vp9_coeff_probs frame_coef_probs_4x4[BLOCK_TYPES];
vp9_coeff_stats frame_branch_ct_4x4[BLOCK_TYPES];
vp9_coeff_count coef_counts_8x8[BLOCK_TYPES_8X8];
vp9_coeff_probs frame_coef_probs_8x8[BLOCK_TYPES_8X8];
vp9_coeff_stats frame_branch_ct_8x8[BLOCK_TYPES_8X8];
vp9_coeff_count hybrid_coef_counts_8x8[BLOCK_TYPES_8X8_HYBRID];
vp9_coeff_probs frame_hybrid_coef_probs_8x8[BLOCK_TYPES_8X8_HYBRID];
vp9_coeff_stats frame_hybrid_branch_ct_8x8[BLOCK_TYPES_8X8_HYBRID];
vp9_coeff_count coef_counts_8x8[BLOCK_TYPES];
vp9_coeff_probs frame_coef_probs_8x8[BLOCK_TYPES];
vp9_coeff_stats frame_branch_ct_8x8[BLOCK_TYPES];
vp9_coeff_count coef_counts_16x16[BLOCK_TYPES_16X16];
vp9_coeff_probs frame_coef_probs_16x16[BLOCK_TYPES_16X16];
vp9_coeff_stats frame_branch_ct_16x16[BLOCK_TYPES_16X16];
vp9_coeff_count hybrid_coef_counts_16x16[BLOCK_TYPES_16X16_HYBRID];
vp9_coeff_probs frame_hybrid_coef_probs_16x16[BLOCK_TYPES_16X16_HYBRID];
vp9_coeff_stats frame_hybrid_branch_ct_16x16[BLOCK_TYPES_16X16_HYBRID];
vp9_coeff_count coef_counts_16x16[BLOCK_TYPES];
vp9_coeff_probs frame_coef_probs_16x16[BLOCK_TYPES];
vp9_coeff_stats frame_branch_ct_16x16[BLOCK_TYPES];
vp9_coeff_count coef_counts_32x32[BLOCK_TYPES_32X32];
vp9_coeff_probs frame_coef_probs_32x32[BLOCK_TYPES_32X32];

View File

@ -169,11 +169,8 @@ void vp9_save_coding_context(VP9_COMP *cpi) {
vp9_copy(cc->last_mode_lf_deltas, xd->last_mode_lf_deltas);
vp9_copy(cc->coef_probs_4x4, cm->fc.coef_probs_4x4);
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->hybrid_coef_probs_8x8, cm->fc.hybrid_coef_probs_8x8);
vp9_copy(cc->coef_probs_16x16, cm->fc.coef_probs_16x16);
vp9_copy(cc->hybrid_coef_probs_16x16, cm->fc.hybrid_coef_probs_16x16);
vp9_copy(cc->coef_probs_32x32, cm->fc.coef_probs_32x32);
vp9_copy(cc->switchable_interp_prob, cm->fc.switchable_interp_prob);
#if CONFIG_COMP_INTERINTRA_PRED
@ -227,11 +224,8 @@ void vp9_restore_coding_context(VP9_COMP *cpi) {
vp9_copy(xd->last_mode_lf_deltas, cc->last_mode_lf_deltas);
vp9_copy(cm->fc.coef_probs_4x4, cc->coef_probs_4x4);
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.hybrid_coef_probs_8x8, cc->hybrid_coef_probs_8x8);
vp9_copy(cm->fc.coef_probs_16x16, cc->coef_probs_16x16);
vp9_copy(cm->fc.hybrid_coef_probs_16x16, cc->hybrid_coef_probs_16x16);
vp9_copy(cm->fc.coef_probs_32x32, cc->coef_probs_32x32);
vp9_copy(cm->fc.switchable_interp_prob, cc->switchable_interp_prob);
#if CONFIG_COMP_INTERINTRA_PRED

View File

@ -150,20 +150,21 @@ const MODE_DEFINITION vp9_mode_order[MAX_MODES] = {
static void fill_token_costs(vp9_coeff_count *c,
vp9_coeff_probs *p,
int block_type_counts) {
int i, j, k;
int i, j, k, l;
for (i = 0; i < block_type_counts; i++)
for (j = 0; j < COEF_BANDS; j++)
for (k = 0; k < PREV_COEF_CONTEXTS; k++) {
if (k == 0 && j > 0)
vp9_cost_tokens_skip((int *)(c[i][j][k]),
p[i][j][k],
vp9_coef_tree);
else
vp9_cost_tokens((int *)(c[i][j][k]),
p[i][j][k],
vp9_coef_tree);
}
for (j = 0; j < REF_TYPES; j++)
for (k = 0; k < COEF_BANDS; k++)
for (l = 0; l < PREV_COEF_CONTEXTS; l++) {
if (l == 0 && k > 0)
vp9_cost_tokens_skip((int *)(c[i][j][k][l]),
p[i][j][k][l],
vp9_coef_tree);
else
vp9_cost_tokens((int *)(c[i][j][k][l]),
p[i][j][k][l],
vp9_coef_tree);
}
}
@ -268,23 +269,11 @@ void vp9_initialize_rd_consts(VP9_COMP *cpi, int QIndex) {
}
fill_token_costs(cpi->mb.token_costs[TX_4X4],
cpi->common.fc.coef_probs_4x4, BLOCK_TYPES_4X4);
fill_token_costs(cpi->mb.hybrid_token_costs[TX_4X4],
cpi->common.fc.hybrid_coef_probs_4x4,
BLOCK_TYPES_4X4_HYBRID);
cpi->common.fc.coef_probs_4x4, BLOCK_TYPES);
fill_token_costs(cpi->mb.token_costs[TX_8X8],
cpi->common.fc.coef_probs_8x8, BLOCK_TYPES_8X8);
fill_token_costs(cpi->mb.hybrid_token_costs[TX_8X8],
cpi->common.fc.hybrid_coef_probs_8x8,
BLOCK_TYPES_8X8_HYBRID);
cpi->common.fc.coef_probs_8x8, BLOCK_TYPES);
fill_token_costs(cpi->mb.token_costs[TX_16X16],
cpi->common.fc.coef_probs_16x16, BLOCK_TYPES_16X16);
fill_token_costs(cpi->mb.hybrid_token_costs[TX_16X16],
cpi->common.fc.hybrid_coef_probs_16x16,
BLOCK_TYPES_16X16_HYBRID);
cpi->common.fc.coef_probs_16x16, BLOCK_TYPES);
fill_token_costs(cpi->mb.token_costs[TX_32X32],
cpi->common.fc.coef_probs_32x32, BLOCK_TYPES_32X32);
@ -407,11 +396,11 @@ static INLINE int cost_coeffs(MACROBLOCK *mb,
const int segment_id = xd->mode_info_context->mbmi.segment_id;
const int *scan;
int16_t *qcoeff_ptr = b->qcoeff;
const int ref = xd->mode_info_context->mbmi.ref_frame != INTRA_FRAME;
const TX_TYPE tx_type = (type == PLANE_TYPE_Y_WITH_DC) ?
get_tx_type(xd, b) : DCT_DCT;
unsigned int (*token_costs)[PREV_COEF_CONTEXTS][MAX_ENTROPY_TOKENS] =
(tx_type == DCT_DCT) ? mb->token_costs[tx_size][type] :
mb->hybrid_token_costs[tx_size][type];
mb->token_costs[tx_size][type][ref];
ENTROPY_CONTEXT a_ec = *a, l_ec = *l;
switch (tx_size) {
@ -453,7 +442,7 @@ static INLINE int cost_coeffs(MACROBLOCK *mb,
if (vp9_segfeature_active(xd, segment_id, SEG_LVL_SKIP))
seg_eob = 0;
if (tx_type != DCT_DCT) {
{
int recent_energy = 0;
for (; c < eob; c++) {
int v = qcoeff_ptr[scan[c]];
@ -463,19 +452,7 @@ static INLINE int cost_coeffs(MACROBLOCK *mb,
pt = vp9_get_coef_context(&recent_energy, t);
}
if (c < seg_eob)
cost += mb->hybrid_token_costs[tx_size][type][get_coef_band(tx_size, c)]
[pt][DCT_EOB_TOKEN];
} else {
int recent_energy = 0;
for (; c < eob; c++) {
int v = qcoeff_ptr[scan[c]];
int t = vp9_dct_value_tokens_ptr[v].Token;
cost += token_costs[get_coef_band(tx_size, c)][pt][t];
cost += vp9_dct_value_cost_ptr[v];
pt = vp9_get_coef_context(&recent_energy, t);
}
if (c < seg_eob)
cost += mb->token_costs[tx_size][type][get_coef_band(tx_size, c)]
cost += mb->token_costs[tx_size][type][ref][get_coef_band(tx_size, c)]
[pt][DCT_EOB_TOKEN];
}

View File

@ -25,20 +25,14 @@
compressions, then generating vp9_context.c = initial stats. */
#ifdef ENTROPY_STATS
vp9_coeff_accum context_counters_4x4[BLOCK_TYPES_4X4];
vp9_coeff_accum hybrid_context_counters_4x4[BLOCK_TYPES_4X4_HYBRID];
vp9_coeff_accum context_counters_8x8[BLOCK_TYPES_8X8];
vp9_coeff_accum hybrid_context_counters_8x8[BLOCK_TYPES_8X8_HYBRID];
vp9_coeff_accum context_counters_16x16[BLOCK_TYPES_16X16];
vp9_coeff_accum hybrid_context_counters_16x16[BLOCK_TYPES_16X16_HYBRID];
vp9_coeff_accum context_counters_4x4[BLOCK_TYPES];
vp9_coeff_accum context_counters_8x8[BLOCK_TYPES];
vp9_coeff_accum context_counters_16x16[BLOCK_TYPES];
vp9_coeff_accum context_counters_32x32[BLOCK_TYPES_32X32];
extern vp9_coeff_stats tree_update_hist_4x4[BLOCK_TYPES_4X4];
extern vp9_coeff_stats hybrid_tree_update_hist_4x4[BLOCK_TYPES_4X4_HYBRID];
extern vp9_coeff_stats tree_update_hist_8x8[BLOCK_TYPES_8X8];
extern vp9_coeff_stats hybrid_tree_update_hist_8x8[BLOCK_TYPES_8X8_HYBRID];
extern vp9_coeff_stats tree_update_hist_16x16[BLOCK_TYPES_16X16];
extern vp9_coeff_stats hybrid_tree_update_hist_16x16[BLOCK_TYPES_16X16_HYBRID];
extern vp9_coeff_stats tree_update_hist_4x4[BLOCK_TYPES];
extern vp9_coeff_stats tree_update_hist_8x8[BLOCK_TYPES];
extern vp9_coeff_stats tree_update_hist_16x16[BLOCK_TYPES];
extern vp9_coeff_stats tree_update_hist_32x32[BLOCK_TYPES_32X32];
#endif /* ENTROPY_STATS */
@ -121,6 +115,7 @@ static void tokenize_b(VP9_COMP *cpi,
vp9_coeff_probs *probs;
const TX_TYPE tx_type = (type == PLANE_TYPE_Y_WITH_DC) ?
get_tx_type(xd, b) : DCT_DCT;
const int ref = xd->mode_info_context->mbmi.ref_frame != INTRA_FRAME;
ENTROPY_CONTEXT *const a = (ENTROPY_CONTEXT *)xd->above_context +
vp9_block2above[tx_size][ib];
@ -140,17 +135,14 @@ static void tokenize_b(VP9_COMP *cpi,
seg_eob = 16;
scan = vp9_default_zig_zag1d_4x4;
if (tx_type != DCT_DCT) {
counts = cpi->hybrid_coef_counts_4x4;
probs = cpi->common.fc.hybrid_coef_probs_4x4;
if (tx_type == ADST_DCT) {
scan = vp9_row_scan_4x4;
} else if (tx_type == DCT_ADST) {
scan = vp9_col_scan_4x4;
}
} else {
counts = cpi->coef_counts_4x4;
probs = cpi->common.fc.coef_probs_4x4;
}
counts = cpi->coef_counts_4x4;
probs = cpi->common.fc.coef_probs_4x4;
break;
case TX_8X8:
#if CONFIG_CNVCONTEXT
@ -159,13 +151,8 @@ static void tokenize_b(VP9_COMP *cpi,
#endif
seg_eob = 64;
scan = vp9_default_zig_zag1d_8x8;
if (tx_type != DCT_DCT) {
counts = cpi->hybrid_coef_counts_8x8;
probs = cpi->common.fc.hybrid_coef_probs_8x8;
} else {
counts = cpi->coef_counts_8x8;
probs = cpi->common.fc.coef_probs_8x8;
}
counts = cpi->coef_counts_8x8;
probs = cpi->common.fc.coef_probs_8x8;
break;
case TX_16X16:
#if CONFIG_CNVCONTEXT
@ -179,13 +166,8 @@ static void tokenize_b(VP9_COMP *cpi,
#endif
seg_eob = 256;
scan = vp9_default_zig_zag1d_16x16;
if (tx_type != DCT_DCT) {
counts = cpi->hybrid_coef_counts_16x16;
probs = cpi->common.fc.hybrid_coef_probs_16x16;
} else {
counts = cpi->coef_counts_16x16;
probs = cpi->common.fc.coef_probs_16x16;
}
counts = cpi->coef_counts_16x16;
probs = cpi->common.fc.coef_probs_16x16;
if (type == PLANE_TYPE_UV) {
int uv_idx = (ib - 16) >> 2;
qcoeff_ptr = xd->sb_coeff_data.qcoeff + 1024 + 256 * uv_idx;
@ -229,11 +211,11 @@ static void tokenize_b(VP9_COMP *cpi,
}
t->Token = token;
t->context_tree = probs[type][band][pt];
t->context_tree = probs[type][ref][band][pt];
t->skip_eob_node = (pt == 0) && (band > 0);
assert(vp9_coef_encodings[t->Token].Len - t->skip_eob_node > 0);
if (!dry_run) {
++counts[type][band][pt][token];
++counts[type][ref][band][pt][token];
}
pt = vp9_get_coef_context(&recent_energy, token);
@ -470,25 +452,13 @@ void init_context_counters(void) {
FILE *f = fopen("context.bin", "rb");
if (!f) {
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(hybrid_context_counters_8x8, 0,
sizeof(hybrid_context_counters_8x8));
vpx_memset(context_counters_16x16, 0, sizeof(context_counters_16x16));
vpx_memset(hybrid_context_counters_16x16, 0,
sizeof(hybrid_context_counters_16x16));
vpx_memset(context_counters_32x32, 0, sizeof(context_counters_32x32));
} else {
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(hybrid_context_counters_8x8,
sizeof(hybrid_context_counters_8x8), 1, f);
fread(context_counters_16x16, sizeof(context_counters_16x16), 1, f);
fread(hybrid_context_counters_16x16,
sizeof(hybrid_context_counters_16x16), 1, f);
fread(context_counters_32x32, sizeof(context_counters_32x32), 1, f);
fclose(f);
}
@ -496,25 +466,13 @@ void init_context_counters(void) {
f = fopen("treeupdate.bin", "rb");
if (!f) {
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(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(hybrid_tree_update_hist_16x16, 0,
sizeof(hybrid_tree_update_hist_16x16));
vpx_memset(tree_update_hist_32x32, 0, sizeof(tree_update_hist_32x32));
} else {
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(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(hybrid_tree_update_hist_16x16,
sizeof(hybrid_tree_update_hist_16x16), 1, f);
fread(tree_update_hist_32x32, sizeof(tree_update_hist_32x32), 1, f);
fclose(f);
}
@ -522,33 +480,38 @@ void init_context_counters(void) {
static void print_counter(FILE *f, vp9_coeff_accum *context_counters,
int block_types, const char *header) {
int type, band, pt, t;
int type, ref, band, pt, t;
fprintf(f, "static const vp9_coeff_count %s = {\n", header);
#define Comma(X) (X ? "," : "")
type = 0;
do {
ref = 0;
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;
fprintf(f, "%s\n { /* %s */", Comma(type), ref ? "Inter" : "Intra");
band = 0;
do {
fprintf(f, "%s\n {", Comma(pt));
t = 0;
fprintf(f, "%s\n { /* Coeff Band %d */", Comma(band), band);
pt = 0;
do {
const int64_t x = context_counters[type][band][pt][t];
const int y = (int) x;
fprintf(f, "%s\n {", Comma(pt));
assert(x == (int64_t) y); /* no overflow handling yet */
fprintf(f, "%s %d", Comma(t), y);
} while (++t < MAX_ENTROPY_TOKENS);
fprintf(f, "}");
} while (++pt < PREV_COEF_CONTEXTS);
t = 0;
do {
const int64_t x = context_counters[type][ref][band][pt][t];
const int y = (int) x;
assert(x == (int64_t) 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 (++band < COEF_BANDS);
} while (++ref < REF_TYPES);
fprintf(f, "\n }");
} while (++type < block_types);
fprintf(f, "\n};\n");
@ -556,7 +519,7 @@ static void print_counter(FILE *f, vp9_coeff_accum *context_counters,
static void print_probs(FILE *f, vp9_coeff_accum *context_counters,
int block_types, const char *header) {
int type, band, pt, t;
int type, ref, band, pt, t;
fprintf(f, "static const vp9_coeff_probs %s = {", header);
@ -565,32 +528,38 @@ static void print_probs(FILE *f, vp9_coeff_accum *context_counters,
do {
fprintf(f, "%s%s{ /* block Type %d */",
Comma(type), Newline(type, " "), type);
band = 0;
ref = 0;
do {
fprintf(f, "%s%s{ /* Coeff Band %d */",
Comma(band), Newline(band, " "), band);
pt = 0;
fprintf(f, "%s%s{ /* %s */",
Comma(band), Newline(band, " "), ref ? "Inter" : "Intra");
band = 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[type][band][pt][t];
vp9_tree_probs_from_distribution(MAX_ENTROPY_TOKENS,
vp9_coef_encodings, vp9_coef_tree,
coef_probs, branch_ct, coef_counts);
fprintf(f, "%s\n {", Comma(pt));
t = 0;
fprintf(f, "%s%s{ /* Coeff Band %d */",
Comma(band), Newline(band, " "), band);
pt = 0;
do {
fprintf(f, "%s %3d", Comma(t), coef_probs[t]);
} while (++t < ENTROPY_NODES);
unsigned int branch_ct[ENTROPY_NODES][2];
unsigned int coef_counts[MAX_ENTROPY_TOKENS];
vp9_prob coef_probs[ENTROPY_NODES];
fprintf(f, " }");
} while (++pt < PREV_COEF_CONTEXTS);
for (t = 0; t < MAX_ENTROPY_TOKENS; ++t)
coef_counts[t] = context_counters[type][ref][band][pt][t];
vp9_tree_probs_from_distribution(MAX_ENTROPY_TOKENS,
vp9_coef_encodings, vp9_coef_tree,
coef_probs, branch_ct, coef_counts);
fprintf(f, "%s\n {", Comma(pt));
t = 0;
do {
fprintf(f, "%s %3d", 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 (++band < COEF_BANDS);
} while (++ref < REF_TYPES);
fprintf(f, "\n }");
} while (++type < block_types);
fprintf(f, "\n};\n");
@ -603,35 +572,22 @@ void print_context_counters() {
fprintf(f, "\n/* *** GENERATED FILE: DO NOT EDIT *** */\n\n");
/* print counts */
print_counter(f, context_counters_4x4, BLOCK_TYPES_4X4,
print_counter(f, context_counters_4x4, BLOCK_TYPES,
"vp9_default_coef_counts_4x4[BLOCK_TYPES_4X4]");
print_counter(f, hybrid_context_counters_4x4, BLOCK_TYPES_4X4_HYBRID,
"vp9_default_hybrid_coef_counts_4x4[BLOCK_TYPES_4X4_HYBRID]");
print_counter(f, context_counters_8x8, BLOCK_TYPES_8X8,
print_counter(f, context_counters_8x8, BLOCK_TYPES,
"vp9_default_coef_counts_8x8[BLOCK_TYPES_8X8]");
print_counter(f, hybrid_context_counters_8x8, BLOCK_TYPES_8X8_HYBRID,
"vp9_default_hybrid_coef_counts_8x8[BLOCK_TYPES_8X8_HYBRID]");
print_counter(f, context_counters_16x16, BLOCK_TYPES_16X16,
print_counter(f, context_counters_16x16, BLOCK_TYPES,
"vp9_default_coef_counts_16x16[BLOCK_TYPES_16X16]");
print_counter(f, hybrid_context_counters_16x16, BLOCK_TYPES_16X16_HYBRID,
"vp9_default_hybrid_coef_counts_16x16"
"[BLOCK_TYPES_16X16_HYBRID]");
print_counter(f, context_counters_32x32, BLOCK_TYPES_32X32,
"vp9_default_coef_counts_32x32[BLOCK_TYPES_32X32]");
/* print coefficient probabilities */
print_probs(f, context_counters_4x4, BLOCK_TYPES_4X4,
print_probs(f, context_counters_4x4, BLOCK_TYPES,
"default_coef_probs_4x4[BLOCK_TYPES_4X4]");
print_probs(f, hybrid_context_counters_4x4, BLOCK_TYPES_4X4_HYBRID,
"default_hybrid_coef_probs_4x4[BLOCK_TYPES_4X4_HYBRID]");
print_probs(f, context_counters_8x8, BLOCK_TYPES_8X8,
print_probs(f, context_counters_8x8, BLOCK_TYPES,
"default_coef_probs_8x8[BLOCK_TYPES_8X8]");
print_probs(f, hybrid_context_counters_8x8, BLOCK_TYPES_8X8_HYBRID,
"default_hybrid_coef_probs_8x8[BLOCK_TYPES_8X8_HYBRID]");
print_probs(f, context_counters_16x16, BLOCK_TYPES_16X16,
print_probs(f, context_counters_16x16, BLOCK_TYPES,
"default_coef_probs_16x16[BLOCK_TYPES_16X16]");
print_probs(f, hybrid_context_counters_16x16, BLOCK_TYPES_16X16_HYBRID,
"default_hybrid_coef_probs_16x16[BLOCK_TYPES_16X16_HYBRID]");
print_probs(f, context_counters_32x32, BLOCK_TYPES_32X32,
"default_coef_probs_32x32[BLOCK_TYPES_32X32]");
@ -639,14 +595,8 @@ void print_context_counters() {
f = fopen("context.bin", "wb");
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(hybrid_context_counters_8x8,
sizeof(hybrid_context_counters_8x8), 1, f);
fwrite(context_counters_16x16, sizeof(context_counters_16x16), 1, f);
fwrite(hybrid_context_counters_16x16,
sizeof(hybrid_context_counters_16x16), 1, f);
fwrite(context_counters_32x32, sizeof(context_counters_32x32), 1, f);
fclose(f);
}
@ -663,13 +613,11 @@ static INLINE void stuff_b(VP9_COMP *cpi,
PLANE_TYPE type,
TX_SIZE tx_size,
int dry_run) {
const BLOCKD * const b = xd->block + ib;
vp9_coeff_count *counts;
vp9_coeff_probs *probs;
int pt, band;
TOKENEXTRA *t = *tp;
const TX_TYPE tx_type = (type == PLANE_TYPE_Y_WITH_DC) ?
get_tx_type(xd, b) : DCT_DCT;
const int ref = xd->mode_info_context->mbmi.ref_frame != INTRA_FRAME;
ENTROPY_CONTEXT *const a = (ENTROPY_CONTEXT *)xd->above_context +
vp9_block2above[tx_size][ib];
ENTROPY_CONTEXT *const l = (ENTROPY_CONTEXT *)xd->left_context +
@ -683,26 +631,16 @@ static INLINE void stuff_b(VP9_COMP *cpi,
switch (tx_size) {
default:
case TX_4X4:
if (tx_type != DCT_DCT) {
counts = cpi->hybrid_coef_counts_4x4;
probs = cpi->common.fc.hybrid_coef_probs_4x4;
} else {
counts = cpi->coef_counts_4x4;
probs = cpi->common.fc.coef_probs_4x4;
}
counts = cpi->coef_counts_4x4;
probs = cpi->common.fc.coef_probs_4x4;
break;
case TX_8X8:
#if CONFIG_CNVCONTEXT
a_ec = (a[0] + a[1]) != 0;
l_ec = (l[0] + l[1]) != 0;
#endif
if (tx_type != DCT_DCT) {
counts = cpi->hybrid_coef_counts_8x8;
probs = cpi->common.fc.hybrid_coef_probs_8x8;
} else {
counts = cpi->coef_counts_8x8;
probs = cpi->common.fc.coef_probs_8x8;
}
counts = cpi->coef_counts_8x8;
probs = cpi->common.fc.coef_probs_8x8;
break;
case TX_16X16:
#if CONFIG_CNVCONTEXT
@ -714,13 +652,8 @@ static INLINE void stuff_b(VP9_COMP *cpi,
l_ec = (l[0] + l[1] + l1[0] + l1[1]) != 0;
}
#endif
if (tx_type != DCT_DCT) {
counts = cpi->hybrid_coef_counts_16x16;
probs = cpi->common.fc.hybrid_coef_probs_16x16;
} else {
counts = cpi->coef_counts_16x16;
probs = cpi->common.fc.coef_probs_16x16;
}
counts = cpi->coef_counts_16x16;
probs = cpi->common.fc.coef_probs_16x16;
break;
case TX_32X32:
#if CONFIG_CNVCONTEXT
@ -740,7 +673,7 @@ static INLINE void stuff_b(VP9_COMP *cpi,
band = get_coef_band(tx_size, 0);
t->Token = DCT_EOB_TOKEN;
t->context_tree = probs[type][band][pt];
t->context_tree = probs[type][ref][band][pt];
t->skip_eob_node = 0;
++t;
*tp = t;
@ -764,7 +697,7 @@ static INLINE void stuff_b(VP9_COMP *cpi,
}
if (!dry_run) {
++counts[type][band][pt][DCT_EOB_TOKEN];
++counts[type][ref][band][pt][DCT_EOB_TOKEN];
}
}

View File

@ -28,7 +28,7 @@ typedef struct {
uint8_t skip_eob_node;
} TOKENEXTRA;
typedef int64_t vp9_coeff_accum[COEF_BANDS][PREV_COEF_CONTEXTS]
typedef int64_t vp9_coeff_accum[REF_TYPES][COEF_BANDS][PREV_COEF_CONTEXTS]
[MAX_ENTROPY_TOKENS];
int vp9_mby_is_skippable_4x4(MACROBLOCKD *xd);
@ -57,14 +57,10 @@ void vp9_fix_contexts_sb(MACROBLOCKD *xd);
void init_context_counters();
void print_context_counters();
extern vp9_coeff_accum context_counters_4x4[BLOCK_TYPES_4X4];
extern vp9_coeff_accum context_counters_8x8[BLOCK_TYPES_8X8];
extern vp9_coeff_accum context_counters_16x16[BLOCK_TYPES_16X16];
extern vp9_coeff_accum context_counters_4x4[BLOCK_TYPES];
extern vp9_coeff_accum context_counters_8x8[BLOCK_TYPES];
extern vp9_coeff_accum context_counters_16x16[BLOCK_TYPES];
extern vp9_coeff_accum context_counters_32x32[BLOCK_TYPES_32X32];
extern vp9_coeff_accum hybrid_context_counters_4x4[BLOCK_TYPES_4X4_HYBRID];
extern vp9_coeff_accum hybrid_context_counters_8x8[BLOCK_TYPES_8X8_HYBRID];
extern vp9_coeff_accum hybrid_context_counters_16x16[BLOCK_TYPES_16X16_HYBRID];
#endif
extern const int *vp9_dct_value_cost_ptr;