Commit d4761651 authored by Ronald S. Bultje's avatar Ronald S. Bultje

Compound intra prediction (b_pred/4x4 only, for now),

Also remove duplicate build_intra_predictors_mby/uv().

Change-Id: I78607e7304952a9b962a5b25af9bb9c48692187b
parent af5c774b
......@@ -223,6 +223,7 @@ EXPERIMENT_LIST="
featureupdates
high_precision_mv
sixteenth_subpel_uv
comp_intra_pred
"
CONFIG_LIST="
external_build
......
......@@ -158,7 +158,12 @@ typedef enum
union b_mode_info
{
B_PREDICTION_MODE as_mode;
struct {
B_PREDICTION_MODE first;
#if CONFIG_COMP_INTRA_PRED
B_PREDICTION_MODE second;
#endif
} as_mode;
int_mv mv;
};
......@@ -174,6 +179,9 @@ typedef enum
typedef struct
{
MB_PREDICTION_MODE mode, uv_mode;
#if CONFIG_COMP_INTRA_PRED
MB_PREDICTION_MODE second_mode, second_uv_mode;
#endif
MV_REFERENCE_FRAME ref_frame, second_ref_frame;
#if CONFIG_T8X8
TX_SIZE txfm_size;
......
......@@ -97,7 +97,12 @@ void vp8_print_modes_and_motion_vectors(MODE_INFO *mi, int rows, int cols, int f
bindex = (b_row & 3) * 4 + (b_col & 3);
if (mi[mb_index].mbmi.mode == B_PRED)
fprintf(mvs, "%2d ", mi[mb_index].bmi[bindex].as_mode);
{
fprintf(mvs, "%2d ", mi[mb_index].bmi[bindex].as_mode.first);
#if CONFIG_COMP_INTRA_PRED
fprintf(mvs, "%2d ", mi[mb_index].bmi[bindex].as_mode.second);
#endif
}
else
fprintf(mvs, "xx ");
......
......@@ -137,12 +137,12 @@ static B_PREDICTION_MODE left_block_mode(const MODE_INFO *cur_mb, int b)
return B_TM_PRED;
case I8X8_PRED:
case B_PRED:
return (cur_mb->bmi + b + 3)->as_mode;
return (cur_mb->bmi + b + 3)->as_mode.first;
default:
return B_DC_PRED;
}
}
return (cur_mb->bmi + b - 1)->as_mode;
return (cur_mb->bmi + b - 1)->as_mode.first;
}
static B_PREDICTION_MODE above_block_mode(const MODE_INFO
......@@ -165,13 +165,13 @@ static B_PREDICTION_MODE above_block_mode(const MODE_INFO
return B_TM_PRED;
case I8X8_PRED:
case B_PRED:
return (cur_mb->bmi + b + 12)->as_mode;
return (cur_mb->bmi + b + 12)->as_mode.first;
default:
return B_DC_PRED;
}
}
return (cur_mb->bmi + b - 4)->as_mode;
return (cur_mb->bmi + b - 4)->as_mode.first;
}
#endif
......@@ -48,18 +48,38 @@ void vp8_machine_specific_config(VP8_COMMON *ctx)
rtcd->recon.recon_mby = vp8_recon_mby_c;
rtcd->recon.build_intra_predictors_mby =
vp8_build_intra_predictors_mby;
#if CONFIG_COMP_INTRA_PRED
rtcd->recon.build_comp_intra_predictors_mby =
vp8_build_comp_intra_predictors_mby;
#endif
rtcd->recon.build_intra_predictors_mby_s =
vp8_build_intra_predictors_mby_s;
rtcd->recon.build_intra_predictors_mbuv =
vp8_build_intra_predictors_mbuv;
rtcd->recon.build_intra_predictors_mbuv_s =
vp8_build_intra_predictors_mbuv_s;
#if CONFIG_COMP_INTRA_PRED
rtcd->recon.build_comp_intra_predictors_mbuv =
vp8_build_comp_intra_predictors_mbuv;
#endif
rtcd->recon.intra4x4_predict =
vp8_intra4x4_predict;
#if CONFIG_COMP_INTRA_PRED
rtcd->recon.comp_intra4x4_predict =
vp8_comp_intra4x4_predict;
#endif
rtcd->recon.intra8x8_predict =
vp8_intra8x8_predict;
#if CONFIG_COMP_INTRA_PRED
rtcd->recon.comp_intra8x8_predict =
vp8_comp_intra8x8_predict;
#endif
rtcd->recon.intra_uv4x4_predict =
vp8_intra_uv4x4_predict;
#if CONFIG_COMP_INTRA_PRED
rtcd->recon.comp_intra_uv4x4_predict =
vp8_comp_intra_uv4x4_predict;
#endif
rtcd->subpix.sixtap16x16 = vp8_sixtap_predict16x16_c;
rtcd->subpix.sixtap8x8 = vp8_sixtap_predict8x8_c;
......
......@@ -1024,9 +1024,9 @@ int vp8_post_proc_frame(VP8_COMMON *oci, YV12_BUFFER_CONFIG *dest, vp8_ppflags_t
if ((ppflags->display_b_modes_flag & (1<<mi->mbmi.mode))
|| (ppflags->display_mb_modes_flag & B_PRED))
{
Y = B_PREDICTION_MODE_colors[bmi->as_mode][0];
U = B_PREDICTION_MODE_colors[bmi->as_mode][1];
V = B_PREDICTION_MODE_colors[bmi->as_mode][2];
Y = B_PREDICTION_MODE_colors[bmi->as_mode.first][0];
U = B_PREDICTION_MODE_colors[bmi->as_mode.first][1];
V = B_PREDICTION_MODE_colors[bmi->as_mode.first][2];
POSTPROC_INVOKE(RTCD_VTABLE(oci), blend_b)
(yl+bx, ul+(bx>>1), vl+(bx>>1), Y, U, V, 0xc000, y_stride);
......
......@@ -29,6 +29,11 @@
#define prototype_intra4x4_predict(sym) \
void sym(BLOCKD *x, int b_mode, unsigned char *predictor)
#if CONFIG_COMP_INTRA_PRED
#define prototype_comp_intra4x4_predict(sym) \
void sym(BLOCKD *x, int b_mode, int mode2, unsigned char *predictor)
#endif
struct vp8_recon_rtcd_vtable;
#if ARCH_X86 || ARCH_X86_64
......@@ -101,6 +106,14 @@ extern prototype_recon_macroblock(vp8_recon_recon_mby);
extern prototype_build_intra_predictors\
(vp8_recon_build_intra_predictors_mby);
#if CONFIG_COMP_INTRA_PRED
#ifndef vp8_recon_build_comp_intra_predictors_mby
#define vp8_recon_build_comp_intra_predictors_mby vp8_build_comp_intra_predictors_mby
#endif
extern prototype_build_intra_predictors\
(vp8_recon_build_comp_intra_predictors_mby);
#endif
#ifndef vp8_recon_build_intra8x8_predictors_mby
#define vp8_recon_build_intra8x8_predictors_mby vp8_build_intra8x8_predictors_mby
#endif
......@@ -131,29 +144,64 @@ extern prototype_build_intra_predictors\
extern prototype_build_intra_predictors\
(vp8_recon_build_intra_predictors_mbuv_s);
#if CONFIG_COMP_INTRA_PRED
#ifndef vp8_recon_build_comp_intra_predictors_mbuv
#define vp8_recon_build_comp_intra_predictors_mbuv vp8_build_comp_intra_predictors_mbuv
#endif
extern prototype_build_intra_predictors\
(vp8_recon_build_comp_intra_predictors_mbuv);
#endif
#ifndef vp8_recon_intra4x4_predict
#define vp8_recon_intra4x4_predict vp8_intra4x4_predict
#endif
extern prototype_intra4x4_predict\
(vp8_recon_intra4x4_predict);
#if CONFIG_COMP_INTRA_PRED
#ifndef vp8_recon_comp_intra4x4_predict
#define vp8_recon_comp_intra4x4_predict vp8_comp_intra4x4_predict
#endif
extern prototype_comp_intra4x4_predict\
(vp8_recon_comp_intra4x4_predict);
#endif
#ifndef vp8_recon_intra8x8_predict
#define vp8_recon_intra8x8_predict vp8_intra8x8_predict
#endif
extern prototype_intra4x4_predict\
(vp8_recon_intra8x8_predict);
#if CONFIG_COMP_INTRA_PRED
#ifndef vp8_recon_comp_intra8x8_predict
#define vp8_recon_comp_intra8x8_predict vp8_comp_intra8x8_predict
#endif
extern prototype_comp_intra4x4_predict\
(vp8_recon_comp_intra8x8_predict);
#endif
#ifndef vp8_recon_intra_uv4x4_predict
#define vp8_recon_intra_uv4x4_predict vp8_intra_uv4x4_predict
#endif
extern prototype_intra4x4_predict\
(vp8_recon_intra_uv4x4_predict);
#if CONFIG_COMP_INTRA_PRED
#ifndef vp8_recon_comp_intra_uv4x4_predict
#define vp8_recon_comp_intra_uv4x4_predict vp8_comp_intra_uv4x4_predict
#endif
extern prototype_comp_intra4x4_predict\
(vp8_recon_comp_intra_uv4x4_predict);
#endif
typedef prototype_copy_block((*vp8_copy_block_fn_t));
typedef prototype_recon_block((*vp8_recon_fn_t));
typedef prototype_recon_macroblock((*vp8_recon_mb_fn_t));
typedef prototype_build_intra_predictors((*vp8_build_intra_pred_fn_t));
typedef prototype_intra4x4_predict((*vp8_intra4x4_pred_fn_t));
#if CONFIG_COMP_INTRA_PRED
typedef prototype_comp_intra4x4_predict((*vp8_comp_intra4x4_pred_fn_t));
#endif
typedef struct vp8_recon_rtcd_vtable
{
vp8_copy_block_fn_t copy16x16;
......@@ -169,11 +217,26 @@ typedef struct vp8_recon_rtcd_vtable
vp8_recon_mb_fn_t recon_mby;
vp8_build_intra_pred_fn_t build_intra_predictors_mby_s;
vp8_build_intra_pred_fn_t build_intra_predictors_mby;
#if CONFIG_COMP_INTRA_PRED
vp8_build_intra_pred_fn_t build_comp_intra_predictors_mby;
#endif
vp8_build_intra_pred_fn_t build_intra_predictors_mbuv_s;
vp8_build_intra_pred_fn_t build_intra_predictors_mbuv;
#if CONFIG_COMP_INTRA_PRED
vp8_build_intra_pred_fn_t build_comp_intra_predictors_mbuv;
#endif
vp8_intra4x4_pred_fn_t intra4x4_predict;
#if CONFIG_COMP_INTRA_PRED
vp8_comp_intra4x4_pred_fn_t comp_intra4x4_predict;
#endif
vp8_intra4x4_pred_fn_t intra8x8_predict;
#if CONFIG_COMP_INTRA_PRED
vp8_comp_intra4x4_pred_fn_t comp_intra8x8_predict;
#endif
vp8_intra4x4_pred_fn_t intra_uv4x4_predict;
#if CONFIG_COMP_INTRA_PRED
vp8_comp_intra4x4_pred_fn_t comp_intra_uv4x4_predict;
#endif
} vp8_recon_rtcd_vtable_t;
#if CONFIG_RUNTIME_CPU_DETECT
......
......@@ -28,13 +28,12 @@ void vp8_recon_intra_mbuv(const vp8_recon_rtcd_vtable_t *rtcd, MACROBLOCKD *x)
}
}
void vp8_build_intra_predictors_mby(MACROBLOCKD *x)
void vp8_build_intra_predictors_mby_internal(MACROBLOCKD *x, unsigned char *ypred_ptr, int y_stride, int mode)
{
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++)
......@@ -43,127 +42,7 @@ void vp8_build_intra_predictors_mby(MACROBLOCKD *x)
}
/* 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;
#if CONIFG_I8X8
case I8X8_PRED:
#endif
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 = 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;
int y_stride = x->dst.y_stride;
ypred_ptr = x->dst.y_buffer; /*x->predictor;*/
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)
switch (mode)
{
case DC_PRED:
{
......@@ -190,9 +69,7 @@ void vp8_build_intra_predictors_mby_s(MACROBLOCKD *x)
{
average += yleft_col[i];
}
}
shift = 3 + x->up_available + x->left_available;
expected_dc = (average + (1 << (shift - 1))) >> shift;
}
......@@ -201,7 +78,6 @@ void vp8_build_intra_predictors_mby_s(MACROBLOCKD *x)
expected_dc = 128;
}
/*vpx_memset(ypred_ptr, expected_dc, 256);*/
for (r = 0; r < 16; r++)
{
vpx_memset(ypred_ptr, expected_dc, 16);
......@@ -219,7 +95,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;
......@@ -230,7 +106,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;
}
}
......@@ -253,11 +129,14 @@ void vp8_build_intra_predictors_mby_s(MACROBLOCKD *x)
ypred_ptr[c] = pred;
}
ypred_ptr += y_stride; /*16;*/
ypred_ptr += y_stride;
}
}
break;
#if CONIFG_I8X8
case I8X8_PRED:
#endif
case B_PRED:
case NEARESTMV:
case NEARMV:
......@@ -269,145 +148,41 @@ void vp8_build_intra_predictors_mby_s(MACROBLOCKD *x)
}
}
void vp8_build_intra_predictors_mbuv(MACROBLOCKD *x)
void vp8_build_intra_predictors_mby(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);
vp8_build_intra_predictors_mby_internal(x, x->predictor, 16,
x->mode_info_context->mbmi.mode);
}
void vp8_build_intra_predictors_mby_s(MACROBLOCKD *x)
{
vp8_build_intra_predictors_mby_internal(x, x->dst.y_buffer, x->dst.y_stride,
x->mode_info_context->mbmi.mode);
}
}
break;
case V_PRED:
{
int i;
#if CONFIG_COMP_INTRA_PRED
void vp8_build_comp_intra_predictors_mby(MACROBLOCKD *x)
{
unsigned char predictor[2][256];
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;
}
vp8_build_intra_predictors_mby_internal(x, predictor[0], 16,
x->mode_info_context->mbmi.mode);
vp8_build_intra_predictors_mby_internal(x, predictor[1], 16,
x->mode_info_context->mbmi.second_mode);
}
break;
case H_PRED:
for (i = 0; i < 256; i++)
{
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;
}
}
break;
case B_PRED:
case NEARESTMV:
case NEARMV:
case ZEROMV:
case NEWMV:
case SPLITMV:
case MB_MODE_COUNT:
break;
x->predictor[i] = (predictor[0][i] + predictor[1][i] + 1) >> 1;
}
}
#endif
void vp8_build_intra_predictors_mbuv_s(MACROBLOCKD *x)
void vp8_build_intra_predictors_mbuv_internal(MACROBLOCKD *x,
unsigned char *upred_ptr,
unsigned char *vpred_ptr,
int uv_stride,
int mode)
{
unsigned char *uabove_row = x->dst.u_buffer - x->dst.uv_stride;
unsigned char uleft_col[16];
......@@ -415,9 +190,6 @@ void vp8_build_intra_predictors_mbuv_s(MACROBLOCKD *x)
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->dst.u_buffer; /*&x->predictor[256];*/
unsigned char *vpred_ptr = x->dst.v_buffer; /*&x->predictor[320];*/
int uv_stride = x->dst.uv_stride;
int i, j;
......@@ -427,7 +199,7 @@ void vp8_build_intra_predictors_mbuv_s(MACROBLOCKD *x)
vleft_col[i] = x->dst.v_buffer [i* x->dst.uv_stride -1];
}
switch (x->mode_info_context->mbmi.uv_mode)
switch (mode)
{
case DC_PRED:
{
......@@ -551,6 +323,43 @@ void vp8_build_intra_predictors_mbuv_s(MACROBLOCKD *x)
break;
}
}
void vp8_build_intra_predictors_mbuv(MACROBLOCKD *x)
{
vp8_build_intra_predictors_mbuv_internal(x,
&x->predictor[256],
&x->predictor[320],
8,
x->mode_info_context->mbmi.uv_mode);
}