foreach_predicted_block_in_plane(xd, bsize, plane, visit, arg);
}
-static int raster_block_offset(MACROBLOCKD *xd, BLOCK_SIZE_TYPE bsize,
- int plane, int block, int stride) {
- const int bw = b_width_log2(bsize) - xd->plane[plane].subsampling_x;
- const int y = 4 * (block >> bw), x = 4 * (block & ((1 << bw) - 1));
+static int raster_block_offset(BLOCK_SIZE_TYPE plane_bsize,
+ int raster_block, int stride) {
+ const int bw = b_width_log2(plane_bsize);
+ const int y = 4 * (raster_block >> bw);
+ const int x = 4 * (raster_block & ((1 << bw) - 1));
return y * stride + x;
}
-static int16_t* raster_block_offset_int16(MACROBLOCKD *xd,
- 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 int16_t* raster_block_offset_int16(BLOCK_SIZE_TYPE plane_bsize,
+ int raster_block, int16_t *base) {
+ const int stride = 4 << b_width_log2(plane_bsize);
+ return base + raster_block_offset(plane_bsize, raster_block, stride);
}
-static uint8_t* raster_block_offset_uint8(MACROBLOCKD *xd,
- BLOCK_SIZE_TYPE bsize,
- int plane, int block,
- uint8_t *base, int stride) {
- return base + raster_block_offset(xd, bsize, plane, block, stride);
+static uint8_t* raster_block_offset_uint8(BLOCK_SIZE_TYPE plane_bsize,
+ int raster_block, uint8_t *base,
+ int stride) {
+ return base + raster_block_offset(plane_bsize, raster_block, stride);
}
-static int txfrm_block_to_raster_block(MACROBLOCKD *xd,
- BLOCK_SIZE_TYPE bsize,
- int plane, int block,
- TX_SIZE tx_size) {
- const int bwl = b_width_log2(bsize) - xd->plane[plane].subsampling_x;
+static int txfrm_block_to_raster_block(BLOCK_SIZE_TYPE plane_bsize,
+ TX_SIZE tx_size, int block) {
+ const int bwl = b_width_log2(plane_bsize);
const int tx_cols_log2 = bwl - tx_size;
const int tx_cols = 1 << tx_cols_log2;
const int raster_mb = block >> (tx_size << 1);
const int x = (raster_mb & (tx_cols - 1)) << tx_size;
- const int y = raster_mb >> tx_cols_log2 << 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,
- TX_SIZE tx_size,
+static void txfrm_block_to_raster_xy(BLOCK_SIZE_TYPE plane_bsize,
+ TX_SIZE tx_size, int block,
int *x, int *y) {
- const int bwl = b_width_log2(bsize) - xd->plane[plane].subsampling_x;
+ const int bwl = b_width_log2(plane_bsize);
const int tx_cols_log2 = bwl - tx_size;
const int tx_cols = 1 << tx_cols_log2;
const int raster_mb = block >> (tx_size << 1);
*y = raster_mb >> tx_cols_log2 << tx_size;
}
-static void extend_for_intra(MACROBLOCKD* const xd, BLOCK_SIZE_TYPE bsize,
+static void extend_for_intra(MACROBLOCKD* const xd, BLOCK_SIZE_TYPE plane_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, tx_size, &x, &y);
+ txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &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
// 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) {
+ const int bw = 4 << b_width_log2(plane_bsize);
const int umv_border_start = bw + (xd->mb_to_right_edge >>
(3 + pd->subsampling_x));
}
if (xd->mb_to_bottom_edge < 0) {
+ const int bh = 4 << b_height_log2(plane_bsize);
const int umv_border_start = bh + (xd->mb_to_bottom_edge >>
(3 + pd->subsampling_y));
int i;
TX_SIZE tx_size, void *arg) {
MACROBLOCKD* const xd = arg;
struct macroblockd_plane *const pd = &xd->plane[plane];
+ const BLOCK_SIZE_TYPE plane_bsize = get_plane_block_size(bsize, pd);
int16_t* const qcoeff = BLOCK_OFFSET(pd->qcoeff, block);
const int stride = pd->dst.stride;
const int eob = pd->eobs[block];
- const int raster_block = txfrm_block_to_raster_block(xd, bsize, plane,
- block, tx_size);
- uint8_t* const dst = raster_block_offset_uint8(xd, bsize, plane,
- raster_block,
+ const int raster_block = txfrm_block_to_raster_block(plane_bsize, tx_size,
+ block);
+ uint8_t* const dst = raster_block_offset_uint8(plane_bsize, raster_block,
pd->dst.buf, stride);
switch (tx_size) {
case TX_4X4: {
TX_SIZE tx_size, void *arg) {
MACROBLOCKD* const xd = arg;
struct macroblockd_plane *const pd = &xd->plane[plane];
+ const BLOCK_SIZE_TYPE plane_bsize = get_plane_block_size(bsize, pd);
MODE_INFO *const mi = xd->mode_info_context;
- const int raster_block = txfrm_block_to_raster_block(xd, bsize, plane,
- block, tx_size);
- uint8_t* const dst = raster_block_offset_uint8(xd, bsize, plane,
- raster_block,
+ const int raster_block = txfrm_block_to_raster_block(plane_bsize, tx_size,
+ block);
+ uint8_t* const dst = raster_block_offset_uint8(plane_bsize, raster_block,
pd->dst.buf, pd->dst.stride);
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;
}
if (xd->mb_to_right_edge < 0 || xd->mb_to_bottom_edge < 0)
- extend_for_intra(xd, bsize, plane, block, tx_size);
+ extend_for_intra(xd, plane_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,
+ vp9_predict_intra_block(xd, tx_ib, b_width_log2(plane_bsize), tx_size, b_mode,
dst, pd->dst.stride,
dst, pd->dst.stride);
ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l,
TX_SIZE tx_size) {
MACROBLOCKD *const xd = &mb->e_mbd;
+ struct macroblockd_plane *pd = &xd->plane[plane];
+ const BLOCK_SIZE_TYPE plane_bsize = get_plane_block_size(bsize, pd);
const int ref = is_inter_block(&xd->mode_info_context->mbmi);
vp9_token_state tokens[1025][2];
unsigned best_index[1025][2];
const int16_t *coeff_ptr = BLOCK_OFFSET(mb->plane[plane].coeff, block);
int16_t *qcoeff_ptr;
int16_t *dqcoeff_ptr;
- int eob = xd->plane[plane].eobs[block], final_eob, sz = 0;
+ int eob = pd->eobs[block], final_eob, sz = 0;
const int i0 = 0;
int rc, x, next, i;
int64_t rdmult, rddiv, rd_cost0, rd_cost1;
int rate0, rate1, error0, error1, t0, t1;
int best, band, pt;
- PLANE_TYPE type = xd->plane[plane].plane_type;
+ PLANE_TYPE type = pd->plane_type;
int err_mult = plane_rd_mult[type];
int default_eob;
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, tx_size);
- const int16_t *dequant_ptr = xd->plane[plane].dequant;
+ const int ib = txfrm_block_to_raster_block(plane_bsize, tx_size, block);
+ const int16_t *dequant_ptr = pd->dequant;
const uint8_t * band_translate;
assert((!type && !plane) || (type && plane));
- dqcoeff_ptr = BLOCK_OFFSET(xd->plane[plane].dqcoeff, block);
- qcoeff_ptr = BLOCK_OFFSET(xd->plane[plane].qcoeff, block);
+ dqcoeff_ptr = BLOCK_OFFSET(pd->dqcoeff, block);
+ qcoeff_ptr = BLOCK_OFFSET(pd->qcoeff, block);
switch (tx_size) {
default:
case TX_4X4:
void vp9_optimize_b(int plane, int block, BLOCK_SIZE_TYPE bsize,
TX_SIZE tx_size, MACROBLOCK *mb, struct optimize_ctx *ctx) {
MACROBLOCKD *const xd = &mb->e_mbd;
+ const BLOCK_SIZE_TYPE plane_bsize = get_plane_block_size(bsize,
+ &xd->plane[plane]);
int x, y;
// find current entropy context
- txfrm_block_to_raster_xy(xd, bsize, plane, block, tx_size, &x, &y);
+ txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &x, &y);
optimize_b(mb, plane, block, bsize, &ctx->ta[plane][x], &ctx->tl[plane][y],
tx_size);
foreach_transformed_block_uv(&x->e_mbd, bsize, optimize_block, &arg);
}
-void vp9_xform_quant(int plane, int block, BLOCK_SIZE_TYPE bsize,
+void vp9_xform_quant(int plane, int block, BLOCK_SIZE_TYPE plane_bsize,
TX_SIZE tx_size, void *arg) {
struct encode_b_args* const args = arg;
MACROBLOCK* const x = args->x;
int16_t *dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
const int16_t *scan, *iscan;
uint16_t *eob = &pd->eobs[block];
- const int bwl = b_width_log2(bsize) - pd->subsampling_x, bw = 1 << bwl;
+ const int bwl = b_width_log2(plane_bsize), bw = 1 << bwl;
const int twl = bwl - tx_size, twmask = (1 << twl) - 1;
int xoff, yoff;
int16_t *src_diff;
struct encode_b_args *const args = arg;
MACROBLOCK *const x = args->x;
MACROBLOCKD *const xd = &x->e_mbd;
- const int raster_block = txfrm_block_to_raster_block(xd, bsize, plane,
- block, tx_size);
struct macroblockd_plane *const pd = &xd->plane[plane];
+ const BLOCK_SIZE_TYPE plane_bsize = get_plane_block_size(bsize, pd);
+ const int raster_block = txfrm_block_to_raster_block(plane_bsize, tx_size,
+ block);
+
int16_t *const dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
- uint8_t *const dst = raster_block_offset_uint8(xd, bsize, plane,
- raster_block,
+ uint8_t *const dst = raster_block_offset_uint8(plane_bsize, raster_block,
pd->dst.buf, pd->dst.stride);
- vp9_xform_quant(plane, block, bsize, tx_size, arg);
+ vp9_xform_quant(plane, block, plane_bsize, tx_size, arg);
if (x->optimize)
vp9_optimize_b(plane, block, bsize, tx_size, x, args->ctx);
MB_MODE_INFO *mbmi = &xd->mode_info_context->mbmi;
struct macroblock_plane *const p = &x->plane[plane];
struct macroblockd_plane *const pd = &xd->plane[plane];
+ const BLOCK_SIZE_TYPE plane_bsize = get_plane_block_size(bsize, pd);
int16_t *coeff = BLOCK_OFFSET(p->coeff, block);
int16_t *qcoeff = BLOCK_OFFSET(pd->qcoeff, block);
int16_t *dqcoeff = BLOCK_OFFSET(pd->dqcoeff, block);
const int16_t *scan, *iscan;
TX_TYPE tx_type;
MB_PREDICTION_MODE mode;
- const int bwl = b_width_log2(bsize) - pd->subsampling_x, bw = 1 << bwl;
+ const int bwl = b_width_log2(plane_bsize), bw = 1 << bwl;
const int twl = bwl - tx_size, twmask = (1 << twl) - 1;
int xoff, yoff;
uint8_t *src, *dst;
uint16_t *eob = &pd->eobs[block];
if (xd->mb_to_right_edge < 0 || xd->mb_to_bottom_edge < 0) {
- extend_for_intra(xd, bsize, plane, block, tx_size);
+ extend_for_intra(xd, plane_bsize, plane, block, tx_size);
}
// if (x->optimize)
void vp9_encode_sby(MACROBLOCK *x, BLOCK_SIZE_TYPE bsize);
void vp9_encode_sbuv(MACROBLOCK *x, BLOCK_SIZE_TYPE bsize);
-void vp9_xform_quant(int plane, int block, BLOCK_SIZE_TYPE bsize,
+void vp9_xform_quant(int plane, int block, BLOCK_SIZE_TYPE plane_bsize,
TX_SIZE tx_size, void *arg);
void vp9_xform_quant_sby(MACROBLOCK *x, BLOCK_SIZE_TYPE bsize);
void vp9_xform_quant_sbuv(MACROBLOCK *x, BLOCK_SIZE_TYPE bsize);
const int16_t *scan, *nb;
};
-static void dist_block(int plane, int block, BLOCK_SIZE_TYPE bsize,
- TX_SIZE tx_size, void *arg) {
+static void dist_block(int plane, int block, TX_SIZE tx_size, void *arg) {
const int ss_txfrm_size = tx_size << 1;
struct rdcost_block_args* args = arg;
MACROBLOCK* const x = args->x;
}
}
-static void rate_block(int plane, int block, BLOCK_SIZE_TYPE bsize,
+static void rate_block(int plane, int block, BLOCK_SIZE_TYPE plane_bsize,
TX_SIZE tx_size, void *arg) {
struct rdcost_block_args* args = arg;
MACROBLOCKD *const xd = &args->x->e_mbd;
+ struct macroblockd_plane *const pd = &xd->plane[plane];
+
int x_idx, y_idx;
- txfrm_block_to_raster_xy(xd, bsize, plane, block, args->tx_size,
- &x_idx, &y_idx);
+ txfrm_block_to_raster_xy(plane_bsize, args->tx_size, block, &x_idx, &y_idx);
args->rate += cost_coeffs(args->x, plane, block,
- xd->plane[plane].plane_type, args->t_above + x_idx,
+ pd->plane_type, args->t_above + x_idx,
args->t_left + y_idx, args->tx_size,
args->scan, args->nb);
}
MACROBLOCK *const x = args->x;
MACROBLOCKD *const xd = &x->e_mbd;
struct encode_b_args encode_args = {x, NULL};
+ const BLOCK_SIZE_TYPE plane_bsize = get_plane_block_size(bsize,
+ &xd->plane[plane]);
int64_t rd1, rd2, rd;
if (args->skip)
if (!is_inter_block(&xd->mode_info_context->mbmi))
vp9_encode_block_intra(plane, block, bsize, tx_size, &encode_args);
else
- vp9_xform_quant(plane, block, bsize, tx_size, &encode_args);
+ vp9_xform_quant(plane, block, plane_bsize, tx_size, &encode_args);
- dist_block(plane, block, bsize, tx_size, args);
- rate_block(plane, block, bsize, tx_size, args);
+ dist_block(plane, block, tx_size, args);
+ rate_block(plane, block, plane_bsize, tx_size, args);
}
static void txfm_rd_in_plane(MACROBLOCK *x,
struct macroblockd_plane *pd = &xd->plane[0];
const int src_stride = p->src.stride;
const int dst_stride = pd->dst.stride;
- uint8_t *src_init = raster_block_offset_uint8(xd, BLOCK_8X8, 0, ib,
+ uint8_t *src_init = raster_block_offset_uint8(BLOCK_8X8, ib,
p->src.buf, src_stride);
- uint8_t *dst_init = raster_block_offset_uint8(xd, BLOCK_8X8, 0, ib,
+ uint8_t *dst_init = raster_block_offset_uint8(BLOCK_8X8, ib,
pd->dst.buf, dst_stride);
int16_t *src_diff, *coeff;
block = ib + idy * 2 + idx;
xd->mode_info_context->bmi[block].as_mode = mode;
- src_diff = raster_block_offset_int16(xd, BLOCK_8X8, 0, block,
- p->src_diff);
+ src_diff = raster_block_offset_int16(BLOCK_8X8, block, p->src_diff);
coeff = BLOCK_OFFSET(x->plane[0].coeff, block);
vp9_predict_intra_block(xd, block, 1,
TX_4X4, mode,
const int height = plane_block_height(bsize, pd);
int idx, idy;
const int src_stride = x->plane[0].src.stride;
- uint8_t* const src = raster_block_offset_uint8(xd, BLOCK_8X8, 0, i,
+ uint8_t* const src = raster_block_offset_uint8(BLOCK_8X8, i,
x->plane[0].src.buf,
src_stride);
- int16_t* src_diff = raster_block_offset_int16(xd, BLOCK_8X8, 0, i,
+ int16_t* src_diff = raster_block_offset_int16(BLOCK_8X8, i,
x->plane[0].src_diff);
int16_t* coeff = BLOCK_OFFSET(x->plane[0].coeff, i);
- uint8_t* const pre = raster_block_offset_uint8(xd, BLOCK_8X8, 0, i,
+ uint8_t* const pre = raster_block_offset_uint8(BLOCK_8X8, i,
pd->pre[0].buf,
pd->pre[0].stride);
- uint8_t* const dst = raster_block_offset_uint8(xd, BLOCK_8X8, 0, i,
- pd->dst.buf,
- pd->dst.stride);
+ uint8_t* const dst = raster_block_offset_uint8(BLOCK_8X8, i,
+ pd->dst.buf, pd->dst.stride);
int64_t thisdistortion = 0, thissse = 0;
int thisrate = 0;
if (mi->mbmi.ref_frame[1] > 0) {
uint8_t* const second_pre =
- raster_block_offset_uint8(xd, BLOCK_8X8, 0, i,
- pd->pre[1].buf, pd->pre[1].stride);
+ raster_block_offset_uint8(BLOCK_8X8, 0, pd->pre[1].buf, pd->pre[1].stride);
vp9_build_inter_predictor(second_pre, pd->pre[1].stride,
dst, pd->dst.stride,
&mi->bmi[i].as_mv[1].as_mv,
int64_t ssz, rd, rd1, rd2;
k += (idy * 2 + idx);
- src_diff = raster_block_offset_int16(xd, BLOCK_8X8, 0, k,
+ src_diff = raster_block_offset_int16(BLOCK_8X8, k,
x->plane[0].src_diff);
coeff = BLOCK_OFFSET(x->plane[0].coeff, k);
x->fwd_txm4x4(src_diff, coeff, 16);
}
static INLINE void mi_buf_shift(MACROBLOCK *x, int i) {
- MB_MODE_INFO *mbmi = &x->e_mbd.mode_info_context->mbmi;
- x->plane[0].src.buf =
- raster_block_offset_uint8(&x->e_mbd, BLOCK_8X8, 0, i,
- x->plane[0].src.buf,
- x->plane[0].src.stride);
- assert(((intptr_t)x->e_mbd.plane[0].pre[0].buf & 0x7) == 0);
- x->e_mbd.plane[0].pre[0].buf =
- raster_block_offset_uint8(&x->e_mbd, BLOCK_8X8, 0, i,
- x->e_mbd.plane[0].pre[0].buf,
- x->e_mbd.plane[0].pre[0].stride);
+ MB_MODE_INFO *const mbmi = &x->e_mbd.mode_info_context->mbmi;
+ struct macroblock_plane *const p = &x->plane[0];
+ struct macroblockd_plane *const pd = &x->e_mbd.plane[0];
+
+ p->src.buf = raster_block_offset_uint8(BLOCK_8X8, i, p->src.buf,
+ p->src.stride);
+ assert(((intptr_t)pd->pre[0].buf & 0x7) == 0);
+ pd->pre[0].buf = raster_block_offset_uint8(BLOCK_8X8, i, pd->pre[0].buf,
+ pd->pre[0].stride);
if (mbmi->ref_frame[1])
- x->e_mbd.plane[0].pre[1].buf =
- raster_block_offset_uint8(&x->e_mbd, BLOCK_8X8, 0, i,
- x->e_mbd.plane[0].pre[1].buf,
- x->e_mbd.plane[0].pre[1].stride);
+ pd->pre[1].buf = raster_block_offset_uint8(BLOCK_8X8, i, pd->pre[1].buf,
+ pd->pre[1].stride);
}
static INLINE void mi_buf_restore(MACROBLOCK *x, struct buf_2d orig_src,