[x265] [PATCH 2 of 4] Integration of weighted frames in the encoder

shazeb at multicorewareinc.com shazeb at multicorewareinc.com
Thu Aug 1 14:23:35 CEST 2013


# HG changeset patch
# User Shazeb N Khan
# Date 1375357824 -19800
#      Thu Aug 01 17:20:24 2013 +0530
# Node ID 04d9e878212d42b7a985bb49a54cad259976b2af
# Parent  c48788bcc946082f9bacc731c29085717b969c8b
Integration of weighted frames in the encoder

diff -r c48788bcc946 -r 04d9e878212d source/Lib/TLibCommon/TComSlice.h
--- a/source/Lib/TLibCommon/TComSlice.h	Thu Aug 01 15:53:15 2013 +0530
+++ b/source/Lib/TLibCommon/TComSlice.h	Thu Aug 01 17:20:24 2013 +0530
@@ -1414,7 +1414,6 @@
     UInt        m_sliceSegmentBits;
     Bool        m_bFinalized;
 
-    wpScalingParam  m_weightPredTable[2][MAX_NUM_REF][3]; // [REF_PIC_LIST_0 or REF_PIC_LIST_1][refIdx][0:Y, 1:U, 2:V]
     wpACDCParam     m_weightACDCParam[3];                 // [0:Y, 1:U, 2:V]
 
     std::vector<UInt> m_tileByteLocation;
@@ -1433,6 +1432,7 @@
 public:
 
     x265::MotionReference * m_mref[2][MAX_NUM_REF + 1];
+    wpScalingParam  m_weightPredTable[2][MAX_NUM_REF][3]; // [REF_PIC_LIST_0 or REF_PIC_LIST_1][refIdx][0:Y, 1:U, 2:V]
 
     TComSlice();
     virtual ~TComSlice();
diff -r c48788bcc946 -r 04d9e878212d source/Lib/TLibEncoder/TEncSlice.cpp
--- a/source/Lib/TLibEncoder/TEncSlice.cpp	Thu Aug 01 15:53:15 2013 +0530
+++ b/source/Lib/TLibEncoder/TEncSlice.cpp	Thu Aug 01 17:20:24 2013 +0530
@@ -408,13 +408,28 @@
 
     Int numPredDir = slice->isInterP() ? 1 : 2;
 
-    for (Int refList = 0; refList < numPredDir; refList++)
+    if((slice->getSliceType() == P_SLICE && slice->getPPS()->getUseWP()))
     {
-        RefPicList  picList = (refList ? REF_PIC_LIST_1 : REF_PIC_LIST_0);
-        for (Int refIdxTemp = 0; refIdxTemp < slice->getNumRefIdx(picList); refIdxTemp++)
+        for (Int refList = 0; refList < numPredDir; refList++)
         {
-            // To do: Call the merged IP + weighted frames if weighted prediction enabled
-            slice->m_mref[picList][refIdxTemp] = slice->getRefPic(picList, refIdxTemp)->getPicYuvRec()->generateMotionReference(x265::ThreadPool::getThreadPool(), NULL); 
+            RefPicList  picList = (refList ? REF_PIC_LIST_1 : REF_PIC_LIST_0);
+            for (Int refIdxTemp = 0; refIdxTemp < slice->getNumRefIdx(picList); refIdxTemp++)
+            {
+                //Generate weighted motionreference
+                wpScalingParam *w = &(slice->m_weightPredTable[picList][refIdxTemp][0]);
+                slice->m_mref[picList][refIdxTemp] = slice->getRefPic(picList, refIdxTemp)->getPicYuvRec()->generateMotionReference(x265::ThreadPool::getThreadPool(), w); 
+            }
+        }
+    }
+    else
+    {
+        for (Int refList = 0; refList < numPredDir; refList++)
+        {
+            RefPicList  picList = (refList ? REF_PIC_LIST_1 : REF_PIC_LIST_0);
+            for (Int refIdxTemp = 0; refIdxTemp < slice->getNumRefIdx(picList); refIdxTemp++)
+            {
+               slice->m_mref[picList][refIdxTemp] = slice->getRefPic(picList, refIdxTemp)->getPicYuvRec()->generateMotionReference(x265::ThreadPool::getThreadPool(), NULL); 
+            }
         }
     }
 
diff -r c48788bcc946 -r 04d9e878212d source/encoder/encoder.cpp
--- a/source/encoder/encoder.cpp	Thu Aug 01 15:53:15 2013 +0530
+++ b/source/encoder/encoder.cpp	Thu Aug 01 17:20:24 2013 +0530
@@ -189,7 +189,7 @@
     setQP(param->qp);
 
     //====== Motion search ========
-    if (param->searchMethod != X265_ORIG_SEARCH && (param->bEnableWeightedPred || param->bEnableWeightedBiPred))
+    if (param->searchMethod != X265_ORIG_SEARCH && (param->bEnableWeightedBiPred))
     {
         x265_log(param, X265_LOG_WARNING, "Weighted prediction only supported by HM ME, forcing --me 4\n");
         param->searchMethod = X265_ORIG_SEARCH;
@@ -838,7 +838,6 @@
     return ret;
 }
 
-
 extern "C"
 int x265_encoder_encode(x265_t *encoder, x265_nal_t **pp_nal, int *pi_nal, x265_picture_t *pic_in, x265_picture_t **pic_out)
 {
@@ -915,6 +914,7 @@
 void x265_encoder_close(x265_t *encoder, double *outPsnr)
 {
     Double globalPsnr = encoder->printSummary();
+
     if (outPsnr)
         *outPsnr = globalPsnr;
 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: x265-2.patch
Type: text/x-patch
Size: 4042 bytes
Desc: not available
URL: <http://mailman.videolan.org/private/x265-devel/attachments/20130801/15ffe9c8/attachment.bin>


More information about the x265-devel mailing list