Commit 0b713f8c authored by Paul Wilkins's avatar Paul Wilkins

Merge CONFIG_COMP_INTER_JOINT_SEARCH.

Merge this experiment so that it is under a speed feature
flag not a configuration flag.

Change-Id: I536f7f125a4ff5149bb3a64f791e835c324535fd
parent ddf13be8
...@@ -247,7 +247,6 @@ EXPERIMENT_LIST=" ...@@ -247,7 +247,6 @@ EXPERIMENT_LIST="
non420 non420
alpha alpha
ab4x4 ab4x4
comp_inter_joint_search
" "
CONFIG_LIST=" CONFIG_LIST="
external_build external_build
......
...@@ -414,7 +414,6 @@ int vp9_find_best_sub_pixel_step_iteratively(MACROBLOCK *x, ...@@ -414,7 +414,6 @@ int vp9_find_best_sub_pixel_step_iteratively(MACROBLOCK *x,
return besterr; return besterr;
} }
#if CONFIG_COMP_INTER_JOINT_SEARCH
#undef DIST #undef DIST
/* returns subpixel variance error function */ /* returns subpixel variance error function */
#define DIST(r, c) \ #define DIST(r, c) \
...@@ -606,7 +605,7 @@ int vp9_find_best_sub_pixel_comp(MACROBLOCK *x, ...@@ -606,7 +605,7 @@ int vp9_find_best_sub_pixel_comp(MACROBLOCK *x,
return besterr; return besterr;
} }
#endif // CONFIG_COMP_INTER_JOINT_SEARCH
#undef MVC #undef MVC
#undef PRE #undef PRE
...@@ -2327,7 +2326,6 @@ int vp9_refining_search_sadx4(MACROBLOCK *x, ...@@ -2327,7 +2326,6 @@ int vp9_refining_search_sadx4(MACROBLOCK *x,
return INT_MAX; return INT_MAX;
} }
#if CONFIG_COMP_INTER_JOINT_SEARCH
/* This function is called when we do joint motion search in comp_inter_inter /* This function is called when we do joint motion search in comp_inter_inter
* mode. * mode.
*/ */
...@@ -2429,4 +2427,3 @@ int vp9_refining_search_8p_c(MACROBLOCK *x, ...@@ -2429,4 +2427,3 @@ int vp9_refining_search_8p_c(MACROBLOCK *x,
return INT_MAX; return INT_MAX;
} }
} }
#endif // CONFIG_COMP_INTER_JOINT_SEARCH
...@@ -75,7 +75,6 @@ typedef int (*vp9_diamond_search_fn_t)(MACROBLOCK *x, ...@@ -75,7 +75,6 @@ typedef int (*vp9_diamond_search_fn_t)(MACROBLOCK *x,
int *mvjcost, int *mvcost[2], int *mvjcost, int *mvcost[2],
int_mv *center_mv); int_mv *center_mv);
#if CONFIG_COMP_INTER_JOINT_SEARCH
int vp9_find_best_sub_pixel_comp(MACROBLOCK *x, int vp9_find_best_sub_pixel_comp(MACROBLOCK *x,
int_mv *bestmv, int_mv *ref_mv, int_mv *bestmv, int_mv *ref_mv,
int error_per_bit, int error_per_bit,
...@@ -91,5 +90,4 @@ int vp9_refining_search_8p_c(MACROBLOCK *x, ...@@ -91,5 +90,4 @@ int vp9_refining_search_8p_c(MACROBLOCK *x,
int *mvjcost, int *mvcost[2], int *mvjcost, int *mvcost[2],
int_mv *center_mv, const uint8_t *second_pred, int_mv *center_mv, const uint8_t *second_pred,
int w, int h); int w, int h);
#endif // CONFIG_COMP_INTER_JOINT_SEARCH
#endif // VP9_ENCODER_VP9_MCOMP_H_ #endif // VP9_ENCODER_VP9_MCOMP_H_
...@@ -778,6 +778,7 @@ void vp9_set_speed_features(VP9_COMP *cpi) { ...@@ -778,6 +778,7 @@ void vp9_set_speed_features(VP9_COMP *cpi) {
sf->optimize_coefficients = !cpi->oxcf.lossless; sf->optimize_coefficients = !cpi->oxcf.lossless;
sf->first_step = 0; sf->first_step = 0;
sf->max_step_search_steps = MAX_MVSEARCH_STEPS; sf->max_step_search_steps = MAX_MVSEARCH_STEPS;
sf->comp_inter_joint_serach = 1;
#if CONFIG_MULTIPLE_ARF #if CONFIG_MULTIPLE_ARF
// Switch segmentation off. // Switch segmentation off.
sf->static_segmentation = 0; sf->static_segmentation = 0;
...@@ -788,7 +789,6 @@ void vp9_set_speed_features(VP9_COMP *cpi) { ...@@ -788,7 +789,6 @@ void vp9_set_speed_features(VP9_COMP *cpi) {
sf->static_segmentation = 0; sf->static_segmentation = 0;
#endif #endif
#endif #endif
sf->splitmode_breakout = 0;
sf->mb16_breakout = 0; sf->mb16_breakout = 0;
switch (mode) { switch (mode) {
...@@ -807,13 +807,13 @@ void vp9_set_speed_features(VP9_COMP *cpi) { ...@@ -807,13 +807,13 @@ void vp9_set_speed_features(VP9_COMP *cpi) {
sf->static_segmentation = 0; sf->static_segmentation = 0;
#endif #endif
#endif #endif
sf->splitmode_breakout = 1;
sf->mb16_breakout = 0; sf->mb16_breakout = 0;
if (speed > 0) { if (speed > 0) {
/* Disable coefficient optimization above speed 0 */ /* Disable coefficient optimization above speed 0 */
sf->optimize_coefficients = 0; sf->optimize_coefficients = 0;
sf->no_skip_block4x4_search = 0; sf->no_skip_block4x4_search = 0;
sf->comp_inter_joint_serach = 0;
sf->first_step = 1; sf->first_step = 1;
......
...@@ -224,9 +224,9 @@ typedef struct { ...@@ -224,9 +224,9 @@ typedef struct {
int optimize_coefficients; int optimize_coefficients;
int no_skip_block4x4_search; int no_skip_block4x4_search;
int search_best_filter; int search_best_filter;
int splitmode_breakout;
int mb16_breakout; int mb16_breakout;
int static_segmentation; int static_segmentation;
int comp_inter_joint_serach;
} SPEED_FEATURES; } SPEED_FEATURES;
enum BlockSize { enum BlockSize {
......
...@@ -2083,157 +2083,160 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x, ...@@ -2083,157 +2083,160 @@ static int64_t handle_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
ref_mv[1] = mbmi->ref_mvs[refs[1]][0]; ref_mv[1] = mbmi->ref_mvs[refs[1]][0];
if (is_comp_pred) { if (is_comp_pred) {
#if CONFIG_COMP_INTER_JOINT_SEARCH if (cpi->sf.comp_inter_joint_serach) {
const int b_sz[BLOCK_SIZE_TYPES][2] = { const int b_sz[BLOCK_SIZE_TYPES][2] = {
{4, 4}, {4, 4},
{8, 8}, {8, 8},
{8, 16}, {8, 16},
{16, 8}, {16, 8},
{16, 16}, {16, 16},
{16, 32}, {16, 32},
{32, 16}, {32, 16},
{32, 32}, {32, 32},
{32, 64}, {32, 64},
{64, 32}, {64, 32},
{64, 64} {64, 64}
}; };
int ite; int ite;
// Prediction buffer from second frame. // Prediction buffer from second frame.
uint8_t *second_pred = vpx_memalign(16, b_sz[bsize][0] * uint8_t *second_pred = vpx_memalign(16, b_sz[bsize][0] *
b_sz[bsize][1] * sizeof(uint8_t)); b_sz[bsize][1] * sizeof(uint8_t));
// Do joint motion search in compound mode to get more accurate mv. // Do joint motion search in compound mode to get more accurate mv.
struct buf_2d backup_yv12[MAX_MB_PLANE] = {{0}}; struct buf_2d backup_yv12[MAX_MB_PLANE] = {{0}};
struct buf_2d backup_second_yv12[MAX_MB_PLANE] = {{0}}; struct buf_2d backup_second_yv12[MAX_MB_PLANE] = {{0}};
struct buf_2d scaled_first_yv12; struct buf_2d scaled_first_yv12;
int last_besterr[2] = {INT_MAX, INT_MAX}; int last_besterr[2] = {INT_MAX, INT_MAX};
if (scaled_ref_frame[0]) { if (scaled_ref_frame[0]) {
int i; int i;
// Swap out the reference frame for a version that's been scaled to // Swap out the reference frame for a version that's been scaled to
// match the resolution of the current frame, allowing the existing // match the resolution of the current frame, allowing the existing
// motion search code to be used without additional modifications. // motion search code to be used without additional modifications.
for (i = 0; i < MAX_MB_PLANE; i++) for (i = 0; i < MAX_MB_PLANE; i++)
backup_yv12[i] = xd->plane[i].pre[0]; backup_yv12[i] = xd->plane[i].pre[0];
setup_pre_planes(xd, scaled_ref_frame[0], NULL, mi_row, mi_col, setup_pre_planes(xd, scaled_ref_frame[0], NULL, mi_row, mi_col,
NULL, NULL); NULL, NULL);
} }
if (scaled_ref_frame[1]) {
int i;
for (i = 0; i < MAX_MB_PLANE; i++)
backup_second_yv12[i] = xd->plane[i].pre[1];
setup_pre_planes(xd, scaled_ref_frame[1], NULL, mi_row, mi_col,
NULL, NULL);
}
xd->scale_factor[0].set_scaled_offsets(&xd->scale_factor[0],
mi_row, mi_col);
xd->scale_factor[1].set_scaled_offsets(&xd->scale_factor[1],
mi_row, mi_col);
scaled_first_yv12 = xd->plane[0].pre[0];
// Initialize mv using single prediction mode result.
frame_mv[NEWMV][refs[0]].as_int = single_newmv[refs[0]].as_int;
frame_mv[NEWMV][refs[1]].as_int = single_newmv[refs[1]].as_int;
// Allow joint search multiple times iteratively for each ref frame, and
// break out the search loop if it couldn't find better mv.
for (ite = 0; ite < 4; ite++) {
struct buf_2d ref_yv12[2] = {xd->plane[0].pre[0],
xd->plane[0].pre[1]};
int bestsme = INT_MAX;
int sadpb = x->sadperbit16;
int_mv tmp_mv;
int search_range = 3;
int tmp_col_min = x->mv_col_min;
int tmp_col_max = x->mv_col_max;
int tmp_row_min = x->mv_row_min;
int tmp_row_max = x->mv_row_max;
int id = ite % 2;
// Get pred block from second frame.
vp9_build_inter_predictor(ref_yv12[!id].buf,
ref_yv12[!id].stride,
second_pred, b_sz[bsize][0],
&frame_mv[NEWMV][refs[!id]],
&xd->scale_factor[!id],
b_sz[bsize][0], b_sz[bsize][1], 0,
&xd->subpix);
// Compound motion search on first ref frame.
if (id)
xd->plane[0].pre[0] = ref_yv12[id];
vp9_clamp_mv_min_max(x, &ref_mv[id]);
// Use mv result from single mode as mvp.
tmp_mv.as_int = frame_mv[NEWMV][refs[id]].as_int;
tmp_mv.as_mv.col >>= 3;
tmp_mv.as_mv.row >>= 3;
// Small-range full-pixel motion search
bestsme = vp9_refining_search_8p_c(x, &tmp_mv, sadpb,
search_range,
&cpi->fn_ptr[block_size],
x->nmvjointcost, x->mvcost,
&ref_mv[id], second_pred,
b_sz[bsize][0], b_sz[bsize][1]);
x->mv_col_min = tmp_col_min; if (scaled_ref_frame[1]) {
x->mv_col_max = tmp_col_max; int i;
x->mv_row_min = tmp_row_min;
x->mv_row_max = tmp_row_max;
if (bestsme < INT_MAX) { for (i = 0; i < MAX_MB_PLANE; i++)
int dis; /* TODO: use dis in distortion calculation later. */ backup_second_yv12[i] = xd->plane[i].pre[1];
unsigned int sse;
bestsme = vp9_find_best_sub_pixel_comp(x, &tmp_mv, setup_pre_planes(xd, scaled_ref_frame[1], NULL, mi_row, mi_col,
&ref_mv[id], NULL, NULL);
x->errorperbit,
&cpi->fn_ptr[block_size],
x->nmvjointcost, x->mvcost,
&dis, &sse, second_pred,
b_sz[bsize][0],
b_sz[bsize][1]);
} }
xd->scale_factor[0].set_scaled_offsets(&xd->scale_factor[0],
mi_row, mi_col);
xd->scale_factor[1].set_scaled_offsets(&xd->scale_factor[1],
mi_row, mi_col);
scaled_first_yv12 = xd->plane[0].pre[0];
// Initialize mv using single prediction mode result.
frame_mv[NEWMV][refs[0]].as_int = single_newmv[refs[0]].as_int;
frame_mv[NEWMV][refs[1]].as_int = single_newmv[refs[1]].as_int;
// Allow joint search multiple times iteratively for each ref frame
// and break out the search loop if it couldn't find better mv.
for (ite = 0; ite < 4; ite++) {
struct buf_2d ref_yv12[2];
int bestsme = INT_MAX;
int sadpb = x->sadperbit16;
int_mv tmp_mv;
int search_range = 3;
int tmp_col_min = x->mv_col_min;
int tmp_col_max = x->mv_col_max;
int tmp_row_min = x->mv_row_min;
int tmp_row_max = x->mv_row_max;
int id = ite % 2;
// Initialized here because of compiler problem in Visual Studio.
ref_yv12[0] = xd->plane[0].pre[0];
ref_yv12[1] = xd->plane[0].pre[1];
// Get pred block from second frame.
vp9_build_inter_predictor(ref_yv12[!id].buf,
ref_yv12[!id].stride,
second_pred, b_sz[bsize][0],
&frame_mv[NEWMV][refs[!id]],
&xd->scale_factor[!id],
b_sz[bsize][0], b_sz[bsize][1], 0,
&xd->subpix);
// Compound motion search on first ref frame.
if (id)
xd->plane[0].pre[0] = ref_yv12[id];
vp9_clamp_mv_min_max(x, &ref_mv[id]);
// Use mv result from single mode as mvp.
tmp_mv.as_int = frame_mv[NEWMV][refs[id]].as_int;
tmp_mv.as_mv.col >>= 3;
tmp_mv.as_mv.row >>= 3;
// Small-range full-pixel motion search
bestsme = vp9_refining_search_8p_c(x, &tmp_mv, sadpb,
search_range,
&cpi->fn_ptr[block_size],
x->nmvjointcost, x->mvcost,
&ref_mv[id], second_pred,
b_sz[bsize][0], b_sz[bsize][1]);
x->mv_col_min = tmp_col_min;
x->mv_col_max = tmp_col_max;
x->mv_row_min = tmp_row_min;
x->mv_row_max = tmp_row_max;
if (bestsme < INT_MAX) {
int dis; /* TODO: use dis in distortion calculation later. */
unsigned int sse;
bestsme = vp9_find_best_sub_pixel_comp(x, &tmp_mv,
&ref_mv[id],
x->errorperbit,
&cpi->fn_ptr[block_size],
x->nmvjointcost, x->mvcost,
&dis, &sse, second_pred,
b_sz[bsize][0],
b_sz[bsize][1]);
}
if (id) if (id)
xd->plane[0].pre[0] = scaled_first_yv12; xd->plane[0].pre[0] = scaled_first_yv12;
if (bestsme < last_besterr[id]) { if (bestsme < last_besterr[id]) {
frame_mv[NEWMV][refs[id]].as_int = frame_mv[NEWMV][refs[id]].as_int =
xd->mode_info_context->bmi[0].as_mv[1].as_int = tmp_mv.as_int; xd->mode_info_context->bmi[0].as_mv[1].as_int = tmp_mv.as_int;
last_besterr[id] = bestsme; last_besterr[id] = bestsme;
} else { } else {
break; break;
}
} }
}
// restore the predictor // restore the predictor
if (scaled_ref_frame[0]) { if (scaled_ref_frame[0]) {
int i; int i;
for (i = 0; i < MAX_MB_PLANE; i++) for (i = 0; i < MAX_MB_PLANE; i++)
xd->plane[i].pre[0] = backup_yv12[i]; xd->plane[i].pre[0] = backup_yv12[i];
} }
if (scaled_ref_frame[1]) { if (scaled_ref_frame[1]) {
int i; int i;
for (i = 0; i < MAX_MB_PLANE; i++) for (i = 0; i < MAX_MB_PLANE; i++)
xd->plane[i].pre[1] = backup_second_yv12[i]; xd->plane[i].pre[1] = backup_second_yv12[i];
} }
vpx_free(second_pred); vpx_free(second_pred);
#endif // CONFIG_COMP_INTER_JOINT_SEARCH }
if (frame_mv[NEWMV][refs[0]].as_int == INVALID_MV || if (frame_mv[NEWMV][refs[0]].as_int == INVALID_MV ||
frame_mv[NEWMV][refs[1]].as_int == INVALID_MV) frame_mv[NEWMV][refs[1]].as_int == INVALID_MV)
......
...@@ -86,7 +86,6 @@ typedef struct vp9_variance_vtable { ...@@ -86,7 +86,6 @@ typedef struct vp9_variance_vtable {
vp9_sad_multi_d_fn_t sdx4df; vp9_sad_multi_d_fn_t sdx4df;
} vp9_variance_fn_ptr_t; } vp9_variance_fn_ptr_t;
// #if CONFIG_COMP_INTER_JOINT_SEARCH
static void comp_avg_pred(uint8_t *comp_pred, const uint8_t *pred, int weight, static void comp_avg_pred(uint8_t *comp_pred, const uint8_t *pred, int weight,
int height, uint8_t *ref, int ref_stride) { int height, uint8_t *ref, int ref_stride) {
int i, j; int i, j;
...@@ -102,5 +101,4 @@ static void comp_avg_pred(uint8_t *comp_pred, const uint8_t *pred, int weight, ...@@ -102,5 +101,4 @@ static void comp_avg_pred(uint8_t *comp_pred, const uint8_t *pred, int weight,
ref += ref_stride; ref += ref_stride;
} }
} }
// #endif // CONFIG_COMP_INTER_JOINT_SEARCH
#endif // VP9_ENCODER_VP9_VARIANCE_H_ #endif // VP9_ENCODER_VP9_VARIANCE_H_
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