[x265] [PATCH] rename maxCUSize in param to CTUSize to match with the CLI option --ctu

Steve Borho steve at borho.org
Tue Feb 17 06:42:57 CET 2015


On 02/16, santhoshini at multicorewareinc.com wrote:
> # HG changeset patch
> # User Santhoshini Sekar<santhoshini at multicorewareinc.com>
> # Date 1424087004 -19800
> #      Mon Feb 16 17:13:24 2015 +0530
> # Node ID 7bf665ad72b4cd59bec598d61b1361f22d762760
> # Parent  5fdaef859517b16ef37f26ec1a259a5c139744fe
> rename maxCUSize in param to CTUSize to match with the CLI option --ctu

Since max CU size is equivalent to the CTU size, we would need a more
compelling reason to change x265_param in a non-backward compatible way
Introducing new params does not generally break any existing C code, but
changing existing param names can.

For instance, I've been wanting to change bEnableLoopFilter for quite a
while, since it only enables deblocking and does not have any effect on
SAO, the second loop filter.  But I haven't because of backward
compatibility concerns.  It's not enough of a concern to warrant the
change.

> diff -r 5fdaef859517 -r 7bf665ad72b4 source/common/param.cpp
> --- a/source/common/param.cpp	Mon Feb 16 14:02:23 2015 +0530
> +++ b/source/common/param.cpp	Mon Feb 16 17:13:24 2015 +0530
> @@ -126,7 +126,7 @@
>      param->bEmitInfoSEI = 1;
>  
>      /* CU definitions */
> -    param->maxCUSize = 64;
> +    param->CTUSize = 64;
>      param->minCUSize = 8;
>      param->tuQTMaxInterDepth = 1;
>      param->tuQTMaxIntraDepth = 1;
> @@ -249,7 +249,7 @@
>          {
>              param->lookaheadDepth = 10;
>              param->scenecutThreshold = 0; // disable lookahead
> -            param->maxCUSize = 32;
> +            param->CTUSize = 32;
>              param->searchRange = 25;
>              param->bFrameAdaptive = 0;
>              param->subpelRefine = 0;
> @@ -268,7 +268,7 @@
>          else if (!strcmp(preset, "superfast"))
>          {
>              param->lookaheadDepth = 10;
> -            param->maxCUSize = 32;
> +            param->CTUSize = 32;
>              param->searchRange = 44;
>              param->bFrameAdaptive = 0;
>              param->subpelRefine = 1;
> @@ -285,7 +285,7 @@
>          else if (!strcmp(preset, "veryfast"))
>          {
>              param->lookaheadDepth = 15;
> -            param->maxCUSize = 32;
> +            param->CTUSize = 32;
>              param->bFrameAdaptive = 0;
>              param->subpelRefine = 1;
>              param->bEnableEarlySkip = 1;
> @@ -570,7 +570,7 @@
>      OPT("cu-stats") p->bLogCuStats = atobool(value);
>      OPT("repeat-headers") p->bRepeatHeaders = atobool(value);
>      OPT("wpp") p->bEnableWavefront = atobool(value);
> -    OPT("ctu") p->maxCUSize = (uint32_t)atoi(value);
> +    OPT("ctu") p->CTUSize = (uint32_t)atoi(value);
>      OPT("cu-min") p->minCUSize = (uint32_t)atoi(value);
>      OPT("tu-intra-depth") p->tuQTMaxIntraDepth = (uint32_t)atoi(value);
>      OPT("tu-inter-depth") p->tuQTMaxInterDepth = (uint32_t)atoi(value);
> @@ -962,12 +962,12 @@
>  #define CHECK(expr, msg) check_failed |= _confirm(param, expr, msg)
>      int check_failed = 0; /* abort if there is a fatal configuration problem */
>  
> -    CHECK(param->maxCUSize != 64 && param->maxCUSize != 32 && param->maxCUSize != 16,
> +    CHECK(param->CTUSize != 64 && param->CTUSize != 32 && param->CTUSize != 16,
>            "max ctu size must be 16, 32, or 64");
>      if (check_failed == 1)
>          return check_failed;
>  
> -    uint32_t maxLog2CUSize = (uint32_t)g_log2Size[param->maxCUSize];
> +    uint32_t maxLog2CUSize = (uint32_t)g_log2Size[param->CTUSize];
>      uint32_t tuQTMaxLog2Size = X265_MIN(maxLog2CUSize, 5);
>      uint32_t tuQTMinLog2Size = 2; //log2(4)
>  
> @@ -1024,7 +1024,7 @@
>      CHECK(param->maxNumReferences < 1, "maxNumReferences must be 1 or greater.");
>      CHECK(param->maxNumReferences > MAX_NUM_REF, "maxNumReferences must be 16 or smaller.");
>  
> -    CHECK(param->sourceWidth < (int)param->maxCUSize || param->sourceHeight < (int)param->maxCUSize,
> +    CHECK(param->sourceWidth < (int)param->CTUSize || param->sourceHeight < (int)param->CTUSize,
>            "Picture size must be at least one CTU");
>      CHECK(param->internalCsp < X265_CSP_I420 || X265_CSP_I444 < param->internalCsp,
>            "Color space must be i420, i422, or i444");
> @@ -1162,7 +1162,7 @@
>  
>      if (ATOMIC_INC(&once) > 1)
>      {
> -        if (param->maxCUSize != g_maxCUSize)
> +        if (param->CTUSize != g_maxCUSize)
>          {
>              x265_log(param, X265_LOG_ERROR, "maxCUSize must be the same for all encoders in a single process");
>              return -1;
> @@ -1170,16 +1170,16 @@
>      }
>      else
>      {
> -    if (param->minCUSize > param->maxCUSize)
> +    if (param->minCUSize > param->CTUSize)
>      {
> -        x265_log(param, X265_LOG_WARNING, "Min CU size should be less than or equal to max CU size, setting min CU size = %d\n", param->maxCUSize);
> -        param->minCUSize = param->maxCUSize;
> +        x265_log(param, X265_LOG_WARNING, "Min CU size should be less than or equal to max CU size, setting min CU size = %d\n", param->CTUSize);
> +        param->minCUSize = param->CTUSize;
>      }
> -        uint32_t maxLog2CUSize = (uint32_t)g_log2Size[param->maxCUSize];
> +        uint32_t maxLog2CUSize = (uint32_t)g_log2Size[param->CTUSize];
>          uint32_t minLog2CUSize = (uint32_t)g_log2Size[param->minCUSize];
>  
>          // set max CU width & height
> -        g_maxCUSize     = param->maxCUSize;
> +        g_maxCUSize     = param->CTUSize;
>          g_maxLog2CUSize = maxLog2CUSize;
>  
>          // compute actual CU depth with respect to config depth and max transform size
> @@ -1205,7 +1205,7 @@
>      if (param->interlaceMode)
>          x265_log(param, X265_LOG_INFO, "Interlaced field inputs             : %s\n", x265_interlace_names[param->interlaceMode]);
>  
> -    x265_log(param, X265_LOG_INFO, "Coding QT: max CU size, min CU size : %d / %d\n", param->maxCUSize, param->minCUSize);
> +    x265_log(param, X265_LOG_INFO, "Coding QT: max CU size, min CU size : %d / %d\n", param->CTUSize, param->minCUSize);
>  
>      x265_log(param, X265_LOG_INFO, "Residual QT: max TU size, max depth : %d / %d inter / %d intra\n",
>               param->maxTUSize, param->tuQTMaxInterDepth, param->tuQTMaxIntraDepth);
> @@ -1302,7 +1302,7 @@
>      s += sprintf(s, " fps=%u/%u", p->fpsNum, p->fpsDenom);
>      s += sprintf(s, " bitdepth=%d", p->internalBitDepth);
>      BOOL(p->bEnableWavefront, "wpp");
> -    s += sprintf(s, " ctu=%d", p->maxCUSize);
> +    s += sprintf(s, " ctu=%d", p->CTUSize);
>      s += sprintf(s, " cu-min=%d", p->minCUSize);
>      s += sprintf(s, " max-tu-size=%d", p->maxTUSize);
>      s += sprintf(s, " tu-intra-depth=%d", p->tuQTMaxIntraDepth);
> diff -r 5fdaef859517 -r 7bf665ad72b4 source/encoder/encoder.cpp
> --- a/source/encoder/encoder.cpp	Mon Feb 16 14:02:23 2015 +0530
> +++ b/source/encoder/encoder.cpp	Mon Feb 16 17:13:24 2015 +0530
> @@ -95,8 +95,8 @@
>  
>      x265_param* p = m_param;
>  
> -    int rows = (p->sourceHeight + p->maxCUSize - 1) >> g_log2Size[p->maxCUSize];
> -    int cols = (p->sourceWidth  + p->maxCUSize - 1) >> g_log2Size[p->maxCUSize];
> +    int rows = (p->sourceHeight + p->CTUSize - 1) >> g_log2Size[p->CTUSize];
> +    int cols = (p->sourceWidth  + p->CTUSize - 1) >> g_log2Size[p->CTUSize];
>  
>      // Do not allow WPP if only one row or fewer than 3 columns, it is pointless and unstable
>      if (rows == 1 || cols < 3)
> @@ -1624,10 +1624,10 @@
>          p->rc.cuTree = 0;
>      }
>  
> -    if (p->maxTUSize > p->maxCUSize)
> +    if (p->maxTUSize > p->CTUSize)
>      {
> -        x265_log(p, X265_LOG_WARNING, "Max TU size should be less than or equal to max CU size, setting max TU size = %d\n", p->maxCUSize);
> -        p->maxTUSize = p->maxCUSize;
> +        x265_log(p, X265_LOG_WARNING, "Max TU size should be less than or equal to max CU size, setting max TU size = %d\n", p->CTUSize);
> +        p->maxTUSize = p->CTUSize;
>      }
>  
>      if (p->rc.aqStrength == 0 && p->rc.cuTree == 0)
> diff -r 5fdaef859517 -r 7bf665ad72b4 source/encoder/frameencoder.cpp
> --- a/source/encoder/frameencoder.cpp	Mon Feb 16 14:02:23 2015 +0530
> +++ b/source/encoder/frameencoder.cpp	Mon Feb 16 17:13:24 2015 +0530
> @@ -142,7 +142,7 @@
>  bool FrameEncoder::initializeGeoms()
>  {
>      /* Geoms only vary between CTUs in the presence of picture edges */
> -    int maxCUSize = m_param->maxCUSize;
> +    int maxCUSize = m_param->CTUSize;
>      int minCUSize = m_param->minCUSize;
>      int heightRem = m_param->sourceHeight & (maxCUSize - 1);
>      int widthRem = m_param->sourceWidth & (maxCUSize - 1);
> diff -r 5fdaef859517 -r 7bf665ad72b4 source/encoder/level.cpp
> --- a/source/encoder/level.cpp	Mon Feb 16 14:02:23 2015 +0530
> +++ b/source/encoder/level.cpp	Mon Feb 16 17:13:24 2015 +0530
> @@ -133,7 +133,7 @@
>              continue;
>  
>          /* For level 5 and higher levels, the value of CtbSizeY shall be equal to 32 or 64 */
> -        if (levels[i].levelEnum >= Level::LEVEL5 && param.maxCUSize < 32)
> +        if (levels[i].levelEnum >= Level::LEVEL5 && param.CTUSize < 32)
>          {
>              x265_log(&param, X265_LOG_WARNING, "level %s detected, but CTU size 16 is non-compliant\n", levels[i].name);
>              vps.ptl.profileIdc = Profile::NONE;
> @@ -317,9 +317,9 @@
>          x265_log(&param, X265_LOG_INFO, "Lowering max references to %d to meet level requirement\n", param.maxNumReferences);
>  
>      /* For level 5 and higher levels, the value of CtbSizeY shall be equal to 32 or 64 */
> -    if (param.levelIdc >= 50 && param.maxCUSize < 32)
> +    if (param.levelIdc >= 50 && param.CTUSize < 32)
>      {
> -        param.maxCUSize = 32;
> +        param.CTUSize = 32;
>          x265_log(&param, X265_LOG_INFO, "Levels 5.0 and above require a maximum CTU size of at least 32, using --ctu 32\n");
>      }
>  
> diff -r 5fdaef859517 -r 7bf665ad72b4 source/encoder/search.cpp
> --- a/source/encoder/search.cpp	Mon Feb 16 14:02:23 2015 +0530
> +++ b/source/encoder/search.cpp	Mon Feb 16 17:13:24 2015 +0530
> @@ -62,11 +62,11 @@
>  
>  bool Search::initSearch(const x265_param& param, ScalingList& scalingList)
>  {
> -    uint32_t maxLog2CUSize = g_log2Size[param.maxCUSize];
> +    uint32_t maxLog2CUSize = g_log2Size[param.CTUSize];
>      m_param = ¶m;
>      m_bEnableRDOQ = param.rdLevel >= 4;
>      m_bFrameParallel = param.frameNumThreads > 1;
> -    m_numLayers = g_log2Size[param.maxCUSize] - 2;
> +    m_numLayers = g_log2Size[param.CTUSize] - 2;
>  
>      m_rdCost.setPsyRdScale(param.psyRd);
>      m_me.init(param.searchMethod, param.subpelRefine, param.internalCsp);
> diff -r 5fdaef859517 -r 7bf665ad72b4 source/encoder/slicetype.cpp
> --- a/source/encoder/slicetype.cpp	Mon Feb 16 14:02:23 2015 +0530
> +++ b/source/encoder/slicetype.cpp	Mon Feb 16 17:13:24 2015 +0530
> @@ -303,7 +303,7 @@
>          /* aggregate lowres row satds to CTU resolution */
>          curFrame->m_lowres.lowresCostForRc = curFrame->m_lowres.lowresCosts[b - p0][p1 - b];
>          uint32_t lowresRow = 0, lowresCol = 0, lowresCuIdx = 0, sum = 0;
> -        uint32_t scale = m_param->maxCUSize / (2 * X265_LOWRES_CU_SIZE);
> +        uint32_t scale = m_param->CTUSize / (2 * X265_LOWRES_CU_SIZE);
>          uint32_t numCuInHeight = (m_param->sourceHeight + g_maxCUSize - 1) / g_maxCUSize;
>          uint32_t widthInLowresCu = (uint32_t)m_widthInCU, heightInLowresCu = (uint32_t)m_heightInCU;
>          double *qp_offset = 0;
> diff -r 5fdaef859517 -r 7bf665ad72b4 source/x265.h
> --- a/source/x265.h	Mon Feb 16 14:02:23 2015 +0530
> +++ b/source/x265.h	Mon Feb 16 17:13:24 2015 +0530
> @@ -577,7 +577,7 @@
>       * complexity, greatly improving compression efficiency at large
>       * resolutions.  The smaller the size, the more effective wavefront and
>       * frame parallelism will become because of the increase in rows. default 64 */
> -    uint32_t  maxCUSize;
> +    uint32_t  CTUSize;
>  
>      /* Miniumum CU width and height in pixels.  The size must be 64, 32, 16, or 8.
>       * default 8 */
> diff -r 5fdaef859517 -r 7bf665ad72b4 source/x265cli.h
> --- a/source/x265cli.h	Mon Feb 16 14:02:23 2015 +0530
> +++ b/source/x265cli.h	Mon Feb 16 17:13:24 2015 +0530
> @@ -265,7 +265,7 @@
>      H0("-t/--tune <string>               Tune the settings for a particular type of source or situation:\n");
>      H0("                                 psnr, ssim, grain, zerolatency, fastdecode\n");
>      H0("\nQuad-Tree size and depth:\n");
> -    H0("-s/--ctu <64|32|16>              Maximum CU size (WxH). Default %d\n", param->maxCUSize);
> +    H0("-s/--ctu <64|32|16>              Maximum CU size (WxH). Default %d\n", param->CTUSize);
>      H0("   --cu-min <64|32|16|8>        Minimum CU size (WxH). Default %d\n", param->minCUSize);
>      H0("   --max-tu-size <32|16|8|4>     Maximum TU size (WxH). Default %d\n", param->maxTUSize);
>      H0("   --tu-intra-depth <integer>    Max TU recursive depth for intra CUs. Default %d\n", param->tuQTMaxIntraDepth);
> _______________________________________________
> x265-devel mailing list
> x265-devel at videolan.org
> https://mailman.videolan.org/listinfo/x265-devel

-- 
Steve Borho


More information about the x265-devel mailing list