<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Oct 11, 2013 at 5:29 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 1381487332 -19800<br>
# Node ID 8c6bef70a1d3298d894e013ab57d070683a7d76d<br>
# Parent  c6d89dc62e191f56f63dbcb1781a6494da50a70d<br>
common: included x265_param_parser to set the Input parameters to the encoder<br>
<br>
diff -r c6d89dc62e19 -r 8c6bef70a1d3 source/common/common.cpp<br>
--- a/source/common/common.cpp  Fri Oct 11 01:47:53 2013 -0500<br>
+++ b/source/common/common.cpp  Fri Oct 11 15:58:52 2013 +0530<br>
@@ -421,3 +421,142 @@<br>
     fprintf(stderr, "\n");<br>
     fflush(stderr);<br>
 }<br>
+<br></blockquote><div><br></div><div>This is a public API method, so it must be extern "C"</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>
+{<br>
+    int b_error = 0;<br></blockquote><div>bError </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+    int value_was_null;<br></blockquote><div>valueWasNull </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+    if (!name)<br>
+        return X265_PARAM_BAD_NAME;<br>
+<br>
+    if (!strncmp(name, "no-", 3))<br>
+        value = "0";<br>
+    else<br>
+        value = "1";<br>
+<br>
+    value_was_null = !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 = atoi(value);<br>
+    OPT("wpp")<br>
+        p->bEnableWavefront = atoi(value);<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 = atoi(value);<br>
+    OPT("rect")<br>
+        p->bEnableRectInter = atoi(value);<br>
+    OPT("no-amp")<br>
+        p->bEnableAMP = atoi(value);<br>
+    OPT("amp")<br>
+        p->bEnableAMP = atoi(value);<br>
+    OPT("max-merge")<br>
+        p->maxNumMergeCand = (uint32_t)atoi(value);<br>
+    OPT("no-early-skip")<br>
+        p->bEnableEarlySkip = atoi(value);<br>
+    OPT("early-skip")<br>
+        p->bEnableEarlySkip = atoi(value);<br>
+    OPT("no-fast-cbf")<br>
+        p->bEnableCbfFastMode = atoi(value);<br>
+    OPT("fast-cbf")<br>
+        p->bEnableCbfFastMode = atoi(value);<br>
+    OPT("rdpenalty")<br>
+        p->rdPenalty = atoi(value);<br>
+    OPT("no-tskip")<br>
+        p->bEnableTransformSkip = atoi(value);<br>
+    OPT("tskip")<br>
+        p->bEnableTransformSkip = atoi(value);<br>
+    OPT("no-tskip-fast")<br>
+        p->bEnableTSkipFast = atoi(value);<br>
+    OPT("tskip-fast")<br>
+        p->bEnableTSkipFast = atoi(value);<br>
+    OPT("no-strong-intra-smoothing")<br>
+        p->bEnableStrongIntraSmoothing = atoi(value);<br>
+    OPT("strong-intra-smoothing")<br>
+        p->bEnableStrongIntraSmoothing = atoi(value);<br>
+    OPT("no-constrained-intra")<br>
+        p->bEnableConstrainedIntra = atoi(value);<br>
+    OPT("constrained-intra")<br>
+        p->bEnableConstrainedIntra = atoi(value);<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 = atoi(value);<br>
+    OPT("weightp")<br>
+        p->bEnableWeightedPred = atoi(value);<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 = atoi(value);<br>
+    OPT("signhide")<br>
+        p->bEnableSignHiding = atoi(value);<br>
+    OPT("no-lft")<br>
+        p->bEnableLoopFilter = atoi(value);<br>
+    OPT("lft")<br>
+        p->bEnableLoopFilter = atoi(value);<br>
+    OPT("no-sao")<br>
+        p->bEnableSAO = atoi(value);<br>
+    OPT("sao")<br>
+        p->bEnableSAO = atoi(value);<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 = atoi(value);<br>
+    OPT("ssim")<br>
+        p->bEnableSsim = atoi(value);<br>
+    OPT("no-psnr")<br>
+        p->bEnablePsnr = atoi(value);<br>
+    OPT("psnr")<br>
+        p->bEnablePsnr = atoi(value);<br>
+    OPT("hash")<br>
+        p->decodedPictureHashSEI = atoi(value);<br>
+    else<br>
+        return X265_PARAM_BAD_NAME;<br>
+#undef OPT<br>
+<br>
+    b_error |= value_was_null;<br>
+    return b_error ? X265_PARAM_BAD_VALUE : 0;<br>
+}<br>
\ No newline at end of file<br>
diff -r c6d89dc62e19 -r 8c6bef70a1d3 source/common/common.h<br>
--- a/source/common/common.h    Fri Oct 11 01:47:53 2013 -0500<br>
+++ b/source/common/common.h    Fri Oct 11 15:58:52 2013 +0530<br>
@@ -98,6 +98,8 @@<br>
 #define MAX_NAL_UNITS 5<br>
 #define MIN_FIFO_SIZE 1000<br>
 #define EMULATION_SIZE 1000<br></blockquote><div><br></div><div>These belong in x265.h</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+#define X265_PARAM_BAD_NAME -1<br>
+#define X265_PARAM_BAD_VALUE -2<br>
<br>
 #define CHECKED_MALLOC(var, type, count)\<br>
 {\<br>
@@ -139,5 +141,6 @@<br>
 int  x265_check_params(x265_param_t *param);<br>
 void x265_print_params(x265_param_t *param);<br>
 int x265_set_globals(x265_param_t *param);<br>
+int x265_param_parse( x265_param_t *p, const char *name, const char *value);<br></blockquote><div><br></div><div>this belongs in x265.h</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<br>
 #endif // ifndef X265_COMMON_H<br></blockquote><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
diff -r c6d89dc62e19 -r 8c6bef70a1d3 source/x265.cpp<br>
--- a/source/x265.cpp   Fri Oct 11 01:47:53 2013 -0500<br>
+++ b/source/x265.cpp   Fri Oct 11 15:58:52 2013 +0530<br>
@@ -301,6 +301,7 @@<br>
<br>
     bool parse(int argc, char **argv, x265_param_t* param)<br>
     {<br>
+        int b_error = 0;<br></blockquote><div>bError </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
         int help = 0;<br>
         int cpuid = 0;<br>
         uint32_t inputBitDepth = 8;<br>
@@ -312,8 +313,7 @@<br>
         const char *inputRes = NULL;<br>
<br>
         x265_param_default(param);<br>
-<br>
-        for (optind = 0;; )<br>
+        for (optind = 0;;)<br>
         {<br>
             int long_options_index = -1;<br>
             int c = getopt_long(argc, argv, short_options, long_options, &long_options_index);<br>
@@ -356,16 +356,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>
+                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>
+                b_error |= x265_param_parse(param, long_options[long_options_index].name, optarg);<br>
+<br>
+            if (b_error)<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></blockquote><div><br></div><div>I have conflicting opinions about this.  On the one hand this forces us to dog-food x265_param_parse() which is always a good thing, but this also disconnects options parsing from the online help.  We might as well remove x265opts.h and write a function just to generate help contents.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
             }<br>
         }<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>