<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jun 24, 2013 at 7:37 AM,  <span dir="ltr"><<a href="mailto:deepthidevaki@multicorewareinc.com" target="_blank">deepthidevaki@multicorewareinc.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"># HG changeset patch<br>
# User Deepthi Devaki<br>
# Date 1372077358 -19800<br>
# Node ID a864e518afece8fe5d8f5abbe349dec84114c98d<br>
# Parent  7f9730659262eed1746df4ce17217d6e5c455f92<br>
Added support for bipred, but 8bpp, 16bpp mismatch<br></blockquote><div><br></div><div style>This patch didn't apply cleanly to the tip because it was based on your earlier patch and did not include the fixes I made to it (HIGHBITDEPTH should be HIGH_BIT_DEPTH).  An important part of the patch based workflow is to always base our patches on the current development tip so they apply cleanly.</div>
<div style><br></div><div style>I was able to edit this patch to get it to apply cleanly, so it's been pushed.  Thanks for fixing bidir prediction!</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<br>
diff -r 7f9730659262 -r a864e518afec source/Lib/TLibCommon/TComPrediction.cpp<br>
--- a/source/Lib/TLibCommon/TComPrediction.cpp  Mon Jun 24 11:38:53 2013 +0530<br>
+++ b/source/Lib/TLibCommon/TComPrediction.cpp  Mon Jun 24 18:05:58 2013 +0530<br>
@@ -77,6 +77,8 @@<br>
<br>
     m_acYuvPred[0].destroy();<br>
     m_acYuvPred[1].destroy();<br>
+    m_acShortPred[0].destroy();<br>
+    m_acShortPred[1].destroy();<br>
<br>
     m_cYuvPredTemp.destroy();<br>
<br>
@@ -126,6 +128,8 @@<br>
         // new structure<br>
         m_acYuvPred[0].create(MAX_CU_SIZE, MAX_CU_SIZE);<br>
         m_acYuvPred[1].create(MAX_CU_SIZE, MAX_CU_SIZE);<br>
+        m_acShortPred[0].create(MAX_CU_SIZE, MAX_CU_SIZE);<br>
+        m_acShortPred[1].create(MAX_CU_SIZE, MAX_CU_SIZE);<br>
<br>
         m_cYuvPredTemp.create(MAX_CU_SIZE, MAX_CU_SIZE);<br>
     }<br>
@@ -412,7 +416,7 @@<br>
     Int         iWidth;<br>
     Int         iHeight;<br>
     UInt        uiPartAddr;<br>
