<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Oct 16, 2013 at 1:13 AM, Gopu Govindaswamy <span dir="ltr"><<a href="mailto:gopu@multicorewareinc.com" target="_blank">gopu@multicorewareinc.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"># HG changeset patch<br>
# User Gopu Govindaswamy <<a href="mailto:gopu@multicorewareinc.com">gopu@multicorewareinc.com</a>><br>
# Date 1381904011 -19800<br>
# Node ID de3b1f54873c23189284f63f471d4c95440bacc6<br>
# Parent  09c0e0209d84313a49a15ac3806f03223a1546de<br>
common: parse the command line arguments and set the Input parameters to the encoder<br></blockquote><div><br></div><div>queued with some changes described below</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

diff -r 09c0e0209d84 -r de3b1f54873c source/common/common.cpp<br>
--- a/source/common/common.cpp  Wed Oct 16 10:11:23 2013 +0530<br>
+++ b/source/common/common.cpp  Wed Oct 16 11:43:31 2013 +0530<br>
@@ -420,3 +420,149 @@<br>
     fprintf(stderr, "\n");<br>
     fflush(stderr);<br>
 }<br>
+<br>
+extern "C"<br>
+int x265_param_parse(x265_param_t *p, const char *name, const char *value)<br>
+{<br>
+    int berror = 0;<br>
+    int valuewasnull;<br>
+<br>
+    /* Enable or Disable - default is Enable */<br>
+    int bvalue = 1;<br>
+<br>
+    if (!name)<br>
+        return X265_PARAM_BAD_NAME;<br>
+<br>
+    if (!value)<br>
+        value = "1";<br>
+<br>
+    if (!strncmp(name, "no-", 3))<br>
+        bvalue = 0;<br></blockquote><div><br></div><div>x264's version would increment name by 3 vars here so there was no need to have "amp" and "no-amp" in the table below.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

+    else<br>
+        bvalue = 1;<br>
+<br>
+    valuewasnull = !value;<br>
+<br>
+#define OPT(STR) else if (!strcmp( name, STR))<br>
+    if (0);<br>
+    OPT("fps")<br>
+        p->frameRate = atoi(value);<br>
+    OPT("threads")<br>
+        p->poolNumThreads = atoi(value);<br>
+    OPT("frame-threads")<br>
+        p->frameNumThreads = atoi(value);<br>
+    OPT("log")<br>
+        p->logLevel = atoi(value);<br>
+    OPT("no-wpp")<br>
+        p->bEnableWavefront = bvalue;<br>
+    OPT("wpp")<br>
+        p->bEnableWavefront = bvalue;<br>
+    OPT("ctu")<br>
+        p->maxCUSize =(uint32_t) atoi(value);<br>
+    OPT("tu-intra-depth")<br>
+        p->tuQTMaxIntraDepth = (uint32_t) atoi(value);<br>
+    OPT("tu-inter-depth")<br>
+        p->tuQTMaxInterDepth =(uint32_t) atoi(value);<br>
+    OPT("me")<br>
+        p->searchMethod = atoi(value);<br>
+    OPT("subme")<br>
+        p->subpelRefine = atoi(value);<br>
+    OPT("merange")<br>
+        p->searchRange = atoi(value);<br>
+    OPT("no-rect")<br>
+        p->bEnableRectInter = bvalue;<br>
+    OPT("rect")<br>
+        p->bEnableRectInter = bvalue;<br>
+    OPT("no-amp")<br>
+        p->bEnableAMP = bvalue;<br>
+    OPT("amp")<br>
+        p->bEnableAMP = bvalue;<br>
+    OPT("max-merge")<br>
+        p->maxNumMergeCand = (uint32_t)atoi(value);<br>
+    OPT("no-early-skip")<br>
+        p->bEnableEarlySkip = bvalue;<br>
+    OPT("early-skip")<br>
+        p->bEnableEarlySkip = bvalue;<br>
+    OPT("no-fast-cbf")<br>
+        p->bEnableCbfFastMode = bvalue;<br>
+    OPT("fast-cbf")<br>
+        p->bEnableCbfFastMode = bvalue;<br>
+    OPT("rdpenalty")<br>
+        p->rdPenalty = atoi(value);<br>
+    OPT("no-tskip")<br>
+        p->bEnableTransformSkip = bvalue;<br>
+    OPT("tskip")<br>
+        p->bEnableTransformSkip = bvalue;<br>
+    OPT("no-tskip-fast")<br>
+        p->bEnableTSkipFast = bvalue;<br>
+    OPT("tskip-fast")<br>
+        p->bEnableTSkipFast = bvalue;<br>
+    OPT("no-strong-intra-smoothing")<br>
+        p->bEnableStrongIntraSmoothing = bvalue;<br>
+    OPT("strong-intra-smoothing")<br>
+        p->bEnableStrongIntraSmoothing = bvalue;<br>
+    OPT("no-constrained-intra")<br>
+        p->bEnableConstrainedIntra = bvalue;<br>
+    OPT("constrained-intra")<br>
+        p->bEnableConstrainedIntra = bvalue;<br>
+    OPT("refresh")<br>
+        p->decodingRefreshType = atoi(value);<br>
+    OPT("keyint")<br>
+        p->keyframeMax = atoi(value);<br>
+    OPT("rc-lookahead")<br>
+        p->lookaheadDepth = atoi(value);<br>
+    OPT("bframes")<br>
+        p->bframes = atoi(value);<br>
+    OPT("bframe-bias")<br>
+        p->bFrameBias = atoi(value);<br>
+    OPT("b-adapt")<br>
+        p->bFrameAdaptive = atoi(value);<br>
+    OPT("ref")<br>
+        p->maxNumReferences = atoi(value);<br>
+    OPT("no-weightp")<br>
+        p->bEnableWeightedPred = bvalue;<br>
+    OPT("weightp")<br>
+        p->bEnableWeightedPred = bvalue;<br>
+    OPT("bitrate")<br>
+        p->rc.bitrate = atoi(value);<br>
+    OPT("qp")<br>
+        p->rc.qp = atoi(value);<br>
+    OPT("cbqpoffs")<br>
+        p->cbQpOffset = atoi(value);<br>
+    OPT("crqpoffs")<br>
+        p->crQpOffset = atoi(value);<br>
+    OPT("rd")<br>
+        p->bRDLevel = atoi(value);<br>
+    OPT("no-signhide")<br>
+        p->bEnableSignHiding = bvalue;<br>
+    OPT("signhide")<br>
+        p->bEnableSignHiding = bvalue;<br>
+    OPT("no-lft")<br>
+        p->bEnableLoopFilter = bvalue;<br>
+    OPT("lft")<br>
+        p->bEnableLoopFilter = bvalue;<br>
+    OPT("no-sao")<br>
+        p->bEnableSAO = bvalue;<br>
+    OPT("sao")<br>
+        p->bEnableSAO = bvalue;<br>
+    OPT("sao-lcu-bounds")<br>
+        p->saoLcuBoundary = atoi(value);<br>
+    OPT("sao-lcu-opt")<br>
+        p->saoLcuBasedOptimization = atoi(value);<br>
+    OPT("no-ssim")<br>
+        p->bEnableSsim = bvalue;<br>
+    OPT("ssim")<br>
+        p->bEnableSsim = bvalue;<br>
+    OPT("no-psnr")<br>
+        p->bEnablePsnr = atoi(value);<br>
+    OPT("psnr")<br>
+        p->bEnablePsnr = bvalue;<br>
+    OPT("hash")<br>
+        p->decodedPictureHashSEI = atoi(value);<br>
+    else<br>
+        return X265_PARAM_BAD_NAME;<br>
+#undef OPT<br>
+<br>
+    berror |= valuewasnull;<br>
+    return berror ? X265_PARAM_BAD_VALUE : 0;<br>
+}<br>
diff -r 09c0e0209d84 -r de3b1f54873c source/x265.cpp<br>
--- a/source/x265.cpp   Wed Oct 16 10:11:23 2013 +0530<br>
+++ b/source/x265.cpp   Wed Oct 16 11:43:31 2013 +0530<br>
@@ -290,6 +290,7 @@<br>
<br>
     bool parse(int argc, char **argv, x265_param_t* param)<br>
     {<br>
+        int berror = 0;<br>
         int help = 0;<br>
         int cpuid = 0;<br>
         uint32_t inputBitDepth = 8;<br>
@@ -345,16 +346,30 @@<br>
                     log(X265_LOG_WARNING, "short option '%c' unrecognized\n", c);<br>
                     return true;<br>
                 }<br>
