[x265] [PATCH] common: included x265_param_parser to set the Input parameters to the encoder
Steve Borho
steve at borho.org
Fri Oct 11 22:57:51 CEST 2013
On Fri, Oct 11, 2013 at 5:29 AM, Gopu Govindaswamy <
gopu at multicorewareinc.com> wrote:
> # HG changeset patch
> # User Gopu Govindaswamy <gopu at multicorewareinc.com>
> # Date 1381487332 -19800
> # Node ID 8c6bef70a1d3298d894e013ab57d070683a7d76d
> # Parent c6d89dc62e191f56f63dbcb1781a6494da50a70d
> common: included x265_param_parser to set the Input parameters to the
> encoder
>
> diff -r c6d89dc62e19 -r 8c6bef70a1d3 source/common/common.cpp
> --- a/source/common/common.cpp Fri Oct 11 01:47:53 2013 -0500
> +++ b/source/common/common.cpp Fri Oct 11 15:58:52 2013 +0530
> @@ -421,3 +421,142 @@
> fprintf(stderr, "\n");
> fflush(stderr);
> }
> +
>
This is a public API method, so it must be extern "C"
> +int x265_param_parse(x265_param_t *p, const char *name, const char *value)
> +{
> + int b_error = 0;
>
bError
> + int value_was_null;
>
valueWasNull
> +
> + if (!name)
> + return X265_PARAM_BAD_NAME;
> +
> + if (!strncmp(name, "no-", 3))
> + value = "0";
> + else
> + value = "1";
> +
> + value_was_null = !value;
> +
> +#define OPT(STR) else if(!strcmp( name, STR))
> + if (0);
> + OPT("fps")
> + p->frameRate = atoi(value);
> + OPT("threads")
> + p->poolNumThreads = atoi(value);
> + OPT("frame-threads")
> + p->frameNumThreads = atoi(value);
> + OPT("log")
> + p->logLevel = atoi(value);
> + OPT("no-wpp")
> + p->bEnableWavefront = atoi(value);
> + OPT("wpp")
> + p->bEnableWavefront = atoi(value);
> + OPT("ctu")
> + p->maxCUSize =(uint32_t) atoi(value);
> + OPT("tu-intra-depth")
> + p->tuQTMaxIntraDepth = (uint32_t) atoi(value);
> + OPT("tu-inter-depth")
> + p->tuQTMaxInterDepth =(uint32_t) atoi(value);
> + OPT("me")
> + p->searchMethod = atoi(value);
> + OPT("subme")
> + p->subpelRefine = atoi(value);
> + OPT("merange")
> + p->searchRange = atoi(value);
> + OPT("no-rect")
> + p->bEnableRectInter = atoi(value);
> + OPT("rect")
> + p->bEnableRectInter = atoi(value);
> + OPT("no-amp")
> + p->bEnableAMP = atoi(value);
> + OPT("amp")
> + p->bEnableAMP = atoi(value);
> + OPT("max-merge")
> + p->maxNumMergeCand = (uint32_t)atoi(value);
> + OPT("no-early-skip")
> + p->bEnableEarlySkip = atoi(value);
> + OPT("early-skip")
> + p->bEnableEarlySkip = atoi(value);
> + OPT("no-fast-cbf")
> + p->bEnableCbfFastMode = atoi(value);
> + OPT("fast-cbf")
> + p->bEnableCbfFastMode = atoi(value);
> + OPT("rdpenalty")
> + p->rdPenalty = atoi(value);
> + OPT("no-tskip")
> + p->bEnableTransformSkip = atoi(value);
> + OPT("tskip")
> + p->bEnableTransformSkip = atoi(value);
> + OPT("no-tskip-fast")
> + p->bEnableTSkipFast = atoi(value);
> + OPT("tskip-fast")
> + p->bEnableTSkipFast = atoi(value);
> + OPT("no-strong-intra-smoothing")
> + p->bEnableStrongIntraSmoothing = atoi(value);
> + OPT("strong-intra-smoothing")
> + p->bEnableStrongIntraSmoothing = atoi(value);
> + OPT("no-constrained-intra")
> + p->bEnableConstrainedIntra = atoi(value);
> + OPT("constrained-intra")
> + p->bEnableConstrainedIntra = atoi(value);
> + OPT("refresh")
> + p->decodingRefreshType = atoi(value);
> + OPT("keyint")
> + p->keyframeMax = atoi(value);
> + OPT("rc-lookahead")
> + p->lookaheadDepth = atoi(value);
> + OPT("bframes")
> + p->bframes = atoi(value);
> + OPT("bframe-bias")
> + p->bFrameBias = atoi(value);
> + OPT("b-adapt")
> + p->bFrameAdaptive = atoi(value);
> + OPT("ref")
> + p->maxNumReferences = atoi(value);
> + OPT("no-weightp")
> + p->bEnableWeightedPred = atoi(value);
> + OPT("weightp")
> + p->bEnableWeightedPred = atoi(value);
> + OPT("bitrate")
> + p->rc.bitrate = atoi(value);
> + OPT("qp")
> + p->rc.qp = atoi(value);
> + OPT("cbqpoffs")
> + p->cbQpOffset = atoi(value);
> + OPT("crqpoffs")
> + p->crQpOffset = atoi(value);
> + OPT("rd")
> + p->bRDLevel = atoi(value);
> + OPT("no-signhide")
> + p->bEnableSignHiding = atoi(value);
> + OPT("signhide")
> + p->bEnableSignHiding = atoi(value);
> + OPT("no-lft")
> + p->bEnableLoopFilter = atoi(value);
> + OPT("lft")
> + p->bEnableLoopFilter = atoi(value);
> + OPT("no-sao")
> + p->bEnableSAO = atoi(value);
> + OPT("sao")
> + p->bEnableSAO = atoi(value);
> + OPT("sao-lcu-bounds")
> + p->saoLcuBoundary = atoi(value);
> + OPT("sao-lcu-opt")
> + p->saoLcuBasedOptimization = atoi(value);
> + OPT("no-ssim")
> + p->bEnableSsim = atoi(value);
> + OPT("ssim")
> + p->bEnableSsim = atoi(value);
> + OPT("no-psnr")
> + p->bEnablePsnr = atoi(value);
> + OPT("psnr")
> + p->bEnablePsnr = atoi(value);
> + OPT("hash")
> + p->decodedPictureHashSEI = atoi(value);
> + else
> + return X265_PARAM_BAD_NAME;
> +#undef OPT
> +
> + b_error |= value_was_null;
> + return b_error ? X265_PARAM_BAD_VALUE : 0;
> +}
> \ No newline at end of file
> diff -r c6d89dc62e19 -r 8c6bef70a1d3 source/common/common.h
> --- a/source/common/common.h Fri Oct 11 01:47:53 2013 -0500
> +++ b/source/common/common.h Fri Oct 11 15:58:52 2013 +0530
> @@ -98,6 +98,8 @@
> #define MAX_NAL_UNITS 5
> #define MIN_FIFO_SIZE 1000
> #define EMULATION_SIZE 1000
>
These belong in x265.h
> +#define X265_PARAM_BAD_NAME -1
> +#define X265_PARAM_BAD_VALUE -2
>
> #define CHECKED_MALLOC(var, type, count)\
> {\
> @@ -139,5 +141,6 @@
> int x265_check_params(x265_param_t *param);
> void x265_print_params(x265_param_t *param);
> int x265_set_globals(x265_param_t *param);
> +int x265_param_parse( x265_param_t *p, const char *name, const char
> *value);
>
this belongs in x265.h
>
> #endif // ifndef X265_COMMON_H
>
diff -r c6d89dc62e19 -r 8c6bef70a1d3 source/x265.cpp
> --- a/source/x265.cpp Fri Oct 11 01:47:53 2013 -0500
> +++ b/source/x265.cpp Fri Oct 11 15:58:52 2013 +0530
> @@ -301,6 +301,7 @@
>
> bool parse(int argc, char **argv, x265_param_t* param)
> {
> + int b_error = 0;
>
bError
> int help = 0;
> int cpuid = 0;
> uint32_t inputBitDepth = 8;
> @@ -312,8 +313,7 @@
> const char *inputRes = NULL;
>
> x265_param_default(param);
> -
> - for (optind = 0;; )
> + for (optind = 0;;)
> {
> int long_options_index = -1;
> int c = getopt_long(argc, argv, short_options, long_options,
> &long_options_index);
> @@ -356,16 +356,30 @@
> log(X265_LOG_WARNING, "short option '%c'
> unrecognized\n", c);
> return true;
> }
> -#define HELP(message)
> -#define STROPT(longname, var, argreq, flag, helptext) \
> - else if (!strcmp(long_options[long_options_index].name, longname)) \
> - (var) = optarg;
> -#define OPT(longname, var, argreq, flag, helptext) \
> - else if (!strcmp(long_options[long_options_index].name, longname)) \
> - (var) = (argreq == no_argument) ? (strncmp(longname, "no-", 3) ?
> 1 : 0) : atoi(optarg);
> -#include "x265opts.h"
> +#define OPT(longname) \
> + else if (!strcmp(long_options[long_options_index].name, longname))
> +
> + if (0);
> + OPT("frames") this->framesToBeEncoded =
> (uint32_t)atoi(optarg);
> + OPT("no-progress") this->bProgress =
> (!strncmp(long_options[long_options_index].name, "no-", 3) ? 0 : 1);
> + OPT("frame-skip") this->frameSkip =
> (uint32_t)atoi(optarg);
> + OPT("csv") csvfn = optarg;
> + OPT("output") bitstreamfn = optarg;
> + OPT("input") inputfn = optarg;
> + OPT("recon") reconfn = optarg;
> + OPT("input-depth") inputBitDepth = (uint32_t)atoi(optarg);
> + OPT("recon-depth") outputBitDepth =
> (uint32_t)atoi(optarg);
> + OPT("input-res") inputRes = optarg;
> + else
> + b_error |= x265_param_parse(param,
> long_options[long_options_index].name, optarg);
> +
> + if (b_error)
> + {
> + const char *name = long_options_index > 0 ?
> long_options[long_options_index].name : argv[optind-2];
> + log(X265_LOG_ERROR, "invalid argument: %s = %s\n", name,
> optarg);
> + return true;
> + }
> #undef OPT
> -#undef STROPT
>
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.
> }
> }
>
> _______________________________________________
> x265-devel mailing list
> x265-devel at videolan.org
> https://mailman.videolan.org/listinfo/x265-devel
>
--
Steve Borho
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20131011/468a8244/attachment.html>
More information about the x265-devel
mailing list