-<br>
+<br>
     if (iPartIdx >= 0)<br>
     {<br>
         pcCU->getPartIndexAndSize(iPartIdx, uiPartAddr, iWidth, iHeight);<br>
@@ -420,16 +424,14 @@<br>
         {<br>
             if (pcCU->getSlice()->getPPS()->getUseWP())<br>
             {<br>
-                xPredInterUni(pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, true);<br>
+                TShortYUV* pcMbYuv = &m_acShortPred[0];<br>
+                xPredInterUni(pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, true);<br>
+                xWeightedPredictionUni(pcCU, pcMbYuv, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred);<br>
             }<br>
             else<br>
             {<br>
                 xPredInterUni(pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred);<br>
             }<br>
-            if (pcCU->getSlice()->getPPS()->getUseWP())<br>
-            {<br>
-                xWeightedPredictionUni(pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred);<br>
-            }<br>
         }<br>
         else<br>
         {<br>
@@ -453,16 +455,14 @@<br>
         {<br>
             if (pcCU->getSlice()->getPPS()->getUseWP())<br>
             {<br>
-                xPredInterUni(pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred, true);<br>
+                TShortYUV* pcMbYuv = &m_acShortPred[0];<br>
+                xPredInterUni(pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, true);<br>
+                xWeightedPredictionUni(pcCU, pcMbYuv, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred);<br>
             }<br>
             else<br>
             {<br>
                 xPredInterUni(pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred);<br>
             }<br>
-            if (pcCU->getSlice()->getPPS()->getUseWP())<br>
-            {<br>
-                xWeightedPredictionUni(pcCU, pcYuvPred, uiPartAddr, iWidth, iHeight, eRefPicList, pcYuvPred);<br>
-            }<br>
         }<br>
         else<br>
         {<br>
@@ -478,6 +478,7 @@<br>
     }<br>
 }<br>
<br>
+<br>
 Void TComPrediction::xPredInterUni(TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Bool bi)<br>
 {<br>
     assert (bi == false);<br>
@@ -507,11 +508,11 @@<br>
<br>
 Void TComPrediction::xPredInterBi(TComDataCU* pcCU, UInt uiPartAddr, Int iWidth, Int iHeight, TComYuv*& rpcYuvPred)<br>
 {<br>
-    TComYuv* pcMbYuv;<br>
     Int      iRefIdx[2] = { -1, -1 };<br>
<br>
     if (pcCU->getCUMvField(REF_PIC_LIST_0)->getRefIdx(uiPartAddr) >= 0 && pcCU->getCUMvField(REF_PIC_LIST_1)->getRefIdx(uiPartAddr) >= 0)<br>
     {<br>
+        TShortYUV* pcMbYuv;<br>
         for (Int iRefList = 0; iRefList < 2; iRefList++)<br>
         {<br>
             RefPicList eRefPicList = (iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0);<br>
@@ -519,22 +520,61 @@<br>
<br>
             assert(iRefIdx[iRefList] < pcCU->getSlice()->getNumRefIdx(eRefPicList));<br>
<br>
-            pcMbYuv = &m_acYuvPred[iRefList];<br>
-            xPredInterUni(pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, true);   //pcMbYuv should be TShortYuv<br>
+            pcMbYuv = &m_acShortPred[iRefList];<br>
+            xPredInterUni(pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, true);<br>
         }<br>
         if (pcCU->getSlice()->getPPS()->getWPBiPred() && pcCU->getSlice()->getSliceType() == B_SLICE)<br>
         {<br>
-            //m_acYuvPred must be TShortYuv<br>
-            xWeightedPredictionBi(pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred);<br>
+            xWeightedPredictionBi(pcCU, &m_acShortPred[0], &m_acShortPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred);<br>
         }<br>
         else<br>
         {<br>
-            //m_acYuvPred must be TShortYuv<br>
-            xWeightedAverage(&m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred);<br>
+            rpcYuvPred->addAvg(&m_acShortPred[0], &m_acShortPred[1], uiPartAddr, iWidth, iHeight);<br>
         }<br>
     }<br>
     else if (pcCU->getSlice()->getPPS()->getWPBiPred() && pcCU->getSlice()->getSliceType() == B_SLICE)<br>
     {<br>
+        TShortYUV* pcMbYuv;<br>
+        for (Int iRefList = 0; iRefList < 2; iRefList++)<br>
+        {<br>
+            RefPicList eRefPicList = (iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0);<br>
+            iRefIdx[iRefList] = pcCU->getCUMvField(eRefPicList)->getRefIdx(uiPartAddr);<br>
+<br>
+            if (iRefIdx[iRefList] < 0)<br>
+            {<br>
+                continue;<br>
+            }<br>
+<br>
+            assert(iRefIdx[iRefList] < pcCU->getSlice()->getNumRefIdx(eRefPicList));<br>
+<br>
+            pcMbYuv = &m_acShortPred[iRefList];<br>
+            xPredInterUni(pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, true);<br>
+        }<br>
+        xWeightedPredictionBi(pcCU, &m_acShortPred[0], &m_acShortPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred);<br>
+    }<br>
+    else if (pcCU->getSlice()->getPPS()->getUseWP() && pcCU->getSlice()->getSliceType() == P_SLICE)<br>
+    {<br>
+        TShortYUV* pcMbYuv;<br>
+        for (Int iRefList = 0; iRefList < 2; iRefList++)<br>
+        {<br>
+            RefPicList eRefPicList = (iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0);<br>
+            iRefIdx[iRefList] = pcCU->getCUMvField(eRefPicList)->getRefIdx(uiPartAddr);<br>
+<br>
+            if (iRefIdx[iRefList] < 0)<br>
+            {<br>
+                continue;<br>
+            }<br>
+<br>
+            assert(iRefIdx[iRefList] < pcCU->getSlice()->getNumRefIdx(eRefPicList));<br>
+<br>
+            pcMbYuv = &m_acShortPred[iRefList];<br>
+            xPredInterUni(pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, true);<br>
+        }<br>
+        xWeightedPredictionUni(pcCU, &m_acShortPred[0], uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, rpcYuvPred);<br>
+    }<br>
+    else<br>
+    {<br>
+        TComYuv* pcMbYuv;<br>
         for (Int iRefList = 0; iRefList < 2; iRefList++)<br>
         {<br>
             RefPicList eRefPicList = (iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0);<br>
@@ -548,49 +588,8 @@<br>
             assert(iRefIdx[iRefList] < pcCU->getSlice()->getNumRefIdx(eRefPicList));<br>
<br>
             pcMbYuv = &m_acYuvPred[iRefList];<br>
-            xPredInterUni(pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, true); //pcMbYuv must be TShort<br>
+            xPredInterUni(pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv);<br>
         }<br>
-        //m_acYuvPred must be TShort<br>
-        xWeightedPredictionBi(pcCU, &m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred);<br>
-    }<br>
-    else if (pcCU->getSlice()->getPPS()->getUseWP() && pcCU->getSlice()->getSliceType() == P_SLICE)<br>
-    {<br>
-        for (Int iRefList = 0; iRefList < 2; iRefList++)<br>
-        {<br>
-            RefPicList eRefPicList = (iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0);<br>
-            iRefIdx[iRefList] = pcCU->getCUMvField(eRefPicList)->getRefIdx(uiPartAddr);<br>
-<br>
-            if (iRefIdx[iRefList] < 0)<br>
-            {<br>
-                continue;<br>
-            }<br>
-<br>
-            assert(iRefIdx[iRefList] < pcCU->getSlice()->getNumRefIdx(eRefPicList));<br>
-<br>
-            pcMbYuv = &m_acYuvPred[iRefList];<br>
-            xPredInterUni(pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv, true); //pcMbYuv must be TShortYuv<br>
-        }<br>
-        //m_acYuvPred must be TShortYuv<br>
-        xWeightedPredictionUni(pcCU, &m_acYuvPred[0], uiPartAddr, iWidth, iHeight, REF_PIC_LIST_0, rpcYuvPred);<br>
-    }<br>
-    else<br>
-    {<br>
-        for (Int iRefList = 0; iRefList < 2; iRefList++)<br>
-        {<br>
-            RefPicList eRefPicList = (iRefList ? REF_PIC_LIST_1 : REF_PIC_LIST_0);<br>
-            iRefIdx[iRefList] = pcCU->getCUMvField(eRefPicList)->getRefIdx(uiPartAddr);<br>
-<br>
-            if (iRefIdx[iRefList] < 0)<br>
-            {<br>
-                continue;<br>
-            }<br>
-<br>
-            assert(iRefIdx[iRefList] < pcCU->getSlice()->getNumRefIdx(eRefPicList));<br>
-<br>
-            pcMbYuv = &m_acYuvPred[iRefList];<br>
-            xPredInterUni(pcCU, uiPartAddr, iWidth, iHeight, eRefPicList, pcMbYuv); //pcMbYuv must be TComYuv<br>
-        }<br>
-        //m_acYuvPred must be TComYuv<br>
         xWeightedAverage(&m_acYuvPred[0], &m_acYuvPred[1], iRefIdx[0], iRefIdx[1], uiPartAddr, iWidth, iHeight, rpcYuvPred);<br>
     }<br>
 }<br>
@@ -609,77 +608,22 @@<br>
  */<br>
 Void TComPrediction::xPredInterLumaBlk(TComDataCU *cu, TComPicYuv *refPic, UInt partAddr, TComMv *mv, Int width, Int height, TComYuv *&dstPic, Bool bi)<br>
 {<br>
-#if HIGHBITDEPTH<br>
-    if(bi == false)<br>
-#endif<br>
-    {<br>
-        assert(bi == false);<br>
+    assert(bi == false);<br>
<br>
-        Int refStride = refPic->getStride();<br>
-        Int refOffset = (mv->getHor() >> 2) + (mv->getVer() >> 2) * refStride;<br>
-        Pel *ref      =  refPic->getLumaAddr(cu->getAddr(), cu->getZorderIdxInCU() + partAddr) + refOffset;<br>
+    Int refStride = refPic->getStride();<br>
+    Int refOffset = (mv->getHor() >> 2) + (mv->getVer() >> 2) * refStride;<br>
+    Pel *ref      =  refPic->getLumaAddr(cu->getAddr(), cu->getZorderIdxInCU() + partAddr) + refOffset;<br>
<br>
-        Int dstStride = dstPic->getStride();<br>
-        Pel *dst      = dstPic->getLumaAddr(partAddr);<br>
+    Int dstStride = dstPic->getStride();<br>
+    Pel *dst      = dstPic->getLumaAddr(partAddr);<br>
<br>
-        Int xFrac = mv->getHor() & 0x3;<br>
-        Int yFrac = mv->getVer() & 0x3;<br>
+    Int xFrac = mv->getHor() & 0x3;<br>
+    Int yFrac = mv->getVer() & 0x3;<br>
<br>
-        Pel* src = refPic->getLumaFilterBlock(yFrac, xFrac, cu->getAddr(), cu->getZorderIdxInCU() + partAddr) + refOffset;<br>
-        Int srcStride = refPic->getStride();<br>
+    Pel* src = refPic->getLumaFilterBlock(yFrac, xFrac, cu->getAddr(), cu->getZorderIdxInCU() + partAddr) + refOffset;<br>
+    Int srcStride = refPic->getStride();<br>
<br>
-        x265::primitives.cpyblock(width, height, (pixel*)dst, dstStride, (pixel*)src, srcStride);<br>
-    }<br>
-#if HIGHBITDEPTH<br>
-    else /* For biprediction. will work correctly only when HIGHBITDEPTH enabled. Will be removed once bipred is fixed.  */<br>
-    {<br>
-        assert(bi == true);<br>
-<br>
-        Int refStride = refPic->getStride();<br>
-        Int refOffset = (mv->getHor() >> 2) + (mv->getVer() >> 2) * refStride;<br>
-        Pel *ref      =  refPic->getLumaAddr(cu->getAddr(), cu->getZorderIdxInCU() + partAddr) + refOffset;<br>
-<br>
-        Int dstStride = dstPic->getStride();<br>
-        Short *dst      = (Short*)dstPic->getLumaAddr(partAddr);<br>
-<br>
-        Int xFrac = mv->getHor() & 0x3;<br>
-        Int yFrac = mv->getVer() & 0x3;<br>
-<br>
-        Pel* src = refPic->getLumaFilterBlock(yFrac, xFrac, cu->getAddr(), cu->getZorderIdxInCU() + partAddr) + refOffset;<br>
-        Int srcStride = refPic->getStride();<br>
-<br>
-        if (yFrac == 0)<br>
-        {<br>
-            if(xFrac==0)<br>
-            {<br>
-                //filterconvertpeltoshort<br>
-                x265::primitives.ipfilterConvert_p_s(g_bitDepthY, (pixel*)ref , refStride, dst, dstStride, width, height);<br>
-            }<br>
-            else<br>
-            {<br>
-                //filterhorizontalpelshort<br>
-                x265::primitives.ipFilter_p_s[FILTER_H_P_S_8](g_bitDepthY, (pixel*)ref , refStride, dst, dstStride, width, height, TComInterpolationFilter::m_lumaFilter[xFrac]);<br>
-            }<br>
-        }<br>
-        else if (xFrac == 0)<br>
-        {<br>
-            //filterverticalpelshort<br>
-            x265::primitives.ipFilter_p_s[FILTER_V_P_S_8](g_bitDepthY, (pixel*)ref , refStride, dst, dstStride, width, height, TComInterpolationFilter::m_lumaFilter[yFrac]);<br>
-        }<br>
-        else<br>
-        {<br>
-            Int tmpStride = width;<br>
-            Int filterSize = NTAPS_LUMA;<br>
-            Int halfFilterSize = (filterSize >> 1);<br>
-            Short *tmp    = (Short*)malloc(width * (height + filterSize - 1) * sizeof(Short));<br>
-<br>
-            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]);<br>

-            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]);<br>
-<br>
-            free(tmp);<br>
-        }<br>
-    }<br>
-#endif<br>
+    x265::primitives.cpyblock(width, height, (pixel*)dst, dstStride, (pixel*)src, srcStride);<br>
 }<br>
