Commit 749bc986 authored by Scott LaVarnway's avatar Scott LaVarnway

BLOCKD structure cleanup

Removed redundancies.  All of the information can be
found in the MACROBLOCKD structure.

Change-Id: I7556392c6f67b43bef2a5e9932180a737466ef93
parent 57d459ba
......@@ -185,15 +185,7 @@ typedef struct blockd
unsigned char *predictor;
short *dequant;
/* 16 Y blocks, 4 U blocks, 4 V blocks each with 16 entries */
unsigned char **base_pre;
int pre;
int pre_stride;
unsigned char **base_dst;
int dst;
int dst_stride;
int offset;
char *eob;
union b_mode_info bmi;
......
......@@ -17,33 +17,6 @@ typedef enum
DEST = 1
} BLOCKSET;
static void setup_block
(
BLOCKD *b,
int mv_stride,
unsigned char **base,
int Stride,
int offset,
BLOCKSET bs
)
{
if (bs == DEST)
{
b->dst_stride = Stride;
b->dst = offset;
b->base_dst = base;
}
else
{
b->pre_stride = Stride;
b->pre = offset;
b->base_pre = base;
}
}
static void setup_macroblock(MACROBLOCKD *x, BLOCKSET bs)
{
int block;
......@@ -65,17 +38,15 @@ static void setup_macroblock(MACROBLOCKD *x, BLOCKSET bs)
for (block = 0; block < 16; block++) /* y blocks */
{
setup_block(&x->block[block], x->dst.y_stride, y, x->dst.y_stride,
(block >> 2) * 4 * x->dst.y_stride + (block & 3) * 4, bs);
x->block[block].offset =
(block >> 2) * 4 * x->dst.y_stride + (block & 3) * 4;
}
for (block = 16; block < 20; block++) /* U and V blocks */
{
setup_block(&x->block[block], x->dst.uv_stride, u, x->dst.uv_stride,
((block - 16) >> 1) * 4 * x->dst.uv_stride + (block & 1) * 4, bs);
setup_block(&x->block[block+4], x->dst.uv_stride, v, x->dst.uv_stride,
((block - 16) >> 1) * 4 * x->dst.uv_stride + (block & 1) * 4, bs);
x->block[block+4].offset =
x->block[block].offset =
((block - 16) >> 1) * 4 * x->dst.uv_stride + (block & 1) * 4;
}
}
......
This diff is collapsed.
......@@ -25,6 +25,8 @@ extern void vp8_build_inter16x16_predictors_mby(MACROBLOCKD *x,
unsigned char *dst_y,
int dst_ystride);
extern void vp8_build_inter_predictors_b(BLOCKD *d, int pitch,
unsigned char *base_pre,
int pre_stride,
vp8_subpix_fn_t sppf);
extern void vp8_build_inter16x16_predictors_mbuv(MACROBLOCKD *x);
......
......@@ -304,12 +304,13 @@ void vp8_intra4x4_predict_c(unsigned char *src, int src_stride,
*/
void vp8_intra_prediction_down_copy(MACROBLOCKD *x)
{
unsigned char *above_right = *(x->block[0].base_dst) + x->block[0].dst - x->block[0].dst_stride + 16;
int dst_stride = x->dst.y_stride;
unsigned char *above_right = x->dst.y_buffer - dst_stride + 16;
unsigned int *src_ptr = (unsigned int *)above_right;
unsigned int *dst_ptr0 = (unsigned int *)(above_right + 4 * x->block[0].dst_stride);
unsigned int *dst_ptr1 = (unsigned int *)(above_right + 8 * x->block[0].dst_stride);
unsigned int *dst_ptr2 = (unsigned int *)(above_right + 12 * x->block[0].dst_stride);
unsigned int *dst_ptr0 = (unsigned int *)(above_right + 4 * dst_stride);
unsigned int *dst_ptr1 = (unsigned int *)(above_right + 8 * dst_stride);
unsigned int *dst_ptr2 = (unsigned int *)(above_right + 12 * dst_stride);
*dst_ptr0 = *src_ptr;
*dst_ptr1 = *src_ptr;
......
......@@ -165,6 +165,8 @@ static void decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd,
else
{
short *DQC = xd->dequant_y1;
int dst_stride = xd->dst.y_stride;
unsigned char *base_dst = xd->dst.y_buffer;
/* clear out residual eob info */
if(xd->mode_info_context->mbmi.mb_skip_coeff)
......@@ -177,9 +179,9 @@ static void decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd,
BLOCKD *b = &xd->block[i];
int b_mode = xd->mode_info_context->bmi[i].as_mode;
vp8_intra4x4_predict
( *(b->base_dst) + b->dst, b->dst_stride, b_mode,
*(b->base_dst) + b->dst, b->dst_stride );
vp8_intra4x4_predict (base_dst + b->offset, dst_stride, b_mode,
base_dst + b->offset, dst_stride );
if (xd->eobs[i])
{
......@@ -187,14 +189,14 @@ static void decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd,
{
vp8_dequant_idct_add
(b->qcoeff, DQC,
*(b->base_dst) + b->dst, b->dst_stride);
base_dst + b->offset, dst_stride);
}
else
{
vp8_dc_only_idct_add
(b->qcoeff[0] * DQC[0],
*(b->base_dst) + b->dst, b->dst_stride,
*(b->base_dst) + b->dst, b->dst_stride);
base_dst + b->offset, dst_stride,
base_dst + b->offset, dst_stride);
((int *)b->qcoeff)[0] = 0;
}
}
......
......@@ -617,12 +617,15 @@ void vp8mt_predict_intra4x4(VP8D_COMP *pbi,
unsigned char top_left; /* = Above[-1]; */
BLOCKD *x = &xd->block[num];
int dst_stride = xd->dst.y_stride;
unsigned char *base_dst = xd->dst.y_buffer;
/*Caution: For some b_mode, it needs 8 pixels (4 above + 4 above-right).*/
if (num < 4 && pbi->common.filter_level)
Above = pbi->mt_yabove_row[mb_row] + mb_col*16 + num*4 + 32;
else
Above = *(x->base_dst) + x->dst - x->dst_stride;
Above = base_dst + x->offset - dst_stride;
if (num%4==0 && pbi->common.filter_level)
{
......@@ -630,10 +633,10 @@ void vp8mt_predict_intra4x4(VP8D_COMP *pbi,
Left[i] = pbi->mt_yleft_col[mb_row][num + i];
}else
{
Left[0] = (*(x->base_dst))[x->dst - 1];
Left[1] = (*(x->base_dst))[x->dst - 1 + x->dst_stride];
Left[2] = (*(x->base_dst))[x->dst - 1 + 2 * x->dst_stride];
Left[3] = (*(x->base_dst))[x->dst - 1 + 3 * x->dst_stride];
Left[0] = (base_dst)[x->offset - 1];
Left[1] = (base_dst)[x->offset - 1 + dst_stride];
Left[2] = (base_dst)[x->offset - 1 + 2 * dst_stride];
Left[3] = (base_dst)[x->offset - 1 + 3 * dst_stride];
}
if ((num==4 || num==8 || num==12) && pbi->common.filter_level)
......@@ -918,19 +921,22 @@ void vp8mt_intra_prediction_down_copy(VP8D_COMP *pbi, MACROBLOCKD *x, int mb_row
unsigned int *dst_ptr0;
unsigned int *dst_ptr1;
unsigned int *dst_ptr2;
int dst_stride = x->dst.y_stride;
unsigned char *base_dst = x->dst.y_buffer;
if (pbi->common.filter_level)
above_right = pbi->mt_yabove_row[mb_row] + mb_col*16 + 32 +16;
else
above_right = *(x->block[0].base_dst) + x->block[0].dst - x->block[0].dst_stride + 16;
above_right = base_dst + x->block[0].offset - dst_stride + 16;
src_ptr = (unsigned int *)above_right;
/*dst_ptr0 = (unsigned int *)(above_right + 4 * x->block[0].dst_stride);
dst_ptr1 = (unsigned int *)(above_right + 8 * x->block[0].dst_stride);
dst_ptr2 = (unsigned int *)(above_right + 12 * x->block[0].dst_stride);*/
dst_ptr0 = (unsigned int *)(*(x->block[0].base_dst) + x->block[0].dst + 16 + 3 * x->block[0].dst_stride);
dst_ptr1 = (unsigned int *)(*(x->block[0].base_dst) + x->block[0].dst + 16 + 7 * x->block[0].dst_stride);
dst_ptr2 = (unsigned int *)(*(x->block[0].base_dst) + x->block[0].dst + 16 + 11 * x->block[0].dst_stride);
dst_ptr0 = (unsigned int *)(base_dst + x->block[0].offset + 16 + 3 * dst_stride);
dst_ptr1 = (unsigned int *)(base_dst + x->block[0].offset + 16 + 7 * dst_stride);
dst_ptr2 = (unsigned int *)(base_dst + x->block[0].offset + 16 + 11 * dst_stride);
*dst_ptr0 = *src_ptr;
*dst_ptr1 = *src_ptr;
*dst_ptr2 = *src_ptr;
......
......@@ -171,14 +171,16 @@ static void decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd, int mb_row, int m
if (xd->mode_info_context->mbmi.mode == B_PRED)
{
short *DQC = xd->dequant_y1;
int dst_stride = xd->dst.y_stride;
unsigned char *base_dst = xd->dst.y_buffer;
for (i = 0; i < 16; i++)
{
BLOCKD *b = &xd->block[i];
int b_mode = xd->mode_info_context->bmi[i].as_mode;
vp8mt_predict_intra4x4(pbi, xd, b_mode, *(b->base_dst) + b->dst,
b->dst_stride, mb_row, mb_col, i);
vp8mt_predict_intra4x4(pbi, xd, b_mode, base_dst + b->offset,
dst_stride, mb_row, mb_col, i);
if (xd->eobs[i] )
{
......@@ -186,14 +188,14 @@ static void decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd, int mb_row, int m
{
vp8_dequant_idct_add
(b->qcoeff, DQC,
*(b->base_dst) + b->dst, b->dst_stride);
base_dst + b->offset, dst_stride);
}
else
{
vp8_dc_only_idct_add
(b->qcoeff[0] * DQC[0],
*(b->base_dst) + b->dst, b->dst_stride,
*(b->base_dst) + b->dst, b->dst_stride);
base_dst + b->offset, dst_stride,
base_dst + b->offset, dst_stride);
((int *)b->qcoeff)[0] = 0;
}
}
......
......@@ -53,9 +53,10 @@ void vp8_encode_intra4x4block(MACROBLOCK *x, int ib)
{
BLOCKD *b = &x->e_mbd.block[ib];
BLOCK *be = &x->block[ib];
int dst_stride = x->e_mbd.dst.y_stride;
unsigned char *base_dst = x->e_mbd.dst.y_buffer;
vp8_intra4x4_predict
(*(b->base_dst) + b->dst, b->dst_stride,
vp8_intra4x4_predict(base_dst + b->offset, dst_stride,
b->bmi.as_mode, b->predictor, 16);
vp8_subtract_b(be, b, 16);
......@@ -66,14 +67,14 @@ void vp8_encode_intra4x4block(MACROBLOCK *x, int ib)
if (*b->eob > 1)
{
vp8_short_idct4x4llm(b->dqcoeff,
b->predictor, 16, *(b->base_dst) + b->dst, b->dst_stride);
vp8_short_idct4x4llm(b->dqcoeff,
b->predictor, 16, base_dst + b->offset, dst_stride);
}
else
{
vp8_dc_only_idct_add
(b->dqcoeff[0], b->predictor, 16, *(b->base_dst) + b->dst,
b->dst_stride);
vp8_dc_only_idct_add
(b->dqcoeff[0], b->predictor, 16, base_dst + b->offset,
dst_stride);
}
}
......
......@@ -396,12 +396,12 @@ static void zz_motion_search( VP8_COMP *cpi, MACROBLOCK * x, YV12_BUFFER_CONFIG
unsigned char *src_ptr = (*(b->base_src) + b->src);
int src_stride = b->src_stride;
unsigned char *ref_ptr;
int ref_stride=d->pre_stride;
int ref_stride = x->e_mbd.pre.y_stride;
// Set up pointers for this macro block recon buffer
xd->pre.y_buffer = recon_buffer->y_buffer + recon_yoffset;
ref_ptr = (unsigned char *)(*(d->base_pre) + d->pre );
ref_ptr = (unsigned char *)(xd->pre.y_buffer + d->offset );
vp8_mse16x16 ( src_ptr, src_stride, ref_ptr, ref_stride, (unsigned int *)(best_motion_err));
}
......
This diff is collapsed.
......@@ -68,12 +68,13 @@ static int get_inter_mbpred_error(MACROBLOCK *mb,
BLOCKD *d = &mb->e_mbd.block[0];
unsigned char *what = (*(b->base_src) + b->src);
int what_stride = b->src_stride;
unsigned char *in_what = *(d->base_pre) + d->pre ;
int in_what_stride = d->pre_stride;
int pre_stride = mb->e_mbd.pre.y_stride;
unsigned char *in_what = mb->e_mbd.pre.y_buffer + d->offset ;
int in_what_stride = pre_stride;
int xoffset = this_mv.as_mv.col & 7;
int yoffset = this_mv.as_mv.row & 7;
in_what += (this_mv.as_mv.row >> 3) * d->pre_stride + (this_mv.as_mv.col >> 3);
in_what += (this_mv.as_mv.row >> 3) * pre_stride + (this_mv.as_mv.col >> 3);
if (xoffset | yoffset)
{
......@@ -136,6 +137,8 @@ static int pick_intra4x4block(
BLOCKD *b = &x->e_mbd.block[ib];
BLOCK *be = &x->block[ib];
int dst_stride = x->e_mbd.dst.y_stride;
unsigned char *base_dst = x->e_mbd.dst.y_buffer;
B_PREDICTION_MODE mode;
int best_rd = INT_MAX; // 1<<30
int rate;
......@@ -147,7 +150,7 @@ static int pick_intra4x4block(
rate = mode_costs[mode];
vp8_intra4x4_predict
(*(b->base_dst) + b->dst, b->dst_stride,
(base_dst + b->offset, dst_stride,
mode, b->predictor, 16);
distortion = get_prediction_error(be, b);
this_rd = RDCOST(x->rdmult, x->rddiv, rate, distortion);
......
......@@ -457,7 +457,7 @@ int VP8_UVSSE(MACROBLOCK *x)
int mv_row = x->e_mbd.mode_info_context->mbmi.mv.as_mv.row;
int mv_col = x->e_mbd.mode_info_context->mbmi.mv.as_mv.col;
int offset;
int pre_stride = x->e_mbd.block[16].pre_stride;
int pre_stride = x->e_mbd.pre.uv_stride;
if (mv_row < 0)
mv_row -= 1;
......@@ -635,6 +635,8 @@ static int rd_pick_intra4x4block(
* */
DECLARE_ALIGNED_ARRAY(16, unsigned char, best_predictor, 16*4);
DECLARE_ALIGNED_ARRAY(16, short, best_dqcoeff, 16);
int dst_stride = x->e_mbd.dst.y_stride;
unsigned char *base_dst = x->e_mbd.dst.y_buffer;
for (mode = B_DC_PRED; mode <= B_HU_PRED; mode++)
{
......@@ -643,9 +645,8 @@ static int rd_pick_intra4x4block(
rate = bmode_costs[mode];
vp8_intra4x4_predict
(*(b->base_dst) + b->dst, b->dst_stride,
mode, b->predictor, 16);
vp8_intra4x4_predict(base_dst + b->offset, dst_stride, mode,
b->predictor, 16);
vp8_subtract_b(be, b, 16);
x->short_fdct4x4(be->src_diff, be->coeff, 32);
x->quantize_b(be, b);
......@@ -674,8 +675,8 @@ static int rd_pick_intra4x4block(
}
b->bmi.as_mode = (B_PREDICTION_MODE)(*best_mode);
vp8_short_idct4x4llm(best_dqcoeff,
best_predictor, 16, *(b->base_dst) + b->dst, b->dst_stride);
vp8_short_idct4x4llm(best_dqcoeff, best_predictor, 16, base_dst + b->offset,
dst_stride);
return best_rd;
}
......@@ -1008,6 +1009,9 @@ static unsigned int vp8_encode_inter_mb_segment(MACROBLOCK *x, int const *labels
{
int i;
unsigned int distortion = 0;
int pre_stride = x->e_mbd.pre.y_stride;
unsigned char *base_pre = x->e_mbd.pre.y_buffer;
for (i = 0; i < 16; i++)
{
......@@ -1016,8 +1020,7 @@ static unsigned int vp8_encode_inter_mb_segment(MACROBLOCK *x, int const *labels
BLOCKD *bd = &x->e_mbd.block[i];
BLOCK *be = &x->block[i];
vp8_build_inter_predictors_b(bd, 16, x->e_mbd.subpixel_predict);
vp8_build_inter_predictors_b(bd, 16, base_pre, pre_stride, x->e_mbd.subpixel_predict);
vp8_subtract_b(be, bd, 16);
x->short_fdct4x4(be->src_diff, be->coeff, 32);
......
......@@ -164,9 +164,9 @@ static int vp8_temporal_filter_find_matching_mb_c
unsigned char **base_src = b->base_src;
int src = b->src;
int src_stride = b->src_stride;
unsigned char **base_pre = d->base_pre;
int pre = d->pre;
int pre_stride = d->pre_stride;
unsigned char *base_pre = x->e_mbd.pre.y_buffer;
int pre = d->offset;
int pre_stride = x->e_mbd.pre.y_stride;
best_ref_mv1.as_int = 0;
best_ref_mv1_full.as_mv.col = best_ref_mv1.as_mv.col >>3;
......@@ -177,9 +177,9 @@ static int vp8_temporal_filter_find_matching_mb_c
b->src_stride = arf_frame->y_stride;
b->src = mb_offset;
d->base_pre = &frame_ptr->y_buffer;
d->pre_stride = frame_ptr->y_stride;
d->pre = mb_offset;
x->e_mbd.pre.y_buffer = frame_ptr->y_buffer;
x->e_mbd.pre.y_stride = frame_ptr->y_stride;
d->offset = mb_offset;
// Further step/diamond searches as necessary
if (cpi->Speed < 8)
......@@ -221,9 +221,9 @@ static int vp8_temporal_filter_find_matching_mb_c
b->base_src = base_src;
b->src = src;
b->src_stride = src_stride;
d->base_pre = base_pre;
d->pre = pre;
d->pre_stride = pre_stride;
x->e_mbd.pre.y_buffer = base_pre;
d->offset = pre;
x->e_mbd.pre.y_stride = pre_stride;
return bestsme;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment