[x265] [PATCH] improved getTUEntropyCodingParameters() function

Steve Borho steve at borho.org
Wed Feb 25 16:11:32 CET 2015


On 02/25, ashok at multicorewareinc.com wrote:
> # HG changeset patch
> # User Ashok Kumar Mishra<ashok at multicorewareinc.com>
> # Date 1424765356 -19800
> #      Tue Feb 24 13:39:16 2015 +0530
> # Node ID 0a570547df48890dd7db0df2559f42f874292f8f
> # Parent  f513ae68dd7eb8c72f44dd74ea151041fea82492
> improved getTUEntropyCodingParameters() function

queued

> diff -r f513ae68dd7e -r 0a570547df48 source/common/cudata.cpp
> --- a/source/common/cudata.cpp	Wed Feb 25 16:38:59 2015 +0530
> +++ b/source/common/cudata.cpp	Tue Feb 24 13:39:16 2015 +0530
> @@ -1980,60 +1980,47 @@
>                             + (puWidth  >> (LOG2_UNIT_SIZE + 1))];
>  }
>  
> -ScanType CUData::getCoefScanIdx(uint32_t absPartIdx, uint32_t log2TrSize, bool bIsLuma, bool bIsIntra) const
> -{
> -    uint32_t dirMode;
> -
> -    if (!bIsIntra)
> -        return SCAN_DIAG;
> -
> -    // check that MDCS can be used for this TU
> -    if (bIsLuma)
> -    {
> -        if (log2TrSize > MDCS_LOG2_MAX_SIZE)
> -            return SCAN_DIAG;
> -
> -        dirMode = m_lumaIntraDir[absPartIdx];
> -    }
> -    else
> -    {
> -        if (log2TrSize > (uint32_t)(MDCS_LOG2_MAX_SIZE - m_hChromaShift))
> -            return SCAN_DIAG;
> -
> -        dirMode = m_chromaIntraDir[absPartIdx];
> -        if (dirMode == DM_CHROMA_IDX)
> -        {
> -            dirMode = m_lumaIntraDir[(m_chromaFormat == X265_CSP_I444) ? absPartIdx : absPartIdx & 0xFC];
> -            dirMode = (m_chromaFormat == X265_CSP_I422) ? g_chroma422IntraAngleMappingTable[dirMode] : dirMode;
> -        }
> -    }
> -
> -    if (abs((int)dirMode - VER_IDX) <= MDCS_ANGLE_LIMIT)
> -        return SCAN_HOR;
> -    else if (abs((int)dirMode - HOR_IDX) <= MDCS_ANGLE_LIMIT)
> -        return SCAN_VER;
> -    else
> -        return SCAN_DIAG;
> -}
> -
>  void CUData::getTUEntropyCodingParameters(TUEntropyCodingParameters &result, uint32_t absPartIdx, uint32_t log2TrSize, bool bIsLuma) const
>  {
> +    bool bIsIntra = isIntra(absPartIdx);
> +
>      // set the group layout
>      result.log2TrSizeCG = log2TrSize - 2;
>  
>      // set the scan orders
> -    result.scanType = getCoefScanIdx(absPartIdx, log2TrSize, bIsLuma, isIntra(absPartIdx));
> +    if (!bIsIntra)
> +    {
> +        result.scanType = SCAN_DIAG;
> +    }
> +    else
> +    {
> +        uint32_t dirMode;
> +
> +        if (bIsLuma)
> +            dirMode = m_lumaIntraDir[absPartIdx];
> +        else
> +        {
> +            dirMode = m_chromaIntraDir[absPartIdx];
> +            if (dirMode == DM_CHROMA_IDX)
> +            {
> +                dirMode = m_lumaIntraDir[(m_chromaFormat == X265_CSP_I444) ? absPartIdx : absPartIdx & 0xFC];
> +                dirMode = (m_chromaFormat == X265_CSP_I422) ? g_chroma422IntraAngleMappingTable[dirMode] : dirMode;
> +            }
> +        }
> +
> +        if (log2TrSize <= (MDCS_LOG2_MAX_SIZE - m_hChromaShift) || (bIsLuma && log2TrSize == MDCS_LOG2_MAX_SIZE))
> +            result.scanType = dirMode >= 22 && dirMode <= 30 ? SCAN_HOR : dirMode >= 6 && dirMode <= 14 ? SCAN_VER : SCAN_DIAG;
> +        else
> +            result.scanType = SCAN_DIAG;
> +    }
> +
>      result.scan     = g_scanOrder[result.scanType][log2TrSize - 2];
>      result.scanCG   = g_scanOrderCG[result.scanType][result.log2TrSizeCG];
>  
>      if (log2TrSize == 2)
>          result.firstSignificanceMapContext = 0;
>      else if (log2TrSize == 3)
> -    {
> -        result.firstSignificanceMapContext = 9;
> -        if (result.scanType != SCAN_DIAG && bIsLuma)
> -            result.firstSignificanceMapContext += 6;
> -    }
> +        result.firstSignificanceMapContext = (result.scanType != SCAN_DIAG && bIsLuma) ? 15 : 9;
>      else
>          result.firstSignificanceMapContext = bIsLuma ? 21 : 12;
>  }
> diff -r f513ae68dd7e -r 0a570547df48 source/common/cudata.h
> --- a/source/common/cudata.h	Wed Feb 25 16:38:59 2015 +0530
> +++ b/source/common/cudata.h	Tue Feb 24 13:39:16 2015 +0530
> @@ -122,9 +122,9 @@
>      uint32_t      m_cuPelY;           // CU position within the picture, in pixels (Y)
>      uint32_t      m_numPartitions;    // maximum number of 4x4 partitions within this CU
>  
> -    int           m_chromaFormat;
> -    int           m_hChromaShift;
> -    int           m_vChromaShift;
> +    uint32_t      m_chromaFormat;
> +    uint32_t      m_hChromaShift;
> +    uint32_t      m_vChromaShift;
>  
>      /* Per-part data, stored contiguously */
>      int8_t*       m_qp;               // array of QP values
> @@ -216,7 +216,6 @@
>      uint32_t getSCUAddr() const                  { return (m_cuAddr << g_unitSizeDepth * 2) + m_absIdxInCTU; }
>      uint32_t getCtxSplitFlag(uint32_t absPartIdx, uint32_t depth) const;
>      uint32_t getCtxSkipFlag(uint32_t absPartIdx) const;
> -    ScanType getCoefScanIdx(uint32_t absPartIdx, uint32_t log2TrSize, bool bIsLuma, bool bIsIntra) const;
>      void     getTUEntropyCodingParameters(TUEntropyCodingParameters &result, uint32_t absPartIdx, uint32_t log2TrSize, bool bIsLuma) const;
>  
>      const CUData* getPULeft(uint32_t& lPartUnitIdx, uint32_t curPartUnitIdx) const;
> _______________________________________________
> 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