[x265] [PATCH] Added support for bipred, but 8bpp, 16bpp mismatch

deepthidevaki at multicorewareinc.com deepthidevaki at multicorewareinc.com
Mon Jun 24 14:37:01 CEST 2013


# HG changeset patch
# User Deepthi Devaki
# Date 1372077358 -19800
# Node ID a864e518afece8fe5d8f5abbe349dec84114c98d
# Parent  7f9730659262eed1746df4ce17217d6e5c455f92
Added support for bipred, but 8bpp, 16bpp mismatch

diff -r 7f9730659262 -r a864e518afec source/Lib/TLibCommon/TComPrediction.cpp
--- a/source/Lib/TLibCommon/TComPrediction.cpp	Mon Jun 24 11:38:53 2013 +0530
+++ b/source/Lib/TLibCommon/TComPrediction.cpp	Mon Jun 24 18:05:58 2013 +0530
@@ -77,6 +77,8 @@
 
     m_acYuvPred[0].destroy();
     m_acYuvPred[1].destroy();
+    m_acShortPred[0].destroy();
+    m_acShortPred[1].destroy();
 
     m_cYuvPredTemp.destroy();
 
@@ -126,6 +128,8 @@
         // new structure
         m_acYuvPred[0].create(MAX_CU_SIZE, MAX_CU_SIZE);
         m_acYuvPred[1].create(MAX_CU_SIZE, MAX_CU_SIZE);
+        m_acShortPred[0].create(MAX_CU_SIZE, MAX_CU_SIZE);
+        m_acShortPred[1].create(MAX_CU_SIZE, MAX_CU_SIZE);
 
         m_cYuvPredTemp.create(MAX_CU_SIZE, MAX_CU_SIZE);
     }
@@ -412,7 +416,7 @@
     Int         iWidth;
     Int         iHeight;
     UInt        uiPartAddr;
