[x265] [PATCH RFC] Weighted filter integrated to encoder for testing

Steve Borho steve at borho.org
Wed Jul 24 18:55:18 CEST 2013


On Wed, Jul 24, 2013 at 6:23 AM, <deepthidevaki at multicorewareinc.com> wrote:

> # HG changeset patch
> # User Deepthi Devaki
> # Date 1374664960 -19800
> # Node ID d471a3d25d3ec642df5273b75e35922cb30071b8
> # Parent  fa3b07fcf2128db6e4f54f113225e08c37164c2a
> Weighted filter integrated to encoder for testing.
>

Thanks for posting the patch.  For incomplete work it's good to flag it as
[RFC] or something similar, to make sure it doesn't get pushed by accident.


> diff -r fa3b07fcf212 -r d471a3d25d3e source/Lib/TLibCommon/TComPicYuv.cpp
> --- a/source/Lib/TLibCommon/TComPicYuv.cpp      Wed Jul 24 12:07:19 2013
> +0530
> +++ b/source/Lib/TLibCommon/TComPicYuv.cpp      Wed Jul 24 16:52:40 2013
> +0530
> @@ -251,6 +251,24 @@
>      m_bIsBorderExtended = true;
>  }
>
> +Void TComPicYuv::extendPicBorder(x265::ThreadPool *pool, wpScalingParam
> *w)
> +{
> +    if (m_bIsBorderExtended)
> +        return;
> +
> +    /* HPEL generation requires luma integer plane to already be extended
> */
> +    xExtendPicCompBorder(getLumaAddr(), getStride(), getWidth(),
> getHeight(), m_lumaMarginX, m_lumaMarginY);
> +
> +    xExtendPicCompBorder(getCbAddr(), getCStride(), getWidth() >> 1,
> getHeight() >> 1, m_chromaMarginX, m_chromaMarginY);
> +    xExtendPicCompBorder(getCrAddr(), getCStride(), getWidth() >> 1,
> getHeight() >> 1, m_chromaMarginX, m_chromaMarginY);
>

This bit here will need to walk m_refList to look for a match for w.


> +    if (m_refList == NULL)
> +        m_refList = new x265::MotionReference(this, pool, w);
> +    m_refList->generateReferencePlanes();
> +
> +    m_bIsBorderExtended = true;
> +}
> +
>  Void TComPicYuv::xExtendPicCompBorder(Pel* recon, Int stride, Int width,
> Int height, Int iMarginX, Int iMarginY)
>  {
>      Int   x, y;
> diff -r fa3b07fcf212 -r d471a3d25d3e source/Lib/TLibCommon/TComPicYuv.h
> --- a/source/Lib/TLibCommon/TComPicYuv.h        Wed Jul 24 12:07:19 2013
> +0530
> +++ b/source/Lib/TLibCommon/TComPicYuv.h        Wed Jul 24 16:52:40 2013
> +0530
> @@ -43,6 +43,7 @@
>
>  #include "x265.h"
>  #include "reference.h"
> +#include "TComSlice.h"
>
>  class TShortYUV;
>

It's better to forward decl wpScalingParam like TShortYUV here, instead of
including TComSlice.h (reduces the amount of recompiles necessary when
headers change)


>
> @@ -184,6 +185,7 @@
>
>      //  Extend function of picture buffer
>      Void  extendPicBorder(x265::ThreadPool *pool);
> +    Void  extendPicBorder(x265::ThreadPool *pool, wpScalingParam *w);
>
>      //  Dump picture
>      Void  dump(Char* pFileName, Bool bAdd = false);
> diff -r fa3b07fcf212 -r d471a3d25d3e source/Lib/TLibCommon/TComRdCost.cpp
> --- a/source/Lib/TLibCommon/TComRdCost.cpp      Wed Jul 24 12:07:19 2013
> +0530
> +++ b/source/Lib/TLibCommon/TComRdCost.cpp      Wed Jul 24 16:52:40 2013
> +0530
> @@ -201,10 +201,10 @@
>
>  UInt TComRdCost::xGetSAD(DistParam* distParam)
>  {
> -    if (distParam->applyWeight)
> -    {
> -        return xGetSADw(distParam);
> -    }
> +    //if (distParam->applyWeight)
> +    //{
> +    //    return xGetSADw(distParam);
> +    //}
>
>      Pel* org   = distParam->fenc;
>      Pel* cur   = distParam->fref;
> @@ -230,10 +230,10 @@
>
>  UInt TComRdCost::xGetSAD4(DistParam* distParam)
>  {
> -    if (distParam->applyWeight)
> -    {
> -        return xGetSADw(distParam);
> -    }
> +    //if (distParam->applyWeight)
> +    //{
> +    //    return xGetSADw(distParam);
> +    //}
>
>      Pel* org   = distParam->fenc;
>      Pel* cur   = distParam->fref;
> @@ -261,10 +261,10 @@
>
>  UInt TComRdCost::xGetSAD8(DistParam* distParam)
>  {
> -    if (distParam->applyWeight)
> -    {
> -        return xGetSADw(distParam);
> -    }
> +    //if (distParam->applyWeight)
> +    //{
> +    //    return xGetSADw(distParam);
> +    //}
>
>      Pel* org = distParam->fenc;
>      Pel* cur = distParam->fref;
> @@ -296,10 +296,10 @@
>
>  UInt TComRdCost::xGetSAD16(DistParam* distParam)
>  {
> -    if (distParam->applyWeight)
> -    {
> -        return xGetSADw(distParam);
> -    }
> +    //if (distParam->applyWeight)
> +    //{
> +    //    return xGetSADw(distParam);
> +    //}
>
>      Pel* org = distParam->fenc;
>      Pel* cur = distParam->fref;
> @@ -339,10 +339,10 @@
>
>  UInt TComRdCost::xGetSAD12(DistParam* distparam)
>  {
> -    if (distparam->applyWeight)
> -    {
> -        return xGetSADw(distparam);
> -    }
> +    //if (distparam->applyWeight)
> +    //{
> +    //    return xGetSADw(distparam);
> +    //}
>
>      Pel* org = distparam->fenc;
>      Pel* cur = distparam->fref;
> @@ -421,10 +421,10 @@
>
>  UInt TComRdCost::xGetSAD32(DistParam* distParam)
>  {
> -    if (distParam->applyWeight)
> -    {
> -        return xGetSADw(distParam);
> -    }
> +    //if (distParam->applyWeight)
> +    //{
> +    //    return xGetSADw(distParam);
> +    //}
>
>      Pel* org = distParam->fenc;
>      Pel* cur = distParam->fref;
> @@ -480,10 +480,10 @@
>
>  UInt TComRdCost::xGetSAD24(DistParam* distParam)
>  {
> -    if (distParam->applyWeight)
> -    {
> -        return xGetSADw(distParam);
> -    }
> +    //if (distParam->applyWeight)
> +    //{
> +    //    return xGetSADw(distParam);
> +    //}
>
>      Pel* org = distParam->fenc;
>      Pel* cur = distParam->fref;
> @@ -531,10 +531,10 @@
>
>  UInt TComRdCost::xGetSAD64(DistParam* distParam)
>  {
> -    if (distParam->applyWeight)
> -    {
> -        return xGetSADw(distParam);
> -    }
> +    //if (distParam->applyWeight)
> +    //{
> +    //    return xGetSADw(distParam);
> +    //}
>
>      Pel* org = distParam->fenc;
>      Pel* cur = distParam->fref;
> @@ -623,10 +623,10 @@
>
>  UInt TComRdCost::xGetSAD48(DistParam* distParam)
>  {
> -    if (distParam->applyWeight)
> -    {
> -        return xGetSADw(distParam);
> -    }
> +    //if (distParam->applyWeight)
> +    //{
> +    //    return xGetSADw(distParam);
> +    //}
>
>      Pel* org = distParam->fenc;
>      Pel* cur = distParam->fref;
> @@ -724,10 +724,10 @@
>
>  UInt TComRdCost::xGetSSE(DistParam* distParam)
>  {
> -    if (distParam->applyWeight)
> -    {
> -        return xGetSSEw(distParam);
> -    }
> +    //if (distParam->applyWeight)
> +    //{
> +    //    return xGetSSEw(distParam);
> +    //}
>
>      Int  rows = distParam->rows;
>      Int  cols = distParam->cols;
> @@ -788,11 +788,11 @@
>
>  UInt TComRdCost::xGetSSE4(DistParam* distParam)
>  {
> -    if (distParam->applyWeight)
> -    {
> -        assert(distParam->cols == 4);
> -        return xGetSSEw(distParam);
> -    }
> +    //if (distParam->applyWeight)
> +    //{
> +    //    assert(distParam->cols == 4);
> +    //    return xGetSSEw(distParam);
> +    //}
>
>      Int  rows = distParam->rows;
>      Int  strideOrg = distParam->fencstride;
> @@ -860,11 +860,11 @@
>
>  UInt TComRdCost::xGetSSE8(DistParam* distParam)
>  {
> -    if (distParam->applyWeight)
> -    {
> -        assert(distParam->cols == 8);
> -        return xGetSSEw(distParam);
> -    }
> +    //if (distParam->applyWeight)
> +    //{
> +    //    assert(distParam->cols == 8);
> +    //    return xGetSSEw(distParam);
> +    //}
>
>      Pel* org = distParam->fenc;
>      Pel* cur = distParam->fref;
> @@ -948,11 +948,11 @@
>
>  UInt TComRdCost::xGetSSE16(DistParam* distParam)
>  {
> -    if (distParam->applyWeight)
> -    {
> -        assert(distParam->cols == 16);
> -        return xGetSSEw(distParam);
> -    }
> +    //if (distParam->applyWeight)
> +    //{
> +    //    assert(distParam->cols == 16);
> +    //    return xGetSSEw(distParam);
> +    //}
>      Pel* org = distParam->fenc;
>      Pel* cur = distParam->fref;
>      Int  rows = distParam->rows;
> @@ -1039,10 +1039,10 @@
>
>  UInt TComRdCost::xGetSSE16N(DistParam* distParam)
>  {
> -    if (distParam->applyWeight)
> -    {
> -        return xGetSSEw(distParam);
> -    }
> +    //if (distParam->applyWeight)
> +    //{
> +    //    return xGetSSEw(distParam);
> +    //}
>      Pel* org = distParam->fenc;
>      Pel* cur = distParam->fref;
>      Int  rows = distParam->rows;
> @@ -1159,11 +1159,11 @@
>
>  UInt TComRdCost::xGetSSE32(DistParam* distParam)
>  {
> -    if (distParam->applyWeight)
> -    {
> -        assert(distParam->cols == 32);
> -        return xGetSSEw(distParam);
> -    }
> +    //if (distParam->applyWeight)
> +    //{
> +    //    assert(distParam->cols == 32);
> +    //    return xGetSSEw(distParam);
> +    //}
>      Pel* org = distParam->fenc;
>      Pel* cur = distParam->fref;
>      Int  rows = distParam->rows;
> @@ -1344,11 +1344,11 @@
>
>  UInt TComRdCost::xGetSSE64(DistParam* distParam)
>  {
> -    if (distParam->applyWeight)
> -    {
> -        assert(distParam->cols == 64);
> -        return xGetSSEw(distParam);
> -    }
> +    //if (distParam->applyWeight)
> +    //{
> +    //    assert(distParam->cols == 64);
> +    //    return xGetSSEw(distParam);
> +    //}
>      Pel* org = distParam->fenc;
>      Pel* cur = distParam->fref;
>      Int  rows = distParam->rows;
> @@ -1581,10 +1581,10 @@
>
>  UInt TComRdCost::xGetHADs4(DistParam* distParam)
>  {
> -    if (distParam->applyWeight)
> -    {
> -        return xGetHADs4w(distParam);
> -    }
> +    //if (distParam->applyWeight)
> +    //{
> +    //    return xGetHADs4w(distParam);
> +    //}
>      Pel* org = distParam->fenc;
>      Pel* cur = distParam->fref;
>      Int  rows = distParam->rows;
> @@ -1607,10 +1607,10 @@
>
>  UInt TComRdCost::xGetHADs8(DistParam* distParam)
>  {
> -    if (distParam->applyWeight)
> -    {
> -        return xGetHADs8w(distParam);
> -    }
> +    //if (distParam->applyWeight)
> +    //{
> +    //    return xGetHADs8w(distParam);
> +    //}
>      Pel* org = distParam->fenc;
>      Pel* cur = distParam->fref;
>      Int  rows = distParam->rows;
> @@ -1643,10 +1643,10 @@
>
>  UInt TComRdCost::xGetHADs(DistParam* distParam)
>  {
> -    if (distParam->applyWeight)
> -    {
> -        return xGetHADsw(distParam);
> -    }
> +    //if (distParam->applyWeight)
> +    //{
> +    //    return xGetHADsw(distParam);
> +    //}
>      Pel* org = distParam->fenc;
>      Pel* cur = distParam->fref;
>      Int  rows = distParam->rows;
> diff -r fa3b07fcf212 -r d471a3d25d3e source/Lib/TLibCommon/TComSlice.h
> --- a/source/Lib/TLibCommon/TComSlice.h Wed Jul 24 12:07:19 2013 +0530
> +++ b/source/Lib/TLibCommon/TComSlice.h Wed Jul 24 16:52:40 2013 +0530
> @@ -1413,7 +1413,6 @@
>      UInt        m_sliceSegmentBits;
>      Bool        m_bFinalized;
>
> -    wpScalingParam  m_weightPredTable[2][MAX_NUM_REF][3]; //
> [REF_PIC_LIST_0 or REF_PIC_LIST_1][refIdx][0:Y, 1:U, 2:V]
>      wpACDCParam     m_weightACDCParam[3];                 // [0:Y, 1:U,
> 2:V]
>
>      std::vector<UInt> m_tileByteLocation;
> @@ -1431,6 +1430,8 @@
>
>  public:
>
> +    wpScalingParam  m_weightPredTable[2][MAX_NUM_REF][3]; //
> [REF_PIC_LIST_0 or REF_PIC_LIST_1][refIdx][0:Y, 1:U, 2:V]
> +
>

This would be a good place to add:  MotionReference* m_mref[2];


>      TComSlice();
>      virtual ~TComSlice();
>      Void      initSlice();
> diff -r fa3b07fcf212 -r d471a3d25d3e source/Lib/TLibEncoder/TEncSearch.cpp
> --- a/source/Lib/TLibEncoder/TEncSearch.cpp     Wed Jul 24 12:07:19 2013
> +0530
> +++ b/source/Lib/TLibEncoder/TEncSearch.cpp     Wed Jul 24 16:52:40 2013
> +0530
> @@ -3331,7 +3331,8 @@
>
>      setWpScalingDistParam(cu, refIdxPred, picList);
>
> -    Pel* fref = cu->getSlice()->getRefPic(picList,
> refIdxPred)->getPicYuvRec()->getLumaAddr(cu->getAddr(),
> cu->getZorderIdxInCU() + partAddr);
> +    Pel* fref = cu->getSlice()->getRefPic(picList,
> refIdxPred)->getPicYuvRec()->getLumaFilterBlock(0,0,cu->getAddr(),
> cu->getZorderIdxInCU() + partAddr);
> +
>      Int  stride  = cu->getSlice()->getRefPic(picList,
> refIdxPred)->getPicYuvRec()->getStride();
>
>      // Configure the MV bit cost calculator
> diff -r fa3b07fcf212 -r d471a3d25d3e source/Lib/TLibEncoder/TEncSlice.cpp
> --- a/source/Lib/TLibEncoder/TEncSlice.cpp      Wed Jul 24 12:07:19 2013
> +0530
> +++ b/source/Lib/TLibEncoder/TEncSlice.cpp      Wed Jul 24 16:52:40 2013
> +0530
> @@ -421,17 +421,35 @@
>          xCheckWPEnable(slice);
>      }
>
> +    wpexplicit = (slice->getSliceType() == P_SLICE &&
> slice->getPPS()->getUseWP());
> +
>      Int numPredDir = slice->isInterP() ? 1 : 2;
>
> -    for (Int refList = 0; refList < numPredDir; refList++)
> -    {
> -        RefPicList  picList = (refList ? REF_PIC_LIST_1 : REF_PIC_LIST_0);
> -        for (Int refIdxTemp = 0; refIdxTemp <
> slice->getNumRefIdx(picList); refIdxTemp++)
> -        {
> -            // To do: Call the merged IP + weighted frames if weighted
> prediction enabled
> -            slice->getRefPic(picList,
> refIdxTemp)->getPicYuvRec()->extendPicBorder(x265::ThreadPool::getThreadPool());
> +    if(wpexplicit)
> +     {
> +        for (Int refList = 0; refList < numPredDir; refList++)
> +         {
> +            RefPicList  picList = (refList ? REF_PIC_LIST_1 :
> REF_PIC_LIST_0);
> +            for (Int refIdxTemp = 0; refIdxTemp <
> slice->getNumRefIdx(picList); refIdxTemp++)
> +            {
> +                //Call the merged IP + weighted frames if weighted
> prediction enabled
> +                wpScalingParam *w =
> &(slice->m_weightPredTable[picList][refIdxTemp][0]);
> +                slice->getRefPic(picList,
> refIdxTemp)->getPicYuvRec()->extendPicBorder(x265::ThreadPool::getThreadPool(),
> w);
>

 if extendPicBorder() returned the MotionReference with weight w (that it
probably just created) then we could store that in slice->m_mref[refList].
  I think slice->getNumRefIdx(picList) returns 0 or 1, but perhaps that
should be checked with the B frame setup.  If the MotionReference is cached
here, we would never have to walk the m_refList.

+            }
>          }
>      }
> +    else
> +    {
> +        for (Int refList = 0; refList < numPredDir; refList++)
> +        {
> +            RefPicList  picList = (refList ? REF_PIC_LIST_1 :
> REF_PIC_LIST_0);
> +            for (Int refIdxTemp = 0; refIdxTemp <
> slice->getNumRefIdx(picList); refIdxTemp++)
> +            {
> +                slice->getRefPic(picList,
> refIdxTemp)->getPicYuvRec()->extendPicBorder(x265::ThreadPool::getThreadPool());
> +            }
> +         }
> +     }
> +
>
>      frameEncoder->encode(pic, slice);
>
> diff -r fa3b07fcf212 -r d471a3d25d3e source/common/ipfilter.cpp
> --- a/source/common/ipfilter.cpp        Wed Jul 24 12:07:19 2013 +0530
> +++ b/source/common/ipfilter.cpp        Wed Jul 24 16:52:40 2013 +0530
> @@ -468,6 +468,7 @@
>      filterVertical_s_p<8>(src, srcStride, dstI, dstStride, block_width,
> block_height, g_lumaFilter[2]);
>      filterVertical_s_p<8>(src, srcStride, dstE, dstStride, block_width,
> block_height, g_lumaFilter[1]);
>      filterVertical_s_p<8>(src, srcStride, dstP, dstStride, block_width,
> block_height, g_lumaFilter[3]);
> +
>      extendPicCompBorder(dstE, dstStride, block_width, block_height,
> marginX, marginY);
>      extendPicCompBorder(dstI, dstStride, block_width, block_height,
> marginX, marginY);
>      extendPicCompBorder(dstP, dstStride, block_width, block_height,
> marginX, marginY);
> @@ -509,7 +510,7 @@
>
>  // filterHorizontal, Multiplane, Weighted
>  void filterHorizontalWeighted(pixel *src, int srcStride, short *midF,
> short* midA, short* midB, short* midC, int midStride,
> -                              pixel *dstA, pixel *dstB, pixel *dstC, int
> dstStride, int block_width, int block_height,
> +                              pixel *dstF, pixel *dstA, pixel *dstB,
> pixel *dstC, int dstStride, int block_width, int block_height,
>                                int marginX, int marginY, int w, int
> roundw, int shiftw, int offsetw)
>  {
>      filterConvertPelToShort(src, srcStride, midF, midStride, block_width,
> block_height);
> @@ -517,10 +518,12 @@
>      filterHorizontal_p_s<8>(src, srcStride, midA, midStride, block_width,
> block_height, g_lumaFilter[1]);
>      filterHorizontal_p_s<8>(src, srcStride, midC, midStride, block_width,
> block_height, g_lumaFilter[3]);
>
> +    weightUnidir(midF, dstF, midStride, dstStride, block_width,
> block_height, w, roundw, shiftw, offsetw);
>      weightUnidir(midA, dstA, midStride, dstStride, block_width,
> block_height, w, roundw, shiftw, offsetw);
>      weightUnidir(midB, dstB, midStride, dstStride, block_width,
> block_height, w, roundw, shiftw, offsetw);
>      weightUnidir(midC, dstC, midStride, dstStride, block_width,
> block_height, w, roundw, shiftw, offsetw);
>
> +    extendPicCompBorder(dstF, dstStride, block_width, block_height,
> marginX, marginY);
>      extendPicCompBorder(dstA, dstStride, block_width, block_height,
> marginX, marginY);
>      extendPicCompBorder(dstB, dstStride, block_width, block_height,
> marginX, marginY);
>      extendPicCompBorder(dstC, dstStride, block_width, block_height,
> marginX, marginY);
> @@ -590,4 +593,5 @@
>      p.filterVwghtd = filterVerticalWeighted;
>      p.filterHwghtd = filterHorizontalWeighted;
>  }
> +
>  }
> diff -r fa3b07fcf212 -r d471a3d25d3e source/common/primitives.h
> --- a/source/common/primitives.h        Wed Jul 24 12:07:19 2013 +0530
> +++ b/source/common/primitives.h        Wed Jul 24 16:52:40 2013 +0530
> @@ -223,7 +223,7 @@
>  typedef void (*filterHmulti_t)(pixel *src, int srcStride, short *midF,
> short* midA, short* midB, short* midC, int midStride,
>                                 pixel *dstA, pixel *dstB, pixel *dstC, int
> dstStride, int block_width, int block_height, int marginX, int marginY);
>  typedef void (*filterHwghtd_t)(pixel *src, int srcStride, short *midF,
> short* midA, short* midB, short* midC, int midStride,
> -                               pixel *pDstA, pixel *pDstB, pixel *pDstC,
> int pDstStride, int block_width, int block_height,
> +                               pixel *dstF, pixel *pDstA, pixel *pDstB,
> pixel *pDstC, int pDstStride, int block_width, int



hmm, should cleanup those hungarian p prefixes while we're in the area.


> block_height,
>                                 int marginX, int marginY, int w, int
> roundw, int shiftw, int offsetw);
>  typedef void (*weightpUni_t)(short *src, pixel *dst, int srcStride, int
> dstStride, int width, int height, int w0, int round, int shift, int offset);
>  typedef void (*scale_t)(pixel *dst, pixel *src, intptr_t stride);
> diff -r fa3b07fcf212 -r d471a3d25d3e source/common/reference.cpp
> --- a/source/common/reference.cpp       Wed Jul 24 12:07:19 2013 +0530
> +++ b/source/common/reference.cpp       Wed Jul 24 16:52:40 2013 +0530
> @@ -68,6 +68,47 @@
>              m_lumaPlane[i][j] = (pixel*)xMalloc(pixel,  padwidth *
> padheight) + m_startPad;
>          }
>      }
> +
> +    m_isWeighted = false;
> +}
> +
> +MotionReference::MotionReference(TComPicYuv* pic, ThreadPool *pool,
> wpScalingParam *w)
> +    : JobProvider(pool)
> +{
>

I think I would prefer a single constructor and just pass w as NULL if
unweighted.


> +    m_reconPic = pic;
> +    int width = pic->getWidth();
> +    int height = pic->getHeight();
> +    m_lumaStride = pic->getStride();
> +    m_startPad = pic->m_lumaMarginY * m_lumaStride + pic->m_lumaMarginX;
> +    m_intStride = width + s_tmpMarginX * 4;
> +    m_extendOffset = s_tmpMarginY * m_lumaStride + s_tmpMarginX;
> +    m_offsetToLuma = s_tmpMarginY * 2 * m_intStride  + s_tmpMarginX * 2;
> +    m_filterWidth = width + s_tmpMarginX * 2;
> +    m_filterHeight = height + s_tmpMarginY * 2;
> +    m_next = NULL;
> +
> +    /* directly reference the pre-extended integer pel plane */
> +    //m_lumaPlane[0][0] = pic->m_picBufY + m_startPad;
> +
> +    /* Create buffers for Hpel/Qpel Planes */
> +    size_t padwidth = width + pic->m_lumaMarginX * 2;
> +    size_t padheight = height + pic->m_lumaMarginY * 2;
> +    for (int i = 0; i < 4; i++)
> +    {
> +        for (int j = 0; j < 4; j++)
> +        {
> +            //if (i == 0 && j == 0)
> +            //    continue;

+            m_lumaPlane[i][j] = (pixel*)xMalloc(pixel,  padwidth *
> padheight) + m_startPad;
> +        }
> +    }
> +
> +    //Innitialization of weight parameters
>

tpyo


> +    m_weight      = w->inputWeight;
> +    m_offset = w->inputOffset * (1 << (g_bitDepth - 8));
> +    m_shift  = w->log2WeightDenom;
> +    m_round  = (w->log2WeightDenom >= 1) ? (1 << (w->log2WeightDenom -
> 1)) : (0);
> +    m_isWeighted = true;
>  }
>
>  MotionReference::~MotionReference()
> @@ -105,7 +146,23 @@
>          /* This one function call generates the four intermediate (short)
> planes for each
>           * QPEL offset in the horizontal direction.  At the same time it
> outputs the three
>           * Y=0 output (padded pixel) planes since they require no
> vertical interpolation */
> -        primitives.filterHmulti(srcPtr, m_lumaStride,
>        // source buffer
> +        if(m_isWeighted)
> +        {
> +           primitives.filterHwghtd(srcPtr, m_lumaStride,               //
> source buffer
> +                                   intPtrF, intPtrA, intPtrB, intPtrC,
> m_intStride, // 4 intermediate HPEL buffers
> +                                   m_lumaPlane[0][0] + bufOffset,
> +                                   m_lumaPlane[1][0] + bufOffset,
> +                                   m_lumaPlane[2][0] + bufOffset,
> +                                   m_lumaPlane[3][0] + bufOffset,
> m_lumaStride,     // 3 (x=n, y=0) output buffers (no V interp)
> +                                   m_filterWidth + (2 * s_intMarginX),
>            // filter dimensions with margins
> +                                   m_filterHeight + (2 * s_intMarginY),
> +                                   m_reconPic->m_lumaMarginX -
> s_tmpMarginX - s_intMarginX, // pixel extension margins
> +                                   m_reconPic->m_lumaMarginY -
> s_tmpMarginY - s_intMarginY,
> +                                   m_weight, m_round, m_shift, m_offset);
> +       }
> +       else
> +       {
> +                                primitives.filterHmulti(srcPtr,
> m_lumaStride,                            // source buffer
>                                  intPtrF, intPtrA, intPtrB, intPtrC,
> m_intStride, // 4 intermediate HPEL buffers
>                                  m_lumaPlane[1][0] + bufOffset,
>                                  m_lumaPlane[2][0] + bufOffset,
> @@ -114,6 +171,7 @@
>                                  m_filterHeight + (2 * s_intMarginY),
>                                  m_reconPic->m_lumaMarginX - s_tmpMarginX
> - s_intMarginX, // pixel extension margins
>                                  m_reconPic->m_lumaMarginY - s_tmpMarginY
> - s_intMarginY);
> +        }
>      }
>
>      if (!m_pool)
> @@ -173,5 +231,12 @@
>      pixel *dstPtr2 = m_lumaPlane[x][2] - s_tmpMarginY * m_lumaStride -
> s_tmpMarginX;
>      pixel *dstPtr3 = m_lumaPlane[x][3] - s_tmpMarginY * m_lumaStride -
> s_tmpMarginX;
>
> -    primitives.filterVmulti(intPtr, m_intStride, dstPtr1, dstPtr2,
> dstPtr3, m_lumaStride, m_filterWidth, m_filterHeight,
> m_reconPic->m_lumaMarginX - s_tmpMarginX, m_reconPic->m_lumaMarginY -
> s_tmpMarginY);
> +    if(m_isWeighted)
> +    {
> +        primitives.filterVwghtd(intPtr, m_intStride, dstPtr1, dstPtr2,
> dstPtr3, m_lumaStride, m_filterWidth, m_filterHeight,
> m_reconPic->m_lumaMarginX - s_tmpMarginX, m_reconPic->m_lumaMarginY -
> s_tmpMarginY, m_weight, m_round, m_shift, m_offset);
> +    }
> +    else
> +    {
> +        primitives.filterVmulti(intPtr, m_intStride, dstPtr1, dstPtr2,
> dstPtr3, m_lumaStride, m_filterWidth, m_filterHeight,
> m_reconPic->m_lumaMarginX - s_tmpMarginX, m_reconPic->m_lumaMarginY -
> s_tmpMarginY);
> +    }
>  }
> diff -r fa3b07fcf212 -r d471a3d25d3e source/common/reference.h
> --- a/source/common/reference.h Wed Jul 24 12:07:19 2013 +0530
> +++ b/source/common/reference.h Wed Jul 24 16:52:40 2013 +0530
> @@ -27,6 +27,7 @@
>  #include "primitives.h"
>  #include "threading.h"
>  #include "threadpool.h"
> +#include "TLibCommon/TComSlice.h"
>
>  class TComPicYuv;
>
> @@ -38,6 +39,7 @@
>  public:
>
>      MotionReference(TComPicYuv*, ThreadPool *);
> +    MotionReference(TComPicYuv*, ThreadPool *, wpScalingParam *w);
>
>      ~MotionReference();
>
> @@ -75,6 +77,12 @@
>      int         m_filterHeight;
>      short      *m_intermediateValues;
>
> +    int m_weight;
> +    int m_offset;
> +    int m_shift;
> +    int m_round;
> +    bool m_isWeighted;
> +
>      MotionReference& operator =(const MotionReference&);
>  };
>  }
>
> _______________________________________________
> 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/private/x265-devel/attachments/20130724/b0e0714d/attachment-0001.html>


More information about the x265-devel mailing list