changeset 1729:f4015f6cb173

Add new option -i for printing information about the images that replaces the old misnamed -p ("probe only") option. However, -p option is retained, but changes its meaning to actually perform probing only and no actual image data decoding per se.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 07 Jun 2018 15:54:19 +0300
parents 80adcda72210
children 881a3fc421d8
files tools/64vw.c
diffstat 1 files changed, 23 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/tools/64vw.c	Thu Jun 07 15:52:58 2018 +0300
+++ b/tools/64vw.c	Thu Jun 07 15:54:19 2018 +0300
@@ -15,13 +15,14 @@
 #define SET_SKIP_AMOUNT 10
 
 
-int    optVFlags = 0;
-int    optScrWidth, optScrHeight;
-int    optForcedFormat = -1;
-BOOL   optProbeOnly = FALSE;
-BOOL   optListOnly  = FALSE;
-size_t noptFilenames1 = 0, noptFilenames2 = 0;
-char   **optFilenames = NULL;
+int     optVFlags = 0;
+int     optScrWidth, optScrHeight;
+int     optForcedFormat = -1;
+BOOL    optInfoOnly  = FALSE,
+        optProbeOnly = FALSE,
+        optListOnly  = FALSE;
+size_t  noptFilenames1 = 0, noptFilenames2 = 0;
+char    **optFilenames = NULL;
 
 
 static const DMOptArg optList[] =
@@ -32,8 +33,9 @@
     { 3, 'S', "scale",      "Scale image by factor (1-10)", OPT_ARGREQ },
     { 4, 'f', "format",     "Force input format (see --formats)", OPT_ARGREQ },
     { 5, 'F', "formats",    "List supported input formats", OPT_NONE },
-    { 6, 'p', "probe",      "Probe only (no display)", OPT_NONE },
-    { 7, 'l', "list",       "Output list of files that were recognized (implies -p)", OPT_NONE },
+    { 6, 'i', "info",       "Print information only (no display)", OPT_NONE },
+    { 7, 'l', "list",       "Output list of files that were recognized (implies -i)", OPT_NONE },
+    { 8, 'p', "probe",      "Probe only (do not attempt to decode the image)", OPT_NONE },
 };
 
 const int optListN = sizeof(optList) / sizeof(optList[0]);
@@ -143,6 +145,12 @@
         case 6:
             if (dmVerbosity < 1)
                 dmVerbosity = 1;
+            optInfoOnly = TRUE;
+            break;
+
+        case 8:
+            if (dmVerbosity < 1)
+                dmVerbosity = 1;
             optProbeOnly = TRUE;
             break;
 
@@ -186,7 +194,10 @@
     if ((ret = dmReadDataFile(NULL, filename, &dataBuf, &dataSize)) != DMERR_OK)
         goto exit;
 
-    ret = dmC64DecodeBMP(cimage, dmGrowBufCreateFrom(&tmp, dataBuf, dataSize), 0, 2, fmt, forced);
+    if (optProbeOnly)
+        ret = dmC64ProbeBMP(dataBuf, dataSize, fmt) != DM_PROBE_SCORE_FALSE ? DMERR_OK : DMERR_NOT_SUPPORTED;
+    else
+        ret = dmC64DecodeBMP(cimage, dmGrowBufCreateFrom(&tmp, dataBuf, dataSize), 0, 2, fmt, forced);
 
 exit:
     dmFree(dataBuf);
@@ -262,8 +273,8 @@
     else
         forced = NULL;
 
-    // If we are simply probing, no need to initialize SDL etc
-    if (optProbeOnly)
+    // If we are simply displaying file information, no need to initialize SDL etc
+    if (optInfoOnly || optProbeOnly)
     {
         for (size_t n = 0; n < noptFilenames2; n++)
         {