<br>
 //Motion compensated block for biprediction<br>
@@ -704,18 +648,15 @@<br>
     {<br>
         if(xFrac==0)<br>
         {<br>
-                //filterconvertpeltoshort<br>
             x265::primitives.ipfilterConvert_p_s(g_bitDepthY, (pixel*)ref , refStride, dst, dstStride, width, height);<br>
         }<br>
         else<br>
         {<br>
-            //filterhorizontalpelshort<br>
             x265::primitives.ipFilter_p_s[FILTER_H_P_S_8](g_bitDepthY, (pixel*)ref , refStride, dst, dstStride, width, height, TComInterpolationFilter::m_lumaFilter[xFrac]);<br>
         }<br>
     }<br>
     else if (xFrac == 0)<br>
     {<br>
-        //filterverticalpelshort<br>
         x265::primitives.ipFilter_p_s[FILTER_V_P_S_8](g_bitDepthY, (pixel*)ref , refStride, dst, dstStride, width, height, TComInterpolationFilter::m_lumaFilter[yFrac]);<br>
     }<br>
     else<br>
@@ -767,89 +708,38 @@<br>
     Int filterSize = NTAPS_CHROMA;<br>
<br>
     Int halfFilterSize = (filterSize >> 1);<br>
-#if HIGHBITDEPTH<br>
-    if(bi == false)<br>
-#endif<br>
+<br>
+    if (yFrac == 0)<br>
     {<br>
-        if (yFrac == 0)<br>
+        if (xFrac == 0)<br>
         {<br>
-            if (xFrac == 0)<br>
-            {<br>
-                x265::primitives.cpyblock(cxWidth, cxHeight, (pixel*)dstCb, dstStride, (pixel*)refCb, refStride);<br>
-                x265::primitives.cpyblock(cxWidth, cxHeight, (pixel*)dstCr, dstStride, (pixel*)refCr, refStride);<br>
-            }<br>
-            else<br>
-            {<br>
-                primitives.ipFilter_p_p[FILTER_H_P_P_4](g_bitDepthC, (pixel*)refCb, refStride, (pixel*)dstCb,  dstStride, cxWidth, cxHeight, m_if.m_chromaFilter[xFrac]);<br>
-                primitives.ipFilter_p_p[FILTER_H_P_P_4](g_bitDepthC, (pixel*)refCr, refStride, (pixel*)dstCr,  dstStride, cxWidth, cxHeight, m_if.m_chromaFilter[xFrac]);<br>
-            }<br>
-        }<br>
-        else if (xFrac == 0)<br>
-        {<br>
-            primitives.ipFilter_p_p[FILTER_V_P_P_4](g_bitDepthC, (pixel*)refCb, refStride, (pixel*)dstCb, dstStride, cxWidth, cxHeight, m_if.m_chromaFilter[yFrac]);<br>
-            primitives.ipFilter_p_p[FILTER_V_P_P_4](g_bitDepthC, (pixel*)refCr, refStride, (pixel*)dstCr, dstStride, cxWidth, cxHeight, m_if.m_chromaFilter[yFrac]);<br>
+            x265::primitives.cpyblock(cxWidth, cxHeight, (pixel*)dstCb, dstStride, (pixel*)refCb, refStride);<br>
+            x265::primitives.cpyblock(cxWidth, cxHeight, (pixel*)dstCr, dstStride, (pixel*)refCr, refStride);<br>
         }<br>
         else<br>
         {<br>
-            Int     extStride = cxWidth;<br>
-            Short*  extY      = (Short*)xMalloc(Short, cxWidth * (cxHeight + filterSize - 1));<br>
-<br>
-            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]);<br>
-            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]);<br>
-<br>
-            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]);<br>
-            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]);<br>
-<br>
-            xFree(extY);<br>
+            primitives.ipFilter_p_p[FILTER_H_P_P_4](g_bitDepthC, (pixel*)refCb, refStride, (pixel*)dstCb,  dstStride, cxWidth, cxHeight, m_if.m_chromaFilter[xFrac]);<br>
+            primitives.ipFilter_p_p[FILTER_H_P_P_4](g_bitDepthC, (pixel*)refCr, refStride, (pixel*)dstCr,  dstStride, cxWidth, cxHeight, m_if.m_chromaFilter[xFrac]);<br>
         }<br>
     }<br>
