diff --git a/vp9/encoder/vp9_onyx_if.c b/vp9/encoder/vp9_onyx_if.c index d6fa3fa6c7a354b6c175a4baca93843f78dcefec..ab7a41e28eeef460d2e7931d9998a92ec2c71cc4 100644 --- a/vp9/encoder/vp9_onyx_if.c +++ b/vp9/encoder/vp9_onyx_if.c @@ -1823,8 +1823,8 @@ static void generate_psnr_packet(VP9_COMP *cpi) { struct vpx_codec_cx_pkt pkt; uint64_t sse; int i; - unsigned int width = cpi->common.width; - unsigned int height = cpi->common.height; + unsigned int width = orig->y_crop_width; + unsigned int height = orig->y_crop_height; pkt.kind = VPX_CODEC_PSNR_PKT; sse = calc_plane_error(orig->y_buffer, orig->y_stride, @@ -1835,8 +1835,8 @@ static void generate_psnr_packet(VP9_COMP *cpi) { pkt.data.psnr.samples[0] = width * height; pkt.data.psnr.samples[1] = width * height; - width = orig->uv_width; - height = orig->uv_height; + width = orig->uv_crop_width; + height = orig->uv_crop_height; sse = calc_plane_error(orig->u_buffer, orig->uv_stride, recon->u_buffer, recon->uv_stride, @@ -3758,16 +3758,16 @@ int vp9_get_compressed_data(VP9_PTR ptr, unsigned int *frame_flags, double sq_error; ye = (double)calc_plane_error(orig->y_buffer, orig->y_stride, - recon->y_buffer, recon->y_stride, orig->y_width, - orig->y_height); + recon->y_buffer, recon->y_stride, + orig->y_crop_width, orig->y_crop_height); ue = (double)calc_plane_error(orig->u_buffer, orig->uv_stride, - recon->u_buffer, recon->uv_stride, orig->uv_width, - orig->uv_height); + recon->u_buffer, recon->uv_stride, + orig->uv_crop_width, orig->uv_crop_height); ve = (double)calc_plane_error(orig->v_buffer, orig->uv_stride, - recon->v_buffer, recon->uv_stride, orig->uv_width, - orig->uv_height); + recon->v_buffer, recon->uv_stride, + orig->uv_crop_width, orig->uv_crop_height); sq_error = ye + ue + ve; @@ -3788,16 +3788,16 @@ int vp9_get_compressed_data(VP9_PTR ptr, unsigned int *frame_flags, vp9_clear_system_state(); ye = (double)calc_plane_error(orig->y_buffer, orig->y_stride, - pp->y_buffer, pp->y_stride, orig->y_width, - orig->y_height); + pp->y_buffer, pp->y_stride, + orig->y_crop_width, orig->y_crop_height); ue = (double)calc_plane_error(orig->u_buffer, orig->uv_stride, - pp->u_buffer, pp->uv_stride, orig->uv_width, - orig->uv_height); + pp->u_buffer, pp->uv_stride, + orig->uv_crop_width, orig->uv_crop_height); ve = (double)calc_plane_error(orig->v_buffer, orig->uv_stride, - pp->v_buffer, pp->uv_stride, orig->uv_width, - orig->uv_height); + pp->v_buffer, pp->uv_stride, + orig->uv_crop_width, orig->uv_crop_height); sq_error = ye + ue + ve; diff --git a/vp9/encoder/vp9_ssim.c b/vp9/encoder/vp9_ssim.c index d417f6fe97053941a8fcf8ec5719ab2e44b72b2d..c1555166376d1fc47772ea9096126966074f3979 100644 --- a/vp9/encoder/vp9_ssim.c +++ b/vp9/encoder/vp9_ssim.c @@ -105,16 +105,16 @@ double vp9_calc_ssim(YV12_BUFFER_CONFIG *source, YV12_BUFFER_CONFIG *dest, double ssimv; a = vp9_ssim2(source->y_buffer, dest->y_buffer, - source->y_stride, dest->y_stride, source->y_width, - source->y_height); + source->y_stride, dest->y_stride, + source->y_crop_width, source->y_crop_height); b = vp9_ssim2(source->u_buffer, dest->u_buffer, - source->uv_stride, dest->uv_stride, source->uv_width, - source->uv_height); + source->uv_stride, dest->uv_stride, + source->uv_crop_width, source->uv_crop_height); c = vp9_ssim2(source->v_buffer, dest->v_buffer, - source->uv_stride, dest->uv_stride, source->uv_width, - source->uv_height); + source->uv_stride, dest->uv_stride, + source->uv_crop_width, source->uv_crop_height); ssimv = a * .8 + .1 * (b + c); @@ -129,16 +129,16 @@ double vp9_calc_ssimg(YV12_BUFFER_CONFIG *source, YV12_BUFFER_CONFIG *dest, double a, b, c; a = vp9_ssim2(source->y_buffer, dest->y_buffer, - source->y_stride, dest->y_stride, source->y_width, - source->y_height); + source->y_stride, dest->y_stride, + source->y_crop_width, source->y_crop_height); b = vp9_ssim2(source->u_buffer, dest->u_buffer, - source->uv_stride, dest->uv_stride, source->uv_width, - source->uv_height); + source->uv_stride, dest->uv_stride, + source->uv_crop_width, source->uv_crop_height); c = vp9_ssim2(source->v_buffer, dest->v_buffer, - source->uv_stride, dest->uv_stride, source->uv_width, - source->uv_height); + source->uv_stride, dest->uv_stride, + source->uv_crop_width, source->uv_crop_height); *ssim_y = a; *ssim_u = b; *ssim_v = c; diff --git a/vpx_scale/generic/yv12config.c b/vpx_scale/generic/yv12config.c index 754a615a8a7bfbe30b6c0600d2fea2ff86e695d2..b18155be6385527f14e82363bd2f93f8d2809b77 100644 --- a/vpx_scale/generic/yv12config.c +++ b/vpx_scale/generic/yv12config.c @@ -170,6 +170,8 @@ int vp9_realloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, ybf->y_height = aligned_height; ybf->y_stride = y_stride; + ybf->uv_crop_width = (width + ss_x) >> ss_x; + ybf->uv_crop_height = (height + ss_y) >> ss_y; ybf->uv_width = uv_width; ybf->uv_height = uv_height; ybf->uv_stride = uv_stride; diff --git a/vpx_scale/yv12config.h b/vpx_scale/yv12config.h index 7b8bd850f9e7c17506763ac2e94a07a2f881dc65..c351370412eb9673c184423c7aa53db58192d657 100644 --- a/vpx_scale/yv12config.h +++ b/vpx_scale/yv12config.h @@ -49,6 +49,8 @@ extern "C" { int uv_width; int uv_height; + int uv_crop_width; + int uv_crop_height; int uv_stride; /* int uvinternal_width; */