[x265] [PATCH] Updated x265_param_parse to use parseName & a few nit fixes

dtyx265 at gmail.com dtyx265 at gmail.com
Tue Feb 25 06:19:55 CET 2014


# HG changeset patch
# User David T Yuen <dtyx265 at gmail.com>
# Date 1393305431 28800
# Node ID 40a442a5c7facb5b80e743661ed34f5286cbb475
# Parent  18894c99e1a71dc79e0ae55d4d4b8ed5d0c59c69
Updated x265_param_parse to use parseName & a few nit fixes

diff -r 18894c99e1a7 -r 40a442a5c7fa source/common/param.cpp
--- a/source/common/param.cpp	Mon Feb 24 19:19:27 2014 -0600
+++ b/source/common/param.cpp	Mon Feb 24 21:17:11 2014 -0800
@@ -155,7 +155,7 @@
     param->defDispWinRightOffset = 0;
     param->defDispWinTopOffset = 0;
     param->defDispWinBottomOffset = 0;
-    param->bEnableVuiTimingInfoPresentFlag = 0;
+    param->bEnableVuiTimingInfoPresentFlag = 1;
     param->bEnableVuiHrdParametersPresentFlag = 0;
     param->bEnableBitstreamRestrictionFlag = 0;
     param->bEnableSubPicHrdParamsPresentFlag = 0;
@@ -551,15 +551,13 @@
     OPT("sar")
     {
         p->bEnableVuiParametersPresentFlag = 1;
-        p->bEnableAspectRatioIdc = atobool(value);
-        p->aspectRatioIdc = atoi(value);
-    }
-    OPT("extended-sar")
-    {
-        p->bEnableVuiParametersPresentFlag = 1;
         p->bEnableAspectRatioIdc = 1;
-        p->aspectRatioIdc = X265_EXTENDED_SAR;
-        bError |= sscanf(value, "%dx%d", &p->sarWidth, &p->sarHeight) != 2;
+        p->aspectRatioIdc = parseName(value, x265_sar_names, bError);
+        if (bError)
+        {
+            p->aspectRatioIdc = X265_EXTENDED_SAR;
+            bError = sscanf(value, "%d:%d", &p->sarWidth, &p->sarHeight) != 2;
+        }
     }
     OPT("overscan")
     {
@@ -571,121 +569,43 @@
             p->bEnableOverscanInfoPresentFlag = 1;
             p->bEnableOverscanAppropriateFlag = 1;
         }
+        else if (!strcmp(value, "undef"))
+            p->bEnableOverscanInfoPresentFlag = 0;
         else