-
+    
     if (iPartIdx >= 0)
     {
         pcCU->getPartIndexAndSize(iPartIdx, uiPartAddr, iWidth, iHeight);
@@ -420,16 +424,14 @@
         {
             if (pcCU->getSlice()->getPPS()->getUseWP())
             {
-                xPredInterUni(pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, true);
+                TShortYUV* pcMbYuv = &m_acShortPred[0];
+                xPredInterUni(pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, true);
+                xWeightedPredictionUni(pcCU, pcMbYuv, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred);
             }
             else
             {
                 xPredInterUni(pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred);
             }
-            if (pcCU->getSlice()->getPPS()->getUseWP())
-            {
-                xWeightedPredictionUni(pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred);
-            }
         }
         else
         {
@@ -453,16 +455,14 @@
         {
             if (pcCU->getSlice()->getPPS()->getUseWP())
             {
-                xPredInterUni(pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, true);
+                TShortYUV* pcMbYuv = &m_acShortPred[0];
+                xPredInterUni(pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, true);
+                xWeightedPredictionUni(pcCU, pcMbYuv, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred);
             }
             else
             {
                 xPredInterUni(pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred);
             }
-            if (pcCU->getSlice()->getPPS()->getUseWP())
-            {
-                xWeightedPredictionUni(pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred);
-            }
         }
         else
         {
@@ -478,6 +478,7 @@
     }
 }
 
+
 Void TComPrediction::xPredInterUni(TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi)
 {
     assert (bi == false);
@@ -507,11 +508,11 @@
 
 Void TComPrediction::xPredInterBi(TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv*& rpcYuvPred)
 {
-    TComYuv* pcMbYuv;
     Int      iRefIdx[2] = { -1, -1 };
 
     if (pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(uiPartAddr) >= 0 && pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(uiPartAddr) >= 0)
     {
+        TShortYUV* pcMbYuv;
         for (Int iRefList = 0; iRefList < 2; iRefList++)
         {
             RefPicList eRefPicList = (iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0);
@@ -519,22 +520,61 @@
 
             assert(iRefIdx[iRefList] < pcCU->getSlice()->getNumRefIdx(eRefPicList));
 
-            pcMbYuv = &m_acYuvPred[iRefList];
-            xPredInterUni(pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, true);   //pcMbYuv should be TShortYuv
+            pcMbYuv = &m_acShortPred[iRefList];
+            xPredInterUni(pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, true);  
         }
         if (pcCU->getSlice()->getPPS()->getWPBiPred() && pcCU->getSlice()->getSliceType() == B_SLICE)
         {
-            //m_acYuvPred must be TShortYuv
-            xWeightedPredictionBi(pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred);
+            xWeightedPredictionBi(pcCU, &m_acShortPred[0], &m_acShortPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred);
         }
         else
         {
-            //m_acYuvPred must be TShortYuv
-            xWeightedAverage(&m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred);
+            rpcYuvPred->addAvg(&m_acShortPred[0], &m_acShortPred[1], uiPartAddr, iWidth, iHeight);
         }
     }
     else if (pcCU->getSlice()->getPPS()->getWPBiPred() && pcCU->getSlice()->getSliceType() == B_SLICE)
     {
+        TShortYUV* pcMbYuv;
+        for (Int iRefList = 0; iRefList < 2; iRefList++)
+        {
+            RefPicList eRefPicList = (iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0);
+            iRefIdx[iRefList] = pcCU->getCUMvField(eRefPicList)->getRefIdx(uiPartAddr);
+
+            if (iRefIdx[iRefList] < 0)
+            {
+                continue;
+            }
+
+            assert(iRefIdx[iRefList] < pcCU->getSlice()->getNumRefIdx(eRefPicList));
+
+            pcMbYuv = &m_acShortPred[iRefList];
+            xPredInterUni(pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, true); 
+        }
+        xWeightedPredictionBi(pcCU, &m_acShortPred[0], &m_acShortPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred);
+    }
+    else if (pcCU->getSlice()->getPPS()->getUseWP() && pcCU->getSlice()->getSliceType() == P_SLICE)
+    {
+        TShortYUV* pcMbYuv;
+        for (Int iRefList = 0; iRefList < 2; iRefList++)
+        {
+            RefPicList eRefPicList = (iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0);
+            iRefIdx[iRefList] = pcCU->getCUMvField(eRefPicList)->getRefIdx(uiPartAddr);
+
+            if (iRefIdx[iRefList] < 0)
+            {
+                continue;
+            }
+
+            assert(iRefIdx[iRefList] < pcCU->getSlice()->getNumRefIdx(eRefPicList));
+
+            pcMbYuv = &m_acShortPred[iRefList];
+            xPredInterUni(pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, true); 
+        }
+        xWeightedPredictionUni(pcCU, &m_acShortPred[0], uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, rpcYuvPred);
+    }
+    else
+    {
+        TComYuv* pcMbYuv;
         for (Int iRefList = 0; iRefList < 2; iRefList++)
         {
             RefPicList eRefPicList = (iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0);
@@ -548,49 +588,8 @@
             assert(iRefIdx[iRefList] < pcCU->getSlice()->getNumRefIdx(eRefPicList));
 
             pcMbYuv = &m_acYuvPred[iRefList];
-            xPredInterUni(pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, true); //pcMbYuv must be TShort
+            xPredInterUni(pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv); 
         }
-        //m_acYuvPred must be TShort
-        xWeightedPredictionBi(pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred);
-    }
-    else if (pcCU->getSlice()->getPPS()->getUseWP() && pcCU->getSlice()->getSliceType() == P_SLICE)
-    {
-        for (Int iRefList = 0; iRefList < 2; iRefList++)
-        {
-            RefPicList eRefPicList = (iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0);
-            iRefIdx[iRefList] = pcCU->getCUMvField(eRefPicList)->getRefIdx(uiPartAddr);
-
-            if (iRefIdx[iRefList] < 0)
-            {
-                continue;
-            }
-
-            assert(iRefIdx[iRefList] < pcCU->getSlice()->getNumRefIdx(eRefPicList));
-
-            pcMbYuv = &m_acYuvPred[iRefList];
-            xPredInterUni(pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, true); //pcMbYuv must be TShortYuv
-        }
-        //m_acYuvPred must be TShortYuv
-        xWeightedPredictionUni(pcCU, &m_acYuvPred[0], uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, rpcYuvPred);
-    }
-    else
-    {
-        for (Int iRefList = 0; iRefList < 2; iRefList++)
-        {
-            RefPicList eRefPicList = (iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0);
-            iRefIdx[iRefList] = pcCU->getCUMvField(eRefPicList)->getRefIdx(uiPartAddr);
-
-            if (iRefIdx[iRefList] < 0)
-            {
-                continue;
-            }
-
-            assert(iRefIdx[iRefList] < pcCU->getSlice()->getNumRefIdx(eRefPicList));
-
-            pcMbYuv = &m_acYuvPred[iRefList];
-            xPredInterUni(pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv); //pcMbYuv must be TComYuv
-        }
-        //m_acYuvPred must be TComYuv
         xWeightedAverage(&m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred);
     }
 }
@@ -609,77 +608,22 @@
  */
 Void TComPrediction::xPredInterLumaBlk(TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi)
 { 
-#if HIGHBITDEPTH
-    if(bi == false)
-#endif
-    {
-        assert(bi == false);
+    assert(bi == false);
 
-        Int refStride = refPic->getStride();
-        Int refOffset = (mv->getHor() >> 2) + (mv->getVer() >> 2) * refStride;
-        Pel *ref      =  refPic->getLumaAddr(cu->getAddr(), cu->getZorderIdxInCU() + partAddr) + refOffset;
+    Int refStride = refPic->getStride();
+    Int refOffset = (mv->getHor() >> 2) + (mv->getVer() >> 2) * refStride;
+    Pel *ref      =  refPic->getLumaAddr(cu->getAddr(), cu->getZorderIdxInCU() + partAddr) + refOffset;
 
-        Int dstStride = dstPic->getStride();
-        Pel *dst      = dstPic->getLumaAddr(partAddr);
+    Int dstStride = dstPic->getStride();
+    Pel *dst      = dstPic->getLumaAddr(partAddr);
 
-        Int xFrac = mv->getHor() & 0x3;
-        Int yFrac = mv->getVer() & 0x3;
+    Int xFrac = mv->getHor() & 0x3;
+    Int yFrac = mv->getVer() & 0x3;
 
-        Pel* src = refPic->getLumaFilterBlock(yFrac, xFrac, cu->getAddr(), cu->getZorderIdxInCU() + partAddr) + refOffset;
-        Int srcStride = refPic->getStride();
+    Pel* src = refPic->getLumaFilterBlock(yFrac, xFrac, cu->getAddr(), cu->getZorderIdxInCU() + partAddr) + refOffset;
+    Int srcStride = refPic->getStride();
 
-        x265::primitives.cpyblock(width, height, (pixel*)dst, dstStride, (pixel*)src, srcStride);
-    }
-#if HIGHBITDEPTH
-    else /* For biprediction. will work correctly only when HIGHBITDEPTH enabled. Will be removed once bipred is fixed.  */
-    {
-        assert(bi == true);
-
-        Int refStride = refPic->getStride();
-        Int refOffset = (mv->getHor() >> 2) + (mv->getVer() >> 2) * refStride;
-        Pel *ref      =  refPic->getLumaAddr(cu->getAddr(), cu->getZorderIdxInCU() + partAddr) + refOffset;
-
-        Int dstStride = dstPic->getStride();
-        Short *dst      = (Short*)dstPic->getLumaAddr(partAddr);
-
-        Int xFrac = mv->getHor() & 0x3;
-        Int yFrac = mv->getVer() & 0x3;
-
-        Pel* src = refPic->getLumaFilterBlock(yFrac, xFrac, cu->getAddr(), cu->getZorderIdxInCU() + partAddr) + refOffset;
-        Int srcStride = refPic->getStride();
-
-        if (yFrac == 0)
-        {
-            if(xFrac==0)
-            {
-                //filterconvertpeltoshort
-                x265::primitives.ipfilterConvert_p_s(g_bitDepthY, (pixel*)ref , refStride, dst, dstStride, width, height);
-            }
-            else
-            {
-                //filterhorizontalpelshort
-                x265::primitives.ipFilter_p_s[FILTER_H_P_S_8](g_bitDepthY, (pixel*)ref , refStride, dst, dstStride, width, height, TComInterpolationFilter::m_lumaFilter[xFrac]);
-            }
-        }
-        else if (xFrac == 0)
-        {
-            //filterverticalpelshort
-            x265::primitives.ipFilter_p_s[FILTER_V_P_S_8](g_bitDepthY, (pixel*)ref , refStride, dst, dstStride, width, height, TComInterpolationFilter::m_lumaFilter[yFrac]);
-        }
-        else
-        {
-            Int tmpStride = width;
-            Int filterSize = NTAPS_LUMA;
-            Int halfFilterSize = (filterSize >> 1);
-            Short *tmp    = (Short*)malloc(width * (height + filterSize - 1) * sizeof(Short));
-
-            x265::primitives.ipFilter_p_s[FILTER_H_P_S_8](g_bitDepthY, (pixel*)(ref - (halfFilterSize - 1) * refStride) , refStride, tmp, tmpStride, width, height + filterSize - 1, TComInterpolationFilter::m_lumaFilter[xFrac]);
-            x265::primitives.ipFilter_s_s[FILTER_V_S_S_8](g_bitDepthY, tmp + (halfFilterSize - 1) * tmpStride ,tmpStride, dst, dstStride, width, height, TComInterpolationFilter::m_lumaFilter[yFrac]);
-
-            free(tmp);
-        }
-    }
-#endif
+    x265::primitives.cpyblock(width, height, (pixel*)dst, dstStride, (pixel*)src, srcStride);
 }
 
 //Motion compensated block for biprediction
@@ -704,18 +648,15 @@
     {
         if(xFrac==0)
         {
-                //filterconvertpeltoshort
             x265::primitives.ipfilterConvert_p_s(g_bitDepthY, (pixel*)ref , refStride, dst, dstStride, width, height);
         }
         else
         {
-            //filterhorizontalpelshort
             x265::primitives.ipFilter_p_s[FILTER_H_P_S_8](g_bitDepthY, (pixel*)ref , refStride, dst, dstStride, width, height, TComInterpolationFilter::m_lumaFilter[xFrac]);
         }
     }
     else if (xFrac == 0)
     {
-        //filterverticalpelshort
         x265::primitives.ipFilter_p_s[FILTER_V_P_S_8](g_bitDepthY, (pixel*)ref , refStride, dst, dstStride, width, height, TComInterpolationFilter::m_lumaFilter[yFrac]);
     }
     else
@@ -767,89 +708,38 @@
     Int filterSize = NTAPS_CHROMA;
 
     Int halfFilterSize = (filterSize >> 1);
-#if HIGHBITDEPTH
-    if(bi == false)
-#endif
+
+    if (yFrac == 0)
     {
-        if (yFrac == 0)
+        if (xFrac == 0)
         {
-            if (xFrac == 0)
-            {
-                x265::primitives.cpyblock(cxWidth, cxHeight, (pixel*)dstCb, dstStride, (pixel*)refCb, refStride);
-                x265::primitives.cpyblock(cxWidth, cxHeight, (pixel*)dstCr, dstStride, (pixel*)refCr, refStride);
-            }
-            else
-            {
-                primitives.ipFilter_p_p[FILTER_H_P_P_4](g_bitDepthC, (pixel*)refCb, refStride, (pixel*)dstCb,  dstStride, cxWidth, cxHeight, m_if.m_chromaFilter[xFrac]);
-                primitives.ipFilter_p_p[FILTER_H_P_P_4](g_bitDepthC, (pixel*)refCr, refStride, (pixel*)dstCr,  dstStride, cxWidth, cxHeight, m_if.m_chromaFilter[xFrac]);
-            }
-        }
-        else if (xFrac == 0)
-        {
-            primitives.ipFilter_p_p[FILTER_V_P_P_4](g_bitDepthC, (pixel*)refCb, refStride, (pixel*)dstCb, dstStride, cxWidth, cxHeight, m_if.m_chromaFilter[yFrac]);
-            primitives.ipFilter_p_p[FILTER_V_P_P_4](g_bitDepthC, (pixel*)refCr, refStride, (pixel*)dstCr, dstStride, cxWidth, cxHeight, m_if.m_chromaFilter[yFrac]);
+            x265::primitives.cpyblock(cxWidth, cxHeight, (pixel*)dstCb, dstStride, (pixel*)refCb, refStride);
+            x265::primitives.cpyblock(cxWidth, cxHeight, (pixel*)dstCr, dstStride, (pixel*)refCr, refStride);
         }
         else
         {
-            Int     extStride = cxWidth;
-            Short*  extY      = (Short*)xMalloc(Short, cxWidth * (cxHeight + filterSize - 1));
-
-            primitives.ipFilter_p_s[FILTER_H_P_S_4](g_bitDepthC, (pixel*)(refCb - (halfFilterSize - 1) * refStride), refStride, extY, extStride, cxWidth, cxHeight + filterSize - 1, m_if.m_chromaFilter[xFrac]);
-            primitives.ipFilter_s_p[FILTER_V_S_P_4](g_bitDepthC, extY + (halfFilterSize - 1) * extStride, extStride, (pixel*)dstCb, dstStride, cxWidth, cxHeight, m_if.m_chromaFilter[yFrac]);
-
-            primitives.ipFilter_p_s[FILTER_H_P_S_4](g_bitDepthC, (pixel*)(refCr - (halfFilterSize - 1) * refStride), refStride, extY, extStride, cxWidth, cxHeight + filterSize - 1,  m_if.m_chromaFilter[xFrac]);
-            primitives.ipFilter_s_p[FILTER_V_S_P_4](g_bitDepthC, extY + (halfFilterSize - 1) * extStride, extStride, (pixel*)dstCr, dstStride, cxWidth, cxHeight,  m_if.m_chromaFilter[yFrac]);
-
-            xFree(extY);
+            primitives.ipFilter_p_p[FILTER_H_P_P_4](g_bitDepthC, (pixel*)refCb, refStride, (pixel*)dstCb,  dstStride, cxWidth, cxHeight, m_if.m_chromaFilter[xFrac]);
+            primitives.ipFilter_p_p[FILTER_H_P_P_4](g_bitDepthC, (pixel*)refCr, refStride, (pixel*)dstCr,  dstStride, cxWidth, cxHeight, m_if.m_chromaFilter[xFrac]);
         }
     }
-#if HIGHBITDEPTH
-    else  /* For biprediction. will work correctly only when HIGHBITDEPTH enabled. Will be removed once bipred is fixed.  */
-    {    
-        Short* dstCb = (Short*)dstPic->getCbAddr(partAddr);
-        Short* dstCr = (Short*)dstPic->getCrAddr(partAddr);
-        if (yFrac == 0)
-        {
-            //m_if.filterHorChroma(refCb, refStride, dstCb,  dstStride, cxWidth, cxHeight, xFrac, !bi);
-            //m_if.filterHorChroma(refCr, refStride, dstCr,  dstStride, cxWidth, cxHeight, xFrac, !bi);
-            if(xFrac==0)
-            {
-                    //filterconvertpeltoshort
-                x265::primitives.ipfilterConvert_p_s(g_bitDepthC, (pixel*)refCb , refStride, dstCb, dstStride, cxWidth, cxHeight);
-                x265::primitives.ipfilterConvert_p_s(g_bitDepthC, (pixel*)refCr , refStride, dstCr, dstStride, cxWidth, cxHeight);
-            }
-            else
-            {
-                //filterhorizontalpelshort
-                x265::primitives.ipFilter_p_s[FILTER_H_P_S_4](g_bitDepthC, (pixel*)refCb , refStride, dstCb, dstStride, cxWidth, cxHeight, TComInterpolationFilter::m_chromaFilter[xFrac]);
-                x265::primitives.ipFilter_p_s[FILTER_H_P_S_4](g_bitDepthC, (pixel*)refCr , refStride, dstCr, dstStride, cxWidth, cxHeight, TComInterpolationFilter::m_chromaFilter[xFrac]);
-            }
-        }
-        else if (xFrac == 0)
-        {
-            //m_if.filterVerChroma(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, yFrac, true, !bi);
-            //m_if.filterVerChroma(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, yFrac, true, !bi);
-            x265::primitives.ipFilter_p_s[FILTER_V_P_S_4](g_bitDepthC, (pixel*)refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, TComInterpolationFilter::m_chromaFilter[yFrac]);
-            x265::primitives.ipFilter_p_s[FILTER_V_P_S_4](g_bitDepthC, (pixel*)refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, TComInterpolationFilter::m_chromaFilter[yFrac]);
-        }
-        else
-        {
-            Int     extStride = cxWidth;
-            Short*  extY      = (Short*)malloc(cxWidth * (cxHeight + filterSize - 1) * sizeof(Short));
-            //m_if.filterHorChroma(refCb - (halfFilterSize - 1) * refStride, refStride, extY,  extStride, cxWidth, cxHeight + filterSize - 1, xFrac, false);
-            //m_if.filterVerChroma(extY  + (halfFilterSize - 1) * extStride, extStride, dstCb, dstStride, cxWidth, cxHeight, yFrac, false, !bi);
-            x265::primitives.ipFilter_p_s[FILTER_H_P_S_8](g_bitDepthY, (pixel*)(refCb - (halfFilterSize - 1) * refStride), refStride, extY,  extStride, cxWidth, cxHeight + filterSize - 1, TComInterpolationFilter::m_chromaFilter[xFrac]);
-            x265::primitives.ipFilter_s_s[FILTER_V_S_S_4](g_bitDepthY, extY  + (halfFilterSize - 1) * extStride, extStride, dstCb, dstStride, cxWidth, cxHeight, TComInterpolationFilter::m_chromaFilter[yFrac]);
-
-            //m_if.filterHorChroma(refCr - (halfFilterSize - 1) * refStride, refStride, extY,  extStride, cxWidth, cxHeight + filterSize - 1, xFrac, false);
-            //m_if.filterVerChroma(extY  + (halfFilterSize - 1) * extStride, extStride, dstCr, dstStride, cxWidth, cxHeight, yFrac, false, !bi);
-            x265::primitives.ipFilter_p_s[FILTER_H_P_S_8](g_bitDepthY, (pixel*)(refCr - (halfFilterSize - 1) * refStride), refStride, extY,  extStride, cxWidth, cxHeight + filterSize - 1, TComInterpolationFilter::m_chromaFilter[xFrac]);
-            x265::primitives.ipFilter_s_s[FILTER_V_S_S_4](g_bitDepthY, extY  + (halfFilterSize - 1) * extStride, extStride, dstCr, dstStride, cxWidth, cxHeight, TComInterpolationFilter::m_chromaFilter[yFrac]);
-            free(extY);
-        }
-        
+    else if (xFrac == 0)
+    {
+        primitives.ipFilter_p_p[FILTER_V_P_P_4](g_bitDepthC, (pixel*)refCb, refStride, (pixel*)dstCb, dstStride, cxWidth, cxHeight, m_if.m_chromaFilter[yFrac]);
+        primitives.ipFilter_p_p[FILTER_V_P_P_4](g_bitDepthC, (pixel*)refCr, refStride, (pixel*)dstCr, dstStride, cxWidth, cxHeight, m_if.m_chromaFilter[yFrac]);
     }
-#endif
+    else
+    {
+        Int     extStride = cxWidth;
+        Short*  extY      = (Short*)xMalloc(Short, cxWidth * (cxHeight + filterSize - 1));
+
+        primitives.ipFilter_p_s[FILTER_H_P_S_4](g_bitDepthC, (pixel*)(refCb - (halfFilterSize - 1) * refStride), refStride, extY, extStride, cxWidth, cxHeight + filterSize - 1, m_if.m_chromaFilter[xFrac]);
+        primitives.ipFilter_s_p[FILTER_V_S_P_4](g_bitDepthC, extY + (halfFilterSize - 1) * extStride, extStride, (pixel*)dstCb, dstStride, cxWidth, cxHeight, m_if.m_chromaFilter[yFrac]);
+
+        primitives.ipFilter_p_s[FILTER_H_P_S_4](g_bitDepthC, (pixel*)(refCr - (halfFilterSize - 1) * refStride), refStride, extY, extStride, cxWidth, cxHeight + filterSize - 1,  m_if.m_chromaFilter[xFrac]);
+        primitives.ipFilter_s_p[FILTER_V_S_P_4](g_bitDepthC, extY + (halfFilterSize - 1) * extStride, extStride, (pixel*)dstCr, dstStride, cxWidth, cxHeight,  m_if.m_chromaFilter[yFrac]);
+
+        xFree(extY);
+    }
 }
 
 //Generate motion compensated block when biprediction
@@ -879,25 +769,19 @@
 
     if (yFrac == 0)
     {
-        //m_if.filterHorChroma(refCb, refStride, dstCb,  dstStride, cxWidth, cxHeight, xFrac, !bi);
-        //m_if.filterHorChroma(refCr, refStride, dstCr,  dstStride, cxWidth, cxHeight, xFrac, !bi);
         if(xFrac==0)
         {
-            //filterconvertpeltoshort
             x265::primitives.ipfilterConvert_p_s(g_bitDepthC, (pixel*)refCb , refStride, dstCb, dstStride, cxWidth, cxHeight);
             x265::primitives.ipfilterConvert_p_s(g_bitDepthC, (pixel*)refCr , refStride, dstCr, dstStride, cxWidth, cxHeight);
         }
         else
         {
-            //filterhorizontalpelshort
             x265::primitives.ipFilter_p_s[FILTER_H_P_S_4](g_bitDepthC, (pixel*)refCb , refStride, dstCb, dstStride, cxWidth, cxHeight, TComInterpolationFilter::m_chromaFilter[xFrac]);
             x265::primitives.ipFilter_p_s[FILTER_H_P_S_4](g_bitDepthC, (pixel*)refCr , refStride, dstCr, dstStride, cxWidth, cxHeight, TComInterpolationFilter::m_chromaFilter[xFrac]);
         }
     }
     else if (xFrac == 0)
     {
-        //m_if.filterVerChroma(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, yFrac, true, !bi);
-        //m_if.filterVerChroma(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, yFrac, true, !bi);
         x265::primitives.ipFilter_p_s[FILTER_V_P_S_4](g_bitDepthC, (pixel*)refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, TComInterpolationFilter::m_chromaFilter[yFrac]);
         x265::primitives.ipFilter_p_s[FILTER_V_P_S_4](g_bitDepthC, (pixel*)refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, TComInterpolationFilter::m_chromaFilter[yFrac]);
     }
@@ -905,18 +789,12 @@
     {
         Int     extStride = cxWidth;
         Short*  extY      = (Short*)malloc(cxWidth * (cxHeight + filterSize - 1) * sizeof(Short));
-        //m_if.filterHorChroma(refCb - (halfFilterSize - 1) * refStride, refStride, extY,  extStride, cxWidth, cxHeight + filterSize - 1, xFrac, false);
-        //m_if.filterVerChroma(extY  + (halfFilterSize - 1) * extStride, extStride, dstCb, dstStride, cxWidth, cxHeight, yFrac, false, !bi);
-        x265::primitives.ipFilter_p_s[FILTER_H_P_S_8](g_bitDepthY, (pixel*)(refCb - (halfFilterSize - 1) * refStride), refStride, extY,  extStride, cxWidth, cxHeight + filterSize - 1, TComInterpolationFilter::m_chromaFilter[xFrac]);
+        x265::primitives.ipFilter_p_s[FILTER_H_P_S_4](g_bitDepthY, (pixel*)(refCb - (halfFilterSize - 1) * refStride), refStride, extY,  extStride, cxWidth, cxHeight + filterSize - 1, TComInterpolationFilter::m_chromaFilter[xFrac]);
         x265::primitives.ipFilter_s_s[FILTER_V_S_S_4](g_bitDepthY, extY  + (halfFilterSize - 1) * extStride, extStride, dstCb, dstStride, cxWidth, cxHeight, TComInterpolationFilter::m_chromaFilter[yFrac]);
-
-        //m_if.filterHorChroma(refCr - (halfFilterSize - 1) * refStride, refStride, extY,  extStride, cxWidth, cxHeight + filterSize - 1, xFrac, false);
-        //m_if.filterVerChroma(extY  + (halfFilterSize - 1) * extStride, extStride, dstCr, dstStride, cxWidth, cxHeight, yFrac, false, !bi);
-        x265::primitives.ipFilter_p_s[FILTER_H_P_S_8](g_bitDepthY, (pixel*)(refCr - (halfFilterSize - 1) * refStride), refStride, extY,  extStride, cxWidth, cxHeight + filterSize - 1, TComInterpolationFilter::m_chromaFilter[xFrac]);
+        x265::primitives.ipFilter_p_s[FILTER_H_P_S_4](g_bitDepthY, (pixel*)(refCr - (halfFilterSize - 1) * refStride), refStride, extY,  extStride, cxWidth, cxHeight + filterSize - 1, TComInterpolationFilter::m_chromaFilter[xFrac]);
         x265::primitives.ipFilter_s_s[FILTER_V_S_S_4](g_bitDepthY, extY  + (halfFilterSize - 1) * extStride, extStride, dstCr, dstStride, cxWidth, cxHeight, TComInterpolationFilter::m_chromaFilter[yFrac]);
         free(extY);
     }
-
 }
 
 Void TComPrediction::xWeightedAverage(TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartIdx, Int iWidth, Int iHeight, TComYuv*& rpcYuvDst)
diff -r 7f9730659262 -r a864e518afec source/Lib/TLibCommon/TComPrediction.h
--- a/source/Lib/TLibCommon/TComPrediction.h	Mon Jun 24 11:38:53 2013 +0530
+++ b/source/Lib/TLibCommon/TComPrediction.h	Mon Jun 24 18:05:58 2013 +0530
@@ -68,6 +68,7 @@
     Pel *refAbove, *refAboveFlt, *refLeft, *refLeftFlt;
 
     TComYuv   m_acYuvPred[2];
+    TShortYUV   m_acShortPred[2];
     TComYuv   m_cYuvPredTemp;
     /*This holds final interpolated pixel values (0-255). Hence memory is stored as Pel.*/
     TComYuv m_filteredBlock[4][4];
diff -r 7f9730659262 -r a864e518afec source/Lib/TLibCommon/TComWeightPrediction.cpp
--- a/source/Lib/TLibCommon/TComWeightPrediction.cpp	Mon Jun 24 11:38:53 2013 +0530
+++ b/source/Lib/TLibCommon/TComWeightPrediction.cpp	Mon Jun 24 18:05:58 2013 +0530
@@ -40,26 +40,27 @@
 #include "TComWeightPrediction.h"
 #include "TComInterpolationFilter.h"
 
-static inline Pel weightBidirY(Int w0, Pel P0, Int w1, Pel P1, Int round, Int shift, Int offset)
+static inline Pel weightBidirY(Int w0, Short P0, Int w1, Short P1, Int round, Int shift, Int offset)
 {
     return ClipY(((w0 * (P0 + IF_INTERNAL_OFFS) + w1 * (P1 + IF_INTERNAL_OFFS) + round + (offset << (shift - 1))) >> shift));
 }
 
-static inline Pel weightBidirC(Int w0, Pel P0, Int w1, Pel P1, Int round, Int shift, Int offset)
+static inline Pel weightBidirC(Int w0, Short P0, Int w1, Short P1, Int round, Int shift, Int offset)
 {
     return ClipC(((w0 * (P0 + IF_INTERNAL_OFFS) + w1 * (P1 + IF_INTERNAL_OFFS) + round + (offset << (shift - 1))) >> shift));
 }
 
-static inline Pel weightUnidirY(Int w0, Pel P0, Int round, Int shift, Int offset)
+static inline Pel weightUnidirY(Int w0, Short P0, Int round, Int shift, Int offset)
 {
     return ClipY(((w0 * (P0 + IF_INTERNAL_OFFS) + round) >> shift) + offset);
 }
 
-static inline Pel weightUnidirC(Int w0, Pel P0, Int round, Int shift, Int offset)
+static inline Pel weightUnidirC(Int w0, Short P0, Int round, Int shift, Int offset)
 {
     return ClipC(((w0 * (P0 + IF_INTERNAL_OFFS) + round) >> shift) + offset);
 }
 
+
 // ====================================================================================================================
 // Class definition
 // ====================================================================================================================
@@ -180,6 +181,121 @@
     }
 }
 
+/** weighted averaging for bi-pred
+ * \param TShortYuv* pcYuvSrc0
+ * \param TShortYuv* pcYuvSrc1
+ * \param iPartUnitIdx
+ * \param iWidth
+ * \param iHeight
+ * \param wpScalingParam *wp0
+ * \param wpScalingParam *wp1
+ * \param TComYuv* rpcYuvDst
+ * \returns Void
+ */
+Void TComWeightPrediction::addWeightBi(TShortYUV* pcYuvSrc0, TShortYUV* pcYuvSrc1, UInt iPartUnitIdx, UInt iWidth, UInt iHeight, wpScalingParam *wp0, wpScalingParam *wp1, TComYuv* rpcYuvDst, Bool bRound)
+{
+    Int x, y;
+
+    Short* pSrcY0  = pcYuvSrc0->getLumaAddr(iPartUnitIdx);
+    Short* pSrcU0  = pcYuvSrc0->getCbAddr(iPartUnitIdx);
+    Short* pSrcV0  = pcYuvSrc0->getCrAddr(iPartUnitIdx);
+
+    Short* pSrcY1  = pcYuvSrc1->getLumaAddr(iPartUnitIdx);
+    Short* pSrcU1  = pcYuvSrc1->getCbAddr(iPartUnitIdx);
+    Short* pSrcV1  = pcYuvSrc1->getCrAddr(iPartUnitIdx);
+
+    Pel* pDstY   = rpcYuvDst->getLumaAddr(iPartUnitIdx);
+    Pel* pDstU   = rpcYuvDst->getCbAddr(iPartUnitIdx);
+    Pel* pDstV   = rpcYuvDst->getCrAddr(iPartUnitIdx);
+
+    // Luma : --------------------------------------------
+    Int w0      = wp0[0].w;
+    Int offset  = wp0[0].offset;
+    Int shiftNum = IF_INTERNAL_PREC - g_bitDepthY;
+    Int shift   = wp0[0].shift + shiftNum;
+    Int round   = shift ? (1 << (shift - 1)) * bRound : 0;
+    Int w1      = wp1[0].w;
+
+    UInt  iSrc0Stride = pcYuvSrc0->getStride();
+    UInt  iSrc1Stride = pcYuvSrc1->getStride();
+    UInt  iDstStride  = rpcYuvDst->getStride();
+
+    for (y = iHeight - 1; y >= 0; y--)
+    {
+        for (x = iWidth - 1; x >= 0; )
+        {
+            // note: luma min width is 4
+            pDstY[x] = weightBidirY(w0, pSrcY0[x], w1, pSrcY1[x], round, shift, offset);
+            x--;
+            pDstY[x] = weightBidirY(w0, pSrcY0[x], w1, pSrcY1[x], round, shift, offset);
+            x--;
+            pDstY[x] = weightBidirY(w0, pSrcY0[x], w1, pSrcY1[x], round, shift, offset);
+            x--;
+            pDstY[x] = weightBidirY(w0, pSrcY0[x], w1, pSrcY1[x], round, shift, offset);
+            x--;
+        }
+
+        pSrcY0 += iSrc0Stride;
+        pSrcY1 += iSrc1Stride;
+        pDstY  += iDstStride;
+    }
+
+    // Chroma U : --------------------------------------------
+    w0      = wp0[1].w;
+    offset  = wp0[1].offset;
+    shiftNum = IF_INTERNAL_PREC - g_bitDepthC;
+    shift   = wp0[1].shift + shiftNum;
+    round   = shift ? (1 << (shift - 1)) : 0;
+    w1      = wp1[1].w;
+
+    iSrc0Stride = pcYuvSrc0->getCStride();
+    iSrc1Stride = pcYuvSrc1->getCStride();
+    iDstStride  = rpcYuvDst->getCStride();
+
+    iWidth  >>= 1;
+    iHeight >>= 1;
+
+    for (y = iHeight - 1; y >= 0; y--)
+    {
+        for (x = iWidth - 1; x >= 0; )
+        {
+            // note: chroma min width is 2
+            pDstU[x] = weightBidirC(w0, pSrcU0[x], w1, pSrcU1[x], round, shift, offset);
+            x--;
+            pDstU[x] = weightBidirC(w0, pSrcU0[x], w1, pSrcU1[x], round, shift, offset);
+            x--;
+        }
+
+        pSrcU0 += iSrc0Stride;
+        pSrcU1 += iSrc1Stride;
+        pDstU  += iDstStride;
+    }
+
+    // Chroma V : --------------------------------------------
+    w0      = wp0[2].w;
+    offset  = wp0[2].offset;
+    shift   = wp0[2].shift + shiftNum;
+    round   = shift ? (1 << (shift - 1)) : 0;
+    w1      = wp1[2].w;
+
+    for (y = iHeight - 1; y >= 0; y--)
+    {
+        for (x = iWidth - 1; x >= 0; )
+        {
+            // note: chroma min width is 2
+            pDstV[x] = weightBidirC(w0, pSrcV0[x], w1, pSrcV1[x], round, shift, offset);
+            x--;
+            pDstV[x] = weightBidirC(w0, pSrcV0[x], w1, pSrcV1[x], round, shift, offset);
+            x--;
+        }
+
+        pSrcV0 += iSrc0Stride;
+        pSrcV1 += iSrc1Stride;
+        pDstV  += iDstStride;
+    }
+}
+
+
 /** weighted averaging for uni-pred
  * \param TComYuv* pcYuvSrc0
  * \param iPartUnitIdx
@@ -279,6 +395,105 @@
     }
 }
 
+/** weighted averaging for uni-pred
+ * \param TShortYUV* pcYuvSrc0
+ * \param iPartUnitIdx
+ * \param iWidth
+ * \param iHeight
+ * \param wpScalingParam *wp0
+ * \param TComYuv* rpcYuvDst
+ * \returns Void
+ */
+Void TComWeightPrediction::addWeightUni(TShortYUV* pcYuvSrc0, UInt iPartUnitIdx, UInt iWidth, UInt iHeight, wpScalingParam *wp0, TComYuv* rpcYuvDst)
+{
+    Int x, y;
+
+    Short* pSrcY0  = pcYuvSrc0->getLumaAddr(iPartUnitIdx);
+    Short* pSrcU0  = pcYuvSrc0->getCbAddr(iPartUnitIdx);
+    Short* pSrcV0  = pcYuvSrc0->getCrAddr(iPartUnitIdx);
+
+    Pel* pDstY   = rpcYuvDst->getLumaAddr(iPartUnitIdx);
+    Pel* pDstU   = rpcYuvDst->getCbAddr(iPartUnitIdx);
+    Pel* pDstV   = rpcYuvDst->getCrAddr(iPartUnitIdx);
+
+    // Luma : --------------------------------------------
+    Int w0      = wp0[0].w;
+    Int offset  = wp0[0].offset;
+    Int shiftNum = IF_INTERNAL_PREC - g_bitDepthY;
+    Int shift   = wp0[0].shift + shiftNum;
+    Int round   = shift ? (1 << (shift - 1)) : 0;
+    UInt  iSrc0Stride = pcYuvSrc0->getStride();
+    UInt  iDstStride  = rpcYuvDst->getStride();
+
+    for (y = iHeight - 1; y >= 0; y--)
+    {
+        for (x = iWidth - 1; x >= 0; )
+        {
+            // note: luma min width is 4
+            pDstY[x] = weightUnidirY(w0, pSrcY0[x], round, shift, offset);
+            x--;
+            pDstY[x] = weightUnidirY(w0, pSrcY0[x], round, shift, offset);
+            x--;
+            pDstY[x] = weightUnidirY(w0, pSrcY0[x], round, shift, offset);
+            x--;
+            pDstY[x] = weightUnidirY(w0, pSrcY0[x], round, shift, offset);
+            x--;
+        }
+
+        pSrcY0 += iSrc0Stride;
+        pDstY  += iDstStride;
+    }
+
+    // Chroma U : --------------------------------------------
+    w0      = wp0[1].w;
+    offset  = wp0[1].offset;
+    shiftNum = IF_INTERNAL_PREC - g_bitDepthC;
+    shift   = wp0[1].shift + shiftNum;
+    round   = shift ? (1 << (shift - 1)) : 0;
+
+    iSrc0Stride = pcYuvSrc0->getCStride();
+    iDstStride  = rpcYuvDst->getCStride();
+
+    iWidth  >>= 1;
+    iHeight >>= 1;
+
+    for (y = iHeight - 1; y >= 0; y--)
+    {
+        for (x = iWidth - 1; x >= 0; )
+        {
+            // note: chroma min width is 2
+            pDstU[x] = weightUnidirC(w0, pSrcU0[x], round, shift, offset);
+            x--;
+            pDstU[x] = weightUnidirC(w0, pSrcU0[x], round, shift, offset);
+            x--;
+        }
+
+        pSrcU0 += iSrc0Stride;
+        pDstU  += iDstStride;
+    }
+
+    // Chroma V : --------------------------------------------
+    w0      = wp0[2].w;
+    offset  = wp0[2].offset;
+    shift   = wp0[2].shift + shiftNum;
+    round   = shift ? (1 << (shift - 1)) : 0;
+
+    for (y = iHeight - 1; y >= 0; y--)
+    {
+        for (x = iWidth - 1; x >= 0; )
+        {
+            // note: chroma min width is 2
+            pDstV[x] = weightUnidirC(w0, pSrcV0[x], round, shift, offset);
+            x--;
+            pDstV[x] = weightUnidirC(w0, pSrcV0[x], round, shift, offset);
+            x--;
+        }
+
+        pSrcV0 += iSrc0Stride;
+        pDstV  += iDstStride;
+    }
+}
+
 //=======================================================
 //  getWpScaling()
 //=======================================================
