[x265-commits] [x265] entropy: fix warning reported by llvm

Steve Borho steve at borho.org
Fri Jul 18 07:31:15 CEST 2014


details:   http://hg.videolan.org/x265/rev/8eed1fac9ccb
branches:  
changeset: 7469:8eed1fac9ccb
user:      Steve Borho <steve at borho.org>
date:      Thu Jul 17 22:08:05 2014 -0500
description:
entropy: fix warning reported by llvm

/Users/steve/repos/x265/source/encoder/entropy.cpp:321:44: warning: equality comparison with extraneous parentheses[-Wparentheses-equality]
    if ((cu->getSlice()->m_numRefIdx[list] == 1))
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
Subject: [x265] slice: remove m_bLMvdL1Zero

details:   http://hg.videolan.org/x265/rev/82c1fec5da66
branches:  
changeset: 7470:82c1fec5da66
user:      Steve Borho <steve at borho.org>
date:      Thu Jul 17 22:12:32 2014 -0500
description:
slice: remove m_bLMvdL1Zero

This feature, which signals L1 MVD is zero for an entire slice, was never
enabled because we never use the same frame list in L0 and L1.
Subject: [x265] dpb: remove check for B frame without L1

details:   http://hg.videolan.org/x265/rev/fb9681ba75ac
branches:  
changeset: 7471:fb9681ba75ac
user:      Steve Borho <steve at borho.org>
date:      Thu Jul 17 22:19:00 2014 -0500
description:
dpb: remove check for B frame without L1

our lookahead won't emit B frames without a leading P frame
Subject: [x265] dpb: simplify check for m_bCheckLDC; make note for future optimization

details:   http://hg.videolan.org/x265/rev/f7624977ec9a
branches:  
changeset: 7472:f7624977ec9a
user:      Steve Borho <steve at borho.org>
date:      Thu Jul 17 23:14:58 2014 -0500
description:
dpb: simplify check for m_bCheckLDC; make note for future optimization
Subject: [x265] entropy: slice->m_colFromL0Flag is a bool

details:   http://hg.videolan.org/x265/rev/1bf5e0390f7d
branches:  
changeset: 7473:1bf5e0390f7d
user:      Steve Borho <steve at borho.org>
date:      Thu Jul 17 23:22:15 2014 -0500
description:
entropy: slice->m_colFromL0Flag is a bool
Subject: [x265] encoder: do some slice initializations only once

details:   http://hg.videolan.org/x265/rev/37ea4eb500cf
branches:  
changeset: 7474:37ea4eb500cf
user:      Steve Borho <steve at borho.org>
date:      Thu Jul 17 23:26:35 2014 -0500
description:
encoder: do some slice initializations only once
Subject: [x265] slice: do not initialize fields that are always written unconditionally

details:   http://hg.videolan.org/x265/rev/eb6178f8449e
branches:  
changeset: 7475:eb6178f8449e
user:      Steve Borho <steve at borho.org>
date:      Thu Jul 17 23:28:43 2014 -0500
description:
slice: do not initialize fields that are always written unconditionally
Subject: [x265] slice: make xGetRefPic a PicList method

details:   http://hg.videolan.org/x265/rev/b4643bc7ac7d
branches:  
changeset: 7476:b4643bc7ac7d
user:      Steve Borho <steve at borho.org>
date:      Thu Jul 17 23:36:55 2014 -0500
description:
slice: make xGetRefPic a PicList method
Subject: [x265] slice: remove getWpScaling()

details:   http://hg.videolan.org/x265/rev/601e61fb185f
branches:  
changeset: 7477:601e61fb185f
user:      Steve Borho <steve at borho.org>
date:      Thu Jul 17 23:45:29 2014 -0500
description:
slice: remove getWpScaling()
Subject: [x265] slice: remove unused initWpScaling()

details:   http://hg.videolan.org/x265/rev/9cbd9fc1710a
branches:  
changeset: 7478:9cbd9fc1710a
user:      Steve Borho <steve at borho.org>
date:      Thu Jul 17 23:48:38 2014 -0500
description:
slice: remove unused initWpScaling()

diffstat:

 source/Lib/TLibCommon/TComSlice.cpp            |  61 +-------------------------
 source/Lib/TLibCommon/TComSlice.h              |  29 ++----------
 source/Lib/TLibCommon/TComWeightPrediction.cpp |  34 +++++---------
 source/common/piclist.cpp                      |   8 +++
 source/common/piclist.h                        |   3 +
 source/encoder/dpb.cpp                         |  52 ++++-----------------
 source/encoder/encoder.cpp                     |   2 +
 source/encoder/entropy.cpp                     |  17 ++----
 source/encoder/frameencoder.cpp                |   2 -
 9 files changed, 49 insertions(+), 159 deletions(-)

diffs (truncated from 425 to 300 lines):

diff -r 93ab6ed75b01 -r 9cbd9fc1710a source/Lib/TLibCommon/TComSlice.cpp
--- a/source/Lib/TLibCommon/TComSlice.cpp	Thu Jul 17 20:54:19 2014 -0500
+++ b/source/Lib/TLibCommon/TComSlice.cpp	Thu Jul 17 23:48:38 2014 -0500
@@ -42,24 +42,6 @@
 
 using namespace x265;
 
-Frame* TComSlice::xGetRefPic(PicList& picList, int poc)
-{
-    Frame *iterPic = picList.first();
-    Frame* pic = NULL;
-
-    while (iterPic)
-    {
-        pic = iterPic;
-        if (pic->getPOC() == poc)
-        {
-            break;
-        }
-        iterPic = iterPic->m_next;
-    }
-
-    return pic;
-}
-
 void TComSlice::setRefPicList(PicList& picList)
 {
     if (m_sliceType == I_SLICE)
@@ -82,7 +64,7 @@ void TComSlice::setRefPicList(PicList& p
     {
         if (m_rps.m_used[i])
         {
-            refPic = xGetRefPic(picList, m_poc + m_rps.m_deltaPOC[i]);
+            refPic = picList.getPOC(m_poc + m_rps.m_deltaPOC[i]);
             refPicSetStCurr0[numPocStCurr0] = refPic;
             numPocStCurr0++;
         }
@@ -92,7 +74,7 @@ void TComSlice::setRefPicList(PicList& p
     {
         if (m_rps.m_used[i])
         {
-            refPic = xGetRefPic(picList, m_poc + m_rps.m_deltaPOC[i]);
+            refPic = picList.getPOC(m_poc + m_rps.m_deltaPOC[i]);
             refPicSetStCurr1[numPocStCurr1] = refPic;
             numPocStCurr1++;
         }
@@ -160,17 +142,6 @@ void TComSlice::setRefPicList(PicList& p
             m_refPOCList[dir][numRefIdx] = m_refPicList[dir][numRefIdx]->getPOC();
 }
 
-/** get WP tables for weighted pred
- * \param int
- * \param refIdx
- * \param *&wpScalingParam
- * \returns void
- */
-void TComSlice::getWpScaling(int l, int refIdx, WeightParam *&wp)
-{
-    wp = m_weightPredTable[l][refIdx];
-}
-
 /** reset Default WP tables settings : no weight.
  * \param wpScalingParam
  * \returns void
@@ -193,34 +164,6 @@ void TComSlice::resetWpScaling()
     }
 }
 
-/** init WP table
- * \returns void
- */
-void TComSlice::initWpScaling()
-{
-    for (int e = 0; e < 2; e++)
-    {
-        for (int i = 0; i < MAX_NUM_REF; i++)
-        {
-            for (int yuv = 0; yuv < 3; yuv++)
-            {
-                WeightParam  *pwp = &(m_weightPredTable[e][i][yuv]);
-                if (!pwp->bPresentFlag)
-                {
-                    // Inferring values not present :
-                    pwp->inputWeight = (1 << pwp->log2WeightDenom);
-                    pwp->inputOffset = 0;
-                }
-
-                pwp->w      = pwp->inputWeight;
-                pwp->o      = pwp->inputOffset << (X265_DEPTH - 8);
-                pwp->shift  = pwp->log2WeightDenom;
-                pwp->round  = (pwp->log2WeightDenom >= 1) ? (1 << (pwp->log2WeightDenom - 1)) : (0);
-            }
-        }
-    }
-}
-
 /* Sorts the deltaPOC and Used by current values in the RPS based on the
  * deltaPOC values.  deltaPOC values are sorted with -ve values before the +ve
  * values.  -ve values are in decreasing order.  +ve values are in increasing
diff -r 93ab6ed75b01 -r 9cbd9fc1710a source/Lib/TLibCommon/TComSlice.h
--- a/source/Lib/TLibCommon/TComSlice.h	Thu Jul 17 20:54:19 2014 -0500
+++ b/source/Lib/TLibCommon/TComSlice.h	Thu Jul 17 23:48:38 2014 -0500
@@ -324,32 +324,21 @@ public:
     int         m_lastIDR;
     bool        m_bReferenced;
 
-    bool        m_bCheckLDC;       // TODO: What is this for?
-    bool        m_bLMvdL1Zero;     // TODOD: what is mvd_l1_zero_flag?
+    bool        m_bCheckLDC;       // TODO: is this necessary?
     bool        m_colFromL0Flag;   // collocated picture from List0 or List1 flag
     uint32_t    m_colRefIdx;       // never modified
     
-    uint32_t    m_maxNumMergeCand; // use param
-
     int         m_numRefIdx[2];
     Frame*      m_refPicList[2][MAX_NUM_REF + 1];
     int         m_refPOCList[2][MAX_NUM_REF + 1];
 
+    uint32_t    m_maxNumMergeCand; // use param
     uint32_t    m_sliceCurEndCUAddr;
 
     TComSlice()
     {
         m_lastIDR = 0;
-        m_nalUnitType = NAL_UNIT_CODED_SLICE_IDR_W_RADL;
-        m_sliceType = I_SLICE;
-        m_sliceQp = 0;
-        m_bCheckLDC = false;
-        m_bReferenced = false;
-        m_colFromL0Flag = 1;
-        m_sliceCurEndCUAddr = 0;
-        m_bLMvdL1Zero = false;
         m_numRefIdx[0] = m_numRefIdx[1] = 0;
-
         for (int i = 0; i < MAX_NUM_REF; i++)
         {
             m_refPicList[0][i] = NULL;
@@ -365,7 +354,7 @@ public:
     {
         m_numRefIdx[0] = 0;
         m_numRefIdx[1] = 0;
-        m_colFromL0Flag = 1;
+        m_colFromL0Flag = true;
         m_colRefIdx = 0;
         m_bCheckLDC = false;
     }
@@ -399,16 +388,8 @@ public:
 
     bool isInterP() const { return m_sliceType == P_SLICE; }
 
-    void  setWpScaling(WeightParam wp[2][MAX_NUM_REF][3]) { memcpy(m_weightPredTable, wp, sizeof(WeightParam) * 2 * MAX_NUM_REF * 3); }
-
-    void  getWpScaling(int e, int refIdx, WeightParam *&wp);
-
-    void  resetWpScaling();
-    void  initWpScaling();
-
-protected:
-
-    Frame*  xGetRefPic(PicList& picList, int poc);
+    void setWpScaling(WeightParam wp[2][MAX_NUM_REF][3]) { memcpy(m_weightPredTable, wp, sizeof(WeightParam) * 2 * MAX_NUM_REF * 3); }
+    void resetWpScaling();
 };
 }
 //! \}
diff -r 93ab6ed75b01 -r 9cbd9fc1710a source/Lib/TLibCommon/TComWeightPrediction.cpp
--- a/source/Lib/TLibCommon/TComWeightPrediction.cpp	Thu Jul 17 20:54:19 2014 -0500
+++ b/source/Lib/TLibCommon/TComWeightPrediction.cpp	Thu Jul 17 23:48:38 2014 -0500
@@ -499,40 +499,30 @@ void TComWeightPrediction::addWeightUni(
  */
 void TComWeightPrediction::getWpScaling(TComDataCU* cu, int refIdx0, int refIdx1, WeightParam *&wp0, WeightParam *&wp1)
 {
-    TComSlice*      slice = cu->getSlice();
-    const TComPPS*  pps     = cu->getSlice()->m_pps;
-    bool            wpBiPred = pps->bUseWeightedBiPred;
-    WeightParam* pwp;
-    bool            bBiDir   = (refIdx0 >= 0 && refIdx1 >= 0);
-    bool            bUniDir  = !bBiDir;
+    TComSlice* slice = cu->getSlice();
+    bool wpBiPred = slice->m_pps->bUseWeightedBiPred;
+    bool bBiDir  = (refIdx0 >= 0 && refIdx1 >= 0);
+    bool bUniDir = !bBiDir;
 
     if (bUniDir || wpBiPred)
-    { // explicit --------------------
+    {
         if (refIdx0 >= 0)
-        {
-            slice->getWpScaling(REF_PIC_LIST_0, refIdx0, wp0);
-        }
+            wp0 = slice->m_weightPredTable[0][refIdx0];
+
         if (refIdx1 >= 0)
-        {
-            slice->getWpScaling(REF_PIC_LIST_1, refIdx1, wp1);
-        }
+            wp1 = slice->m_weightPredTable[1][refIdx1];
     }
     else
-    {
         X265_CHECK(0, "unexpected wpScaling configuration\n");
-    }
 
     if (refIdx0 < 0)
-    {
         wp0 = NULL;
-    }
+
     if (refIdx1 < 0)
-    {
         wp1 = NULL;
-    }
 
     if (bBiDir)
-    { // Bi-Dir case
+    {
         for (int yuv = 0; yuv < 3; yuv++)
         {
             wp0[yuv].w      = wp0[yuv].inputWeight;
@@ -546,8 +536,8 @@ void TComWeightPrediction::getWpScaling(
         }
     }
     else
-    { // Unidir
-        pwp = (refIdx0 >= 0) ? wp0 : wp1;
+    {
+        WeightParam* pwp = (refIdx0 >= 0) ? wp0 : wp1;
         for (int yuv = 0; yuv < 3; yuv++)
         {
             pwp[yuv].w      = pwp[yuv].inputWeight;
diff -r 93ab6ed75b01 -r 9cbd9fc1710a source/common/piclist.cpp
--- a/source/common/piclist.cpp	Thu Jul 17 20:54:19 2014 -0500
+++ b/source/common/piclist.cpp	Thu Jul 17 23:48:38 2014 -0500
@@ -86,6 +86,14 @@ Frame *PicList::popFront()
         return NULL;
 }
 
+Frame* PicList::getPOC(int poc)
+{
+    Frame *pic = m_start;
+    while (pic && pic->getPOC() != poc)
+        pic = pic->m_next;
+    return pic;
+}
+
 Frame *PicList::popBack()
 {
     if (m_end)
diff -r 93ab6ed75b01 -r 9cbd9fc1710a source/common/piclist.h
--- a/source/common/piclist.h	Thu Jul 17 20:54:19 2014 -0500
+++ b/source/common/piclist.h	Thu Jul 17 23:48:38 2014 -0500
@@ -58,6 +58,9 @@ public:
     /** Pop picture from beginning of the list */
     Frame* popFront();
 
+    /** Find frame with specified POC */
+    Frame* getPOC(int poc);
+
     /** Remove picture from list */
     void remove(Frame& pic);
 
diff -r 93ab6ed75b01 -r 9cbd9fc1710a source/encoder/dpb.cpp
--- a/source/encoder/dpb.cpp	Thu Jul 17 20:54:19 2014 -0500
+++ b/source/encoder/dpb.cpp	Thu Jul 17 23:48:38 2014 -0500
@@ -133,57 +133,25 @@ void DPB::prepareEncode(Frame *pic)
 
     slice->m_numRefIdx[0] = X265_MIN(m_maxRefL0, slice->m_rps.m_numberOfNegativePictures); // Ensuring L0 contains just the -ve POC
     slice->m_numRefIdx[1] = X265_MIN(m_maxRefL1, slice->m_rps.m_numberOfPositivePictures);
-
     slice->setRefPicList(m_picList);
 
-    // Slice type refinement:  TODO: does this ever happen?
-    if ((slice->m_sliceType == B_SLICE) && (slice->m_numRefIdx[1] == 0))
-        slice->m_sliceType = P_SLICE;
+    X265_CHECK(slice->m_sliceType != B_SLICE || slice->m_numRefIdx[1], "B slice without L1 references (non-fatal)\n");
 
     if (slice->m_sliceType == B_SLICE)
     {
-        // TODO: Can we estimate this from lookahead?
-        slice->m_colFromL0Flag = 0;
-
-        bool bLowDelay = true;
-        int curPOC = slice->m_poc;
-        int refIdx = 0;
-
-        for (refIdx = 0; refIdx < slice->m_numRefIdx[0] && bLowDelay; refIdx++)
-            if (slice->m_refPOCList[0][refIdx] > curPOC)
-                bLowDelay = false;
-
-        for (refIdx = 0; refIdx < slice->m_numRefIdx[1] && bLowDelay; refIdx++)
-            if (slice->m_refPOCList[1][refIdx] > curPOC)
-                bLowDelay = false;
-
-        slice->m_bCheckLDC = bLowDelay;
+        /* TODO: the lookahead should be able to tell which reference picture
+         * had the least motion residual.  We should be able to use that here to
+         * select a colocation reference list and index */
+        slice->m_colFromL0Flag = false;
+        slice->m_colRefIdx = 0;
+        slice->m_bCheckLDC = false;


More information about the x265-commits mailing list