Adding get_scan_and_band function.
Extracting get_scan_and_band function from get_entropy_context to remove duplicated code. Change-Id: I5da1f5a60263017e887da68bc834317b5f084cb2
This commit is contained in:
@@ -336,37 +336,26 @@ static INLINE const int16_t* get_iscan_16x16(TX_TYPE tx_type) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int get_entropy_context(const MACROBLOCKD *xd, TX_SIZE tx_size,
|
static int get_entropy_context(TX_SIZE tx_size,
|
||||||
PLANE_TYPE type, int block_idx,
|
ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l) {
|
||||||
ENTROPY_CONTEXT *A, ENTROPY_CONTEXT *L,
|
|
||||||
const int16_t **scan,
|
|
||||||
const uint8_t **band_translate) {
|
|
||||||
ENTROPY_CONTEXT above_ec = 0, left_ec = 0;
|
ENTROPY_CONTEXT above_ec = 0, left_ec = 0;
|
||||||
|
|
||||||
switch (tx_size) {
|
switch (tx_size) {
|
||||||
case TX_4X4:
|
case TX_4X4:
|
||||||
*scan = get_scan_4x4(get_tx_type_4x4(type, xd, block_idx));
|
above_ec = a[0] != 0;
|
||||||
*band_translate = vp9_coefband_trans_4x4;
|
left_ec = l[0] != 0;
|
||||||
above_ec = A[0] != 0;
|
|
||||||
left_ec = L[0] != 0;
|
|
||||||
break;
|
break;
|
||||||
case TX_8X8:
|
case TX_8X8:
|
||||||
*scan = get_scan_8x8(get_tx_type_8x8(type, xd));
|
above_ec = !!*(uint16_t *)a;
|
||||||
*band_translate = vp9_coefband_trans_8x8plus;
|
left_ec = !!*(uint16_t *)l;
|
||||||
above_ec = !!*(uint16_t *)A;
|
|
||||||
left_ec = !!*(uint16_t *)L;
|
|
||||||
break;
|
break;
|
||||||
case TX_16X16:
|
case TX_16X16:
|
||||||
*scan = get_scan_16x16(get_tx_type_16x16(type, xd));
|
above_ec = !!*(uint32_t *)a;
|
||||||
*band_translate = vp9_coefband_trans_8x8plus;
|
left_ec = !!*(uint32_t *)l;
|
||||||
above_ec = !!*(uint32_t *)A;
|
|
||||||
left_ec = !!*(uint32_t *)L;
|
|
||||||
break;
|
break;
|
||||||
case TX_32X32:
|
case TX_32X32:
|
||||||
*scan = vp9_default_scan_32x32;
|
above_ec = !!*(uint64_t *)a;
|
||||||
*band_translate = vp9_coefband_trans_8x8plus;
|
left_ec = !!*(uint64_t *)l;
|
||||||
above_ec = !!*(uint64_t *)A;
|
|
||||||
left_ec = !!*(uint64_t *)L;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
assert(!"Invalid transform size.");
|
assert(!"Invalid transform size.");
|
||||||
@@ -375,6 +364,33 @@ static int get_entropy_context(const MACROBLOCKD *xd, TX_SIZE tx_size,
|
|||||||
return combine_entropy_contexts(above_ec, left_ec);
|
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;
|
||||||
|
break;
|
||||||
|
case TX_8X8:
|
||||||
|
*scan = get_scan_8x8(get_tx_type_8x8(type, xd));
|
||||||
|
*band_translate = vp9_coefband_trans_8x8plus;
|
||||||
|
break;
|
||||||
|
case TX_16X16:
|
||||||
|
*scan = get_scan_16x16(get_tx_type_16x16(type, xd));
|
||||||
|
*band_translate = vp9_coefband_trans_8x8plus;
|
||||||
|
break;
|
||||||
|
case TX_32X32:
|
||||||
|
*scan = vp9_default_scan_32x32;
|
||||||
|
*band_translate = vp9_coefband_trans_8x8plus;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
assert(!"Invalid transform size.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
enum { VP9_COEF_UPDATE_PROB = 252 };
|
enum { VP9_COEF_UPDATE_PROB = 252 };
|
||||||
|
|
||||||
#endif // VP9_COMMON_VP9_ENTROPY_H_
|
#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 int16_t *scan, *nb;
|
||||||
const uint8_t *band_translate;
|
const uint8_t *band_translate;
|
||||||
uint8_t token_cache[1024];
|
uint8_t token_cache[1024];
|
||||||
int pt = get_entropy_context(xd, tx_size, type, block_idx, A, L,
|
int pt = get_entropy_context(tx_size, A, L);
|
||||||
&scan, &band_translate);
|
get_scan_and_band(xd, tx_size, type, block_idx, &scan, &band_translate);
|
||||||
nb = vp9_get_coef_neighbors_handle(scan);
|
nb = vp9_get_coef_neighbors_handle(scan);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
@@ -161,7 +161,7 @@ static void optimize_b(MACROBLOCK *mb,
|
|||||||
int best, band, pt;
|
int best, band, pt;
|
||||||
PLANE_TYPE type = pd->plane_type;
|
PLANE_TYPE type = pd->plane_type;
|
||||||
int err_mult = plane_rd_mult[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 int16_t *scan, *nb;
|
||||||
const int mul = 1 + (tx_size == TX_32X32);
|
const int mul = 1 + (tx_size == TX_32X32);
|
||||||
uint8_t token_cache[1024];
|
uint8_t token_cache[1024];
|
||||||
@@ -172,29 +172,7 @@ static void optimize_b(MACROBLOCK *mb,
|
|||||||
assert((!type && !plane) || (type && plane));
|
assert((!type && !plane) || (type && plane));
|
||||||
dqcoeff_ptr = BLOCK_OFFSET(pd->dqcoeff, block);
|
dqcoeff_ptr = BLOCK_OFFSET(pd->dqcoeff, block);
|
||||||
qcoeff_ptr = BLOCK_OFFSET(pd->qcoeff, block);
|
qcoeff_ptr = BLOCK_OFFSET(pd->qcoeff, block);
|
||||||
switch (tx_size) {
|
get_scan_and_band(xd, tx_size, type, ib, &scan, &band_translate);
|
||||||
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;
|
|
||||||
}
|
|
||||||
assert(eob <= default_eob);
|
assert(eob <= default_eob);
|
||||||
|
|
||||||
/* Now set up a Viterbi trellis to evaluate alternative roundings. */
|
/* 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);
|
const int ref = is_inter_block(mbmi);
|
||||||
uint8_t token_cache[1024];
|
uint8_t token_cache[1024];
|
||||||
const uint8_t *band_translate;
|
const uint8_t *band_translate;
|
||||||
ENTROPY_CONTEXT *A, *L;
|
|
||||||
const int seg_eob = get_tx_eob(&cpi->common.seg, segment_id, tx_size);
|
const int seg_eob = get_tx_eob(&cpi->common.seg, segment_id, tx_size);
|
||||||
int aoff, loff;
|
int aoff, loff;
|
||||||
txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &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));
|
assert((!type && !plane) || (type && plane));
|
||||||
|
|
||||||
pt = get_entropy_context(xd, tx_size, type, block, A, L,
|
pt = get_entropy_context(tx_size, pd->above_context + aoff,
|
||||||
&scan, &band_translate);
|
pd->left_context + loff);
|
||||||
|
get_scan_and_band(xd, tx_size, type, block, &scan, &band_translate);
|
||||||
nb = vp9_get_coef_neighbors_handle(scan);
|
nb = vp9_get_coef_neighbors_handle(scan);
|
||||||
c = 0;
|
c = 0;
|
||||||
do {
|
do {
|
||||||
|
Reference in New Issue
Block a user