Commit 403966ae authored by Scott LaVarnway's avatar Scott LaVarnway
Browse files

Removed duplicate vp8_build_intra_predictors_mb y/uv

Added y/uv stride as a parameter and remove the
duplicate code.

Change-Id: I019117a9dd9659a09d3d4e845d4814d3f33341b5
parent bf2c9030
...@@ -14,140 +14,17 @@ ...@@ -14,140 +14,17 @@
#include "vpx_mem/vpx_mem.h" #include "vpx_mem/vpx_mem.h"
#include "blockd.h" #include "blockd.h"
/* For skip_recon_mb(), add vp8_build_intra_predictors_mby_s(MACROBLOCKD *x) and
* vp8_build_intra_predictors_mbuv_s(MACROBLOCKD *x).
*/
void vp8_build_intra_predictors_mby_c(MACROBLOCKD *x)
{
unsigned char *yabove_row = x->dst.y_buffer - x->dst.y_stride;
unsigned char yleft_col[16];
unsigned char ytop_left = yabove_row[-1];
unsigned char *ypred_ptr = x->predictor;
int r, c, i;
for (i = 0; i < 16; i++)
{
yleft_col[i] = x->dst.y_buffer [i* x->dst.y_stride -1];
}
/* for Y */
switch (x->mode_info_context->mbmi.mode)
{
case DC_PRED:
{
int expected_dc;
int i;
int shift;
int average = 0;
if (x->up_available || x->left_available)
{
if (x->up_available)
{
for (i = 0; i < 16; i++)
{
average += yabove_row[i];
}
}
if (x->left_available)
{
for (i = 0; i < 16; i++)
{
average += yleft_col[i];
}
}
shift = 3 + x->up_available + x->left_available;
expected_dc = (average + (1 << (shift - 1))) >> shift;
}
else
{
expected_dc = 128;
}
vpx_memset(ypred_ptr, expected_dc, 256);
}
break;
case V_PRED:
{
for (r = 0; r < 16; r++)
{
((int *)ypred_ptr)[0] = ((int *)yabove_row)[0];
((int *)ypred_ptr)[1] = ((int *)yabove_row)[1];
((int *)ypred_ptr)[2] = ((int *)yabove_row)[2];
((int *)ypred_ptr)[3] = ((int *)yabove_row)[3];
ypred_ptr += 16;
}
}
break;
case H_PRED:
{
for (r = 0; r < 16; r++)
{
vpx_memset(ypred_ptr, yleft_col[r], 16);
ypred_ptr += 16;
}
}
break;
case TM_PRED:
{
for (r = 0; r < 16; r++)
{
for (c = 0; c < 16; c++)
{
int pred = yleft_col[r] + yabove_row[ c] - ytop_left;
if (pred < 0)
pred = 0;
if (pred > 255)
pred = 255;
ypred_ptr[c] = pred;
}
ypred_ptr += 16;
}
}
break;
case B_PRED:
case NEARESTMV:
case NEARMV:
case ZEROMV:
case NEWMV:
case SPLITMV:
case MB_MODE_COUNT:
break;
}
}
void vp8_build_intra_predictors_mby_s(MACROBLOCKD *x, void vp8_build_intra_predictors_mby_s(MACROBLOCKD *x,
unsigned char * yabove_row, unsigned char * yabove_row,
unsigned char * yleft, unsigned char * yleft,
int left_stride, int left_stride,
unsigned char * ypred_ptr) unsigned char * ypred_ptr,
int y_stride)
{ {
unsigned char yleft_col[16]; unsigned char yleft_col[16];
unsigned char ytop_left = yabove_row[-1]; unsigned char ytop_left = yabove_row[-1];
int r, c, i; int r, c, i;
int y_stride = x->dst.y_stride;
for (i = 0; i < 16; i++) for (i = 0; i < 16; i++)
{ {
yleft_col[i] = yleft[i* left_stride]; yleft_col[i] = yleft[i* left_stride];
...@@ -198,7 +75,7 @@ void vp8_build_intra_predictors_mby_s(MACROBLOCKD *x, ...@@ -198,7 +75,7 @@ void vp8_build_intra_predictors_mby_s(MACROBLOCKD *x,
for (r = 0; r < 16; r++) for (r = 0; r < 16; r++)
{ {
vpx_memset(ypred_ptr, expected_dc, 16); vpx_memset(ypred_ptr, expected_dc, 16);
ypred_ptr += y_stride; /*16;*/ ypred_ptr += y_stride;
} }
} }
break; break;
...@@ -212,7 +89,7 @@ void vp8_build_intra_predictors_mby_s(MACROBLOCKD *x, ...@@ -212,7 +89,7 @@ void vp8_build_intra_predictors_mby_s(MACROBLOCKD *x,
((int *)ypred_ptr)[1] = ((int *)yabove_row)[1]; ((int *)ypred_ptr)[1] = ((int *)yabove_row)[1];
((int *)ypred_ptr)[2] = ((int *)yabove_row)[2]; ((int *)ypred_ptr)[2] = ((int *)yabove_row)[2];
((int *)ypred_ptr)[3] = ((int *)yabove_row)[3]; ((int *)ypred_ptr)[3] = ((int *)yabove_row)[3];
ypred_ptr += y_stride; /*16;*/ ypred_ptr += y_stride;
} }
} }
break; break;
...@@ -223,7 +100,7 @@ void vp8_build_intra_predictors_mby_s(MACROBLOCKD *x, ...@@ -223,7 +100,7 @@ void vp8_build_intra_predictors_mby_s(MACROBLOCKD *x,
{ {
vpx_memset(ypred_ptr, yleft_col[r], 16); vpx_memset(ypred_ptr, yleft_col[r], 16);
ypred_ptr += y_stride; /*16;*/ ypred_ptr += y_stride;
} }
} }
...@@ -246,145 +123,7 @@ void vp8_build_intra_predictors_mby_s(MACROBLOCKD *x, ...@@ -246,145 +123,7 @@ void vp8_build_intra_predictors_mby_s(MACROBLOCKD *x,
ypred_ptr[c] = pred; ypred_ptr[c] = pred;
} }
ypred_ptr += y_stride; /*16;*/ ypred_ptr += y_stride;
}
}
break;
case B_PRED:
case NEARESTMV:
case NEARMV:
case ZEROMV:
case NEWMV:
case SPLITMV:
case MB_MODE_COUNT:
break;
}
}
void vp8_build_intra_predictors_mbuv_c(MACROBLOCKD *x)
{
unsigned char *uabove_row = x->dst.u_buffer - x->dst.uv_stride;
unsigned char uleft_col[16];
unsigned char utop_left = uabove_row[-1];
unsigned char *vabove_row = x->dst.v_buffer - x->dst.uv_stride;
unsigned char vleft_col[20];
unsigned char vtop_left = vabove_row[-1];
unsigned char *upred_ptr = &x->predictor[256];
unsigned char *vpred_ptr = &x->predictor[320];
int i, j;
for (i = 0; i < 8; i++)
{
uleft_col[i] = x->dst.u_buffer [i* x->dst.uv_stride -1];
vleft_col[i] = x->dst.v_buffer [i* x->dst.uv_stride -1];
}
switch (x->mode_info_context->mbmi.uv_mode)
{
case DC_PRED:
{
int expected_udc;
int expected_vdc;
int i;
int shift;
int Uaverage = 0;
int Vaverage = 0;
if (x->up_available)
{
for (i = 0; i < 8; i++)
{
Uaverage += uabove_row[i];
Vaverage += vabove_row[i];
}
}
if (x->left_available)
{
for (i = 0; i < 8; i++)
{
Uaverage += uleft_col[i];
Vaverage += vleft_col[i];
}
}
if (!x->up_available && !x->left_available)
{
expected_udc = 128;
expected_vdc = 128;
}
else
{
shift = 2 + x->up_available + x->left_available;
expected_udc = (Uaverage + (1 << (shift - 1))) >> shift;
expected_vdc = (Vaverage + (1 << (shift - 1))) >> shift;
}
vpx_memset(upred_ptr, expected_udc, 64);
vpx_memset(vpred_ptr, expected_vdc, 64);
}
break;
case V_PRED:
{
int i;
for (i = 0; i < 8; i++)
{
vpx_memcpy(upred_ptr, uabove_row, 8);
vpx_memcpy(vpred_ptr, vabove_row, 8);
upred_ptr += 8;
vpred_ptr += 8;
}
}
break;
case H_PRED:
{
int i;
for (i = 0; i < 8; i++)
{
vpx_memset(upred_ptr, uleft_col[i], 8);
vpx_memset(vpred_ptr, vleft_col[i], 8);
upred_ptr += 8;
vpred_ptr += 8;
}
}
break;
case TM_PRED:
{
int i;
for (i = 0; i < 8; i++)
{
for (j = 0; j < 8; j++)
{
int predu = uleft_col[i] + uabove_row[j] - utop_left;
int predv = vleft_col[i] + vabove_row[j] - vtop_left;
if (predu < 0)
predu = 0;
if (predu > 255)
predu = 255;
if (predv < 0)
predv = 0;
if (predv > 255)
predv = 255;
upred_ptr[j] = predu;
vpred_ptr[j] = predv;
}
upred_ptr += 8;
vpred_ptr += 8;
} }
} }
...@@ -407,13 +146,13 @@ void vp8_build_intra_predictors_mbuv_s_c(MACROBLOCKD *x, ...@@ -407,13 +146,13 @@ void vp8_build_intra_predictors_mbuv_s_c(MACROBLOCKD *x,
unsigned char * vleft, unsigned char * vleft,
int left_stride, int left_stride,
unsigned char * upred_ptr, unsigned char * upred_ptr,
unsigned char * vpred_ptr) unsigned char * vpred_ptr,
int pred_stride)
{ {
unsigned char uleft_col[8]; unsigned char uleft_col[8];
unsigned char utop_left = uabove_row[-1]; unsigned char utop_left = uabove_row[-1];
unsigned char vleft_col[8]; unsigned char vleft_col[8];
unsigned char vtop_left = vabove_row[-1]; unsigned char vtop_left = vabove_row[-1];
int uv_stride = x->dst.uv_stride;
int i, j; int i, j;
...@@ -471,8 +210,8 @@ void vp8_build_intra_predictors_mbuv_s_c(MACROBLOCKD *x, ...@@ -471,8 +210,8 @@ void vp8_build_intra_predictors_mbuv_s_c(MACROBLOCKD *x,
{ {
vpx_memset(upred_ptr, expected_udc, 8); vpx_memset(upred_ptr, expected_udc, 8);
vpx_memset(vpred_ptr, expected_vdc, 8); vpx_memset(vpred_ptr, expected_vdc, 8);
upred_ptr += uv_stride; /*8;*/ upred_ptr += pred_stride;
vpred_ptr += uv_stride; /*8;*/ vpred_ptr += pred_stride;
} }
} }
break; break;
...@@ -484,8 +223,8 @@ void vp8_build_intra_predictors_mbuv_s_c(MACROBLOCKD *x, ...@@ -484,8 +223,8 @@ void vp8_build_intra_predictors_mbuv_s_c(MACROBLOCKD *x,
{ {
vpx_memcpy(upred_ptr, uabove_row, 8); vpx_memcpy(upred_ptr, uabove_row, 8);
vpx_memcpy(vpred_ptr, vabove_row, 8); vpx_memcpy(vpred_ptr, vabove_row, 8);
upred_ptr += uv_stride; /*8;*/ upred_ptr += pred_stride;
vpred_ptr += uv_stride; /*8;*/ vpred_ptr += pred_stride;
} }
} }
...@@ -498,8 +237,8 @@ void vp8_build_intra_predictors_mbuv_s_c(MACROBLOCKD *x, ...@@ -498,8 +237,8 @@ void vp8_build_intra_predictors_mbuv_s_c(MACROBLOCKD *x,
{ {
vpx_memset(upred_ptr, uleft_col[i], 8); vpx_memset(upred_ptr, uleft_col[i], 8);
vpx_memset(vpred_ptr, vleft_col[i], 8); vpx_memset(vpred_ptr, vleft_col[i], 8);
upred_ptr += uv_stride; /*8;*/ upred_ptr += pred_stride;
vpred_ptr += uv_stride; /*8;*/ vpred_ptr += pred_stride;
} }
} }
...@@ -531,8 +270,8 @@ void vp8_build_intra_predictors_mbuv_s_c(MACROBLOCKD *x, ...@@ -531,8 +270,8 @@ void vp8_build_intra_predictors_mbuv_s_c(MACROBLOCKD *x,
vpred_ptr[j] = predv; vpred_ptr[j] = predv;
} }
upred_ptr += uv_stride; /*8;*/ upred_ptr += pred_stride;
vpred_ptr += uv_stride; /*8;*/ vpred_ptr += pred_stride;
} }
} }
......
...@@ -122,16 +122,10 @@ prototype void vp8_copy_mem8x4 "unsigned char *src, int src_pitch, unsigned char ...@@ -122,16 +122,10 @@ prototype void vp8_copy_mem8x4 "unsigned char *src, int src_pitch, unsigned char
specialize vp8_copy_mem8x4 mmx media neon specialize vp8_copy_mem8x4 mmx media neon
vp8_copy_mem8x4_media=vp8_copy_mem8x4_v6 vp8_copy_mem8x4_media=vp8_copy_mem8x4_v6
prototype void vp8_build_intra_predictors_mby "struct macroblockd *x" prototype void vp8_build_intra_predictors_mby_s "struct macroblockd *x, unsigned char * yabove_row, unsigned char * yleft, int left_stride, unsigned char * ypred_ptr, int y_stride"
specialize vp8_build_intra_predictors_mby sse2 ssse3 neon
prototype void vp8_build_intra_predictors_mby_s "struct macroblockd *x, unsigned char * yabove_row, unsigned char * yleft, int left_stride, unsigned char * ypred_ptr"
#TODO: fix assembly --- specialize vp8_build_intra_predictors_mby_s sse2 ssse3 neon #TODO: fix assembly --- specialize vp8_build_intra_predictors_mby_s sse2 ssse3 neon
prototype void vp8_build_intra_predictors_mbuv "struct macroblockd *x" prototype void vp8_build_intra_predictors_mbuv_s "struct macroblockd *x, unsigned char * uabove_row, unsigned char * vabove_row, unsigned char *uleft, unsigned char *vleft, int left_stride, unsigned char * upred_ptr, unsigned char * vpred_ptr, int pred_stride"
specialize vp8_build_intra_predictors_mbuv sse2 ssse3
prototype void vp8_build_intra_predictors_mbuv_s "struct macroblockd *x, unsigned char * uabove_row, unsigned char * vabove_row, unsigned char *uleft, unsigned char *vleft, int left_stride, unsigned char * upred_ptr, unsigned char * vpred_ptr"
#TODO: fix assembly --- specialize vp8_build_intra_predictors_mbuv_s sse2 ssse3 #TODO: fix assembly --- specialize vp8_build_intra_predictors_mbuv_s sse2 ssse3
prototype void vp8_intra4x4_predict "unsigned char *src, int src_stride, int b_mode, unsigned char *dst, int dst_stride" prototype void vp8_intra4x4_predict "unsigned char *src, int src_stride, int b_mode, unsigned char *dst, int dst_stride"
......
...@@ -162,7 +162,8 @@ static void decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd, ...@@ -162,7 +162,8 @@ static void decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd,
xd->recon_left[1], xd->recon_left[1],
xd->recon_left[2], xd->recon_left[2],
xd->recon_left_stride[1], xd->recon_left_stride[1],
xd->dst.u_buffer, xd->dst.v_buffer); xd->dst.u_buffer, xd->dst.v_buffer,
xd->dst.uv_stride);
if (mode != B_PRED) if (mode != B_PRED)
{ {
...@@ -170,7 +171,8 @@ static void decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd, ...@@ -170,7 +171,8 @@ static void decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd,
xd->recon_above[0], xd->recon_above[0],
xd->recon_left[0], xd->recon_left[0],
xd->recon_left_stride[0], xd->recon_left_stride[0],
xd->dst.y_buffer); xd->dst.y_buffer,
xd->dst.y_stride);
} }
else else
{ {
......
...@@ -150,7 +150,8 @@ static void decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd, unsigned int mb_i ...@@ -150,7 +150,8 @@ static void decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd, unsigned int mb_i
xd->recon_left[1], xd->recon_left[1],
xd->recon_left[2], xd->recon_left[2],
xd->recon_left_stride[1], xd->recon_left_stride[1],
xd->dst.u_buffer, xd->dst.v_buffer); xd->dst.u_buffer, xd->dst.v_buffer,
xd->dst.uv_stride);
if (mode != B_PRED) if (mode != B_PRED)
{ {
...@@ -158,7 +159,8 @@ static void decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd, unsigned int mb_i ...@@ -158,7 +159,8 @@ static void decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd, unsigned int mb_i
xd->recon_above[0], xd->recon_above[0],
xd->recon_left[0], xd->recon_left[0],
xd->recon_left_stride[0], xd->recon_left_stride[0],
xd->dst.y_buffer); xd->dst.y_buffer,
xd->dst.y_stride);
} }
else else
{ {
......
...@@ -99,7 +99,8 @@ void vp8_encode_intra16x16mby(MACROBLOCK *x) ...@@ -99,7 +99,8 @@ void vp8_encode_intra16x16mby(MACROBLOCK *x)
xd->dst.y_buffer - xd->dst.y_stride, xd->dst.y_buffer - xd->dst.y_stride,
xd->dst.y_buffer - 1, xd->dst.y_buffer - 1,
xd->dst.y_stride, xd->dst.y_stride,
xd->dst.y_buffer); xd->dst.y_buffer,
xd->dst.y_stride);
vp8_subtract_mby(x->src_diff, *(b->base_src), vp8_subtract_mby(x->src_diff, *(b->base_src),
b->src_stride, xd->dst.y_buffer, xd->dst.y_stride); b->src_stride, xd->dst.y_buffer, xd->dst.y_stride);
...@@ -121,7 +122,8 @@ void vp8_encode_intra16x16mbuv(MACROBLOCK *x) ...@@ -121,7 +122,8 @@ void vp8_encode_intra16x16mbuv(MACROBLOCK *x)
xd->dst.u_buffer - 1, xd->dst.u_buffer - 1,
xd->dst.v_buffer - 1, xd->dst.v_buffer - 1,
xd->dst.uv_stride, xd->dst.uv_stride,
xd->dst.u_buffer, xd->dst.v_buffer); xd->dst.u_buffer, xd->dst.v_buffer,
xd->dst.uv_stride);
vp8_subtract_mbuv(x->src_diff, x->src.u_buffer, vp8_subtract_mbuv(x->src_diff, x->src.u_buffer,
x->src.v_buffer, x->src.uv_stride, xd->dst.u_buffer, x->src.v_buffer, x->src.uv_stride, xd->dst.u_buffer,
......
...@@ -735,8 +735,12 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset, ...@@ -735,8 +735,12 @@ void vp8_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
case V_PRED: case V_PRED:
case H_PRED: case H_PRED:
case TM_PRED: case TM_PRED:
vp8_build_intra_predictors_mby vp8_build_intra_predictors_mby_s(xd,
(&x->e_mbd); xd->dst.y_buffer - xd->dst.y_stride,
xd->dst.y_buffer - 1,
xd->dst.y_stride,
xd->predictor,
16);
distortion2 = vp8_variance16x16 distortion2 = vp8_variance16x16
(*(b->base_src), b->src_stride, (*(b->base_src), b->src_stride,
x->e_mbd.predictor, 16, &sse); x->e_mbd.predictor, 16, &sse);
...@@ -1130,19 +1134,24 @@ void vp8_pick_intra_mode(VP8_COMP *cpi, MACROBLOCK *x, int *rate_) ...@@ -1130,19 +1134,24 @@ void vp8_pick_intra_mode(VP8_COMP *cpi, MACROBLOCK *x, int *rate_)
int this_rd; int this_rd;
unsigned int sse; unsigned int sse;
BLOCK *b = &x->block[0]; BLOCK *b = &x->block[0];
MACROBLOCKD *xd = &x->e_mbd;
x->e_mbd.mode_info_context->mbmi.ref_frame = INTRA_FRAME; xd->mode_info_context->mbmi.ref_frame = INTRA_FRAME;
pick_intra_mbuv_mode(x); pick_intra_mbuv_mode(x);
for (mode = DC_PRED; mode <= TM_PRED; mode ++) for (mode = DC_PRED; mode <= TM_PRED; mode ++)
{ {
x->e_mbd.mode_info_context->mbmi.mode = mode; xd->mode_info_context->mbmi.mode = mode;
vp8_build_intra_predictors_mby vp8_build_intra_predictors_mby_s(xd,
(&x->e_mbd); xd->dst.y_buffer - xd->dst.y_stride,
xd->dst.y_buffer - 1,
xd->dst.y_stride,
xd->predictor,
16);
distortion = vp8_variance16x16 distortion = vp8_variance16x16
(*(b->base_src), b->src_stride, x->e_mbd.predictor, 16, &sse); (*(b->base_src), b->src_stride, xd->predictor, 16, &sse);
rate = x->mbmode_cost[x->e_mbd.frame_type][mode]; rate = x->mbmode_cost[xd->frame_type][mode];
this_rd = RDCOST(x->rdmult, x->rddiv, rate, distortion); this_rd = RDCOST(x->rdmult, x->rddiv, rate, distortion);
if (error16x16 > this_rd) if (error16x16 > this_rd)
...@@ -1153,13 +1162,13 @@ void vp8_pick_intra_mode(VP8_COMP *cpi, MACROBLOCK *x, int *rate_) ...@@ -1153,13 +1162,13 @@ void vp8_pick_intra_mode(VP8_COMP *cpi, MACROBLOCK *x, int *rate_)
best_rate = rate; best_rate = rate;
} }
} }
x->e_mbd.mode_info_context->mbmi.mode = best_mode; xd->mode_info_context->mbmi.mode = best_mode;
error4x4 = pick_intra4x4mby_modes(x, &rate, error4x4 = pick_intra4x4mby_modes(x, &rate,
&best_sse); &best_sse);