diff --git a/vp9/common/vp9_blockd.h b/vp9/common/vp9_blockd.h index c98ca90b9..5d3d8f1a2 100644 --- a/vp9/common/vp9_blockd.h +++ b/vp9/common/vp9_blockd.h @@ -167,6 +167,8 @@ enum mv_precision { }; #define VP9_REF_SCALE_SHIFT 14 +#define VP9_REF_NO_SCALE 16384 + struct scale_factors { int x_scale_fp; // horizontal fixed point scale factor int y_scale_fp; // vertical fixed point scale factor diff --git a/vp9/common/vp9_reconinter.c b/vp9/common/vp9_reconinter.c index c29fd147e..c1b64d87c 100644 --- a/vp9/common/vp9_reconinter.c +++ b/vp9/common/vp9_reconinter.c @@ -16,6 +16,7 @@ #include "vp9/common/vp9_filter.h" #include "vp9/common/vp9_reconinter.h" #include "vp9/common/vp9_reconintra.h" +#include "./vpx_scale_rtcd.h" static int scale_value_x_with_scaling(int val, const struct scale_factors *scale) { @@ -406,6 +407,10 @@ void vp9_setup_scale_factors(VP9_COMMON *cm, int i) { vp9_setup_scale_factors_for_frame(sf, fb->y_crop_width, fb->y_crop_height, cm->width, cm->height); + + if (sf->x_scale_fp != VP9_REF_NO_SCALE || + sf->y_scale_fp != VP9_REF_NO_SCALE) + vp9_extend_frame_borders(fb, cm->subsampling_x, cm->subsampling_y); } } diff --git a/vp9/decoder/vp9_onyxd_if.c b/vp9/decoder/vp9_onyxd_if.c index 3cef88bcd..b9c7f302d 100644 --- a/vp9/decoder/vp9_onyxd_if.c +++ b/vp9/decoder/vp9_onyxd_if.c @@ -361,8 +361,9 @@ int vp9_receive_compressed_data(VP9D_PTR ptr, cm->current_video_frame + 3000); #endif - vp9_extend_frame_borders(cm->frame_to_show, - cm->subsampling_x, cm->subsampling_y); + vp9_extend_frame_inner_borders(cm->frame_to_show, + cm->subsampling_x, + cm->subsampling_y); } #if WRITE_RECON_BUFFER == 1 diff --git a/vp9/encoder/vp9_onyx_if.c b/vp9/encoder/vp9_onyx_if.c index 14d36bdf6..cbb9f87c6 100644 --- a/vp9/encoder/vp9_onyx_if.c +++ b/vp9/encoder/vp9_onyx_if.c @@ -2402,7 +2402,7 @@ static void loopfilter_frame(VP9_COMP *cpi, VP9_COMMON *cm) { vp9_loop_filter_frame(cm, &cpi->mb.e_mbd, cm->filter_level, 0); } - vp9_extend_frame_borders(cm->frame_to_show, + vp9_extend_frame_inner_borders(cm->frame_to_show, cm->subsampling_x, cm->subsampling_y); } diff --git a/vpx_scale/generic/yv12extend.c b/vpx_scale/generic/yv12extend.c index c38fb807a..60df0af56 100644 --- a/vpx_scale/generic/yv12extend.c +++ b/vpx_scale/generic/yv12extend.c @@ -96,12 +96,13 @@ vp8_yv12_extend_frame_borders_c(YV12_BUFFER_CONFIG *ybf) { } #if CONFIG_VP9 -void vp9_extend_frame_borders_c(YV12_BUFFER_CONFIG *ybf, - int subsampling_x, int subsampling_y) { +static void extend_frame(YV12_BUFFER_CONFIG *ybf, + int subsampling_x, int subsampling_y, + int ext_size) { const int c_w = (ybf->y_crop_width + subsampling_x) >> subsampling_x; const int c_h = (ybf->y_crop_height + subsampling_y) >> subsampling_y; - const int c_et = ybf->border >> subsampling_y; - const int c_el = ybf->border >> subsampling_x; + const int c_et = ext_size >> subsampling_y; + const int c_el = ext_size >> subsampling_x; const int c_eb = (ybf->border + ybf->y_height - ybf->y_crop_height + subsampling_y) >> subsampling_y; const int c_er = (ybf->border + ybf->y_width - ybf->y_crop_width + @@ -114,9 +115,9 @@ void vp9_extend_frame_borders_c(YV12_BUFFER_CONFIG *ybf, extend_plane(ybf->y_buffer, ybf->y_stride, ybf->y_crop_width, ybf->y_crop_height, - ybf->border, ybf->border, - ybf->border + ybf->y_height - ybf->y_crop_height, - ybf->border + ybf->y_width - ybf->y_crop_width); + ext_size, ext_size, + ext_size + ybf->y_height - ybf->y_crop_height, + ext_size + ybf->y_width - ybf->y_crop_width); extend_plane(ybf->u_buffer, ybf->uv_stride, c_w, c_h, c_et, c_el, c_eb, c_er); @@ -124,6 +125,19 @@ void vp9_extend_frame_borders_c(YV12_BUFFER_CONFIG *ybf, extend_plane(ybf->v_buffer, ybf->uv_stride, c_w, c_h, c_et, c_el, c_eb, c_er); } + + +void vp9_extend_frame_borders_c(YV12_BUFFER_CONFIG *ybf, + int subsampling_x, int subsampling_y) { + extend_frame(ybf, subsampling_x, subsampling_y, ybf->border); +} + +void vp9_extend_frame_inner_borders_c(YV12_BUFFER_CONFIG *ybf, + int subsampling_x, int subsampling_y) { + const int inner_bw = ybf->border > VP9INNERBORDERINPIXLES ? + VP9INNERBORDERINPIXLES : ybf->border; + extend_frame(ybf, subsampling_x, subsampling_y, inner_bw); +} #endif /**************************************************************************** diff --git a/vpx_scale/vpx_scale_rtcd.sh b/vpx_scale/vpx_scale_rtcd.sh index b4f89077d..21d1e52d6 100644 --- a/vpx_scale/vpx_scale_rtcd.sh +++ b/vpx_scale/vpx_scale_rtcd.sh @@ -28,4 +28,7 @@ specialize vp8_yv12_copy_y neon if [ "$CONFIG_VP9" = "yes" ]; then prototype void vp9_extend_frame_borders "struct yv12_buffer_config *ybf, int subsampling_x, int subsampling_y" specialize vp9_extend_frame_borders + + prototype void vp9_extend_frame_inner_borders "struct yv12_buffer_config *ybf, int subsampling_x, int subsampling_y" + specialize vp9_extend_frame_inner_borders_c fi diff --git a/vpx_scale/yv12config.h b/vpx_scale/yv12config.h index a934a94bd..a919e493b 100644 --- a/vpx_scale/yv12config.h +++ b/vpx_scale/yv12config.h @@ -18,7 +18,8 @@ extern "C" { #include "vpx/vpx_integer.h" #define VP8BORDERINPIXELS 32 -#define VP9BORDERINPIXELS 160 +#define VP9INNERBORDERINPIXLES 96 +#define VP9BORDERINPIXELS 160 #define VP9_INTERP_EXTEND 4 /*************************************