Commit 450c7b57 authored by Ronald S. Bultje's avatar Ronald S. Bultje

Only do metrics on cropped (visible) area of picture.

The part where we align it by 8 or 16 is an implementation detail that
shouldn't matter to the outside world.

Change-Id: I9edd6f08b51b31c839c0ea91f767640bccb08d53
parent 44f349df
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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; */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment