[x265] [PATCH 3 of 4] Using the weighted frames in prediction

shazeb at multicorewareinc.com shazeb at multicorewareinc.com
Thu Aug 1 14:23:36 CEST 2013


# HG changeset patch
# User Shazeb N Khan
# Date 1375357883 -19800
#      Thu Aug 01 17:21:23 2013 +0530
# Node ID 129570f2b79a35685a8f992a5109852b9656ddfd
# Parent  04d9e878212d42b7a985bb49a54cad259976b2af
Using the weighted frames in prediction

diff -r 04d9e878212d -r 129570f2b79a source/Lib/TLibCommon/TComPrediction.cpp
--- a/source/Lib/TLibCommon/TComPrediction.cpp	Thu Aug 01 17:20:24 2013 +0530
+++ b/source/Lib/TLibCommon/TComPrediction.cpp	Thu Aug 01 17:21:23 2013 +0530
@@ -257,7 +257,15 @@
             if (cu->getSlice()->getPPS()->getUseWP())
             {
                 TShortYUV* pcMbYuv = &m_predShortYuv[0];
-                xPredInterUni(cu, partAddr, width, height, picList, pcMbYuv);
+                Int refId = cu->getCUMvField(picList)->getRefIdx(partAddr);
+                assert(refId >= 0);
+
+                MV mv = cu->getCUMvField(picList)->getMv(partAddr);
+                cu->clipMv(mv);
+
+                xPredInterLumaBlk(cu, cu->getSlice()->m_mref[picList][refId], partAddr, &mv, width, height, predYuv);
+                xPredInterChromaBlk(cu, cu->getSlice()->getRefPic(picList, refId)->getPicYuvRec(), partAddr, &mv, width, height, pcMbYuv);
+
                 xWeightedPredictionUni(cu, pcMbYuv, partAddr, width, height, picList, predYuv);
             }
             else
@@ -288,7 +296,17 @@
             if (cu->getSlice()->getPPS()->getUseWP())
             {
                 TShortYUV* pcMbYuv = &m_predShortYuv[0];
-                xPredInterUni(cu, partAddr, width, height, picList, pcMbYuv);
+                //xPredInterUni(cu, partAddr, width, height, picList, pcMbYuv);
+
+                Int refId = cu->getCUMvField(picList)->getRefIdx(partAddr);
+                assert(refId >= 0);
+
+                MV mv = cu->getCUMvField(picList)->getMv(partAddr);
+                cu->clipMv(mv);
+
+                xPredInterLumaBlk(cu, cu->getSlice()->m_mref[picList][refId], partAddr, &mv, width, height, predYuv);
+                xPredInterChromaBlk(cu, cu->getSlice()->getRefPic(picList, refId)->getPicYuvRec(), partAddr, &mv, width, height, pcMbYuv);
+
                 xWeightedPredictionUni(cu, pcMbYuv, partAddr, width, height, picList, predYuv);
             }
             else
