Merge "Converting code from using ss_txfrm_size to tx_size."

This commit is contained in:
Dmitry Kovalev 2013-08-15 15:21:09 -07:00 committed by Gerrit Code Review
commit 9451e8d37e
5 changed files with 55 additions and 68 deletions

View File

@ -540,52 +540,55 @@ static int raster_block_offset(MACROBLOCKD *xd, BLOCK_SIZE_TYPE bsize,
return y * stride + x;
}
static int16_t* raster_block_offset_int16(MACROBLOCKD *xd,
BLOCK_SIZE_TYPE bsize,
int plane, int block, int16_t *base) {
BLOCK_SIZE_TYPE bsize,
int plane, int block, int16_t *base) {
const int stride = plane_block_width(bsize, &xd->plane[plane]);
return base + raster_block_offset(xd, bsize, plane, block, stride);
}
static uint8_t* raster_block_offset_uint8(MACROBLOCKD *xd,
BLOCK_SIZE_TYPE bsize,
int plane, int block,
uint8_t *base, int stride) {
BLOCK_SIZE_TYPE bsize,
int plane, int block,
uint8_t *base, int stride) {
return base + raster_block_offset(xd, bsize, plane, block, stride);
}
static int txfrm_block_to_raster_block(MACROBLOCKD *xd,
BLOCK_SIZE_TYPE bsize,
int plane, int block,
int ss_txfrm_size) {
TX_SIZE tx_size) {
const int bwl = b_width_log2(bsize) - xd->plane[plane].subsampling_x;
const int txwl = ss_txfrm_size >> 1;
const int tx_cols_log2 = bwl - txwl;
const int ss_txfrm_size = tx_size << 1;
const int tx_cols_log2 = bwl - tx_size;
const int tx_cols = 1 << tx_cols_log2;
const int raster_mb = block >> ss_txfrm_size;
const int x = (raster_mb & (tx_cols - 1)) << (txwl);
const int y = raster_mb >> tx_cols_log2 << (txwl);
const int x = (raster_mb & (tx_cols - 1)) << tx_size;
const int y = raster_mb >> tx_cols_log2 << tx_size;
return x + (y << bwl);
}
static void txfrm_block_to_raster_xy(MACROBLOCKD *xd,
BLOCK_SIZE_TYPE bsize,
int plane, int block,
int ss_txfrm_size,
TX_SIZE tx_size,
int *x, int *y) {
const int bwl = b_width_log2(bsize) - xd->plane[plane].subsampling_x;
const int txwl = ss_txfrm_size >> 1;
const int tx_cols_log2 = bwl - txwl;
const int ss_txfrm_size = tx_size << 1;
const int tx_cols_log2 = bwl - tx_size;
const int tx_cols = 1 << tx_cols_log2;
const int raster_mb = block >> ss_txfrm_size;
*x = (raster_mb & (tx_cols - 1)) << (txwl);
*y = raster_mb >> tx_cols_log2 << (txwl);
*x = (raster_mb & (tx_cols - 1)) << tx_size;
*y = raster_mb >> tx_cols_log2 << tx_size;
}
static void extend_for_intra(MACROBLOCKD* const xd, int plane, int block,
BLOCK_SIZE_TYPE bsize, int ss_txfrm_size) {
const int bw = plane_block_width(bsize, &xd->plane[plane]);
const int bh = plane_block_height(bsize, &xd->plane[plane]);
static void extend_for_intra(MACROBLOCKD* const xd, BLOCK_SIZE_TYPE bsize,
int plane, int block, TX_SIZE tx_size) {
struct macroblockd_plane *const pd = &xd->plane[plane];
uint8_t *const buf = pd->dst.buf;
const int stride = pd->dst.stride;
const int bw = plane_block_width(bsize, pd);
const int bh = plane_block_height(bsize, pd);
int x, y;
txfrm_block_to_raster_xy(xd, bsize, plane, block, ss_txfrm_size, &x, &y);
txfrm_block_to_raster_xy(xd, bsize, plane, block, tx_size, &x, &y);
x = x * 4 - 1;
y = y * 4 - 1;
// Copy a pixel into the umv if we are in a situation where the block size
@ -593,29 +596,23 @@ static void extend_for_intra(MACROBLOCKD* const xd, int plane, int block,
// TODO(JBB): Should be able to do the full extend in place so we don't have
// to do this multiple times.
if (xd->mb_to_right_edge < 0) {
int umv_border_start = bw
+ (xd->mb_to_right_edge >> (3 + xd->plane[plane].subsampling_x));
const int umv_border_start = bw + (xd->mb_to_right_edge >>
(3 + pd->subsampling_x));
if (x + bw > umv_border_start)
vpx_memset(
xd->plane[plane].dst.buf + y * xd->plane[plane].dst.stride
+ umv_border_start,
*(xd->plane[plane].dst.buf + y * xd->plane[plane].dst.stride
+ umv_border_start - 1),
bw);
vpx_memset(&buf[y * stride + umv_border_start],
buf[y * stride + umv_border_start - 1], bw);
}
if (xd->mb_to_bottom_edge < 0) {
int umv_border_start = bh
+ (xd->mb_to_bottom_edge >> (3 + xd->plane[plane].subsampling_y));
int i;
uint8_t c = *(xd->plane[plane].dst.buf
+ (umv_border_start - 1) * xd->plane[plane].dst.stride + x);
uint8_t *d = xd->plane[plane].dst.buf
+ umv_border_start * xd->plane[plane].dst.stride + x;
if (xd->mb_to_bottom_edge < 0) {
const int umv_border_start = bh + (xd->mb_to_bottom_edge >>
(3 + pd->subsampling_y));
int i;
const uint8_t c = buf[(umv_border_start - 1) * stride + x];
uint8_t *d = &buf[umv_border_start * stride + x];
if (y + bh > umv_border_start)
for (i = 0; i < bh; i++, d += xd->plane[plane].dst.stride)
for (i = 0; i < bh; ++i, d += stride)
*d = c;
}
}

View File

@ -90,17 +90,16 @@ static void init_dequantizer(VP9_COMMON *cm, MACROBLOCKD *xd) {
static void decode_block(int plane, int block, BLOCK_SIZE_TYPE bsize,
int ss_txfrm_size, void *arg) {
MACROBLOCKD* const xd = arg;
struct macroblockd_plane *pd = &xd->plane[plane];
struct macroblockd_plane *const pd = &xd->plane[plane];
int16_t* const qcoeff = BLOCK_OFFSET(pd->qcoeff, block);
const int stride = pd->dst.stride;
const int eob = pd->eobs[block];
const TX_SIZE tx_size = (TX_SIZE)(ss_txfrm_size >> 1);
const int raster_block = txfrm_block_to_raster_block(xd, bsize, plane,
block, ss_txfrm_size);
block, tx_size);
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 (tx_size) {
case TX_4X4: {
const TX_TYPE tx_type = get_tx_type_4x4(pd->plane_type, xd, raster_block);
@ -129,20 +128,18 @@ static void decode_block(int plane, int block, BLOCK_SIZE_TYPE bsize,
static void decode_block_intra(int plane, int block, BLOCK_SIZE_TYPE bsize,
int ss_txfrm_size, void *arg) {
MACROBLOCKD* const xd = arg;
struct macroblockd_plane *pd = &xd->plane[plane];
struct macroblockd_plane *const pd = &xd->plane[plane];
MODE_INFO *const mi = xd->mode_info_context;
const TX_SIZE tx_size = (TX_SIZE)(ss_txfrm_size >> 1);
const int raster_block = txfrm_block_to_raster_block(xd, bsize, plane,
block, ss_txfrm_size);
block, tx_size);
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);
int b_mode;
int plane_b_size;
const int tx_ib = raster_block >> tx_size;
const int mode = plane == 0 ? mi->mbmi.mode
: mi->mbmi.uv_mode;
const int mode = (plane == 0) ? mi->mbmi.mode : mi->mbmi.uv_mode;
if (plane == 0 && mi->mbmi.sb_type < BLOCK_8X8) {
assert(bsize == BLOCK_8X8);
@ -152,7 +149,7 @@ static void decode_block_intra(int plane, int block, BLOCK_SIZE_TYPE bsize,
}
if (xd->mb_to_right_edge < 0 || xd->mb_to_bottom_edge < 0)
extend_for_intra(xd, plane, block, bsize, ss_txfrm_size);
extend_for_intra(xd, bsize, plane, block, tx_size);
plane_b_size = b_width_log2(bsize) - pd->subsampling_x;
vp9_predict_intra_block(xd, tx_ib, plane_b_size, tx_size, b_mode,

View File

@ -164,8 +164,7 @@ static void optimize_b(MACROBLOCK *mb,
const int16_t *scan, *nb;
const int mul = 1 + (tx_size == TX_32X32);
uint8_t token_cache[1024];
const int ib = txfrm_block_to_raster_block(xd, bsize, plane,
block, 2 * tx_size);
const int ib = txfrm_block_to_raster_block(xd, bsize, plane, block, tx_size);
const int16_t *dequant_ptr = xd->plane[plane].dequant;
const uint8_t * band_translate;
@ -371,14 +370,12 @@ static void optimize_b(MACROBLOCK *mb,
}
void vp9_optimize_b(int plane, int block, BLOCK_SIZE_TYPE bsize,
int ss_txfrm_size, MACROBLOCK *mb,
struct optimize_ctx *ctx) {
TX_SIZE tx_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);
txfrm_block_to_raster_xy(xd, bsize, plane, block, tx_size, &x, &y);
optimize_b(mb, plane, block, bsize, &ctx->ta[plane][x], &ctx->tl[plane][y],
tx_size);
@ -387,7 +384,7 @@ void vp9_optimize_b(int plane, int block, BLOCK_SIZE_TYPE bsize,
static void optimize_block(int plane, int block, BLOCK_SIZE_TYPE bsize,
int ss_txfrm_size, void *arg) {
const struct encode_b_args* const args = arg;
vp9_optimize_b(plane, block, bsize, ss_txfrm_size, args->x, args->ctx);
vp9_optimize_b(plane, block, bsize, ss_txfrm_size >> 1, args->x, args->ctx);
}
void optimize_init_b(int plane, BLOCK_SIZE_TYPE bsize, void *arg) {
@ -528,19 +525,18 @@ static void encode_block(int plane, int block, BLOCK_SIZE_TYPE bsize,
struct encode_b_args *const args = arg;
MACROBLOCK *const x = args->x;
MACROBLOCKD *const xd = &x->e_mbd;
const TX_SIZE tx_size = (TX_SIZE)(ss_txfrm_size >> 1);
const int raster_block = txfrm_block_to_raster_block(xd, bsize, plane,
block, ss_txfrm_size);
block, tx_size);
struct macroblockd_plane *const pd = &xd->plane[plane];
int16_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
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);
vp9_optimize_b(plane, block, bsize, tx_size, x, args->ctx);
if (x->skip_encode || pd->eobs[block] == 0)
return;
@ -650,12 +646,11 @@ void encode_block_intra(int plane, int block, BLOCK_SIZE_TYPE bsize,
uint16_t *eob = &pd->eobs[block];
if (xd->mb_to_right_edge < 0 || xd->mb_to_bottom_edge < 0) {
extend_for_intra(xd, plane, block, bsize, ss_txfrm_size);
extend_for_intra(xd, bsize, plane, block, tx_size);
}
// if (x->optimize)
// vp9_optimize_b(plane, block, bsize, ss_txfrm_size,
// x, args->ctx);
// vp9_optimize_b(plane, block, bsize, tx_size, x, args->ctx);
switch (tx_size) {
case TX_32X32:

View File

@ -34,8 +34,7 @@ struct encode_b_args {
};
void vp9_optimize_b(int plane, int block, BLOCK_SIZE_TYPE bsize,
int ss_txfrm_size, MACROBLOCK *x,
struct optimize_ctx *ctx);
TX_SIZE tx_size, MACROBLOCK *x, struct optimize_ctx *ctx);
void vp9_optimize_sby(VP9_COMMON *cm, MACROBLOCK *x, BLOCK_SIZE_TYPE bsize);
void vp9_optimize_sbuv(VP9_COMMON *cm, MACROBLOCK *x, BLOCK_SIZE_TYPE bsize);

View File

@ -599,11 +599,10 @@ static void dist_block(int plane, int block, BLOCK_SIZE_TYPE bsize,
static void rate_block(int plane, int block, BLOCK_SIZE_TYPE bsize,
int ss_txfrm_size, void *arg) {
struct rdcost_block_args* args = arg;
MACROBLOCKD *const xd = &args->x->e_mbd;
int x_idx, y_idx;
MACROBLOCKD * const xd = &args->x->e_mbd;
txfrm_block_to_raster_xy(xd, bsize, plane, block, args->tx_size * 2, &x_idx,
&y_idx);
txfrm_block_to_raster_xy(xd, bsize, plane, block, args->tx_size,
&x_idx, &y_idx);
args->rate += cost_coeffs(args->x, plane, block,
xd->plane[plane].plane_type, args->t_above + x_idx,