Index: source/libvpx/vp9/encoder/vp9_mcomp.c |
diff --git a/source/libvpx/vp9/encoder/vp9_mcomp.c b/source/libvpx/vp9/encoder/vp9_mcomp.c |
index 80c509a1b4908cc3f759280e40c9ed9ad273dbaa..15f95829fb87f2548a450edf2258683a85daabfe 100644 |
--- a/source/libvpx/vp9/encoder/vp9_mcomp.c |
+++ b/source/libvpx/vp9/encoder/vp9_mcomp.c |
@@ -13,10 +13,13 @@ |
#include <stdio.h> |
#include "./vpx_config.h" |
+#include "./vpx_dsp_rtcd.h" |
#include "vpx_mem/vpx_mem.h" |
+#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" |
@@ -302,13 +305,13 @@ static INLINE unsigned int setup_center_error(const MACROBLOCKD *xd, |
if (second_pred != NULL) { |
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) { |
DECLARE_ALIGNED(16, uint16_t, comp_pred16[64 * 64]); |
- vp9_highbd_comp_avg_pred(comp_pred16, second_pred, w, h, y + offset, |
+ vpx_highbd_comp_avg_pred(comp_pred16, second_pred, w, h, y + offset, |
y_stride); |
besterr = vfp->vf(CONVERT_TO_BYTEPTR(comp_pred16), w, src, src_stride, |
sse1); |
} else { |
DECLARE_ALIGNED(16, uint8_t, comp_pred[64 * 64]); |
- vp9_comp_avg_pred(comp_pred, second_pred, w, h, y + offset, y_stride); |
+ vpx_comp_avg_pred(comp_pred, second_pred, w, h, y + offset, y_stride); |
besterr = vfp->vf(comp_pred, w, src, src_stride, sse1); |
} |
} else { |
@@ -320,7 +323,7 @@ static INLINE unsigned int setup_center_error(const MACROBLOCKD *xd, |
(void) xd; |
if (second_pred != NULL) { |
DECLARE_ALIGNED(16, uint8_t, comp_pred[64 * 64]); |
- vp9_comp_avg_pred(comp_pred, second_pred, w, h, y + offset, y_stride); |
+ vpx_comp_avg_pred(comp_pred, second_pred, w, h, y + offset, y_stride); |
besterr = vfp->vf(comp_pred, w, src, src_stride, sse1); |
} else { |
besterr = vfp->vf(y + offset, y_stride, src, src_stride, sse1); |
@@ -1788,8 +1791,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]); |
@@ -1806,12 +1812,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 |
@@ -1889,6 +1917,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; |
} |