@@ -396,6 +611,45 @@
     }
 }
 
+/** weighted prediction for bi-pred
+ * \param TComDataCU* pcCU
+ * \param TShortYuv* pcYuvSrc0
+ * \param TShortYuv* pcYuvSrc1
+ * \param iRefIdx0
+ * \param iRefIdx1
+ * \param uiPartIdx
+ * \param iWidth
+ * \param iHeight
+ * \param TComYuv* rpcYuvDst
+ * \returns Void
+ */
+Void TComWeightPrediction::xWeightedPredictionBi(TComDataCU* pcCU, TShortYUV* pcYuvSrc0, TShortYUV* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartIdx, Int iWidth, Int iHeight, TComYuv* rpcYuvDst)
+{
+    wpScalingParam  *pwp0, *pwp1;
+    const TComPPS   *pps = pcCU->getSlice()->getPPS();
+
+    assert(pps->getWPBiPred());
+
+    getWpScaling(pcCU, iRefIdx0, iRefIdx1, pwp0, pwp1);
+
+    if (iRefIdx0 >= 0 && iRefIdx1 >= 0)
+    {
+        addWeightBi(pcYuvSrc0, pcYuvSrc1, uiPartIdx, iWidth, iHeight, pwp0, pwp1, rpcYuvDst);
+    }
+    else if (iRefIdx0 >= 0 && iRefIdx1 <  0)
+    {
+        addWeightUni(pcYuvSrc0, uiPartIdx, iWidth, iHeight, pwp0, rpcYuvDst);
+    }
+    else if (iRefIdx0 <  0 && iRefIdx1 >= 0)
+    {
+        addWeightUni(pcYuvSrc1, uiPartIdx, iWidth, iHeight, pwp1, rpcYuvDst);
+    }
+    else
+    {
+        assert(0);
+    }
+}
+
 /** weighted prediction for uni-pred
  * \param TComDataCU* pcCU
  * \param TComYuv* pcYuvSrc
@@ -428,3 +682,37 @@
     }
     addWeightUni(pcYuvSrc, uiPartAddr, iWidth, iHeight, pwp, rpcYuvPred);
 }
+
+
+/** weighted prediction for uni-pred
+ * \param TComDataCU* pcCU
+ * \param TShortYuv* pcYuvSrc
+ * \param uiPartAddr
+ * \param iWidth
+ * \param iHeight
+ * \param eRefPicList
+ * \param TComYuv*& rpcYuvPred
+ * \param iPartIdx
+ * \param iRefIdx
+ * \returns Void
+ */
+Void TComWeightPrediction::xWeightedPredictionUni(TComDataCU* pcCU, TShortYUV* pcYuvSrc, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iRefIdx)
+{
+    wpScalingParam  *pwp, *pwpTmp;
+
+    if (iRefIdx < 0)
+    {
+        iRefIdx   = pcCU->getCUMvField(eRefPicList)->getRefIdx(uiPartAddr);
+    }
+    assert(iRefIdx >= 0);
+
+    if (eRefPicList == REF_PIC_LIST_0)
+    {
+        getWpScaling(pcCU, iRefIdx, -1, pwp, pwpTmp);
+    }
+    else
+    {
+        getWpScaling(pcCU, -1, iRefIdx, pwpTmp, pwp);
+    }
+    addWeightUni(pcYuvSrc, uiPartAddr, iWidth, iHeight, pwp, rpcYuvPred);
+}
diff -r 7f9730659262 -r a864e518afec source/Lib/TLibCommon/TComWeightPrediction.h
--- a/source/Lib/TLibCommon/TComWeightPrediction.h	Mon Jun 24 11:38:53 2013 +0530
+++ b/source/Lib/TLibCommon/TComWeightPrediction.h	Mon Jun 24 18:05:58 2013 +0530
@@ -58,10 +58,14 @@
     Void  getWpScaling(TComDataCU* pcCU, Int iRefIdx0, Int iRefIdx1, wpScalingParam *&wp0, wpScalingParam *&wp1);
 
     Void  addWeightBi(TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt iPartUnitIdx, UInt iWidth, UInt iHeight, wpScalingParam *wp0, wpScalingParam *wp1, TComYuv* rpcYuvDst, Bool bRound = true);
