about summary refs log tree commit diff
path: root/analyzer
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2016-01-27 03:01:55 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2016-01-27 03:01:55 +0000
commit62c1ea4a1863d1cf3b83b76088a0ff323c68220c (patch)
tree7b4b5facebb1b7b5cdda77c0c4a596b4f6dddb29 /analyzer
parentadab94d786a3f136e77d73322d13443af11f9009 (diff)
downloadnetpbm-mirror-62c1ea4a1863d1cf3b83b76088a0ff323c68220c.tar.gz
netpbm-mirror-62c1ea4a1863d1cf3b83b76088a0ff323c68220c.tar.xz
netpbm-mirror-62c1ea4a1863d1cf3b83b76088a0ff323c68220c.zip
Add -max
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@2675 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'analyzer')
-rw-r--r--analyzer/pnmpsnr.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/analyzer/pnmpsnr.c b/analyzer/pnmpsnr.c
index c9c08b28..19f013a4 100644
--- a/analyzer/pnmpsnr.c
+++ b/analyzer/pnmpsnr.c
@@ -29,6 +29,8 @@ struct CmdlineInfo {
     const char * inputFile2Name;  /* Name of second input file */
     unsigned int rgb;
     unsigned int machine;
+    unsigned int maxSpec;
+    float        max;
 };
 
 
@@ -50,8 +52,12 @@ parseCommandLine(int argc, const char ** argv,
     MALLOCARRAY_NOFAIL(option_def, 100);
     
     option_def_index = 0;   /* incremented by OPTENT3 */
-    OPTENT3(0,   "rgb",      OPT_FLAG,  NULL, &cmdlineP->rgb,       0);
-    OPTENT3(0,   "machine",  OPT_FLAG,  NULL, &cmdlineP->machine,   0);
+    OPTENT3(0,   "rgb",      OPT_FLAG,  NULL,
+            &cmdlineP->rgb,       0);
+    OPTENT3(0,   "machine",  OPT_FLAG,  NULL,
+            &cmdlineP->machine,   0);
+    OPTENT3(0,   "max",      OPT_FLOAT, &cmdlineP->max,  
+            &cmdlineP->maxSpec,   0);
 
     opt.opt_table     = option_def;
     opt.short_allowed = FALSE; /* We have no short (old-fashioned) options */
@@ -424,15 +430,19 @@ reportPsnrHuman(struct Psnr   const psnr,
 
 static void
 reportPsnrMachine(struct Psnr  const psnr,
-                  unsigned int const componentCt) {
+                  unsigned int const componentCt,
+                  bool         const maxSpec,
+                  float        const max) {
 
     unsigned int i;
 
     for (i = 0; i < componentCt; ++i) {
+        double const clipped = maxSpec ? MIN(max, psnr.psnr[i]) : psnr.psnr[i];
+
         if (i > 0)
             fprintf(stdout, " ");
 
-        fprintf(stdout, "%.2f", psnr.psnr[i]);
+        fprintf(stdout, "%.2f", clipped);
     }
     fprintf(stdout, "\n");
 }
@@ -484,7 +494,8 @@ main (int argc, const char **argv) {
                 sumSqDiff, maxSumSqDiff, colorSpace.componentCt);
 
         if (cmdline.machine)
-            reportPsnrMachine(psnr, colorSpace.componentCt);
+            reportPsnrMachine(psnr, colorSpace.componentCt,
+                              cmdline.maxSpec, cmdline.max);
         else
             reportPsnrHuman(psnr, colorSpace,
                             cmdline.inputFile1Name, cmdline.inputFile2Name);