Commit a23c2a9e authored by Dmitry Kovalev's avatar Dmitry Kovalev
Browse files

Adding get_scan_and_band function.

Extracting get_scan_and_band function from get_entropy_context to
remove duplicated code.

Change-Id: I5da1f5a60263017e887da68bc834317b5f084cb2
parent 1600707d
......@@ -336,45 +336,61 @@ 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) {
static int get_entropy_context(TX_SIZE tx_size,
ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l) {
ENTROPY_CONTEXT above_ec = 0, left_ec = 0;
switch (tx_size) {
case TX_4X4:
above_ec = a[0] != 0;
left_ec = l[0] != 0;
break;
case TX_8X8:
above_ec = !!*(uint16_t *)a;
left_ec = !!*(uint16_t *)l;
break;
case TX_16X16:
above_ec = !!*(uint32_t *)a;
left_ec = !!*(uint32_t *)l;
break;
case TX_32X32:
above_ec = !!*(uint64_t *)a;
left_ec = !!*(uint64_t *)l;
break;
default:
assert(!"Invalid transform size.");
}
return combine_entropy_contexts(above_ec, left_ec);
}
static void get_scan_and_band(const MACROBLOCKD *xd, TX_SIZE tx_size,
PLANE_TYPE type, int block_idx,
const int16_t **scan,
const uint8_t **band_translate) {
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_
......@@ -105,8 +105,8 @@ static int decode_coefs(VP9_COMMON *cm, const MACROBLOCKD *xd,
const int16_t *scan, *nb;
const uint8_t *band_translate;
uint8_t token_cache[1024];
int pt = get_entropy_context(xd, tx_size, type, block_idx, A, L,
&scan, &band_translate);
int pt = get_entropy_context(tx_size, A, L);
get_scan_and_band(xd, tx_size, type, block_idx, &scan, &band_translate);
nb = vp9_get_coef_neighbors_handle(scan);
while (1) {
......
......@@ -161,7 +161,7 @@ static void optimize_b(MACROBLOCK *mb,
int best, band, pt;
PLANE_TYPE type = pd->plane_type;
int err_mult = plane_rd_mult[type];
int default_eob;
const int default_eob = 16 << (tx_size << 1);
const int16_t *scan, *nb;
const int mul = 1 + (tx_size == TX_32X32);
uint8_t token_cache[1024];
......@@ -172,29 +172,7 @@ static void optimize_b(MACROBLOCK *mb,
assert((!type && !plane) || (type && plane));
dqcoeff_ptr = BLOCK_OFFSET(pd->dqcoeff, block);
qcoeff_ptr = BLOCK_OFFSET(pd->qcoeff, block);
switch (tx_size) {
default:
case TX_4X4:
default_eob = 16;
scan = get_scan_4x4(get_tx_type_4x4(type, xd, ib));
band_translate = vp9_coefband_trans_4x4;
break;
case TX_8X8:
scan = get_scan_8x8(get_tx_type_8x8(type, xd));
default_eob = 64;
band_translate = vp9_coefband_trans_8x8plus;
break;
case TX_16X16:
scan = get_scan_16x16(get_tx_type_16x16(type, xd));
default_eob = 256;
band_translate = vp9_coefband_trans_8x8plus;
break;
case TX_32X32:
scan = vp9_default_scan_32x32;
default_eob = 1024;
band_translate = vp9_coefband_trans_8x8plus;
break;
}
get_scan_and_band(xd, tx_size, type, ib, &scan, &band_translate);
assert(eob <= default_eob);
/* Now set up a Viterbi trellis to evaluate alternative roundings. */
......
......@@ -129,18 +129,15 @@ static void tokenize_b(int plane, int block, BLOCK_SIZE plane_bsize,
const int ref = is_inter_block(mbmi);
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);
A = pd->above_context + aoff;
L = pd->left_context + loff;
assert((!type && !plane) || (type && plane));
pt = get_entropy_context(xd, tx_size, type, block, A, L,
&scan, &band_translate);
pt = get_entropy_context(tx_size, pd->above_context + aoff,
pd->left_context + loff);
get_scan_and_band(xd, tx_size, type, block, &scan, &band_translate);
nb = vp9_get_coef_neighbors_handle(scan);
c = 0;
do {
......
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