Commit 954e560f authored by hui su's avatar hui su
Browse files

Refactor entropy coding of transform size

No performance change.

Change-Id: If35125fed909d89235b303514f77a33183bb36b3
parent e3d001ea
...@@ -320,17 +320,6 @@ static const vpx_prob default_single_ref_p[REF_CONTEXTS][SINGLE_REFS - 1] = { ...@@ -320,17 +320,6 @@ static const vpx_prob default_single_ref_p[REF_CONTEXTS][SINGLE_REFS - 1] = {
#endif // CONFIG_EXT_REFS #endif // CONFIG_EXT_REFS
}; };
static const struct tx_probs default_tx_probs = {
{ { 3, 136, 37 },
{ 5, 52, 13 } },
{ { 20, 152 },
{ 15, 101 } },
{ { 100 },
{ 66 } }
};
const vpx_tree_index vp10_palette_size_tree[TREE_SIZE(PALETTE_SIZES)] = { const vpx_tree_index vp10_palette_size_tree[TREE_SIZE(PALETTE_SIZES)] = {
-TWO_COLORS, 2, -TWO_COLORS, 2,
-THREE_COLORS, 4, -THREE_COLORS, 4,
...@@ -694,6 +683,34 @@ static const int palette_color_context_lookup[PALETTE_COLOR_CONTEXTS] = { ...@@ -694,6 +683,34 @@ static const int palette_color_context_lookup[PALETTE_COLOR_CONTEXTS] = {
9680, 10648, 10890, 13310 9680, 10648, 10890, 13310
}; };
const vpx_tree_index vp10_tx_size_tree[TX_SIZES - 1][TREE_SIZE(TX_SIZES)] = {
{ // Max tx_size is 8X8
-TX_4X4, -TX_8X8,
},
{ // Max tx_size is 16X16
-TX_4X4, 2,
-TX_8X8, -TX_16X16,
},
{ // Max tx_size is 32X32
-TX_4X4, 2,
-TX_8X8, 4,
-TX_16X16, -TX_32X32,
},
};
static const vpx_prob
default_tx_size_prob[TX_SIZES - 1][TX_SIZE_CONTEXTS][TX_SIZES - 1] = {
{ // Max tx_size is 8X8
{ 100, }, { 66, },
},
{ // Max tx_size is 16X16
{ 20, 152, }, { 15, 101, },
},
{ // Max tx_size is 32X32
{ 3, 136, 37 }, { 5, 52, 13 },
},
};
int vp10_get_palette_color_context(const uint8_t *color_map, int cols, int vp10_get_palette_color_context(const uint8_t *color_map, int cols,
int r, int c, int n, int *color_order) { int r, int c, int n, int *color_order) {
int i, j, max, max_idx, temp; int i, j, max, max_idx, temp;
...@@ -767,33 +784,6 @@ int vp10_get_palette_color_context(const uint8_t *color_map, int cols, ...@@ -767,33 +784,6 @@ int vp10_get_palette_color_context(const uint8_t *color_map, int cols,
return color_ctx; return color_ctx;
} }
void vp10_tx_counts_to_branch_counts_32x32(const unsigned int *tx_count_32x32p,
unsigned int (*ct_32x32p)[2]) {
ct_32x32p[0][0] = tx_count_32x32p[TX_4X4];
ct_32x32p[0][1] = tx_count_32x32p[TX_8X8] +
tx_count_32x32p[TX_16X16] +
tx_count_32x32p[TX_32X32];
ct_32x32p[1][0] = tx_count_32x32p[TX_8X8];
ct_32x32p[1][1] = tx_count_32x32p[TX_16X16] +
tx_count_32x32p[TX_32X32];
ct_32x32p[2][0] = tx_count_32x32p[TX_16X16];
ct_32x32p[2][1] = tx_count_32x32p[TX_32X32];
}
void vp10_tx_counts_to_branch_counts_16x16(const unsigned int *tx_count_16x16p,
unsigned int (*ct_16x16p)[2]) {
ct_16x16p[0][0] = tx_count_16x16p[TX_4X4];
ct_16x16p[0][1] = tx_count_16x16p[TX_8X8] + tx_count_16x16p[TX_16X16];
ct_16x16p[1][0] = tx_count_16x16p[TX_8X8];
ct_16x16p[1][1] = tx_count_16x16p[TX_16X16];
}
void vp10_tx_counts_to_branch_counts_8x8(const unsigned int *tx_count_8x8p,
unsigned int (*ct_8x8p)[2]) {
ct_8x8p[0][0] = tx_count_8x8p[TX_4X4];
ct_8x8p[0][1] = tx_count_8x8p[TX_8X8];
}
#if CONFIG_VAR_TX #if CONFIG_VAR_TX
static const vpx_prob default_txfm_partition_probs[TXFM_PARTITION_CONTEXTS] = { static const vpx_prob default_txfm_partition_probs[TXFM_PARTITION_CONTEXTS] = {
192, 128, 64, 192, 128, 64, 192, 128, 64, 192, 128, 64, 192, 128, 64, 192, 128, 64,
...@@ -1315,7 +1305,7 @@ static void init_mode_probs(FRAME_CONTEXT *fc) { ...@@ -1315,7 +1305,7 @@ static void init_mode_probs(FRAME_CONTEXT *fc) {
vp10_copy(fc->comp_inter_prob, default_comp_inter_p); vp10_copy(fc->comp_inter_prob, default_comp_inter_p);
vp10_copy(fc->comp_ref_prob, default_comp_ref_p); vp10_copy(fc->comp_ref_prob, default_comp_ref_p);
vp10_copy(fc->single_ref_prob, default_single_ref_p); vp10_copy(fc->single_ref_prob, default_single_ref_p);
fc->tx_probs = default_tx_probs; vp10_copy(fc->tx_size_probs, default_tx_size_prob);
#if CONFIG_VAR_TX #if CONFIG_VAR_TX
vp10_copy(fc->txfm_partition_prob, default_txfm_partition_probs); vp10_copy(fc->txfm_partition_prob, default_txfm_partition_probs);
#endif #endif
...@@ -1467,32 +1457,18 @@ void vp10_adapt_inter_frame_probs(VP10_COMMON *cm) { ...@@ -1467,32 +1457,18 @@ void vp10_adapt_inter_frame_probs(VP10_COMMON *cm) {
} }
void vp10_adapt_intra_frame_probs(VP10_COMMON *cm) { void vp10_adapt_intra_frame_probs(VP10_COMMON *cm) {
int i; int i, j;
FRAME_CONTEXT *fc = cm->fc; FRAME_CONTEXT *fc = cm->fc;
const FRAME_CONTEXT *pre_fc = &cm->frame_contexts[cm->frame_context_idx]; const FRAME_CONTEXT *pre_fc = &cm->frame_contexts[cm->frame_context_idx];
const FRAME_COUNTS *counts = &cm->counts; const FRAME_COUNTS *counts = &cm->counts;
if (cm->tx_mode == TX_MODE_SELECT) { if (cm->tx_mode == TX_MODE_SELECT) {
int j; for (i = 0; i < TX_SIZES - 1; ++i) {
unsigned int branch_ct_8x8p[TX_SIZES - 3][2]; for (j = 0; j < TX_SIZE_CONTEXTS; ++j)
unsigned int branch_ct_16x16p[TX_SIZES - 2][2]; vpx_tree_merge_probs(vp10_tx_size_tree[i],
unsigned int branch_ct_32x32p[TX_SIZES - 1][2]; pre_fc->tx_size_probs[i][j],
counts->tx_size[i][j],
for (i = 0; i < TX_SIZE_CONTEXTS; ++i) { fc->tx_size_probs[i][j]);
vp10_tx_counts_to_branch_counts_8x8(counts->tx.p8x8[i], branch_ct_8x8p);
for (j = 0; j < TX_SIZES - 3; ++j)
fc->tx_probs.p8x8[i][j] = mode_mv_merge_probs(
pre_fc->tx_probs.p8x8[i][j], branch_ct_8x8p[j]);
vp10_tx_counts_to_branch_counts_16x16(counts->tx.p16x16[i], branch_ct_16x16p);
for (j = 0; j < TX_SIZES - 2; ++j)
fc->tx_probs.p16x16[i][j] = mode_mv_merge_probs(
pre_fc->tx_probs.p16x16[i][j], branch_ct_16x16p[j]);
vp10_tx_counts_to_branch_counts_32x32(counts->tx.p32x32[i], branch_ct_32x32p);
for (j = 0; j < TX_SIZES - 1; ++j)
fc->tx_probs.p32x32[i][j] = mode_mv_merge_probs(
pre_fc->tx_probs.p32x32[i][j], branch_ct_32x32p[j]);
} }
} }
...@@ -1532,7 +1508,6 @@ void vp10_adapt_intra_frame_probs(VP10_COMMON *cm) { ...@@ -1532,7 +1508,6 @@ void vp10_adapt_intra_frame_probs(VP10_COMMON *cm) {
} }
#else #else
for (i = TX_4X4; i < EXT_TX_SIZES; ++i) { for (i = TX_4X4; i < EXT_TX_SIZES; ++i) {
int j;
for (j = 0; j < TX_TYPES; ++j) for (j = 0; j < TX_TYPES; ++j)
vpx_tree_merge_probs(vp10_ext_tx_tree, vpx_tree_merge_probs(vp10_ext_tx_tree,
pre_fc->intra_ext_tx_prob[i][j], pre_fc->intra_ext_tx_prob[i][j],
......
...@@ -37,19 +37,6 @@ extern "C" { ...@@ -37,19 +37,6 @@ extern "C" {
struct VP10Common; struct VP10Common;
struct tx_probs {
vpx_prob p32x32[TX_SIZE_CONTEXTS][TX_SIZES - 1];
vpx_prob p16x16[TX_SIZE_CONTEXTS][TX_SIZES - 2];
vpx_prob p8x8[TX_SIZE_CONTEXTS][TX_SIZES - 3];
};
struct tx_counts {
unsigned int p32x32[TX_SIZE_CONTEXTS][TX_SIZES];
unsigned int p16x16[TX_SIZE_CONTEXTS][TX_SIZES - 1];
unsigned int p8x8[TX_SIZE_CONTEXTS][TX_SIZES - 2];
unsigned int tx_totals[TX_SIZES];
};
struct seg_counts { struct seg_counts {
unsigned int tree_total[MAX_SEGMENTS]; unsigned int tree_total[MAX_SEGMENTS];
unsigned int tree_mispred[MAX_SEGMENTS]; unsigned int tree_mispred[MAX_SEGMENTS];
...@@ -89,7 +76,7 @@ typedef struct frame_contexts { ...@@ -89,7 +76,7 @@ typedef struct frame_contexts {
vpx_prob comp_inter_prob[COMP_INTER_CONTEXTS]; vpx_prob comp_inter_prob[COMP_INTER_CONTEXTS];
vpx_prob single_ref_prob[REF_CONTEXTS][SINGLE_REFS-1]; vpx_prob single_ref_prob[REF_CONTEXTS][SINGLE_REFS-1];
vpx_prob comp_ref_prob[REF_CONTEXTS][COMP_REFS-1]; vpx_prob comp_ref_prob[REF_CONTEXTS][COMP_REFS-1];
struct tx_probs tx_probs; vpx_prob tx_size_probs[TX_SIZES - 1][TX_SIZE_CONTEXTS][TX_SIZES - 1];
#if CONFIG_VAR_TX #if CONFIG_VAR_TX
vpx_prob txfm_partition_prob[TXFM_PARTITION_CONTEXTS]; vpx_prob txfm_partition_prob[TXFM_PARTITION_CONTEXTS];
#endif #endif
...@@ -151,7 +138,8 @@ typedef struct FRAME_COUNTS { ...@@ -151,7 +138,8 @@ typedef struct FRAME_COUNTS {
unsigned int comp_inter[COMP_INTER_CONTEXTS][2]; unsigned int comp_inter[COMP_INTER_CONTEXTS][2];
unsigned int single_ref[REF_CONTEXTS][SINGLE_REFS-1][2]; unsigned int single_ref[REF_CONTEXTS][SINGLE_REFS-1][2];
unsigned int comp_ref[REF_CONTEXTS][COMP_REFS-1][2]; unsigned int comp_ref[REF_CONTEXTS][COMP_REFS-1][2];
struct tx_counts tx; unsigned int tx_size_totals[TX_SIZES];
unsigned int tx_size[TX_SIZES - 1][TX_SIZE_CONTEXTS][TX_SIZES];
#if CONFIG_VAR_TX #if CONFIG_VAR_TX
unsigned int txfm_partition[TXFM_PARTITION_CONTEXTS][2]; unsigned int txfm_partition[TXFM_PARTITION_CONTEXTS][2];
#endif #endif
...@@ -205,6 +193,8 @@ extern const vpx_tree_index vp10_switchable_interp_tree ...@@ -205,6 +193,8 @@ extern const vpx_tree_index vp10_switchable_interp_tree
extern const vpx_tree_index vp10_palette_size_tree[TREE_SIZE(PALETTE_SIZES)]; extern const vpx_tree_index vp10_palette_size_tree[TREE_SIZE(PALETTE_SIZES)];
extern const vpx_tree_index extern const vpx_tree_index
vp10_palette_color_tree[PALETTE_MAX_SIZE - 1][TREE_SIZE(PALETTE_COLORS)]; vp10_palette_color_tree[PALETTE_MAX_SIZE - 1][TREE_SIZE(PALETTE_COLORS)];
extern const vpx_tree_index
vp10_tx_size_tree[TX_SIZES - 1][TREE_SIZE(TX_SIZES)];
#if CONFIG_EXT_INTRA #if CONFIG_EXT_INTRA
extern const vpx_tree_index vp10_intra_filter_tree[TREE_SIZE(INTRA_FILTERS)]; extern const vpx_tree_index vp10_intra_filter_tree[TREE_SIZE(INTRA_FILTERS)];
#endif // CONFIG_EXT_INTRA #endif // CONFIG_EXT_INTRA
...@@ -223,13 +213,6 @@ void vp10_setup_past_independence(struct VP10Common *cm); ...@@ -223,13 +213,6 @@ void vp10_setup_past_independence(struct VP10Common *cm);
void vp10_adapt_intra_frame_probs(struct VP10Common *cm); void vp10_adapt_intra_frame_probs(struct VP10Common *cm);
void vp10_adapt_inter_frame_probs(struct VP10Common *cm); void vp10_adapt_inter_frame_probs(struct VP10Common *cm);
void vp10_tx_counts_to_branch_counts_32x32(const unsigned int *tx_count_32x32p,
unsigned int (*ct_32x32p)[2]);
void vp10_tx_counts_to_branch_counts_16x16(const unsigned int *tx_count_16x16p,
unsigned int (*ct_16x16p)[2]);
void vp10_tx_counts_to_branch_counts_8x8(const unsigned int *tx_count_8x8p,
unsigned int (*ct_8x8p)[2]);
static INLINE int vp10_ceil_log2(int n) { static INLINE int vp10_ceil_log2(int n) {
int i = 1, p = 2; int i = 1, p = 2;
while (p < n) { while (p < n) {
......
...@@ -185,48 +185,11 @@ static INLINE int get_tx_size_context(const MACROBLOCKD *xd) { ...@@ -185,48 +185,11 @@ static INLINE int get_tx_size_context(const MACROBLOCKD *xd) {
return (above_ctx + left_ctx) > max_tx_size; return (above_ctx + left_ctx) > max_tx_size;
} }
static INLINE const vpx_prob *get_tx_probs(TX_SIZE max_tx_size, int ctx,
const struct tx_probs *tx_probs) {
switch (max_tx_size) {
case TX_8X8:
return tx_probs->p8x8[ctx];
case TX_16X16:
return tx_probs->p16x16[ctx];
case TX_32X32:
return tx_probs->p32x32[ctx];
default:
assert(0 && "Invalid max_tx_size.");
return NULL;
}
}
static INLINE const vpx_prob *get_tx_probs2(TX_SIZE max_tx_size,
const MACROBLOCKD *xd,
const struct tx_probs *tx_probs) {
return get_tx_probs(max_tx_size, get_tx_size_context(xd), tx_probs);
}
static INLINE unsigned int *get_tx_counts(TX_SIZE max_tx_size, int ctx,
struct tx_counts *tx_counts) {
switch (max_tx_size) {
case TX_8X8:
return tx_counts->p8x8[ctx];
case TX_16X16:
return tx_counts->p16x16[ctx];
case TX_32X32:
return tx_counts->p32x32[ctx];
default:
assert(0 && "Invalid max_tx_size.");
return NULL;
}
}
#if CONFIG_VAR_TX #if CONFIG_VAR_TX
static void update_tx_counts(VP10_COMMON *cm, MACROBLOCKD *xd, static void update_tx_counts(VP10_COMMON *cm, MACROBLOCKD *xd,
MB_MODE_INFO *mbmi, BLOCK_SIZE plane_bsize, MB_MODE_INFO *mbmi, BLOCK_SIZE plane_bsize,
TX_SIZE tx_size, int blk_row, int blk_col, TX_SIZE tx_size, int blk_row, int blk_col,
TX_SIZE max_tx_size, int ctx, TX_SIZE max_tx_size, int ctx) {
struct tx_counts *tx_counts) {
const struct macroblockd_plane *const pd = &xd->plane[0]; const struct macroblockd_plane *const pd = &xd->plane[0];
const BLOCK_SIZE bsize = txsize_to_bsize[tx_size]; const BLOCK_SIZE bsize = txsize_to_bsize[tx_size];
int tx_idx = (blk_row >> (1 - pd->subsampling_y)) * 8 + int tx_idx = (blk_row >> (1 - pd->subsampling_y)) * 8 +
...@@ -244,7 +207,7 @@ static void update_tx_counts(VP10_COMMON *cm, MACROBLOCKD *xd, ...@@ -244,7 +207,7 @@ static void update_tx_counts(VP10_COMMON *cm, MACROBLOCKD *xd,
return; return;
if (tx_size == plane_tx_size) { if (tx_size == plane_tx_size) {
++get_tx_counts(max_tx_size, ctx, tx_counts)[tx_size]; ++xd->counts->tx_size[max_tx_size - TX_8X8][ctx][tx_size];
mbmi->tx_size = tx_size; mbmi->tx_size = tx_size;
} else { } else {
int bsl = b_width_log2_lookup[bsize]; int bsl = b_width_log2_lookup[bsize];
...@@ -260,8 +223,7 @@ static void update_tx_counts(VP10_COMMON *cm, MACROBLOCKD *xd, ...@@ -260,8 +223,7 @@ static void update_tx_counts(VP10_COMMON *cm, MACROBLOCKD *xd,
if (offsetr >= max_blocks_high || offsetc >= max_blocks_wide) if (offsetr >= max_blocks_high || offsetc >= max_blocks_wide)
continue; continue;
update_tx_counts(cm, xd, mbmi, plane_bsize, update_tx_counts(cm, xd, mbmi, plane_bsize,
tx_size - 1, offsetr, offsetc, tx_size - 1, offsetr, offsetc, max_tx_size, ctx);
max_tx_size, ctx, tx_counts);
} }
} }
} }
...@@ -270,8 +232,7 @@ static INLINE void inter_block_tx_count_update(VP10_COMMON *cm, ...@@ -270,8 +232,7 @@ static INLINE void inter_block_tx_count_update(VP10_COMMON *cm,
MACROBLOCKD *xd, MACROBLOCKD *xd,
MB_MODE_INFO *mbmi, MB_MODE_INFO *mbmi,
BLOCK_SIZE plane_bsize, BLOCK_SIZE plane_bsize,
int ctx, int ctx) {
struct tx_counts *tx_counts) {
const int mi_width = num_4x4_blocks_wide_lookup[plane_bsize]; const int mi_width = num_4x4_blocks_wide_lookup[plane_bsize];
const int mi_height = num_4x4_blocks_high_lookup[plane_bsize]; const int mi_height = num_4x4_blocks_high_lookup[plane_bsize];
TX_SIZE max_tx_size = max_txsize_lookup[plane_bsize]; TX_SIZE max_tx_size = max_txsize_lookup[plane_bsize];
...@@ -282,7 +243,7 @@ static INLINE void inter_block_tx_count_update(VP10_COMMON *cm, ...@@ -282,7 +243,7 @@ static INLINE void inter_block_tx_count_update(VP10_COMMON *cm,
for (idy = 0; idy < mi_height; idy += bh) for (idy = 0; idy < mi_height; idy += bh)
for (idx = 0; idx < mi_width; idx += bh) for (idx = 0; idx < mi_width; idx += bh)
update_tx_counts(cm, xd, mbmi, plane_bsize, max_tx_size, idy, idx, update_tx_counts(cm, xd, mbmi, plane_bsize, max_tx_size, idy, idx,
max_tx_size, ctx, tx_counts); max_tx_size, ctx);
} }
#endif #endif
......
...@@ -432,19 +432,13 @@ void vp10_accumulate_frame_counts(VP10_COMMON *cm, FRAME_COUNTS *counts, ...@@ -432,19 +432,13 @@ void vp10_accumulate_frame_counts(VP10_COMMON *cm, FRAME_COUNTS *counts,
for (k = 0; k < 2; k++) for (k = 0; k < 2; k++)
cm->counts.comp_ref[i][j][k] += counts->comp_ref[i][j][k]; cm->counts.comp_ref[i][j][k] += counts->comp_ref[i][j][k];
for (i = 0; i < TX_SIZE_CONTEXTS; i++) { for (i = 0; i < TX_SIZES - 1; ++i)
for (j = 0; j < TX_SIZES; j++) for (j = 0; j < TX_SIZE_CONTEXTS; ++j)
cm->counts.tx.p32x32[i][j] += counts->tx.p32x32[i][j]; for (k = 0; k < i + 2; ++k)
cm->counts.tx_size[i][j][k] += counts->tx_size[i][j][k];
for (j = 0; j < TX_SIZES - 1; j++)
cm->counts.tx.p16x16[i][j] += counts->tx.p16x16[i][j];
for (j = 0; j < TX_SIZES - 2; j++) for (i = 0; i < TX_SIZES; ++i)
cm->counts.tx.p8x8[i][j] += counts->tx.p8x8[i][j]; cm->counts.tx_size_totals[i] += counts->tx_size_totals[i];
}
for (i = 0; i < TX_SIZES; i++)
cm->counts.tx.tx_totals[i] += counts->tx.tx_totals[i];
#if CONFIG_VAR_TX #if CONFIG_VAR_TX
for (i = 0; i < TXFM_PARTITION_CONTEXTS; ++i) for (i = 0; i < TXFM_PARTITION_CONTEXTS; ++i)
......
...@@ -100,22 +100,6 @@ static TX_MODE read_tx_mode(struct vpx_read_bit_buffer *rb) { ...@@ -100,22 +100,6 @@ static TX_MODE read_tx_mode(struct vpx_read_bit_buffer *rb) {
return vpx_rb_read_bit(rb) ? TX_MODE_SELECT : vpx_rb_read_literal(rb, 2); return vpx_rb_read_bit(rb) ? TX_MODE_SELECT : vpx_rb_read_literal(rb, 2);
} }
static void read_tx_mode_probs(struct tx_probs *tx_probs, vpx_reader *r) {
int i, j;
for (i = 0; i < TX_SIZE_CONTEXTS; ++i)
for (j = 0; j < TX_SIZES - 3; ++j)
vp10_diff_update_prob(r, &tx_probs->p8x8[i][j]);
for (i = 0; i < TX_SIZE_CONTEXTS; ++i)
for (j = 0; j < TX_SIZES - 2; ++j)
vp10_diff_update_prob(r, &tx_probs->p16x16[i][j]);
for (i = 0; i < TX_SIZE_CONTEXTS; ++i)
for (j = 0; j < TX_SIZES - 1; ++j)
vp10_diff_update_prob(r, &tx_probs->p32x32[i][j]);
}
static void read_switchable_interp_probs(FRAME_CONTEXT *fc, vpx_reader *r) { static void read_switchable_interp_probs(FRAME_CONTEXT *fc, vpx_reader *r) {
int i, j; int i, j;
for (j = 0; j < SWITCHABLE_FILTER_CONTEXTS; ++j) for (j = 0; j < SWITCHABLE_FILTER_CONTEXTS; ++j)
...@@ -3541,8 +3525,13 @@ static int read_compressed_header(VP10Decoder *pbi, const uint8_t *data, ...@@ -3541,8 +3525,13 @@ static int read_compressed_header(VP10Decoder *pbi, const uint8_t *data,
vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR,
"Failed to allocate bool decoder 0"); "Failed to allocate bool decoder 0");
if (cm->tx_mode == TX_MODE_SELECT) if (cm->tx_mode == TX_MODE_SELECT) {
read_tx_mode_probs(&fc->tx_probs, &r); for (i = 0; i < TX_SIZES - 1; ++i)
for (j = 0; j < TX_SIZE_CONTEXTS; ++j)
for (k = 0; k < i + 1; ++k)
vp10_diff_update_prob(&r, &fc->tx_size_probs[i][j][k]);
}
read_coef_probs(fc, cm->tx_mode, &r); read_coef_probs(fc, cm->tx_mode, &r);
#if CONFIG_VAR_TX #if CONFIG_VAR_TX
...@@ -3679,7 +3668,8 @@ static void debug_check_frame_counts(const VP10_COMMON *const cm) { ...@@ -3679,7 +3668,8 @@ static void debug_check_frame_counts(const VP10_COMMON *const cm) {
sizeof(cm->counts.single_ref))); sizeof(cm->counts.single_ref)));
assert(!memcmp(cm->counts.comp_ref, zero_counts.comp_ref, assert(!memcmp(cm->counts.comp_ref, zero_counts.comp_ref,
sizeof(cm->counts.comp_ref))); sizeof(cm->counts.comp_ref)));
assert(!memcmp(&cm->counts.tx, &zero_counts.tx, sizeof(cm->counts.tx))); assert(!memcmp(&cm->counts.tx_size, &zero_counts.tx_size,
sizeof(cm->counts.tx_size)));
assert(!memcmp(cm->counts.skip, zero_counts.skip, sizeof(cm->counts.skip))); assert(!memcmp(cm->counts.skip, zero_counts.skip, sizeof(cm->counts.skip)));
#if CONFIG_REF_MV #if CONFIG_REF_MV
assert(!memcmp(&cm->counts.mv[0], &zero_counts.mv[0], assert(!memcmp(&cm->counts.mv[0], &zero_counts.mv[0],
......
...@@ -273,16 +273,11 @@ static TX_SIZE read_selected_tx_size(VP10_COMMON *cm, MACROBLOCKD *xd, ...@@ -273,16 +273,11 @@ static TX_SIZE read_selected_tx_size(VP10_COMMON *cm, MACROBLOCKD *xd,
TX_SIZE max_tx_size, vpx_reader *r) { TX_SIZE max_tx_size, vpx_reader *r) {
FRAME_COUNTS *counts = xd->counts; FRAME_COUNTS *counts = xd->counts;
const int ctx = get_tx_size_context(xd); const int ctx = get_tx_size_context(xd);
const vpx_prob *tx_probs = get_tx_probs(max_tx_size, ctx, &cm->fc->tx_probs); const int tx_size_cat = max_tx_size - TX_8X8;
int tx_size = vpx_read(r, tx_probs[0]); int tx_size = vpx_read_tree(r, vp10_tx_size_tree[tx_size_cat],
if (tx_size != TX_4X4 && max_tx_size >= TX_16X16) { cm->fc->tx_size_probs[tx_size_cat][ctx]);
tx_size += vpx_read(r, tx_probs[1]);
if (tx_size != TX_8X8 && max_tx_size >= TX_32X32)
tx_size += vpx_read(r, tx_probs[2]);
}
if (counts) if (counts)
++get_tx_counts(max_tx_size, ctx, &counts->tx)[tx_size]; ++counts->tx_size[tx_size_cat][ctx][tx_size];
return (TX_SIZE)tx_size; return (TX_SIZE)tx_size;
} }
...@@ -1508,7 +1503,7 @@ static void read_inter_frame_mode_info(VP10Decoder *const pbi, ...@@ -1508,7 +1503,7 @@ static void read_inter_frame_mode_info(VP10Decoder *const pbi,
idy, idx, r); idy, idx, r);
if (xd->counts) { if (xd->counts) {
const int ctx = get_tx_size_context(xd); const int ctx = get_tx_size_context(xd);
++get_tx_counts(max_tx_size, ctx, &xd->counts->tx)[mbmi->tx_size]; ++xd->counts->tx_size[max_tx_size - TX_8X8][ctx][mbmi->tx_size];
} }
} else { } else {
mbmi->tx_size = read_tx_size(cm, xd, !mbmi->skip || !inter_block, r); mbmi->tx_size = read_tx_size(cm, xd, !mbmi->skip || !inter_block, r);
......
...@@ -81,6 +81,13 @@ palette_color_encodings[PALETTE_MAX_SIZE - 1][PALETTE_MAX_SIZE] = { ...@@ -81,6 +81,13 @@ palette_color_encodings[PALETTE_MAX_SIZE - 1][PALETTE_MAX_SIZE] = {
{30, 5}, {62, 6}, {126, 7}, {127, 7}}, // 8 colors {30, 5}, {62, 6}, {126, 7}, {127, 7}}, // 8 colors
}; };
static const struct vp10_token
tx_size_encodings[TX_SIZES - 1][TX_SIZES] = {
{{0, 1}, {1, 1}}, // Max tx_size is 8X8
{{0, 1}, {2, 2}, {3, 2}}, // Max tx_size is 16X16
{{0, 1}, {2, 2}, {6, 3}, {7, 3}}, // Max tx_size is 32X32
};
static INLINE void write_uniform(vpx_writer *w, int n, int v) { static INLINE void write_uniform(vpx_writer *w, int n, int v) {
int l = get_unsigned_bits(n); int l = get_unsigned_bits(n);
int m = (1 << l) - n; int m = (1 << l) - n;
...@@ -314,13 +321,11 @@ static void write_selected_tx_size(const VP10_COMMON *cm, ...@@ -314,13 +321,11 @@ static void write_selected_tx_size(const VP10_COMMON *cm,
TX_SIZE tx_size = xd->mi[0]->mbmi.tx_size; TX_SIZE tx_size = xd->mi[0]->mbmi.tx_size;
BLOCK_SIZE bsize = xd->mi[0]->mbmi.sb_type; BLOCK_SIZE bsize = xd->mi[0]->mbmi.sb_type;
const TX_SIZE max_tx_size = max_txsize_lookup[bsize]; const TX_SIZE max_tx_size = max_txsize_lookup[bsize];
const vpx_prob *const tx_probs = get_tx_probs2(max_tx_size, xd, if (max_tx_size > TX_4X4) {
&cm->fc->tx_probs); vp10_write_token(w, vp10_tx_size_tree[max_tx_size - TX_8X8],
vpx_write(w, tx_size != TX_4X4, tx_probs[0]); cm->fc->tx_size_probs[max_tx_size - TX_8X8]
if (tx_size != TX_4X4 && max_tx_size >= TX_16X16) { [get_tx_size_context(xd)],
vpx_write(w, tx_size != TX_8X8, tx_probs[1]); &tx_size_encodings[max_tx_size - TX_8X8][tx_size]);
if (tx_size != TX_8X8 && max_tx_size >= TX_32X32)
vpx_write(w, tx_size != TX_16X16, tx_probs[2]);
} }
} }
...@@ -1847,7 +1852,7 @@ static void update_coef_probs(VP10_COMP *cpi, vpx_writer* w) { ...@@ -1847,7 +1852,7 @@ static void update_coef_probs(VP10_COMP *cpi, vpx_writer* w) {
for (tx_size = TX_4X4; tx_size <= max_tx_size; ++tx_size) { for (tx_size = TX_4X4; tx_size <= max_tx_size; ++tx_size) {
vp10_coeff_stats frame_branch_ct[PLANE_TYPES]; vp10_coeff_stats frame_branch_ct[PLANE_TYPES];
vp10_coeff_probs_model frame_coef_probs[PLANE_TYPES]; vp10_coeff_probs_model frame_coef_probs[PLANE_TYPES];
if (cpi->td.counts->tx.tx_totals[tx_size] <= 20 || if (cpi->td.counts->tx_size_totals[tx_size] <= 20 ||
(tx_size >= TX_16X16 && cpi->sf.tx_size_search_method == USE_TX_8X8)) { (tx_size >= TX_16X16 && cpi->sf.tx_size_search_method == USE_TX_8X8)) {
vpx_write_bit(w, 0); vpx_write_bit(w, 0);
} else { } else {
...@@ -2028,30 +2033,11 @@ static void update_txfm_probs(VP10_COMMON *cm, vpx_writer *w, ...@@ -2028,30 +2033,11 @@ static void update_txfm_probs(VP10_COMMON *cm, vpx_writer *w,
FRAME_COUNTS *counts) { FRAME_COUNTS *counts) {
if (cm->tx_mode == TX_MODE_SELECT) { if (cm->tx_mode == TX_MODE_SELECT) {
int i, j; int i, j;
unsigned int ct_8x8p[TX_SIZES - 3][2]; for (i = 0; i < TX_SIZES - 1; ++i)
unsigned int ct_16x16p[TX_SIZES - 2][2]; for (j = 0; j < TX_SIZE_CONTEXTS; ++j)
unsigned int ct_32x32p[TX_SIZES - 1][2]; prob_diff_update(vp10_tx_size_tree[i],
cm->fc->tx_size_probs[i][j],
counts->tx_size[i][j], i + 2, w);
for (i = 0; i < TX_SIZE_CONTEXTS; i++) {
vp10_tx_counts_to_branch_counts_8x8(counts->tx.p8x8[i], ct_8x8p);
for (j = 0; j < TX_SIZES - 3; j++)
vp10_cond_prob_diff_update(w, &cm->fc->tx_probs.p8x8[i][j], ct_8x8p[j]);
}
for (i = 0; i < TX_SIZE_CONTEXTS; i++) {
vp10_tx_counts_to_branch_counts_16x16(counts->tx.p16x16[i], ct_16x16p);
for (j = 0; j < TX_SIZES - 2; j++)
vp10_cond_prob_diff_update(w, &cm->fc->tx_probs.p16x16[i][j],