[x265] [PATCH] Lookahead : Allocated memory and Initialized the Default cost

gopu at multicorewareinc.com gopu at multicorewareinc.com
Fri Aug 2 13:03:05 CEST 2013


# HG changeset patch
# User ggopu
# Date 1375441374 -19800
# Node ID 765c02fcaee642e6283e434e7cf341a43bd59559
# Parent  de3e6c30815ccc11ed6a33835f7d0c0d13e07f8c
Lookahead : Allocated memory and Initialized the Default cost

diff -r de3e6c30815c -r 765c02fcaee6 source/Lib/TLibCommon/TComPic.cpp
--- a/source/Lib/TLibCommon/TComPic.cpp	Fri Aug 02 12:36:59 2013 +0530
+++ b/source/Lib/TLibCommon/TComPic.cpp	Fri Aug 02 16:32:54 2013 +0530
@@ -37,7 +37,9 @@
 
 #include "TComPic.h"
 #include "SEI.h"
+#include "mv.h"
 
+using namespace x265;
 //! \ingroup TLibCommon
 //! \{
 
@@ -57,8 +59,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_lookahead.bframes = bframes;
     m_picSym = new TComPicSym;
     m_picSym->create(width, height, maxWidth, maxHeight, maxDepth);
 
@@ -95,6 +98,25 @@
     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 < m_lookahead.bframes + 2; i++ )
+    {
+        for( int j = 0; j < m_lookahead.bframes + 2; j++ )
+        {
+            m_lowres.rowSatds[i][j] = (int *)X265_MALLOC(int, (m_origPicYuv->m_cuWidth * 16) );
+            m_lowres.lowresMvs[i][j] = (MV *) X265_MALLOC (MV, 2 * m_origPicYuv->m_cuWidth);
+        }
+    }
+
+    memset( m_lowres.costEst, -1, sizeof(m_lowres.costEst) );   
+    for( int y = 0; y < m_lookahead.bframes + 2; y++ )
+    {
+        for( int x = 0; x < m_lookahead.bframes + 2; x++ )
+        {
+            m_lowres.rowSatds[y][x][0] = -1;
+            m_lowres.lowresMvs[y][x][0] = 0x7FFF;
+        }
+    }
 }
 
 Void TComPic::destroy()
@@ -125,6 +147,18 @@
          if (m_lowres.buffer[i])
              X265_FREE(m_lowres.buffer[i]);
     }
+
+    for( int i = 0; i < m_lookahead.bframes + 2; i++ )
+    {
+        for( int j = 0; j < m_lookahead.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 de3e6c30815c -r 765c02fcaee6 source/Lib/TLibCommon/TComPic.h
--- a/source/Lib/TLibCommon/TComPic.h	Fri Aug 02 12:36:59 2013 +0530
+++ b/source/Lib/TLibCommon/TComPic.h	Fri Aug 02 16:32:54 2013 +0530
@@ -70,11 +70,12 @@
 public:
 
     x265::LookaheadFrame  m_lowres;
+    x265::Lookahead m_lookahead;
 
     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 de3e6c30815c -r 765c02fcaee6 source/Lib/TLibCommon/TComPicYuv.h
--- a/source/Lib/TLibCommon/TComPicYuv.h	Fri Aug 02 12:36:59 2013 +0530
+++ b/source/Lib/TLibCommon/TComPicYuv.h	Fri Aug 02 16:32:54 2013 +0530
@@ -81,8 +81,6 @@
     Int   m_picWidth;          ///< Width of picture
     Int   m_picHeight;         ///< Height of picture
 
-    Int   m_cuWidth;           ///< Width of Coding Unit (CU)
-    Int   m_cuHeight;          ///< Height of Coding Unit (CU)
     Int*  m_cuOffsetY;
     Int*  m_cuOffsetC;
     Int*  m_buOffsetY;
@@ -99,6 +97,9 @@
 
 public:
 
+    Int   m_cuWidth;           ///< Width of Coding Unit (CU)
+    Int   m_cuHeight;          ///< Height of Coding Unit (CU)
+
     TComPicYuv();
     virtual ~TComPicYuv();
 
diff -r de3e6c30815c -r 765c02fcaee6 source/Lib/TLibEncoder/TEncTop.cpp
--- a/source/Lib/TLibEncoder/TEncTop.cpp	Fri Aug 02 12:36:59 2013 +0530
+++ b/source/Lib/TLibEncoder/TEncTop.cpp	Fri Aug 02 16:32:54 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 (getUseSAO())
         {
             // TODO: we shouldn't need a frame encoder to do this


More information about the x265-devel mailing list