Commit 372e12b9 authored by Yue Chen's avatar Yue Chen Committed by Gerrit Code Review
Browse files

Merge "Add single motion search for OBMC predictor" into nextgenv2

parents 0778f05c 370f203a
......@@ -487,6 +487,7 @@ static INLINE int vp10_is_interp_needed(const MACROBLOCKD *const xd) {
#endif // CONFIG_EXT_INTERP
#if CONFIG_OBMC
void setup_obmc_mask(int length, const uint8_t *mask[2]);
void vp10_build_obmc_inter_prediction(VP10_COMMON *cm,
MACROBLOCKD *xd, int mi_row, int mi_col,
int use_tmp_dst_buf,
......
......@@ -1219,6 +1219,49 @@ MAKE_MBFP_SAD_WRAPPER(vpx_highbd_masked_sad4x8)
MAKE_MBFP_SAD_WRAPPER(vpx_highbd_masked_sad4x4)
#endif // CONFIG_EXT_INTER
#if CONFIG_OBMC
#define HIGHBD_OBFP(BT, OSDF, OVF, OSVF) \
cpi->fn_ptr[BT].osdf = OSDF; \
cpi->fn_ptr[BT].ovf = OVF; \
cpi->fn_ptr[BT].osvf = OSVF;
#define MAKE_OBFP_SAD_WRAPPER(fnname) \
static unsigned int fnname##_bits8(const uint8_t *ref, int ref_stride, \
const int *wsrc, int wsrc_stride, \
const int *msk, int msk_stride) { \
return fnname(ref, ref_stride, wsrc, wsrc_stride, msk, msk_stride); \
} \
static unsigned int fnname##_bits10(const uint8_t *ref, int ref_stride, \
const int *wsrc, int wsrc_stride, \
const int *msk, int msk_stride) { \
return fnname(ref, ref_stride, wsrc, wsrc_stride, msk, msk_stride) >> 2; \
} \
static unsigned int fnname##_bits12(const uint8_t *ref, int ref_stride, \
const int *wsrc, int wsrc_stride, \
const int *msk, int msk_stride) { \
return fnname(ref, ref_stride, wsrc, wsrc_stride, msk, msk_stride) >> 4; \
}
#if CONFIG_EXT_PARTITION
MAKE_OBFP_SAD_WRAPPER(vpx_highbd_obmc_sad128x128)
MAKE_OBFP_SAD_WRAPPER(vpx_highbd_obmc_sad128x64)
MAKE_OBFP_SAD_WRAPPER(vpx_highbd_obmc_sad64x128)
#endif // CONFIG_EXT_PARTITION
MAKE_OBFP_SAD_WRAPPER(vpx_highbd_obmc_sad64x64)
MAKE_OBFP_SAD_WRAPPER(vpx_highbd_obmc_sad64x32)
MAKE_OBFP_SAD_WRAPPER(vpx_highbd_obmc_sad32x64)
MAKE_OBFP_SAD_WRAPPER(vpx_highbd_obmc_sad32x32)
MAKE_OBFP_SAD_WRAPPER(vpx_highbd_obmc_sad32x16)
MAKE_OBFP_SAD_WRAPPER(vpx_highbd_obmc_sad16x32)
MAKE_OBFP_SAD_WRAPPER(vpx_highbd_obmc_sad16x16)
MAKE_OBFP_SAD_WRAPPER(vpx_highbd_obmc_sad16x8)
MAKE_OBFP_SAD_WRAPPER(vpx_highbd_obmc_sad8x16)
MAKE_OBFP_SAD_WRAPPER(vpx_highbd_obmc_sad8x8)
MAKE_OBFP_SAD_WRAPPER(vpx_highbd_obmc_sad8x4)
MAKE_OBFP_SAD_WRAPPER(vpx_highbd_obmc_sad4x8)
MAKE_OBFP_SAD_WRAPPER(vpx_highbd_obmc_sad4x4)
#endif // CONFIG_OBMC
static void highbd_set_var_fns(VP10_COMP *const cpi) {
VP10_COMMON *const cm = &cpi->common;
if (cm->use_highbitdepth) {
......@@ -1454,6 +1497,74 @@ static void highbd_set_var_fns(VP10_COMP *const cpi) {
vpx_highbd_masked_variance4x4,
vpx_highbd_masked_sub_pixel_variance4x4)
#endif // CONFIG_EXT_INTER
#if CONFIG_OBMC
#if CONFIG_EXT_PARTITION
HIGHBD_OBFP(BLOCK_128X128,
vpx_highbd_obmc_sad128x128_bits8,
vpx_highbd_obmc_variance128x128,
vpx_highbd_obmc_sub_pixel_variance128x128)
HIGHBD_OBFP(BLOCK_128X64,
vpx_highbd_obmc_sad128x64_bits8,
vpx_highbd_obmc_variance128x64,
vpx_highbd_obmc_sub_pixel_variance128x64)
HIGHBD_OBFP(BLOCK_64X128,
vpx_highbd_obmc_sad64x128_bits8,
vpx_highbd_obmc_variance64x128,
vpx_highbd_obmc_sub_pixel_variance64x128)
#endif // CONFIG_EXT_PARTITION
HIGHBD_OBFP(BLOCK_64X64,
vpx_highbd_obmc_sad64x64_bits8,
vpx_highbd_obmc_variance64x64,
vpx_highbd_obmc_sub_pixel_variance64x64)
HIGHBD_OBFP(BLOCK_64X32,
vpx_highbd_obmc_sad64x32_bits8,
vpx_highbd_obmc_variance64x32,
vpx_highbd_obmc_sub_pixel_variance64x32)
HIGHBD_OBFP(BLOCK_32X64,
vpx_highbd_obmc_sad32x64_bits8,
vpx_highbd_obmc_variance32x64,
vpx_highbd_obmc_sub_pixel_variance32x64)
HIGHBD_OBFP(BLOCK_32X32,
vpx_highbd_obmc_sad32x32_bits8,
vpx_highbd_obmc_variance32x32,
vpx_highbd_obmc_sub_pixel_variance32x32)
HIGHBD_OBFP(BLOCK_32X16,
vpx_highbd_obmc_sad32x16_bits8,
vpx_highbd_obmc_variance32x16,
vpx_highbd_obmc_sub_pixel_variance32x16)
HIGHBD_OBFP(BLOCK_16X32,
vpx_highbd_obmc_sad16x32_bits8,
vpx_highbd_obmc_variance16x32,
vpx_highbd_obmc_sub_pixel_variance16x32)
HIGHBD_OBFP(BLOCK_16X16,
vpx_highbd_obmc_sad16x16_bits8,
vpx_highbd_obmc_variance16x16,
vpx_highbd_obmc_sub_pixel_variance16x16)
HIGHBD_OBFP(BLOCK_8X16,
vpx_highbd_obmc_sad8x16_bits8,
vpx_highbd_obmc_variance8x16,
vpx_highbd_obmc_sub_pixel_variance8x16)
HIGHBD_OBFP(BLOCK_16X8,
vpx_highbd_obmc_sad16x8_bits8,
vpx_highbd_obmc_variance16x8,
vpx_highbd_obmc_sub_pixel_variance16x8)
HIGHBD_OBFP(BLOCK_8X8,
vpx_highbd_obmc_sad8x8_bits8,
vpx_highbd_obmc_variance8x8,
vpx_highbd_obmc_sub_pixel_variance8x8)
HIGHBD_OBFP(BLOCK_4X8,
vpx_highbd_obmc_sad4x8_bits8,
vpx_highbd_obmc_variance4x8,
vpx_highbd_obmc_sub_pixel_variance4x8)
HIGHBD_OBFP(BLOCK_8X4,
vpx_highbd_obmc_sad8x4_bits8,
vpx_highbd_obmc_variance8x4,
vpx_highbd_obmc_sub_pixel_variance8x4)
HIGHBD_OBFP(BLOCK_4X4,
vpx_highbd_obmc_sad4x4_bits8,
vpx_highbd_obmc_variance4x4,
vpx_highbd_obmc_sub_pixel_variance4x4)
#endif // CONFIG_OBMC
break;
case VPX_BITS_10:
......@@ -1687,6 +1798,74 @@ static void highbd_set_var_fns(VP10_COMP *const cpi) {
vpx_highbd_10_masked_variance4x4,
vpx_highbd_10_masked_sub_pixel_variance4x4)
#endif // CONFIG_EXT_INTER
#if CONFIG_OBMC
#if CONFIG_EXT_PARTITION
HIGHBD_OBFP(BLOCK_128X128,
vpx_highbd_obmc_sad128x128_bits10,
vpx_highbd_10_obmc_variance128x128,
vpx_highbd_10_obmc_sub_pixel_variance128x128)
HIGHBD_OBFP(BLOCK_128X64,
vpx_highbd_obmc_sad128x64_bits10,
vpx_highbd_10_obmc_variance128x64,
vpx_highbd_10_obmc_sub_pixel_variance128x64)
HIGHBD_OBFP(BLOCK_64X128,
vpx_highbd_obmc_sad64x128_bits10,
vpx_highbd_10_obmc_variance64x128,
vpx_highbd_10_obmc_sub_pixel_variance64x128)
#endif // CONFIG_EXT_PARTITION
HIGHBD_OBFP(BLOCK_64X64,
vpx_highbd_obmc_sad64x64_bits10,
vpx_highbd_10_obmc_variance64x64,
vpx_highbd_10_obmc_sub_pixel_variance64x64)
HIGHBD_OBFP(BLOCK_64X32,
vpx_highbd_obmc_sad64x32_bits10,
vpx_highbd_10_obmc_variance64x32,
vpx_highbd_10_obmc_sub_pixel_variance64x32)
HIGHBD_OBFP(BLOCK_32X64,
vpx_highbd_obmc_sad32x64_bits10,
vpx_highbd_10_obmc_variance32x64,
vpx_highbd_10_obmc_sub_pixel_variance32x64)
HIGHBD_OBFP(BLOCK_32X32,
vpx_highbd_obmc_sad32x32_bits10,
vpx_highbd_10_obmc_variance32x32,
vpx_highbd_10_obmc_sub_pixel_variance32x32)
HIGHBD_OBFP(BLOCK_32X16,
vpx_highbd_obmc_sad32x16_bits10,
vpx_highbd_10_obmc_variance32x16,
vpx_highbd_10_obmc_sub_pixel_variance32x16)
HIGHBD_OBFP(BLOCK_16X32,
vpx_highbd_obmc_sad16x32_bits10,
vpx_highbd_10_obmc_variance16x32,
vpx_highbd_10_obmc_sub_pixel_variance16x32)
HIGHBD_OBFP(BLOCK_16X16,
vpx_highbd_obmc_sad16x16_bits10,
vpx_highbd_10_obmc_variance16x16,
vpx_highbd_10_obmc_sub_pixel_variance16x16)
HIGHBD_OBFP(BLOCK_8X16,
vpx_highbd_obmc_sad8x16_bits10,
vpx_highbd_10_obmc_variance8x16,
vpx_highbd_10_obmc_sub_pixel_variance8x16)
HIGHBD_OBFP(BLOCK_16X8,
vpx_highbd_obmc_sad16x8_bits10,
vpx_highbd_10_obmc_variance16x8,
vpx_highbd_10_obmc_sub_pixel_variance16x8)
HIGHBD_OBFP(BLOCK_8X8,
vpx_highbd_obmc_sad8x8_bits10,
vpx_highbd_10_obmc_variance8x8,
vpx_highbd_10_obmc_sub_pixel_variance8x8)
HIGHBD_OBFP(BLOCK_4X8,
vpx_highbd_obmc_sad4x8_bits10,
vpx_highbd_10_obmc_variance4x8,
vpx_highbd_10_obmc_sub_pixel_variance4x8)
HIGHBD_OBFP(BLOCK_8X4,
vpx_highbd_obmc_sad8x4_bits10,
vpx_highbd_10_obmc_variance8x4,
vpx_highbd_10_obmc_sub_pixel_variance8x4)
HIGHBD_OBFP(BLOCK_4X4,
vpx_highbd_obmc_sad4x4_bits10,
vpx_highbd_10_obmc_variance4x4,
vpx_highbd_10_obmc_sub_pixel_variance4x4)
#endif // CONFIG_OBMC
break;
case VPX_BITS_12:
......@@ -1920,6 +2099,75 @@ static void highbd_set_var_fns(VP10_COMP *const cpi) {
vpx_highbd_12_masked_variance4x4,
vpx_highbd_12_masked_sub_pixel_variance4x4)
#endif // CONFIG_EXT_INTER
#if CONFIG_OBMC
#if CONFIG_EXT_PARTITION
HIGHBD_OBFP(BLOCK_128X128,
vpx_highbd_obmc_sad128x128_bits12,
vpx_highbd_12_obmc_variance128x128,
vpx_highbd_12_obmc_sub_pixel_variance128x128)
HIGHBD_OBFP(BLOCK_128X64,
vpx_highbd_obmc_sad128x64_bits12,
vpx_highbd_12_obmc_variance128x64,
vpx_highbd_12_obmc_sub_pixel_variance128x64)
HIGHBD_OBFP(BLOCK_64X128,
vpx_highbd_obmc_sad64x128_bits12,
vpx_highbd_12_obmc_variance64x128,
vpx_highbd_12_obmc_sub_pixel_variance64x128)
#endif // CONFIG_EXT_PARTITION
HIGHBD_OBFP(BLOCK_64X64,
vpx_highbd_obmc_sad64x64_bits12,
vpx_highbd_12_obmc_variance64x64,
vpx_highbd_12_obmc_sub_pixel_variance64x64)
HIGHBD_OBFP(BLOCK_64X32,
vpx_highbd_obmc_sad64x32_bits12,
vpx_highbd_12_obmc_variance64x32,
vpx_highbd_12_obmc_sub_pixel_variance64x32)
HIGHBD_OBFP(BLOCK_32X64,
vpx_highbd_obmc_sad32x64_bits12,
vpx_highbd_12_obmc_variance32x64,
vpx_highbd_12_obmc_sub_pixel_variance32x64)
HIGHBD_OBFP(BLOCK_32X32,
vpx_highbd_obmc_sad32x32_bits12,
vpx_highbd_12_obmc_variance32x32,
vpx_highbd_12_obmc_sub_pixel_variance32x32)
HIGHBD_OBFP(BLOCK_32X16,
vpx_highbd_obmc_sad32x16_bits12,
vpx_highbd_12_obmc_variance32x16,
vpx_highbd_12_obmc_sub_pixel_variance32x16)
HIGHBD_OBFP(BLOCK_16X32,
vpx_highbd_obmc_sad16x32_bits12,
vpx_highbd_12_obmc_variance16x32,
vpx_highbd_12_obmc_sub_pixel_variance16x32)
HIGHBD_OBFP(BLOCK_16X16,
vpx_highbd_obmc_sad16x16_bits12,
vpx_highbd_12_obmc_variance16x16,
vpx_highbd_12_obmc_sub_pixel_variance16x16)
HIGHBD_OBFP(BLOCK_8X16,
vpx_highbd_obmc_sad8x16_bits12,
vpx_highbd_12_obmc_variance8x16,
vpx_highbd_12_obmc_sub_pixel_variance8x16)
HIGHBD_OBFP(BLOCK_16X8,
vpx_highbd_obmc_sad16x8_bits12,
vpx_highbd_12_obmc_variance16x8,
vpx_highbd_12_obmc_sub_pixel_variance16x8)
HIGHBD_OBFP(BLOCK_8X8,
vpx_highbd_obmc_sad8x8_bits12,
vpx_highbd_12_obmc_variance8x8,
vpx_highbd_12_obmc_sub_pixel_variance8x8)
HIGHBD_OBFP(BLOCK_4X8,
vpx_highbd_obmc_sad4x8_bits12,
vpx_highbd_12_obmc_variance4x8,
vpx_highbd_12_obmc_sub_pixel_variance4x8)
HIGHBD_OBFP(BLOCK_8X4,
vpx_highbd_obmc_sad8x4_bits12,
vpx_highbd_12_obmc_variance8x4,
vpx_highbd_12_obmc_sub_pixel_variance8x4)
HIGHBD_OBFP(BLOCK_4X4,
vpx_highbd_obmc_sad4x4_bits12,
vpx_highbd_12_obmc_variance4x4,
vpx_highbd_12_obmc_sub_pixel_variance4x4)
#endif // CONFIG_OBMC
break;
default:
......@@ -2414,6 +2662,48 @@ VP10_COMP *vp10_create_compressor(VP10EncoderConfig *oxcf,
vpx_sub_pixel_avg_variance4x4,
vpx_sad4x4x3, vpx_sad4x4x8, vpx_sad4x4x4d)
#if CONFIG_OBMC
#define OBFP(BT, OSDF, OVF, OSVF) \
cpi->fn_ptr[BT].osdf = OSDF; \
cpi->fn_ptr[BT].ovf = OVF; \
cpi->fn_ptr[BT].osvf = OSVF;
#if CONFIG_EXT_PARTITION
OBFP(BLOCK_128X128, vpx_obmc_sad128x128, vpx_obmc_variance128x128,
vpx_obmc_sub_pixel_variance128x128)
OBFP(BLOCK_128X64, vpx_obmc_sad128x64, vpx_obmc_variance128x64,
vpx_obmc_sub_pixel_variance128x64)
OBFP(BLOCK_64X128, vpx_obmc_sad64x128, vpx_obmc_variance64x128,
vpx_obmc_sub_pixel_variance64x128)
#endif // CONFIG_EXT_PARTITION
OBFP(BLOCK_64X64, vpx_obmc_sad64x64, vpx_obmc_variance64x64,
vpx_obmc_sub_pixel_variance64x64)
OBFP(BLOCK_64X32, vpx_obmc_sad64x32, vpx_obmc_variance64x32,
vpx_obmc_sub_pixel_variance64x32)
OBFP(BLOCK_32X64, vpx_obmc_sad32x64, vpx_obmc_variance32x64,
vpx_obmc_sub_pixel_variance32x64)
OBFP(BLOCK_32X32, vpx_obmc_sad32x32, vpx_obmc_variance32x32,
vpx_obmc_sub_pixel_variance32x32)
OBFP(BLOCK_32X16, vpx_obmc_sad32x16, vpx_obmc_variance32x16,
vpx_obmc_sub_pixel_variance32x16)
OBFP(BLOCK_16X32, vpx_obmc_sad16x32, vpx_obmc_variance16x32,
vpx_obmc_sub_pixel_variance16x32)
OBFP(BLOCK_16X16, vpx_obmc_sad16x16, vpx_obmc_variance16x16,
vpx_obmc_sub_pixel_variance16x16)
OBFP(BLOCK_16X8, vpx_obmc_sad16x8, vpx_obmc_variance16x8,
vpx_obmc_sub_pixel_variance16x8)
OBFP(BLOCK_8X16, vpx_obmc_sad8x16, vpx_obmc_variance8x16,
vpx_obmc_sub_pixel_variance8x16)
OBFP(BLOCK_8X8, vpx_obmc_sad8x8, vpx_obmc_variance8x8,
vpx_obmc_sub_pixel_variance8x8)
OBFP(BLOCK_4X8, vpx_obmc_sad4x8, vpx_obmc_variance4x8,
vpx_obmc_sub_pixel_variance4x8)
OBFP(BLOCK_8X4, vpx_obmc_sad8x4, vpx_obmc_variance8x4,
vpx_obmc_sub_pixel_variance8x4)
OBFP(BLOCK_4X4, vpx_obmc_sad4x4, vpx_obmc_variance4x4,
vpx_obmc_sub_pixel_variance4x4)
#endif // CONFIG_OBMC
#if CONFIG_EXT_INTER
#define MBFP(BT, MSDF, MVF, MSVF) \
cpi->fn_ptr[BT].msdf = MSDF; \
......
This diff is collapsed.
......@@ -195,6 +195,29 @@ int vp10_masked_full_pixel_diamond(const struct VP10_COMP *cpi, MACROBLOCK *x,
const MV *ref_mv, MV *dst_mv,
int is_second);
#endif // CONFIG_EXT_INTER
#if CONFIG_OBMC
int vp10_obmc_full_pixel_diamond(const struct VP10_COMP *cpi, MACROBLOCK *x,
const int *wsrc, int wsrc_stride,
const int *mask, int mask_stride,
MV *mvp_full, int step_param,
int sadpb, int further_steps, int do_refine,
const vp10_variance_fn_ptr_t *fn_ptr,
const MV *ref_mv, MV *dst_mv,
int is_second);
int vp10_find_best_obmc_sub_pixel_tree_up(struct VP10_COMP *cpi, MACROBLOCK *x,
const int *wsrc, int wsrc_stride,
const int *mask, int mask_stride,
int mi_row, int mi_col,
MV *bestmv, const MV *ref_mv,
int allow_hp, int error_per_bit,
const vp10_variance_fn_ptr_t *vfp,
int forced_stop, int iters_per_step,
int *mvjcost, int *mvcost[2],
int *distortion, unsigned int *sse1,
int is_second,
int use_upsampled_ref);
#endif // CONFIG_OBMC
#ifdef __cplusplus
} // extern "C"
#endif
......
......@@ -6036,6 +6036,149 @@ static INLINE void restore_dst_buf(MACROBLOCKD *xd,
}
}
#if CONFIG_OBMC
static void single_motion_search_obmc(VP10_COMP *cpi, MACROBLOCK *x,
BLOCK_SIZE bsize, int mi_row, int mi_col,
const int* wsrc, int wsrc_stride,
const int* mask, int mask_stride,
#if CONFIG_EXT_INTER
int ref_idx,
int mv_idx,
#endif // CONFIG_EXT_INTER
int_mv *tmp_mv, int_mv pred_mv,
int *rate_mv) {
MACROBLOCKD *xd = &x->e_mbd;
const VP10_COMMON *cm = &cpi->common;
MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
struct buf_2d backup_yv12[MAX_MB_PLANE] = {{0, 0}};
int bestsme = INT_MAX;
int step_param;
int sadpb = x->sadperbit16;
MV mvp_full;
#if CONFIG_EXT_INTER
int ref = mbmi->ref_frame[ref_idx];
MV ref_mv = x->mbmi_ext->ref_mvs[ref][mv_idx].as_mv;
#else
int ref = mbmi->ref_frame[0];
MV ref_mv = x->mbmi_ext->ref_mvs[ref][0].as_mv;
int ref_idx = 0;
#endif // CONFIG_EXT_INTER
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;
const YV12_BUFFER_CONFIG *scaled_ref_frame = vp10_get_scaled_ref_frame(cpi,
ref);
#if CONFIG_REF_MV
vp10_set_mvcost(x, ref);
#endif
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[ref_idx];
vp10_setup_pre_planes(xd, ref_idx, scaled_ref_frame, mi_row, mi_col, NULL);
}
vp10_set_mv_search_range(x, &ref_mv);
// Work out the size of the first step in the mv step search.
// 0 here is maximum length first step. 1 is VPXMAX >> 1 etc.
if (cpi->sf.mv.auto_mv_step_size && cm->show_frame) {
// Take wtd average of the step_params based on the last frame's
// max mv magnitude and that based on the best ref mvs of the current
// block for the given reference.
step_param = (vp10_init_search_range(x->max_mv_context[ref]) +
cpi->mv_step_param) / 2;
} else {
step_param = cpi->mv_step_param;
}
if (cpi->sf.adaptive_motion_search && bsize < cm->sb_size) {
int boffset = 2 * (b_width_log2_lookup[cm->sb_size] -
VPXMIN(b_height_log2_lookup[bsize], b_width_log2_lookup[bsize]));
step_param = VPXMAX(step_param, boffset);
}
if (cpi->sf.adaptive_motion_search) {
int bwl = b_width_log2_lookup[bsize];
int bhl = b_height_log2_lookup[bsize];
int tlevel = x->pred_mv_sad[ref] >> (bwl + bhl + 4);
if (tlevel < 5)
step_param += 2;
// prev_mv_sad is not setup for dynamically scaled frames.
if (cpi->oxcf.resize_mode != RESIZE_DYNAMIC) {
int i;
for (i = LAST_FRAME; i <= ALTREF_FRAME && cm->show_frame; ++i) {
if ((x->pred_mv_sad[ref] >> 3) > x->pred_mv_sad[i]) {
x->pred_mv[ref].row = 0;
x->pred_mv[ref].col = 0;
tmp_mv->as_int = INVALID_MV;
if (scaled_ref_frame) {
int i;
for (i = 0; i < MAX_MB_PLANE; ++i)
xd->plane[i].pre[ref_idx] = backup_yv12[i];
}
return;
}
}
}
}
mvp_full = pred_mv.as_mv;
mvp_full.col >>= 3;
mvp_full.row >>= 3;
bestsme = vp10_obmc_full_pixel_diamond(cpi, x, wsrc, wsrc_stride,
mask, mask_stride,
&mvp_full, step_param, sadpb,
MAX_MVSEARCH_STEPS - 1 - step_param,
1, &cpi->fn_ptr[bsize],
&ref_mv, &tmp_mv->as_mv, ref_idx);
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;
vp10_find_best_obmc_sub_pixel_tree_up(cpi, x,
wsrc, wsrc_stride,
mask, mask_stride,
mi_row, mi_col,
&tmp_mv->as_mv, &ref_mv,
cm->allow_high_precision_mv,
x->errorperbit,
&cpi->fn_ptr[bsize],
cpi->sf.mv.subpel_force_stop,
cpi->sf.mv.subpel_iters_per_step,
x->nmvjointcost, x->mvcost,
&dis, &x->pred_sse[ref],
ref_idx,
cpi->sf.use_upsampled_references);
}
*rate_mv = vp10_mv_bit_cost(&tmp_mv->as_mv, &ref_mv,
x->nmvjointcost, x->mvcost, MV_COST_WEIGHT);
if (scaled_ref_frame) {
int i;
for (i = 0; i < MAX_MB_PLANE; i++)
xd->plane[i].pre[ref_idx] = backup_yv12[i];
}
}
#endif // CONFIG_OBMC
#if CONFIG_EXT_INTER
static void do_masked_motion_search(VP10_COMP *cpi, MACROBLOCK *x,
const uint8_t *mask, int mask_stride,
......@@ -6370,10 +6513,10 @@ static int64_t handle_inter_mode(VP10_COMP *cpi, MACROBLOCK *x,
int_mv (*mode_mv)[MAX_REF_FRAMES],
int mi_row, int mi_col,
#if CONFIG_OBMC
uint8_t *dst_buf1[3],
int dst_stride1[3],
uint8_t *dst_buf2[3],
int dst_stride2[3],
uint8_t *dst_buf1[3], int dst_stride1[3],
uint8_t *dst_buf2[3], int dst_stride2[3],
int *wsrc, int wsrc_strides,
int *mask2d, int mask2d_strides,
#endif // CONFIG_OBMC
#if CONFIG_EXT_INTER
int_mv single_newmvs[2][MAX_REF_FRAMES],
......@@ -6435,6 +6578,7 @@ static int64_t handle_inter_mode(VP10_COMP *cpi, MACROBLOCK *x,
MB_MODE_INFO best_mbmi;
#if CONFIG_EXT_INTER
int rate2_bmc_nocoeff;
int rate_mv_bmc;
MB_MODE_INFO best_bmc_mbmi;
#endif // CONFIG_EXT_INTER
#endif // CONFIG_OBMC
......@@ -6873,6 +7017,7 @@ static int64_t handle_inter_mode(VP10_COMP *cpi, MACROBLOCK *x,
#if CONFIG_EXT_INTER
#if CONFIG_OBMC
best_bmc_mbmi = *mbmi;
rate_mv_bmc = rate_mv;
rate2_bmc_nocoeff = *rate2;
if (cm->interp_filter == SWITCHABLE)
rate2_bmc_nocoeff += rs;
......@@ -7386,14 +7531,45 @@ static int64_t handle_inter_mode(VP10_COMP *cpi, MACROBLOCK *x,
for (mbmi->obmc = 0; mbmi->obmc <= allow_obmc; mbmi->obmc++) {
int64_t tmp_rd, tmp_dist;
int tmp_rate;
#if CONFIG_EXT_INTER
int tmp_rate2 = mbmi->obmc ? rate2_bmc_nocoeff : rate2_nocoeff;
#else
int tmp_rate2 = rate2_nocoeff;
#endif // CONFIG_EXT_INTER
if (mbmi->obmc) {
#if CONFIG_EXT_INTER
*mbmi = best_bmc_mbmi;
assert(!mbmi->use_wedge_interinter);
vp10_build_inter_predictors_sb(xd, mi_row, mi_col, bsize);
mbmi->obmc = 1;
#endif // CONFIG_EXT_INTER
if (!is_comp_pred && have_newmv_in_inter_mode(this_mode)) {
int_mv tmp_mv;
int_mv pred_mv;
int tmp_rate_mv = 0;
pred_mv.as_int = mbmi->mv[0].as_int;
single_motion_search_obmc(cpi, x, bsize, mi_row, mi_col,
wsrc, wsrc_strides,
mask2d, mask2d_strides,
#if CONFIG_EXT_INTER
0, mv_idx,
#endif // CONFIG_EXT_INTER
&tmp_mv, pred_mv, &tmp_rate_mv);
mbmi->mv[0].as_int = tmp_mv.as_int;
if (discount_newmv_test(cpi, this_mode, tmp_mv, mode_mv, refs[0])) {
tmp_rate_mv = VPXMAX((tmp_rate_mv / NEW_MV_DISCOUNT_FACTOR), 1);
}
#if CONFIG_EXT_INTER
tmp_rate2 = rate2_bmc_nocoeff - rate_mv_bmc + tmp_rate_mv;
#else
tmp_rate2 = rate2_nocoeff - rate_mv + tmp_rate_mv;
#endif // CONFIG_EXT_INTER
vp10_build_inter_predictors_sb(xd, mi_row, mi_col, bsize);
#if CONFIG_EXT_INTER
} else {
vp10_build_inter_predictors_sb(xd, mi_row, mi_col, bsize);
#endif // CONFIG_EXT_INTER
}
vp10_build_obmc_inter_prediction(cm, xd, mi_row, mi_col, 0,
NULL, NULL,
dst_buf1, dst_stride1,
......@@ -7415,11 +7591,7 @@ static int64_t handle_inter_mode(VP10_COMP *cpi, MACROBLOCK *x,
#endif // CONFIG_VP9_HIGHBITDEPTH
x->skip = 0;
#if CONFIG_EXT_INTER
*rate2 = mbmi->obmc ? rate2_bmc_nocoeff : rate2_nocoeff;
#else
*rate2 = rate2_nocoeff;
#endif // CONFIG_EXT_INTER
*rate2 = tmp_rate2;
if (allow_obmc)
*rate2 += cpi->obmc_cost[bsize][mbmi->obmc];
*distortion = 0;
......@@ -7927,9 +8099,13 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi,
DECLARE_ALIGNED(16, uint8_t, tmp_buf1[MAX_MB_PLANE * MAX_SB_SQUARE]);
DECLARE_ALIGNED(16, uint8_t, tmp_buf2[MAX_MB_PLANE * MAX_SB_SQUARE]);
#endif // CONFIG_VP9_HIGHBITDEPTH
DECLARE_ALIGNED(16, int, weighted_src_buf[MAX_SB_SQUARE]);
DECLARE_ALIGNED(16, int, mask2d_buf[MAX_SB_SQUARE]);
uint8_t *dst_buf1[MAX_MB_PLANE], *dst_buf2[MAX_MB_PLANE];
int dst_stride1[MAX_MB_PLANE] = {MAX_SB_SIZE, MAX_SB_SIZE, MAX_SB_SIZE};
int dst_stride2[MAX_MB_PLANE] = {MAX_SB_SIZE, MAX_SB_SIZE, MAX_SB_SIZE};
int weighted_src_stride = MAX_SB_SIZE;
int mask2d_stride = MAX_SB_SIZE;
#if CONFIG_VP9_HIGHBITDEPTH
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
......@@ -8031,6 +8207,11 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi,
vp10_build_prediction_by_left_preds(cm, xd, mi_row, mi_col, dst_buf2,
dst_stride2);
vp10_setup_dst_planes(xd->plane, get_frame_new_buffer(cm), mi_row, mi_col);
calc_target_weighted_pred(cm, x, xd, mi_row, mi_col,
dst_buf1[0], dst_stride1[0],
dst_buf2[0], dst_stride2[0],
mask2d_buf, mask2d_stride,
weighted_src_buf, weighted_src_stride);
#endif // CONFIG_OBMC
for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ++ref_frame) {
......@@ -8577,6 +8758,8 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi,
#if CONFIG_OBMC
dst_buf1, dst_stride1,
dst_buf2, dst_stride2,
weighted_src_buf, weighted_src_stride,
mask2d_buf, mask2d_stride,