-#if HIGHBITDEPTH<br>
-    else  /* For biprediction. will work correctly only when HIGHBITDEPTH enabled. Will be removed once bipred is fixed.  */<br>
-    {<br>
-        Short* dstCb = (Short*)dstPic->getCbAddr(partAddr);<br>
-        Short* dstCr = (Short*)dstPic->getCrAddr(partAddr);<br>
-        if (yFrac == 0)<br>
-        {<br>
-            //m_if.filterHorChroma(refCb, refStride, dstCb,  dstStride, cxWidth, cxHeight, xFrac, !bi);<br>
-            //m_if.filterHorChroma(refCr, refStride, dstCr,  dstStride, cxWidth, cxHeight, xFrac, !bi);<br>
-            if(xFrac==0)<br>
-            {<br>
-                    //filterconvertpeltoshort<br>
-                x265::primitives.ipfilterConvert_p_s(g_bitDepthC, (pixel*)refCb , refStride, dstCb, dstStride, cxWidth, cxHeight);<br>
-                x265::primitives.ipfilterConvert_p_s(g_bitDepthC, (pixel*)refCr , refStride, dstCr, dstStride, cxWidth, cxHeight);<br>
-            }<br>
-            else<br>
-            {<br>
-                //filterhorizontalpelshort<br>
-                x265::primitives.ipFilter_p_s[FILTER_H_P_S_4](g_bitDepthC, (pixel*)refCb , refStride, dstCb, dstStride, cxWidth, cxHeight, TComInterpolationFilter::m_chromaFilter[xFrac]);<br>
-                x265::primitives.ipFilter_p_s[FILTER_H_P_S_4](g_bitDepthC, (pixel*)refCr , refStride, dstCr, dstStride, cxWidth, cxHeight, TComInterpolationFilter::m_chromaFilter[xFrac]);<br>
-            }<br>
-        }<br>
-        else if (xFrac == 0)<br>
-        {<br>
-            //m_if.filterVerChroma(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, yFrac, true, !bi);<br>
-            //m_if.filterVerChroma(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, yFrac, true, !bi);<br>
-            x265::primitives.ipFilter_p_s[FILTER_V_P_S_4](g_bitDepthC, (pixel*)refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, TComInterpolationFilter::m_chromaFilter[yFrac]);<br>
-            x265::primitives.ipFilter_p_s[FILTER_V_P_S_4](g_bitDepthC, (pixel*)refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, TComInterpolationFilter::m_chromaFilter[yFrac]);<br>
-        }<br>
-        else<br>
-        {<br>
-            Int     extStride = cxWidth;<br>
-            Short*  extY      = (Short*)malloc(cxWidth * (cxHeight + filterSize - 1) * sizeof(Short));<br>
-            //m_if.filterHorChroma(refCb - (halfFilterSize - 1) * refStride, refStride, extY,  extStride, cxWidth, cxHeight + filterSize - 1, xFrac, false);<br>
-            //m_if.filterVerChroma(extY  + (halfFilterSize - 1) * extStride, extStride, dstCb, dstStride, cxWidth, cxHeight, yFrac, false, !bi);<br>
-            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]);<br>

-            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]);<br>
-<br>
-            //m_if.filterHorChroma(refCr - (halfFilterSize - 1) * refStride, refStride, extY,  extStride, cxWidth, cxHeight + filterSize - 1, xFrac, false);<br>
-            //m_if.filterVerChroma(extY  + (halfFilterSize - 1) * extStride, extStride, dstCr, dstStride, cxWidth, cxHeight, yFrac, false, !bi);<br>
-            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]);<br>

-            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]);<br>
-            free(extY);<br>
-        }<br>
-<br>
+    else if (xFrac == 0)<br>
+    {<br>
+        primitives.ipFilter_p_p[FILTER_V_P_P_4](g_bitDepthC, (pixel*)refCb, refStride, (pixel*)dstCb, dstStride, cxWidth, cxHeight, m_if.m_chromaFilter[yFrac]);<br>
+        primitives.ipFilter_p_p[FILTER_V_P_P_4](g_bitDepthC, (pixel*)refCr, refStride, (pixel*)dstCr, dstStride, cxWidth, cxHeight, m_if.m_chromaFilter[yFrac]);<br>
     }<br>
-#endif<br>
+    else<br>
+    {<br>
+        Int     extStride = cxWidth;<br>
+        Short*  extY      = (Short*)xMalloc(Short, cxWidth * (cxHeight + filterSize - 1));<br>
+<br>
+        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]);<br>
+        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]);<br>
+<br>
+        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]);<br>
+        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]);<br>
+<br>
+        xFree(extY);<br>
+    }<br>
 }<br>
<br>
 //Generate motion compensated block when biprediction<br>
@@ -879,25 +769,19 @@<br>
<br>
     if (yFrac == 0)<br>
     {<br>
-        //m_if.filterHorChroma(refCb, refStride, dstCb,  dstStride, cxWidth, cxHeight, xFrac, !bi);<br>
-        //m_if.filterHorChroma(refCr, refStride, dstCr,  dstStride, cxWidth, cxHeight, xFrac, !bi);<br>
         if(xFrac==0)<br>
         {<br>
-            //filterconvertpeltoshort<br>
             x265::primitives.ipfilterConvert_p_s(g_bitDepthC, (pixel*)refCb , refStride, dstCb, dstStride, cxWidth, cxHeight);<br>
             x265::primitives.ipfilterConvert_p_s(g_bitDepthC, (pixel*)refCr , refStride, dstCr, dstStride, cxWidth, cxHeight);<br>
         }<br>
         else<br>
         {<br>
-            //filterhorizontalpelshort<br>
             x265::primitives.ipFilter_p_s[FILTER_H_P_S_4](g_bitDepthC, (pixel*)refCb , refStride, dstCb, dstStride, cxWidth, cxHeight, TComInterpolationFilter::m_chromaFilter[xFrac]);<br>
             x265::primitives.ipFilter_p_s[FILTER_H_P_S_4](g_bitDepthC, (pixel*)refCr , refStride, dstCr, dstStride, cxWidth, cxHeight, TComInterpolationFilter::m_chromaFilter[xFrac]);<br>
         }<br>
     }<br>
     else if (xFrac == 0)<br>
     {<br>
-        //m_if.filterVerChroma(refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, yFrac, true, !bi);<br>
-        //m_if.filterVerChroma(refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, yFrac, true, !bi);<br>
         x265::primitives.ipFilter_p_s[FILTER_V_P_S_4](g_bitDepthC, (pixel*)refCb, refStride, dstCb, dstStride, cxWidth, cxHeight, TComInterpolationFilter::m_chromaFilter[yFrac]);<br>
         x265::primitives.ipFilter_p_s[FILTER_V_P_S_4](g_bitDepthC, (pixel*)refCr, refStride, dstCr, dstStride, cxWidth, cxHeight, TComInterpolationFilter::m_chromaFilter[yFrac]);<br>
     }<br>
@@ -905,18 +789,12 @@<br>
     {<br>
         Int     extStride = cxWidth;<br>
         Short*  extY      = (Short*)malloc(cxWidth * (cxHeight + filterSize - 1) * sizeof(Short));<br>
-        //m_if.filterHorChroma(refCb - (halfFilterSize - 1) * refStride, refStride, extY,  extStride, cxWidth, cxHeight + filterSize - 1, xFrac, false);<br>
-        //m_if.filterVerChroma(extY  + (halfFilterSize - 1) * extStride, extStride, dstCb, dstStride, cxWidth, cxHeight, yFrac, false, !bi);<br>
-        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]);<br>

+        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]);<br>

         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]);<br>
-<br>
-        //m_if.filterHorChroma(refCr - (halfFilterSize - 1) * refStride, refStride, extY,  extStride, cxWidth, cxHeight + filterSize - 1, xFrac, false);<br>
-        //m_if.filterVerChroma(extY  + (halfFilterSize - 1) * extStride, extStride, dstCr, dstStride, cxWidth, cxHeight, yFrac, false, !bi);<br>
-        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]);<br>

+        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]);<br>

         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]);<br>
         free(extY);<br>
     }<br>
-<br>
 }<br>
<br>
 Void TComPrediction::xWeightedAverage(TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartIdx, Int iWidth, Int iHeight, TComYuv*& rpcYuvDst)<br>
diff -r 7f9730659262 -r a864e518afec source/Lib/TLibCommon/TComPrediction.h<br>
--- a/source/Lib/TLibCommon/TComPrediction.h    Mon Jun 24 11:38:53 2013 +0530<br>
+++ b/source/Lib/TLibCommon/TComPrediction.h    Mon Jun 24 18:05:58 2013 +0530<br>
@@ -68,6 +68,7 @@<br>
     Pel *refAbove, *refAboveFlt, *refLeft, *refLeftFlt;<br>
<br>
     TComYuv   m_acYuvPred[2];<br>
+    TShortYUV   m_acShortPred[2];<br>
     TComYuv   m_cYuvPredTemp;<br>
     /*This holds final interpolated pixel values (0-255). Hence memory is stored as Pel.*/<br>
     TComYuv m_filteredBlock[4][4];<br>
diff -r 7f9730659262 -r a864e518afec source/Lib/TLibCommon/TComWeightPrediction.cpp<br>
--- a/source/Lib/TLibCommon/TComWeightPrediction.cpp    Mon Jun 24 11:38:53 2013 +0530<br>
+++ b/source/Lib/TLibCommon/TComWeightPrediction.cpp    Mon Jun 24 18:05:58 2013 +0530<br>
@@ -40,26 +40,27 @@<br>
 #include "TComWeightPrediction.h"<br>
 #include "TComInterpolationFilter.h"<br>
<br>
-static inline Pel weightBidirY(Int w0, Pel P0, Int w1, Pel P1, Int round, Int shift, Int offset)<br>
+static inline Pel weightBidirY(Int w0, Short P0, Int w1, Short P1, Int round, Int shift, Int offset)<br>
 {<br>
     return ClipY(((w0 * (P0 + IF_INTERNAL_OFFS) + w1 * (P1 + IF_INTERNAL_OFFS) + round + (offset << (shift - 1))) >> shift));<br>
 }<br>
<br>
-static inline Pel weightBidirC(Int w0, Pel P0, Int w1, Pel P1, Int round, Int shift, Int offset)<br>
+static inline Pel weightBidirC(Int w0, Short P0, Int w1, Short P1, Int round, Int shift, Int offset)<br>
 {<br>
     return ClipC(((w0 * (P0 + IF_INTERNAL_OFFS) + w1 * (P1 + IF_INTERNAL_OFFS) + round + (offset << (shift - 1))) >> shift));<br>
 }<br>
<br>
-static inline Pel weightUnidirY(Int w0, Pel P0, Int round, Int shift, Int offset)<br>
+static inline Pel weightUnidirY(Int w0, Short P0, Int round, Int shift, Int offset)<br>
 {<br>
     return ClipY(((w0 * (P0 + IF_INTERNAL_OFFS) + round) >> shift) + offset);<br>
 }<br>
<br>
-static inline Pel weightUnidirC(Int w0, Pel P0, Int round, Int shift, Int offset)<br>
+static inline Pel weightUnidirC(Int w0, Short P0, Int round, Int shift, Int offset)<br>
 {<br>
     return ClipC(((w0 * (P0 + IF_INTERNAL_OFFS) + round) >> shift) + offset);<br>
 }<br>
<br>
+<br>
 // ====================================================================================================================<br>
 // Class definition<br>
 // ====================================================================================================================<br>
@@ -180,6 +181,121 @@<br>
     }<br>
 }<br>
<br>
+/** weighted averaging for bi-pred<br>
+ * \param TShortYuv* pcYuvSrc0<br>
+ * \param TShortYuv* pcYuvSrc1<br>
+ * \param iPartUnitIdx<br>
+ * \param iWidth<br>
+ * \param iHeight<br>
+ * \param wpScalingParam *wp0<br>
+ * \param wpScalingParam *wp1<br>
+ * \param TComYuv* rpcYuvDst<br>
+ * \returns Void<br>
+ */<br>
+Void TComWeightPrediction::addWeightBi(TShortYUV* pcYuvSrc0, TShortYUV* pcYuvSrc1, UInt iPartUnitIdx, UInt iWidth, UInt iHeight, wpScalingParam *wp0, wpScalingParam *wp1, TComYuv* rpcYuvDst, Bool bRound)<br>
+{<br>
+    Int x, y;<br>
+<br>
+    Short* pSrcY0  = pcYuvSrc0->getLumaAddr(iPartUnitIdx);<br>
+    Short* pSrcU0  = pcYuvSrc0->getCbAddr(iPartUnitIdx);<br>
+    Short* pSrcV0  = pcYuvSrc0->getCrAddr(iPartUnitIdx);<br>
+<br>
+    Short* pSrcY1  = pcYuvSrc1->getLumaAddr(iPartUnitIdx);<br>
+    Short* pSrcU1  = pcYuvSrc1->getCbAddr(iPartUnitIdx);<br>
+    Short* pSrcV1  = pcYuvSrc1->getCrAddr(iPartUnitIdx);<br>
+<br>
+    Pel* pDstY   = rpcYuvDst->getLumaAddr(iPartUnitIdx);<br>
+    Pel* pDstU   = rpcYuvDst->getCbAddr(iPartUnitIdx);<br>
+    Pel* pDstV   = rpcYuvDst->getCrAddr(iPartUnitIdx);<br>
+<br>
+    // Luma : --------------------------------------------<br>
+    Int w0      = wp0[0].w;<br>
+    Int offset  = wp0[0].offset;<br>
+    Int shiftNum = IF_INTERNAL_PREC - g_bitDepthY;<br>
+    Int shift   = wp0[0].shift + shiftNum;<br>
+    Int round   = shift ? (1 << (shift - 1)) * bRound : 0;<br>
+    Int w1      = wp1[0].w;<br>
+<br>
+    UInt  iSrc0Stride = pcYuvSrc0->getStride();<br>
+    UInt  iSrc1Stride = pcYuvSrc1->getStride();<br>
+    UInt  iDstStride  = rpcYuvDst->getStride();<br>
+<br>
+    for (y = iHeight - 1; y >= 0; y--)<br>
+    {<br>
+        for (x = iWidth - 1; x >= 0; )<br>
+        {<br>
+            // note: luma min width is 4<br>
+            pDstY[x] = weightBidirY(w0, pSrcY0[x], w1, pSrcY1[x], round, shift, offset);<br>
+            x--;<br>
+            pDstY[x] = weightBidirY(w0, pSrcY0[x], w1, pSrcY1[x], round, shift, offset);<br>
+            x--;<br>
+            pDstY[x] = weightBidirY(w0, pSrcY0[x], w1, pSrcY1[x], round, shift, offset);<br>
+            x--;<br>
+            pDstY[x] = weightBidirY(w0, pSrcY0[x], w1, pSrcY1[x], round, shift, offset);<br>
+            x--;<br>
+        }<br>
+<br>
+        pSrcY0 += iSrc0Stride;<br>
+        pSrcY1 += iSrc1Stride;<br>
+        pDstY  += iDstStride;<br>
+    }<br>
+<br>
+    // Chroma U : --------------------------------------------<br>
+    w0      = wp0[1].w;<br>
+    offset  = wp0[1].offset;<br>
+    shiftNum = IF_INTERNAL_PREC - g_bitDepthC;<br>
+    shift   = wp0[1].shift + shiftNum;<br>
+    round   = shift ? (1 << (shift - 1)) : 0;<br>
+    w1      = wp1[1].w;<br>
+<br>
+    iSrc0Stride = pcYuvSrc0->getCStride();<br>
+    iSrc1Stride = pcYuvSrc1->getCStride();<br>
+    iDstStride  = rpcYuvDst->getCStride();<br>
+<br>
+    iWidth  >>= 1;<br>
+    iHeight >>= 1;<br>
+<br>
+    for (y = iHeight - 1; y >= 0; y--)<br>
+    {<br>
+        for (x = iWidth - 1; x >= 0; )<br>
+        {<br>
+            // note: chroma min width is 2<br>
+            pDstU[x] = weightBidirC(w0, pSrcU0[x], w1, pSrcU1[x], round, shift, offset);<br>
+            x--;<br>
+            pDstU[x] = weightBidirC(w0, pSrcU0[x], w1, pSrcU1[x], round, shift, offset);<br>
+            x--;<br>
+        }<br>
+<br>
+        pSrcU0 += iSrc0Stride;<br>
+        pSrcU1 += iSrc1Stride;<br>
+        pDstU  += iDstStride;<br>
+    }<br>
+<br>
+    // Chroma V : --------------------------------------------<br>
+    w0      = wp0[2].w;<br>
+    offset  = wp0[2].offset;<br>
+    shift   = wp0[2].shift + shiftNum;<br>
+    round   = shift ? (1 << (shift - 1)) : 0;<br>
+    w1      = wp1[2].w;<br>
+<br>
+    for (y = iHeight - 1; y >= 0; y--)<br>
+    {<br>
+        for (x = iWidth - 1; x >= 0; )<br>
+        {<br>
+            // note: chroma min width is 2<br>
+            pDstV[x] = weightBidirC(w0, pSrcV0[x], w1, pSrcV1[x], round, shift, offset);<br>
+            x--;<br>
+            pDstV[x] = weightBidirC(w0, pSrcV0[x], w1, pSrcV1[x], round, shift, offset);<br>
+            x--;<br>
+        }<br>
+<br>
+        pSrcV0 += iSrc0Stride;<br>
+        pSrcV1 += iSrc1Stride;<br>
+        pDstV  += iDstStride;<br>
+    }<br>
+}<br>
+<br>
+<br>
 /** weighted averaging for uni-pred<br>
  * \param TComYuv* pcYuvSrc0<br>
  * \param iPartUnitIdx<br>
@@ -279,6 +395,105 @@<br>
     }<br>
 }<br>
<br>
+/** weighted averaging for uni-pred<br>
+ * \param TShortYUV* pcYuvSrc0<br>
+ * \param iPartUnitIdx<br>
+ * \param iWidth<br>
+ * \param iHeight<br>
+ * \param wpScalingParam *wp0<br>
+ * \param TComYuv* rpcYuvDst<br>
+ * \returns Void<br>
+ */<br>
+Void TComWeightPrediction::addWeightUni(TShortYUV* pcYuvSrc0, UInt iPartUnitIdx, UInt iWidth, UInt iHeight, wpScalingParam *wp0, TComYuv* rpcYuvDst)<br>
+{<br>
+    Int x, y;<br>
+<br>
+    Short* pSrcY0  = pcYuvSrc0->getLumaAddr(iPartUnitIdx);<br>
+    Short* pSrcU0  = pcYuvSrc0->getCbAddr(iPartUnitIdx);<br>
+    Short* pSrcV0  = pcYuvSrc0->getCrAddr(iPartUnitIdx);<br>
+<br>
+    Pel* pDstY   = rpcYuvDst->getLumaAddr(iPartUnitIdx);<br>
+    Pel* pDstU   = rpcYuvDst->getCbAddr(iPartUnitIdx);<br>
+    Pel* pDstV   = rpcYuvDst->getCrAddr(iPartUnitIdx);<br>
+<br>
+    // Luma : --------------------------------------------<br>
+    Int w0      = wp0[0].w;<br>
+    Int offset  = wp0[0].offset;<br>
+    Int shiftNum = IF_INTERNAL_PREC - g_bitDepthY;<br>
+    Int shift   = wp0[0].shift + shiftNum;<br>
+    Int round   = shift ? (1 << (shift - 1)) : 0;<br>
+    UInt  iSrc0Stride = pcYuvSrc0->getStride();<br>
+    UInt  iDstStride  = rpcYuvDst->getStride();<br>
+<br>
+    for (y = iHeight - 1; y >= 0; y--)<br>
+    {<br>
+        for (x = iWidth - 1; x >= 0; )<br>
+        {<br>
+            // note: luma min width is 4<br>
+            pDstY[x] = weightUnidirY(w0, pSrcY0[x], round, shift, offset);<br>
+            x--;<br>
+            pDstY[x] = weightUnidirY(w0, pSrcY0[x], round, shift, offset);<br>
+            x--;<br>
+            pDstY[x] = weightUnidirY(w0, pSrcY0[x], round, shift, offset);<br>
+            x--;<br>
+            pDstY[x] = weightUnidirY(w0, pSrcY0[x], round, shift, offset);<br>
+            x--;<br>
+        }<br>
+<br>
+        pSrcY0 += iSrc0Stride;<br>
+        pDstY  += iDstStride;<br>
+    }<br>
+<br>
+    // Chroma U : --------------------------------------------<br>
+    w0      = wp0[1].w;<br>
+    offset  = wp0[1].offset;<br>
+    shiftNum = IF_INTERNAL_PREC - g_bitDepthC;<br>
+    shift   = wp0[1].shift + shiftNum;<br>
+    round   = shift ? (1 << (shift - 1)) : 0;<br>
+<br>
+    iSrc0Stride = pcYuvSrc0->getCStride();<br>
+    iDstStride  = rpcYuvDst->getCStride();<br>
+<br>
+    iWidth  >>= 1;<br>
+    iHeight >>= 1;<br>
+<br>
+    for (y = iHeight - 1; y >= 0; y--)<br>
+    {<br>
+        for (x = iWidth - 1; x >= 0; )<br>
+        {<br>
+            // note: chroma min width is 2<br>
+            pDstU[x] = weightUnidirC(w0, pSrcU0[x], round, shift, offset);<br>
+            x--;<br>
+            pDstU[x] = weightUnidirC(w0, pSrcU0[x], round, shift, offset);<br>
+            x--;<br>
+        }<br>
+<br>
+        pSrcU0 += iSrc0Stride;<br>
+        pDstU  += iDstStride;<br>
+    }<br>
+<br>
+    // Chroma V : --------------------------------------------<br>
+    w0      = wp0[2].w;<br>
+    offset  = wp0[2].offset;<br>
+    shift   = wp0[2].shift + shiftNum;<br>
+    round   = shift ? (1 << (shift - 1)) : 0;<br>
+<br>
+    for (y = iHeight - 1; y >= 0; y--)<br>
+    {<br>
+        for (x = iWidth - 1; x >= 0; )<br>
+        {<br>
+            // note: chroma min width is 2<br>
+            pDstV[x] = weightUnidirC(w0, pSrcV0[x], round, shift, offset);<br>
+            x--;<br>
+            pDstV[x] = weightUnidirC(w0, pSrcV0[x], round, shift, offset);<br>
+            x--;<br>
+        }<br>
+<br>
+        pSrcV0 += iSrc0Stride;<br>
+        pDstV  += iDstStride;<br>
+    }<br>
+}<br>
+<br>
 //=======================================================<br>
 //  getWpScaling()<br>
 //=======================================================<br>
@@ -396,6 +611,45 @@<br>
     }<br>
 }<br>