-#define HELP(message)<br>
-#define STROPT(longname, var, argreq, flag, helptext) \<br>
-    else if (!strcmp(long_options[long_options_index].name, longname)) \<br>
-        (var) = optarg;<br>
-#define OPT(longname, var, argreq, flag, helptext) \<br>
-    else if (!strcmp(long_options[long_options_index].name, longname)) \<br>
-        (var) = (argreq == no_argument) ? (strncmp(longname, "no-", 3) ? 1 : 0) : atoi(optarg);<br>
-#include "x265opts.h"<br>
+#define OPT(longname) \<br>
+    else if (!strcmp(long_options[long_options_index].name, longname))<br>
+<br>
+            if (0);<br>
+                OPT("frames") this->framesToBeEncoded = (uint32_t)atoi(optarg);<br>
+                OPT("no-progress") this->bProgress = (!strncmp(long_options[long_options_index].name, "no-", 3) ? 0 : 1);<br></blockquote><div>this->bProgress = false; </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

+                OPT("frame-skip") this->frameSkip = (uint32_t)atoi(optarg);<br>
+                OPT("csv") csvfn = optarg;<br>
+                OPT("output") bitstreamfn = optarg;<br>
+                OPT("input") inputfn = optarg;<br>
+                OPT("recon") reconfn = optarg;<br>
+                OPT("input-depth") inputBitDepth = (uint32_t)atoi(optarg);<br>
+                OPT("recon-depth") outputBitDepth = (uint32_t)atoi(optarg);<br>
+                OPT("input-res") inputRes = optarg;<br>
+            else<br>
+                berror |= x265_param_parse(param, long_options[long_options_index].name, optarg);<br>
+<br>
+            if (berror)<br>
+            {<br>
+                const char *name = long_options_index > 0 ? long_options[long_options_index].name : argv[optind-2];<br>
+                log(X265_LOG_ERROR, "invalid argument: %s = %s\n", name, optarg);<br>
+                return true;<br>
+            }<br>
 #undef OPT<br>
