foreach_transformed_block_in_plane cleanup, explicit tx_size var.
Making foreach_transformed_block_in_plane more clear (it's not finished yet). Using explicit tx_size variable consistently instead of (ss_txfrm_size / 2) or (ss_txfrm_size >> 1) expression. Change-Id: I1b9bba2c0a9f817fca72c88324bbe6004766fb7d
This commit is contained in:
parent
f2c073efaa
commit
bb072000e8
@ -393,7 +393,7 @@ static INLINE struct plane_block_idx plane_block_idx(int y_blocks,
|
||||
}
|
||||
|
||||
static BLOCK_SIZE_TYPE get_plane_block_size(BLOCK_SIZE_TYPE bsize,
|
||||
struct macroblockd_plane *pd) {
|
||||
const struct macroblockd_plane *pd) {
|
||||
BLOCK_SIZE_TYPE bs = ss_size_lookup[bsize]
|
||||
[pd->subsampling_x][pd->subsampling_y];
|
||||
assert(bs < BLOCK_SIZES);
|
||||
@ -418,7 +418,7 @@ typedef void (*foreach_transformed_block_visitor)(int plane, int block,
|
||||
static INLINE void foreach_transformed_block_in_plane(
|
||||
const MACROBLOCKD* const xd, BLOCK_SIZE_TYPE bsize, int plane,
|
||||
foreach_transformed_block_visitor visit, void *arg) {
|
||||
const int bw = b_width_log2(bsize), bh = b_height_log2(bsize);
|
||||
const struct macroblockd_plane *const pd = &xd->plane[plane];
|
||||
|
||||
// block and transform sizes, in number of 4x4 blocks log 2 ("*_b")
|
||||
// 4x4=0, 8x8=2, 16x16=4, 32x32=6, 64x64=8
|
||||
@ -426,56 +426,45 @@ static INLINE void foreach_transformed_block_in_plane(
|
||||
const MB_MODE_INFO* mbmi = &xd->mode_info_context->mbmi;
|
||||
const TX_SIZE tx_size = plane ? get_uv_tx_size(mbmi)
|
||||
: mbmi->txfm_size;
|
||||
const int block_size_b = bw + bh;
|
||||
const int bw = b_width_log2(bsize) - pd->subsampling_x;
|
||||
const int bh = b_height_log2(bsize) - pd->subsampling_y;
|
||||
const int txfrm_size_b = tx_size * 2;
|
||||
|
||||
// subsampled size of the block
|
||||
const int ss_sum = xd->plane[plane].subsampling_x
|
||||
+ xd->plane[plane].subsampling_y;
|
||||
const int ss_block_size = block_size_b - ss_sum;
|
||||
|
||||
const int step = 1 << txfrm_size_b;
|
||||
|
||||
int i;
|
||||
|
||||
assert(txfrm_size_b <= block_size_b);
|
||||
assert(txfrm_size_b <= ss_block_size);
|
||||
|
||||
// If mb_to_right_edge is < 0 we are in a situation in which
|
||||
// the current block size extends into the UMV and we won't
|
||||
// visit the sub blocks that are wholly within the UMV.
|
||||
if (xd->mb_to_right_edge < 0 || xd->mb_to_bottom_edge < 0) {
|
||||
int r, c;
|
||||
const int sw = bw - xd->plane[plane].subsampling_x;
|
||||
const int sh = bh - xd->plane[plane].subsampling_y;
|
||||
int max_blocks_wide = 1 << sw;
|
||||
int max_blocks_high = 1 << sh;
|
||||
|
||||
int max_blocks_wide = 1 << bw;
|
||||
int max_blocks_high = 1 << bh;
|
||||
|
||||
// xd->mb_to_right_edge is in units of pixels * 8. This converts
|
||||
// it to 4x4 block sizes.
|
||||
if (xd->mb_to_right_edge < 0)
|
||||
max_blocks_wide +=
|
||||
(xd->mb_to_right_edge >> (5 + xd->plane[plane].subsampling_x));
|
||||
max_blocks_wide += (xd->mb_to_right_edge >> (5 + pd->subsampling_x));
|
||||
|
||||
if (xd->mb_to_bottom_edge < 0)
|
||||
max_blocks_high +=
|
||||
(xd->mb_to_bottom_edge >> (5 + xd->plane[plane].subsampling_y));
|
||||
max_blocks_high += (xd->mb_to_bottom_edge >> (5 + pd->subsampling_y));
|
||||
|
||||
i = 0;
|
||||
// Unlike the normal case - in here we have to keep track of the
|
||||
// row and column of the blocks we use so that we know if we are in
|
||||
// the unrestricted motion border.
|
||||
for (r = 0; r < (1 << sh); r += (1 << tx_size)) {
|
||||
for (c = 0; c < (1 << sw); c += (1 << tx_size)) {
|
||||
for (r = 0; r < (1 << bh); r += (1 << tx_size)) {
|
||||
for (c = 0; c < (1 << bw); c += (1 << tx_size)) {
|
||||
if (r < max_blocks_high && c < max_blocks_wide)
|
||||
visit(plane, i, bsize, txfrm_size_b, arg);
|
||||
i += step;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < (1 << ss_block_size); i += step) {
|
||||
const int ss_block_size = bw + bh;
|
||||
assert(txfrm_size_b <= ss_block_size);
|
||||
for (i = 0; i < (1 << ss_block_size); i += step)
|
||||
visit(plane, i, bsize, txfrm_size_b, arg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -484,10 +473,8 @@ static INLINE void foreach_transformed_block(
|
||||
foreach_transformed_block_visitor visit, void *arg) {
|
||||
int plane;
|
||||
|
||||
for (plane = 0; plane < MAX_MB_PLANE; plane++) {
|
||||
foreach_transformed_block_in_plane(xd, bsize, plane,
|
||||
visit, arg);
|
||||
}
|
||||
for (plane = 0; plane < MAX_MB_PLANE; plane++)
|
||||
foreach_transformed_block_in_plane(xd, bsize, plane, visit, arg);
|
||||
}
|
||||
|
||||
static INLINE void foreach_transformed_block_uv(
|
||||
@ -495,10 +482,8 @@ static INLINE void foreach_transformed_block_uv(
|
||||
foreach_transformed_block_visitor visit, void *arg) {
|
||||
int plane;
|
||||
|
||||
for (plane = 1; plane < MAX_MB_PLANE; plane++) {
|
||||
foreach_transformed_block_in_plane(xd, bsize, plane,
|
||||
visit, arg);
|
||||
}
|
||||
for (plane = 1; plane < MAX_MB_PLANE; plane++)
|
||||
foreach_transformed_block_in_plane(xd, bsize, plane, visit, arg);
|
||||
}
|
||||
|
||||
// TODO(jkoleszar): In principle, pred_w, pred_h are unnecessary, as we could
|
||||
@ -548,9 +533,8 @@ static INLINE void foreach_predicted_block(
|
||||
foreach_predicted_block_visitor visit, void *arg) {
|
||||
int plane;
|
||||
|
||||
for (plane = 0; plane < MAX_MB_PLANE; plane++) {
|
||||
for (plane = 0; plane < MAX_MB_PLANE; plane++)
|
||||
foreach_predicted_block_in_plane(xd, bsize, plane, visit, arg);
|
||||
}
|
||||
}
|
||||
|
||||
static int raster_block_offset(MACROBLOCKD *xd, BLOCK_SIZE_TYPE bsize,
|
||||
@ -577,7 +561,7 @@ static int txfrm_block_to_raster_block(MACROBLOCKD *xd,
|
||||
int plane, int block,
|
||||
int ss_txfrm_size) {
|
||||
const int bwl = b_width_log2(bsize) - xd->plane[plane].subsampling_x;
|
||||
const int txwl = ss_txfrm_size / 2;
|
||||
const int txwl = ss_txfrm_size >> 1;
|
||||
const int tx_cols_log2 = bwl - txwl;
|
||||
const int tx_cols = 1 << tx_cols_log2;
|
||||
const int raster_mb = block >> ss_txfrm_size;
|
||||
@ -592,7 +576,7 @@ static void txfrm_block_to_raster_xy(MACROBLOCKD *xd,
|
||||
int ss_txfrm_size,
|
||||
int *x, int *y) {
|
||||
const int bwl = b_width_log2(bsize) - xd->plane[plane].subsampling_x;
|
||||
const int txwl = ss_txfrm_size / 2;
|
||||
const int txwl = ss_txfrm_size >> 1;
|
||||
const int tx_cols_log2 = bwl - txwl;
|
||||
const int tx_cols = 1 << tx_cols_log2;
|
||||
const int raster_mb = block >> ss_txfrm_size;
|
||||
@ -656,14 +640,14 @@ static void set_contexts_on_border(MACROBLOCKD *xd, BLOCK_SIZE_TYPE bsize,
|
||||
if (xd->mb_to_right_edge < 0)
|
||||
mi_blocks_wide += (xd->mb_to_right_edge >> (5 + pd->subsampling_x));
|
||||
|
||||
if (xd->mb_to_bottom_edge < 0)
|
||||
mi_blocks_high += (xd->mb_to_bottom_edge >> (5 + pd->subsampling_y));
|
||||
|
||||
// this code attempts to avoid copying into contexts that are outside
|
||||
// our border. Any blocks that do are set to 0...
|
||||
if (above_contexts + aoff > mi_blocks_wide)
|
||||
above_contexts = mi_blocks_wide - aoff;
|
||||
|
||||
if (xd->mb_to_bottom_edge < 0)
|
||||
mi_blocks_high += (xd->mb_to_bottom_edge >> (5 + pd->subsampling_y));
|
||||
|
||||
if (left_contexts + loff > mi_blocks_high)
|
||||
left_contexts = mi_blocks_high - loff;
|
||||
|
||||
|
@ -99,8 +99,9 @@ static void decode_block(int plane, int block, BLOCK_SIZE_TYPE bsize,
|
||||
uint8_t* const dst = raster_block_offset_uint8(xd, bsize, plane,
|
||||
raster_block,
|
||||
pd->dst.buf, stride);
|
||||
const TX_SIZE tx_size = (TX_SIZE)(ss_txfrm_size >> 1);
|
||||
|
||||
switch (ss_txfrm_size / 2) {
|
||||
switch (tx_size) {
|
||||
case TX_4X4: {
|
||||
const TX_TYPE tx_type = get_tx_type_4x4(pd->plane_type, xd, raster_block);
|
||||
if (tx_type == DCT_DCT)
|
||||
@ -120,6 +121,8 @@ static void decode_block(int plane, int block, BLOCK_SIZE_TYPE bsize,
|
||||
case TX_32X32:
|
||||
vp9_idct_add_32x32(qcoeff, dst, stride, eob);
|
||||
break;
|
||||
default:
|
||||
assert(!"Invalid transform size");
|
||||
}
|
||||
}
|
||||
|
||||
@ -134,7 +137,7 @@ static void decode_block_intra(int plane, int block, BLOCK_SIZE_TYPE bsize,
|
||||
uint8_t* const dst = raster_block_offset_uint8(xd, bsize, plane,
|
||||
raster_block,
|
||||
pd->dst.buf, pd->dst.stride);
|
||||
const TX_SIZE tx_size = (TX_SIZE)(ss_txfrm_size / 2);
|
||||
const TX_SIZE tx_size = (TX_SIZE)(ss_txfrm_size >> 1);
|
||||
int b_mode;
|
||||
int plane_b_size;
|
||||
const int tx_ib = raster_block >> tx_size;
|
||||
|
@ -260,19 +260,19 @@ static void decode_block(int plane, int block,
|
||||
MACROBLOCKD *xd = &arg->pbi->mb;
|
||||
struct macroblockd_plane* pd = &xd->plane[plane];
|
||||
const int segment_id = xd->mode_info_context->mbmi.segment_id;
|
||||
const TX_SIZE ss_tx_size = ss_txfrm_size / 2;
|
||||
const TX_SIZE tx_size = ss_txfrm_size >> 1;
|
||||
const int seg_eob = get_eob(&xd->seg, segment_id, 16 << ss_txfrm_size);
|
||||
const int off = block >> ss_txfrm_size;
|
||||
const int mod = bw - ss_tx_size - pd->subsampling_x;
|
||||
const int aoff = (off & ((1 << mod) - 1)) << ss_tx_size;
|
||||
const int loff = (off >> mod) << ss_tx_size;
|
||||
const int tx_size_in_blocks = 1 << ss_tx_size;
|
||||
const int mod = bw - tx_size - pd->subsampling_x;
|
||||
const int aoff = (off & ((1 << mod) - 1)) << tx_size;
|
||||
const int loff = (off >> mod) << tx_size;
|
||||
const int tx_size_in_blocks = 1 << tx_size;
|
||||
ENTROPY_CONTEXT *A = pd->above_context + aoff;
|
||||
ENTROPY_CONTEXT *L = pd->left_context + loff;
|
||||
const int eob = decode_coefs(&arg->pbi->common, xd, arg->r, block,
|
||||
pd->plane_type, seg_eob,
|
||||
BLOCK_OFFSET(pd->qcoeff, block),
|
||||
ss_tx_size, pd->dequant, A, L);
|
||||
tx_size, pd->dequant, A, L);
|
||||
|
||||
if (xd->mb_to_right_edge < 0 || xd->mb_to_bottom_edge < 0) {
|
||||
set_contexts_on_border(xd, bsize, plane, tx_size_in_blocks, eob, aoff, loff,
|
||||
|
@ -374,13 +374,14 @@ void vp9_optimize_b(int plane, int block, BLOCK_SIZE_TYPE bsize,
|
||||
int ss_txfrm_size, MACROBLOCK *mb,
|
||||
struct optimize_ctx *ctx) {
|
||||
MACROBLOCKD *const xd = &mb->e_mbd;
|
||||
const TX_SIZE tx_size = (TX_SIZE)(ss_txfrm_size >> 1);
|
||||
int x, y;
|
||||
|
||||
// find current entropy context
|
||||
txfrm_block_to_raster_xy(xd, bsize, plane, block, ss_txfrm_size, &x, &y);
|
||||
|
||||
optimize_b(mb, plane, block, bsize,
|
||||
&ctx->ta[plane][x], &ctx->tl[plane][y], ss_txfrm_size / 2);
|
||||
optimize_b(mb, plane, block, bsize, &ctx->ta[plane][x], &ctx->tl[plane][y],
|
||||
tx_size);
|
||||
}
|
||||
|
||||
static void optimize_block(int plane, int block, BLOCK_SIZE_TYPE bsize,
|
||||
@ -460,7 +461,7 @@ void xform_quant(int plane, int block, BLOCK_SIZE_TYPE bsize,
|
||||
int16_t *dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
|
||||
const int16_t *scan, *iscan;
|
||||
uint16_t *eob = &pd->eobs[block];
|
||||
const TX_SIZE tx_size = (TX_SIZE)(ss_txfrm_size / 2);
|
||||
const TX_SIZE tx_size = (TX_SIZE)(ss_txfrm_size >> 1);
|
||||
const int bwl = b_width_log2(bsize) - pd->subsampling_x, bw = 1 << bwl;
|
||||
const int twl = bwl - tx_size, twmask = (1 << twl) - 1;
|
||||
int xoff, yoff;
|
||||
@ -534,17 +535,17 @@ static void encode_block(int plane, int block, BLOCK_SIZE_TYPE bsize,
|
||||
uint8_t *const dst = raster_block_offset_uint8(xd, bsize, plane,
|
||||
raster_block,
|
||||
pd->dst.buf, pd->dst.stride);
|
||||
const TX_SIZE tx_size = (TX_SIZE)(ss_txfrm_size >> 1);
|
||||
|
||||
xform_quant(plane, block, bsize, ss_txfrm_size, arg);
|
||||
|
||||
if (x->optimize)
|
||||
vp9_optimize_b(plane, block, bsize, ss_txfrm_size, x, args->ctx);
|
||||
|
||||
if (x->skip_encode)
|
||||
return;
|
||||
if (pd->eobs[block] == 0)
|
||||
if (x->skip_encode || pd->eobs[block] == 0)
|
||||
return;
|
||||
|
||||
switch (ss_txfrm_size / 2) {
|
||||
switch (tx_size) {
|
||||
case TX_32X32:
|
||||
vp9_short_idct32x32_add(dqcoeff, dst, pd->dst.stride);
|
||||
break;
|
||||
@ -563,6 +564,8 @@ static void encode_block(int plane, int block, BLOCK_SIZE_TYPE bsize,
|
||||
inverse_transform_b_4x4_add(xd, pd->eobs[block], dqcoeff,
|
||||
dst, pd->dst.stride);
|
||||
break;
|
||||
default:
|
||||
assert(!"Invalid transform size");
|
||||
}
|
||||
}
|
||||
|
||||
@ -630,7 +633,7 @@ void encode_block_intra(int plane, int block, BLOCK_SIZE_TYPE bsize,
|
||||
MACROBLOCK *const x = args->x;
|
||||
MACROBLOCKD *const xd = &x->e_mbd;
|
||||
MB_MODE_INFO *mbmi = &xd->mode_info_context->mbmi;
|
||||
const TX_SIZE tx_size = (TX_SIZE)(ss_txfrm_size / 2);
|
||||
const TX_SIZE tx_size = (TX_SIZE)(ss_txfrm_size >> 1);
|
||||
struct macroblock_plane *const p = &x->plane[plane];
|
||||
struct macroblockd_plane *const pd = &xd->plane[plane];
|
||||
int16_t *coeff = BLOCK_OFFSET(p->coeff, block);
|
||||
|
@ -100,8 +100,8 @@ struct tokenize_b_args {
|
||||
static void set_entropy_context_b(int plane, int block, BLOCK_SIZE_TYPE bsize,
|
||||
int ss_txfrm_size, void *arg) {
|
||||
struct tokenize_b_args* const args = arg;
|
||||
TX_SIZE tx_size = ss_txfrm_size >> 1;
|
||||
MACROBLOCKD *xd = args->xd;
|
||||
const TX_SIZE tx_size = (TX_SIZE)(ss_txfrm_size >> 1);
|
||||
MACROBLOCKD *const xd = args->xd;
|
||||
const int bwl = b_width_log2(bsize);
|
||||
const int off = block >> (2 * tx_size);
|
||||
const int mod = bwl - tx_size - xd->plane[plane].subsampling_x;
|
||||
@ -127,7 +127,7 @@ static void tokenize_b(int plane, int block, BLOCK_SIZE_TYPE bsize,
|
||||
VP9_COMP *cpi = args->cpi;
|
||||
MACROBLOCKD *xd = args->xd;
|
||||
TOKENEXTRA **tp = args->tp;
|
||||
const TX_SIZE tx_size = ss_txfrm_size >> 1;
|
||||
const TX_SIZE tx_size = (TX_SIZE)(ss_txfrm_size >> 1);
|
||||
const int tx_size_in_blocks = 1 << tx_size;
|
||||
MB_MODE_INFO *mbmi = &xd->mode_info_context->mbmi;
|
||||
int pt; /* near block/prev token context index */
|
||||
|
Loading…
x
Reference in New Issue
Block a user