Merge "Fix integral projection motion search for frame resize"

This commit is contained in:
Jingning Han 2015-05-26 16:08:31 +00:00 committed by Gerrit Code Review
commit 55ef1ae9e7
4 changed files with 41 additions and 8 deletions

View File

@ -724,7 +724,7 @@ static int choose_partitioning(VP9_COMP *cpi,
mbmi->mv[0].as_int = 0;
mbmi->interp_filter = BILINEAR;
y_sad = vp9_int_pro_motion_estimation(cpi, x, bsize);
y_sad = vp9_int_pro_motion_estimation(cpi, x, bsize, mi_row, mi_col);
if (y_sad_g < y_sad) {
vp9_setup_pre_planes(xd, 0, yv12_g, mi_row, mi_col,
&cm->frame_refs[GOLDEN_FRAME - 1].sf);

View File

@ -18,6 +18,7 @@
#include "vpx_ports/mem.h"
#include "vp9/common/vp9_common.h"
#include "vp9/common/vp9_reconinter.h"
#include "vp9/encoder/vp9_encoder.h"
#include "vp9/encoder/vp9_mcomp.h"
@ -1789,8 +1790,11 @@ static const MV search_pos[4] = {
};
unsigned int vp9_int_pro_motion_estimation(const VP9_COMP *cpi, MACROBLOCK *x,
BLOCK_SIZE bsize) {
BLOCK_SIZE bsize,
int mi_row, int mi_col) {
MACROBLOCKD *xd = &x->e_mbd;
MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
struct buf_2d backup_yv12[MAX_MB_PLANE] = {{0, 0}};
DECLARE_ALIGNED(16, int16_t, hbuf[128]);
DECLARE_ALIGNED(16, int16_t, vbuf[128]);
DECLARE_ALIGNED(16, int16_t, src_hbuf[64]);
@ -1807,12 +1811,34 @@ unsigned int vp9_int_pro_motion_estimation(const VP9_COMP *cpi, MACROBLOCK *x,
unsigned int best_sad, tmp_sad, this_sad[4];
MV this_mv;
const int norm_factor = 3 + (bw >> 5);
const YV12_BUFFER_CONFIG *scaled_ref_frame =
vp9_get_scaled_ref_frame(cpi, mbmi->ref_frame[0]);
if (scaled_ref_frame) {
int i;
// Swap out the reference frame for a version that's been scaled to
// match the resolution of the current frame, allowing the existing
// motion search code to be used without additional modifications.
for (i = 0; i < MAX_MB_PLANE; i++)
backup_yv12[i] = xd->plane[i].pre[0];
vp9_setup_pre_planes(xd, 0, scaled_ref_frame, mi_row, mi_col, NULL);
}
#if CONFIG_VP9_HIGHBITDEPTH
tmp_mv->row = 0;
tmp_mv->col = 0;
return cpi->fn_ptr[bsize].sdf(x->plane[0].src.buf, src_stride,
xd->plane[0].pre[0].buf, ref_stride);
{
unsigned int this_sad;
tmp_mv->row = 0;
tmp_mv->col = 0;
this_sad = cpi->fn_ptr[bsize].sdf(x->plane[0].src.buf, src_stride,
xd->plane[0].pre[0].buf, ref_stride);
if (scaled_ref_frame) {
int i;
for (i = 0; i < MAX_MB_PLANE; i++)
xd->plane[i].pre[0] = backup_yv12[i];
}
return this_sad;
}
#endif
// Set up prediction 1-D reference set
@ -1890,6 +1916,12 @@ unsigned int vp9_int_pro_motion_estimation(const VP9_COMP *cpi, MACROBLOCK *x,
tmp_mv->row *= 8;
tmp_mv->col *= 8;
if (scaled_ref_frame) {
int i;
for (i = 0; i < MAX_MB_PLANE; i++)
xd->plane[i].pre[0] = backup_yv12[i];
}
return best_sad;
}

View File

@ -83,7 +83,8 @@ int vp9_full_pixel_diamond(const struct VP9_COMP *cpi, MACROBLOCK *x,
// Perform integral projection based motion estimation.
unsigned int vp9_int_pro_motion_estimation(const struct VP9_COMP *cpi,
MACROBLOCK *x,
BLOCK_SIZE bsize);
BLOCK_SIZE bsize,
int mi_row, int mi_col);
typedef int (integer_mv_pattern_search_fn) (
const MACROBLOCK *x,

View File

@ -1248,7 +1248,7 @@ void vp9_pick_inter_mode(VP9_COMP *cpi, MACROBLOCK *x,
if (bsize < BLOCK_16X16)
continue;
tmp_sad = vp9_int_pro_motion_estimation(cpi, x, bsize);
tmp_sad = vp9_int_pro_motion_estimation(cpi, x, bsize, mi_row, mi_col);
if (tmp_sad > x->pred_mv_sad[LAST_FRAME])
continue;