[x265] [PATCH 1 of 2] param2string: increase buffer size, do not store file names

Ashok Kumar Mishra ashok at multicorewareinc.com
Mon Jan 15 20:14:33 CET 2018


On Sat, Jan 13, 2018 at 5:23 AM, Ma0 <mateuszb at poczta.onet.pl> wrote:

> # HG changeset patch
> # User Ma0 <mateuszb at poczta.onet.pl>
> # Date 1515799544 -3600
> #      Sat Jan 13 00:25:44 2018 +0100
> # Node ID 6f4c949761c446334245d72204a3cd7345b36a9f
> # Parent  2f3c4158cf3553030920708271bc43cdc79932a3
> param2string: increase buffer size, do not store file names
>
> diff -r 2f3c4158cf35 -r 6f4c949761c4 source/common/param.cpp
> --- a/source/common/param.cpp   Thu Jan 04 12:37:01 2018 +0530
> +++ b/source/common/param.cpp   Sat Jan 13 00:25:44 2018 +0100
> @@ -1530,8 +1530,14 @@
>  char *x265_param2string(x265_param* p, int padx, int pady)
>  {
>      char *buf, *s;
> +    int bufSize = 4000 + p->rc.zoneCount * 64;
>

bufSize can be replaced with macro MAXPARAMSIZE.

>
> -    buf = s = X265_MALLOC(char, MAXPARAMSIZE);
> +    if (p->numaPools)
> +        bufSize += strlen(p->numaPools);
> +    if (p->masteringDisplayColorVolume)
> +        bufSize += strlen(p->masteringDisplayColorVolume);
>

We have other string parameters like csv file name, analysis save and load
etc., why adding string length of only two parameters in buffer size?


> +
> +    buf = s = X265_MALLOC(char, bufSize);
>      if (!buf)
>          return NULL;
>
> @@ -1549,7 +1555,7 @@
>      BOOL(p->bEnableSsim, "ssim");
>      s += sprintf(s, " log-level=%d", p->logLevel);
>      if (p->csvfn)
> -        s += sprintf(s, " csvfn=%s csv-log-level=%d", p->csvfn,
> p->csvLogLevel);
> +        s += sprintf(s, " csv csv-log-level=%d", p->csvLogLevel);
>      s += sprintf(s, " bitdepth=%d", p->internalBitDepth);
>      s += sprintf(s, " input-csp=%d", p->internalCsp);
>      s += sprintf(s, " fps=%u/%u", p->fpsNum, p->fpsDenom);
> @@ -1722,8 +1728,10 @@
>      BOOL(p->bEmitHDRSEI, "hdr");
>      BOOL(p->bHDROpt, "hdr-opt");
>      BOOL(p->bDhdr10opt, "dhdr10-opt");
> -    s += sprintf(s, " analysis-save=%s", p->analysisSave);
> -    s += sprintf(s, " analysis-load=%s", p->analysisLoad);
> +    if (p->analysisSave)
> +        s += sprintf(s, " analysis-save");
> +    if (p->analysisLoad)
> +        s += sprintf(s, " analysis-load");
>      s += sprintf(s, " analysis-reuse-level=%d", p->analysisReuseLevel);
>      s += sprintf(s, " scale-factor=%d", p->scaleFactor);
>      s += sprintf(s, " refine-intra=%d", p->intraRefine);
> diff -r 2f3c4158cf35 -r 6f4c949761c4 source/common/param.h
> --- a/source/common/param.h     Thu Jan 04 12:37:01 2018 +0530
> +++ b/source/common/param.h     Sat Jan 13 00:25:44 2018 +0100
> @@ -53,8 +53,6 @@
>  int x265_param_parse(x265_param *p, const char *name, const char *value);
>  #define PARAM_NS X265_NS
>  #endif
> -
> -#define MAXPARAMSIZE 2000
>  }
>
>  #endif // ifndef X265_PARAM_H
> _______________________________________________
> x265-devel mailing list
> x265-devel at videolan.org
> https://mailman.videolan.org/listinfo/x265-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20180116/f8cc7a35/attachment.html>


More information about the x265-devel mailing list