[x265] [PATCH 1 of 5] predict: inline single call of predInterBi()

Steve Borho steve at borho.org
Thu Sep 25 05:32:04 CEST 2014


# HG changeset patch
# User Steve Borho <steve at borho.org>
# Date 1411594685 18000
#      Wed Sep 24 16:38:05 2014 -0500
# Node ID a5d10add90dc4d4fd8d856955315d7d8ce327318
# Parent  87ac13088486f24625d80317fd9dbb4c6b1a27a8
predict: inline single call of predInterBi()

diff -r 87ac13088486 -r a5d10add90dc source/encoder/predict.cpp
--- a/source/encoder/predict.cpp	Wed Sep 24 16:21:42 2014 -0500
+++ b/source/encoder/predict.cpp	Wed Sep 24 16:38:05 2014 -0500
@@ -167,6 +167,7 @@
 {
     if (m_slice->isInterP())
     {
+        /* P Slice */
         if (m_slice->m_pps->bUseWeightPred)
         {
             ShortYuv* shortYuv = &m_predShortYuv[0];
@@ -184,7 +185,78 @@
             predInterUni(0, predYuv, bLuma, bChroma);
     }
     else
-        predInterBi(cu, predYuv, bLuma, bChroma);
+    {
+        /* B Slice */
+        int refIdx0 = m_mvField[REF_PIC_LIST_0]->getRefIdx(m_partAddr);
+        int refIdx1 = m_mvField[REF_PIC_LIST_1]->getRefIdx(m_partAddr);
+
+        if (refIdx0 >= 0 && refIdx1 >= 0)
+        {
+            /* Biprediction */
+            X265_CHECK(refIdx0 < m_slice->m_numRefIdx[0], "bidir refidx0 out of range\n");
+            X265_CHECK(refIdx1 < m_slice->m_numRefIdx[1], "bidir refidx1 out of range\n");
+
+            predInterUni(0, &m_predShortYuv[0], bLuma, bChroma);
+            predInterUni(1, &m_predShortYuv[1], bLuma, bChroma);
+
+            if (m_slice->m_pps->bUseWeightedBiPred)
+            {
+                WeightParam *pwp0 = NULL, *pwp1 = NULL;
+                getWpScaling(cu, refIdx0, refIdx1, pwp0, pwp1);
+                addWeightBi(&m_predShortYuv[0], &m_predShortYuv[1], m_partAddr, m_width, m_height, pwp0, pwp1, predYuv, bLuma, bChroma);
+            }
+            else
+                predYuv->addAvg(&m_predShortYuv[0], &m_predShortYuv[1], m_partAddr, m_width, m_height, bLuma, bChroma);
+        }
+        else if (m_slice->m_pps->bUseWeightedBiPred)
+        {
+            /* if weighted prediction is possible, we must check if it has been
+             * enabled and configured for this particular reference */
+            WeightParam *pwp0 = NULL, *pwp1 = NULL;
+            getWpScaling(cu, refIdx0, refIdx1, pwp0, pwp1);
+
+            if (refIdx0 >= 0)
+            {
+                X265_CHECK(refIdx0 < m_slice->m_numRefIdx[0], "unidir refidx0 out of range\n");
+
+                if (pwp0->bPresentFlag)
+                {
+                    /* TODO: can we use fast weighted uni-prediction here? */
+                    predInterUni(0, &m_predShortYuv[0], bLuma, bChroma);
+                    addWeightUni(&m_predShortYuv[0], m_partAddr, m_width, m_height, pwp0, predYuv, bLuma, bChroma);
+                }
+                else
+                    predInterUni(0, predYuv, bLuma, bChroma);
+            }
+            else
+            {
+                X265_CHECK(refIdx1 >= 0, "refidx1 was not positive\n");
+                X265_CHECK(refIdx1 < m_slice->m_numRefIdx[1], "unidir refidx1 out of range\n");
+
+                if (pwp1->bPresentFlag)
+                {
+                    /* TODO: can we use fast weighted uni-prediction here? */
+                    predInterUni(1, &m_predShortYuv[1], bLuma, bChroma);
+                    addWeightUni(&m_predShortYuv[1], m_partAddr, m_width, m_height, pwp1, predYuv, bLuma, bChroma);
+                }
+                else
+                    predInterUni(1, predYuv, bLuma, bChroma);
+            }
+        }
+        else if (refIdx0 >= 0)
+        {
+            X265_CHECK(refIdx0 < m_slice->m_numRefIdx[0], "unidir refidx0 out of range\n");
+
+            predInterUni(0, predYuv, bLuma, bChroma);
+        }
+        else
+        {
+            X265_CHECK(refIdx1 >= 0, "refidx1 was not positive\n");
+            X265_CHECK(refIdx1 < m_slice->m_numRefIdx[1], "unidir refidx1 out of range\n");
+
+            predInterUni(1, predYuv, bLuma, bChroma);
+        }
+    }
 }
 
 void Predict::predInterUni(int list, TComYuv* outPredYuv, bool bLuma, bool bChroma)
@@ -213,80 +285,6 @@
         predInterChromaBlk(m_slice->m_refPicList[list][refIdx]->getPicYuvRec(), outPredYuv, &m_clippedMv[list]);
 }
 
