]> granicus.if.org Git - libvpx/commitdiff
Set a max dB value for PSNR_HVS and FAST_SSIM
authorYaowu Xu <yaowu@google.com>
Thu, 4 Feb 2016 22:03:48 +0000 (14:03 -0800)
committerYaowu Xu <yaowu@google.com>
Mon, 8 Feb 2016 18:55:25 +0000 (10:55 -0800)
Now set at 100.0 instead of infinite

Change-Id: I41bae0c4bd95a26f9819584e7311b7945df1271a

vpx/internal/vpx_psnr.h
vpx/src/vpx_psnr.c
vpx_dsp/fastssim.c
vpx_dsp/psnrhvs.c
vpx_dsp/ssim.h

index 07d81bb8d9046466e327fcc79a3c2a7894c1ad28..0e900858e35a6b961f1749b6be2e0f48703e4035 100644 (file)
@@ -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
index 05843acb61f0e9cfec9da01266564da703dd8462..27a6180ce83341c7a609e10a6d4ff447816f8dc3 100644 (file)
@@ -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) {
index 1405a30e00af02d932f9c27ea4e3cfbc41f184c8..569f18b69616273cd151361ac36ffffa0601ef8f 100644 (file)
@@ -10,6 +10,7 @@
  *  This code was originally written by: Nathan E. Egge, at the Daala
  *  project.
  */
+#include <assert.h>
 #include <math.h>
 #include <stdlib.h>
 #include <string.h>
@@ -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));
 }
 
index b10f9f303ec50886233522a88e84926ea624d718..083cc806a1026c57f13b48fe009ab1cf77838c80 100644 (file)
@@ -10,6 +10,7 @@
  *  This code was originally written by: Gregory Maxwell, at the Daala
  *  project.
  */
+#include <assert.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <math.h>
@@ -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));
 }
 
index 132f7f9e1984ed5037acd433790f384eccff31e3..1d90f9b4dbcb13ed7a6dd19cea7576bcd363871e 100644 (file)
@@ -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