<br>
+/** weighted prediction for bi-pred<br>
+ * \param TComDataCU* pcCU<br>
+ * \param TShortYuv* pcYuvSrc0<br>
+ * \param TShortYuv* pcYuvSrc1<br>
+ * \param iRefIdx0<br>
+ * \param iRefIdx1<br>
+ * \param uiPartIdx<br>
+ * \param iWidth<br>
+ * \param iHeight<br>
+ * \param TComYuv* rpcYuvDst<br>
+ * \returns Void<br>
+ */<br>
+Void TComWeightPrediction::xWeightedPredictionBi(TComDataCU* pcCU, TShortYUV* pcYuvSrc0, TShortYUV* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartIdx, Int iWidth, Int iHeight, TComYuv* rpcYuvDst)<br>
+{<br>
+    wpScalingParam  *pwp0, *pwp1;<br>
+    const TComPPS   *pps = pcCU->getSlice()->getPPS();<br>
+<br>
+    assert(pps->getWPBiPred());<br>
+<br>
+    getWpScaling(pcCU, iRefIdx0, iRefIdx1, pwp0, pwp1);<br>
+<br>
+    if (iRefIdx0 >= 0 && iRefIdx1 >= 0)<br>
+    {<br>
+        addWeightBi(pcYuvSrc0, pcYuvSrc1, uiPartIdx, iWidth, iHeight, pwp0, pwp1, rpcYuvDst);<br>
+    }<br>
+    else if (iRefIdx0 >= 0 && iRefIdx1 <  0)<br>
+    {<br>
+        addWeightUni(pcYuvSrc0, uiPartIdx, iWidth, iHeight, pwp0, rpcYuvDst);<br>
+    }<br>
+    else if (iRefIdx0 <  0 && iRefIdx1 >= 0)<br>
+    {<br>
+        addWeightUni(pcYuvSrc1, uiPartIdx, iWidth, iHeight, pwp1, rpcYuvDst);<br>
+    }<br>
+    else<br>
+    {<br>
+        assert(0);<br>
+    }<br>
+}<br>
+<br>
 /** weighted prediction for uni-pred<br>
  * \param TComDataCU* pcCU<br>
  * \param TComYuv* pcYuvSrc<br>
@@ -428,3 +682,37 @@<br>
     }<br>
     addWeightUni(pcYuvSrc, uiPartAddr, iWidth, iHeight, pwp, rpcYuvPred);<br>
 }<br>
+<br>
+<br>
+/** weighted prediction for uni-pred<br>
+ * \param TComDataCU* pcCU<br>
+ * \param TShortYuv* pcYuvSrc<br>
+ * \param uiPartAddr<br>
+ * \param iWidth<br>
+ * \param iHeight<br>
+ * \param eRefPicList<br>
+ * \param TComYuv*& rpcYuvPred<br>
+ * \param iPartIdx<br>
+ * \param iRefIdx<br>
+ * \returns Void<br>
+ */<br>
+Void TComWeightPrediction::xWeightedPredictionUni(TComDataCU* pcCU, TShortYUV* pcYuvSrc, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iRefIdx)<br>
+{<br>
+    wpScalingParam  *pwp, *pwpTmp;<br>
+<br>
+    if (iRefIdx < 0)<br>
+    {<br>
+        iRefIdx   = pcCU->getCUMvField(eRefPicList)->getRefIdx(uiPartAddr);<br>
+    }<br>
+    assert(iRefIdx >= 0);<br>
+<br>
+    if (eRefPicList == REF_PIC_LIST_0)<br>
+    {<br>
+        getWpScaling(pcCU, iRefIdx, -1, pwp, pwpTmp);<br>
+    }<br>
+    else<br>
+    {<br>
+        getWpScaling(pcCU, -1, iRefIdx, pwpTmp, pwp);<br>
+    }<br>
+    addWeightUni(pcYuvSrc, uiPartAddr, iWidth, iHeight, pwp, rpcYuvPred);<br>
+}<br>
diff -r 7f9730659262 -r a864e518afec source/Lib/TLibCommon/TComWeightPrediction.h<br>
--- a/source/Lib/TLibCommon/TComWeightPrediction.h      Mon Jun 24 11:38:53 2013 +0530<br>
+++ b/source/Lib/TLibCommon/TComWeightPrediction.h      Mon Jun 24 18:05:58 2013 +0530<br>
@@ -58,10 +58,14 @@<br>
     Void  getWpScaling(TComDataCU* pcCU, Int iRefIdx0, Int iRefIdx1, wpScalingParam *&wp0, wpScalingParam *&wp1);<br>
<br>
     Void  addWeightBi(TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt iPartUnitIdx, UInt iWidth, UInt iHeight, wpScalingParam *wp0, wpScalingParam *wp1, TComYuv* rpcYuvDst, Bool bRound = true);<br>
+    Void  addWeightBi(TShortYUV* pcYuvSrc0, TShortYUV* pcYuvSrc1, UInt iPartUnitIdx, UInt iWidth, UInt iHeight, wpScalingParam *wp0, wpScalingParam *wp1, TComYuv* rpcYuvDst, Bool bRound = true);<br>
     Void  addWeightUni(TComYuv* pcYuvSrc0, UInt iPartUnitIdx, UInt iWidth, UInt iHeight, wpScalingParam *wp0, TComYuv* rpcYuvDst);<br>
+    Void  addWeightUni(TShortYUV* pcYuvSrc0, UInt iPartUnitIdx, UInt iWidth, UInt iHeight, wpScalingParam *wp0, TComYuv* rpcYuvDst);<br>
<br>
     Void  xWeightedPredictionUni(TComDataCU* pcCU, TComYuv* pcYuvSrc, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iRefIdx = -1);<br>
+    Void  xWeightedPredictionUni(TComDataCU* pcCU, TShortYUV* pcYuvSrc, UInt uiPartAddr, Int iWidth, Int iHeight, RefPicList eRefPicList, TComYuv*& rpcYuvPred, Int iRefIdx = -1);<br>
     Void  xWeightedPredictionBi(TComDataCU* pcCU, TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartIdx, Int iWidth, Int iHeight, TComYuv* rpcYuvDst);<br>
+    Void  xWeightedPredictionBi(TComDataCU* pcCU, TShortYUV* pcYuvSrc0, TShortYUV* pcYuvSrc1, Int iRefIdx0, Int iRefIdx1, UInt uiPartIdx, Int iWidth, Int iHeight, TComYuv* rpcYuvDst);<br>
 };<br>
<br>
 #endif // ifndef __TCOMWEIGHTPREDICTION__<br>
diff -r 7f9730659262 -r a864e518afec source/Lib/TLibCommon/TComYuv.cpp<br>
--- a/source/Lib/TLibCommon/TComYuv.cpp Mon Jun 24 11:38:53 2013 +0530<br>
+++ b/source/Lib/TLibCommon/TComYuv.cpp Mon Jun 24 18:05:58 2013 +0530<br>
@@ -649,6 +649,75 @@<br>
     }<br>
 }<br>
