Merge "Adding get_entropy_context function."

This commit is contained in:
Dmitry Kovalev 2013-08-27 17:02:36 -07:00 committed by Gerrit Code Review
commit 1d3f94efe2
4 changed files with 54 additions and 79 deletions

View File

@ -584,4 +584,10 @@ static void set_contexts(MACROBLOCKD *xd, struct macroblockd_plane *pd,
}
}
static int get_tx_eob(struct segmentation *seg, int segment_id,
TX_SIZE tx_size) {
const int eob_max = 16 << (tx_size << 1);
return vp9_segfeature_active(seg, segment_id, SEG_LVL_SKIP) ? 0 : eob_max;
}
#endif // VP9_COMMON_VP9_BLOCKD_H_

View File

@ -336,6 +336,45 @@ static INLINE const int16_t* get_iscan_16x16(TX_TYPE tx_type) {
}
}
static int get_entropy_context(const MACROBLOCKD *xd, TX_SIZE tx_size,
PLANE_TYPE type, int block_idx,
ENTROPY_CONTEXT *A, ENTROPY_CONTEXT *L,
const int16_t **scan,
const uint8_t **band_translate) {
ENTROPY_CONTEXT above_ec, left_ec;
switch (tx_size) {
case TX_4X4:
*scan = get_scan_4x4(get_tx_type_4x4(type, xd, block_idx));
*band_translate = vp9_coefband_trans_4x4;
above_ec = A[0] != 0;
left_ec = L[0] != 0;
break;
case TX_8X8:
*scan = get_scan_8x8(get_tx_type_8x8(type, xd));
*band_translate = vp9_coefband_trans_8x8plus;
above_ec = !!*(uint16_t *)A;
left_ec = !!*(uint16_t *)L;
break;
case TX_16X16:
*scan = get_scan_16x16(get_tx_type_16x16(type, xd));
*band_translate = vp9_coefband_trans_8x8plus;
above_ec = !!*(uint32_t *)A;
left_ec = !!*(uint32_t *)L;
break;
case TX_32X32:
*scan = vp9_default_scan_32x32;
*band_translate = vp9_coefband_trans_8x8plus;
above_ec = !!*(uint64_t *)A;
left_ec = !!*(uint64_t *)L;
break;
default:
assert(!"Invalid transform size.");
}
return combine_entropy_contexts(above_ec, left_ec);
}
enum { VP9_COEF_UPDATE_PROB = 252 };
#endif // VP9_COMMON_VP9_ENTROPY_H_

View File