-void Predict::predInterBi(TComDataCU* cu, TComYuv* outPredYuv, bool bLuma, bool bChroma)
-{
-    X265_CHECK(m_slice->isInterB(), "biprediction in P frame\n");
-
-    int refIdx0 = m_mvField[REF_PIC_LIST_0]->getRefIdx(m_partAddr);
-    int refIdx1 = m_mvField[REF_PIC_LIST_1]->getRefIdx(m_partAddr);
-
-    if (refIdx0 >= 0 && refIdx1 >= 0)
-    {
-        X265_CHECK(refIdx0 < m_slice->m_numRefIdx[0], "bidir refidx0 out of range\n");
-        X265_CHECK(refIdx1 < m_slice->m_numRefIdx[1], "bidir refidx1 out of range\n");
-
-        predInterUni(0, &m_predShortYuv[0], bLuma, bChroma);
-        predInterUni(1, &m_predShortYuv[1], bLuma, bChroma);
-
-        if (m_slice->m_pps->bUseWeightedBiPred)
-        {
-            WeightParam *pwp0 = NULL, *pwp1 = NULL;
-            getWpScaling(cu, refIdx0, refIdx1, pwp0, pwp1);
-            addWeightBi(&m_predShortYuv[0], &m_predShortYuv[1], m_partAddr, m_width, m_height, pwp0, pwp1, outPredYuv, bLuma, bChroma);
-        }
-        else
-            outPredYuv->addAvg(&m_predShortYuv[0], &m_predShortYuv[1], m_partAddr, m_width, m_height, bLuma, bChroma);
-    }
-    else if (m_slice->m_pps->bUseWeightedBiPred)
-    {
-        /* if weighted prediction is possible, we must check if it has been
-         * configured for this reference */
-        WeightParam *pwp0 = NULL, *pwp1 = NULL;
-        getWpScaling(cu, refIdx0, refIdx1, pwp0, pwp1);
-
-        if (refIdx0 >= 0)
-        {
-            X265_CHECK(refIdx0 < m_slice->m_numRefIdx[0], "unidir refidx0 out of range\n");
-
-            if (pwp0->bPresentFlag)
-            {
-                /* TODO: can we use fast weighted uni-prediction here? */
-                predInterUni(0, &m_predShortYuv[0], bLuma, bChroma);
-                addWeightUni(&m_predShortYuv[0], m_partAddr, m_width, m_height, pwp0, outPredYuv, bLuma, bChroma);
-            }
-            else
-                predInterUni(0, outPredYuv, bLuma, bChroma);
-        }
-        else
-        {
-            X265_CHECK(refIdx1 >= 0, "refidx1 was not positive\n");
-            X265_CHECK(refIdx1 < m_slice->m_numRefIdx[1], "unidir refidx1 out of range\n");
-
-            if (pwp1->bPresentFlag)
-            {
-                /* TODO: can we use fast weighted uni-prediction here? */
-                predInterUni(1, &m_predShortYuv[1], bLuma, bChroma);
-                addWeightUni(&m_predShortYuv[1], m_partAddr, m_width, m_height, pwp1, outPredYuv, bLuma, bChroma);
-            }
-            else
-                predInterUni(1, outPredYuv, bLuma, bChroma);
-        }
-    }
-    else if (refIdx0 >= 0)
-    {
-        X265_CHECK(refIdx0 < m_slice->m_numRefIdx[0], "unidir refidx0 out of range\n");
-
-        predInterUni(0, outPredYuv, bLuma, bChroma);
-    }
-    else
-    {
-        X265_CHECK(refIdx1 >= 0, "refidx1 was not positive\n");
-        X265_CHECK(refIdx1 < m_slice->m_numRefIdx[1], "unidir refidx1 out of range\n");
-
-        predInterUni(1, outPredYuv, bLuma, bChroma);
-    }
-}
-
 void Predict::predInterLumaBlk(TComPicYuv *refPic, TComYuv *dstPic, MV *mv)
 {
     int dstStride = dstPic->getStride();
diff -r 87ac13088486 -r a5d10add90dc source/encoder/predict.h
--- a/source/encoder/predict.h	Wed Sep 24 16:21:42 2014 -0500
+++ b/source/encoder/predict.h	Wed Sep 24 16:38:05 2014 -0500
@@ -66,8 +66,6 @@
     void predInterChromaBlk(TComPicYuv *refPic, TComYuv *dstPic, MV *mv);
     void predInterChromaBlk(TComPicYuv *refPic, ShortYuv *dstPic, MV *mv);
 
-    void predInterBi(TComDataCU* cu, TComYuv* outPredYuv, bool bLuma, bool bChroma);
-
     void addWeightBi(ShortYuv* srcYuv0, ShortYuv* srcYuv1, uint32_t partUnitIdx, uint32_t width, uint32_t height, WeightParam *wp0, WeightParam *wp1, TComYuv* outDstYuv, bool bLuma, bool bChroma);
     void addWeightUni(ShortYuv* srcYuv0, uint32_t partUnitIdx, uint32_t width, uint32_t height, WeightParam *wp0, TComYuv* outDstYuv, bool bLuma, bool bChroma);
 


More information about the x265-devel mailing list