Commit ff8b630c authored by Yaowu Xu's avatar Yaowu Xu Committed by On2 (Google) Code Review

Merge "Added Prediction Filter to Mode Selection" into experimental

parents cb231c88 bbc926dc
......@@ -231,6 +231,7 @@ EXPERIMENT_LIST="
int_8x8fdct
newintramodes
adaptive_entropy
pred_filter
"
CONFIG_LIST="
external_build
......
......@@ -214,6 +214,11 @@ typedef struct
// a valid predictor
unsigned char mb_in_image;
#if CONFIG_PRED_FILTER
// Flag to turn prediction signal filter on(1)/off(0 ) at the MB level
unsigned int pred_filter_enabled;
#endif
} MB_MODE_INFO;
typedef struct
......
......@@ -287,6 +287,15 @@ typedef struct VP8Common
#if CONFIG_POSTPROC
struct postproc_state postproc_state;
#endif
#if CONFIG_PRED_FILTER
/* Prediction filter variables */
int pred_filter_mode; // 0=disabled at the frame level (no MB filtered)
// 1=enabled at the frame level (all MB filtered)
// 2=specified per MB (1=filtered, 0=non-filtered)
vp8_prob prob_pred_filter_off;
#endif
} VP8_COMMON;
#endif
This diff is collapsed.
......@@ -527,8 +527,14 @@ static void mb_mode_mv_init(VP8D_COMP *pbi)
#endif
}
if(pbi->common.frame_type != KEY_FRAME)
if(cm->frame_type != KEY_FRAME)
{
#if CONFIG_PRED_FILTER
cm->pred_filter_mode = (vp8_prob)vp8_read_literal(bc, 2);
if (cm->pred_filter_mode == 2)
cm->prob_pred_filter_off = (vp8_prob)vp8_read_literal(bc, 8);
#endif
// Decode the baseline probabilities for decoding reference frame
cm->prob_intra_coded = (vp8_prob)vp8_read_literal(bc, 8);
cm->prob_last_coded = (vp8_prob)vp8_read_literal(bc, 8);
......@@ -728,6 +734,18 @@ static void read_mb_modes_mv(VP8D_COMP *pbi, MODE_INFO *mi, MB_MODE_INFO *mbmi,
vp8_accum_mv_refs(&pbi->common, mbmi->mode, rct);
}
#if CONFIG_PRED_FILTER
if (mbmi->mode >= NEARESTMV && mbmi->mode < SPLITMV)
{
// Is the prediction filter enabled
if (cm->pred_filter_mode == 2)
mbmi->pred_filter_enabled =
vp8_read(bc, cm->prob_pred_filter_off);
else
mbmi->pred_filter_enabled = cm->pred_filter_mode;
}
#endif
if ( cm->comp_pred_mode == COMP_PREDICTION_ONLY ||
(cm->comp_pred_mode == HYBRID_PREDICTION &&
vp8_read(bc, get_pred_prob( cm, xd, PRED_COMP ))) )
......
......@@ -815,6 +815,18 @@ static void pack_inter_mode_mvs(VP8_COMP *const cpi)
#endif
}
#if CONFIG_PRED_FILTER
// Write the prediction filter mode used for this frame
vp8_write_literal(w, pc->pred_filter_mode, 2);
// Write prediction filter on/off probability if signaling at MB level
if (pc->pred_filter_mode == 2)
vp8_write_literal(w, pc->prob_pred_filter_off, 8);
//printf("pred_filter_mode:%d prob_pred_filter_off:%d\n",
// pc->pred_filter_mode, pc->prob_pred_filter_off);
#endif
vp8_write_literal(w, pc->prob_intra_coded, 8);
vp8_write_literal(w, pc->prob_last_coded, 8);
vp8_write_literal(w, pc->prob_gf_coded, 8);
......@@ -1032,6 +1044,18 @@ static void pack_inter_mode_mvs(VP8_COMP *const cpi)
vp8_accum_mv_refs(&cpi->common, mode, ct);
}
#if CONFIG_PRED_FILTER
// Is the prediction filter enabled
if (mode >= NEARESTMV && mode < SPLITMV)
{
if (cpi->common.pred_filter_mode == 2 )
vp8_write(w, mi->pred_filter_enabled,
pc->prob_pred_filter_off);
else
assert (mi->pred_filter_enabled ==
cpi->common.pred_filter_mode);
}
#endif
if (mi->second_ref_frame &&
(mode == NEWMV || mode == SPLITMV))
{
......
......@@ -1201,6 +1201,19 @@ static void encode_frame_internal(VP8_COMP *cpi)
cpi->skip_false_count = 0;
#endif
#if CONFIG_PRED_FILTER
if (cm->current_video_frame == 0)
{
// Initially assume that we'll signal the prediction filter
// state at the frame level and that it is off.
cpi->common.pred_filter_mode = 0;
cpi->common.prob_pred_filter_off = 128;
}
cpi->pred_filter_on_count = 0;
cpi->pred_filter_off_count = 0;
#endif
#if 0
// Experimental code
cpi->frame_distortion = 0;
......
......@@ -1223,6 +1223,11 @@ void vp8_encode_inter16x16y(const VP8_ENCODER_RTCD *rtcd, MACROBLOCK *x)
BLOCK *b = &x->block[0];
#if CONFIG_PRED_FILTER
// Disable the prediction filter for firstpass
x->e_mbd.mode_info_context->mbmi.pred_filter_enabled = 0;
#endif
vp8_build_inter16x16_predictors_mby(&x->e_mbd);
ENCODEMB_INVOKE(&rtcd->encodemb, submby)(x->src_diff, *(b->base_src), x->e_mbd.predictor, b->src_stride);
......
......@@ -83,6 +83,17 @@ typedef struct
prototype_submbuv(*submbuv);
} vp8_encodemb_rtcd_vtable_t;
typedef struct
{
MB_PREDICTION_MODE mode;
MV_REFERENCE_FRAME ref_frame;
MV_REFERENCE_FRAME second_ref_frame;
#if CONFIG_PRED_FILTER
int pred_filter_flag;
#endif
} MODE_DEFINITION;
#if CONFIG_RUNTIME_CPU_DETECT
#define ENCODEMB_INVOKE(ctx,fn) (ctx)->fn
#else
......
......@@ -104,6 +104,11 @@ static unsigned int do_16x16_motion_iteration
&distortion, &sse);
}
#if CONFIG_PRED_FILTER
// Disable the prediction filter
xd->mode_info_context->mbmi.pred_filter_enabled = 0;
#endif
vp8_set_mbmode_and_mvs(x, NEWMV, dst_mv);
vp8_build_inter16x16_predictors_mby(xd);
//VARIANCE_INVOKE(&cpi->rtcd.variance, satd16x16)
......
This diff is collapsed.
......@@ -43,11 +43,19 @@
#define AF_THRESH2 100
#define ARF_DECAY_THRESH 12
#if CONFIG_PRED_FILTER
#if CONFIG_NEWINTRAMODES
#define MAX_MODES 54
#else
#define MAX_MODES 48
#endif
#else // CONFIG_PRED_FILTER
#if CONFIG_NEWINTRAMODES
#define MAX_MODES 42
#else
#define MAX_MODES 36
#endif
#endif // CONFIG_PRED_FILTER
#define MIN_THRESHMULT 32
#define MAX_THRESHMULT 512
......@@ -164,25 +172,100 @@ typedef struct
MBGRAPH_MB_STATS *mb_stats;
} MBGRAPH_FRAME_STATS;
#if CONFIG_PRED_FILTER
typedef enum
{
THR_ZEROMV,
THR_ZEROMV_FILT,
THR_DC,
THR_NEARESTMV,
THR_NEARESTMV_FILT,
THR_NEARMV,
THR_NEARMV_FILT,
THR_ZEROG,
THR_ZEROG_FILT,
THR_NEARESTG,
THR_NEARESTG_FILT,
THR_ZEROA,
THR_ZEROA_FILT,
THR_NEARESTA,
THR_NEARESTA_FILT,
THR_NEARG,
THR_NEARG_FILT,
THR_NEARA,
THR_NEARA_FILT,
THR_V_PRED,
THR_H_PRED,
#if CONFIG_NEWINTRAMODES
THR_D45_PRED,
THR_D135_PRED,
THR_D117_PRED,
THR_D153_PRED,
THR_D27_PRED,
THR_D63_PRED,
#endif
THR_TM,
THR_NEWMV,
THR_NEWMV_FILT,
THR_NEWG,
THR_NEWG_FILT,
THR_NEWA,
THR_NEWA_FILT,
THR_SPLITMV,
THR_SPLITG,
THR_SPLITA,
THR_B_PRED,
THR_I8X8_PRED,
THR_COMP_ZEROLG,
THR_COMP_NEARESTLG,
THR_COMP_NEARLG,
THR_COMP_ZEROLA,
THR_COMP_NEARESTLA,
THR_COMP_NEARLA,
THR_COMP_ZEROGA,
THR_COMP_NEARESTGA,
THR_COMP_NEARGA,
THR_COMP_NEWLG,
THR_COMP_NEWLA,
THR_COMP_NEWGA,
THR_COMP_SPLITLG,
THR_COMP_SPLITLA,
THR_COMP_SPLITGA,
}
THR_MODES;
#else
typedef enum
{
THR_ZEROMV = 0,
THR_DC = 1,
THR_ZEROMV,
THR_DC,
THR_NEARESTMV = 2,
THR_NEARMV = 3,
THR_NEARESTMV,
THR_NEARMV,
THR_ZEROG = 4,
THR_NEARESTG = 5,
THR_ZEROG,
THR_NEARESTG,
THR_ZEROA = 6,
THR_NEARESTA = 7,
THR_ZEROA,
THR_NEARESTA,
THR_NEARG = 8,
THR_NEARA = 9,
THR_NEARG,
THR_NEARA,
THR_V_PRED = 10,
THR_H_PRED = 11,
THR_V_PRED,
THR_H_PRED,
#if CONFIG_NEWINTRAMODES
THR_D45_PRED,
THR_D135_PRED,
......@@ -222,9 +305,10 @@ typedef enum
THR_COMP_SPLITLG,
THR_COMP_SPLITLA,
THR_COMP_SPLITGA,
THR_COMP_SPLITGA
}
THR_MODES;
#endif
typedef enum
{
......@@ -679,6 +763,11 @@ typedef struct VP8_COMP
int dummy_packing; /* flag to indicate if packing is dummy */
#if CONFIG_PRED_FILTER
int pred_filter_on_count;
int pred_filter_off_count;
#endif
} VP8_COMP;
void control_data_rate(VP8_COMP *cpi);
......
......@@ -27,9 +27,7 @@
#define MIN_BPB_FACTOR 0.005
#define MAX_BPB_FACTOR 50
extern const MB_PREDICTION_MODE vp8_mode_order[MAX_MODES];
extern const MV_REFERENCE_FRAME vp8_ref_frame_order[MAX_MODES];
extern const MODE_DEFINITION vp8_mode_order[MAX_MODES];
#ifdef MODE_STATS
......
This diff is collapsed.
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