[x265] [PATCH] weightp: add unweighted duplicate of first weighted L0 reference;

kavitha at multicorewareinc.com kavitha at multicorewareinc.com
Tue Mar 18 19:09:42 CET 2014


# HG changeset patch
# User Kavitha Sampath <kavitha at multicorewareinc.com>
# Date 1395166152 -19800
#      Tue Mar 18 23:39:12 2014 +0530
# Node ID 41d2f204ad3392d536462084586b80fce6ef3904
# Parent  dc700298419d382e58c49d4ea62a3d7398b4beaf
weightp: add unweighted duplicate of first weighted L0 reference;
do not add duplicate if frame has only one reference

diff -r dc700298419d -r 41d2f204ad33 source/encoder/frameencoder.cpp
--- a/source/encoder/frameencoder.cpp	Tue Mar 18 08:46:15 2014 -0500
+++ b/source/encoder/frameencoder.cpp	Tue Mar 18 23:39:12 2014 +0530
@@ -453,6 +453,37 @@
         }
     }
 
+    // Add an unweighted duplicate of first L0 weighted reference
+    // Do not add duplicate when the frame has only one L0 reference as the encoder signals failure
+    // while encountering consecutive references with same POC
+    if (bUseWeightP && slice->m_weightPredTable[0][0][0].bPresentFlag && slice->getNumRefIdx(0) > 1)
+    {
+        int numref = slice->getNumRefIdx(0);
+        TComPic *dup = slice->getRefPic(0, 0);
+        slice->setRefPic(dup, 0, numref);
+        slice->setRefPOC(slice->getRefPOC(0, 0), 0, numref);
+
+        // update RPS
+        TComReferencePictureSet *rps = slice->getLocalRPS();
+        rps->m_numberOfPictures++;
+        rps->m_numberOfNegativePictures++;
+        rps->m_deltaPOC[numref + 1] = rps->m_deltaPOC[numref];
+        rps->m_used[numref + 1] = rps->m_used[numref];
+        rps->m_POC[numref + 1] = rps->m_POC[numref];
+
+        // copy first reference data to the duplicate reference in RPS
+        rps->m_deltaPOC[numref] = rps->m_deltaPOC[0];
+        rps->m_used[numref] = rps->m_used[0];
+        rps->m_POC[numref] = rps->m_POC[0];
+
+        wpScalingParam *wp = slice->m_weightPredTable[0][numref];
+        SET_WEIGHT(wp[0], false, 1, 0, 0);
+        SET_WEIGHT(wp[1], false, 1, 0, 0);
+        SET_WEIGHT(wp[2], false, 1, 0, 0);
+        m_mref[0][numref].init(slice->getRefPic(0, 0)->getPicYuvRec(), NULL);
+        slice->setNumRefIdx(0, ++numref);
+    }
+
     // Analyze CTU rows, most of the hard work is done here
     // frame is compressed in a wave-front pattern if WPP is enabled. Loop filter runs as a
     // wave-front behind the CU compression and reconstruction


More information about the x265-devel mailing list