Adding update_tx_counts function.

Moving common encoder/decoder code to update_tx_counts. Also renaming
vp9_get_pred_probs_tx_size to get_tx_probs2 and adding get_tx_probs to
call vp9_get_pred_context_tx_size inside read_selected_tx_size only once
(twice before).

Change-Id: Ia50247f3893de88ef8e9041b0d44be44a40aaa4d
This commit is contained in:
Dmitry Kovalev 2013-07-22 14:57:43 -07:00
parent 746154d905
commit b2fc6fa969
5 changed files with 46 additions and 44 deletions

View File

@ -108,16 +108,31 @@ 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);
static const vp9_prob *vp9_get_pred_probs_tx_size(const MACROBLOCKD *xd,
const struct tx_probs *tx_probs) {
const MODE_INFO *const mi = xd->mode_info_context;
const int pred_context = vp9_get_pred_context_tx_size(xd);
if (mi->mbmi.sb_type < BLOCK_SIZE_MB16X16)
return tx_probs->p8x8[pred_context];
else if (mi->mbmi.sb_type < BLOCK_SIZE_SB32X32)
return tx_probs->p16x16[pred_context];
static const vp9_prob *get_tx_probs(BLOCK_SIZE_TYPE bsize, uint8_t context,
const struct tx_probs *tx_probs) {
if (bsize < BLOCK_SIZE_MB16X16)
return tx_probs->p8x8[context];
else if (bsize < BLOCK_SIZE_SB32X32)
return tx_probs->p16x16[context];
else
return tx_probs->p32x32[pred_context];
return tx_probs->p32x32[context];
}
static const vp9_prob *get_tx_probs2(const MACROBLOCKD *xd,
const struct tx_probs *tx_probs) {
const BLOCK_SIZE_TYPE bsize = xd->mode_info_context->mbmi.sb_type;
const int context = vp9_get_pred_context_tx_size(xd);
return get_tx_probs(bsize, context, tx_probs);
}
static void update_tx_counts(BLOCK_SIZE_TYPE bsize, uint8_t context,
TX_SIZE tx_size, struct tx_counts *tx_counts) {
if (bsize >= BLOCK_SIZE_SB32X32)
tx_counts->p32x32[context][tx_size]++;
else if (bsize >= BLOCK_SIZE_MB16X16)
tx_counts->p16x16[context][tx_size]++;
else
tx_counts->p8x8[context][tx_size]++;
}
#endif // VP9_COMMON_VP9_PRED_COMMON_H_

View File

@ -38,35 +38,29 @@ static int read_segment_id(vp9_reader *r, const struct segmentation *seg) {
return treed_read(r, vp9_segment_tree, seg->tree_probs);
}
static TX_SIZE read_selected_txfm_size(VP9_COMMON *cm, MACROBLOCKD *xd,
BLOCK_SIZE_TYPE bsize, vp9_reader *r) {
const int context = vp9_get_pred_context_tx_size(xd);
const vp9_prob *tx_probs = vp9_get_pred_probs_tx_size(xd, &cm->fc.tx_probs);
TX_SIZE txfm_size = vp9_read(r, tx_probs[0]);
if (txfm_size != TX_4X4 && bsize >= BLOCK_SIZE_MB16X16) {
txfm_size += vp9_read(r, tx_probs[1]);
if (txfm_size != TX_8X8 && bsize >= BLOCK_SIZE_SB32X32)
txfm_size += vp9_read(r, tx_probs[2]);
static TX_SIZE read_selected_tx_size(VP9_COMMON *cm, MACROBLOCKD *xd,
BLOCK_SIZE_TYPE bsize, vp9_reader *r) {
const uint8_t context = vp9_get_pred_context_tx_size(xd);
const vp9_prob *tx_probs = get_tx_probs(bsize, context, &cm->fc.tx_probs);
TX_SIZE tx_size = vp9_read(r, tx_probs[0]);
if (tx_size != TX_4X4 && bsize >= BLOCK_SIZE_MB16X16) {
tx_size += vp9_read(r, tx_probs[1]);
if (tx_size != TX_8X8 && bsize >= BLOCK_SIZE_SB32X32)
tx_size += vp9_read(r, tx_probs[2]);
}
if (bsize >= BLOCK_SIZE_SB32X32)
cm->fc.tx_counts.p32x32[context][txfm_size]++;
else if (bsize >= BLOCK_SIZE_MB16X16)
cm->fc.tx_counts.p16x16[context][txfm_size]++;
else
cm->fc.tx_counts.p8x8[context][txfm_size]++;
return txfm_size;
update_tx_counts(bsize, context, tx_size, &cm->fc.tx_counts);
return tx_size;
}
static TX_SIZE read_txfm_size(VP9D_COMP *pbi, TX_MODE tx_mode,
BLOCK_SIZE_TYPE bsize, int select_cond,
vp9_reader *r) {
static TX_SIZE read_tx_size(VP9D_COMP *pbi, TX_MODE tx_mode,
BLOCK_SIZE_TYPE bsize, int select_cond,
vp9_reader *r) {
VP9_COMMON *const cm = &pbi->common;
MACROBLOCKD *const xd = &pbi->mb;
if (tx_mode == TX_MODE_SELECT && bsize >= BLOCK_SIZE_SB8X8 && select_cond)
return read_selected_txfm_size(cm, xd, bsize, r);
return read_selected_tx_size(cm, xd, bsize, r);
else if (tx_mode >= ALLOW_32X32 && bsize >= BLOCK_SIZE_SB32X32)
return TX_32X32;
else if (tx_mode >= ALLOW_16X16 && bsize >= BLOCK_SIZE_MB16X16)
@ -162,7 +156,7 @@ static void read_intra_mode_info(VP9D_COMP *pbi, MODE_INFO *m,
mbmi->segment_id = read_intra_segment_id(pbi, mi_row, mi_col, r);
mbmi->mb_skip_coeff = read_skip_coeff(pbi, mbmi->segment_id, r);
mbmi->txfm_size = read_txfm_size(pbi, cm->tx_mode, bsize, 1, r);
mbmi->txfm_size = read_tx_size(pbi, cm->tx_mode, bsize, 1, r);
mbmi->ref_frame[0] = INTRA_FRAME;
if (bsize >= BLOCK_SIZE_SB8X8) {
@ -463,7 +457,7 @@ static void read_inter_mode_info(VP9D_COMP *pbi, MODE_INFO *mi,
mbmi->mb_skip_coeff = read_skip_coeff(pbi, mbmi->segment_id, r);
mbmi->ref_frame[0] = read_reference_frame(pbi, mbmi->segment_id, r);
mbmi->ref_frame[1] = NONE;
mbmi->txfm_size = read_txfm_size(pbi, cm->tx_mode, bsize,
mbmi->txfm_size = read_tx_size(pbi, cm->tx_mode, bsize,
(!mbmi->mb_skip_coeff || mbmi->ref_frame[0] == INTRA_FRAME), r);
if (mbmi->ref_frame[0] != INTRA_FRAME) {

View File

@ -202,9 +202,8 @@ static void update_mbintra_mode_probs(VP9_COMP* const cpi,
static void write_selected_txfm_size(const VP9_COMP *cpi, TX_SIZE tx_size,
BLOCK_SIZE_TYPE bsize, vp9_writer *w) {
const VP9_COMMON *const cm = &cpi->common;
const MACROBLOCKD *const xd = &cpi->mb.e_mbd;
const vp9_prob *tx_probs = vp9_get_pred_probs_tx_size(xd, &cm->fc.tx_probs);
const vp9_prob *tx_probs = get_tx_probs2(xd, &cpi->common.fc.tx_probs);
vp9_write(w, tx_size != TX_4X4, tx_probs[0]);
if (bsize >= BLOCK_SIZE_MB16X16 && tx_size != TX_4X4) {
vp9_write(w, tx_size != TX_8X8, tx_probs[1]);

View File

@ -2610,14 +2610,8 @@ static void encode_superblock(VP9_COMP *cpi, TOKENEXTRA **t, int output_enabled,
!(mbmi->ref_frame[0] != INTRA_FRAME &&
(mbmi->mb_skip_coeff ||
vp9_segfeature_active(&xd->seg, segment_id, SEG_LVL_SKIP)))) {
const int context = vp9_get_pred_context_tx_size(xd);
if (bsize >= BLOCK_SIZE_SB32X32) {
cm->fc.tx_counts.p32x32[context][mbmi->txfm_size]++;
} else if (bsize >= BLOCK_SIZE_MB16X16) {
cm->fc.tx_counts.p16x16[context][mbmi->txfm_size]++;
} else {
cm->fc.tx_counts.p8x8[context][mbmi->txfm_size]++;
}
const uint8_t context = vp9_get_pred_context_tx_size(xd);
update_tx_counts(bsize, context, mbmi->txfm_size, &cm->fc.tx_counts);
} else {
int x, y;
TX_SIZE sz = (cm->tx_mode == TX_MODE_SELECT) ? TX_32X32 : cm->tx_mode;

View File

@ -862,7 +862,7 @@ static void choose_txfm_size_from_rd(VP9_COMP *cpi, MACROBLOCK *x,
int n, m;
int s0, s1;
const vp9_prob *tx_probs = vp9_get_pred_probs_tx_size(xd, &cm->fc.tx_probs);
const vp9_prob *tx_probs = get_tx_probs2(xd, &cm->fc.tx_probs);
for (n = TX_4X4; n <= max_txfm_size; n++) {
r[n][1] = r[n][0];
@ -969,7 +969,7 @@ static void choose_txfm_size_from_modelrd(VP9_COMP *cpi, MACROBLOCK *x,
double scale_rd[TX_SIZE_MAX_SB] = {1.73, 1.44, 1.20, 1.00};
// double scale_r[TX_SIZE_MAX_SB] = {2.82, 2.00, 1.41, 1.00};
const vp9_prob *tx_probs = vp9_get_pred_probs_tx_size(xd, &cm->fc.tx_probs);
const vp9_prob *tx_probs = get_tx_probs2(xd, &cm->fc.tx_probs);
// for (n = TX_4X4; n <= max_txfm_size; n++)
// r[n][0] = (r[n][0] * scale_r[n]);