+    Void  addWeightBi(TShortYUV* pcYuvSrc0, TShortYUV* pcYuvSrc1, UInt iPartUnitIdx, UInt iWidth, UInt iHeight, wpScalingParam *wp0, wpScalingParam *wp1, TComYuv* rpcYuvDst, Bool bRound = true);
     Void  addWeightUni(TComYuv* pcYuvSrc0, UInt iPartUnitIdx, UInt iWidth, UInt iHeight, wpScalingParam *wp0, TComYuv* rpcYuvDst);
+    Void  addWeightUni(TShortYUV* pcYuvSrc0, UInt iPartUnitIdx, UInt iWidth, UInt iHeight, wpScalingParam *wp0, TComYuv* rpcYuvDst);
 
     Void  xWeightedPredictionUni(TComDataCU* pcCU, TComYuv* pcYuvSrc, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iRefIdx = -1);
+    Void  xWeightedPredictionUni(TComDataCU* pcCU, TShortYUV* pcYuvSrc, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iRefIdx = -1);
     Void  xWeightedPredictionBi(TComDataCU* pcCU, TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartIdx, Int iWidth, Int iHeight, TComYuv* rpcYuvDst);
+    Void  xWeightedPredictionBi(TComDataCU* pcCU, TShortYUV* pcYuvSrc0, TShortYUV* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartIdx, Int iWidth, Int iHeight, TComYuv* rpcYuvDst);
 };
 
 #endif // ifndef __TCOMWEIGHTPREDICTION__
