[x265] [PATCH 11 of 14] predict: use faster unidir prediction for B frames when weighting not enabled

Steve Borho steve at borho.org
Sat Sep 20 18:46:10 CEST 2014


# HG changeset patch
# User Steve Borho <steve at borho.org>
# Date 1411234203 -3600
#      Sat Sep 20 18:30:03 2014 +0100
# Node ID c388593c272d1d2e51b466645c132d6b45bd40ec
# Parent  a2f5d5a4b48f9e0679684a5c723f7b488b016f40
predict: use faster unidir prediction for B frames when weighting not enabled

diff -r a2f5d5a4b48f -r c388593c272d source/encoder/predict.cpp
--- a/source/encoder/predict.cpp	Sat Sep 20 18:12:56 2014 +0100
+++ b/source/encoder/predict.cpp	Sat Sep 20 18:30:03 2014 +0100
@@ -277,19 +277,35 @@
     }
     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)
         {
-            predInterUni(0, &m_predShortYuv[0], bLuma, bChroma);
-            addWeightUni(&m_predShortYuv[0], m_partAddr, m_width, m_height, pwp0, outPredYuv, bLuma, bChroma);
+            X265_CHECK(refIdx0 < m_slice->m_numRefIdx[0], "unidir refidx0 out of range\n");
+
+            if (pwp0->bPresentFlag)
+            {
+                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");
-            predInterUni(1, &m_predShortYuv[1], bLuma, bChroma);
-            addWeightUni(&m_predShortYuv[1], m_partAddr, m_width, m_height, pwp1, outPredYuv, bLuma, bChroma);
+            X265_CHECK(refIdx1 < m_slice->m_numRefIdx[1], "unidir refidx1 out of range\n");
+
+            if (pwp1->bPresentFlag)
+            {
+                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)


More information about the x265-devel mailing list