@@ -386,23 +404,29 @@
     else if (cu->getSlice()->getPPS()->getUseWP() && cu->getSlice()->getSliceType() == P_SLICE)
     {
         TShortYUV* pcMbYuv;
-        for (Int refList = 0; refList < 2; refList++)
+
+        RefPicList picList = ( REF_PIC_LIST_0);
+        refIdx[0] = cu->getCUMvField(picList)->getRefIdx(partAddr);
+
+        if (!(refIdx[0] < 0))
         {
-            RefPicList picList = (refList ? REF_PIC_LIST_1 : REF_PIC_LIST_0);
-            refIdx[refList] = cu->getCUMvField(picList)->getRefIdx(partAddr);
+            assert(refIdx[0] < cu->getSlice()->getNumRefIdx(picList));
 
-            if (refIdx[refList] < 0)
-            {
-                continue;
-            }
+            pcMbYuv = &m_predShortYuv[0];
+            //xPredInterUni(cu, partAddr, width, height, picList, pcMbYuv);
+            Int refId = cu->getCUMvField(picList)->getRefIdx(partAddr);
+            assert(refId >= 0);
 
-            assert(refIdx[refList] < cu->getSlice()->getNumRefIdx(picList));
+            MV mv = cu->getCUMvField(picList)->getMv(partAddr);
+            cu->clipMv(mv);
 
-            pcMbYuv = &m_predShortYuv[refList];
-            xPredInterUni(cu, partAddr, width, height, picList, pcMbYuv);
+            xPredInterLumaBlk(cu, cu->getSlice()->m_mref[picList][refId], partAddr, &mv, width, height, outPredYuv);
+            xPredInterChromaBlk(cu, cu->getSlice()->getRefPic(picList, refId)->getPicYuvRec(), partAddr, &mv, width, height, pcMbYuv);
+
+            xWeightedPredictionUni(cu, &m_predShortYuv[0], partAddr, width, height, REF_PIC_LIST_0, outPredYuv);
+            
         }
 
-        xWeightedPredictionUni(cu, &m_predShortYuv[0], partAddr, width, height, REF_PIC_LIST_0, outPredYuv);
     }
     else
     {
diff -r 04d9e878212d -r 129570f2b79a source/Lib/TLibCommon/TComWeightPrediction.cpp
--- a/source/Lib/TLibCommon/TComWeightPrediction.cpp	Thu Aug 01 17:20:24 2013 +0530
+++ b/source/Lib/TLibCommon/TComWeightPrediction.cpp	Thu Aug 01 17:21:23 2013 +0530
@@ -404,7 +404,7 @@
  * \returns Void
  */
 
-Void TComWeightPrediction::addWeightUni(TShortYUV* srcYuv0, UInt partUnitIdx, UInt width, UInt height, wpScalingParam *wp0, TComYuv* outDstYuv)
+Void TComWeightPrediction::addWeightUni(TShortYUV* srcYuv0, UInt partUnitIdx, UInt width, UInt height, wpScalingParam *wp0, TComYuv* outDstYuv, bool justChroma)
 {
     Short* srcY0  = srcYuv0->getLumaAddr(partUnitIdx);
     Short* srcU0  = srcYuv0->getCbAddr(partUnitIdx);
@@ -414,16 +414,23 @@
     Pel* dstU   = outDstYuv->getCbAddr(partUnitIdx);
     Pel* dstV   = outDstYuv->getCrAddr(partUnitIdx);
 
-    // Luma : --------------------------------------------
-    Int w0      = wp0[0].w;
-    Int offset  = wp0[0].offset;
-    Int shiftNum = IF_INTERNAL_PREC - X265_DEPTH;
-    Int shift   = wp0[0].shift + shiftNum;
-    Int round   = shift ? (1 << (shift - 1)) : 0;
-    UInt srcStride = srcYuv0->m_width;
-    UInt dstStride  = outDstYuv->getStride();
 
-   x265::primitives.weightpUni(srcY0, dstY, srcStride, dstStride, width, height, w0, round, shift, offset);
+    Int w0, offset, shiftNum, shift, round;
+    UInt srcStride, dstStride;
+
+    if(!justChroma)
+    {
+        // Luma : --------------------------------------------
+        w0      = wp0[0].w;
+        offset  = wp0[0].offset;
+        shiftNum = IF_INTERNAL_PREC - X265_DEPTH;
+        shift   = wp0[0].shift + shiftNum;
+        round   = shift ? (1 << (shift - 1)) : 0;
+        srcStride = srcYuv0->m_width;
+        dstStride  = outDstYuv->getStride();
+
+        x265::primitives.weightpUni(srcY0, dstY, srcStride, dstStride, width, height, w0, round, shift, offset);
+    }
 
     // Chroma U : --------------------------------------------
     w0      = wp0[1].w;
@@ -660,5 +667,5 @@
     {
         getWpScaling(cu, -1, refIdx, pwpTmp, pwp);
     }
-    addWeightUni(srcYuv, partAddr, width, height, pwp, outPredYuv);
+    addWeightUni(srcYuv, partAddr, width, height, pwp, outPredYuv, true);
 }
diff -r 04d9e878212d -r 129570f2b79a source/Lib/TLibCommon/TComWeightPrediction.h
--- a/source/Lib/TLibCommon/TComWeightPrediction.h	Thu Aug 01 17:20:24 2013 +0530
+++ b/source/Lib/TLibCommon/TComWeightPrediction.h	Thu Aug 01 17:21:23 2013 +0530
@@ -60,7 +60,7 @@
     Void  addWeightBi(TComYuv* srcYuv0, TComYuv* srcYuv1, UInt partUnitIdx, UInt width, UInt height, wpScalingParam *wp0, wpScalingParam *wp1, TComYuv* outDstYuv, Bool bRound = true);
     Void  addWeightBi(TShortYUV* srcYuv0, TShortYUV* srcYuv1, UInt partUnitIdx, UInt width, UInt height, wpScalingParam *wp0, wpScalingParam *wp1, TComYuv* outDstYuv, Bool bRound = true);
     Void  addWeightUni(TComYuv* srcYuv0, UInt partUnitIdx, UInt width, UInt height, wpScalingParam *wp0, TComYuv* outDstYuv);
-    Void  addWeightUni(TShortYUV* srcYuv0, UInt partUnitIdx, UInt width, UInt height, wpScalingParam *wp0, TComYuv* outDstYuv);
+    Void  addWeightUni(TShortYUV* srcYuv0, UInt partUnitIdx, UInt width, UInt height, wpScalingParam *wp0, TComYuv* outDstYuv, bool justChroma = false);
 
     Void  xWeightedPredictionUni(TComDataCU* cu, TComYuv* srcYuv, UInt partAddr, Int width, Int height, RefPicList picList, TComYuv*& outPredYuv, Int refIdx = -1);
     Void  xWeightedPredictionUni(TComDataCU* cu, TShortYUV* srcYuv, UInt partAddr, Int width, Int height, RefPicList picList, TComYuv*& outPredYuv, Int refIdx = -1);
diff -r 04d9e878212d -r 129570f2b79a source/Lib/TLibEncoder/TEncSearch.cpp
--- a/source/Lib/TLibEncoder/TEncSearch.cpp	Thu Aug 01 17:20:24 2013 +0530
+++ b/source/Lib/TLibEncoder/TEncSearch.cpp	Thu Aug 01 17:21:23 2013 +0530
@@ -3272,17 +3272,8 @@
 
     // prediction pattern
     MotionReference* ref = cu->getSlice()->m_mref[picList][refIfx];
-    if (cu->getSlice()->getPPS()->getUseWP() && cu->getSlice()->getSliceType() == P_SLICE)
-    {
-        TShortYUV *mbYuv = &m_predShortYuv[0];
-        xPredInterLumaBlk(cu, cu->getSlice()->getRefPic(picList, refIfx)->getPicYuvRec(), partAddr, &mvCand, sizex, sizey, mbYuv);
-        xWeightedPredictionUni(cu, mbYuv, partAddr, sizex, sizey, picList, templateCand, refIfx);
-    }
-    else
-    {
-        xPredInterLumaBlk(cu, ref, partAddr, &mvCand, sizex, sizey, templateCand);
-    }
-
+    xPredInterLumaBlk(cu, ref, partAddr, &mvCand, sizex, sizey, templateCand);
+    
     // calc distortion
     UInt cost = m_me.bufSAD(templateCand->getLumaAddr(partAddr), templateCand->getStride());
     x265_emms();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: x265-3.patch
Type: text/x-patch
Size: 8674 bytes
Desc: not available
URL: <http://mailman.videolan.org/private/x265-devel/attachments/20130801/c8e44713/attachment-0001.bin>


More information about the x265-devel mailing list