-            p->bEnableOverscanInfoPresentFlag = -1;
+            bError = true;
     }
     OPT("videoformat")
     {
         p->bEnableVuiParametersPresentFlag = 1;
         p->bEnableVideoSignalTypePresentFlag = 1;
-        if (!strcmp(value, "component"))
-            p->videoFormat = 0;
-        else if (!strcmp(value, "pal"))
-            p->videoFormat = 1;
-        else if (!strcmp(value, "ntsc"))
-            p->videoFormat = 2;
-        else if (!strcmp(value, "secam"))
-            p->videoFormat = 3;
-        else if (!strcmp(value, "mac"))
-            p->videoFormat = 4;
-        else if (!strcmp(value, "undef"))
-            p->videoFormat = 5;
-        else
-            p->videoFormat = -1;
+        p->videoFormat = parseName(value, x265_video_format_names, bError);
     }
     OPT("range")
     {
         p->bEnableVuiParametersPresentFlag = 1;
-        p->bEnableVideoSignalTypePresentFlag = atobool(value);
-        p->bEnableVideoFullRangeFlag = atobool(value);
+        p->bEnableVideoSignalTypePresentFlag = 1; 
+        p->bEnableVideoFullRangeFlag = parseName(value, x265_fullrange_names, bError);
     }
     OPT("colorprim")
     {
         p->bEnableVuiParametersPresentFlag = 1;
         p->bEnableVideoSignalTypePresentFlag = 1;
         p->bEnableColorDescriptionPresentFlag = 1;
-        if (!strcmp(value, "bt709"))
-            p->colorPrimaries = 1;
-        else if (!strcmp(value, "undef"))
-            p->colorPrimaries = 2;
-        else if (!strcmp(value, "bt470m"))
-            p->colorPrimaries = 4;
-        else if (!strcmp(value, "bt470bg"))
-            p->colorPrimaries = 5;
-        else if (!strcmp(value, "smpte170m"))
-            p->colorPrimaries = 6;
-        else if (!strcmp(value, "smpte240m"))
-            p->colorPrimaries = 7;
-        else if (!strcmp(value, "film"))
-            p->colorPrimaries = 8;
-        else if (!strcmp(value, "bt2020"))
-            p->colorPrimaries = 9;
-        else
-            p->colorPrimaries = -1;
+        p->colorPrimaries = parseName(value, x265_colorprim_names, bError);
     }
     OPT("transfer")
     {
         p->bEnableVuiParametersPresentFlag = 1;
         p->bEnableVideoSignalTypePresentFlag = 1;
         p->bEnableColorDescriptionPresentFlag = 1;
-        if (!strcmp(value, "bt709"))
-            p->transferCharacteristics = 1;
-        else if (!strcmp(value, "undef"))
-            p->transferCharacteristics = 2;
-        else if (!strcmp(value, "bt470m"))
-            p->transferCharacteristics = 4;
-        else if (!strcmp(value, "bt470bg"))
-            p->transferCharacteristics = 5;
-        else if (!strcmp(value, "smpte170m"))
-            p->transferCharacteristics = 6;
-        else if (!strcmp(value, "smpte240m"))
-            p->transferCharacteristics = 7;
-        else if (!strcmp(value, "linear"))
-            p->transferCharacteristics = 8;
-        else if (!strcmp(value, "log100"))
-            p->transferCharacteristics = 9;
-        else if (!strcmp(value, "log316"))
-            p->transferCharacteristics = 10;
-        else if (!strcmp(value, "iec61966-2-4"))
-            p->transferCharacteristics = 11;
-        else if (!strcmp(value, "bt1361e"))
-            p->transferCharacteristics = 12;
-        else if (!strcmp(value, "iec61966-2-1"))
-            p->transferCharacteristics = 13;
-        else if (!strcmp(value, "bt2020-10"))
-            p->transferCharacteristics = 14;
-        else if (!strcmp(value, "bt2020-12"))
-            p->transferCharacteristics = 15;
-        else
-            p->transferCharacteristics = -1;
+        p->transferCharacteristics = parseName(value, x265_transfer_names, bError);
     }
     OPT("colormatrix")
     {
         p->bEnableVuiParametersPresentFlag = 1;
         p->bEnableVideoSignalTypePresentFlag = 1;
         p->bEnableColorDescriptionPresentFlag = 1;
-        if (!strcmp(value, "GBR"))
-            p->matrixCoeffs = 0;
-        else if (!strcmp(value, "bt709"))
-            p->matrixCoeffs = 1;
-        else if (!strcmp(value, "undef"))
-            p->matrixCoeffs = 2;
-        else if (!strcmp(value, "fcc"))
-            p->matrixCoeffs = 4;
-        else if (!strcmp(value, "bt470bg"))
-            p->matrixCoeffs = 5;
-        else if (!strcmp(value, "smpte170m"))
-            p->matrixCoeffs = 6;
-        else if (!strcmp(value, "smpte240m"))
-            p->matrixCoeffs = 7;
-        else if (!strcmp(value, "YCgCo"))
-            p->matrixCoeffs = 8;
-        else if (!strcmp(value, "bt2020nc"))
-            p->matrixCoeffs = 9;
-        else if (!strcmp(value, "bt2020c"))
-            p->matrixCoeffs = 10;
-        else
-            p->matrixCoeffs = -1;
+        p->matrixCoeffs = parseName(value, x265_colmatrix_names, bError);
     }
     OPT("chromaloc")
     {
@@ -722,7 +642,7 @@
     OPT("nal-hrd")
     {
         p->bEnableVuiParametersPresentFlag = 1;
-        p->bEnableVuiTimingInfoPresentFlag = atobool(value);
+        p->bEnableVuiTimingInfoPresentFlag = 1;
         p->bEnableVuiHrdParametersPresentFlag = atobool(value);
     }
     OPT("bitstreamrestriction")
@@ -733,7 +653,7 @@
     OPT("subpichrd")
     {
         p->bEnableVuiParametersPresentFlag = 1;
-        p->bEnableVuiHrdParametersPresentFlag = atobool(value);
+        p->bEnableVuiHrdParametersPresentFlag = 1;
         p->bEnableSubPicHrdParamsPresentFlag = atobool(value);
     }
     else
@@ -870,7 +790,7 @@
     CHECK(param->aspectRatioIdc == X265_EXTENDED_SAR && param->sarHeight <= 0,
           "Sample Aspect Ratio height must be greater than 0");
     CHECK(param->videoFormat < 0 || param->videoFormat > 5,
-          "Video Format must be Component component,"
+          "Video Format must be component,"
           " pal, ntsc, secam, mac or undef");
     CHECK(param->colorPrimaries < 0
           || param->colorPrimaries > 9
diff -r 18894c99e1a7 -r 40a442a5c7fa source/x265.cpp
--- a/source/x265.cpp	Mon Feb 24 19:19:27 2014 -0600
+++ b/source/x265.cpp	Mon Feb 24 21:17:11 2014 -0800
@@ -154,11 +154,9 @@
     { "cutree",                    no_argument, NULL, 0 },
     { "vui",                  no_argument, NULL, 0 },
     { "sar",            required_argument, NULL, 0 },
-    { "extended-sar",   required_argument, NULL, 0 },
     { "overscan",       required_argument, NULL, 0 },
     { "videoformat",    required_argument, NULL, 0 },
-    { "range",                no_argument, NULL, 0 },
-    { "no-range",             no_argument, NULL, 0 },
+    { "range",          required_argument, NULL, 0 },
     { "colorprim",      required_argument, NULL, 0 },
     { "transfer",       required_argument, NULL, 0 },
     { "colormatrix",    required_argument, NULL, 0 },
@@ -371,21 +369,20 @@
     H0("   --hash                        Decoded Picture Hash SEI 0: disabled, 1: MD5, 2: CRC, 3: Checksum. Default %d\n", param->decodedPictureHashSEI);
     H0("\nVUI options:\n");
     H0("   --vui                         Add Video Useability Information with all fields to the SPS. Default %s\n", OPT(param->bEnableVuiParametersPresentFlag));
-    H0("   --sar                         Sample Aspect Ratio, the ratio of width to height of an individual pixel.\n");
-    H0("                                 Choose from 0=Unspecified, 1=1:1(\"square\"), 2=12:11, 3=10:11, 4=16:11,\n");
+    H0("   --sar <int:int|int>           Sample Aspect Ratio, the ratio of width to height of an individual pixel.\n");
+    H0("                                 Choose from 0=undef, 1=1:1(\"square\"), 2=12:11, 3=10:11, 4=16:11,\n");
     H0("                                 5=40:33, 6=24:11, 7=20:11, 8=32:11, 9=80:33, 10=18:11, 11=15:11,\n");
-    H0("                                 12=64:33, 13=160:99, 14=4:3, 15=3:2, 16=2:1. Default %d\n", param->aspectRatioIdc);
-    H0("   --extended-sar                Use a custom Sample Aspect Ratio,[WxH]\n");
-    H0("   --overscan <string>           Specify crop overscan setting from undef, show or crop. Default of undef\n");
-    H0("   --videoformat <string>        Specify video format from undef, component, pal, ntsc, secam, mac. Default of undef\n");
-    H0("   --[no-]range                       Specify black level and range of luma and chroma signals. Default of %s\n", OPT(param->bEnableVideoFullRangeFlag));
+    H0("                                 12=64:33, 13=160:99, 14=4:3, 15=3:2, 16=2:1 or custom ratio of <int:int>. Default %d\n", param->aspectRatioIdc);
+    H0("   --overscan <string>           Specify crop overscan setting from undef, show or crop. Default undef\n");
+    H0("   --videoformat <string>        Specify video format from undef, component, pal, ntsc, secam, mac. Default undef\n");
+    H0("   --range <string>              Specify black level and range of luma and chroma signals as full or limited Default limited\n");
     H0("   --colorprim <string>          Specify color primaries from undef, bt709, bt470m, bt470bg, smpte170m,\n");
-    H0("                                 smpte240m, film, bt2020. Default of undef\n");
+    H0("                                 smpte240m, film, bt2020. Default undef\n");
     H0("   --transfer <string>           Specify transfer characteristics from undef, bt709, bt470m, bt470bg, smpte170m,\n");
     H0("                                 smpte240m, linear, log100, log316, iec61966-2-4, bt1361e, iec61966-2-1,\n");
-    H0("                                 bt2020-10, bt2020-12. Default of undef\n");
+    H0("                                 bt2020-10, bt2020-12. Default undef\n");
     H0("   --colormatrix <string>        Specify color matrix setting from undef, bt709, fcc, bt470bg, smpte170m,\n");
-    H0("                                 smpte240m, GBR, YCgCo, bt2020nc, bt2020c\n");
+    H0("                                 smpte240m, GBR, YCgCo, bt2020nc, bt2020c. Default undef\n");
     H0("   --chromaloc <integer>         Specify chroma sample location (0 to 5). Default of %d\n", param->chromaSampleLocTypeTopField);
     H0("   --[no-]fieldseq               Specify that pictures are fields and an SEI timing message\n");
     H0("                                 will be added to every access unit. Default %s\n", OPT(param->bEnableFieldSeqFlag));
diff -r 18894c99e1a7 -r 40a442a5c7fa source/x265.h
--- a/source/x265.h	Mon Feb 24 19:19:27 2014 -0600
+++ b/source/x265.h	Mon Feb 24 21:17:11 2014 -0800
@@ -184,8 +184,6 @@
 #define X265_CPU_NEON            0x0000002  /* ARM NEON */
 #define X265_CPU_FAST_NEON_MRC   0x0000004  /* Transfer from NEON to ARM register is fast (Cortex-A9) */
 
-static const char * const x265_motion_est_names[] = { "dia", "hex", "umh", "star", "full", 0 };
-
 #define X265_MAX_SUBPEL_LEVEL   7
 
 /* Log level */
@@ -234,8 +232,6 @@
 
 #define X265_EXTENDED_SAR       255 /* aspect ratio explicitly specified as width:height */
 
-static const char * const x265_source_csp_names[] = { "i400", "i420", "i422", "i444", "nv12", "nv16", 0 };
-
 typedef struct
 {
     int planes;
@@ -279,6 +275,35 @@
     /* new statistic member variables must be added below this line */
 } x265_stats;
 
+static const char * const x265_motion_est_names[] = { "dia", "hex", "umh",
+                                                      "star", "full", 0 };
+static const char * const x265_source_csp_names[] = { "i400", "i420", "i422",
+                                                      "i444", "nv12", "nv16", 0 };
+static const char * const x265_video_format_names[] = { "component", "pal",
+                                                        "ntsc", "secam", "mac",
+                                                        "undef", 0 };
+static const char * const x265_fullrange_names[] = { "limited", "full", 0 };
+static const char * const x265_colorprim_names[] = { "", "bt709", "undef", "",
+                                                     "bt470m", "bt470bg",
+                                                     "smpte170m", "smpte240m",
+                                                     "film", "bt2020", 0 };
+static const char * const x265_transfer_names[] = { "", "bt709", "undef", "",
+                                                    "bt470m", "bt470bg",
+                                                    "smpte170m", "smpte240m",
+                                                    "linear", "log100",
+                                                    "log316", "iec61966-2-4",
+                                                    "bt1361e", "iec61966-2-1",
+                                                    "bt2020-10", "bt2020-12", 0 };
+static const char * const x265_colmatrix_names[] = { "GBR", "bt709", "undef",
+                                                     "", "fcc", "bt470bg",
+                                                     "smpte170m", "smpte240m",
+                                                     "YCgCo", "bt2020nc",
+                                                     "bt2020c", 0 };
+static const char * const x265_sar_names[] = { "undef", "1:1", "12:11", "10:11",
+                                               "16:11", "40:33", "24:11", "20:11",
+                                               "32:11", "80:33", "18:11", "15:11",
+                                               "64:33", "160:99", "4:3", "3:2", "2:1" };
+
 /* x265 input parameters
  *
  * For version safety you may use x265_param_alloc/free() to manage the


More information about the x265-devel mailing list