[x265] [PATCH] lookahead: lookahead output cost allocations and initialization

gopu at multicorewareinc.com gopu at multicorewareinc.com
Mon Aug 5 12:24:21 CEST 2013


# HG changeset patch
# User ggopu
# Date 1375698246 -19800
# Node ID c8bc62894e13875a7d9e41be71fd99d3c67ed03a
# Parent  48c6641e19de62b2640ef7d149435fba362d7d81
lookahead: lookahead output cost allocations and initialization

diff -r 48c6641e19de -r c8bc62894e13 source/Lib/TLibCommon/TComPic.cpp
--- a/source/Lib/TLibCommon/TComPic.cpp	Mon Aug 05 11:47:58 2013 +0530
+++ b/source/Lib/TLibCommon/TComPic.cpp	Mon Aug 05 15:54:06 2013 +0530
@@ -37,6 +37,9 @@
 
 #include "TComPic.h"
 #include "SEI.h"
+#include "mv.h"
+
+using namespace x265;
 
 //! \ingroup TLibCommon
 //! \{
@@ -57,8 +60,9 @@
 TComPic::~TComPic()
 {}
 
-Void TComPic::create(Int width, Int height, UInt maxWidth, UInt maxHeight, UInt maxDepth, Window &conformanceWindow, Window &defaultDisplayWindow)
+Void TComPic::create(Int width, Int height, UInt maxWidth, UInt maxHeight, UInt maxDepth, Window &conformanceWindow, Window &defaultDisplayWindow, Int bframes)
 {
+    m_bframes = bframes;
     m_picSym = new TComPicSym;
     m_picSym->create(width, height, maxWidth, maxHeight, maxDepth);
 
@@ -95,6 +99,27 @@
     m_lowres.m_lumaPlane[2][1] = m_lowres.m_lumaPlane[3][0] = m_lowres.m_lumaPlane[3][1] = m_lowres.m_lumaPlane[2][0];
     m_lowres.m_lumaPlane[0][3] = m_lowres.m_lumaPlane[1][2] = m_lowres.m_lumaPlane[1][3] = m_lowres.m_lumaPlane[0][2];
     m_lowres.m_lumaPlane[2][3] = m_lowres.m_lumaPlane[3][2] = m_lowres.m_lumaPlane[3][3] = m_lowres.m_lumaPlane[2][2];
+
+    for( int i = 0; i < bframes + 2; i++ )
+    {
+        for( int j = 0; j < bframes + 2; j++ )
+        {   
+            /* number of CU rows in frame */ 
+            m_lowres.rowSatds[i][j] = (int *)X265_MALLOC(int, m_picSym->getFrameHeightInCU());
+            /* number of CUs in frame */
+            m_lowres.lowresMvs[i][j] = (MV *) X265_MALLOC (MV, m_picSym->getNumberOfCUsInFrame());
+        }
+    }
+
+    memset( m_lowres.costEst, -1, sizeof(m_lowres.costEst) );   
+    for( int y = 0; y < bframes + 2; y++ )
+    {
+        for( int x = 0; x < bframes + 2; x++ )
+        {
+            m_lowres.rowSatds[y][x][0] = -1;
+            m_lowres.lowresMvs[y][x][0] = 0x7FFF;
+        }
+    }
 }
 
 Void TComPic::destroy()
@@ -125,6 +150,18 @@
          if (m_lowres.buffer[i])
              X265_FREE(m_lowres.buffer[i]);
     }
+
+    for( int i = 0; i < m_bframes + 2; i++ )
+    {
+        for( int j = 0; j < m_bframes + 2; j++ )
+        {
+            if(m_lowres.rowSatds[i][j])
+                X265_FREE(m_lowres.rowSatds[i][j]);
+
+            if(m_lowres.lowresMvs[i][j])
+                X265_FREE(m_lowres.lowresMvs[i][j]);
+        }
+    }
 }
 
 Void TComPic::compressMotion()
diff -r 48c6641e19de -r c8bc62894e13 source/Lib/TLibCommon/TComPic.h
--- a/source/Lib/TLibCommon/TComPic.h	Mon Aug 05 11:47:58 2013 +0530
+++ b/source/Lib/TLibCommon/TComPic.h	Mon Aug 05 15:54:06 2013 +0530
@@ -66,6 +66,7 @@
     Bool                  m_bUsedByCurr;          // Used by current picture
     Bool                  m_bIsLongTerm;          // IS long term picture
     Bool                  m_bCheckLTMSB;
+    Int                   m_bframes;              // number of bframes used to destroy the lookahead costs 
 
 public:
 
@@ -74,7 +75,7 @@
     TComPic();
     virtual ~TComPic();
 
-    Void          create(Int width, Int height, UInt maxWidth, UInt maxHeight, UInt maxDepth, Window &conformanceWindow, Window &defaultDisplayWindow);
+    Void          create(Int width, Int height, UInt maxWidth, UInt maxHeight, UInt maxDepth, Window &conformanceWindow, Window &defaultDisplayWindow, Int bframes);
 
     virtual Void  destroy();
 
diff -r 48c6641e19de -r c8bc62894e13 source/Lib/TLibEncoder/TEncTop.cpp
--- a/source/Lib/TLibEncoder/TEncTop.cpp	Mon Aug 05 11:47:58 2013 +0530
+++ b/source/Lib/TLibEncoder/TEncTop.cpp	Mon Aug 05 15:54:06 2013 +0530
@@ -132,7 +132,7 @@
     {
         TComPic *pic = new TComPic;
         pic->create(param.sourceWidth, param.sourceHeight, g_maxCUWidth, g_maxCUHeight, g_maxCUDepth,
-                    getConformanceWindow(), getDefaultDisplayWindow());
+                    getConformanceWindow(), getDefaultDisplayWindow(), param.bframes);
         if (param.bEnableSAO)
         {
             // TODO: we shouldn't need a frame encoder to do this


More information about the x265-devel mailing list