[x265] [PATCH] Added better vui parameter checking

dtyx265 at gmail.com dtyx265 at gmail.com
Thu Feb 20 23:28:24 CET 2014


# HG changeset patch
# User David T Yuen <dtyx265 at gmail.com>
# Date 1392935264 28800
# Node ID fe18d3e9e8ccca9ba618e1292e1a4e415e0d3547
# Parent  549f5bf10211da2b5b427d4ea0a87eb7ef20341b
Added better vui parameter checking

diff -r 549f5bf10211 -r fe18d3e9e8cc source/common/common.cpp
--- a/source/common/common.cpp	Thu Feb 20 14:47:41 2014 -0600
+++ b/source/common/common.cpp	Thu Feb 20 14:27:44 2014 -0800
@@ -549,6 +549,49 @@
     }
 
     CHECK(param->bEnableWavefront < 0, "WaveFrontSynchro cannot be negative");
+    CHECK((param->aspectRatioIdc < 0
+          || param->aspectRatioIdc > 16)
+         && param->aspectRatioIdc != 255,
+         "Sample Aspect Ratio must be 0-16 or 255");
+    CHECK(param->sarWidth < 0,
+         "Sample Aspect Ratio width must be greater than 0");
+    CHECK(param->sarHeight < 0,
+         "Sample Aspect Ratio height must be greater than 0");
+    CHECK(param->bEnableOverscanInfoPresentFlag < 0,
+         "Overscan must be show, crop or undef");
+    CHECK(param->videoFormat < 0 || param->videoFormat > 5,
+         "Video Format must be Component component,"
+         " pal, ntsc, secam, mac or undef");
+    CHECK(param->colorPrimaries < 0
+          || param->colorPrimaries > 9
+          || param->colorPrimaries == 3,
+         "Color Primaries must be undef, bt709, bt470m,"
+         " bt470bg, smpte170m, smpte240m, film or bt2020");
+    CHECK(param->transferCharacteristics < 0
+          || param->transferCharacteristics > 15
+          || param->transferCharacteristics == 3,
+         "Transfer Characteristics must be undef, bt709, bt470m, bt470bg,"
+         " smpte170m, smpte240m, linear, log100, log316, iec61966-2-4, bt1361e,"
+         " iec61966-2-1, bt2020-10 or bt2020-12");
+    CHECK(param->matrixCoeffs < 0
+          || param->matrixCoeffs > 10
+          || param->matrixCoeffs == 3,
+          "Matrix Coefficients must be undef, bt709, fcc, bt470bg, smpte170m,"
+          " smpte240m, GBR, YCgCo, bt2020nc or bt2020c");
+    CHECK(param->chromaSampleLocTypeTopField < 0
+          || param->chromaSampleLocTypeTopField > 5,
+          "Chroma Sample Location Type Top Field must be 0-5");
+    CHECK(param->chromaSampleLocTypeBottomField < 0
+          || param->chromaSampleLocTypeBottomField > 5,
+          "Chroma Sample Location Type Bottom Field must be 0-5");
+    CHECK(param->defDispWinLeftOffset < 0,
+          "Default Display Window Left Offset must be 0 or greater");
+    CHECK(param->defDispWinRightOffset < 0,
+          "Default Display Window Right Offset must be 0 or greater");
+    CHECK(param->defDispWinTopOffset < 0,
+          "Default Display Window Top Offset must be 0 or greater");
+    CHECK(param->defDispWinBottomOffset < 0,
+          "Default Display Window Bottom Offset must be 0 or greater");
     return check_failed;
 }
 
@@ -832,6 +875,8 @@
             p->bEnableOverscanInfoPresentFlag = bvalue;
             p->bEnableOverscanAppropriateFlag = bvalue;
         }
+        else
+            p->bEnableOverscanInfoPresentFlag = -1;
     }
     OPT("videoformat")
     {
@@ -849,6 +894,8 @@
             p->videoFormat = 4;
         else if (!strcmp(value, "undef"))
             p->videoFormat = 5;
+        else
+            p->videoFormat = -1;
     }
     OPT("range")
     {
@@ -877,6 +924,8 @@
             p->colorPrimaries = 8;
         else if (!strcmp(value, "bt2020"))
             p->colorPrimaries = 9;
+        else
+            p->colorPrimaries = -1;
     }
     OPT("transfer")
     {
@@ -911,6 +960,8 @@
             p->transferCharacteristics = 14;
         else if (!strcmp(value, "bt2020-12"))
             p->transferCharacteristics = 15;
+        else
+            p->transferCharacteristics = -1;
     }
     OPT("colormatrix")
     {
@@ -937,6 +988,8 @@
             p->matrixCoeffs = 9;
         else if (!strcmp(value, "bt2020c"))
             p->matrixCoeffs = 10;
+        else
+            p->matrixCoeffs = -1;
     }
     OPT("chromaloc")
     {


More information about the x265-devel mailing list