@ -94,9 +94,8 @@ static int decode_coefs(VP9_COMMON *cm, const MACROBLOCKD *xd,
ENTROPY_CONTEXT *A, ENTROPY_CONTEXT *L) {
FRAME_CONTEXT *const fc = &cm->fc;
FRAME_COUNTS *const counts = &cm->counts;
ENTROPY_CONTEXT above_ec, left_ec;
const int ref = is_inter_block(&xd->mode_info_context->mbmi);
int band, pt, c = 0;
int band, c = 0;
vp9_prob (*coef_probs)[PREV_COEF_CONTEXTS][UNCONSTRAINED_NODES] =
fc->coef_probs[tx_size][type][ref];
vp9_prob coef_probs_full[COEF_BANDS][PREV_COEF_CONTEXTS][ENTROPY_NODES];
@ -104,38 +103,10 @@ static int decode_coefs(VP9_COMMON *cm, const MACROBLOCKD *xd,
vp9_prob *prob;
vp9_coeff_count_model *coef_counts = counts->coef[tx_size];
const int16_t *scan, *nb;
uint8_t token_cache[1024];
const uint8_t *band_translate;
switch (tx_size) {
default:
case TX_4X4:
scan = get_scan_4x4(get_tx_type_4x4(type, xd, block_idx));
above_ec = A[0] != 0;
left_ec = L[0] != 0;
band_translate = vp9_coefband_trans_4x4;
break;
case TX_8X8:
scan = get_scan_8x8(get_tx_type_8x8(type, xd));
above_ec = !!*(uint16_t *)A;
left_ec = !!*(uint16_t *)L;
band_translate = vp9_coefband_trans_8x8plus;
break;
case TX_16X16:
scan = get_scan_16x16(get_tx_type_16x16(type, xd));
above_ec = !!*(uint32_t *)A;
left_ec = !!*(uint32_t *)L;
band_translate = vp9_coefband_trans_8x8plus;
break;
case TX_32X32:
scan = vp9_default_scan_32x32;
above_ec = !!*(uint64_t *)A;
left_ec = !!*(uint64_t *)L;
band_translate = vp9_coefband_trans_8x8plus;
break;
}
pt = combine_entropy_contexts(above_ec, left_ec);
uint8_t token_cache[1024];
int pt = get_entropy_context(xd, tx_size, type, block_idx, A, L,
&scan, &band_translate);
nb = vp9_get_coef_neighbors_handle(scan);
while (1) {
@ -239,10 +210,6 @@ SKIP_START:
return c;
}
static int get_eob(struct segmentation *seg, int segment_id, int eob_max) {
return vp9_segfeature_active(seg, segment_id, SEG_LVL_SKIP) ? 0 : eob_max;
}
struct decode_block_args {
VP9D_COMP *pbi;
vp9_reader *r;
@ -258,8 +225,7 @@ static void decode_block(int plane, int block, BLOCK_SIZE plane_bsize,
struct segmentation *seg = &arg->pbi->common.seg;
struct macroblockd_plane* pd = &xd->plane[plane];
const int segment_id = xd->mode_info_context->mbmi.segment_id;
const int ss_txfrm_size = tx_size << 1;
const int seg_eob = get_eob(seg, segment_id, 16 << ss_txfrm_size);
const int seg_eob = get_tx_eob(seg, segment_id, tx_size);
int aoff, loff, eob;
txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &aoff, &loff);

View File

@ -121,16 +121,16 @@ static void tokenize_b(int plane, int block, BLOCK_SIZE plane_bsize,
const int eob = pd->eobs[block];
const PLANE_TYPE type = pd->plane_type;
const int16_t *qcoeff_ptr = BLOCK_OFFSET(pd->qcoeff, block);
int seg_eob;
const int segment_id = mbmi->segment_id;
const int16_t *scan, *nb;
vp9_coeff_count *const counts = cpi->coef_counts[tx_size];
vp9_coeff_probs_model *const coef_probs = cpi->common.fc.coef_probs[tx_size];
const int ref = is_inter_block(mbmi);
ENTROPY_CONTEXT above_ec, left_ec;
uint8_t token_cache[1024];
const uint8_t *band_translate;
ENTROPY_CONTEXT *A, *L;
const int seg_eob = get_tx_eob(&cpi->common.seg, segment_id, tx_size);
int aoff, loff;
txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &aoff, &loff);
@ -139,45 +139,9 @@ static void tokenize_b(int plane, int block, BLOCK_SIZE plane_bsize,
assert((!type && !plane) || (type && plane));
switch (tx_size) {
case TX_4X4:
above_ec = A[0] != 0;
left_ec = L[0] != 0;
seg_eob = 16;
scan = get_scan_4x4(get_tx_type_4x4(type, xd, block));
band_translate = vp9_coefband_trans_4x4;
break;
case TX_8X8:
above_ec = !!*(uint16_t *)A;
left_ec = !!*(uint16_t *)L;
seg_eob = 64;
scan = get_scan_8x8(get_tx_type_8x8(type, xd));
band_translate = vp9_coefband_trans_8x8plus;
break;
case TX_16X16:
above_ec = !!*(uint32_t *)A;
left_ec = !!*(uint32_t *)L;
seg_eob = 256;
scan = get_scan_16x16(get_tx_type_16x16(type, xd));
band_translate = vp9_coefband_trans_8x8plus;
break;
case TX_32X32:
above_ec = !!*(uint64_t *)A;
left_ec = !!*(uint64_t *)L;
seg_eob = 1024;
scan = vp9_default_scan_32x32;
band_translate = vp9_coefband_trans_8x8plus;
break;
default:
assert(!"Invalid transform size");
}
pt = combine_entropy_contexts(above_ec, left_ec);
pt = get_entropy_context(xd, tx_size, type, block, A, L,
&scan, &band_translate);
nb = vp9_get_coef_neighbors_handle(scan);
if (vp9_segfeature_active(&cpi->common.seg, segment_id, SEG_LVL_SKIP))
seg_eob = 0;
c = 0;
do {
const int band = get_coef_band(band_translate, c);