From: Yaowu Xu Date: Thu, 4 Feb 2016 22:03:48 +0000 (-0800) Subject: Set a max dB value for PSNR_HVS and FAST_SSIM X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=efe1b1dbf78f61f65e07141c94b67e292bbaf613;p=libvpx Set a max dB value for PSNR_HVS and FAST_SSIM Now set at 100.0 instead of infinite Change-Id: I41bae0c4bd95a26f9819584e7311b7945df1271a --- diff --git a/vpx/internal/vpx_psnr.h b/vpx/internal/vpx_psnr.h index 07d81bb8d..0e900858e 100644 --- a/vpx/internal/vpx_psnr.h +++ b/vpx/internal/vpx_psnr.h @@ -11,6 +11,8 @@ #ifndef VPX_INTERNAL_VPX_PSNR_H_ #define VPX_INTERNAL_VPX_PSNR_H_ +#define MAX_PSNR 100.0 + #ifdef __cplusplus extern "C" { #endif diff --git a/vpx/src/vpx_psnr.c b/vpx/src/vpx_psnr.c index 05843acb6..27a6180ce 100644 --- a/vpx/src/vpx_psnr.c +++ b/vpx/src/vpx_psnr.c @@ -12,7 +12,6 @@ #include "vpx/internal/vpx_psnr.h" -#define MAX_PSNR 100.0 double vpx_sse_to_psnr(double samples, double peak, double sse) { if (sse > 0.0) { diff --git a/vpx_dsp/fastssim.c b/vpx_dsp/fastssim.c index 1405a30e0..569f18b69 100644 --- a/vpx_dsp/fastssim.c +++ b/vpx_dsp/fastssim.c @@ -10,6 +10,7 @@ * This code was originally written by: Nathan E. Egge, at the Daala * project. */ +#include #include #include #include @@ -17,6 +18,7 @@ #include "./vpx_dsp_rtcd.h" #include "vpx_dsp/ssim.h" #include "vpx_ports/system_state.h" + /* TODO(jbb): High bit depth version of this code needed */ typedef struct fs_level fs_level; typedef struct fs_ctx fs_ctx; @@ -442,6 +444,9 @@ static double calc_ssim(const unsigned char *_src, int _systride, } static double convert_ssim_db(double _ssim, double _weight) { + assert(_weight >= _ssim); + if ((_weight - _ssim) < 1e-10) + return MAX_SSIM_DB; return 10 * (log10(_weight) - log10(_weight - _ssim)); } diff --git a/vpx_dsp/psnrhvs.c b/vpx_dsp/psnrhvs.c index b10f9f303..083cc806a 100644 --- a/vpx_dsp/psnrhvs.c +++ b/vpx_dsp/psnrhvs.c @@ -10,6 +10,7 @@ * This code was originally written by: Gregory Maxwell, at the Daala * project. */ +#include #include #include #include @@ -18,6 +19,7 @@ #include "./vpx_dsp_rtcd.h" #include "vpx_dsp/ssim.h" #include "vpx_ports/system_state.h" +#include "vpx/internal/vpx_psnr.h" #if !defined(M_PI) # define M_PI (3.141592653589793238462643) @@ -90,6 +92,9 @@ static const double csf_cr420[8][8] = { 0.478717061273, 0.393021669543, 0.330555063063, 0.285345396658}}; static double convert_score_db(double _score, double _weight) { + assert(_score * _weight >= 0.0); + if (_weight * _score < 255 * 255 * 1e-10) + return MAX_PSNR; return 10 * (log10(255 * 255) - log10(_weight * _score)); } diff --git a/vpx_dsp/ssim.h b/vpx_dsp/ssim.h index 132f7f9e1..1d90f9b4d 100644 --- a/vpx_dsp/ssim.h +++ b/vpx_dsp/ssim.h @@ -11,6 +11,8 @@ #ifndef VPX_DSP_SSIM_H_ #define VPX_DSP_SSIM_H_ +#define MAX_SSIM_DB 100.0; + #ifdef __cplusplus extern "C" { #endif