Commit 4a96e64d authored by Dmitry Kovalev's avatar Dmitry Kovalev
Browse files

Using max_tx_size instead of bsize when possible.

Change-Id: I246364bc4270ca13aefb4bc3445bcf102b3170dc
parent 648e30bc
...@@ -109,32 +109,40 @@ static INLINE vp9_prob vp9_get_pred_prob_single_ref_p2(const VP9_COMMON *cm, ...@@ -109,32 +109,40 @@ static INLINE vp9_prob vp9_get_pred_prob_single_ref_p2(const VP9_COMMON *cm,
unsigned char vp9_get_pred_context_tx_size(const MACROBLOCKD *xd); unsigned char vp9_get_pred_context_tx_size(const MACROBLOCKD *xd);
static const vp9_prob *get_tx_probs(BLOCK_SIZE bsize, uint8_t context, static const vp9_prob *get_tx_probs(TX_SIZE max_tx_size, int ctx,
const struct tx_probs *tx_probs) { const struct tx_probs *tx_probs) {
if (bsize < BLOCK_16X16) switch (max_tx_size) {
return tx_probs->p8x8[context]; case TX_8X8:
else if (bsize < BLOCK_32X32) return tx_probs->p8x8[ctx];
return tx_probs->p16x16[context]; case TX_16X16:
else return tx_probs->p16x16[ctx];
return tx_probs->p32x32[context]; case TX_32X32:
return tx_probs->p32x32[ctx];
default:
assert(!"Invalid max_tx_size.");
return NULL;
}
} }
static const vp9_prob *get_tx_probs2(const MACROBLOCKD *xd, static const vp9_prob *get_tx_probs2(TX_SIZE max_tx_size, const MACROBLOCKD *xd,
const struct tx_probs *tx_probs, const struct tx_probs *tx_probs) {
const MODE_INFO *m) { const int ctx = vp9_get_pred_context_tx_size(xd);
const BLOCK_SIZE bsize = m->mbmi.sb_type; return get_tx_probs(max_tx_size, ctx, tx_probs);
const int context = vp9_get_pred_context_tx_size(xd);
return get_tx_probs(bsize, context, tx_probs);
} }
static unsigned int *get_tx_counts(BLOCK_SIZE bsize, uint8_t context, static unsigned int *get_tx_counts(TX_SIZE max_tx_size, int ctx,
struct tx_counts *tx_counts) { struct tx_counts *tx_counts) {
if (bsize < BLOCK_16X16) switch (max_tx_size) {
return tx_counts->p8x8[context]; case TX_8X8:
else if (bsize < BLOCK_32X32) return tx_counts->p8x8[ctx];
return tx_counts->p16x16[context]; case TX_16X16:
else return tx_counts->p16x16[ctx];
return tx_counts->p32x32[context]; case TX_32X32:
return tx_counts->p32x32[ctx];
default:
assert(!"Invalid max_tx_size.");
return NULL;
}
} }
#endif // VP9_COMMON_VP9_PRED_COMMON_H_ #endif // VP9_COMMON_VP9_PRED_COMMON_H_
...@@ -61,31 +61,28 @@ static int read_segment_id(vp9_reader *r, const struct segmentation *seg) { ...@@ -61,31 +61,28 @@ static int read_segment_id(vp9_reader *r, const struct segmentation *seg) {
} }
static TX_SIZE read_selected_tx_size(VP9_COMMON *cm, MACROBLOCKD *xd, static TX_SIZE read_selected_tx_size(VP9_COMMON *cm, MACROBLOCKD *xd,
BLOCK_SIZE bsize, vp9_reader *r) { TX_SIZE max_tx_size, vp9_reader *r) {
const uint8_t context = vp9_get_pred_context_tx_size(xd); const int ctx = vp9_get_pred_context_tx_size(xd);
const vp9_prob *tx_probs = get_tx_probs(bsize, context, &cm->fc.tx_probs); const vp9_prob *tx_probs = get_tx_probs(max_tx_size, ctx, &cm->fc.tx_probs);
TX_SIZE tx_size = vp9_read(r, tx_probs[0]); TX_SIZE tx_size = vp9_read(r, tx_probs[0]);
if (tx_size != TX_4X4 && bsize >= BLOCK_16X16) { if (tx_size != TX_4X4 && max_tx_size >= TX_16X16) {
tx_size += vp9_read(r, tx_probs[1]); tx_size += vp9_read(r, tx_probs[1]);
if (tx_size != TX_8X8 && bsize >= BLOCK_32X32) if (tx_size != TX_8X8 && max_tx_size >= TX_32X32)
tx_size += vp9_read(r, tx_probs[2]); tx_size += vp9_read(r, tx_probs[2]);
} }
if (!cm->frame_parallel_decoding_mode) if (!cm->frame_parallel_decoding_mode)
++get_tx_counts(bsize, context, &cm->counts.tx)[tx_size]; ++get_tx_counts(max_tx_size, ctx, &cm->counts.tx)[tx_size];
return tx_size; return tx_size;
} }
static TX_SIZE read_tx_size(VP9_COMMON *const cm, MACROBLOCKD *const xd, static TX_SIZE read_tx_size(VP9_COMMON *cm, MACROBLOCKD *xd, TX_MODE tx_mode,
TX_MODE tx_mode, BLOCK_SIZE bsize, int allow_select, BLOCK_SIZE bsize, int allow_select, vp9_reader *r) {
vp9_reader *r) { const TX_SIZE max_tx_size = max_txsize_lookup[bsize];
if (allow_select && tx_mode == TX_MODE_SELECT && bsize >= BLOCK_8X8) { if (allow_select && tx_mode == TX_MODE_SELECT && bsize >= BLOCK_8X8)
return read_selected_tx_size(cm, xd, bsize, r); return read_selected_tx_size(cm, xd, max_tx_size, r);
} else { else
const TX_SIZE max_tx_size_block = max_txsize_lookup[bsize]; return MIN(max_tx_size, tx_mode_to_biggest_tx_size[tx_mode]);
const TX_SIZE max_tx_size_txmode = tx_mode_to_biggest_tx_size[tx_mode];
return MIN(max_tx_size_block, max_tx_size_txmode);
}
} }
static void set_segment_id(VP9_COMMON *cm, BLOCK_SIZE bsize, static void set_segment_id(VP9_COMMON *cm, BLOCK_SIZE bsize,
......
...@@ -191,12 +191,14 @@ static void update_mbintra_mode_probs(VP9_COMP* const cpi, ...@@ -191,12 +191,14 @@ static void update_mbintra_mode_probs(VP9_COMP* const cpi,
static void write_selected_tx_size(const VP9_COMP *cpi, MODE_INFO *m, static void write_selected_tx_size(const VP9_COMP *cpi, MODE_INFO *m,
TX_SIZE tx_size, BLOCK_SIZE bsize, TX_SIZE tx_size, BLOCK_SIZE bsize,
vp9_writer *w) { vp9_writer *w) {
const TX_SIZE max_tx_size = max_txsize_lookup[bsize];
const MACROBLOCKD *const xd = &cpi->mb.e_mbd; const MACROBLOCKD *const xd = &cpi->mb.e_mbd;
const vp9_prob *tx_probs = get_tx_probs2(xd, &cpi->common.fc.tx_probs, m); const vp9_prob *const tx_probs = get_tx_probs2(max_tx_size, xd,
&cpi->common.fc.tx_probs);
vp9_write(w, tx_size != TX_4X4, tx_probs[0]); vp9_write(w, tx_size != TX_4X4, tx_probs[0]);
if (bsize >= BLOCK_16X16 && tx_size != TX_4X4) { if (tx_size != TX_4X4 && max_tx_size >= TX_16X16) {
vp9_write(w, tx_size != TX_8X8, tx_probs[1]); vp9_write(w, tx_size != TX_8X8, tx_probs[1]);
if (bsize >= BLOCK_32X32 && tx_size != TX_8X8) if (tx_size != TX_8X8 && max_tx_size >= TX_32X32)
vp9_write(w, tx_size != TX_16X16, tx_probs[2]); vp9_write(w, tx_size != TX_16X16, tx_probs[2]);
} }
} }
......
...@@ -2486,7 +2486,8 @@ static void encode_superblock(VP9_COMP *cpi, TOKENEXTRA **t, int output_enabled, ...@@ -2486,7 +2486,8 @@ static void encode_superblock(VP9_COMP *cpi, TOKENEXTRA **t, int output_enabled,
(mbmi->skip_coeff || (mbmi->skip_coeff ||
vp9_segfeature_active(&cm->seg, segment_id, SEG_LVL_SKIP)))) { vp9_segfeature_active(&cm->seg, segment_id, SEG_LVL_SKIP)))) {
const uint8_t context = vp9_get_pred_context_tx_size(xd); const uint8_t context = vp9_get_pred_context_tx_size(xd);
++get_tx_counts(bsize, context, &cm->counts.tx)[mbmi->tx_size]; ++get_tx_counts(max_txsize_lookup[bsize],
context, &cm->counts.tx)[mbmi->tx_size];
} else { } else {
int x, y; int x, y;
TX_SIZE sz = tx_mode_to_biggest_tx_size[cm->tx_mode]; TX_SIZE sz = tx_mode_to_biggest_tx_size[cm->tx_mode];
......
...@@ -740,7 +740,7 @@ static void choose_txfm_size_from_rd(VP9_COMP *cpi, MACROBLOCK *x, ...@@ -740,7 +740,7 @@ static void choose_txfm_size_from_rd(VP9_COMP *cpi, MACROBLOCK *x,
int n, m; int n, m;
int s0, s1; int s0, s1;
const vp9_prob *tx_probs = get_tx_probs2(xd, &cm->fc.tx_probs, xd->mi_8x8[0]); const vp9_prob *tx_probs = get_tx_probs2(max_tx_size, xd, &cm->fc.tx_probs);
for (n = TX_4X4; n <= max_tx_size; n++) { for (n = TX_4X4; n <= max_tx_size; n++) {
r[n][1] = r[n][0]; r[n][1] = r[n][0];
...@@ -845,7 +845,7 @@ static void choose_txfm_size_from_modelrd(VP9_COMP *cpi, MACROBLOCK *x, ...@@ -845,7 +845,7 @@ static void choose_txfm_size_from_modelrd(VP9_COMP *cpi, MACROBLOCK *x,
double scale_rd[TX_SIZES] = {1.73, 1.44, 1.20, 1.00}; double scale_rd[TX_SIZES] = {1.73, 1.44, 1.20, 1.00};
// double scale_r[TX_SIZES] = {2.82, 2.00, 1.41, 1.00}; // double scale_r[TX_SIZES] = {2.82, 2.00, 1.41, 1.00};
const vp9_prob *tx_probs = get_tx_probs2(xd, &cm->fc.tx_probs, xd->mi_8x8[0]); const vp9_prob *tx_probs = get_tx_probs2(max_tx_size, xd, &cm->fc.tx_probs);
// for (n = TX_4X4; n <= max_txfm_size; n++) // for (n = TX_4X4; n <= max_txfm_size; n++)
// r[n][0] = (r[n][0] * scale_r[n]); // r[n][0] = (r[n][0] * scale_r[n]);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment