ref: 9451e8d37e89eb32f91fb844bf2ba31d16bc1526
parent: 939b1e4a8c7b1486bed570001915c34ca5605f64
parent: bb3b817c1e64e4f1460db0d5b3c65f44273c0944
author: Dmitry Kovalev <[email protected]>
date: Thu Aug 15 11:21:09 EDT 2013
Merge "Converting code from using ss_txfrm_size to tx_size."
--- a/vp9/common/vp9_blockd.h
+++ b/vp9/common/vp9_blockd.h
@@ -540,15 +540,15 @@
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);
}
@@ -555,14 +555,14 @@
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);
}
@@ -569,23 +569,26 @@
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 @@
// 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));
+ const int umv_border_start = bh + (xd->mb_to_bottom_edge >>
+ (3 + pd->subsampling_y));
int i;
- uint8_t c = *(xd->plane[plane].dst.buf
- + (umv_border_start - 1) * xd->plane[plane].dst.stride + x);
+ const uint8_t c = buf[(umv_border_start - 1) * stride + x];
+ uint8_t *d = &buf[umv_border_start * stride + x];
- uint8_t *d = xd->plane[plane].dst.buf
- + umv_border_start * xd->plane[plane].dst.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;
}
}
--- a/vp9/decoder/vp9_decodframe.c
+++ b/vp9/decoder/vp9_decodframe.c
@@ -90,17 +90,16 @@
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_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 @@
}
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,
--- a/vp9/encoder/vp9_encodemb.c
+++ b/vp9/encoder/vp9_encodemb.c
@@ -164,8 +164,7 @@
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 @@
}
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 @@
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 @@
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 @@
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:
--- a/vp9/encoder/vp9_encodemb.h
+++ b/vp9/encoder/vp9_encodemb.h
@@ -34,8 +34,7 @@
};
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);
--- a/vp9/encoder/vp9_rdopt.c
+++ b/vp9/encoder/vp9_rdopt.c
@@ -599,11 +599,10 @@
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,