Simplifies band-getting with a static array

Simplifies the code by implementing band mapping with static arrays.
A lot of the code complexity introduced in a previous patch
disappears.

Change-Id: Ia3fac36e594fb5ad2d55ae141c58bba4c55c2d28
This commit is contained in:
Deb Mukherjee 2013-11-13 16:02:06 -08:00
Родитель 8282c1a68d
Коммит cfcd5c4f61
9 изменённых файлов: 100 добавлений и 73 удалений

Просмотреть файл

@ -37,15 +37,78 @@ DECLARE_ALIGNED(16, const uint8_t, vp9_norm[256]) = {
};
DECLARE_ALIGNED(16, const uint8_t,
vp9_coefband_trans_8x8plus[MAXBAND_INDEX + 1]) = {
vp9_coefband_trans_8x8plus[1024]) = {
0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 5
4, 4, 4, 4, 4, 5,
// beyond MAXBAND_INDEX+1 all values are filled as 5
5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5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5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
};
DECLARE_ALIGNED(16, const uint8_t,
vp9_coefband_trans_4x4[MAXBAND_INDEX + 1]) = {
vp9_coefband_trans_4x4[16]) = {
0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5, 5,
5, 5, 5, 5, 5, 5
};
DECLARE_ALIGNED(16, const uint8_t, vp9_pt_energy_class[MAX_ENTROPY_TOKENS]) = {

Просмотреть файл

@ -120,12 +120,16 @@ static INLINE void reset_skip_context(MACROBLOCKD *xd, BLOCK_SIZE bsize) {
// This is the index in the scan order beyond which all coefficients for
// 8x8 transform and above are in the top band.
// For 4x4 blocks the index is less but to keep things common the lookup
// table for 4x4 is padded out to this index.
// This macro is currently unused but may be used by certain implementations
#define MAXBAND_INDEX 21
extern const uint8_t vp9_coefband_trans_8x8plus[MAXBAND_INDEX + 1];
extern const uint8_t vp9_coefband_trans_4x4[MAXBAND_INDEX + 1];
extern const uint8_t vp9_coefband_trans_8x8plus[1024];
extern const uint8_t vp9_coefband_trans_4x4[16];
static const uint8_t *get_band_translate(TX_SIZE tx_size) {
return tx_size == TX_4X4 ? vp9_coefband_trans_4x4
: vp9_coefband_trans_8x8plus;
}
// 128 lists of probabilities are stored for the following ONE node probs:
// 1, 3, 5, 7, ..., 253, 255

Просмотреть файл

@ -45,7 +45,6 @@ typedef struct TileWorkerData {
DECLARE_ALIGNED(16, int16_t, qcoeff[MAX_MB_PLANE][64 * 64]);
DECLARE_ALIGNED(16, int16_t, dqcoeff[MAX_MB_PLANE][64 * 64]);
DECLARE_ALIGNED(16, uint16_t, eobs[MAX_MB_PLANE][256]);
const uint8_t *band_translate[2];
} TileWorkerData;
static int read_be32(const uint8_t *p) {
@ -295,7 +294,6 @@ struct intra_args {
MACROBLOCKD *xd;
vp9_reader *r;
uint8_t *token_cache;
const uint8_t *band_translate[2];
};
static void predict_and_reconstruct_intra_block(int plane, int block,
@ -304,9 +302,6 @@ static void predict_and_reconstruct_intra_block(int plane, int block,
struct intra_args *const args = arg;
VP9_COMMON *const cm = args->cm;
MACROBLOCKD *const xd = args->xd;
const uint8_t *band_translate[2] = {
args->band_translate[0], args->band_translate[1]
};
struct macroblockd_plane *const pd = &xd->plane[plane];
MODE_INFO *const mi = xd->mi_8x8[0];
const MB_PREDICTION_MODE mode = (plane == 0)
@ -327,7 +322,7 @@ static void predict_and_reconstruct_intra_block(int plane, int block,
if (!mi->mbmi.skip_coeff) {
vp9_decode_block_tokens(cm, xd, plane, block, plane_bsize, x, y, tx_size,
args->r, args->token_cache, band_translate);
args->r, args->token_cache);
inverse_transform_block(xd, plane, block, tx_size, x, y);
}
}
@ -338,7 +333,6 @@ struct inter_args {
vp9_reader *r;
int *eobtotal;
uint8_t *token_cache;
const uint8_t *band_translate[2];
};
static void reconstruct_inter_block(int plane, int block,
@ -347,16 +341,12 @@ static void reconstruct_inter_block(int plane, int block,
struct inter_args *args = arg;
VP9_COMMON *const cm = args->cm;
MACROBLOCKD *const xd = args->xd;
const uint8_t *band_translate[2] = {
args->band_translate[0], args->band_translate[1]
};
int x, y;
txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &x, &y);
*args->eobtotal += vp9_decode_block_tokens(cm, xd, plane, block,
plane_bsize, x, y, tx_size,
args->r, args->token_cache,
band_translate);
args->r, args->token_cache);
inverse_transform_block(xd, plane, block, tx_size, x, y);
}
@ -408,8 +398,7 @@ static void decode_modes_b(VP9_COMMON *const cm, MACROBLOCKD *const xd,
const TileInfo *const tile,
int mi_row, int mi_col,
vp9_reader *r, BLOCK_SIZE bsize,
uint8_t *token_cache,
const uint8_t *band_translate[2]) {
uint8_t *token_cache) {
const int less8x8 = bsize < BLOCK_8X8;
MB_MODE_INFO *mbmi;
@ -432,7 +421,7 @@ static void decode_modes_b(VP9_COMMON *const cm, MACROBLOCKD *const xd,
if (!is_inter_block(mbmi)) {
struct intra_args arg = {
cm, xd, r, token_cache, {band_translate[0], band_translate[1]}
cm, xd, r, token_cache
};
foreach_transformed_block(xd, bsize, predict_and_reconstruct_intra_block,
&arg);
@ -452,8 +441,7 @@ static void decode_modes_b(VP9_COMMON *const cm, MACROBLOCKD *const xd,
if (!mbmi->skip_coeff) {
int eobtotal = 0;
struct inter_args arg = {
cm, xd, r, &eobtotal, token_cache,
{band_translate[0], band_translate[1]}
cm, xd, r, &eobtotal, token_cache
};
foreach_transformed_block(xd, bsize, reconstruct_inter_block, &arg);
if (!less8x8 && eobtotal == 0)
@ -494,8 +482,7 @@ static void decode_modes_sb(VP9_COMMON *const cm, MACROBLOCKD *const xd,
const TileInfo *const tile,
int mi_row, int mi_col,
vp9_reader* r, BLOCK_SIZE bsize,
uint8_t *token_cache,
const uint8_t *band_translate[2]) {
uint8_t *token_cache) {
const int hbs = num_8x8_blocks_wide_lookup[bsize] / 2;
PARTITION_TYPE partition;
BLOCK_SIZE subsize;
@ -506,37 +493,33 @@ static void decode_modes_sb(VP9_COMMON *const cm, MACROBLOCKD *const xd,
partition = read_partition(cm, xd, hbs, mi_row, mi_col, bsize, r);
subsize = get_subsize(bsize, partition);
if (subsize < BLOCK_8X8) {
decode_modes_b(cm, xd, tile, mi_row, mi_col, r, subsize, token_cache,
band_translate);
decode_modes_b(cm, xd, tile, mi_row, mi_col, r, subsize, token_cache);
} else {
switch (partition) {
case PARTITION_NONE:
decode_modes_b(cm, xd, tile, mi_row, mi_col, r, subsize, token_cache,
band_translate);
decode_modes_b(cm, xd, tile, mi_row, mi_col, r, subsize, token_cache);
break;
case PARTITION_HORZ:
decode_modes_b(cm, xd, tile, mi_row, mi_col, r, subsize, token_cache,
band_translate);
decode_modes_b(cm, xd, tile, mi_row, mi_col, r, subsize, token_cache);
if (mi_row + hbs < cm->mi_rows)
decode_modes_b(cm, xd, tile, mi_row + hbs, mi_col, r, subsize,
token_cache, band_translate);
token_cache);
break;
case PARTITION_VERT:
decode_modes_b(cm, xd, tile, mi_row, mi_col, r, subsize, token_cache,
band_translate);
decode_modes_b(cm, xd, tile, mi_row, mi_col, r, subsize, token_cache);
if (mi_col + hbs < cm->mi_cols)
decode_modes_b(cm, xd, tile, mi_row, mi_col + hbs, r, subsize,
token_cache, band_translate);
token_cache);
break;
case PARTITION_SPLIT:
decode_modes_sb(cm, xd, tile, mi_row, mi_col, r, subsize,
token_cache, band_translate);
token_cache);
decode_modes_sb(cm, xd, tile, mi_row, mi_col + hbs, r, subsize,
token_cache, band_translate);
token_cache);
decode_modes_sb(cm, xd, tile, mi_row + hbs, mi_col, r, subsize,
token_cache, band_translate);
token_cache);
decode_modes_sb(cm, xd, tile, mi_row + hbs, mi_col + hbs, r, subsize,
token_cache, band_translate);
token_cache);
break;
default:
assert(!"Invalid partition type");
@ -820,11 +803,8 @@ static void decode_tile(VP9D_COMP *pbi, const TileInfo *const tile,
vp9_zero(xd->left_seg_context);
for (mi_col = tile->mi_col_start; mi_col < tile->mi_col_end;
mi_col += MI_BLOCK_SIZE) {
const uint8_t *band_translate[2] = {
vp9_coefband_trans_4x4, pbi->coefband_trans_8x8plus
};
decode_modes_sb(cm, xd, tile, mi_row, mi_col, r, BLOCK_64X64,
pbi->token_cache, band_translate);
pbi->token_cache);
}
if (pbi->do_loopfilter_inline) {
@ -985,8 +965,7 @@ static int tile_worker_hook(void *arg1, void *arg2) {
mi_col += MI_BLOCK_SIZE) {
decode_modes_sb(tile_data->cm, &tile_data->xd, tile,
mi_row, mi_col, &tile_data->bit_reader, BLOCK_64X64,
tile_data->token_cache,
tile_data->band_translate);
tile_data->token_cache);
}
}
return !tile_data->xd.corrupted;
@ -1045,8 +1024,6 @@ static const uint8_t *decode_tiles_mt(VP9D_COMP *pbi, const uint8_t *data) {
tile_data->cm = cm;
tile_data->xd = pbi->mb;
tile_data->xd.corrupted = 0;
tile_data->band_translate[0] = vp9_coefband_trans_4x4;
tile_data->band_translate[1] = pbi->coefband_trans_8x8plus;
vp9_tile_init(tile, tile_data->cm, 0, tile_col);
setup_token_decoder(data, data_end, size, &cm->error,

Просмотреть файл

@ -93,8 +93,7 @@ static int decode_coefs(VP9_COMMON *cm, const MACROBLOCKD *xd,
vp9_reader *r, int block_idx,
PLANE_TYPE type, int seg_eob, int16_t *dqcoeff_ptr,
TX_SIZE tx_size, const int16_t *dq, int pt,
uint8_t *token_cache,
const uint8_t *band_translate) {
uint8_t *token_cache) {
const FRAME_CONTEXT *const fc = &cm->fc;
FRAME_COUNTS *const counts = &cm->counts;
const int ref = is_inter_block(&xd->mi_8x8[0]->mbmi);
@ -110,6 +109,7 @@ static int decode_coefs(VP9_COMMON *cm, const MACROBLOCKD *xd,
counts->eob_branch[tx_size][type][ref];
const int16_t *scan, *nb;
const uint8_t *cat6;
const uint8_t *band_translate = get_band_translate(tx_size);
get_scan(xd, tx_size, type, block_idx, &scan, &nb);
while (c < seg_eob) {
@ -219,8 +219,7 @@ static int decode_coefs(VP9_COMMON *cm, const MACROBLOCKD *xd,
int vp9_decode_block_tokens(VP9_COMMON *cm, MACROBLOCKD *xd,
int plane, int block, BLOCK_SIZE plane_bsize,
int x, int y, TX_SIZE tx_size, vp9_reader *r,
uint8_t *token_cache,
const uint8_t *band_translate[2]) {
uint8_t *token_cache) {
struct macroblockd_plane *const pd = &xd->plane[plane];
const int seg_eob = get_tx_eob(&cm->seg, xd->mi_8x8[0]->mbmi.segment_id,
tx_size);
@ -228,8 +227,7 @@ int vp9_decode_block_tokens(VP9_COMMON *cm, MACROBLOCKD *xd,
pd->left_context + y);
const int eob = decode_coefs(cm, xd, r, block, pd->plane_type, seg_eob,
BLOCK_OFFSET(pd->dqcoeff, block), tx_size,
pd->dequant, pt, token_cache,
band_translate[tx_size != TX_4X4]);
pd->dequant, pt, token_cache);
set_contexts(xd, pd, plane_bsize, tx_size, eob > 0, x, y);
pd->eobs[block] = eob;
return eob;

Просмотреть файл

@ -18,7 +18,6 @@
int vp9_decode_block_tokens(VP9_COMMON *cm, MACROBLOCKD *xd,
int plane, int block, BLOCK_SIZE plane_bsize,
int x, int y, TX_SIZE tx_size, vp9_reader *r,
uint8_t *token_cache,
const uint8_t *band_translate[2]);
uint8_t *token_cache);
#endif // VP9_DECODER_VP9_DETOKENIZE_H_

Просмотреть файл

@ -194,9 +194,6 @@ struct macroblock {
BLOCK_SIZE sb64_partitioning;
void (*fwd_txm4x4)(const int16_t *input, int16_t *output, int stride);
// band cache
DECLARE_ALIGNED(16, uint8_t, coefband_trans_8x8plus[1024]);
};
// TODO(jingning): the variables used here are little complicated. need further

Просмотреть файл

@ -137,9 +137,7 @@ static void optimize_b(MACROBLOCK *mb,
const int mul = 1 + (tx_size == TX_32X32);
uint8_t token_cache[1024];
const int16_t *dequant_ptr = pd->dequant;
const uint8_t *const band_translate = (tx_size == TX_4X4 ?
vp9_coefband_trans_4x4 :
mb->coefband_trans_8x8plus);
const uint8_t *const band_translate = get_band_translate(tx_size);
assert((!type && !plane) || (type && plane));
dqcoeff_ptr = BLOCK_OFFSET(pd->dqcoeff, block);

Просмотреть файл

@ -1224,13 +1224,6 @@ static void init_config(VP9_PTR ptr, VP9_CONFIG *oxcf) {
cpi->fixed_divide[0] = 0;
for (i = 1; i < 512; i++)
cpi->fixed_divide[i] = 0x80000 / i;
vpx_memset(cpi->mb.coefband_trans_8x8plus,
(COEF_BANDS-1),
sizeof(cpi->mb.coefband_trans_8x8plus));
vpx_memcpy(cpi->mb.coefband_trans_8x8plus,
vp9_coefband_trans_8x8plus,
sizeof(vp9_coefband_trans_8x8plus));
}

Просмотреть файл

@ -115,9 +115,7 @@ static void tokenize_b(int plane, int block, BLOCK_SIZE plane_bsize,
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);
const uint8_t *const band_translate = (tx_size == TX_4X4 ?
vp9_coefband_trans_4x4 :
cpi->mb.coefband_trans_8x8plus);
const uint8_t *const band_translate = get_band_translate(tx_size);
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);