[x265] [PATCH] TshortYUV: Cleanup and Used Performance Primitives for copy the block

Steve Borho steve at borho.org
Wed Jul 17 22:15:44 CEST 2013


On Wed, Jul 17, 2013 at 4:31 AM, <gopu at multicorewareinc.com> wrote:

> # HG changeset patch
> # User ggopu
> # Date 1374053501 -19800
> # Node ID ad9f7a7307572f0769e8abd1af78f66541fa4de6
> # Parent  c6c045e9272798ce5268643436759db22fd1950b
> TshortYUV: Cleanup and Used Performance Primitives for copy the block
>
> diff -r c6c045e92727 -r ad9f7a730757 source/common/TShortYUV.cpp
> --- a/source/common/TShortYUV.cpp       Wed Jul 17 13:06:06 2013 +0530
> +++ b/source/common/TShortYUV.cpp       Wed Jul 17 15:01:41 2013 +0530
> @@ -172,98 +172,78 @@
>      copyPartToPartChroma(pcYuvDst, uiPartIdx, iWidth >> 1, iHeight >> 1);
>  }
>
> -Void TShortYUV::copyPartToPartLuma(TShortYUV* pcYuvDst, unsigned int
> uiPartIdx, unsigned int iWidth, unsigned int iHeight)
> +Void TShortYUV::copyPartToPartLuma(TShortYUV* pcYuvDst, unsigned int
> partIdx, unsigned int widthl, unsigned int heightl)
>

pcYuvDst -> dstYuv



>  {
> -    short* pSrc =           getLumaAddr(uiPartIdx);
> -    short* pDst = pcYuvDst->getLumaAddr(uiPartIdx);
> +    short* src =           getLumaAddr(partIdx);
> +    short* dst = pcYuvDst->getLumaAddr(partIdx);
>
> -    if (pSrc == pDst)
> +    if (src == dst)
>      {
>          //th not a good idea
>          //th best would be to fix the caller
>          return;
>      }
>
> -    unsigned int  iSrcStride = width;
> -    unsigned int  iDstStride = pcYuvDst->width;
> -    for (unsigned int y = iHeight; y != 0; y--)
> +    unsigned int  srcStride = width;
> +    unsigned int  dstStride = pcYuvDst->width;
> +    for (unsigned int y = heightl; y != 0; y--)
>      {
> -        ::memcpy(pDst, pSrc, iWidth * sizeof(short));
> -        pSrc += iSrcStride;
> -        pDst += iDstStride;
> +        ::memcpy(dst, src, widthl * sizeof(short));
>

widhtl?


> +        src += srcStride;
> +        dst += dstStride;
>      }
>  }
>
> -Void TShortYUV::copyPartToPartLuma(TComYuv* pcYuvDst, unsigned int
> uiPartIdx, unsigned int iWidth, unsigned int iHeight)
> +Void TShortYUV::copyPartToPartLuma(TComYuv* pcYuvDst, unsigned int
> partIdx, unsigned int widthl, unsigned int heightl)
>  {
> -    short* pSrc =           getLumaAddr(uiPartIdx);
> -    Pel* pDst = pcYuvDst->getLumaAddr(uiPartIdx);
> +    short* src =           getLumaAddr(partIdx);
> +    Pel* dst = pcYuvDst->getLumaAddr(partIdx);
>
> -    unsigned int  iSrcStride = width;
> -    unsigned int  iDstStride = pcYuvDst->getStride();
> +    unsigned int  srcStride = width;
> +    unsigned int  dstStride = pcYuvDst->getStride();
>
> -    for (unsigned int y = iHeight; y != 0; y--)
> -    {
> -        for (unsigned int x = 0; x < iWidth; x++)
> -        {
> -            pDst[x] = (Pel)(pSrc[x]);
> -        }
> -
> -        pSrc += iSrcStride;
> -        pDst += iDstStride;
> -    }
> +    primitives.blockcpy_ps(widthl, heightl, dst, dstStride, src,
> srcStride);
>  }
>
> -Void TShortYUV::copyPartToPartChroma(TShortYUV* pcYuvDst, unsigned int
> uiPartIdx, unsigned int iWidth, unsigned int iHeight)
> +Void TShortYUV::copyPartToPartChroma(TShortYUV* pcYuvDst, unsigned int
> partIdx, unsigned int widthc, unsigned int heightc)
>  {
> -    short*  pSrcU =           getCbAddr(uiPartIdx);
> -    short*  pSrcV =           getCrAddr(uiPartIdx);
> -    short*  pDstU = pcYuvDst->getCbAddr(uiPartIdx);
> -    short*  pDstV = pcYuvDst->getCrAddr(uiPartIdx);
> +    short*  srcU =           getCbAddr(partIdx);
> +    short*  srcV =           getCrAddr(partIdx);
> +    short*  dstU = pcYuvDst->getCbAddr(partIdx);
> +    short*  dstV = pcYuvDst->getCrAddr(partIdx);
>
> -    if (pSrcU == pDstU && pSrcV == pDstV)
> +    if (srcU == dstU && srcV == dstV)
>      {
>          //th not a good idea
>          //th best would be to fix the caller
>          return;
>      }
>
> -    unsigned int   iSrcStride = Cwidth;
> -    unsigned int   iDstStride = pcYuvDst->Cwidth;
> -    for (unsigned int y = iHeight; y != 0; y--)
> +    unsigned int   srcStride = Cwidth;
> +    unsigned int   dstStride = pcYuvDst->Cwidth;
> +    for (unsigned int y = heightc; y != 0; y--)
>      {
> -        ::memcpy(pDstU, pSrcU, iWidth * sizeof(short));
> -        ::memcpy(pDstV, pSrcV, iWidth * sizeof(short));
> -        pSrcU += iSrcStride;
> -        pSrcV += iSrcStride;
> -        pDstU += iDstStride;
> -        pDstV += iDstStride;
> +        ::memcpy(dstU, srcU, widthc * sizeof(short));
> +        ::memcpy(dstV, srcV, widthc * sizeof(short));
> +        srcU += srcStride;
> +        srcV += srcStride;
> +        dstU += dstStride;
> +        dstV += dstStride;
>      }
>  }
>
> -Void TShortYUV::copyPartToPartChroma(TComYuv* pcYuvDst, unsigned int
> uiPartIdx, unsigned int iWidth, unsigned int iHeight)
> +Void TShortYUV::copyPartToPartChroma(TComYuv* pcYuvDst, unsigned int
> partIdx, unsigned int widthc, unsigned int heightc)
>  {
> -    short*  pSrcU =           getCbAddr(uiPartIdx);
> -    short*  pSrcV =           getCrAddr(uiPartIdx);
> -    Pel*  pDstU = pcYuvDst->getCbAddr(uiPartIdx);
> -    Pel*  pDstV = pcYuvDst->getCrAddr(uiPartIdx);
> +    short*  srcU =           getCbAddr(partIdx);
> +    short*  srcV =           getCrAddr(partIdx);
> +    Pel*  dstU = pcYuvDst->getCbAddr(partIdx);
> +    Pel*  dstV = pcYuvDst->getCrAddr(partIdx);
>
> -    unsigned int   iSrcStride = Cwidth;
> -    unsigned int   iDstStride = pcYuvDst->getCStride();
> +    unsigned int   srcStride = Cwidth;
> +    unsigned int   dstStride = pcYuvDst->getCStride();
>
> -    for (unsigned int y = iHeight; y != 0; y--)
> -    {
> -        for (unsigned int x = 0; x < iWidth; x++)
> -        {
> -            pDstU[x] = (Pel)(pSrcU[x]);
> -            pDstV[x] = (Pel)(pSrcV[x]);
> -        }
> -
> -        pSrcU += iSrcStride;
> -        pSrcV += iSrcStride;
> -        pDstU += iDstStride;
> -        pDstV += iDstStride;
> -    }
> +    primitives.blockcpy_ps(widthc, heightc, dstU, dstStride, srcU,
> srcStride);
> +    primitives.blockcpy_ps(widthc, heightc, dstV, dstStride, srcV,
> srcStride);
>  }
>
>  Void TShortYUV::copyPartToPartChroma(TShortYUV* pcYuvDst, unsigned int
> uiPartIdx, unsigned int iWidth, unsigned int iHeight, unsigned int chromaId)
> @@ -329,63 +309,34 @@
>      }
>  }
>
> -Void TShortYUV::copyPartToPartChroma(TComYuv* pcYuvDst, unsigned int
> uiPartIdx, unsigned int iWidth, unsigned int iHeight, unsigned int chromaId)
> +Void TShortYUV::copyPartToPartChroma(TComYuv* pcYuvDst, unsigned int
> partIdx, unsigned int widthc, unsigned int heightc, unsigned int chromaId)
>  {
>      if (chromaId == 0)
>      {
> -        short*  pSrcU =           getCbAddr(uiPartIdx);
> -        Pel*  pDstU = pcYuvDst->getCbAddr(uiPartIdx);
> -        unsigned int   iSrcStride = Cwidth;
> -        unsigned int   iDstStride = pcYuvDst->getCStride();
> -        for (unsigned int y = iHeight; y != 0; y--)
> -        {
> -            for (unsigned int x = 0; x < iWidth; x++)
> -            {
> -                pDstU[x] = (Pel)(pSrcU[x]);
> -            }
> -
> -            pSrcU += iSrcStride;
> -            pDstU += iDstStride;
> -        }
> +        short*  srcU =           getCbAddr(partIdx);
> +        Pel*  dstU = pcYuvDst->getCbAddr(partIdx);
> +        unsigned int   srcStride = Cwidth;
> +        unsigned int   dstStride = pcYuvDst->getCStride();
> +        primitives.blockcpy_ps(widthc, heightc, dstU, dstStride, srcU,
> srcStride);
>      }
>      else if (chromaId == 1)
>      {
> -        short*  pSrcV =           getCrAddr(uiPartIdx);
> -        Pel*  pDstV = pcYuvDst->getCrAddr(uiPartIdx);
> -        unsigned int   iSrcStride = Cwidth;
> -        unsigned int   iDstStride = pcYuvDst->getCStride();
> -        for (unsigned int y = iHeight; y != 0; y--)
> -        {
> -            for (unsigned int x = 0; x < iWidth; x++)
> -            {
> -                pDstV[x] = (Pel)(pSrcV[x]);
> -            }
> -
> -            pSrcV += iSrcStride;
> -            pDstV += iDstStride;
> -        }
> +        short*  srcV =           getCrAddr(partIdx);
> +        Pel*  dstV = pcYuvDst->getCrAddr(partIdx);
> +        unsigned int   srcStride = Cwidth;
> +        unsigned int   dstStride = pcYuvDst->getCStride();
> +        primitives.blockcpy_ps(widthc, heightc, dstV, dstStride, srcV,
> srcStride);
>      }
>      else
>      {
> -        short*  pSrcU =           getCbAddr(uiPartIdx);
> -        short*  pSrcV =           getCrAddr(uiPartIdx);
> -        Pel*  pDstU = pcYuvDst->getCbAddr(uiPartIdx);
> -        Pel*  pDstV = pcYuvDst->getCrAddr(uiPartIdx);
> +        short*  srcU =           getCbAddr(partIdx);
> +        short*  srcV =           getCrAddr(partIdx);
> +        Pel*  dstU = pcYuvDst->getCbAddr(partIdx);
> +        Pel*  dstV = pcYuvDst->getCrAddr(partIdx);
>
> -        unsigned int   iSrcStride = Cwidth;
> -        unsigned int   iDstStride = pcYuvDst->getCStride();
> -        for (unsigned int y = iHeight; y != 0; y--)
> -        {
> -            for (unsigned int x = 0; x < iWidth; x++)
> -            {
> -                pDstU[x] = (Pel)(pSrcU[x]);
> -                pDstV[x] = (Pel)(pSrcV[x]);
> -            }
> -
> -            pSrcU += iSrcStride;
> -            pSrcV += iSrcStride;
> -            pDstU += iDstStride;
> -            pDstV += iDstStride;
> -        }
> +        unsigned int   srcStride = Cwidth;
> +        unsigned int   dstStride = pcYuvDst->getCStride();
> +        primitives.blockcpy_ps(widthc, heightc, dstU, dstStride, srcU,
> srcStride);
> +        primitives.blockcpy_ps(widthc, heightc, dstV, dstStride, srcV,
> srcStride);
>      }
>  }
> _______________________________________________
> x265-devel mailing list
> x265-devel at videolan.org
> http://mailman.videolan.org/listinfo/x265-devel
>



-- 
Steve Borho
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20130717/78a29818/attachment.html>


More information about the x265-devel mailing list