[x265] [PATCH 1 of 3 STABLE] cli: derive output bit depth from --profile if --output-depth is not specified

Steve Borho steve at borho.org
Wed Aug 19 07:44:27 CEST 2015


# HG changeset patch
# User Steve Borho <steve at borho.org>
# Date 1439958158 -19800
#      Wed Aug 19 09:52:38 2015 +0530
# Branch stable
# Node ID d24c033d6fe5b43a967ea15581ee43187eb3b23a
# Parent  ee04f391b7bc446d5b05f4b155443b053a922064
cli: derive output bit depth from --profile if --output-depth is not specified

Closes #156.

diff -r ee04f391b7bc -r d24c033d6fe5 doc/reST/cli.rst
--- a/doc/reST/cli.rst	Tue Aug 18 09:46:44 2015 +0530
+++ b/doc/reST/cli.rst	Wed Aug 19 09:52:38 2015 +0530
@@ -439,6 +439,9 @@
 	libx265_main12 for a 12bit encoder (EXPERIMENTAL), with the
 	same API version as the linked libx265.
 
+	If the output depth is not specified but :option:`--profile` is
+	specified, the output depth will be derived from the profile name.
+
 	**CLI ONLY**
 
 Profile, Level, Tier
@@ -484,6 +487,9 @@
 	their param structure. Any changes made to the param structure after
 	this call might make the encode non-compliant.
 
+	The CLI application will derive the output bit depth from the
+	profile name if :option:`--output-depth` is not specified.
+
 .. note::
 
 	All 12bit presets are extremely unstable, do not use them yet.
diff -r ee04f391b7bc -r d24c033d6fe5 source/x265.cpp
--- a/source/x265.cpp	Tue Aug 18 09:46:44 2015 +0530
+++ b/source/x265.cpp	Wed Aug 19 09:52:38 2015 +0530
@@ -199,10 +199,23 @@
             tune = optarg;
         else if (c == 'D')
             outputBitDepth = atoi(optarg);
+        else if (c == 'P')
+            profile = optarg;
         else if (c == '?')
             bShowHelp = true;
     }
 
+    if (!outputBitDepth && profile)
+    {
+        /* try to derive the output bit depth from the requested profile */
+        if (strstr(profile, "10"))
+            outputBitDepth = 10;
+        else if (strstr(profile, "12"))
+            outputBitDepth = 12;
+        else
+            outputBitDepth = 8;
+    }
+
     api = x265_api_get(outputBitDepth);
     if (!api)
     {
@@ -292,9 +305,9 @@
             OPT("dither") this->bDither = true;
             OPT("recon-depth") reconFileBitDepth = (uint32_t)x265_atoi(optarg, bError);
             OPT("y4m") this->bForceY4m = true;
-            OPT("profile") profile = optarg; /* handled last */
-            OPT("preset") /* handled above */;
-            OPT("tune")   /* handled above */;
+            OPT("profile") /* handled above */;
+            OPT("preset")  /* handled above */;
+            OPT("tune")    /* handled above */;
             OPT("output-depth")   /* handled above */;
             OPT("recon-y4m-exec") reconPlayCmd = optarg;
             OPT("qpfile")


More information about the x265-devel mailing list