Removed duplicate vp8_build_intra_predictors_mb y/uv

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

Change-Id: I019117a9dd9659a09d3d4e845d4814d3f33341b5
This commit is contained in:
Scott LaVarnway 2012-03-20 15:11:42 -04:00
Родитель bf2c903000
Коммит 403966ae00
7 изменённых файлов: 83 добавлений и 315 удалений

Просмотреть файл

@ -14,140 +14,17 @@
#include "vpx_mem/vpx_mem.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,
unsigned char * yabove_row,
unsigned char * yleft,
int left_stride,
unsigned char * ypred_ptr)
unsigned char * ypred_ptr,
int y_stride)
{
unsigned char yleft_col[16];
unsigned char ytop_left = yabove_row[-1];
int r, c, i;
int y_stride = x->dst.y_stride;
for (i = 0; i < 16; i++)
{
yleft_col[i] = yleft[i* left_stride];
@ -198,7 +75,7 @@ void vp8_build_intra_predictors_mby_s(MACROBLOCKD *x,
for (r = 0; r < 16; r++)
{
vpx_memset(ypred_ptr, expected_dc, 16);
ypred_ptr += y_stride; /*16;*/
ypred_ptr += y_stride;
}
}
break;
@ -212,7 +89,7 @@ void vp8_build_intra_predictors_mby_s(MACROBLOCKD *x,
((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 += y_stride; /*16;*/
ypred_ptr += y_stride;
}
}
break;
@ -223,7 +100,7 @@ void vp8_build_intra_predictors_mby_s(MACROBLOCKD *x,
{
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,
ypred_ptr[c] = pred;
}
ypred_ptr += y_stride; /*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_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;
ypred_ptr += y_stride;
}
}
@ -407,13 +146,13 @@ void vp8_build_intra_predictors_mbuv_s_c(MACROBLOCKD *x,
unsigned char * vleft,
int left_stride,
unsigned char * upred_ptr,
unsigned char * vpred_ptr)
unsigned char * vpred_ptr,
int pred_stride)
{
unsigned char uleft_col[8];
unsigned char utop_left = uabove_row[-1];
unsigned char vleft_col[8];
unsigned char vtop_left = vabove_row[-1];
int uv_stride = x->dst.uv_stride;
int i, j;
@ -471,8 +210,8 @@ void vp8_build_intra_predictors_mbuv_s_c(MACROBLOCKD *x,
{
vpx_memset(upred_ptr, expected_udc, 8);
vpx_memset(vpred_ptr, expected_vdc, 8);
upred_ptr += uv_stride; /*8;*/
vpred_ptr += uv_stride; /*8;*/
upred_ptr += pred_stride;
vpred_ptr += pred_stride;
}
}
break;
@ -484,8 +223,8 @@ void vp8_build_intra_predictors_mbuv_s_c(MACROBLOCKD *x,
{
vpx_memcpy(upred_ptr, uabove_row, 8);
vpx_memcpy(vpred_ptr, vabove_row, 8);
upred_ptr += uv_stride; /*8;*/
vpred_ptr += uv_stride; /*8;*/
upred_ptr += pred_stride;
vpred_ptr += pred_stride;
}
}
@ -498,8 +237,8 @@ void vp8_build_intra_predictors_mbuv_s_c(MACROBLOCKD *x,
{
vpx_memset(upred_ptr, uleft_col[i], 8);
vpx_memset(vpred_ptr, vleft_col[i], 8);
upred_ptr += uv_stride; /*8;*/
vpred_ptr += uv_stride; /*8;*/
upred_ptr += pred_stride;
vpred_ptr += pred_stride;
}
}
@ -531,8 +270,8 @@ void vp8_build_intra_predictors_mbuv_s_c(MACROBLOCKD *x,
vpred_ptr[j] = predv;
}
upred_ptr += uv_stride; /*8;*/
vpred_ptr += uv_stride; /*8;*/
upred_ptr += pred_stride;
vpred_ptr += pred_stride;
}
}

Просмотреть файл

