add -print_psnr and -print_ssim options to cwebp.

These will report the 7x7-averaged PSNR or SSIM, using the
new internal function WebPPictureDistortion().
This is for information only. These flags have no encoding impact.

+misc opportunistic cosmetics

Change-Id: I64c0a7eca679134d39062e438886274b22bb643f
This commit is contained in:
Pascal Massimino
2012-01-20 07:20:56 -08:00
parent 2e3e8b2ef5
commit d61479f95b
7 changed files with 165 additions and 26 deletions

View File

@ -248,6 +248,15 @@ WEBP_EXTERN(void) WebPPictureFree(WebPPicture* const picture);
WEBP_EXTERN(int) WebPPictureCopy(const WebPPicture* const src,
WebPPicture* const dst);
// Compute PSNR or SSIM distortion between two pictures.
// Result is in dB, stores in result[] in the Y/U/V/Alpha/All order.
// Returns 0 in case of error (pic1 and pic2 don't have same dimension, ...)
// Warning: this function is rather CPU-intensive.
WEBP_EXTERN(int) WebPPictureDistortion(
const WebPPicture* const pic1, const WebPPicture* const pic2,
int metric_type, // 0 = PSNR, 1 = SSIM
float result[5]);
// self-crops a picture to the rectangle defined by top/left/width/height.
// Returns 0 in case of memory allocation error, or if the rectangle is
// outside of the source picture.