[x265] qtLayer in reverse order

Steve Borho steve at borho.org
Thu Jul 24 05:11:58 CEST 2014


On 07/24, Satoshi Nakagawa wrote:
> # HG changeset patch
> # User Satoshi Nakagawa <nakagawa424 at oki.com>
> # Date 1406166493 -32400
> #      Thu Jul 24 10:48:13 2014 +0900
> # Node ID 737648a21e98a7ea339e1b659175c1f229d77c8c
> # Parent  342d72f0b61322f31bec35634cc893e4e2b04be3
> qtLayer in reverse order
> 
> diff -r 342d72f0b613 -r 737648a21e98 source/Lib/TLibEncoder/TEncSearch.cpp
> --- a/source/Lib/TLibEncoder/TEncSearch.cpp	Wed Jul 23 17:47:16 2014 -0500
> +++ b/source/Lib/TLibEncoder/TEncSearch.cpp	Thu Jul 24 10:48:13 2014 +0900
> @@ -51,9 +51,7 @@
>  
>  TEncSearch::TEncSearch()
>  {
> -    m_qtTempCoeff[0] = NULL;
> -    m_qtTempCoeff[1] = NULL;
> -    m_qtTempCoeff[2] = NULL;
> +    memset(m_qtTempCoeff, 0, sizeof(m_qtTempCoeff));
>      m_qtTempTrIdx = NULL;
>      m_qtTempShortYuv = NULL;
>      for (int i = 0; i < 3; i++)
> @@ -80,7 +78,6 @@
>      X265_FREE(m_qtTempCbf[0]);
>      X265_FREE(m_qtTempTransformSkipFlag[0]);
>  
> -    delete[] m_qtTempCoeff[0];
>      delete[] m_qtTempShortYuv;
>  }
>  
> @@ -94,9 +91,6 @@
>       * available for motion reference.  See refLagRows in FrameEncoder::compressCTURows() */
>      m_refLagPixels = m_bFrameParallel ? m_param->searchRange : m_param->sourceHeight;
>  
> -    m_qtTempCoeff[0] = new coeff_t*[m_numLayers * 3];
> -    m_qtTempCoeff[1] = m_qtTempCoeff[0] + m_numLayers;
> -    m_qtTempCoeff[2] = m_qtTempCoeff[0] + m_numLayers * 2;
>      m_qtTempShortYuv = new ShortYuv[m_numLayers];
>      uint32_t sizeL = 1 << (g_maxLog2CUSize * 2);
>      uint32_t sizeC = sizeL >> (CHROMA_H_SHIFT(m_csp) + CHROMA_V_SHIFT(m_csp));
> @@ -239,7 +233,7 @@
>      }
>  
>      uint32_t log2TrSize = g_maxLog2CUSize - fullDepth;
> -    uint32_t qtLayer    = cu->m_slice->m_sps->quadtreeTULog2MaxSize - log2TrSize;
> +    uint32_t qtLayer    = log2TrSize - 2;
>      uint32_t log2UnitSize = cu->m_pic->getLog2UnitSize();
>      uint32_t coeffOffset = absPartIdx << (log2UnitSize * 2);
>      coeff_t* coeff = m_qtTempCoeff[ttype][qtLayer] + coeffOffset;
> @@ -266,8 +260,6 @@
>      }
>  
>      uint32_t log2TrSize = g_maxLog2CUSize - fullDepth;
> -    uint32_t qtLayer    = cu->m_slice->m_sps->quadtreeTULog2MaxSize - log2TrSize;
> -    uint32_t log2UnitSize = cu->m_pic->getLog2UnitSize();
>  
>      uint32_t trDepthC = trDepth;
>      int hChromaShift = CHROMA_H_SHIFT(m_csp);
> @@ -286,6 +278,9 @@
>          }
>      }
>  
> +    uint32_t qtLayer    = log2TrSize - 2;
> +    uint32_t log2UnitSize = cu->m_pic->getLog2UnitSize();
> +
>      if (m_csp != CHROMA_422)
>      {
>          uint32_t shift = (m_csp == CHROMA_420) ? 2 : 0;
> @@ -560,7 +555,6 @@
>      bool     bCheckFull  = (log2TrSize <= cu->m_slice->m_sps->quadtreeTULog2MaxSize);
>      bool     bCheckSplit = (log2TrSize > cu->getQuadtreeTULog2MinSizeInCU(absPartIdx));
>  
> -    int maxTuSize = cu->m_slice->m_sps->quadtreeTULog2MaxSize;
>      int isIntraSlice = (cu->m_slice->m_sliceType == I_SLICE);
>  
>      // don't check split if TU size is less or equal to max TU size
> @@ -568,6 +562,7 @@
>  
>      if (m_param->rdPenalty && !isIntraSlice)
>      {
> +        int maxTuSize = cu->m_slice->m_sps->quadtreeTULog2MaxSize;
>          // in addition don't check split if TU size is less or equal to 16x16 TU size for non-intra slice
>          noSplitIntraMaxTuSize = (log2TrSize <= X265_MIN(maxTuSize, 4));
>  
> @@ -613,7 +608,7 @@
>  
>          cu->setTrIdxSubParts(trDepth, absPartIdx, fullDepth);
>  
> -        uint32_t qtLayer        = cu->m_slice->m_sps->quadtreeTULog2MaxSize - log2TrSize;
> +        uint32_t qtLayer        = log2TrSize - 2;
>          uint32_t coeffOffsetY   = absPartIdx << cu->m_pic->getLog2UnitSize() * 2;
>          coeff_t* coeffY         = m_qtTempCoeff[0][qtLayer] + coeffOffsetY;
>          int16_t* reconQt        = m_qtTempShortYuv[qtLayer].getLumaAddr(absPartIdx);
> @@ -793,7 +788,7 @@
>          cu->setTransformSkipSubParts(bestModeId, TEXT_LUMA, absPartIdx, fullDepth);
>  
>          //--- set reconstruction for next intra prediction blocks ---
> -        uint32_t qtLayer   = cu->m_slice->m_sps->quadtreeTULog2MaxSize - log2TrSize;
> +        uint32_t qtLayer   = log2TrSize - 2;
>          uint32_t zorder    = cu->getZorderIdxInCU() + absPartIdx;
>          int16_t* reconQt   = m_qtTempShortYuv[qtLayer].getLumaAddr(absPartIdx);
>          X265_CHECK(m_qtTempShortYuv[qtLayer].m_width == MAX_CU_SIZE, "width is not max CU size\n");
> @@ -823,12 +818,14 @@
>      bool     bCheckFull  = (log2TrSize <= cu->m_slice->m_sps->quadtreeTULog2MaxSize);
>      bool     bCheckSplit = (log2TrSize > cu->getQuadtreeTULog2MinSizeInCU(absPartIdx));
>  
> -    int maxTuSize = cu->m_slice->m_sps->quadtreeTULog2MaxSize;
>      int isIntraSlice = (cu->m_slice->m_sliceType == I_SLICE);
>  
>      if (m_param->rdPenalty == 2 && !isIntraSlice)
> +    {
> +        int maxTuSize = cu->m_slice->m_sps->quadtreeTULog2MaxSize;
>          // if maximum RD-penalty don't check TU size 32x32
>          bCheckFull = (log2TrSize <= X265_MIN(maxTuSize, 4));
> +    }
>  
>      if (bCheckFull)
>      {
> @@ -923,7 +920,7 @@
>      if (trMode == trDepth)
>      {
>          uint32_t log2TrSize = g_maxLog2CUSize - fullDepth;
> -        uint32_t qtLayer    = cu->m_slice->m_sps->quadtreeTULog2MaxSize - log2TrSize;
> +        uint32_t qtLayer    = log2TrSize - 2;
>  
>          //===== copy transform coefficients =====
>          uint32_t coeffOffsetY = absPartIdx << cu->m_pic->getLog2UnitSize() * 2;
> @@ -1032,6 +1029,7 @@
>                  return;
>          }
>  
> +        uint32_t qtLayer = log2TrSize - 2;
>          uint32_t log2UnitSize = cu->m_pic->getLog2UnitSize();
>          uint32_t tuSize = 1 << log2TrSizeC;
>          uint32_t stride = fencYuv->getCStride();
> @@ -1041,8 +1039,6 @@
>                                     log2TrSizeC <= MAX_LOG2_TS_SIZE &&
>                                     !cu->getCUTransquantBypass(0));
>  
> -        uint32_t qtLayer = cu->m_slice->m_sps->quadtreeTULog2MaxSize - log2TrSize;
> -
>          if (m_param->bEnableTSkipFast)
>          {
>              checkTransformSkip &= (log2TrSize <= MAX_LOG2_TS_SIZE);
> @@ -1225,7 +1221,6 @@
>      {
>          uint32_t log2TrSize = g_maxLog2CUSize - fullDepth;
>          uint32_t log2TrSizeC = log2TrSize - hChromaShift;
> -        uint32_t qtLayer    = cu->m_slice->m_sps->quadtreeTULog2MaxSize - log2TrSize;
>  
>          if ((log2TrSize == 2) && !(m_csp == CHROMA_444))
>          {
> @@ -1242,6 +1237,7 @@
>          uint32_t numCoeffC = 1 << (log2TrSizeC * 2 + (m_csp == CHROMA_422));
>          uint32_t coeffOffsetC = absPartIdx << (cu->m_pic->getLog2UnitSize() * 2 - (hChromaShift + vChromaShift));
>  
> +        uint32_t qtLayer   = log2TrSize - 2;
>          coeff_t* coeffSrcU = m_qtTempCoeff[1][qtLayer] + coeffOffsetC;
>          coeff_t* coeffSrcV = m_qtTempCoeff[2][qtLayer] + coeffOffsetC;
>          coeff_t* coeffDstU = cu->getCoeffCb()          + coeffOffsetC;
> @@ -2699,12 +2695,12 @@
>          uint32_t trSizeC = 1 << log2TrSizeC;
>          int sizeIdx  = log2TrSize - 2;
>          int sizeIdxC = log2TrSizeC - 2;
> -        const uint32_t qtLayer = cu->m_slice->m_sps->quadtreeTULog2MaxSize - log2TrSize;
> +        const uint32_t qtLayer = log2TrSize - 2;
>          uint32_t coeffOffsetY = absPartIdx << cu->m_pic->getLog2UnitSize() * 2;
>          uint32_t coeffOffsetC = coeffOffsetY >> (hChromaShift + vChromaShift);
> -        coeff_t *coeffCurY = m_qtTempCoeff[0][qtLayer] + coeffOffsetY;
> -        coeff_t *coeffCurU = m_qtTempCoeff[1][qtLayer] + coeffOffsetC;
> -        coeff_t *coeffCurV = m_qtTempCoeff[2][qtLayer] + coeffOffsetC;
> +        coeff_t* coeffCurY = m_qtTempCoeff[0][qtLayer] + coeffOffsetY;
> +        coeff_t* coeffCurU = m_qtTempCoeff[1][qtLayer] + coeffOffsetC;
> +        coeff_t* coeffCurV = m_qtTempCoeff[2][qtLayer] + coeffOffsetC;
>  
>          cu->setTrIdxSubParts(depth - cu->getDepth(0), absPartIdx, depth);
>          bool checkTransformSkip   = cu->m_slice->m_pps->bTransformSkipEnabled && !cu->getCUTransquantBypass(0);
> @@ -3512,9 +3508,9 @@
>      if (!bSubdiv)
>      {
>          //Luma
> -        const uint32_t qtLayer = cu->m_slice->m_sps->quadtreeTULog2MaxSize - log2TrSize;
> +        const uint32_t qtLayer = log2TrSize - 2;
>          uint32_t coeffOffsetY = absPartIdx << cu->m_pic->getLog2UnitSize() * 2;
> -        coeff_t *coeffCurY = m_qtTempCoeff[0][qtLayer] + coeffOffsetY;
> +        coeff_t* coeffCurY = m_qtTempCoeff[0][qtLayer] + coeffOffsetY;
>  
>          //Chroma
>          bool bCodeChroma = true;
> @@ -3537,8 +3533,8 @@
>              if (bCodeChroma)
>              {
>                  uint32_t coeffOffsetC = coeffOffsetY >> (hChromaShift + vChromaShift);
> -                coeff_t *coeffCurU = m_qtTempCoeff[1][qtLayer] + coeffOffsetC;
> -                coeff_t *coeffCurV = m_qtTempCoeff[2][qtLayer] + coeffOffsetC;
> +                coeff_t* coeffCurU = m_qtTempCoeff[1][qtLayer] + coeffOffsetC;
> +                coeff_t* coeffCurV = m_qtTempCoeff[2][qtLayer] + coeffOffsetC;
>  
>                  if (!splitIntoSubTUs)
>                  {
> @@ -3592,7 +3588,7 @@
>      if (curTrMode == trMode)
>      {
>          const uint32_t log2TrSize = g_maxLog2CUSize - depth;
> -        const uint32_t qtLayer    = cu->m_slice->m_sps->quadtreeTULog2MaxSize - log2TrSize;
> +        const uint32_t qtLayer    = log2TrSize - 2;
>  
>          uint32_t log2TrSizeC = log2TrSize - hChromaShift;
>          bool bCodeChroma = true;
> @@ -3608,7 +3604,6 @@
>          if (bSpatial)
>          {
>              m_qtTempShortYuv[qtLayer].copyPartToPartLuma(resiYuv, absPartIdx, log2TrSize);
> -
>              if (bCodeChroma)
>                  m_qtTempShortYuv[qtLayer].copyPartToPartChroma(resiYuv, absPartIdx, log2TrSizeC + hChromaShift);
>          }
> diff -r 342d72f0b613 -r 737648a21e98 source/Lib/TLibEncoder/TEncSearch.h
> --- a/source/Lib/TLibEncoder/TEncSearch.h	Wed Jul 23 17:47:16 2014 -0500
> +++ b/source/Lib/TLibEncoder/TEncSearch.h	Thu Jul 24 10:48:13 2014 +0900
> @@ -51,6 +51,7 @@
>  #include "rdcost.h"
>  
>  #define MVP_IDX_BITS 1
> +#define NUM_LAYERS 4

Is NUM_LAYERS the same as MAX_CU_DEPTH? Could we use that here?

Otherwise the patch looks fine.

>  
>  namespace x265 {
>  // private namespace
> @@ -108,7 +109,7 @@
>  
>      ShortYuv*       m_qtTempShortYuv;
>  
> -    coeff_t**       m_qtTempCoeff[3];
> +    coeff_t*        m_qtTempCoeff[3][NUM_LAYERS];
>      uint8_t*        m_qtTempTrIdx;
>      uint8_t*        m_qtTempCbf[3];
>  
> diff -r 342d72f0b613 -r 737648a21e98 source/encoder/analysis.cpp
> --- a/source/encoder/analysis.cpp	Wed Jul 23 17:47:16 2014 -0500
> +++ b/source/encoder/analysis.cpp	Thu Jul 24 10:48:13 2014 +0900
> @@ -64,7 +64,7 @@
>      m_rdCost.setPsyRdScale(m_param->psyRd);
>      m_bEnableRDOQ = top->m_bEnableRDOQ;
>      m_bFrameParallel = m_param->frameNumThreads > 1;
> -    m_numLayers = top->m_quadtreeTULog2MaxSize - top->m_quadtreeTULog2MinSize + 1;
> +    m_numLayers = top->m_quadtreeTULog2MaxSize - 2 + 1;
>  
>      return initSearch();
>  }
> _______________________________________________
> 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