-#undef STROPT<br>
             }<br>
         }<br>
<br>
diff -r 09c0e0209d84 -r de3b1f54873c source/<a href="http://x265.def.in" target="_blank">x265.def.in</a><br>
--- a/source/<a href="http://x265.def.in" target="_blank">x265.def.in</a>        Wed Oct 16 10:11:23 2013 +0530<br>
+++ b/source/<a href="http://x265.def.in" target="_blank">x265.def.in</a>        Wed Oct 16 11:43:31 2013 +0530<br>
@@ -2,6 +2,7 @@<br>
 x265_encoder_open_${X265_BUILD}<br>
 x265_setup_primitives<br>
 x265_param_default<br>
+x265_param_parse<br>
 x265_picture_init<br>
 x265_param_apply_profile<br>
 x265_max_bit_depth<br>
diff -r 09c0e0209d84 -r de3b1f54873c source/x265.h<br>
--- a/source/x265.h     Wed Oct 16 10:11:23 2013 +0530<br>
+++ b/source/x265.h     Wed Oct 16 11:43:31 2013 +0530<br>
@@ -191,6 +191,8 @@<br>
 static const char * const x265_motion_est_names[] = { "dia", "hex", "umh", "star", "full", 0 };<br>
<br>
 #define X265_MAX_SUBPEL_LEVEL   7<br>
+#define X265_PARAM_BAD_NAME -1<br>
+#define X265_PARAM_BAD_VALUE -2<br>
<br>
 /* Log level */<br>
 #define X265_LOG_NONE          (-1)<br>
@@ -410,6 +412,10 @@<br>
  *      close an encoder handler.  Optionally return the global PSNR value (6 * psnrY + psnrU + psnrV) / 8 */<br>
 void x265_encoder_close(x265_t *, double *globalPsnr);<br>
<br>
+/* x265_param_parse:<br>
+ *     parse the command line arguments and set the Input parameters to the encoder */<br></blockquote><div><br></div><div>I adapted x264's much more detailed comment</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

+int x265_param_parse( x265_param_t *p, const char *name, const char *value);<br></blockquote><div><br></div><div>white-space </div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
 /***<br>
  * Release library static allocations<br>
  */<br>
_______________________________________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org">x265-devel@videolan.org</a><br>
<a href="https://mailman.videolan.org/listinfo/x265-devel" target="_blank">https://mailman.videolan.org/listinfo/x265-devel</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Steve Borho
</div></div>