changeset 1647:948d6fda722d

Add sanity check for interlaced formats: check that the interlace type flags are set.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 30 May 2018 01:17:57 +0300
parents 415c732dc14c
children 52cd979d63fd
files tools/lib64gfx.c tools/lib64gfx.h
diffstat 2 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/tools/lib64gfx.c	Wed May 30 01:07:07 2018 +0300
+++ b/tools/lib64gfx.c	Wed May 30 01:17:57 2018 +0300
@@ -48,7 +48,7 @@
     if (img->type & D64_FMT_ILACE)
     {
         char *tmps;
-        switch(img->laceType)
+        switch (img->laceType)
         {
             case D64_ILACE_COLOR: tmps = "color"; break;
             case D64_ILACE_RES: tmps = "resolution"; break;
@@ -773,6 +773,14 @@
         }
     }
 
+    // Sanity check certain things ..
+    if ((fmt->type & D64_FMT_ILACE) && img->laceType == D64_ILACE_NONE)
+    {
+        return dmError(DMERR_INTERNAL,
+            "Format '%s' (%s) has interlace flag set, but interlace type is not set.\n",
+            fmt->name, fmt->fext);
+    }
+
     return DMERR_OK;
 }
 
--- a/tools/lib64gfx.h	Wed May 30 01:07:07 2018 +0300
+++ b/tools/lib64gfx.h	Wed May 30 01:17:57 2018 +0300
@@ -64,6 +64,7 @@
 // Different types of interlace
 enum
 {
+    D64_ILACE_NONE       = 0x0000, // Not set (invalid for interlaced images)
     D64_ILACE_RES        = 0x0001, // Interlace doubles resolution
     D64_ILACE_COLOR      = 0x0002, // Uses color mixing
 };