Remove predictor pointers from BLOCKD

Access these members from MACROBLOCKD instead.

Change-Id: I2574622e577bb9feede47f6b7ccbb11f3e928ca8
This commit is contained in:
John Koleszar 2013-04-25 11:15:38 -07:00
parent 6c0c6b86c1
commit a99e1aa8ca
7 changed files with 82 additions and 101 deletions

View File

@ -279,12 +279,6 @@ typedef struct {
} MODE_INFO;
typedef struct blockd {
/* 16 Y blocks, 4 U blocks, 4 V blocks each with 16 entries */
uint8_t **base_pre;
uint8_t **base_second_pre;
int pre;
int pre_stride;
uint8_t **base_dst;
int dst;
int dst_stride;

View File

@ -22,11 +22,6 @@ static void setup_block(BLOCKD *b, uint8_t **base, uint8_t **base2,
b->dst_stride = stride;
b->dst = offset;
b->base_dst = base;
} else {
b->pre_stride = stride;
b->pre = offset;
b->base_pre = base;
b->base_second_pre = base2;
}
}
@ -43,14 +38,6 @@ static void setup_macroblock(MACROBLOCKD *mb, BLOCKSET bs) {
y2 = NULL;
u2 = NULL;
v2 = NULL;
} else {
y = &mb->plane[0].pre[0].buf;
u = &mb->plane[1].pre[0].buf;
v = &mb->plane[2].pre[0].buf;
y2 = &mb->plane[0].pre[1].buf;
u2 = &mb->plane[1].pre[1].buf;
v2 = &mb->plane[2].pre[1].buf;
}
// luma
@ -82,5 +69,4 @@ void vp9_setup_block_dptrs(MACROBLOCKD *mb) {
void vp9_build_block_doffsets(MACROBLOCKD *mb) {
// handle the destination pitch features
setup_macroblock(mb, DEST);
setup_macroblock(mb, PRED);
}

View File

@ -130,7 +130,7 @@ static void output_stats(const VP9_COMP *cpi,
FILE *fpfile;
fpfile = fopen("firstpass.stt", "a");
fprintf(fpfile, "%12.0f %12.0f %12.0f %12.0f %12.0f %12.4f %12.4f"
fprintf(stdout, "%12.0f %12.0f %12.0f %12.0f %12.0f %12.4f %12.4f"
"%12.4f %12.4f %12.4f %12.4f %12.4f %12.4f %12.4f"
"%12.0f %12.0f %12.4f %12.0f %12.0f %12.4f\n",
stats->frame,
@ -349,19 +349,12 @@ void vp9_end_first_pass(VP9_COMP *cpi) {
static void zz_motion_search(VP9_COMP *cpi, MACROBLOCK *x, YV12_BUFFER_CONFIG *recon_buffer, int *best_motion_err, int recon_yoffset) {
MACROBLOCKD *const xd = &x->e_mbd;
BLOCKD *d = &x->e_mbd.block[0];
uint8_t *src_ptr = x->plane[0].src.buf;
int src_stride = x->plane[0].src.stride;
uint8_t *ref_ptr;
int ref_stride = d->pre_stride;
// Set up pointers for this macro block recon buffer
xd->plane[0].pre[0].buf = recon_buffer->y_buffer + recon_yoffset;
ref_ptr = (uint8_t *)(*(d->base_pre) + d->pre);
vp9_mse16x16(src_ptr, src_stride, ref_ptr, ref_stride,
vp9_mse16x16(x->plane[0].src.buf, x->plane[0].src.stride,
xd->plane[0].pre[0].buf, xd->plane[0].pre[0].stride,
(unsigned int *)(best_motion_err));
}

View File

@ -99,15 +99,6 @@ static int do_16x16_motion_search
MACROBLOCKD *const xd = &x->e_mbd;
unsigned int err, tmp_err;
int_mv tmp_mv;
int n;
for (n = 0; n < 16; n++) {
BLOCKD *d = &xd->block[n];
d->base_pre = &xd->plane[0].pre[0].buf;
d->pre_stride = xd->plane[0].pre[0].stride;
d->pre = xd->plane[0].pre[0].stride * (n & 12) + (n & 3) * 4;
}
// Try zero MV first
// FIXME should really use something like near/nearest MV and/or MV prediction

View File

@ -265,9 +265,11 @@ int vp9_find_best_sub_pixel_step_iteratively(MACROBLOCK *x, BLOCKD *d,
int offset;
int usehp = xd->allow_high_precision_mv;
uint8_t *y = *(d->base_pre) + d->pre +
(bestmv->as_mv.row) * d->pre_stride + bestmv->as_mv.col;
y_stride = d->pre_stride;
uint8_t *y = xd->plane[0].pre[0].buf +
(bestmv->as_mv.row) * xd->plane[0].pre[0].stride +
bestmv->as_mv.col;
y_stride = xd->plane[0].pre[0].stride;
rr = ref_mv->as_mv.row;
rc = ref_mv->as_mv.col;
@ -440,9 +442,10 @@ int vp9_find_best_sub_pixel_step(MACROBLOCK *x, BLOCKD *d,
MACROBLOCKD *xd = &x->e_mbd;
int usehp = xd->allow_high_precision_mv;
uint8_t *y = *(d->base_pre) + d->pre +
(bestmv->as_mv.row) * d->pre_stride + bestmv->as_mv.col;
y_stride = d->pre_stride;
uint8_t *y = xd->plane[0].pre[0].buf +
(bestmv->as_mv.row) * xd->plane[0].pre[0].stride +
bestmv->as_mv.col;
y_stride = xd->plane[0].pre[0].stride;
// central mv
bestmv->as_mv.row <<= 3;
@ -940,9 +943,9 @@ int vp9_find_best_half_pixel_step(MACROBLOCK *x, BLOCKD *d,
int y_stride;
MACROBLOCKD *xd = &x->e_mbd;
uint8_t *y = *(d->base_pre) + d->pre +
(bestmv->as_mv.row) * d->pre_stride + bestmv->as_mv.col;
y_stride = d->pre_stride;
uint8_t *y = xd->plane[0].pre[0].buf +
(bestmv->as_mv.row) * xd->plane[0].pre[0].stride + bestmv->as_mv.col;
y_stride = xd->plane[0].pre[0].stride;
// central mv
bestmv->as_mv.row <<= 3;
@ -1103,13 +1106,14 @@ int vp9_hex_search
int *mvjcost, int *mvcost[2],
int_mv *center_mv
) {
const MACROBLOCKD* const xd = &x->e_mbd;
MV hex[6] = { { -1, -2}, {1, -2}, {2, 0}, {1, 2}, { -1, 2}, { -2, 0} };
MV neighbors[4] = {{0, -1}, { -1, 0}, {1, 0}, {0, 1}};
int i, j;
uint8_t *what = x->plane[0].src.buf;
int what_stride = x->plane[0].src.stride;
int in_what_stride = d->pre_stride;
int in_what_stride = xd->plane[0].pre[0].stride;
int br, bc;
int_mv this_mv;
unsigned int bestsad = 0x7fffffff;
@ -1130,8 +1134,8 @@ int vp9_hex_search
bc = ref_mv->as_mv.col;
// Work out the start point for the search
base_offset = (uint8_t *)(*(d->base_pre) + d->pre);
this_offset = base_offset + (br * (d->pre_stride)) + bc;
base_offset = (uint8_t *)(xd->plane[0].pre[0].buf);
this_offset = base_offset + (br * (xd->plane[0].pre[0].stride)) + bc;
this_mv.as_mv.row = br;
this_mv.as_mv.col = bc;
bestsad = vfp->sdf(what, what_stride, this_offset,
@ -1253,10 +1257,11 @@ int vp9_diamond_search_sad_c(MACROBLOCK *x, BLOCKD *d,
int *mvcost[2], int_mv *center_mv) {
int i, j, step;
const MACROBLOCKD* const xd = &x->e_mbd;
uint8_t *what = x->plane[0].src.buf;
int what_stride = x->plane[0].src.stride;
uint8_t *in_what;
int in_what_stride = d->pre_stride;
int in_what_stride = xd->plane[0].pre[0].stride;
uint8_t *best_address;
int tot_steps;
@ -1272,7 +1277,6 @@ int vp9_diamond_search_sad_c(MACROBLOCK *x, BLOCKD *d,
uint8_t *check_here;
int thissad;
MACROBLOCKD *xd = &x->e_mbd;
int_mv fcenter_mv;
int *mvjsadcost = x->nmvjointsadcost;
@ -1289,8 +1293,8 @@ int vp9_diamond_search_sad_c(MACROBLOCK *x, BLOCKD *d,
best_mv->as_mv.col = ref_col;
// Work out the start point for the search
in_what = (uint8_t *)(*(d->base_pre) + d->pre +
(ref_row * (d->pre_stride)) + ref_col);
in_what = (uint8_t *)(xd->plane[0].pre[0].buf +
(ref_row * (xd->plane[0].pre[0].stride)) + ref_col);
best_address = in_what;
// Check the starting position
@ -1364,10 +1368,11 @@ int vp9_diamond_search_sadx4(MACROBLOCK *x, BLOCKD *d,
int *mvjcost, int *mvcost[2], int_mv *center_mv) {
int i, j, step;
const MACROBLOCKD* const xd = &x->e_mbd;
uint8_t *what = x->plane[0].src.buf;
int what_stride = x->plane[0].src.stride;
uint8_t *in_what;
int in_what_stride = d->pre_stride;
int in_what_stride = xd->plane[0].pre[0].stride;
uint8_t *best_address;
int tot_steps;
@ -1385,7 +1390,6 @@ int vp9_diamond_search_sadx4(MACROBLOCK *x, BLOCKD *d,
uint8_t *check_here;
unsigned int thissad;
MACROBLOCKD *xd = &x->e_mbd;
int_mv fcenter_mv;
int *mvjsadcost = x->nmvjointsadcost;
@ -1402,8 +1406,8 @@ int vp9_diamond_search_sadx4(MACROBLOCK *x, BLOCKD *d,
best_mv->as_mv.col = ref_col;
// Work out the start point for the search
in_what = (uint8_t *)(*(d->base_pre) + d->pre +
(ref_row * (d->pre_stride)) + ref_col);
in_what = (uint8_t *)(xd->plane[0].pre[0].buf +
(ref_row * (xd->plane[0].pre[0].stride)) + ref_col);
best_address = in_what;
// Check the starting position
@ -1571,11 +1575,12 @@ int vp9_full_search_sad_c(MACROBLOCK *x, BLOCKD *d, int_mv *ref_mv,
vp9_variance_fn_ptr_t *fn_ptr, int *mvjcost,
int *mvcost[2],
int_mv *center_mv) {
const MACROBLOCKD* const xd = &x->e_mbd;
uint8_t *what = x->plane[0].src.buf;
int what_stride = x->plane[0].src.stride;
uint8_t *in_what;
int in_what_stride = d->pre_stride;
int mv_stride = d->pre_stride;
int in_what_stride = xd->plane[0].pre[0].stride;
int mv_stride = xd->plane[0].pre[0].stride;
uint8_t *bestaddress;
int_mv *best_mv = &d->bmi.as_mv[0];
int_mv this_mv;
@ -1584,7 +1589,6 @@ int vp9_full_search_sad_c(MACROBLOCK *x, BLOCKD *d, int_mv *ref_mv,
uint8_t *check_here;
int thissad;
MACROBLOCKD *xd = &x->e_mbd;
int ref_row = ref_mv->as_mv.row;
int ref_col = ref_mv->as_mv.col;
@ -1602,8 +1606,8 @@ int vp9_full_search_sad_c(MACROBLOCK *x, BLOCKD *d, int_mv *ref_mv,
fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3;
// Work out the mid point for the search
in_what = *(d->base_pre) + d->pre;
bestaddress = in_what + (ref_row * d->pre_stride) + ref_col;
in_what = xd->plane[0].pre[0].buf;
bestaddress = in_what + (ref_row * xd->plane[0].pre[0].stride) + ref_col;
best_mv->as_mv.row = ref_row;
best_mv->as_mv.col = ref_col;
@ -1666,11 +1670,12 @@ int vp9_full_search_sadx3(MACROBLOCK *x, BLOCKD *d, int_mv *ref_mv,
int sad_per_bit, int distance,
vp9_variance_fn_ptr_t *fn_ptr, int *mvjcost,
int *mvcost[2], int_mv *center_mv) {
const MACROBLOCKD* const xd = &x->e_mbd;
uint8_t *what = x->plane[0].src.buf;
int what_stride = x->plane[0].src.stride;
uint8_t *in_what;
int in_what_stride = d->pre_stride;
int mv_stride = d->pre_stride;
int in_what_stride = xd->plane[0].pre[0].stride;
int mv_stride = xd->plane[0].pre[0].stride;
uint8_t *bestaddress;
int_mv *best_mv = &d->bmi.as_mv[0];
int_mv this_mv;
@ -1679,7 +1684,6 @@ int vp9_full_search_sadx3(MACROBLOCK *x, BLOCKD *d, int_mv *ref_mv,
uint8_t *check_here;
unsigned int thissad;
MACROBLOCKD *xd = &x->e_mbd;
int ref_row = ref_mv->as_mv.row;
int ref_col = ref_mv->as_mv.col;
@ -1699,8 +1703,8 @@ int vp9_full_search_sadx3(MACROBLOCK *x, BLOCKD *d, int_mv *ref_mv,
fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3;
// Work out the mid point for the search
in_what = *(d->base_pre) + d->pre;
bestaddress = in_what + (ref_row * d->pre_stride) + ref_col;
in_what = xd->plane[0].pre[0].buf;
bestaddress = in_what + (ref_row * xd->plane[0].pre[0].stride) + ref_col;
best_mv->as_mv.row = ref_row;
best_mv->as_mv.col = ref_col;
@ -1795,11 +1799,12 @@ int vp9_full_search_sadx8(MACROBLOCK *x, BLOCKD *d, int_mv *ref_mv,
vp9_variance_fn_ptr_t *fn_ptr,
int *mvjcost, int *mvcost[2],
int_mv *center_mv) {
const MACROBLOCKD* const xd = &x->e_mbd;
uint8_t *what = x->plane[0].src.buf;
int what_stride = x->plane[0].src.stride;
uint8_t *in_what;
int in_what_stride = d->pre_stride;
int mv_stride = d->pre_stride;
int in_what_stride = xd->plane[0].pre[0].stride;
int mv_stride = xd->plane[0].pre[0].stride;
uint8_t *bestaddress;
int_mv *best_mv = &d->bmi.as_mv[0];
int_mv this_mv;
@ -1808,7 +1813,6 @@ int vp9_full_search_sadx8(MACROBLOCK *x, BLOCKD *d, int_mv *ref_mv,
uint8_t *check_here;
unsigned int thissad;
MACROBLOCKD *xd = &x->e_mbd;
int ref_row = ref_mv->as_mv.row;
int ref_col = ref_mv->as_mv.col;
@ -1829,8 +1833,8 @@ int vp9_full_search_sadx8(MACROBLOCK *x, BLOCKD *d, int_mv *ref_mv,
fcenter_mv.as_mv.col = center_mv->as_mv.col >> 3;
// Work out the mid point for the search
in_what = *(d->base_pre) + d->pre;
bestaddress = in_what + (ref_row * d->pre_stride) + ref_col;
in_what = xd->plane[0].pre[0].buf;
bestaddress = in_what + (ref_row * xd->plane[0].pre[0].stride) + ref_col;
best_mv->as_mv.row = ref_row;
best_mv->as_mv.col = ref_col;
@ -1948,21 +1952,21 @@ int vp9_refining_search_sad_c(MACROBLOCK *x, BLOCKD *d,
int_mv *ref_mv, int error_per_bit,
int search_range, vp9_variance_fn_ptr_t *fn_ptr,
int *mvjcost, int *mvcost[2], int_mv *center_mv) {
const MACROBLOCKD* const xd = &x->e_mbd;
MV neighbors[4] = {{ -1, 0}, {0, -1}, {0, 1}, {1, 0}};
int i, j;
int this_row_offset, this_col_offset;
int what_stride = x->plane[0].src.stride;
int in_what_stride = d->pre_stride;
int in_what_stride = xd->plane[0].pre[0].stride;
uint8_t *what = x->plane[0].src.buf;
uint8_t *best_address = (uint8_t *)(*(d->base_pre) + d->pre +
(ref_mv->as_mv.row * (d->pre_stride)) +
ref_mv->as_mv.col);
uint8_t *best_address = xd->plane[0].pre[0].buf +
(ref_mv->as_mv.row * xd->plane[0].pre[0].stride) +
ref_mv->as_mv.col;
uint8_t *check_here;
unsigned int thissad;
int_mv this_mv;
unsigned int bestsad = INT_MAX;
MACROBLOCKD *xd = &x->e_mbd;
int_mv fcenter_mv;
int *mvjsadcost = x->nmvjointsadcost;
@ -2026,21 +2030,21 @@ int vp9_refining_search_sadx4(MACROBLOCK *x, BLOCKD *d,
int_mv *ref_mv, int error_per_bit,
int search_range, vp9_variance_fn_ptr_t *fn_ptr,
int *mvjcost, int *mvcost[2], int_mv *center_mv) {
const MACROBLOCKD* const xd = &x->e_mbd;
MV neighbors[4] = {{ -1, 0}, {0, -1}, {0, 1}, {1, 0}};
int i, j;
int this_row_offset, this_col_offset;
int what_stride = x->plane[0].src.stride;
int in_what_stride = d->pre_stride;
int in_what_stride = xd->plane[0].pre[0].stride;
uint8_t *what = x->plane[0].src.buf;
uint8_t *best_address = (uint8_t *)(*(d->base_pre) + d->pre +
(ref_mv->as_mv.row * (d->pre_stride)) +
ref_mv->as_mv.col);
uint8_t *best_address = xd->plane[0].pre[0].buf +
(ref_mv->as_mv.row * xd->plane[0].pre[0].stride) +
ref_mv->as_mv.col;
uint8_t *check_here;
unsigned int thissad;
int_mv this_mv;
unsigned int bestsad = INT_MAX;
MACROBLOCKD *xd = &x->e_mbd;
int_mv fcenter_mv;
int *mvjsadcost = x->nmvjointsadcost;

View File

@ -1723,10 +1723,14 @@ static int64_t encode_inter_mb_segment(VP9_COMMON *const cm,
raster_block_offset_int16(xd, BLOCK_SIZE_MB16X16, 0, i,
x->plane[0].src_diff);
int16_t* const coeff = BLOCK_OFFSET(x->plane[0].coeff, 16, i);
uint8_t* const pre =
raster_block_offset_uint8(xd, BLOCK_SIZE_MB16X16, 0, i,
xd->plane[0].pre[0].buf,
xd->plane[0].pre[0].stride);
int thisdistortion;
vp9_build_inter_predictor(*(bd->base_pre) + bd->pre,
bd->pre_stride,
vp9_build_inter_predictor(pre,
xd->plane[0].pre[0].stride,
*(bd->base_dst) + bd->dst,
bd->dst_stride,
&bd->bmi.as_mv[0],
@ -1737,8 +1741,12 @@ static int64_t encode_inter_mb_segment(VP9_COMMON *const cm,
// implicit-compoundinter-weight experiment when implicit
// weighting for splitmv modes is turned on.
if (xd->mode_info_context->mbmi.second_ref_frame > 0) {
uint8_t* const second_pre =
raster_block_offset_uint8(xd, BLOCK_SIZE_MB16X16, 0, i,
xd->plane[0].pre[1].buf,
xd->plane[0].pre[1].stride);
vp9_build_inter_predictor(
*(bd->base_second_pre) + bd->pre, bd->pre_stride,
second_pre, xd->plane[0].pre[1].stride,
*(bd->base_dst) + bd->dst, bd->dst_stride,
&bd->bmi.as_mv[1], &xd->scale_factor[1], 4, 4, 1,
&xd->subpix);
@ -1806,13 +1814,16 @@ static int64_t encode_inter_mb_segment_8x8(VP9_COMMON *const cm,
assert(idx < 16);
for (which_mv = 0; which_mv < 1 + use_second_ref; ++which_mv) {
uint8_t **base_pre = which_mv ? bd->base_second_pre : bd->base_pre;
uint8_t* const pre =
raster_block_offset_uint8(xd, BLOCK_SIZE_MB16X16, 0, ib,
xd->plane[0].pre[which_mv].buf,
xd->plane[0].pre[which_mv].stride);
// TODO(debargha): Make this work properly with the
// implicit-compoundinter-weight experiment when implicit
// weighting for splitmv modes is turned on.
vp9_build_inter_predictor(
*base_pre + bd->pre, bd->pre_stride,
pre, xd->plane[0].pre[which_mv].stride,
*(bd->base_dst) + bd->dst, bd->dst_stride,
&bd->bmi.as_mv[which_mv], &xd->scale_factor[which_mv], 8, 8,
which_mv, &xd->subpix);
@ -2030,6 +2041,7 @@ static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x,
int thissme, bestsme = INT_MAX;
BLOCKD *e;
const struct buf_2d orig_src = x->plane[0].src;
const struct buf_2d orig_pre = x->e_mbd.plane[0].pre[0];
/* Is the best so far sufficiently good that we cant justify doing
* and new motion search. */
@ -2072,6 +2084,11 @@ static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x,
raster_block_offset_uint8(&x->e_mbd, BLOCK_SIZE_MB16X16, 0, n,
x->plane[0].src.buf,
x->plane[0].src.stride);
assert(((intptr_t)x->e_mbd.plane[0].pre[0].buf & 0xf) == 0);
x->e_mbd.plane[0].pre[0].buf =
raster_block_offset_uint8(&x->e_mbd, BLOCK_SIZE_MB16X16, 0, n,
x->e_mbd.plane[0].pre[0].buf,
x->e_mbd.plane[0].pre[0].stride);
e = &x->e_mbd.block[n];
bestsme = vp9_full_pixel_diamond(cpi, x, e, &mvp_full, step_param,
@ -2114,8 +2131,9 @@ static void rd_check_segment_txsize(VP9_COMP *cpi, MACROBLOCK *x,
seg_mvs[i][mbmi->ref_frame - 1].as_int = mode_mv[NEW4X4].as_int;
}
// restore src pointer
// restore src pointers
x->plane[0].src = orig_src;
x->e_mbd.plane[0].pre[0] = orig_pre;
} else if (mbmi->second_ref_frame > 0 && this_mode == NEW4X4) {
/* NEW4X4 */
/* motion search not completed? Then skip newmv for this block with

View File

@ -124,6 +124,7 @@ static int temporal_filter_find_matching_mb_c(VP9_COMP *cpi,
int mb_offset,
int error_thresh) {
MACROBLOCK *x = &cpi->mb;
MACROBLOCKD* const xd = &x->e_mbd;
int step_param;
int sadpb = x->sadperbit16;
int bestsme = INT_MAX;
@ -134,9 +135,7 @@ static int temporal_filter_find_matching_mb_c(VP9_COMP *cpi,
// Save input state
struct buf_2d src = x->plane[0].src;
uint8_t **base_pre = d->base_pre;
int pre = d->pre;
int pre_stride = d->pre_stride;
struct buf_2d pre = xd->plane[0].pre[0];
best_ref_mv1.as_int = 0;
best_ref_mv1_full.as_mv.col = best_ref_mv1.as_mv.col >> 3;
@ -145,10 +144,8 @@ static int temporal_filter_find_matching_mb_c(VP9_COMP *cpi,
// Setup frame pointers
x->plane[0].src.buf = arf_frame->y_buffer + mb_offset;
x->plane[0].src.stride = arf_frame->y_stride;
d->base_pre = &frame_ptr->y_buffer;
d->pre_stride = frame_ptr->y_stride;
d->pre = mb_offset;
xd->plane[0].pre[0].buf = frame_ptr->y_buffer + mb_offset;
xd->plane[0].pre[0].stride = arf_frame->y_stride;
// Further step/diamond searches as necessary
if (cpi->Speed < 8) {
@ -182,11 +179,9 @@ static int temporal_filter_find_matching_mb_c(VP9_COMP *cpi,
}
#endif
// Save input state
// Restore input state
x->plane[0].src = src;
d->base_pre = base_pre;
d->pre = pre;
d->pre_stride = pre_stride;
xd->plane[0].pre[0] = pre;
return bestsme;
}