diff -r 7f9730659262 -r a864e518afec source/Lib/TLibCommon/TComYuv.cpp
--- a/source/Lib/TLibCommon/TComYuv.cpp	Mon Jun 24 11:38:53 2013 +0530
+++ b/source/Lib/TLibCommon/TComYuv.cpp	Mon Jun 24 18:05:58 2013 +0530
@@ -649,6 +649,75 @@
     }
 }
 
+Void TComYuv::addAvg(TShortYUV* pcYuvSrc0, TShortYUV* pcYuvSrc1, UInt iPartUnitIdx, UInt iWidth, UInt iHeight)
+{
+    Int x, y;
+
+    Short* pSrcY0  = pcYuvSrc0->getLumaAddr(iPartUnitIdx);
+    Short* pSrcU0  = pcYuvSrc0->getCbAddr(iPartUnitIdx);
+    Short* pSrcV0  = pcYuvSrc0->getCrAddr(iPartUnitIdx);
+
+    Short* pSrcY1  = pcYuvSrc1->getLumaAddr(iPartUnitIdx);
+    Short* pSrcU1  = pcYuvSrc1->getCbAddr(iPartUnitIdx);
+    Short* pSrcV1  = pcYuvSrc1->getCrAddr(iPartUnitIdx);
+
+    Pel* pDstY   = getLumaAddr(iPartUnitIdx);
+    Pel* pDstU   = getCbAddr(iPartUnitIdx);
+    Pel* pDstV   = getCrAddr(iPartUnitIdx);
+
+    UInt  iSrc0Stride = pcYuvSrc0->getStride();
+    UInt  iSrc1Stride = pcYuvSrc1->getStride();
+    UInt  iDstStride  = getStride();
+    Int shiftNum = IF_INTERNAL_PREC + 1 - g_bitDepthY;
+    Int offset = (1 << (shiftNum - 1)) + 2 * IF_INTERNAL_OFFS;
+
+    for (y = 0; y < iHeight; y++)
+    {
+        for (x = 0; x < iWidth; x += 4)
+        {
+            pDstY[x + 0] = ClipY((pSrcY0[x + 0] + pSrcY1[x + 0] + offset) >> shiftNum);
+            pDstY[x + 1] = ClipY((pSrcY0[x + 1] + pSrcY1[x + 1] + offset) >> shiftNum);
+            pDstY[x + 2] = ClipY((pSrcY0[x + 2] + pSrcY1[x + 2] + offset) >> shiftNum);
+            pDstY[x + 3] = ClipY((pSrcY0[x + 3] + pSrcY1[x + 3] + offset) >> shiftNum);
+        }
+
+        pSrcY0 += iSrc0Stride;
+        pSrcY1 += iSrc1Stride;
+        pDstY  += iDstStride;
+    }
+
+    shiftNum = IF_INTERNAL_PREC + 1 - g_bitDepthC;
+    offset = (1 << (shiftNum - 1)) + 2 * IF_INTERNAL_OFFS;
+
+    iSrc0Stride = pcYuvSrc0->getCStride();
+    iSrc1Stride = pcYuvSrc1->getCStride();
+    iDstStride  = getCStride();
+
+    iWidth  >>= 1;
+    iHeight >>= 1;
+
+    for (y = iHeight - 1; y >= 0; y--)
+    {
+        for (x = iWidth - 1; x >= 0; )
+        {
+            // note: chroma min width is 2
+            pDstU[x] = ClipC((pSrcU0[x] + pSrcU1[x] + offset) >> shiftNum);
+            pDstV[x] = ClipC((pSrcV0[x] + pSrcV1[x] + offset) >> shiftNum);
+            x--;
+            pDstU[x] = ClipC((pSrcU0[x] + pSrcU1[x] + offset) >> shiftNum);
+            pDstV[x] = ClipC((pSrcV0[x] + pSrcV1[x] + offset) >> shiftNum);
+            x--;
+        }
+
+        pSrcU0 += iSrc0Stride;
+        pSrcU1 += iSrc1Stride;
+        pSrcV0 += iSrc0Stride;
+        pSrcV1 += iSrc1Stride;
+        pDstU  += iDstStride;
+        pDstV  += iDstStride;
+    }
+}
+
 Void TComYuv::removeHighFreq(TComYuv* pcYuvSrc, UInt uiPartIdx, UInt uiWidht, UInt uiHeight)
 {
     Int x, y;
diff -r 7f9730659262 -r a864e518afec source/Lib/TLibCommon/TComYuv.h
--- a/source/Lib/TLibCommon/TComYuv.h	Mon Jun 24 11:38:53 2013 +0530
+++ b/source/Lib/TLibCommon/TComYuv.h	Mon Jun 24 18:05:58 2013 +0530
@@ -157,6 +157,7 @@
 
     //  (pcYuvSrc0 + pcYuvSrc1)/2 for YUV partition
     Void    addAvg(TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt iPartUnitIdx, UInt iWidth, UInt iHeight);
+    Void    addAvg(TShortYUV* pcYuvSrc0, TShortYUV* pcYuvSrc1, UInt iPartUnitIdx, UInt iWidth, UInt iHeight);
 
     //   Remove High frequency
     Void    removeHighFreq(TComYuv* pcYuvSrc, UInt uiPartIdx, UInt uiWidht, UInt uiHeight);
diff -r 7f9730659262 -r a864e518afec source/Lib/TLibEncoder/TEncSearch.cpp
--- a/source/Lib/TLibEncoder/TEncSearch.cpp	Mon Jun 24 11:38:53 2013 +0530
+++ b/source/Lib/TLibEncoder/TEncSearch.cpp	Mon Jun 24 18:05:58 2013 +0530
@@ -3561,18 +3561,15 @@
     // prediction pattern
     if (pcCU->getSlice()->getPPS()->getUseWP() && pcCU->getSlice()->getSliceType() == P_SLICE)
     {
-        xPredInterLumaBlk(pcCU, pcPicYuvRef, uiPartAddr, &cMvCand, iSizeX, iSizeY, pcTemplateCand, true);
+        TShortYUV *pcMbYuv = &m_acShortPred[0];
+        xPredInterLumaBlk(pcCU, pcPicYuvRef, uiPartAddr, &cMvCand, iSizeX, iSizeY, pcMbYuv, true);
+        xWeightedPredictionUni(pcCU, pcMbYuv, uiPartAddr, iSizeX, iSizeY, eRefPicList, pcTemplateCand, iRefIdx);
     }
     else
     {
         xPredInterLumaBlk(pcCU, pcPicYuvRef, uiPartAddr, &cMvCand, iSizeX, iSizeY, pcTemplateCand, false);
     }
 
-    if (pcCU->getSlice()->getPPS()->getUseWP() && pcCU->getSlice()->getSliceType() == P_SLICE)
-    {
-        xWeightedPredictionUni(pcCU, pcTemplateCand, uiPartAddr, iSizeX, iSizeY, eRefPicList, pcTemplateCand, iRefIdx);
-    }
-
     // calc distortion
     uiCost = m_me.bufSAD((pixel*)pcTemplateCand->getLumaAddr(uiPartAddr), pcTemplateCand->getStride());
     x265_emms();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: xhevc_deepthid.patch
Type: text/x-patch
Size: 44152 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20130624/66a05f54/attachment-0001.bin>


More information about the x265-devel mailing list