@ -122,16 +122,10 @@ prototype void vp8_copy_mem8x4 "unsigned char *src, int src_pitch, unsigned char
specialize vp8_copy_mem8x4 mmx media neon
vp8_copy_mem8x4_media=vp8_copy_mem8x4_v6
prototype void vp8_build_intra_predictors_mby "struct macroblockd *x"
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"
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"
#TODO: fix assembly --- specialize vp8_build_intra_predictors_mby_s sse2 ssse3 neon
prototype void vp8_build_intra_predictors_mbuv "struct macroblockd *x"
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"
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"
#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"

Просмотреть файл

@ -162,7 +162,8 @@ static void decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd,
xd->recon_left[1],
xd->recon_left[2],
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)
{
@ -170,7 +171,8 @@ static void decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd,
xd->recon_above[0],
xd->recon_left[0],
xd->recon_left_stride[0],
xd->dst.y_buffer);
xd->dst.y_buffer,
xd->dst.y_stride);
}
else
{

Просмотреть файл

@ -150,7 +150,8 @@ static void decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd, unsigned int mb_i
xd->recon_left[1],
xd->recon_left[2],
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)
{
@ -158,7 +159,8 @@ static void decode_macroblock(VP8D_COMP *pbi, MACROBLOCKD *xd, unsigned int mb_i
xd->recon_above[0],
xd->recon_left[0],
xd->recon_left_stride[0],
xd->dst.y_buffer);
xd->dst.y_buffer,
xd->dst.y_stride);
}
else
{

Просмотреть файл

@ -99,7 +99,8 @@ void vp8_encode_intra16x16mby(MACROBLOCK *x)
xd->dst.y_buffer - xd->dst.y_stride,
xd->dst.y_buffer - 1,
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),
b->src_stride, xd->dst.y_buffer, xd->dst.y_stride);
@ -121,7 +122,8 @@ void vp8_encode_intra16x16mbuv(MACROBLOCK *x)
xd->dst.u_buffer - 1,
xd->dst.v_buffer - 1,
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,
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,
case V_PRED:
case H_PRED:
case TM_PRED:
vp8_build_intra_predictors_mby
(&x->e_mbd);
vp8_build_intra_predictors_mby_s(xd,
xd->dst.y_buffer - xd->dst.y_stride,
xd->dst.y_buffer - 1,
xd->dst.y_stride,
xd->predictor,
16);
distortion2 = vp8_variance16x16
(*(b->base_src), b->src_stride,
x->e_mbd.predictor, 16, &sse);
@ -1130,19 +1134,24 @@ void vp8_pick_intra_mode(VP8_COMP *cpi, MACROBLOCK *x, int *rate_)
int this_rd;
unsigned int sse;
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);
for (mode = DC_PRED; mode <= TM_PRED; mode ++)
{
x->e_mbd.mode_info_context->mbmi.mode = mode;
vp8_build_intra_predictors_mby
(&x->e_mbd);
xd->mode_info_context->mbmi.mode = mode;
vp8_build_intra_predictors_mby_s(xd,
xd->dst.y_buffer - xd->dst.y_stride,
xd->dst.y_buffer - 1,
xd->dst.y_stride,
xd->predictor,
16);
distortion = vp8_variance16x16
(*(b->base_src), b->src_stride, x->e_mbd.predictor, 16, &sse);
rate = x->mbmode_cost[x->e_mbd.frame_type][mode];
(*(b->base_src), b->src_stride, xd->predictor, 16, &sse);
rate = x->mbmode_cost[xd->frame_type][mode];
this_rd = RDCOST(x->rdmult, x->rddiv, rate, distortion);
if (error16x16 > this_rd)
@ -1153,13 +1162,13 @@ void vp8_pick_intra_mode(VP8_COMP *cpi, MACROBLOCK *x, int *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,
&best_sse);
if (error4x4 < error16x16)
{
x->e_mbd.mode_info_context->mbmi.mode = B_PRED;
xd->mode_info_context->mbmi.mode = B_PRED;
best_rate = rate;
}

Просмотреть файл

@ -782,18 +782,23 @@ static int rd_pick_intra16x16mby_mode(VP8_COMP *cpi,
int distortion;
int best_rd = INT_MAX;
int this_rd;
MACROBLOCKD *xd = &x->e_mbd;
//Y Search for 16x16 intra prediction 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
(&x->e_mbd);
vp8_build_intra_predictors_mby_s(xd,
xd->dst.y_buffer - xd->dst.y_stride,
xd->dst.y_buffer - 1,
xd->dst.y_stride,
xd->predictor,
16);
macro_block_yrd(x, &ratey, &distortion);
rate = ratey + x->mbmode_cost[x->e_mbd.frame_type]
[x->e_mbd.mode_info_context->mbmi.mode];
rate = ratey + x->mbmode_cost[xd->frame_type]
[xd->mode_info_context->mbmi.mode];
this_rd = RDCOST(x->rdmult, x->rddiv, rate, distortion);
@ -807,7 +812,7 @@ static int rd_pick_intra16x16mby_mode(VP8_COMP *cpi,
}
}
x->e_mbd.mode_info_context->mbmi.mode = mode_selected;
xd->mode_info_context->mbmi.mode = mode_selected;
return best_rd;
}
@ -875,6 +880,7 @@ static void rd_pick_intra_mbuv_mode(VP8_COMP *cpi, MACROBLOCK *x, int *rate, int
int best_rd = INT_MAX;
int UNINITIALIZED_IS_SAFE(d), UNINITIALIZED_IS_SAFE(r);
int rate_to;
MACROBLOCKD *xd = &x->e_mbd;
for (mode = DC_PRED; mode <= TM_PRED; mode++)
{
@ -882,17 +888,26 @@ static void rd_pick_intra_mbuv_mode(VP8_COMP *cpi, MACROBLOCK *x, int *rate, int
int distortion;
int this_rd;
x->e_mbd.mode_info_context->mbmi.uv_mode = mode;
vp8_build_intra_predictors_mbuv
(&x->e_mbd);
xd->mode_info_context->mbmi.uv_mode = mode;
vp8_build_intra_predictors_mbuv_s(xd,
xd->dst.u_buffer - xd->dst.uv_stride,
xd->dst.v_buffer - xd->dst.uv_stride,
xd->dst.u_buffer - 1,
xd->dst.v_buffer - 1,
xd->dst.uv_stride,
&xd->predictor[256], &xd->predictor[320],
8);
vp8_subtract_mbuv(x->src_diff,
x->src.u_buffer, x->src.v_buffer, x->src.uv_stride,
&x->e_mbd.predictor[256], &x->e_mbd.predictor[320], 8);
&xd->predictor[256], &xd->predictor[320], 8);
vp8_transform_mbuv(x);
vp8_quantize_mbuv(x);
rate_to = rd_cost_mbuv(x);
rate = rate_to + x->intra_uv_mode_cost[x->e_mbd.frame_type][x->e_mbd.mode_info_context->mbmi.uv_mode];
rate = rate_to + x->intra_uv_mode_cost[xd->frame_type][xd->mode_info_context->mbmi.uv_mode];
distortion = vp8_mbuverror(x) / 4;
@ -911,7 +926,7 @@ static void rd_pick_intra_mbuv_mode(VP8_COMP *cpi, MACROBLOCK *x, int *rate, int
*rate = r;
*distortion = d;
x->e_mbd.mode_info_context->mbmi.uv_mode = mode_selected;
xd->mode_info_context->mbmi.uv_mode = mode_selected;
}
int vp8_cost_mv_ref(MB_PREDICTION_MODE m, const int near_mv_ref_ct[4])
@ -2157,8 +2172,13 @@ void vp8_rd_pick_inter_mode(VP8_COMP *cpi, MACROBLOCK *x, int recon_yoffset,
{
int distortion;
x->e_mbd.mode_info_context->mbmi.ref_frame = INTRA_FRAME;
vp8_build_intra_predictors_mby
(&x->e_mbd);
vp8_build_intra_predictors_mby_s(xd,
xd->dst.y_buffer - xd->dst.y_stride,
xd->dst.y_buffer - 1,
xd->dst.y_stride,
xd->predictor,
16);
macro_block_yrd(x, &rd.rate_y, &distortion) ;
rd.rate2 += rd.rate_y;
rd.distortion2 += distortion;