<br>
+Void TComYuv::addAvg(TShortYUV* pcYuvSrc0, TShortYUV* pcYuvSrc1, UInt iPartUnitIdx, UInt iWidth, UInt iHeight)<br>
+{<br>
+    Int x, y;<br>
+<br>
+    Short* pSrcY0  = pcYuvSrc0->getLumaAddr(iPartUnitIdx);<br>
+    Short* pSrcU0  = pcYuvSrc0->getCbAddr(iPartUnitIdx);<br>
+    Short* pSrcV0  = pcYuvSrc0->getCrAddr(iPartUnitIdx);<br>
+<br>
+    Short* pSrcY1  = pcYuvSrc1->getLumaAddr(iPartUnitIdx);<br>
+    Short* pSrcU1  = pcYuvSrc1->getCbAddr(iPartUnitIdx);<br>
+    Short* pSrcV1  = pcYuvSrc1->getCrAddr(iPartUnitIdx);<br>
+<br>
+    Pel* pDstY   = getLumaAddr(iPartUnitIdx);<br>
+    Pel* pDstU   = getCbAddr(iPartUnitIdx);<br>
+    Pel* pDstV   = getCrAddr(iPartUnitIdx);<br>
+<br>
+    UInt  iSrc0Stride = pcYuvSrc0->getStride();<br>
+    UInt  iSrc1Stride = pcYuvSrc1->getStride();<br>
+    UInt  iDstStride  = getStride();<br>
+    Int shiftNum = IF_INTERNAL_PREC + 1 - g_bitDepthY;<br>
+    Int offset = (1 << (shiftNum - 1)) + 2 * IF_INTERNAL_OFFS;<br>
+<br>
+    for (y = 0; y < iHeight; y++)<br>
+    {<br>
+        for (x = 0; x < iWidth; x += 4)<br>
+        {<br>
+            pDstY[x + 0] = ClipY((pSrcY0[x + 0] + pSrcY1[x + 0] + offset) >> shiftNum);<br>
+            pDstY[x + 1] = ClipY((pSrcY0[x + 1] + pSrcY1[x + 1] + offset) >> shiftNum);<br>
+            pDstY[x + 2] = ClipY((pSrcY0[x + 2] + pSrcY1[x + 2] + offset) >> shiftNum);<br>
+            pDstY[x + 3] = ClipY((pSrcY0[x + 3] + pSrcY1[x + 3] + offset) >> shiftNum);<br>
+        }<br>
+<br>
+        pSrcY0 += iSrc0Stride;<br>
+        pSrcY1 += iSrc1Stride;<br>
+        pDstY  += iDstStride;<br>
+    }<br>
+<br>
+    shiftNum = IF_INTERNAL_PREC + 1 - g_bitDepthC;<br>
+    offset = (1 << (shiftNum - 1)) + 2 * IF_INTERNAL_OFFS;<br>
+<br>
+    iSrc0Stride = pcYuvSrc0->getCStride();<br>
+    iSrc1Stride = pcYuvSrc1->getCStride();<br>
+    iDstStride  = getCStride();<br>
+<br>
+    iWidth  >>= 1;<br>
+    iHeight >>= 1;<br>
+<br>
+    for (y = iHeight - 1; y >= 0; y--)<br>
+    {<br>
+        for (x = iWidth - 1; x >= 0; )<br>
+        {<br>
+            // note: chroma min width is 2<br>
+            pDstU[x] = ClipC((pSrcU0[x] + pSrcU1[x] + offset) >> shiftNum);<br>
+            pDstV[x] = ClipC((pSrcV0[x] + pSrcV1[x] + offset) >> shiftNum);<br>
+            x--;<br>
+            pDstU[x] = ClipC((pSrcU0[x] + pSrcU1[x] + offset) >> shiftNum);<br>
+            pDstV[x] = ClipC((pSrcV0[x] + pSrcV1[x] + offset) >> shiftNum);<br>
+            x--;<br>
+        }<br>
+<br>
+        pSrcU0 += iSrc0Stride;<br>
+        pSrcU1 += iSrc1Stride;<br>
+        pSrcV0 += iSrc0Stride;<br>
+        pSrcV1 += iSrc1Stride;<br>
+        pDstU  += iDstStride;<br>
+        pDstV  += iDstStride;<br>
+    }<br>
+}<br>
+<br>
 Void TComYuv::removeHighFreq(TComYuv* pcYuvSrc, UInt uiPartIdx, UInt uiWidht, UInt uiHeight)<br>
 {<br>
     Int x, y;<br>
diff -r 7f9730659262 -r a864e518afec source/Lib/TLibCommon/TComYuv.h<br>
--- a/source/Lib/TLibCommon/TComYuv.h   Mon Jun 24 11:38:53 2013 +0530<br>
+++ b/source/Lib/TLibCommon/TComYuv.h   Mon Jun 24 18:05:58 2013 +0530<br>
@@ -157,6 +157,7 @@<br>
<br>
     //  (pcYuvSrc0 + pcYuvSrc1)/2 for YUV partition<br>
     Void    addAvg(TComYuv* pcYuvSrc0, TComYuv* pcYuvSrc1, UInt iPartUnitIdx, UInt iWidth, UInt iHeight);<br>
+    Void    addAvg(TShortYUV* pcYuvSrc0, TShortYUV* pcYuvSrc1, UInt iPartUnitIdx, UInt iWidth, UInt iHeight);<br>
<br>
     //   Remove High frequency<br>
     Void    removeHighFreq(TComYuv* pcYuvSrc, UInt uiPartIdx, UInt uiWidht, UInt uiHeight);<br>
diff -r 7f9730659262 -r a864e518afec source/Lib/TLibEncoder/TEncSearch.cpp<br>
--- a/source/Lib/TLibEncoder/TEncSearch.cpp     Mon Jun 24 11:38:53 2013 +0530<br>
+++ b/source/Lib/TLibEncoder/TEncSearch.cpp     Mon Jun 24 18:05:58 2013 +0530<br>
@@ -3561,18 +3561,15 @@<br>
     // prediction pattern<br>
     if (pcCU->getSlice()->getPPS()->getUseWP() && pcCU->getSlice()->getSliceType() == P_SLICE)<br>
     {<br>
-        xPredInterLumaBlk(pcCU, pcPicYuvRef, uiPartAddr, &cMvCand, iSizeX, iSizeY, pcTemplateCand, true);<br>
+        TShortYUV *pcMbYuv = &m_acShortPred[0];<br>
+        xPredInterLumaBlk(pcCU, pcPicYuvRef, uiPartAddr, &cMvCand, iSizeX, iSizeY, pcMbYuv, true);<br>
+        xWeightedPredictionUni(pcCU, pcMbYuv, uiPartAddr, iSizeX, iSizeY, eRefPicList, pcTemplateCand, iRefIdx);<br>
     }<br>
     else<br>
     {<br>
         xPredInterLumaBlk(pcCU, pcPicYuvRef, uiPartAddr, &cMvCand, iSizeX, iSizeY, pcTemplateCand, false);<br>
     }<br>
<br>
-    if (pcCU->getSlice()->getPPS()->getUseWP() && pcCU->getSlice()->getSliceType() == P_SLICE)<br>
-    {<br>
-        xWeightedPredictionUni(pcCU, pcTemplateCand, uiPartAddr, iSizeX, iSizeY, eRefPicList, pcTemplateCand, iRefIdx);<br>
-    }<br>
-<br>
     // calc distortion<br>
     uiCost = m_me.bufSAD((pixel*)pcTemplateCand->getLumaAddr(uiPartAddr), pcTemplateCand->getStride());<br>
     x265_emms();<br>
<br>_______________________________________________<br>
x265-devel mailing list<br>
<a href="mailto:x265-devel@videolan.org">x265-devel@videolan.org</a><br>
<a href="http://mailman.videolan.org/listinfo/x265-devel" target="_blank">http://mailman.videolan.org/listinfo/x265-devel</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br>Steve Borho
</div></div>