Ticket #66: tracemem.patch
File tracemem.patch, 120.9 KB (added by li@…, 14 years ago) |
---|
-
build/linux/lib/TLibCommon/makefile
54 54 $(OBJ_DIR)/TComSlice.o \ 55 55 $(OBJ_DIR)/TComTrQuant.o \ 56 56 $(OBJ_DIR)/TComYuv.o \ 57 $(OBJ_DIR)/tool_tracemem.o \ 57 58 58 59 LIBS = -lpthread 59 60 -
build/vc8/TLibCommon_vc8.vcproj
363 363 RelativePath="..\..\source\Lib\TLibCommon\TComYuv.cpp" 364 364 > 365 365 </File> 366 <File 367 RelativePath="..\..\source\Lib\TLibCommon\tool_tracemem.cpp" 368 > 369 </File> 366 370 </Filter> 367 371 <Filter 368 372 Name="Header Files" … … 478 482 > 479 483 </File> 480 484 <File 485 RelativePath="..\..\source\Lib\TLibCommon\tool_tracemem.h" 486 > 487 </File> 488 <File 481 489 RelativePath="..\..\source\Lib\TLibCommon\TypeDef.h" 482 490 > 483 491 </File> -
build/vc9/TLibCommon_vc9.vcproj
366 366 RelativePath="..\..\source\Lib\TLibCommon\TComYuv.cpp" 367 367 > 368 368 </File> 369 <File 370 RelativePath="..\..\source\Lib\TLibCommon\tool_tracemem.cpp" 371 > 372 </File> 369 373 </Filter> 370 374 <Filter 371 375 Name="Header Files" … … 481 485 > 482 486 </File> 483 487 <File 488 RelativePath="..\..\source\Lib\TLibCommon\tool_tracemem.h" 489 > 490 </File> 491 <File 484 492 RelativePath="..\..\source\Lib\TLibCommon\TypeDef.h" 485 493 > 486 494 </File> -
source/App/TAppCommon/program_options_lite.cpp
15 15 Options::~Options() 16 16 { 17 17 for(Options::NamesPtrList::iterator it = opt_list.begin(); it != opt_list.end(); it++) { 18 delete *it;18 MEMDELETE( *it ); 19 19 } 20 20 } 21 21 22 22 void Options::addOption(OptionBase *opt) 23 23 { 24 Names* names = newNames();24 Names* names = MEMNEW Names(); 25 25 names->opt = opt; 26 26 string& opt_string = opt->opt_string; 27 27 -
source/App/TAppCommon/program_options_lite.h
4 4 #include <list> 5 5 #include <map> 6 6 7 #include "../../Lib/TLibCommon/tool_tracemem.h" 8 7 9 namespace df { 8 10 namespace program_options_lite { 9 11 … … 100 102 Names() : opt(0) {}; 101 103 ~Names() { 102 104 if (opt) 103 delete opt;105 MEMDELETE( opt ); 104 106 } 105 107 std::list<std::string> opt_long; 106 108 std::list<std::string> opt_short; … … 132 134 template<typename T> 133 135 OptionSpecific& 134 136 operator()(const std::string& name, T& storage, T default_val, const std::string& desc = "") { 135 parent.addOption( newOption<T>(name, storage, default_val, desc));137 parent.addOption(MEMNEW Option<T>(name, storage, default_val, desc)); 136 138 return *this; 137 139 } 138 140 … … 145 147 */ 146 148 OptionSpecific& 147 149 operator()(const std::string& name, OptionFunc::Func *func, const std::string& desc = "") { 148 parent.addOption( newOptionFunc(name, parent, func, desc));150 parent.addOption(MEMNEW OptionFunc(name, parent, func, desc)); 149 151 return *this; 150 152 } 151 153 private: -
source/App/TAppDecoder/decmain.cpp
37 37 #include <time.h> 38 38 #include "TAppDecTop.h" 39 39 40 #include <cassert> 41 #include "../../Lib/TLibCommon/tool_tracemem.h" 42 40 43 // ==================================================================================================================== 41 44 // Main function 42 45 // ==================================================================================================================== 43 46 44 47 int main(int argc, char* argv[]) 45 48 { 46 TAppDecTop cTAppDecTop; 49 TAppDecTop * pTAppDecTop = MEMNEW TAppDecTop; 50 assert( pTAppDecTop != NULL ); 47 51 48 52 // print information 49 53 fprintf( stdout, "\n" ); … … 54 58 fprintf( stdout, "\n" ); 55 59 56 60 // create application decoder class 57 cTAppDecTop.create();61 pTAppDecTop->create(); 58 62 59 63 // parse configuration 60 if(! cTAppDecTop.parseCfg( argc, argv ))64 if(!pTAppDecTop->parseCfg( argc, argv )) 61 65 { 62 cTAppDecTop.destroy();66 pTAppDecTop->destroy(); 63 67 return 1; 64 68 } 65 69 … … 68 72 long lBefore = clock(); 69 73 70 74 // call decoding function 71 cTAppDecTop.decode();75 pTAppDecTop->decode(); 72 76 73 77 // ending time 74 78 dResult = (double)(clock()-lBefore) / CLOCKS_PER_SEC; 75 79 printf("\n Total Time: %12.3f sec.\n", dResult); 76 80 77 81 // destroy application decoder class 78 cTAppDecTop.destroy(); 82 pTAppDecTop->destroy(); 83 MEMDELETE( pTAppDecTop ); 84 pTAppDecTop = NULL; 79 85 86 // memory log 87 MEMTRACEINFO( stdout ); 88 80 89 return 0; 81 90 } 82 91 -
source/App/TAppDecoder/TAppDecCfg.cpp
35 35 36 36 #include "TAppDecCfg.h" 37 37 38 #include "../../Lib/TLibCommon/tool_tracemem.h" 39 38 40 // ==================================================================================================================== 39 41 // Public member functions 40 42 // ==================================================================================================================== … … 62 64 if( ! m_apcOpt->hasOptions() || !m_apcOpt->getValue( 'b' ) ) 63 65 { 64 66 m_apcOpt->printUsage(); 65 delete m_apcOpt;67 MEMDELETE( m_apcOpt ); 66 68 m_apcOpt = NULL; 67 69 return false; 68 70 } -
source/App/TAppDecoder/TAppDecOption.cpp
66 66 #include <cstring> 67 67 #include "TAppDecOption.h" 68 68 69 #include "../../Lib/TLibCommon/tool_tracemem.h" 70 69 71 TAppOption::TAppOption() 70 72 { 71 73 init(); … … 961 963 length = int( is.tellg() ); 962 964 is.seekg (0, ios::beg); 963 965 // buffer = (char*) malloc(length*sizeof(char)); 964 buffer = newchar[length]; //kolya966 buffer = MEMNEWARRAY char[length]; //kolya 965 967 is.read (buffer, length); 966 968 is.close(); 967 969 return buffer; … … 1001 1003 cursor++; /* keep moving */ 1002 1004 linelength++; 1003 1005 } 1004 delete [] buffer; //kolya1006 MEMDELETEARRAY( buffer ); //kolya 1005 1007 buffer = NULL; 1006 1008 return true; 1007 1009 } … … 1031 1033 TAppOption::processLine( char *theline, int length ) 1032 1034 { 1033 1035 bool found = false; 1034 char *pline = newchar[length+1];1036 char *pline = MEMNEWARRAY char[length+1]; 1035 1037 for( int i = 0 ; i < length ; i ++ ) 1036 1038 pline[i]= *(theline++); 1037 1039 pline[length] = nullterminate; … … 1055 1057 if( !found ) /* not a pair */ 1056 1058 justValue( pline ); 1057 1059 } 1058 delete [] pline;1060 MEMDELETEARRAY( pline ); 1059 1061 pline = NULL; 1060 1062 } 1061 1063 -
source/App/TAppDecoder/TAppDecTop.cpp
61 61 62 62 Void TAppDecTop::create() 63 63 { 64 m_apcOpt = newTAppOption();65 m_apcBitstream = newTComBitstream;64 m_apcOpt = MEMNEW TAppOption(); 65 m_apcBitstream = MEMNEW TComBitstream; 66 66 67 67 m_apcBitstream->create( BITS_BUF_SIZE ); 68 68 } … … 71 71 { 72 72 if ( m_apcOpt ) 73 73 { 74 delete m_apcOpt;74 MEMDELETE( m_apcOpt ); 75 75 m_apcOpt = NULL; 76 76 } 77 77 if ( m_apcBitstream ) 78 78 { 79 79 m_apcBitstream->destroy(); 80 delete m_apcBitstream;80 MEMDELETE( m_apcBitstream ); 81 81 m_apcBitstream = NULL; 82 82 } 83 83 } -
source/App/TAppEncoder/encmain.cpp
36 36 #include <time.h> 37 37 #include "TAppEncTop.h" 38 38 39 #include <cassert> 40 #include "../../Lib/TLibCommon/tool_tracemem.h" 41 39 42 // ==================================================================================================================== 40 43 // Main function 41 44 // ==================================================================================================================== 42 45 43 46 int main(int argc, char* argv[]) 44 47 { 45 TAppEncTop cTAppEncTop; 48 TAppEncTop * pTAppEncTop = MEMNEW TAppEncTop; 49 assert( pTAppEncTop != NULL ); 46 50 47 51 // print information 48 52 fprintf( stdout, "\n" ); … … 53 57 fprintf( stdout, "\n" ); 54 58 55 59 // create application encoder class 56 cTAppEncTop.create();60 pTAppEncTop->create(); 57 61 58 62 // parse configuration 59 if(! cTAppEncTop.parseCfg( argc, argv ))63 if(!pTAppEncTop->parseCfg( argc, argv )) 60 64 { 61 cTAppEncTop.destroy();65 pTAppEncTop->destroy(); 62 66 return 1; 63 67 } 64 68 … … 67 71 long lBefore = clock(); 68 72 69 73 // call encoding function 70 cTAppEncTop.encode();74 pTAppEncTop->encode(); 71 75 72 76 // ending time 73 77 dResult = (double)(clock()-lBefore) / CLOCKS_PER_SEC; 74 78 printf("\n Total Time: %12.3f sec.\n", dResult); 75 79 76 80 // destroy application encoder class 77 cTAppEncTop.destroy(); 81 pTAppEncTop->destroy(); 82 MEMDELETE( pTAppEncTop ); 83 pTAppEncTop = NULL; 78 84 85 // memory log 86 MEMTRACEINFO( stdout ); 87 79 88 return 0; 80 89 } 81 90 -
source/App/TAppEncoder/TAppEncCfg.cpp
40 40 #include "TAppEncCfg.h" 41 41 #include "../../App/TAppCommon/program_options_lite.h" 42 42 43 #include "../../Lib/TLibCommon/tool_tracemem.h" 44 43 45 #ifdef WIN32 44 46 #define strdup _strdup 45 47 #endif … … 75 77 { 76 78 if ( m_aidQP ) 77 79 { 78 delete[] m_aidQP;80 MEMDELETEARRAY( m_aidQP ); 79 81 } 80 82 } 81 83 … … 289 291 m_iSourceHeight += m_aiPad[1]; 290 292 291 293 // allocate slice-based dQP values 292 m_aidQP = newInt[ m_iFrameToBeEncoded + m_iRateGOPSize + 1 ];294 m_aidQP = MEMNEWARRAY Int[ m_iFrameToBeEncoded + m_iRateGOPSize + 1 ]; 293 295 ::memset( m_aidQP, 0, sizeof(Int)*( m_iFrameToBeEncoded + m_iRateGOPSize + 1 ) ); 294 296 295 297 // handling of floating-point QP values -
source/App/TAppEncoder/TAppEncTop.cpp
199 199 */ 200 200 Void TAppEncTop::encode() 201 201 { 202 TComPicYuv* pcPicYuvOrg = newTComPicYuv;202 TComPicYuv* pcPicYuvOrg = MEMNEW TComPicYuv; 203 203 TComPicYuv* pcPicYuvRec = NULL; 204 204 TComBitstream* pcBitstream = NULL; 205 205 … … 242 242 243 243 // delete original YUV buffer 244 244 pcPicYuvOrg->destroy(); 245 delete pcPicYuvOrg;245 MEMDELETE( pcPicYuvOrg ); 246 246 pcPicYuvOrg = NULL; 247 247 248 248 // delete used buffers in encoder class … … 271 271 { 272 272 if (m_cListPicYuvRec.size() == 0) 273 273 { 274 rpcPicYuvRec = newTComPicYuv;275 rpcBitStream = newTComBitstream;274 rpcPicYuvRec = MEMNEW TComPicYuv; 275 rpcBitStream = MEMNEW TComBitstream; 276 276 277 277 rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); 278 278 rpcBitStream->create( (m_iSourceWidth * m_iSourceHeight * 3) >> 1 ); … … 300 300 } 301 301 else 302 302 { 303 rpcPicYuvRec = newTComPicYuv;304 rpcBitStream = newTComBitstream;303 rpcPicYuvRec = MEMNEW TComPicYuv; 304 rpcBitStream = MEMNEW TComBitstream; 305 305 306 306 rpcPicYuvRec->create( m_iSourceWidth, m_iSourceHeight, m_uiMaxCUWidth, m_uiMaxCUHeight, m_uiMaxCUDepth ); 307 307 rpcBitStream->create( (m_iSourceWidth * m_iSourceHeight * 3) >> 1 ); … … 325 325 pcPicYuvRec->destroy(); 326 326 pcBitstream->destroy(); 327 327 328 delete pcPicYuvRec; pcPicYuvRec = NULL;329 delete pcBitstream; pcBitstream = NULL;328 MEMDELETE( pcPicYuvRec ); pcPicYuvRec = NULL; 329 MEMDELETE( pcBitstream ); pcBitstream = NULL; 330 330 } 331 331 332 332 } -
source/Lib/TLibCommon/CommonDef.h
122 122 #define ClipMax(x) ( Min(g_uiBASE_MAX, x ) ) ///< clip with max. value 123 123 #define Clip3( MinVal, MaxVal, a) ( ((a)<(MinVal)) ? (MinVal) : (((a)>(MaxVal)) ? (MaxVal) :(a)) ) ///< general min/max clip 124 124 125 #ifdef CTRL_USE_TRACEMEM 126 #define xMalloc( type, len ) MEMNEWARRAY type[len] 127 #define xFree( ptr ) MEMDELETEARRAY( ptr ) 128 #define calloc( num , size ) MEMNEW char[num*size] 129 #define free( ptr ) MEMDELETE( ptr ) 130 #else 125 131 #define DATA_ALIGN 1 ///< use 32-bit aligned malloc/free 126 132 #if DATA_ALIGN && _WIN32 && ( _MSC_VER > 1300 ) 127 133 #define xMalloc( type, len ) _aligned_malloc( sizeof(type)*(len), 32 ) … … 130 136 #define xMalloc( type, len ) malloc ( sizeof(type)*(len) ) 131 137 #define xFree( ptr ) free ( ptr ) 132 138 #endif 139 #endif 133 140 134 141 // ==================================================================================================================== 135 142 // Bug fixes -
source/Lib/TLibCommon/ContextModel3DBuffer.cpp
35 35 36 36 #include "ContextModel3DBuffer.h" 37 37 38 #include "tool_tracemem.h" 39 38 40 // ==================================================================================================================== 39 41 // Constructor / destructor / initialization / destroy 40 42 // ==================================================================================================================== … … 47 49 48 50 { 49 51 // allocate 3D buffer 50 m_pcContextModel = newContextModel[ uiSizeZ * m_uiSizeY * m_uiSizeX ];52 m_pcContextModel = MEMNEWARRAY ContextModel[ uiSizeZ * m_uiSizeY * m_uiSizeX ]; 51 53 } 52 54 53 55 ContextModel3DBuffer::~ContextModel3DBuffer() 54 56 { 55 57 // delete 3D buffer 56 delete [] m_pcContextModel;58 MEMDELETEARRAY( m_pcContextModel ); 57 59 m_pcContextModel = NULL; 58 60 } 59 61 -
source/Lib/TLibCommon/TComAdaptiveLoopFilter.cpp
39 39 #include <stdio.h> 40 40 #include <math.h> 41 41 42 #include "tool_tracemem.h" 43 42 44 #if HHI_ALF 43 45 // ==================================================================================================================== 44 46 // Constructor / destructor / create / destroy … … 53 55 { 54 56 if ( !m_pcTempPicYuv ) 55 57 { 56 m_pcTempPicYuv = newTComPicYuv;58 m_pcTempPicYuv = MEMNEW TComPicYuv; 57 59 m_pcTempPicYuv->create( iPicWidth, iPicHeight, uiMaxCUWidth, uiMaxCUHeight, uiMaxCUDepth ); 58 60 } 59 61 } … … 63 65 if ( m_pcTempPicYuv ) 64 66 { 65 67 m_pcTempPicYuv->destroy(); 66 delete m_pcTempPicYuv;68 MEMDELETE( m_pcTempPicYuv ); 67 69 } 68 70 } 69 71 … … 81 83 pAlfParam->pcQuadTree = NULL; 82 84 pAlfParam->bSeparateQt = false; 83 85 84 pAlfParam->acHorizontalAlfFilter = newAlfFilter[ ALF_FILT_FOR_CHROMA +1 ];85 pAlfParam->acVerticalAlfFilter = newAlfFilter[ ALF_FILT_FOR_CHROMA +1 ];86 pAlfParam->acHorizontalAlfFilter = MEMNEWARRAY AlfFilter[ ALF_FILT_FOR_CHROMA +1 ]; 87 pAlfParam->acVerticalAlfFilter = MEMNEWARRAY AlfFilter[ ALF_FILT_FOR_CHROMA +1 ]; 86 88 87 89 ::memset(pAlfParam->acHorizontalAlfFilter, 0, sizeof(AlfFilter)*( ALF_FILT_FOR_CHROMA +1 ) ); 88 90 ::memset(pAlfParam->acVerticalAlfFilter , 0, sizeof(AlfFilter)*( ALF_FILT_FOR_CHROMA +1 ) ); … … 90 92 91 93 pAlfParam->acHorizontalAlfFilter[ 0 ].bIsHorizontal = true; 92 94 pAlfParam->acHorizontalAlfFilter[ 0 ].bIsVertical = false; 93 pAlfParam->acHorizontalAlfFilter[ 0 ].aiQuantFilterCoeffs = newInt[ALF_MAX_NUM_COEF];94 pAlfParam->acHorizontalAlfFilter[ 0 ].aiTapCoeffMapping = newInt[ALF_MAX_NUM_COEF];95 pAlfParam->acHorizontalAlfFilter[ 0 ].aiCoeffWeights = newInt[ALF_MAX_NUM_COEF];95 pAlfParam->acHorizontalAlfFilter[ 0 ].aiQuantFilterCoeffs = MEMNEWARRAY Int[ALF_MAX_NUM_COEF]; 96 pAlfParam->acHorizontalAlfFilter[ 0 ].aiTapCoeffMapping = MEMNEWARRAY Int[ALF_MAX_NUM_COEF]; 97 pAlfParam->acHorizontalAlfFilter[ 0 ].aiCoeffWeights = MEMNEWARRAY Int[ALF_MAX_NUM_COEF]; 96 98 pAlfParam->acVerticalAlfFilter [ 0 ].bIsHorizontal = false; 97 99 pAlfParam->acVerticalAlfFilter [ 0 ].bIsVertical = true; 98 pAlfParam->acVerticalAlfFilter [ 0 ].aiQuantFilterCoeffs = newInt[ALF_MAX_NUM_COEF];99 pAlfParam->acVerticalAlfFilter [ 0 ].aiTapCoeffMapping = newInt[ALF_MAX_NUM_COEF];100 pAlfParam->acVerticalAlfFilter [ 0 ].aiCoeffWeights = newInt[ALF_MAX_NUM_COEF];100 pAlfParam->acVerticalAlfFilter [ 0 ].aiQuantFilterCoeffs = MEMNEWARRAY Int[ALF_MAX_NUM_COEF]; 101 pAlfParam->acVerticalAlfFilter [ 0 ].aiTapCoeffMapping = MEMNEWARRAY Int[ALF_MAX_NUM_COEF]; 102 pAlfParam->acVerticalAlfFilter [ 0 ].aiCoeffWeights = MEMNEWARRAY Int[ALF_MAX_NUM_COEF]; 101 103 ::memset( pAlfParam->acHorizontalAlfFilter[ 0 ].aiQuantFilterCoeffs , 0 , sizeof(Int) * ALF_MAX_NUM_COEF ); 102 104 ::memset( pAlfParam->acHorizontalAlfFilter[ 0 ].aiTapCoeffMapping , 0 , sizeof(Int) * ALF_MAX_NUM_COEF ); 103 105 ::memset( pAlfParam->acHorizontalAlfFilter[ 0 ].aiCoeffWeights , 0 , sizeof(Int) * ALF_MAX_NUM_COEF ); … … 109 111 { 110 112 pAlfParam->acHorizontalAlfFilter[ uiIndx ].bIsHorizontal = true; 111 113 pAlfParam->acHorizontalAlfFilter[ uiIndx ].bIsVertical = false; 112 pAlfParam->acHorizontalAlfFilter[ uiIndx ].aiQuantFilterCoeffs = newInt[ALF_MAX_NUM_COEF];114 pAlfParam->acHorizontalAlfFilter[ uiIndx ].aiQuantFilterCoeffs = MEMNEWARRAY Int[ALF_MAX_NUM_COEF]; 113 115 pAlfParam->acVerticalAlfFilter [ uiIndx ].bIsHorizontal = false; 114 116 pAlfParam->acVerticalAlfFilter [ uiIndx ].bIsVertical = true; 115 pAlfParam->acVerticalAlfFilter [ uiIndx ].aiQuantFilterCoeffs = newInt[ALF_MAX_NUM_COEF];116 pAlfParam->acVerticalAlfFilter [ uiIndx ].aiTapCoeffMapping = newInt[ALF_MAX_NUM_COEF];117 pAlfParam->acVerticalAlfFilter [ uiIndx ].aiCoeffWeights = newInt[ALF_MAX_NUM_COEF];118 pAlfParam->acHorizontalAlfFilter[ uiIndx ].aiTapCoeffMapping = newInt[ALF_MAX_NUM_COEF];119 pAlfParam->acHorizontalAlfFilter[ uiIndx ].aiCoeffWeights = newInt[ALF_MAX_NUM_COEF];117 pAlfParam->acVerticalAlfFilter [ uiIndx ].aiQuantFilterCoeffs = MEMNEWARRAY Int[ALF_MAX_NUM_COEF]; 118 pAlfParam->acVerticalAlfFilter [ uiIndx ].aiTapCoeffMapping = MEMNEWARRAY Int[ALF_MAX_NUM_COEF]; 119 pAlfParam->acVerticalAlfFilter [ uiIndx ].aiCoeffWeights = MEMNEWARRAY Int[ALF_MAX_NUM_COEF]; 120 pAlfParam->acHorizontalAlfFilter[ uiIndx ].aiTapCoeffMapping = MEMNEWARRAY Int[ALF_MAX_NUM_COEF]; 121 pAlfParam->acHorizontalAlfFilter[ uiIndx ].aiCoeffWeights = MEMNEWARRAY Int[ALF_MAX_NUM_COEF]; 120 122 ::memset( pAlfParam->acHorizontalAlfFilter[ uiIndx ].aiQuantFilterCoeffs , 0 , sizeof(Int) * ALF_MAX_NUM_COEF ); 121 123 ::memset( pAlfParam->acVerticalAlfFilter [ uiIndx ].aiQuantFilterCoeffs , 0 , sizeof(Int) * ALF_MAX_NUM_COEF ); 122 124 ::memset( pAlfParam->acHorizontalAlfFilter[ uiIndx ].aiTapCoeffMapping , 0 , sizeof(Int) * ALF_MAX_NUM_COEF ); … … 138 140 { 139 141 if( pAlfParam->acHorizontalAlfFilter[ uiIndx ].aiQuantFilterCoeffs != NULL ) 140 142 { 141 delete[] pAlfParam->acHorizontalAlfFilter[ uiIndx ].aiQuantFilterCoeffs;143 MEMDELETEARRAY( pAlfParam->acHorizontalAlfFilter[ uiIndx ].aiQuantFilterCoeffs ); 142 144 pAlfParam->acHorizontalAlfFilter[ uiIndx ].aiQuantFilterCoeffs = NULL; 143 145 } 144 146 if( pAlfParam->acHorizontalAlfFilter[ uiIndx ].aiTapCoeffMapping != NULL ) 145 147 { 146 delete[] pAlfParam->acHorizontalAlfFilter[ uiIndx ].aiTapCoeffMapping;148 MEMDELETEARRAY( pAlfParam->acHorizontalAlfFilter[ uiIndx ].aiTapCoeffMapping ); 147 149 pAlfParam->acHorizontalAlfFilter[ uiIndx ].aiTapCoeffMapping = NULL; 148 150 } 149 151 if( pAlfParam->acHorizontalAlfFilter[ uiIndx ].aiCoeffWeights != NULL ) 150 152 { 151 delete[] pAlfParam->acHorizontalAlfFilter[ uiIndx ].aiCoeffWeights;153 MEMDELETEARRAY( pAlfParam->acHorizontalAlfFilter[ uiIndx ].aiCoeffWeights ); 152 154 pAlfParam->acHorizontalAlfFilter[ uiIndx ].aiCoeffWeights = NULL; 153 155 } 154 156 } 155 delete[] pAlfParam->acHorizontalAlfFilter;157 MEMDELETEARRAY( pAlfParam->acHorizontalAlfFilter ); 156 158 pAlfParam->acHorizontalAlfFilter = NULL; 157 159 } 158 160 … … 163 165 { 164 166 if( pAlfParam->acVerticalAlfFilter[ uiIndx ].aiQuantFilterCoeffs != NULL ) 165 167 { 166 delete[] pAlfParam->acVerticalAlfFilter[ uiIndx ].aiQuantFilterCoeffs;168 MEMDELETEARRAY( pAlfParam->acVerticalAlfFilter[ uiIndx ].aiQuantFilterCoeffs ); 167 169 pAlfParam->acVerticalAlfFilter[ uiIndx ].aiQuantFilterCoeffs = NULL; 168 170 } 169 171 if( pAlfParam->acVerticalAlfFilter[ uiIndx ].aiTapCoeffMapping != NULL ) 170 172 { 171 delete[] pAlfParam->acVerticalAlfFilter[ uiIndx ].aiTapCoeffMapping;173 MEMDELETEARRAY( pAlfParam->acVerticalAlfFilter[ uiIndx ].aiTapCoeffMapping ); 172 174 pAlfParam->acVerticalAlfFilter[ uiIndx ].aiTapCoeffMapping = NULL; 173 175 } 174 176 if( pAlfParam->acVerticalAlfFilter[ uiIndx ].aiCoeffWeights != NULL ) 175 177 { 176 delete[] pAlfParam->acVerticalAlfFilter[ uiIndx ].aiCoeffWeights;178 MEMDELETEARRAY( pAlfParam->acVerticalAlfFilter[ uiIndx ].aiCoeffWeights ); 177 179 pAlfParam->acVerticalAlfFilter[ uiIndx ].aiCoeffWeights = NULL; 178 180 } 179 181 } 180 delete[] pAlfParam->acVerticalAlfFilter;182 MEMDELETEARRAY( pAlfParam->acVerticalAlfFilter ); 181 183 pAlfParam->acVerticalAlfFilter = NULL; 182 184 } 183 185 … … 188 190 Void TComAdaptiveLoopFilter::destroyQuadTree(ALFParam* pcAlfParam) 189 191 { 190 192 pcAlfParam->pcQuadTree->destroy(); 191 delete pcAlfParam->pcQuadTree;193 MEMDELETE( pcAlfParam->pcQuadTree ); 192 194 pcAlfParam->pcQuadTree = NULL; 193 195 } 194 196 … … 383 385 if(pcAlfParam->cu_control_flag && iPlane ==0 ) 384 386 { 385 387 // block-adaptive ALF process 386 TComPicYuv* pcTempPicYuv2 = newTComPicYuv;388 TComPicYuv* pcTempPicYuv2 = MEMNEW TComPicYuv; 387 389 pcTempPicYuv2->create( pcPicRest->getWidth(), pcPicRest->getHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); 388 390 pcPicRest->copyToPicLuma( pcTempPicYuv2 ); 389 391 xApplyFrame ( pcPicRest, m_pcTempPicYuv , pcAlfParam->acVerticalAlfFilter [0] ); … … 391 393 //xCUAdaptive ( m_pcAlfQuadTree, pcAlfParam->acHorizontalAlfFilter[0] , m_pcTempPicYuv, pcPicRest ); 392 394 xCopyDecToRestCUs( pcAlfParam->pcQuadTree , pcTempPicYuv2 , pcPicRest ); 393 395 pcTempPicYuv2->destroy(); 394 delete pcTempPicYuv2;396 MEMDELETE( pcTempPicYuv2 ); 395 397 } 396 398 else 397 399 { … … 1261 1263 { 1262 1264 if ( !m_pcTempPicYuv ) 1263 1265 { 1264 m_pcTempPicYuv = newTComPicYuv;1266 m_pcTempPicYuv = MEMNEW TComPicYuv; 1265 1267 m_pcTempPicYuv->create( iPicWidth, iPicHeight, uiMaxCUWidth, uiMaxCUHeight, uiMaxCUDepth ); 1266 1268 } 1267 1269 #if QC_ALF … … 1285 1287 if ( m_pcTempPicYuv ) 1286 1288 { 1287 1289 m_pcTempPicYuv->destroy(); 1288 delete m_pcTempPicYuv;1290 MEMDELETE( m_pcTempPicYuv ); 1289 1291 } 1290 1292 #if QC_ALF 1291 1293 destroyMatrix_imgpel(imgY_var); … … 1313 1315 { 1314 1316 pAlfParam->alf_flag = 0; 1315 1317 1316 pAlfParam->coeff = newInt[ALF_MAX_NUM_COEF];1317 pAlfParam->coeff_chroma = newInt[ALF_MAX_NUM_COEF_C];1318 pAlfParam->coeff = MEMNEWARRAY Int[ALF_MAX_NUM_COEF]; 1319 pAlfParam->coeff_chroma = MEMNEWARRAY Int[ALF_MAX_NUM_COEF_C]; 1318 1320 1319 1321 ::memset(pAlfParam->coeff, 0, sizeof(Int)*ALF_MAX_NUM_COEF ); 1320 1322 ::memset(pAlfParam->coeff_chroma, 0, sizeof(Int)*ALF_MAX_NUM_COEF_C ); 1321 1323 #if QC_ALF 1322 pAlfParam->coeffmulti = newInt*[NO_VAR_BINS];1324 pAlfParam->coeffmulti = MEMNEWARRAY Int*[NO_VAR_BINS]; 1323 1325 for (int i=0; i<NO_VAR_BINS; i++) 1324 1326 { 1325 pAlfParam->coeffmulti[i] = newInt[ALF_MAX_NUM_COEF];1327 pAlfParam->coeffmulti[i] = MEMNEWARRAY Int[ALF_MAX_NUM_COEF]; 1326 1328 ::memset(pAlfParam->coeffmulti[i], 0, sizeof(Int)*ALF_MAX_NUM_COEF ); 1327 1329 } 1328 1330 #endif … … 1334 1336 1335 1337 if (pAlfParam->coeff != NULL) 1336 1338 { 1337 delete[] pAlfParam->coeff;1339 MEMDELETEARRAY( pAlfParam->coeff ); 1338 1340 pAlfParam->coeff = NULL; 1339 1341 } 1340 1342 1341 1343 if (pAlfParam->coeff_chroma != NULL) 1342 1344 { 1343 delete[] pAlfParam->coeff_chroma;1345 MEMDELETEARRAY( pAlfParam->coeff_chroma ); 1344 1346 pAlfParam->coeff_chroma = NULL; 1345 1347 } 1346 1348 #if QC_ALF 1347 1349 for (int i=0; i<NO_VAR_BINS; i++) 1348 1350 { 1349 delete[] pAlfParam->coeffmulti[i];1351 MEMDELETEARRAY( pAlfParam->coeffmulti[i] ); 1350 1352 pAlfParam->coeffmulti[i] = NULL; 1351 1353 } 1352 delete[] pAlfParam->coeffmulti;1354 MEMDELETEARRAY( pAlfParam->coeffmulti ); 1353 1355 pAlfParam->coeffmulti = NULL; 1354 1356 #endif 1355 1357 } -
source/Lib/TLibCommon/TComBitBuffer.cpp
35 35 36 36 #include "TComBitBuffer.h" 37 37 38 #include "tool_tracemem.h" 38 39 39 40 TComBitBuffer::TComBitBuffer() 40 : m_puiBuffer ( newUInt [ STD_BIT_BUFFER_ALLOC_SIZE ] )41 : m_puiBuffer ( MEMNEWARRAY UInt [ STD_BIT_BUFFER_ALLOC_SIZE ] ) 41 42 , m_uiBufferSize( STD_BIT_BUFFER_ALLOC_SIZE ) 42 43 , m_uiWriteElemIdx ( 0 ) 43 44 , m_uiWriteAvailBits( 32 ) … … 48 49 49 50 TComBitBuffer::~TComBitBuffer() 50 51 { 51 delete [] m_puiBuffer;52 MEMDELETEARRAY( m_puiBuffer ); 52 53 } 53 54 54 55 Void 55 56 TComBitBuffer::xIncreaseBufferSize() 56 57 { 57 58 UInt uiNewBufferSize = ( m_uiBufferSize << 1 ); 58 UInt* puiNewBuffer = newUInt [ uiNewBufferSize ];59 UInt* puiNewBuffer = MEMNEWARRAY UInt [ uiNewBufferSize ]; 59 60 ::memcpy( puiNewBuffer, m_puiBuffer, m_uiBufferSize * sizeof( UInt ) ); 60 delete [] m_puiBuffer;61 MEMDELETEARRAY( m_puiBuffer ); 61 62 m_puiBuffer = puiNewBuffer; 62 63 m_uiBufferSize = uiNewBufferSize; 63 64 } -
source/Lib/TLibCommon/TComBitStream.cpp
36 36 #include "TComBitStream.h" 37 37 #include <memory.h> 38 38 39 #include "tool_tracemem.h" 40 39 41 // ==================================================================================================================== 40 42 // Constructor / destructor / create / destroy 41 43 // ==================================================================================================================== … … 44 46 { 45 47 UInt uiSize = uiSizeInBytes / sizeof(UInt); 46 48 47 m_apulStreamPacketBegin = newUInt[uiSize];49 m_apulStreamPacketBegin = MEMNEWARRAY UInt[uiSize]; 48 50 m_uiBufSize = uiSize; 49 51 m_uiBitSize = 0; 50 52 m_iValidBits = 32; … … 57 59 58 60 Void TComBitstream::destroy() 59 61 { 60 delete [] m_apulStreamPacketBegin; m_apulStreamPacketBegin = NULL;62 MEMDELETEARRAY( m_apulStreamPacketBegin ); m_apulStreamPacketBegin = NULL; 61 63 } 62 64 63 65 // ==================================================================================================================== … … 313 315 //make sure start pos is inside the buffer 314 316 // assert( uiStartPos > uiBytesInBuffer ); 315 317 316 UChar* pucRead = newUChar[ uiBytesInBuffer ];318 UChar* pucRead = MEMNEWARRAY UChar[ uiBytesInBuffer ]; 317 319 //th this is not nice but ... 318 320 memcpy( pucRead, getStartStream(), uiBytesInBuffer ); 319 321 … … 340 342 } 341 343 } 342 344 343 delete [] pucRead;345 MEMDELETEARRAY( pucRead ); 344 346 m_uiBitsWritten = uiWriteOffset << 3; 345 347 } 346 348 #endif -
source/Lib/TLibCommon/TComLoopFilter.cpp
37 37 #include "TComSlice.h" 38 38 #include "TComMv.h" 39 39 40 #include "tool_tracemem.h" 41 40 42 // ==================================================================================================================== 41 43 // Constants 42 44 // ==================================================================================================================== … … 112 114 for( UInt uiDir = 0; uiDir < 2; uiDir++ ) 113 115 for( UInt uiPlane = 0; uiPlane < 3; uiPlane++ ) 114 116 { 115 m_aapucBS [uiDir][uiPlane] = newUChar[m_uiNumPartitions];116 m_aapbEdgeFilter[uiDir][uiPlane] = newBool [m_uiNumPartitions];117 m_aapucBS [uiDir][uiPlane] = MEMNEWARRAY UChar[m_uiNumPartitions]; 118 m_aapbEdgeFilter[uiDir][uiPlane] = MEMNEWARRAY Bool [m_uiNumPartitions]; 117 119 } 118 120 } 119 121 … … 122 124 for( UInt uiDir = 0; uiDir < 2; uiDir++ ) 123 125 for( UInt uiPlane = 0; uiPlane < 3; uiPlane++ ) 124 126 { 125 delete [] m_aapucBS [uiDir][uiPlane];126 delete [] m_aapbEdgeFilter[uiDir][uiPlane];127 MEMDELETEARRAY( m_aapucBS [uiDir][uiPlane] ); 128 MEMDELETEARRAY( m_aapbEdgeFilter[uiDir][uiPlane] ); 127 129 } 128 130 } 129 131 #endif -
source/Lib/TLibCommon/TComPic.cpp
35 35 36 36 #include "TComPic.h" 37 37 38 #include "tool_tracemem.h" 39 38 40 // ==================================================================================================================== 39 41 // Constructor / destructor / create / destroy 40 42 // ==================================================================================================================== … … 59 61 60 62 Void TComPic::create( Int iWidth, Int iHeight, UInt uiMaxWidth, UInt uiMaxHeight, UInt uiMaxDepth, Bool bIsVirtual ) 61 63 { 62 m_apcPicSym = newTComPicSym; m_apcPicSym ->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth );64 m_apcPicSym = MEMNEW TComPicSym; m_apcPicSym ->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth ); 63 65 if (!bIsVirtual) 64 66 { 65 m_apcPicYuv[0] = newTComPicYuv; m_apcPicYuv[0]->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth );67 m_apcPicYuv[0] = MEMNEW TComPicYuv; m_apcPicYuv[0]->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth ); 66 68 } 67 m_apcPicYuv[1] = newTComPicYuv; m_apcPicYuv[1]->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth );69 m_apcPicYuv[1] = MEMNEW TComPicYuv; m_apcPicYuv[1]->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth ); 68 70 69 71 #if HHI_INTERP_FILTER 70 72 // buffer for filtered reconstructed pic 71 m_apcPicYuv[2] = newTComPicYuv; m_apcPicYuv[2]->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth );73 m_apcPicYuv[2] = MEMNEW TComPicYuv; m_apcPicYuv[2]->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth ); 72 74 #endif 73 75 74 76 return; … … 79 81 if (m_apcPicSym) 80 82 { 81 83 m_apcPicSym->destroy(); 82 delete m_apcPicSym;84 MEMDELETE( m_apcPicSym ); 83 85 m_apcPicSym = NULL; 84 86 } 85 87 86 88 if (m_apcPicYuv[0]) 87 89 { 88 90 m_apcPicYuv[0]->destroy(); 89 delete m_apcPicYuv[0];91 MEMDELETE( m_apcPicYuv[0] ); 90 92 m_apcPicYuv[0] = NULL; 91 93 } 92 94 93 95 if (m_apcPicYuv[1]) 94 96 { 95 97 m_apcPicYuv[1]->destroy(); 96 delete m_apcPicYuv[1];98 MEMDELETE( m_apcPicYuv[1] ); 97 99 m_apcPicYuv[1] = NULL; 98 100 } 99 101 … … 101 103 if (m_apcPicYuv[2]) 102 104 { 103 105 m_apcPicYuv[2]->destroy(); 104 delete m_apcPicYuv[2];106 MEMDELETE( m_apcPicYuv[2] ); 105 107 m_apcPicYuv[2] = NULL; 106 108 } 107 109 #endif -
source/Lib/TLibCommon/TComPicSym.cpp
35 35 36 36 #include "TComPicSym.h" 37 37 38 #include "tool_tracemem.h" 39 38 40 // ==================================================================================================================== 39 41 // Constructor / destructor / create / destroy 40 42 // ==================================================================================================================== … … 43 45 { 44 46 UInt i; 45 47 46 m_apcTComSlice = newTComSlice;48 m_apcTComSlice = MEMNEW TComSlice; 47 49 48 50 m_uhTotalDepth = uiMaxDepth; 49 51 m_uiNumPartitions = 1<<(m_uhTotalDepth<<1); … … 61 63 m_uiHeightInCU = ( iPicHeight%m_uiMaxCUHeight ) ? iPicHeight/m_uiMaxCUHeight + 1 : iPicHeight/m_uiMaxCUHeight; 62 64 63 65 m_uiNumCUsInFrame = m_uiWidthInCU * m_uiHeightInCU; 64 m_apcTComDataCU = newTComDataCU*[m_uiNumCUsInFrame];66 m_apcTComDataCU = MEMNEWARRAY TComDataCU*[m_uiNumCUsInFrame]; 65 67 66 68 for ( i=0; i<m_uiNumCUsInFrame ; i++ ) 67 69 { 68 m_apcTComDataCU[i] = newTComDataCU;70 m_apcTComDataCU[i] = MEMNEW TComDataCU; 69 71 m_apcTComDataCU[i]->create( m_uiNumPartitions, m_uiMaxCUWidth, m_uiMaxCUHeight, false ); 70 72 } 71 73 } … … 74 76 { 75 77 Int i; 76 78 77 delete m_apcTComSlice;79 MEMDELETE( m_apcTComSlice ); 78 80 m_apcTComSlice = NULL; 79 81 80 82 … … 82 84 for (i = 0; i < m_uiNumCUsInFrame; i++) 83 85 { 84 86 m_apcTComDataCU[i]->destroy(); 85 delete m_apcTComDataCU[i];87 MEMDELETE( m_apcTComDataCU[i] ); 86 88 m_apcTComDataCU[i] = NULL; 87 89 } 88 delete [] m_apcTComDataCU;90 MEMDELETEARRAY( m_apcTComDataCU ); 89 91 m_apcTComDataCU = NULL; 90 92 } 91 93 -
source/Lib/TLibCommon/TComPredFilterMOMS.cpp
36 36 37 37 #include "TComPredFilterMOMS.h" 38 38 39 #include "tool_tracemem.h" 40 39 41 #if HHI_INTERP_FILTER 40 42 41 43 // predict luma block for a given motion vector for motion compensation … … 346 348 Void TComPredFilter6TapMOMS::interpolate( Pel* pcDst, Int iDstStride, Pel* pcSrc, Int iSrcStride, Int iDstYMax, Int iDstXMax, Int iDx, Int iDy, Int iDstStep ) 347 349 { 348 350 // temp buffer 349 Pel* pcTmpBufOrg = newPel[iDstXMax*(iDstYMax+5)];351 Pel* pcTmpBufOrg = MEMNEWARRAY Pel[iDstXMax*(iDstYMax+5)]; 350 352 #if HHI_INTERP_FILTER_KERNEL_FIX 351 353 const Int iQ6Gain = Int( pow((54.545454545454550),2) * pow(2.0,6) + 0.5 ); 352 354 #else … … 431 433 } 432 434 } 433 435 434 delete[] pcTmpBufOrg;436 MEMDELETEARRAY( pcTmpBufOrg ); 435 437 } 436 438 437 439 … … 467 469 Void TComPredFilter4TapMOMS::interpolate( Pel* pcDst, Int iDstStride, Pel* pcSrc, Int iSrcStride, Int iDstYMax, Int iDstXMax, Int iDx, Int iDy, Int iDstStep ) 468 470 { 469 471 // temp buffer 470 Pel* pcTmpBufOrg = newPel[iDstXMax*(iDstYMax+3)];472 Pel* pcTmpBufOrg = MEMNEWARRAY Pel[iDstXMax*(iDstYMax+3)]; 471 473 472 474 // interpolation in horizontal direction 473 475 { … … 535 537 } 536 538 } 537 539 538 delete[] pcTmpBufOrg;540 MEMDELETEARRAY( pcTmpBufOrg ); 539 541 } 540 542 541 543 -
source/Lib/TLibCommon/TComPrediction.cpp
36 36 #include <memory.h> 37 37 #include "TComPrediction.h" 38 38 39 #include "tool_tracemem.h" 40 39 41 // ==================================================================================================================== 40 42 // Constructor / destructor / initialize 41 43 // ==================================================================================================================== … … 53 55 { 54 56 m_cYuvExt.destroy(); 55 57 56 delete[] m_piYuvExt;58 MEMDELETEARRAY( m_piYuvExt ); 57 59 #ifdef EDGE_BASED_PREDICTION 58 delete[] m_piYExtEdgeBased;60 MEMDELETEARRAY( m_piYExtEdgeBased ); 59 61 #endif //EDGE_BASED_PREDICTION 60 62 61 63 m_acYuvPred[0].destroy(); … … 63 65 64 66 m_cYuvPredTemp.destroy(); 65 67 #ifdef EDGE_BASED_PREDICTION 66 delete EdgeBasedPred;68 MEMDELETE( EdgeBasedPred ); 67 69 #endif //EDGE_BASED_PREDICTION 68 70 69 71 } … … 76 78 m_iYuvExtStride = ((g_uiMaxCUWidth + 12) << 4); 77 79 78 80 m_cYuvExt.create( m_iYuvExtStride, m_iYuvExtHeight ); 79 m_piYuvExt = newInt[ m_iYuvExtStride * m_iYuvExtHeight ];81 m_piYuvExt = MEMNEWARRAY Int[ m_iYuvExtStride * m_iYuvExtHeight ]; 80 82 81 83 // new structure 82 84 m_acYuvPred[0] .create( g_uiMaxCUWidth, g_uiMaxCUHeight ); … … 90 92 } 91 93 #ifdef EDGE_BASED_PREDICTION 92 94 if( m_piYExtEdgeBased == NULL ) 93 m_piYExtEdgeBased = newInt[ ((g_uiMaxCUWidth<<1)+4) * ((g_uiMaxCUHeight<<1)+4) ];95 m_piYExtEdgeBased = MEMNEWARRAY Int[ ((g_uiMaxCUWidth<<1)+4) * ((g_uiMaxCUHeight<<1)+4) ]; 94 96 #endif //EDGE_BASED_PREDICTION 95 97 96 98 m_iDIFHalfTap = ( m_iDIFTap >> 1 ); 97 99 #ifdef EDGE_BASED_PREDICTION 98 EdgeBasedPred = newTComEdgeBased;100 EdgeBasedPred = MEMNEW TComEdgeBased; 99 101 #endif //EDGE_BASED_PREDICTION 100 102 } 101 103 -
source/Lib/TLibCommon/TComRdCost.cpp
37 37 #include <assert.h> 38 38 #include "TComRdCost.h" 39 39 40 #include "tool_tracemem.h" 41 40 42 TComRdCost::TComRdCost() 41 43 { 42 44 init(); … … 235 237 236 238 m_iSearchLimit = iSubPelSearchLimit; 237 239 238 m_puiComponentCostOriginP = newUInt[ 4 * iSubPelSearchLimit ];240 m_puiComponentCostOriginP = MEMNEWARRAY UInt[ 4 * iSubPelSearchLimit ]; 239 241 iSubPelSearchLimit *= 2; 240 242 241 243 m_puiComponentCost = m_puiComponentCostOriginP + iSubPelSearchLimit; … … 251 253 { 252 254 if( NULL != m_puiComponentCostOriginP ) 253 255 { 254 delete [] m_puiComponentCostOriginP;256 MEMDELETEARRAY( m_puiComponentCostOriginP ); 255 257 m_puiComponentCostOriginP = NULL; 256 258 } 257 259 } -
source/Lib/TLibCommon/TComRom.cpp
37 37 #include <memory.h> 38 38 #include <stdlib.h> 39 39 #include <stdio.h> 40 41 #include "tool_tracemem.h" 42 40 43 // ==================================================================================================================== 41 44 // Initialize / destroy functions 42 45 // ==================================================================================================================== … … 64 67 #endif 65 68 for ( i=0; i<MAX_CU_DEPTH; i++ ) 66 69 { 67 g_auiFrameScanXY[ i ] = newUInt[ c*c ];68 g_auiFrameScanX [ i ] = newUInt[ c*c ];69 g_auiFrameScanY [ i ] = newUInt[ c*c ];70 g_auiFrameScanXY[ i ] = MEMNEWARRAY UInt[ c*c ]; 71 g_auiFrameScanX [ i ] = MEMNEWARRAY UInt[ c*c ]; 72 g_auiFrameScanY [ i ] = MEMNEWARRAY UInt[ c*c ]; 70 73 initFrameScanXY( g_auiFrameScanXY[i], g_auiFrameScanX[i], g_auiFrameScanY[i], c, c ); 71 74 c <<= 1; 72 75 } … … 77 80 { 78 81 const int iBlockSize = 1 << i; 79 82 const UInt uiNumScanPos = UInt( iBlockSize * iBlockSize ); 80 g_auiSigLastScan[ i ][ 0 ] = newUInt[ uiNumScanPos ];81 g_auiSigLastScan[ i ][ 1 ] = newUInt[ uiNumScanPos ];83 g_auiSigLastScan[ i ][ 0 ] = MEMNEWARRAY UInt[ uiNumScanPos ]; 84 g_auiSigLastScan[ i ][ 1 ] = MEMNEWARRAY UInt[ uiNumScanPos ]; 82 85 initSigLastScanPattern( g_auiSigLastScan[ i ][ 1 ], i, true ); 83 86 initSigLastScanPattern( g_auiSigLastScan[ i ][ 0 ], i, false ); 84 87 } … … 88 91 int ipredmode; 89 92 for(ipredmode=0; ipredmode<9; ipredmode++) 90 93 { 91 scanOrder4x4[ipredmode] = newUInt[ 4*4 ];92 scanOrder4x4X[ipredmode]= newUInt[ 4*4 ];93 scanOrder4x4Y[ipredmode]= newUInt[ 4*4 ];94 scanOrder4x4[ipredmode] = MEMNEWARRAY UInt[ 4*4 ]; 95 scanOrder4x4X[ipredmode]= MEMNEWARRAY UInt[ 4*4 ]; 96 scanOrder4x4Y[ipredmode]= MEMNEWARRAY UInt[ 4*4 ]; 94 97 95 scanStats4x4[ipredmode] = newUInt[ 4*4 ];98 scanStats4x4[ipredmode] = MEMNEWARRAY UInt[ 4*4 ]; 96 99 97 100 98 scanOrder8x8[ipredmode] = newUInt[ 8*8 ];99 scanOrder8x8X[ipredmode]= newUInt[ 8*8 ];100 scanOrder8x8Y[ipredmode]= newUInt[ 8*8 ];101 scanOrder8x8[ipredmode] = MEMNEWARRAY UInt[ 8*8 ]; 102 scanOrder8x8X[ipredmode]= MEMNEWARRAY UInt[ 8*8 ]; 103 scanOrder8x8Y[ipredmode]= MEMNEWARRAY UInt[ 8*8 ]; 101 104 102 scanStats8x8[ipredmode] = newUInt[ 8*8 ];105 scanStats8x8[ipredmode] = MEMNEWARRAY UInt[ 8*8 ]; 103 106 } 104 107 105 108 // 16x16 106 109 for (int z=0; z < NUM_SCANS_16x16; z++) 107 110 { 108 scanOrder16x16[z] = newUInt[ 16*16 ];109 scanOrder16x16X[z] = newUInt[ 16*16 ];110 scanOrder16x16Y[z] = newUInt[ 16*16 ];111 scanStats16x16[z] = newUInt[ 16*16 ];111 scanOrder16x16[z] = MEMNEWARRAY UInt[ 16*16 ]; 112 scanOrder16x16X[z] = MEMNEWARRAY UInt[ 16*16 ]; 113 scanOrder16x16Y[z] = MEMNEWARRAY UInt[ 16*16 ]; 114 scanStats16x16[z] = MEMNEWARRAY UInt[ 16*16 ]; 112 115 } 113 116 114 117 // 32x32 115 118 for (int z=0; z < NUM_SCANS_32x32; z++) 116 119 { 117 scanOrder32x32[z] = newUInt[ 32*32 ];118 scanOrder32x32X[z] = newUInt[ 32*32 ];119 scanOrder32x32Y[z] = newUInt[ 32*32 ];120 scanStats32x32[z] = newUInt[ 32*32 ];120 scanOrder32x32[z] = MEMNEWARRAY UInt[ 32*32 ]; 121 scanOrder32x32X[z] = MEMNEWARRAY UInt[ 32*32 ]; 122 scanOrder32x32Y[z] = MEMNEWARRAY UInt[ 32*32 ]; 123 scanStats32x32[z] = MEMNEWARRAY UInt[ 32*32 ]; 121 124 } 122 125 123 126 // 64x64 124 127 for (int z=0; z < NUM_SCANS_64x64; z++) 125 128 { 126 scanOrder64x64[z] = newUInt[ 64*64 ];127 scanOrder64x64X[z] = newUInt[ 64*64 ];128 scanOrder64x64Y[z] = newUInt[ 64*64 ];129 scanStats64x64[z] = newUInt[ 64*64 ];129 scanOrder64x64[z] = MEMNEWARRAY UInt[ 64*64 ]; 130 scanOrder64x64X[z] = MEMNEWARRAY UInt[ 64*64 ]; 131 scanOrder64x64Y[z] = MEMNEWARRAY UInt[ 64*64 ]; 132 scanStats64x64[z] = MEMNEWARRAY UInt[ 64*64 ]; 130 133 } 131 134 #endif 132 135 } … … 137 140 138 141 for ( i=0; i<MAX_CU_DEPTH; i++ ) 139 142 { 140 delete[] g_auiFrameScanXY[i];141 delete[] g_auiFrameScanX [i];142 delete[] g_auiFrameScanY [i];143 MEMDELETEARRAY( g_auiFrameScanXY[i] ); 144 MEMDELETEARRAY( g_auiFrameScanX [i] ); 145 MEMDELETEARRAY( g_auiFrameScanY [i] ); 143 146 } 144 147 145 148 #if HHI_TRANSFORM_CODING 146 149 for ( i=0; i<MAX_CU_DEPTH+1; i++ ) 147 150 { 148 delete[] g_auiSigLastScan[i][0];149 delete[] g_auiSigLastScan[i][1];151 MEMDELETEARRAY( g_auiSigLastScan[i][0] ); 152 MEMDELETEARRAY( g_auiSigLastScan[i][1] ); 150 153 } 151 154 #endif 152 155 … … 154 157 int ipredmode; 155 158 for(ipredmode=0; ipredmode<9; ipredmode++) 156 159 { 157 delete [] scanOrder4x4[ipredmode];158 delete [] scanOrder4x4X[ipredmode];159 delete [] scanOrder4x4Y[ipredmode];160 delete [] scanStats4x4[ipredmode];160 MEMDELETEARRAY( scanOrder4x4[ipredmode] ); 161 MEMDELETEARRAY( scanOrder4x4X[ipredmode] ); 162 MEMDELETEARRAY( scanOrder4x4Y[ipredmode] ); 163 MEMDELETEARRAY( scanStats4x4[ipredmode] ); 161 164 162 delete [] scanOrder8x8[ipredmode];163 delete [] scanOrder8x8X[ipredmode];164 delete [] scanOrder8x8Y[ipredmode];165 delete [] scanStats8x8[ipredmode];165 MEMDELETEARRAY( scanOrder8x8[ipredmode] ); 166 MEMDELETEARRAY( scanOrder8x8X[ipredmode] ); 167 MEMDELETEARRAY( scanOrder8x8Y[ipredmode] ); 168 MEMDELETEARRAY( scanStats8x8[ipredmode] ); 166 169 } 167 170 168 171 // 16x16 169 172 for (int z=0; z < NUM_SCANS_16x16; z++) 170 173 { 171 delete [] scanOrder16x16[z];172 delete [] scanOrder16x16X[z];173 delete [] scanOrder16x16Y[z];174 delete [] scanStats16x16[z];174 MEMDELETEARRAY( scanOrder16x16[z] ); 175 MEMDELETEARRAY( scanOrder16x16X[z] ); 176 MEMDELETEARRAY( scanOrder16x16Y[z] ); 177 MEMDELETEARRAY( scanStats16x16[z] ); 175 178 } 176 179 // 32x32 177 180 for (int z=0; z < NUM_SCANS_32x32; z++) 178 181 { 179 delete [] scanOrder32x32[z];180 delete [] scanOrder32x32X[z];181 delete [] scanOrder32x32Y[z];182 delete [] scanStats32x32[z];182 MEMDELETEARRAY( scanOrder32x32[z] ); 183 MEMDELETEARRAY( scanOrder32x32X[z] ); 184 MEMDELETEARRAY( scanOrder32x32Y[z] ); 185 MEMDELETEARRAY( scanStats32x32[z] ); 183 186 } 184 187 // 64x64 185 188 for (int z=0; z < NUM_SCANS_64x64; z++) 186 189 { 187 delete [] scanOrder64x64[z];188 delete [] scanOrder64x64X[z];189 delete [] scanOrder64x64Y[z];190 delete [] scanStats64x64[z];190 MEMDELETEARRAY( scanOrder64x64[z] ); 191 MEMDELETEARRAY( scanOrder64x64X[z] ); 192 MEMDELETEARRAY( scanOrder64x64Y[z] ); 193 MEMDELETEARRAY( scanStats64x64[z] ); 191 194 } 192 195 #endif 193 196 } -
source/Lib/TLibCommon/TComTrQuant.cpp
42 42 #endif 43 43 #include "ContextTables.h" 44 44 45 #include "tool_tracemem.h" 46 45 47 // ==================================================================================================================== 46 48 // Constants 47 49 // ==================================================================================================================== … … 243 245 m_cQP.clear(); 244 246 245 247 // allocate temporary buffers 246 m_plTempCoeff = newLong[ MAX_CU_SIZE*MAX_CU_SIZE ];248 m_plTempCoeff = MEMNEWARRAY Long[ MAX_CU_SIZE*MAX_CU_SIZE ]; 247 249 248 250 // allocate bit estimation class (for RDOQ) 249 m_pcEstBitsSbac = newestBitsSbacStruct;251 m_pcEstBitsSbac = MEMNEW estBitsSbacStruct; 250 252 } 251 253 252 254 TComTrQuant::~TComTrQuant() … … 254 256 // delete temporary buffers 255 257 if ( m_plTempCoeff ) 256 258 { 257 delete [] m_plTempCoeff;259 MEMDELETEARRAY( m_plTempCoeff ); 258 260 m_plTempCoeff = NULL; 259 261 } 260 262 261 263 // delete bit estimation class 262 if ( m_pcEstBitsSbac ) delete m_pcEstBitsSbac;264 if ( m_pcEstBitsSbac ) MEMDELETE( m_pcEstBitsSbac ); 263 265 } 264 266 265 267 /// Including Chroma QP Parameter setting … … 6805 6807 UInt puiCtxCoeffLevelM1[MAX_CU_SIZE * MAX_CU_SIZE]; 6806 6808 UInt puiBaseCtx[MAX_CU_SIZE * MAX_CU_SIZE / 16]; 6807 6809 6808 // Int* piCoeff = newInt [ uiMaxNumCoeff ];6810 // Int* piCoeff = MEMNEWARRAY Int [ uiMaxNumCoeff ]; 6809 6811 //#if QC_MDDT 6810 // Int64* plLevelDouble = newInt64[ uiMaxNumCoeff ];6812 // Int64* plLevelDouble = MEMNEWARRAY Int64[ uiMaxNumCoeff ]; 6811 6813 //#else 6812 // Long* plLevelDouble = newLong[ uiMaxNumCoeff ];6814 // Long* plLevelDouble = MEMNEWARRAY Long[ uiMaxNumCoeff ]; 6813 6815 //#endif 6814 // UInt* puiCtxAbsGreOne = newUInt[ uiMaxNumCoeff ];6815 // UInt* puiCtxCoeffLevelM1 = newUInt[ uiMaxNumCoeff ];6816 // UInt* puiBaseCtx = newUInt[ uiMaxNumCoeff / 16 ];6816 // UInt* puiCtxAbsGreOne = MEMNEWARRAY UInt[ uiMaxNumCoeff ]; 6817 // UInt* puiCtxCoeffLevelM1 = MEMNEWARRAY UInt[ uiMaxNumCoeff ]; 6818 // UInt* puiBaseCtx = MEMNEWARRAY UInt[ uiMaxNumCoeff / 16 ]; 6817 6819 const UInt uiNumOfSets = 4; 6818 6820 const UInt uiNum4x4Blk = max<UInt>( 1, uiMaxNumCoeff / 16 ); 6819 6821 … … 7254 7256 } 7255 7257 } 7256 7258 7257 // delete[] piCoeff;7258 // delete[] plLevelDouble;7259 // delete[] puiCtxAbsGreOne;7260 // delete[] puiCtxCoeffLevelM1;7261 // delete[] puiBaseCtx;7259 // MEMDELETEARRAY( piCoeff ); 7260 // MEMDELETEARRAY( plLevelDouble ); 7261 // MEMDELETEARRAY( puiCtxAbsGreOne ); 7262 // MEMDELETEARRAY( puiCtxCoeffLevelM1 ); 7263 // MEMDELETEARRAY( puiBaseCtx ); 7262 7264 #else 7263 7265 // temporal buffer for speed 7264 7266 static levelDataStruct slevelData [ MAX_CU_SIZE*MAX_CU_SIZE ]; -
source/Lib/TLibCommon/tool_tracemem.cpp
1 /**************************************************************************** 2 tool_tracemem.cpp 3 ------------------- 4 begin : Fri Oct 06 2006 5 authors : Xiang Li 6 email : xiangli@ieee.org 7 ****************************************************************************/ 8 9 /**************************************************************************** 10 Implementation of tools for tracing memory allocation. 11 ****************************************************************************/ 12 13 #include <stdio.h> 14 #include <assert.h> 15 #include "tool_tracemem.h" 16 17 #ifdef CTRL_USE_TRACEMEM 18 19 /***************************************************************************/ 20 namespace Utilities 21 { 22 23 #define TRACEMEM_REPORT_MISMATCH_NEWDEL 0 24 #define TRACEMEM_THRESHOLD_FILE_TIMESNEW 10000 25 #define TRACEMEM_THRESHOLD_FILE_BYTESALLOC 3000000 26 #define TRACEMEM_THRESHOLD_FILE_PER 0.25 27 28 CMemoryTrace::CMemoryTrace() 29 { 30 m_szMaxRecord = 0; 31 m_szCurUsed = 0; 32 m_szMaxUsed = 0; 33 m_uTimesNew = 0; 34 m_uTimesDelMissed = 0; 35 } 36 37 CMemoryTrace::~CMemoryTrace() 38 { 39 40 } 41 42 void CMemoryTrace::AddRecord( void * pMemory , size_t sz , char * pFileName , int nLine , bool bArray ) 43 { 44 if( pMemory != NULL ) 45 { 46 assert( m_MemoryNew.find( ( size_t )pMemory ) == m_MemoryNew.end() ); 47 48 // record memory allocation 49 xxGetFileName( pFileName , m_MemoryNew[ ( size_t )pMemory ].strFileNameNew ); 50 m_MemoryNew[ ( size_t )pMemory ].nLineNew = nLine; 51 m_MemoryNew[ ( size_t )pMemory ].bArray = bArray; 52 m_MemoryNew[ ( size_t )pMemory ].szSize = sz; 53 m_szCurUsed += sz; 54 if( m_szCurUsed > m_szMaxUsed ) 55 m_szMaxUsed = m_szCurUsed; 56 m_uTimesNew++; 57 58 // record the allocation from a file 59 const std::string & rStr = m_MemoryNew[ ( size_t )pMemory ].strFileNameNew; 60 if( m_MemoryFileNew.find( rStr ) == m_MemoryFileNew.end() ) 61 { 62 // new file 63 m_MemoryFileNew[ rStr ].strFileNameNew = rStr; 64 m_MemoryFileNew[ rStr ].szCurAllocated = sz; 65 m_MemoryFileNew[ rStr ].uTimesNew = 1; 66 m_MemoryFileNew[ rStr ].szMaxAllocated = sz; 67 } 68 else 69 { 70 m_MemoryFileNew[ rStr ].szCurAllocated += sz; 71 m_MemoryFileNew[ rStr ].uTimesNew += 1; 72 if( m_MemoryFileNew[ rStr ].szMaxAllocated < m_MemoryFileNew[ rStr ].szCurAllocated ) 73 m_MemoryFileNew[ rStr ].szMaxAllocated = m_MemoryFileNew[ rStr ].szCurAllocated; 74 } 75 76 // max number of the records 77 if( m_MemoryNew.size() > m_szMaxRecord ) 78 { 79 m_szMaxRecord = m_MemoryNew.size(); 80 } 81 82 } 83 } 84 85 void CMemoryTrace::DelRecord( void * pMemory , char * pFileName , int nLine , bool bArray ) 86 { 87 if( pMemory != NULL ) 88 { 89 if( m_MemoryNew.empty() == false && m_MemoryNew.find( ( size_t )pMemory ) != m_MemoryNew.end() ) 90 { 91 92 #if TRACEMEM_REPORT_MISMATCH_NEWDEL 93 if( m_MemoryNew[ ( size_t )pMemory ].bArray != bArray ) 94 { 95 // record the item which not paired properly 96 m_NotPairedNew[ ( size_t )pMemory ] = m_MemoryNew[ ( size_t )pMemory ]; 97 xxGetFileName( pFileName , m_NotPairedNew[ ( size_t )pMemory ].strFileNameDel ); 98 m_NotPairedNew[ ( size_t )pMemory ].nLineDel = nLine; 99 } 100 #endif 101 102 // file record 103 const std::string & rStr = m_MemoryNew[ ( size_t )pMemory ].strFileNameNew; 104 m_MemoryFileNew[ rStr ].szCurAllocated -= m_MemoryNew[ ( size_t )pMemory ].szSize; 105 106 // global record 107 m_szCurUsed = m_szCurUsed - m_MemoryNew[ ( size_t )pMemory ].szSize; 108 m_MemoryNew.erase( ( size_t )pMemory ); 109 } 110 else 111 { 112 xxGetFileName( pFileName , m_MemoryDel[ ( size_t )pMemory ].strFileNameDel ); 113 m_MemoryDel[ ( size_t )pMemory ].nLineDel = nLine; 114 m_MemoryDel[ ( size_t )pMemory ].bArray = bArray; 115 m_uTimesDelMissed++; 116 } 117 } 118 } 119 120 bool CMemoryTrace::HasBeenAllocated( void * pMemory ) 121 { 122 if( pMemory != NULL && m_MemoryNew.empty() == false ) 123 return( m_MemoryNew.find( ( size_t )pMemory ) != m_MemoryNew.end() ); 124 else 125 return( false ); 126 } 127 128 void CMemoryTrace::OutputMemTraceInfo( FILE * fpLog ) 129 { 130 if( fpLog != NULL ) 131 { 132 fprintf( fpLog , "\n\n******************** Memory Log ********************" ); 133 134 char strMaxMemory[256] , strCurMemory[256]; 135 136 if( m_szMaxUsed < 1000 ) 137 sprintf( strMaxMemory , "%d B" , m_szMaxUsed ); 138 else if( m_szMaxUsed < 1000000 ) 139 sprintf( strMaxMemory , "%.1lf KB" , m_szMaxUsed / 1000.0 ); 140 else 141 sprintf( strMaxMemory , "%.2lf MB" , m_szMaxUsed / 1000000.0 ); 142 143 if( m_szCurUsed < 1000 ) 144 sprintf( strCurMemory , "%d B" , m_szCurUsed ); 145 else if( m_szCurUsed < 1000000 ) 146 sprintf( strCurMemory , "%.1lf KB" , m_szCurUsed / 1000.0 ); 147 else 148 sprintf( strCurMemory , "%.2lf MB" , m_szCurUsed / 1000000.0 ); 149 150 fprintf( fpLog , "\nAllocating memory %lld times, incorrect deleting %lld times." , m_uTimesNew , m_uTimesDelMissed ); 151 fprintf( fpLog , "\nMax %s were allocated, %s have not be freed." , strMaxMemory , strCurMemory ); 152 fprintf( fpLog , "\nMax %d records." , m_szMaxRecord ); 153 154 if( m_MemoryNew.empty() == false ) 155 { 156 fprintf( fpLog , "\n----------------------------------------------------" ); 157 fprintf( fpLog , "\nMemory has not been freed:" ); 158 HASH_MAP < unsigned int , SMemoryRecord >::iterator CurPos = m_MemoryNew.begin(); 159 while( CurPos != m_MemoryNew.end() ) 160 { 161 fprintf( fpLog , "\nIn %s line %d, memory was allocated at 0x%08x (%dB)." , CurPos->second.strFileNameNew.c_str() , 162 CurPos->second.nLineNew , CurPos->first , CurPos->second.szSize ); 163 CurPos++; 164 } 165 } 166 167 if( m_MemoryDel.empty() == false ) 168 { 169 fprintf( fpLog , "\n----------------------------------------------------" ); 170 fprintf( fpLog , "\nIncorrect delete:" ); 171 HASH_MAP < unsigned int , SMemoryRecord >::iterator CurPos = m_MemoryDel.begin(); 172 while( CurPos != m_MemoryDel.end() ) 173 { 174 fprintf( fpLog , "\nIn %s line %d, memory 0x%08x was incorrectly deleted." , CurPos->second.strFileNameDel.c_str() , 175 CurPos->second.nLineDel , CurPos->first ); 176 CurPos++; 177 } 178 } 179 180 #if TRACEMEM_REPORT_MISMATCH_NEWDEL 181 if( m_NotPairedNew.empty() == false ) 182 { 183 fprintf( fpLog , "\n----------------------------------------------------" ); 184 fprintf( fpLog , "\nnew/new[] not paired by proper delete/delete[]:" ); 185 HASH_MAP < unsigned int , SMemoryRecord >::iterator CurPos = m_NotPairedNew.begin(); 186 while( CurPos != m_NotPairedNew.end() ) 187 { 188 fprintf( fpLog , "\nIn %s line %d, new 0x%08x was by allocated by %s while freed by %s in %s line %d." , 189 CurPos->second.strFileNameNew.c_str() , CurPos->second.nLineNew , CurPos->first , 190 CurPos->second.bArray == false ? "MEMNEW" : "MEMNEWARRAY" , 191 CurPos->second.bArray == true ? "MEMDELETE" : "DELETEARRAY" , 192 CurPos->second.strFileNameDel.c_str() , CurPos->second.nLineDel ); 193 CurPos++; 194 } 195 } 196 #endif 197 198 if( m_MemoryFileNew.empty() == false ) 199 { 200 fprintf( fpLog , "\n----------------------------------------------------" ); 201 fprintf( fpLog , "\nFiles of frequent memory allocation and files using much memory:" ); 202 std::map < std::string , SFileMemory >::iterator CurPos = m_MemoryFileNew.begin(); 203 while( CurPos != m_MemoryFileNew.end() ) 204 { 205 if( CurPos->second.uTimesNew >= TRACEMEM_THRESHOLD_FILE_TIMESNEW 206 || CurPos->second.uTimesNew >= TRACEMEM_THRESHOLD_FILE_PER * m_uTimesNew 207 || CurPos->second.szMaxAllocated >= TRACEMEM_THRESHOLD_FILE_BYTESALLOC 208 || CurPos->second.szMaxAllocated >= TRACEMEM_THRESHOLD_FILE_PER * m_szMaxUsed ) 209 { 210 const size_t & rMaxUsed = CurPos->second.szMaxAllocated; 211 if( rMaxUsed < 1000 ) 212 sprintf( strMaxMemory , "%d B" , rMaxUsed ); 213 else if( rMaxUsed < 1000000 ) 214 sprintf( strMaxMemory , "%.1lf KB" , rMaxUsed / 1000.0 ); 215 else 216 sprintf( strMaxMemory , "%.2lf MB" , rMaxUsed / 1000000.0 ); 217 fprintf( fpLog , "\n%s, %lld times (%.2lf%%) allocation, max %s were allocated." , CurPos->second.strFileNameNew.c_str() , 218 CurPos->second.uTimesNew , CurPos->second.uTimesNew * 100.0 / m_uTimesNew , strMaxMemory ); 219 } 220 CurPos++; 221 } 222 } 223 224 fprintf( fpLog , "\n****************************************************\n" ); 225 } 226 227 xxRelease(); 228 } 229 230 void CMemoryTrace::xxGetFileName( const char * pPathFileName , std::string & rFileName ) const 231 { 232 rFileName = pPathFileName; 233 size_t nLast = rFileName.find_last_of( CSLASH ); 234 if( nLast + 1 < std::string::npos ) 235 rFileName.erase( 0 , nLast + 1 ); 236 } 237 238 void CMemoryTrace::xxRelease() 239 { 240 m_MemoryNew.clear(); 241 m_MemoryDel.clear(); 242 m_NotPairedNew.clear(); 243 } 244 245 } // namespace Utilities 246 /***************************************************************************/ 247 248 /** global variables *******************************************************/ 249 Utilities::CMemoryTrace gMemoryTrace; 250 /***************************************************************************/ 251 252 /** new and delete *********************************************************/ 253 void * operator new( size_t sz , char * pFileName , int nLine , bool bArray ) 254 { 255 void * pMemory = operator new( sz ); 256 257 gMemoryTrace.AddRecord( pMemory , sz , pFileName , nLine , bArray ); 258 259 return( pMemory ); 260 } 261 262 void * operator new[] ( size_t sz , char * pFileName , int nLine , bool bArray ) 263 { 264 void * pMemory = operator new( sz ); 265 266 gMemoryTrace.AddRecord( pMemory , sz , pFileName , nLine , bArray ); 267 268 return( pMemory ); 269 } 270 271 void operator delete( void * pMemory , char * pFileName , int nLine , bool bArray ) 272 { 273 if( pMemory != NULL ) 274 { 275 gMemoryTrace.DelRecord( pMemory , pFileName , nLine , bArray ); 276 operator delete ( pMemory ); 277 } 278 } 279 280 void operator delete [] ( void * pMemory , char * pFileName , int nLine , bool bArray ) 281 { 282 if( pMemory != NULL ) 283 { 284 gMemoryTrace.DelRecord( pMemory , pFileName , nLine , bArray ); 285 operator delete ( pMemory ); 286 } 287 } 288 289 void OutputMemTraceInfo( FILE * fpLog ) 290 { 291 gMemoryTrace.OutputMemTraceInfo( fpLog ); 292 } 293 294 295 /***************************************************************************/ 296 297 #endif // CTRL_USE_TRACEMEM 298 299 double GetMaxMBMemAllocated() 300 { 301 double dReturn = 0; 302 303 #ifdef CTRL_USE_TRACEMEM 304 dReturn = gMemoryTrace.GetMaxMBMemAllocated(); 305 #endif 306 307 return( dReturn ); 308 } 309 310 double GetTimesMemAllocation() 311 { 312 double dReturn = 0; 313 314 #ifdef CTRL_USE_TRACEMEM 315 dReturn = gMemoryTrace.GetTimesMemAllocation(); 316 #endif 317 318 return( dReturn ); 319 } 320 321 /**************************************************************************** 322 end-of-file 323 ****************************************************************************/ -
source/Lib/TLibCommon/tool_tracemem.h
1 /**************************************************************************** 2 tool_tracemem.h 3 ------------------- 4 begin : Fri Oct 06 2006 5 authors : Xiang Li 6 email : xiangli@ieee.org 7 ****************************************************************************/ 8 9 #ifndef __TOOL_TRACEMEM_H__ 10 #define __TOOL_TRACEMEM_H__ 11 12 /**************************************************************************** 13 Implementations of tools for tracing memory allocation. 14 ****************************************************************************/ 15 16 /** standard headers *******************************************************/ 17 #include <string> 18 #include <map> 19 #ifdef WIN32 20 #include <hash_map> 21 #else 22 #include <ext/hash_map> 23 #endif 24 /***************************************************************************/ 25 26 /** control definition *****************************************************/ 27 #define CTRL_USE_TRACEMEM 28 /***************************************************************************/ 29 30 #ifdef CTRL_USE_TRACEMEM 31 32 /***************************************************************************/ 33 namespace Utilities 34 { 35 36 #ifdef WIN32 37 #define HASH_MAP stdext::hash_map 38 #define CSLASH '\\' 39 typedef unsigned __int64 uint64_t; 40 #else 41 #define HASH_MAP __gnu_cxx::hash_map 42 #define CSLASH '/' 43 typedef unsigned long long uint64_t; 44 #endif 45 46 //! class for memory tracing 47 class CMemoryTrace 48 { 49 50 public: 51 52 /** function members *******************************************************/ 53 54 //! constructor 55 CMemoryTrace(); 56 57 //! destructor 58 ~CMemoryTrace(); 59 60 /***********************************************************************/ 61 /*! 62 * \short add a record for the operator new 63 * 64 * \param pMemory, pointer to the memory just newed 65 * \param sz, size of memory to be newed 66 * \param pFileName, indicates the file which calls new 67 * \param nLine, indicates the line where new is called 68 * \param bArray, whether by new [] 69 */ 70 /***********************************************************************/ 71 void AddRecord( void * pMemory , size_t sz , char * pFileName , int nLine , bool bArray ); 72 73 /***********************************************************************/ 74 /*! 75 * \short add a record for the operator delete 76 * 77 * \param pMemory, pointer to the memory to be deleted 78 * \param pFileName, indicates the file which calls new 79 * \param nLine, indicates the line where new is called 80 * \param bArray, whether by delete [] 81 */ 82 /***********************************************************************/ 83 void DelRecord( void * pMemory , char * pFileName , int nLine , bool bArray ); 84 85 /***********************************************************************/ 86 /*! 87 * \short check whether the memory has been recorded for the operator new 88 * 89 * \param pMemory, pointer to the memory 90 */ 91 /***********************************************************************/ 92 bool HasBeenAllocated( void * pMemory ); 93 94 /***********************************************************************/ 95 /*! 96 * \short output the memory tracing information 97 */ 98 /***********************************************************************/ 99 void OutputMemTraceInfo( FILE * fpLog ); 100 101 /***********************************************************************/ 102 /*! 103 * \short Get the memory (in MBytes) has been allocated 104 * 105 * \return memory has been allocated 106 */ 107 /***********************************************************************/ 108 double GetMaxMBMemAllocated() 109 { 110 return( m_szMaxUsed / 1000000.0 ); 111 } 112 113 /***********************************************************************/ 114 /*! 115 * \short Get the times of memory allocation 116 * 117 * \return the times of memory allocation 118 */ 119 /***********************************************************************/ 120 double GetTimesMemAllocation() 121 { 122 return( ( double )( m_uTimesNew ) ); 123 } 124 125 /***************************************************************************/ 126 127 private: 128 129 /** private structure ******************************************************/ 130 131 //! record of memory tracing 132 typedef struct _SMemoryRecord 133 { 134 //! indicates the file which calls new 135 std::string strFileNameNew; 136 137 //! indicates the line where new is called 138 int nLineNew; 139 140 //! the size to be newed 141 size_t szSize; 142 143 //! whether allocated by new [] 144 bool bArray; 145 146 //! indicates the file which calls delete 147 std::string strFileNameDel; 148 149 //! indicates the line where delete is called 150 int nLineDel; 151 152 }SMemoryRecord; 153 154 //! statistics of memory allocation from a file 155 typedef struct _SFileMemory 156 { 157 //! indicates the file which calls new 158 std::string strFileNameNew; 159 160 //! max bytes have been allocated from the file 161 size_t szMaxAllocated; 162 163 //! current bytes have been allocated from the file 164 size_t szCurAllocated; 165 166 //! number of allocation from the file 167 uint64_t uTimesNew; 168 169 }SFileMemory; 170 171 /***************************************************************************/ 172 173 /** variable members *******************************************************/ 174 175 //! max bytes have been allocated 176 size_t m_szMaxUsed; 177 178 //! current bytes have been allocated 179 size_t m_szCurUsed; 180 181 //! the times the operator new has been called 182 uint64_t m_uTimesNew; 183 184 //! the times the operator delete has missed (the memory to be deleted was not recorded) 185 uint64_t m_uTimesDelMissed; 186 187 //! max number of elements in m_uTimesNew 188 size_t m_szMaxRecord; 189 190 //! records of new 191 HASH_MAP < size_t , SMemoryRecord > m_MemoryNew; 192 193 //! records of delete 194 HASH_MAP < size_t , SMemoryRecord > m_MemoryDel; 195 196 //! records of new/new[] not paired by proper delete/delete[] 197 HASH_MAP < size_t , SMemoryRecord > m_NotPairedNew; 198 199 //! records of new from a file 200 std::map < std::string , SFileMemory > m_MemoryFileNew; 201 202 /***************************************************************************/ 203 204 /** function members *******************************************************/ 205 206 /***********************************************************************/ 207 /*! 208 * \short Get file name (remove the path info) 209 * 210 * \param pPathFileName, pointer to the file name with path info 211 * \param rFileName, reference to get the file name 212 */ 213 /***********************************************************************/ 214 void xxGetFileName( const char * pPathFileName , std::string & rFileName ) const; 215 216 /***********************************************************************/ 217 /*! 218 * \short Release the records 219 */ 220 /***********************************************************************/ 221 void xxRelease(); 222 223 /***************************************************************************/ 224 225 }; 226 227 } // namespace Utilities 228 /***************************************************************************/ 229 230 231 /** functions **************************************************************/ 232 233 /***************************************************************************/ 234 /*! 235 * \short overload operator new to trace memory 236 * 237 * \param sz, size of memory to be newed 238 * \param pFileName, indicates the file which calls new 239 * \param nLine, indicates the line where new is called 240 * \param bArray, whether with [] 241 * 242 * \return pointer to the allocated memory 243 */ 244 /***************************************************************************/ 245 void * operator new( size_t sz , char * pFileName , int nLine , bool bArray ); 246 void * operator new [] ( size_t sz , char * pFileName , int nLine , bool bArray ); 247 248 /***************************************************************************/ 249 /*! 250 * \short overload operator delete to trace memory 251 * 252 * \param pMemory, pointer to the memory to be deleted 253 * \param pFileName, indicates the file which calls new 254 * \param nLine, indicates the line where new is called 255 * \param bArray, whether with [] 256 * 257 * \return pointer to the allocated memory 258 */ 259 /***************************************************************************/ 260 void operator delete( void * pMemory , char * pFileName , int nLine , bool bArray ); 261 void operator delete [] ( void * pMemory , char * pFileName , int nLine , bool bArray ); 262 263 /***************************************************************************/ 264 /*! 265 * \short template delete function 266 * 267 * \param p, pointer to the object to be deleted 268 * \param pFileName, indicates the file which calls new 269 * \param nLine, indicates the line where new is called 270 * \param bArray, whether with [] 271 */ 272 /***************************************************************************/ 273 template <class T> inline 274 void Delete( T * p , char * pFileName , int nLine , bool bArray ) 275 { 276 { 277 void * pSingle = ( void * )p; 278 void * pArray = ( void * )( ( size_t )( pSingle ) - sizeof( int ) ); 279 extern Utilities::CMemoryTrace gMemoryTrace; 280 281 if( gMemoryTrace.HasBeenAllocated( pSingle ) == true ) 282 { 283 // by normal new 284 285 // call the destructor of the object 286 p->~T(); 287 288 // delete the memory 289 operator delete( pSingle , pFileName , nLine , bArray ); 290 } 291 else if( gMemoryTrace.HasBeenAllocated( pArray ) == true ) 292 { 293 // by new [] 294 295 // get the number of components 296 int nNumber = *( ( int * )pArray ); 297 298 // call the destructor for each object 299 for( ; nNumber > 0 ; nNumber-- , p++ ) 300 p->~T(); 301 302 // delete the memory 303 operator delete [] ( pArray , pFileName , nLine , bArray ); 304 } 305 else 306 { 307 // not recorded memory allocation, do nothing but 308 // save the record by calling DelRecord() 309 gMemoryTrace.DelRecord( p , pFileName , nLine , bArray ); 310 } 311 } 312 } 313 314 /***************************************************************************/ 315 /*! 316 * \short Output the information of memory tracing 317 * 318 * \param fpLog, pointer to log file 319 */ 320 /***************************************************************************/ 321 void OutputMemTraceInfo( FILE * fpLog ); 322 323 /***************************************************************************/ 324 325 /** definitions ************************************************************/ 326 #define MEMNEW new (__FILE__ , __LINE__ , false ) 327 #define MEMNEWARRAY new (__FILE__ , __LINE__ , true ) 328 #define MEMDELETE(p) Delete( ( p ) , __FILE__ , __LINE__ , false ) 329 #define MEMDELETEARRAY(p) Delete( ( p ) , __FILE__ , __LINE__ , true ) 330 #define MEMTRACEINFO(p) OutputMemTraceInfo(p) 331 /***************************************************************************/ 332 333 #else 334 335 /** definitions ************************************************************/ 336 // use default new and delete 337 #define MEMNEW new 338 #define MEMNEWARRAY new 339 #define MEMDELETE(p) delete (p) 340 #define MEMDELETEARRAY(p) delete [] (p) 341 #define MEMTRACEINFO(p) {} // do nothing 342 /***************************************************************************/ 343 344 #endif // CTRL_USE_TRACEMEM 345 346 /***************************************************************************/ 347 /*! 348 * \short Get how much memory (peak value) has been allocated 349 * 350 * \return memory in MBytes 351 */ 352 /***************************************************************************/ 353 double GetMaxMBMemAllocated(); 354 355 /***************************************************************************/ 356 /*! 357 * \short Get how many times the memory allocation has been called 358 * 359 * \return the times of memory allocation 360 */ 361 /***************************************************************************/ 362 double GetTimesMemAllocation(); 363 364 #endif //__TOOL_TRACEMEM_H__ 365 366 /**************************************************************************** 367 end-of-file 368 ****************************************************************************/ -
source/Lib/TLibDecoder/TDecBinCoderPIPE.cpp
35 35 36 36 #include "TDecBinCoderPIPE.h" 37 37 38 #include "../TLibCommon/tool_tracemem.h" 38 39 39 40 #if PIPE_LOW_DELAY_OPTION 40 41 V2VDecoder::V2VDecoder( const UInt uiPIPEId, UInt* puiMaxDelayBitCounter ) … … 117 118 for( UInt uiIdx = 0; uiIdx < NUM_V2V_CODERS; uiIdx++ ) 118 119 { 119 120 #if PIPE_LOW_DELAY_OPTION 120 m_apcV2VDecoders[ uiIdx ] = newV2VDecoder( uiIdx, &m_uiMaxDelayBitCounter );121 m_apcV2VDecoders[ uiIdx ] = MEMNEW V2VDecoder( uiIdx, &m_uiMaxDelayBitCounter ); 121 122 #else 122 m_apcV2VDecoders[ uiIdx ] = newV2VDecoder( uiIdx );123 m_apcV2VDecoders[ uiIdx ] = MEMNEW V2VDecoder( uiIdx ); 123 124 #endif 124 125 } 125 126 } … … 128 129 { 129 130 for( UInt uiIdx = 0; uiIdx < NUM_V2V_CODERS; uiIdx++ ) 130 131 { 131 delete m_apcV2VDecoders[ uiIdx ];132 MEMDELETE( m_apcV2VDecoders[ uiIdx ] ); 132 133 } 133 134 } 134 135 -
source/Lib/TLibDecoder/TDecBinCoderV2VwLB.h
43 43 #include "TDecBinCoder.h" 44 44 #include "TDecV2VTrees.h" 45 45 46 #include "../TLibCommon/tool_tracemem.h" 47 46 48 class TDecClearBit : public TDecBinIf { 47 49 48 50 public: … … 170 172 virtual Void decodeBinTrm ( UInt& bit ) { bit = retrieveBit(mergedStatesMapping[62]); } 171 173 172 174 public: 173 TDecClearBuffer() { temp_space = newUChar[TEMP_SIZE]; }174 ~TDecClearBuffer() { delete [] temp_space; }175 TDecClearBuffer() { temp_space = MEMNEWARRAY UChar[TEMP_SIZE]; } 176 ~TDecClearBuffer() { MEMDELETEARRAY( temp_space ); } 175 177 176 178 }; 177 179 -
source/Lib/TLibDecoder/TDecCu.cpp
35 35 36 36 #include "TDecCu.h" 37 37 38 #include "../TLibCommon/tool_tracemem.h" 39 38 40 // ==================================================================================================================== 39 41 // Constructor / destructor / create / destroy 40 42 // ==================================================================================================================== … … 65 67 { 66 68 m_uiMaxDepth = uiMaxDepth+1; 67 69 68 m_ppcYuvResi = newTComYuv*[m_uiMaxDepth-1];69 m_ppcYuvReco = newTComYuv*[m_uiMaxDepth-1];70 m_ppcCU = newTComDataCU*[m_uiMaxDepth-1];70 m_ppcYuvResi = MEMNEWARRAY TComYuv*[m_uiMaxDepth-1]; 71 m_ppcYuvReco = MEMNEWARRAY TComYuv*[m_uiMaxDepth-1]; 72 m_ppcCU = MEMNEWARRAY TComDataCU*[m_uiMaxDepth-1]; 71 73 72 74 UInt uiNumPartitions; 73 75 for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ ) … … 76 78 UInt uiWidth = uiMaxWidth >> ui; 77 79 UInt uiHeight = uiMaxHeight >> ui; 78 80 79 m_ppcYuvResi[ui] = newTComYuv; m_ppcYuvResi[ui]->create( uiWidth, uiHeight );80 m_ppcYuvReco[ui] = newTComYuv; m_ppcYuvReco[ui]->create( uiWidth, uiHeight );81 m_ppcCU [ui] = newTComDataCU; m_ppcCU [ui]->create( uiNumPartitions, uiWidth, uiHeight, true );81 m_ppcYuvResi[ui] = MEMNEW TComYuv; m_ppcYuvResi[ui]->create( uiWidth, uiHeight ); 82 m_ppcYuvReco[ui] = MEMNEW TComYuv; m_ppcYuvReco[ui]->create( uiWidth, uiHeight ); 83 m_ppcCU [ui] = MEMNEW TComDataCU; m_ppcCU [ui]->create( uiNumPartitions, uiWidth, uiHeight, true ); 82 84 } 83 85 84 86 // initialize partition order. … … 94 96 { 95 97 for ( UInt ui = 0; ui < m_uiMaxDepth-1; ui++ ) 96 98 { 97 m_ppcYuvResi[ui]->destroy(); delete m_ppcYuvResi[ui]; m_ppcYuvResi[ui] = NULL;98 m_ppcYuvReco[ui]->destroy(); delete m_ppcYuvReco[ui]; m_ppcYuvReco[ui] = NULL;99 m_ppcCU [ui]->destroy(); delete m_ppcCU [ui]; m_ppcCU [ui] = NULL;99 m_ppcYuvResi[ui]->destroy(); MEMDELETE( m_ppcYuvResi[ui] ); m_ppcYuvResi[ui] = NULL; 100 m_ppcYuvReco[ui]->destroy(); MEMDELETE( m_ppcYuvReco[ui] ); m_ppcYuvReco[ui] = NULL; 101 m_ppcCU [ui]->destroy(); MEMDELETE( m_ppcCU [ui] ); m_ppcCU [ui] = NULL; 100 102 } 101 103 102 delete [] m_ppcYuvResi; m_ppcYuvResi = NULL;103 delete [] m_ppcYuvReco; m_ppcYuvReco = NULL;104 delete [] m_ppcCU; m_ppcCU = NULL;104 MEMDELETEARRAY( m_ppcYuvResi ); m_ppcYuvResi = NULL; 105 MEMDELETEARRAY( m_ppcYuvReco ); m_ppcYuvReco = NULL; 106 MEMDELETEARRAY( m_ppcCU ); m_ppcCU = NULL; 105 107 } 106 108 107 109 // ==================================================================================================================== -
source/Lib/TLibDecoder/TDecEntropy.cpp
198 198 m_pcEntropyDecoderIf->setMaxAlfCtrlDepth(uiSymbol); 199 199 if( pAlfParam->bSeparateQt ) 200 200 { 201 pAlfParam->pcQuadTree = newTComPicSym();201 pAlfParam->pcQuadTree = MEMNEW TComPicSym(); 202 202 pAlfParam->pcQuadTree->create( pcPic->getPicYuvRec()->getWidth(), pcPic->getPicYuvRec()->getHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); 203 203 for( UInt uiCUAddr = 0; uiCUAddr < pAlfParam->pcQuadTree->getNumberOfCUsInFrame(); uiCUAddr++ ) 204 204 { -
source/Lib/TLibDecoder/TDecGop.cpp
185 185 186 186 Double dDecTime = (double)(clock()-iBeforeTime) / CLOCKS_PER_SEC; 187 187 printf ("[DT %6.3f] ", dDecTime ); 188 printf( "[MA %.1lf MB, %.1lf KTimes] " , GetMaxMBMemAllocated() , GetTimesMemAllocation() / 1000 ); 188 189 189 190 for (Int iRefList = 0; iRefList < 2; iRefList++) 190 191 { -
source/Lib/TLibDecoder/TDecSlice.cpp
35 35 36 36 #include "TDecSlice.h" 37 37 38 #include "../TLibCommon/tool_tracemem.h" 39 38 40 ////////////////////////////////////////////////////////////////////// 39 41 // Construction/Destruction 40 42 ////////////////////////////////////////////////////////////////////// … … 60 62 { 61 63 if(m_apcVirtPic[j][i] == NULL) 62 64 { 63 m_apcVirtPic[j][i] = newTComPic;65 m_apcVirtPic[j][i] = MEMNEW TComPic; 64 66 m_apcVirtPic[j][i]->create( iWidth, iHeight, uiMaxWidth, uiMaxHeight, uiMaxDepth, true ); 65 67 } 66 68 } … … 75 77 if(m_apcVirtPic[j][i]) 76 78 { 77 79 m_apcVirtPic[j][i]->destroy(); 78 delete m_apcVirtPic[j][i];80 MEMDELETE( m_apcVirtPic[j][i] ); 79 81 m_apcVirtPic[j][i]=NULL; 80 82 } 81 83 } -
source/Lib/TLibDecoder/TDecTop.cpp
35 35 36 36 #include "TDecTop.h" 37 37 38 #include "../TLibCommon/tool_tracemem.h" 39 38 40 TDecTop::TDecTop() 39 41 { 40 42 m_iGopSize = 0; … … 62 64 Void TDecTop::create() 63 65 { 64 66 m_cGopDecoder.create(); 65 m_apcSlicePilot = newTComSlice;67 m_apcSlicePilot = MEMNEW TComSlice; 66 68 } 67 69 68 70 Void TDecTop::destroy() 69 71 { 70 72 m_cGopDecoder.destroy(); 71 73 72 delete m_apcSlicePilot;74 MEMDELETE( m_apcSlicePilot ); 73 75 m_apcSlicePilot = NULL; 74 76 75 77 m_cSliceDecoder.destroy(); … … 95 97 TComPic* pcPic = *(iterPic++); 96 98 pcPic->destroy(); 97 99 98 delete pcPic;100 MEMDELETE( pcPic ); 99 101 pcPic = NULL; 100 102 } 101 103 … … 129 131 130 132 if (m_cListPic.size() < (UInt)m_iMaxRefPicNum) 131 133 { 132 rpcPic = newTComPic;134 rpcPic = MEMNEW TComPic; 133 135 134 136 rpcPic->create ( pcSlice->getSPS()->getWidth(), pcSlice->getSPS()->getHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, true); 135 137 m_cListPic.pushBack( rpcPic ); -
source/Lib/TLibEncoder/TEncAdaptiveLoopFilter.cpp
38 38 #include <stdio.h> 39 39 #include <math.h> 40 40 41 #include "../TLibCommon/tool_tracemem.h" 42 41 43 // ==================================================================================================================== 42 44 // Constants 43 45 // ==================================================================================================================== … … 77 79 { 78 80 m_pcPic = pcPic; 79 81 m_pcEntropyCoder = pcEntropyCoder; 80 m_pcCoderFixedBits = newTComBitCounter;82 m_pcCoderFixedBits = MEMNEW TComBitCounter; 81 83 m_pcEntropyCoder->setBitstream( m_pcCoderFixedBits ); 82 84 m_pppcRDSbacCoder = pppcRDSbacCoder; 83 85 m_pcRDGoOnSbacCoder = pcRDGoOnSbacCoder; … … 105 107 Int iWidth = pcPic->getPicYuvOrg()->getWidth(); 106 108 Int iHeight = pcPic->getPicYuvOrg()->getHeight(); 107 109 108 m_pcPicYuvTmp = newTComPicYuv();110 m_pcPicYuvTmp = MEMNEW TComPicYuv(); 109 111 m_pcPicYuvTmp->create(iWidth, iHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth); 110 112 111 m_pcPicYuvFiltered = newTComPicYuv();113 m_pcPicYuvFiltered = MEMNEW TComPicYuv(); 112 114 m_pcPicYuvFiltered->create(iWidth, iHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth); 113 115 114 116 m_pcPicYuvBest = pcPic->getPicYuvPred(); 115 117 116 m_pcBestAlfParam = newALFParam;117 m_pcTempAlfParam = newALFParam;118 m_pcBestAlfParam = MEMNEW ALFParam; 119 m_pcTempAlfParam = MEMNEW ALFParam; 118 120 allocALFParam(m_pcBestAlfParam); 119 121 allocALFParam(m_pcTempAlfParam); 120 122 } … … 125 127 xUninitParam(); 126 128 127 129 m_pcPicYuvFiltered->destroy() ; 128 delete m_pcPicYuvFiltered;130 MEMDELETE( m_pcPicYuvFiltered ) ; 129 131 130 132 m_pcPicYuvTmp->destroy(); 131 delete m_pcPicYuvTmp;133 MEMDELETE( m_pcPicYuvTmp ) ; 132 134 // m_pcPicYuvTmp = NULL; 133 135 m_pcPic = NULL; 134 136 m_pcEntropyCoder = NULL; 135 delete m_pcCoderFixedBits;137 MEMDELETE( m_pcCoderFixedBits ); 136 138 137 139 freeALFParam(m_pcBestAlfParam); 138 140 freeALFParam(m_pcTempAlfParam); 139 delete m_pcBestAlfParam;140 delete m_pcTempAlfParam;141 MEMDELETE( m_pcBestAlfParam ) ; 142 MEMDELETE( m_pcTempAlfParam ); 141 143 } 142 144 143 145 /** \param pcAlfParam ALF parameter … … 155 157 TComPicYuv* pcPicOrg = m_pcPic->getPicYuvOrg(); 156 158 TComPicYuv* pcPicYuvRec = m_pcPic->getPicYuvRec(); 157 159 158 TComPicYuv* pcPicYuvFiltered = newTComPicYuv ;160 TComPicYuv* pcPicYuvFiltered = MEMNEW TComPicYuv ; 159 161 pcPicYuvFiltered->create(pcPicOrg->getWidth(), pcPicOrg->getHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ) ; 160 162 161 163 // set min cost … … 229 231 // store best depth 230 232 ruiMaxAlfCtrlDepth = m_pcEntropyCoder->getMaxAlfCtrlDepth(); 231 233 pcPicYuvFiltered->destroy() ; 232 delete pcPicYuvFiltered;234 MEMDELETE( pcPicYuvFiltered ) ; 233 235 } 234 236 235 237 … … 294 296 UInt64 uiDist ; 295 297 Double dCmpCost = rdMinCost; 296 298 297 TComPicYuv* pcTmpPicVerticallyFiltered = newTComPicYuv;298 TComPicYuv* pcTmpPicHorizontallyFiltered = newTComPicYuv;299 TComPicYuv* pcTmpPicVerticallyFiltered = MEMNEW TComPicYuv; 300 TComPicYuv* pcTmpPicHorizontallyFiltered = MEMNEW TComPicYuv; 299 301 300 302 pcTmpPicVerticallyFiltered->create(pcPicOrg->getWidth(), pcPicOrg->getHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth) ; 301 303 pcTmpPicHorizontallyFiltered->create(pcPicOrg->getWidth(), pcPicOrg->getHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth) ; 302 304 303 ALFParam* pcTmpAlfParams = newALFParam ;305 ALFParam* pcTmpAlfParams = MEMNEW ALFParam ; 304 306 allocALFParam( pcTmpAlfParams ); 305 307 306 308 for(Int iPrevPlane=0; iPrevPlane<iPlane; iPrevPlane++) … … 337 339 } 338 340 pcTmpPicVerticallyFiltered->destroy() ; 339 341 pcTmpPicHorizontallyFiltered->destroy() ; 340 delete pcTmpPicVerticallyFiltered;341 delete pcTmpPicHorizontallyFiltered;342 MEMDELETE( pcTmpPicVerticallyFiltered ) ; 343 MEMDELETE( pcTmpPicHorizontallyFiltered ) ; 342 344 freeALFParam( pcTmpAlfParams ); 343 delete pcTmpAlfParams;345 MEMDELETE( pcTmpAlfParams ) ; 344 346 } 345 347 346 348 Void TEncAdaptiveLoopFilter::xFilterTapDecision(TComPicYuv* pcPicOrg, TComPicYuv* pcPicDec, TComPicYuv* pcPicFiltered, ALFParam* pcAlfParams, UInt64& ruiMinRate, UInt64& ruiMinDist, Double& rdMinCost, Int iPlane) … … 352 354 // } 353 355 UInt64 uiTmpRate, uiTmpDist; 354 356 Double dTmpCost; 355 TComPicYuv* pcTmpPicVerticallyFiltered = newTComPicYuv;356 TComPicYuv* pcTmpPicHorizontallyFiltered = newTComPicYuv;357 ALFParam* pcTmpAlfParams = newALFParam ;357 TComPicYuv* pcTmpPicVerticallyFiltered = MEMNEW TComPicYuv; 358 TComPicYuv* pcTmpPicHorizontallyFiltered = MEMNEW TComPicYuv; 359 ALFParam* pcTmpAlfParams = MEMNEW ALFParam ; 358 360 allocALFParam( pcTmpAlfParams ); 359 361 360 362 … … 402 404 freeALFParam( pcTmpAlfParams ); 403 405 pcTmpPicHorizontallyFiltered->destroy(); 404 406 pcTmpPicVerticallyFiltered->destroy(); 405 delete pcTmpAlfParams;406 delete pcTmpPicHorizontallyFiltered;407 delete pcTmpPicVerticallyFiltered;407 MEMDELETE( pcTmpAlfParams ); 408 MEMDELETE( pcTmpPicHorizontallyFiltered ) ; 409 MEMDELETE( pcTmpPicVerticallyFiltered ) ; 408 410 409 411 } 410 412 … … 414 416 m_pcEntropyCoder->setAlfCtrl(true); 415 417 UInt uiBestDepth = 0; 416 418 417 ALFParam* pcTmpAlfParam = newALFParam ;419 ALFParam* pcTmpAlfParam = MEMNEW ALFParam ; 418 420 allocALFParam(pcTmpAlfParam); 419 421 copyALFParam(pcTmpAlfParam, pcAlfParam); 420 422 421 ALFParam* pcFrmAlfParam = newALFParam ;423 ALFParam* pcFrmAlfParam = MEMNEW ALFParam ; 422 424 allocALFParam(pcFrmAlfParam); 423 425 copyALFParam(pcFrmAlfParam, pcAlfParam); 424 426 425 TComPicYuv* pcFilteredFrm = newTComPicYuv();427 TComPicYuv* pcFilteredFrm = MEMNEW TComPicYuv(); 426 428 pcFilteredFrm->create(pcPicOrg->getWidth(), pcPicOrg->getHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth); 427 429 pcPicFiltered->copyToPic( pcFilteredFrm ); 428 430 429 TComPicYuv* pcTmpPicVerticallyFiltered = newTComPicYuv;431 TComPicYuv* pcTmpPicVerticallyFiltered = MEMNEW TComPicYuv; 430 432 pcTmpPicVerticallyFiltered->create(pcPicOrg->getWidth(), pcPicOrg->getHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth); 431 TComPicYuv* pcTmpPicHorizontallyFiltered = newTComPicYuv;433 TComPicYuv* pcTmpPicHorizontallyFiltered = MEMNEW TComPicYuv; 432 434 pcTmpPicHorizontallyFiltered->create(pcPicOrg->getWidth(), pcPicOrg->getHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth); 433 435 434 436 TComPicSym* pcQuadTreeBest; … … 436 438 TComPicSym* pcQuadTreeHelp; 437 439 if( m_bALFSeparateQt ) 438 440 { 439 pcQuadTreeBest = newTComPicSym();441 pcQuadTreeBest = MEMNEW TComPicSym(); 440 442 pcQuadTreeBest->create( pcPicDec->getWidth(), pcPicDec->getHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); 441 pcQuadTreeTmp = newTComPicSym();443 pcQuadTreeTmp = MEMNEW TComPicSym(); 442 444 pcQuadTreeTmp->create( pcPicDec->getWidth(), pcPicDec->getHeight(), g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); 443 445 for( UInt uiCUAddr = 0; uiCUAddr < pcQuadTreeBest->getNumberOfCUsInFrame(); uiCUAddr++ ) 444 446 { … … 528 530 if( m_bALFSeparateQt ) 529 531 { 530 532 pcQuadTreeBest->destroy(); 531 delete pcQuadTreeBest;533 MEMDELETE( pcQuadTreeBest ); 532 534 } 533 535 } 534 536 535 537 if( m_bALFSeparateQt) 536 538 { 537 539 pcQuadTreeTmp->destroy(); 538 delete pcQuadTreeTmp;540 MEMDELETE( pcQuadTreeTmp ); 539 541 } 540 542 else 541 543 { … … 543 545 } 544 546 545 547 pcFilteredFrm->destroy(); 546 delete pcFilteredFrm;548 MEMDELETE( pcFilteredFrm ); 547 549 548 550 // 549 551 freeALFParam(pcTmpAlfParam); 550 delete pcTmpAlfParam;552 MEMDELETE( pcTmpAlfParam ); 551 553 freeALFParam(pcFrmAlfParam); 552 delete pcFrmAlfParam;554 MEMDELETE( pcFrmAlfParam ); 553 555 554 556 pcTmpPicVerticallyFiltered->destroy() ; 555 delete pcTmpPicVerticallyFiltered;557 MEMDELETE( pcTmpPicVerticallyFiltered ); 556 558 pcTmpPicHorizontallyFiltered->destroy() ; 557 delete pcTmpPicHorizontallyFiltered;559 MEMDELETE( pcTmpPicHorizontallyFiltered ); 558 560 559 561 } 560 562 … … 578 580 } 579 581 else 580 582 { 581 m_ppdAlfCorr = newDouble*[ALF_MAX_NUM_COEF];583 m_ppdAlfCorr = MEMNEWARRAY Double*[ALF_MAX_NUM_COEF]; 582 584 for (i = 0; i < ALF_MAX_NUM_COEF; i++) 583 585 { 584 m_ppdAlfCorr[i] = newDouble[ALF_MAX_NUM_COEF+1];586 m_ppdAlfCorr[i] = MEMNEWARRAY Double[ALF_MAX_NUM_COEF+1]; 585 587 for (j = 0; j < ALF_MAX_NUM_COEF+1; j++) 586 588 { 587 589 m_ppdAlfCorr[i][j] = 0; … … 607 609 } 608 610 else 609 611 { 610 m_puiCUVerticalCorr = newUInt***[m_pcPic->getNumCUsInFrame()];612 m_puiCUVerticalCorr = MEMNEWARRAY UInt***[m_pcPic->getNumCUsInFrame()]; 611 613 for (i = 0; i < m_pcPic->getNumCUsInFrame(); i++) 612 614 { 613 m_puiCUVerticalCorr[i] = newUInt**[m_uiNumSCUInCU];615 m_puiCUVerticalCorr[i] = MEMNEWARRAY UInt**[m_uiNumSCUInCU]; 614 616 for (j = 0; j < m_uiNumSCUInCU; j++) 615 617 { 616 m_puiCUVerticalCorr[i][j] = newUInt*[ALF_MAX_NUM_COEF];618 m_puiCUVerticalCorr[i][j] = MEMNEWARRAY UInt*[ALF_MAX_NUM_COEF]; 617 619 for (k = 0; k < ALF_MAX_NUM_COEF; k++) 618 620 { 619 m_puiCUVerticalCorr[i][j][k] = newUInt[ALF_MAX_NUM_COEF+1];621 m_puiCUVerticalCorr[i][j][k] = MEMNEWARRAY UInt[ALF_MAX_NUM_COEF+1]; 620 622 for (l = 0; l< ALF_MAX_NUM_COEF+1; l++) 621 623 { 622 624 m_puiCUVerticalCorr[i][j][k][l] = 0; … … 645 647 } 646 648 else 647 649 { 648 m_puiCUHorizontalCorr = newUInt***[m_pcPic->getNumCUsInFrame()];650 m_puiCUHorizontalCorr = MEMNEWARRAY UInt***[m_pcPic->getNumCUsInFrame()]; 649 651 for (i = 0; i < m_pcPic->getNumCUsInFrame(); i++) 650 652 { 651 m_puiCUHorizontalCorr[i] = newUInt**[m_uiNumSCUInCU];653 m_puiCUHorizontalCorr[i] = MEMNEWARRAY UInt**[m_uiNumSCUInCU]; 652 654 for (j = 0; j < m_uiNumSCUInCU; j++) 653 655 { 654 m_puiCUHorizontalCorr[i][j] = newUInt*[ALF_MAX_NUM_COEF];656 m_puiCUHorizontalCorr[i][j] = MEMNEWARRAY UInt*[ALF_MAX_NUM_COEF]; 655 657 for (k = 0; k < ALF_MAX_NUM_COEF; k++) 656 658 { 657 m_puiCUHorizontalCorr[i][j][k] = newUInt[ALF_MAX_NUM_COEF+1];659 m_puiCUHorizontalCorr[i][j][k] = MEMNEWARRAY UInt[ALF_MAX_NUM_COEF+1]; 658 660 for (l = 0; l< ALF_MAX_NUM_COEF+1; l++) 659 661 { 660 662 m_puiCUHorizontalCorr[i][j][k][l] = 0; … … 674 676 } 675 677 else 676 678 { 677 m_pdDoubleAlfCoeff = newDouble[ALF_MAX_NUM_COEF];679 m_pdDoubleAlfCoeff = MEMNEWARRAY Double[ALF_MAX_NUM_COEF]; 678 680 for (i = 0; i < ALF_MAX_NUM_COEF; i++) 679 681 { 680 682 m_pdDoubleAlfCoeff[i] = 0; … … 690 692 { 691 693 for (i = 0; i < ALF_MAX_NUM_COEF; i++) 692 694 { 693 delete[] m_ppdAlfCorr[i];695 MEMDELETEARRAY( m_ppdAlfCorr[i] ); 694 696 m_ppdAlfCorr[i] = NULL; 695 697 } 696 delete[] m_ppdAlfCorr;698 MEMDELETEARRAY( m_ppdAlfCorr ); 697 699 m_ppdAlfCorr = NULL; 698 700 } 699 701 … … 705 707 { 706 708 for (k = 0; k < ALF_MAX_NUM_COEF; k++) 707 709 { 708 delete[] m_puiCUVerticalCorr[i][j][k];710 MEMDELETEARRAY( m_puiCUVerticalCorr[i][j][k] ); 709 711 m_puiCUVerticalCorr[i][j][k] = NULL; 710 712 } 711 delete[] m_puiCUVerticalCorr[i][j];713 MEMDELETEARRAY( m_puiCUVerticalCorr[i][j] ); 712 714 m_puiCUVerticalCorr[i][j] = NULL; 713 715 } 714 delete[] m_puiCUVerticalCorr[i];716 MEMDELETEARRAY( m_puiCUVerticalCorr[i] ); 715 717 m_puiCUVerticalCorr[i] = NULL; 716 718 } 717 delete[] m_puiCUVerticalCorr;719 MEMDELETEARRAY( m_puiCUVerticalCorr ); 718 720 m_puiCUVerticalCorr = NULL; 719 721 } 720 722 … … 726 728 { 727 729 for (k = 0; k < ALF_MAX_NUM_COEF; k++) 728 730 { 729 delete[] m_puiCUHorizontalCorr[i][j][k];731 MEMDELETEARRAY( m_puiCUHorizontalCorr[i][j][k] ); 730 732 m_puiCUHorizontalCorr[i][j][k] = NULL; 731 733 } 732 delete[] m_puiCUHorizontalCorr[i][j];734 MEMDELETEARRAY( m_puiCUHorizontalCorr[i][j] ); 733 735 m_puiCUHorizontalCorr[i][j] = NULL; 734 736 } 735 delete[] m_puiCUHorizontalCorr[i];737 MEMDELETEARRAY( m_puiCUHorizontalCorr[i] ); 736 738 m_puiCUHorizontalCorr[i] = NULL; 737 739 } 738 delete[] m_puiCUHorizontalCorr;740 MEMDELETEARRAY( m_puiCUHorizontalCorr ); 739 741 m_puiCUHorizontalCorr = NULL; 740 742 } 741 743 742 744 743 745 if (m_pdDoubleAlfCoeff != NULL) 744 746 { 745 delete[] m_pdDoubleAlfCoeff;747 MEMDELETEARRAY( m_pdDoubleAlfCoeff ); 746 748 m_pdDoubleAlfCoeff = NULL; 747 749 } 748 750 } … … 1054 1056 1055 1057 Int* aiQuantCoeffs = rcFilter.aiQuantFilterCoeffs; 1056 1058 1057 Double* adDelta = newDouble[ iNumCoeffs+1 ];1058 Int* aiPosIndx = newInt [ iNumCoeffs+1 ];1059 Double* adDelta = MEMNEWARRAY Double[ iNumCoeffs+1 ]; 1060 Int* aiPosIndx = MEMNEWARRAY Int [ iNumCoeffs+1 ]; 1059 1061 1060 1062 1061 1063 dGainNotQuant = 0.0; … … 1120 1122 aiQuantCoeffs[i] = Max( iMinValue , Min( iMaxValue , aiQuantCoeffs[i] ) ); 1121 1123 } 1122 1124 1123 delete[] adDelta;1125 MEMDELETEARRAY( adDelta ); 1124 1126 adDelta = NULL; 1125 1127 1126 delete[] aiPosIndx;1128 MEMDELETEARRAY( aiPosIndx ); 1127 1129 aiPosIndx = NULL; 1128 1130 } 1129 1131 … … 1139 1141 { 1140 1142 if(pAlfParam != NULL) 1141 1143 { 1142 ALFParam* pcTempAlfParams = newALFParam ;1144 ALFParam* pcTempAlfParams = MEMNEW ALFParam ; 1143 1145 allocALFParam( pcTempAlfParams ); 1144 1146 copyALFParam(pcTempAlfParams, pAlfParam); 1145 1147 xPredictALFCoeff(pcTempAlfParams, 0 ); … … 1153 1155 1154 1156 m_pcEntropyCoder->encodeAlfParam( pcTempAlfParams ); 1155 1157 freeALFParam( pcTempAlfParams ); 1156 delete pcTempAlfParams;1158 MEMDELETE( pcTempAlfParams ); 1157 1159 ruiRate = m_pcEntropyCoder->getNumberOfWrittenBits(); 1158 1160 } 1159 1161 else … … 1167 1169 { 1168 1170 if(pAlfParam != NULL) 1169 1171 { 1170 ALFParam* pcTempAlfParams = newALFParam ;1172 ALFParam* pcTempAlfParams = MEMNEW ALFParam ; 1171 1173 allocALFParam( pcTempAlfParams ); 1172 1174 copyALFParam(pcTempAlfParams, pAlfParam); 1173 1175 xPredictALFCoeff(pcTempAlfParams, iPlane ); … … 1175 1177 m_pcEntropyCoder->resetBits(); 1176 1178 m_pcEntropyCoder->encodeAlfParam(pcTempAlfParams); 1177 1179 freeALFParam( pcTempAlfParams ); 1178 delete pcTempAlfParams;1180 MEMDELETE( pcTempAlfParams ); 1179 1181 1180 1182 if(pAlfParam->cu_control_flag) 1181 1183 { … … 1400 1402 } 1401 1403 UInt64* auiFixedBitsCurrBest; 1402 1404 UInt64* auiFixedBitsNextBest; 1403 auiFixedBitsCurrBest = newUInt64[MAX_CU_DEPTH];1404 auiFixedBitsNextBest = newUInt64[MAX_CU_DEPTH];1405 auiFixedBitsCurrBest = MEMNEWARRAY UInt64[MAX_CU_DEPTH]; 1406 auiFixedBitsNextBest = MEMNEWARRAY UInt64[MAX_CU_DEPTH]; 1405 1407 ::memset( auiFixedBitsCurrBest , 0 , sizeof(UInt64) * MAX_CU_DEPTH ); 1406 1408 ::memset( auiFixedBitsNextBest , 0 , sizeof(UInt64) * MAX_CU_DEPTH ); 1407 1409 for( UInt uiCUAddr = 0; uiCUAddr < pcQuadTree->getNumberOfCUsInFrame() ; uiCUAddr++ ) … … 1420 1422 m_pcRDGoOnSbacCoder->load( m_pppcRDSbacCoder[0][CI_NEXT_BEST] ); 1421 1423 } 1422 1424 ruiRate = auiFixedBitsNextBest[0] + m_pcEntropyCoder->getNumberOfWrittenBits() ; 1423 delete[] auiFixedBitsCurrBest;1424 delete[] auiFixedBitsNextBest;1425 MEMDELETEARRAY( auiFixedBitsCurrBest ); 1426 MEMDELETEARRAY( auiFixedBitsNextBest ); 1425 1427 } 1426 1428 else 1427 1429 { … … 1973 1975 Int iWidth = pcPic->getPicYuvOrg()->getWidth(); 1974 1976 Int iHeight = pcPic->getPicYuvOrg()->getHeight(); 1975 1977 1976 m_pcPicYuvTmp = newTComPicYuv();1978 m_pcPicYuvTmp = MEMNEW TComPicYuv(); 1977 1979 m_pcPicYuvTmp->createLuma(iWidth, iHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth); 1978 1980 m_pcPicYuvBest = pcPic->getPicYuvPred(); 1979 1981 1980 m_pcBestAlfParam = newALFParam;1981 m_pcTempAlfParam = newALFParam;1982 m_pcBestAlfParam = MEMNEW ALFParam; 1983 m_pcTempAlfParam = MEMNEW ALFParam; 1982 1984 allocALFParam(m_pcBestAlfParam); 1983 1985 allocALFParam(m_pcTempAlfParam); 1984 1986 #if QC_ALF … … 2005 2007 get_mem2Dpel(&maskImg, im_height, im_width); 2006 2008 2007 2009 // InitALFGlobalBuffers (iWidth, iHeight); 2008 ALFp = newALFParam;2009 tempALFp = newALFParam;2010 ALFp = MEMNEW ALFParam; 2011 tempALFp = MEMNEW ALFParam; 2010 2012 allocALFParam(ALFp); 2011 2013 allocALFParam(tempALFp); 2012 2014 m_pcDummyEntropyCoder = m_pcEntropyCoder; … … 2019 2021 xDestroyTmpAlfCtrlFlags(); 2020 2022 2021 2023 m_pcPicYuvTmp->destroyLuma(); 2022 delete m_pcPicYuvTmp;2024 MEMDELETE( m_pcPicYuvTmp ); 2023 2025 m_pcPicYuvTmp = NULL; 2024 2026 m_pcPic = NULL; 2025 2027 m_pcEntropyCoder = NULL; 2026 2028 2027 2029 freeALFParam(m_pcBestAlfParam); 2028 2030 freeALFParam(m_pcTempAlfParam); 2029 delete m_pcBestAlfParam;2030 delete m_pcTempAlfParam;2031 MEMDELETE( m_pcBestAlfParam ); 2032 MEMDELETE( m_pcTempAlfParam ); 2031 2033 #if QC_ALF 2032 2034 free_mem2Dpel (imgY_rec); 2033 2035 free_mem2Dpel (imgY_org); … … 2050 2052 // FreeALFGlobalBurrers(); 2051 2053 freeALFParam(ALFp); 2052 2054 freeALFParam(tempALFp); 2053 delete ALFp;2054 delete tempALFp;2055 MEMDELETE( ALFp ); 2056 MEMDELETE( tempALFp ); 2055 2057 #endif 2056 2058 } 2057 2059 … … 2442 2444 } 2443 2445 else 2444 2446 { 2445 m_ppdAlfCorr = newDouble*[ALF_MAX_NUM_COEF];2447 m_ppdAlfCorr = MEMNEWARRAY Double*[ALF_MAX_NUM_COEF]; 2446 2448 for (i = 0; i < ALF_MAX_NUM_COEF; i++) 2447 2449 { 2448 m_ppdAlfCorr[i] = newDouble[ALF_MAX_NUM_COEF+1];2450 m_ppdAlfCorr[i] = MEMNEWARRAY Double[ALF_MAX_NUM_COEF+1]; 2449 2451 for (j = 0; j < ALF_MAX_NUM_COEF+1; j++) 2450 2452 { 2451 2453 m_ppdAlfCorr[i][j] = 0; … … 2471 2473 } 2472 2474 else 2473 2475 { 2474 m_puiCUCorr = newCorrBlk*[m_pcPic->getNumCUsInFrame()];2476 m_puiCUCorr = MEMNEWARRAY CorrBlk*[m_pcPic->getNumCUsInFrame()]; 2475 2477 for (i = 0; i < m_pcPic->getNumCUsInFrame(); i++) 2476 2478 { 2477 m_puiCUCorr[i] = newCorrBlk[m_uiNumSCUInCU];2479 m_puiCUCorr[i] = MEMNEWARRAY CorrBlk[m_uiNumSCUInCU]; 2478 2480 2479 2481 for (j = 0; j < m_uiNumSCUInCU; j++) 2480 2482 { … … 2498 2500 } 2499 2501 else 2500 2502 { 2501 m_pdDoubleAlfCoeff = newDouble[ALF_MAX_NUM_COEF];2503 m_pdDoubleAlfCoeff = MEMNEWARRAY Double[ALF_MAX_NUM_COEF]; 2502 2504 for (i = 0; i < ALF_MAX_NUM_COEF; i++) 2503 2505 { 2504 2506 m_pdDoubleAlfCoeff[i] = 0; … … 2514 2516 { 2515 2517 for (i = 0; i < ALF_MAX_NUM_COEF; i++) 2516 2518 { 2517 delete[] m_ppdAlfCorr[i];2519 MEMDELETEARRAY( m_ppdAlfCorr[i] ); 2518 2520 m_ppdAlfCorr[i] = NULL; 2519 2521 } 2520 delete[] m_ppdAlfCorr;2522 MEMDELETEARRAY( m_ppdAlfCorr ); 2521 2523 m_ppdAlfCorr = NULL; 2522 2524 } 2523 2525 … … 2525 2527 { 2526 2528 for (i = 0; i < m_pcPic->getNumCUsInFrame(); i++) 2527 2529 { 2528 delete[] m_puiCUCorr[i];2530 MEMDELETEARRAY( m_puiCUCorr[i] ); 2529 2531 m_puiCUCorr[i] = NULL; 2530 2532 } 2531 delete[] m_puiCUCorr;2533 MEMDELETEARRAY( m_puiCUCorr ); 2532 2534 m_puiCUCorr = NULL; 2533 2535 } 2534 2536 2535 2537 if (m_pdDoubleAlfCoeff != NULL) 2536 2538 { 2537 delete[] m_pdDoubleAlfCoeff;2539 MEMDELETEARRAY( m_pdDoubleAlfCoeff ); 2538 2540 m_pdDoubleAlfCoeff = NULL; 2539 2541 } 2540 2542 } … … 2705 2707 break; 2706 2708 } 2707 2709 2708 UInt* pTerm = newUInt[N];2710 UInt* pTerm = MEMNEWARRAY UInt[N]; 2709 2711 2710 2712 Int i, j; 2711 2713 … … 2740 2742 } 2741 2743 } 2742 2744 2743 delete[] pTerm;2745 MEMDELETEARRAY( pTerm ); 2744 2746 pTerm = NULL; 2745 2747 } 2746 2748 … … 2771 2773 break; 2772 2774 } 2773 2775 2774 Pel* pTerm = newPel[N];2776 Pel* pTerm = MEMNEWARRAY Pel[N]; 2775 2777 2776 2778 Int i, j; 2777 2779 … … 2812 2814 for(i=j+1; i<N; i++) 2813 2815 m_ppdAlfCorr[i][j] = m_ppdAlfCorr[j][i]; 2814 2816 2815 delete[] pTerm;2817 MEMDELETEARRAY( pTerm ); 2816 2818 pTerm = NULL; 2817 2819 } 2818 2820 … … 2843 2845 break; 2844 2846 } 2845 2847 2846 Pel* pTerm = newPel[N];2848 Pel* pTerm = MEMNEWARRAY Pel[N]; 2847 2849 2848 2850 Int i, j; 2849 2851 … … 2880 2882 } 2881 2883 } 2882 2884 2883 delete[] pTerm;2885 MEMDELETEARRAY( pTerm ); 2884 2886 pTerm = NULL; 2885 2887 } 2886 2888 … … 2998 3000 2999 3001 N = (tap*tap+1)>>1; 3000 3002 3001 dh = newDouble[N];3002 nc = newInt[N];3003 dh = MEMNEWARRAY Double[N]; 3004 nc = MEMNEWARRAY Int[N]; 3003 3005 3004 3006 max_value = (1<<(1+ALF_NUM_BIT_SHIFT))-1; 3005 3007 min_value = 0-(1<<(1+ALF_NUM_BIT_SHIFT)); … … 3087 3089 qh[N] = (h[N]>=0.0)? (Int)( h[N]*(1<<(ALF_NUM_BIT_SHIFT-bit_depth+8)) + 0.5) : -(Int)(-h[N]*(1<<(ALF_NUM_BIT_SHIFT-bit_depth+8)) + 0.5); 3088 3090 qh[N] = Max(min_value,Min(max_value, qh[N])); 3089 3091 3090 delete[] dh;3092 MEMDELETEARRAY( dh ); 3091 3093 dh = NULL; 3092 3094 3093 delete[] nc;3095 MEMDELETEARRAY( nc ); 3094 3096 nc = NULL; 3095 3097 } 3096 3098 … … 3108 3110 if(pAlfParam != NULL) 3109 3111 { 3110 3112 Int* piTmpCoef; 3111 piTmpCoef = newInt[ALF_MAX_NUM_COEF];3113 piTmpCoef = MEMNEWARRAY Int[ALF_MAX_NUM_COEF]; 3112 3114 3113 3115 memcpy(piTmpCoef, pAlfParam->coeff, sizeof(Int)*pAlfParam->num_coeff); 3114 3116 … … 3124 3126 } 3125 3127 ruiRate = m_pcEntropyCoder->getNumberOfWrittenBits(); 3126 3128 memcpy(pAlfParam->coeff, piTmpCoef, sizeof(int)*pAlfParam->num_coeff); 3127 delete[] piTmpCoef;3129 MEMDELETEARRAY( piTmpCoef ); 3128 3130 piTmpCoef = NULL; 3129 3131 } 3130 3132 else … … 3140 3142 if(pAlfParam != NULL) 3141 3143 { 3142 3144 Int* piTmpCoef; 3143 piTmpCoef = newInt[ALF_MAX_NUM_COEF];3145 piTmpCoef = MEMNEWARRAY Int[ALF_MAX_NUM_COEF]; 3144 3146 3145 3147 memcpy(piTmpCoef, pAlfParam->coeff, sizeof(Int)*pAlfParam->num_coeff); 3146 3148 … … 3156 3158 } 3157 3159 ruiRate = m_pcEntropyCoder->getNumberOfWrittenBits(); 3158 3160 memcpy(pAlfParam->coeff, piTmpCoef, sizeof(int)*pAlfParam->num_coeff); 3159 delete[] piTmpCoef;3161 MEMDELETEARRAY( piTmpCoef ); 3160 3162 piTmpCoef = NULL; 3161 3163 } 3162 3164 else … … 3173 3175 if(pAlfParam->chroma_idc) 3174 3176 { 3175 3177 Int* piTmpCoef; 3176 piTmpCoef = newInt[ALF_MAX_NUM_COEF_C];3178 piTmpCoef = MEMNEWARRAY Int[ALF_MAX_NUM_COEF_C]; 3177 3179 3178 3180 memcpy(piTmpCoef, pAlfParam->coeff_chroma, sizeof(Int)*pAlfParam->num_coeff_chroma); 3179 3181 … … 3189 3191 } 3190 3192 ruiRate = m_pcEntropyCoder->getNumberOfWrittenBits(); 3191 3193 memcpy(pAlfParam->coeff_chroma, piTmpCoef, sizeof(int)*pAlfParam->num_coeff_chroma); 3192 delete[] piTmpCoef;3194 MEMDELETEARRAY( piTmpCoef ); 3193 3195 piTmpCoef = NULL; 3194 3196 } 3195 3197 ruiDist = 0; -
source/Lib/TLibEncoder/TEncBinCoderPIPE.cpp
35 35 36 36 #include "TEncBinCoderPIPE.h" 37 37 38 #include "../TLibCommon/tool_tracemem.h" 38 39 39 40 #define INVALID UInt(-1) 40 41 … … 88 89 CodewordBuffer::CodewordBuffer() 89 90 : m_pcTComBitIf ( 0 ) 90 91 , m_uiBufferSize ( INIT_CODEWORD_BUFFER_SIZE ) 91 , m_pacCodewordBuffer ( newCBufEntry [ m_uiBufferSize ] )92 , m_pacCodewordBuffer ( MEMNEWARRAY CBufEntry [ m_uiBufferSize ] ) 92 93 #if PIPE_LOW_DELAY_OPTION 93 94 , m_papcV2VEncoders ( 0 ) 94 95 #endif … … 97 98 98 99 CodewordBuffer::~CodewordBuffer() 99 100 { 100 delete [] m_pacCodewordBuffer;101 MEMDELETEARRAY( m_pacCodewordBuffer ); 101 102 } 102 103 103 104 #if PIPE_LOW_DELAY_OPTION … … 190 191 UInt uiNewBufferSize = m_uiBufferSize + m_uiBufferSize; 191 192 UInt uiNewNextWriteIdx = 0; 192 193 UInt uiNewNextReservedIdx = m_uiBufferSize - m_uiNumFreeEntries; 193 CBufEntry* pacNewCodewordBuffer = newCBufEntry [ uiNewBufferSize ];194 CBufEntry* pacNewCodewordBuffer = MEMNEWARRAY CBufEntry [ uiNewBufferSize ]; 194 195 for( UInt uiSrcIdx = m_uiNextWriteIdx, uiDesIdx = uiNewNextWriteIdx; uiDesIdx < uiNewNextReservedIdx; uiDesIdx++, uiSrcIdx = ( uiSrcIdx + 1 ) % m_uiBufferSize ) 195 196 { 196 197 pacNewCodewordBuffer[ uiDesIdx ] = m_pacCodewordBuffer[ uiSrcIdx ]; … … 203 204 { 204 205 pacNewCodewordBuffer[ uiDesIdx ].ucCWLength = 0; 205 206 } 206 delete [] m_pacCodewordBuffer;207 MEMDELETEARRAY( m_pacCodewordBuffer ); 207 208 m_uiNextWriteIdx = uiNewNextWriteIdx; 208 209 m_uiNextReserveIdx = uiNewNextReservedIdx; 209 210 m_uiBufferSize = uiNewBufferSize; … … 241 242 { 242 243 for( UInt uiIdx = 0; uiIdx < NUM_V2V_CODERS; uiIdx++ ) 243 244 { 244 m_apcV2VEncoders[ uiIdx ] = newV2VEncoder( uiIdx, m_cCodewordBuffer );245 m_apcV2VEncoders[ uiIdx ] = MEMNEW V2VEncoder( uiIdx, m_cCodewordBuffer ); 245 246 } 246 247 #if PIPE_LOW_DELAY_OPTION 247 248 m_cCodewordBuffer.initDelay( m_apcV2VEncoders, 0 ); … … 252 253 { 253 254 for( UInt uiIdx = 0; uiIdx < NUM_V2V_CODERS; uiIdx++ ) 254 255 { 255 delete m_apcV2VEncoders[ uiIdx ];256 MEMDELETE( m_apcV2VEncoders[ uiIdx ] ); 256 257 } 257 258 } 258 259 -
source/Lib/TLibEncoder/TEncBinCoderV2VwLB.h
46 46 #include <cstdlib> 47 47 #include <cstring> 48 48 49 #include "../TLibCommon/tool_tracemem.h" 50 49 51 class TEncClearBit : public TEncBinIf { 50 52 51 53 public: … … 132 134 133 135 public: 134 136 TEncClearBuffer() { 135 buffer = newparallel_buffer[BUFFER_SIZE];136 temp_space = newUChar[TEMP_SIZE];137 buffer = MEMNEWARRAY parallel_buffer[BUFFER_SIZE]; 138 temp_space = MEMNEWARRAY UChar[TEMP_SIZE]; 137 139 init(); 138 140 } 139 141 140 142 virtual ~TEncClearBuffer() { 141 delete [] temp_space;142 delete [] buffer;143 MEMDELETEARRAY( temp_space ); 144 MEMDELETEARRAY( buffer ); 143 145 } 144 146 145 147 Void setState ( UInt* pui ) { memcpy( m_uiState, pui, sizeof(UInt) * StateCount ); } … … 173 175 virtual void groupStates(); 174 176 175 177 public: 176 TEncV2V() { LB_temp_space = newUChar[TEMP_SIZE]; }177 ~TEncV2V() { delete [] LB_temp_space; }178 TEncV2V() { LB_temp_space = MEMNEWARRAY UChar[TEMP_SIZE]; } 179 ~TEncV2V() { MEMDELETEARRAY( LB_temp_space ); } 178 180 }; 179 181 180 182 #endif -
source/Lib/TLibEncoder/TEncCu.cpp
38 38 #include "TEncCu.h" 39 39 #include "TEncAnalyze.h" 40 40 41 #include "../TLibCommon/tool_tracemem.h" 42 41 43 // ==================================================================================================================== 42 44 // Constructor / destructor / create / destroy 43 45 // ==================================================================================================================== … … 51 53 Int i; 52 54 53 55 m_uhTotalDepth = uhTotalDepth + 1; 54 m_ppcBestCU = newTComDataCU*[m_uhTotalDepth-1];55 m_ppcTempCU = newTComDataCU*[m_uhTotalDepth-1];56 m_ppcBestCU = MEMNEWARRAY TComDataCU*[m_uhTotalDepth-1]; 57 m_ppcTempCU = MEMNEWARRAY TComDataCU*[m_uhTotalDepth-1]; 56 58 57 m_ppcPredYuvBest = newTComYuv*[m_uhTotalDepth-1];58 m_ppcResiYuvBest = newTComYuv*[m_uhTotalDepth-1];59 m_ppcRecoYuvBest = newTComYuv*[m_uhTotalDepth-1];60 m_ppcPredYuvTemp = newTComYuv*[m_uhTotalDepth-1];61 m_ppcResiYuvTemp = newTComYuv*[m_uhTotalDepth-1];62 m_ppcRecoYuvTemp = newTComYuv*[m_uhTotalDepth-1];63 m_ppcOrigYuv = newTComYuv*[m_uhTotalDepth-1];59 m_ppcPredYuvBest = MEMNEWARRAY TComYuv*[m_uhTotalDepth-1]; 60 m_ppcResiYuvBest = MEMNEWARRAY TComYuv*[m_uhTotalDepth-1]; 61 m_ppcRecoYuvBest = MEMNEWARRAY TComYuv*[m_uhTotalDepth-1]; 62 m_ppcPredYuvTemp = MEMNEWARRAY TComYuv*[m_uhTotalDepth-1]; 63 m_ppcResiYuvTemp = MEMNEWARRAY TComYuv*[m_uhTotalDepth-1]; 64 m_ppcRecoYuvTemp = MEMNEWARRAY TComYuv*[m_uhTotalDepth-1]; 65 m_ppcOrigYuv = MEMNEWARRAY TComYuv*[m_uhTotalDepth-1]; 64 66 65 67 UInt uiNumPartitions; 66 68 for( i=0 ; i<m_uhTotalDepth-1 ; i++) … … 69 71 UInt uiWidth = uiMaxWidth >> i; 70 72 UInt uiHeight = uiMaxHeight >> i; 71 73 72 m_ppcBestCU[i] = newTComDataCU; m_ppcBestCU[i]->create( uiNumPartitions, uiWidth, uiHeight, false );73 m_ppcTempCU[i] = newTComDataCU; m_ppcTempCU[i]->create( uiNumPartitions, uiWidth, uiHeight, false );74 m_ppcBestCU[i] = MEMNEW TComDataCU; m_ppcBestCU[i]->create( uiNumPartitions, uiWidth, uiHeight, false ); 75 m_ppcTempCU[i] = MEMNEW TComDataCU; m_ppcTempCU[i]->create( uiNumPartitions, uiWidth, uiHeight, false ); 74 76 75 m_ppcPredYuvBest[i] = newTComYuv; m_ppcPredYuvBest[i]->create(uiWidth, uiHeight);76 m_ppcResiYuvBest[i] = newTComYuv; m_ppcResiYuvBest[i]->create(uiWidth, uiHeight);77 m_ppcRecoYuvBest[i] = newTComYuv; m_ppcRecoYuvBest[i]->create(uiWidth, uiHeight);77 m_ppcPredYuvBest[i] = MEMNEW TComYuv; m_ppcPredYuvBest[i]->create(uiWidth, uiHeight); 78 m_ppcResiYuvBest[i] = MEMNEW TComYuv; m_ppcResiYuvBest[i]->create(uiWidth, uiHeight); 79 m_ppcRecoYuvBest[i] = MEMNEW TComYuv; m_ppcRecoYuvBest[i]->create(uiWidth, uiHeight); 78 80 79 m_ppcPredYuvTemp[i] = newTComYuv; m_ppcPredYuvTemp[i]->create(uiWidth, uiHeight);80 m_ppcResiYuvTemp[i] = newTComYuv; m_ppcResiYuvTemp[i]->create(uiWidth, uiHeight);81 m_ppcRecoYuvTemp[i] = newTComYuv; m_ppcRecoYuvTemp[i]->create(uiWidth, uiHeight);81 m_ppcPredYuvTemp[i] = MEMNEW TComYuv; m_ppcPredYuvTemp[i]->create(uiWidth, uiHeight); 82 m_ppcResiYuvTemp[i] = MEMNEW TComYuv; m_ppcResiYuvTemp[i]->create(uiWidth, uiHeight); 83 m_ppcRecoYuvTemp[i] = MEMNEW TComYuv; m_ppcRecoYuvTemp[i]->create(uiWidth, uiHeight); 82 84 83 m_ppcOrigYuv [i] = newTComYuv; m_ppcOrigYuv [i]->create(uiWidth, uiHeight);85 m_ppcOrigYuv [i] = MEMNEW TComYuv; m_ppcOrigYuv [i]->create(uiWidth, uiHeight); 84 86 } 85 87 86 88 // initialize partition order. … … 100 102 { 101 103 if(m_ppcBestCU[i]) 102 104 { 103 m_ppcBestCU[i]->destroy(); delete m_ppcBestCU[i]; m_ppcBestCU[i] = NULL;105 m_ppcBestCU[i]->destroy(); MEMDELETE( m_ppcBestCU[i] ); m_ppcBestCU[i] = NULL; 104 106 } 105 107 if(m_ppcTempCU[i]) 106 108 { 107 m_ppcTempCU[i]->destroy(); delete m_ppcTempCU[i]; m_ppcTempCU[i] = NULL;109 m_ppcTempCU[i]->destroy(); MEMDELETE( m_ppcTempCU[i] ); m_ppcTempCU[i] = NULL; 108 110 } 109 111 if(m_ppcPredYuvBest[i]) 110 112 { 111 m_ppcPredYuvBest[i]->destroy(); delete m_ppcPredYuvBest[i]; m_ppcPredYuvBest[i] = NULL;113 m_ppcPredYuvBest[i]->destroy(); MEMDELETE( m_ppcPredYuvBest[i] ); m_ppcPredYuvBest[i] = NULL; 112 114 } 113 115 if(m_ppcResiYuvBest[i]) 114 116 { 115 m_ppcResiYuvBest[i]->destroy(); delete m_ppcResiYuvBest[i]; m_ppcResiYuvBest[i] = NULL;117 m_ppcResiYuvBest[i]->destroy(); MEMDELETE( m_ppcResiYuvBest[i] ); m_ppcResiYuvBest[i] = NULL; 116 118 } 117 119 if(m_ppcRecoYuvBest[i]) 118 120 { 119 m_ppcRecoYuvBest[i]->destroy(); delete m_ppcRecoYuvBest[i]; m_ppcRecoYuvBest[i] = NULL;121 m_ppcRecoYuvBest[i]->destroy(); MEMDELETE( m_ppcRecoYuvBest[i] ); m_ppcRecoYuvBest[i] = NULL; 120 122 } 121 123 if(m_ppcPredYuvTemp[i]) 122 124 { 123 m_ppcPredYuvTemp[i]->destroy(); delete m_ppcPredYuvTemp[i]; m_ppcPredYuvTemp[i] = NULL;125 m_ppcPredYuvTemp[i]->destroy(); MEMDELETE( m_ppcPredYuvTemp[i] ); m_ppcPredYuvTemp[i] = NULL; 124 126 } 125 127 if(m_ppcResiYuvTemp[i]) 126 128 { 127 m_ppcResiYuvTemp[i]->destroy(); delete m_ppcResiYuvTemp[i]; m_ppcResiYuvTemp[i] = NULL;129 m_ppcResiYuvTemp[i]->destroy(); MEMDELETE( m_ppcResiYuvTemp[i] ); m_ppcResiYuvTemp[i] = NULL; 128 130 } 129 131 if(m_ppcRecoYuvTemp[i]) 130 132 { 131 m_ppcRecoYuvTemp[i]->destroy(); delete m_ppcRecoYuvTemp[i]; m_ppcRecoYuvTemp[i] = NULL;133 m_ppcRecoYuvTemp[i]->destroy(); MEMDELETE( m_ppcRecoYuvTemp[i] ); m_ppcRecoYuvTemp[i] = NULL; 132 134 } 133 135 if(m_ppcOrigYuv[i]) 134 136 { 135 m_ppcOrigYuv[i]->destroy(); delete m_ppcOrigYuv[i]; m_ppcOrigYuv[i] = NULL;137 m_ppcOrigYuv[i]->destroy(); MEMDELETE( m_ppcOrigYuv[i] ); m_ppcOrigYuv[i] = NULL; 136 138 } 137 139 } 138 140 if(m_ppcBestCU) 139 141 { 140 delete [] m_ppcBestCU;142 MEMDELETEARRAY( m_ppcBestCU ); 141 143 m_ppcBestCU = NULL; 142 144 } 143 145 if(m_ppcTempCU) 144 146 { 145 delete [] m_ppcTempCU;147 MEMDELETEARRAY( m_ppcTempCU ); 146 148 m_ppcTempCU = NULL; 147 149 } 148 150 149 151 if(m_ppcPredYuvBest) 150 152 { 151 delete [] m_ppcPredYuvBest;153 MEMDELETEARRAY( m_ppcPredYuvBest ); 152 154 m_ppcPredYuvBest = NULL; 153 155 } 154 156 if(m_ppcResiYuvBest) 155 157 { 156 delete [] m_ppcResiYuvBest;158 MEMDELETEARRAY( m_ppcResiYuvBest ); 157 159 m_ppcResiYuvBest = NULL; 158 160 } 159 161 if(m_ppcRecoYuvBest) 160 162 { 161 delete [] m_ppcRecoYuvBest;163 MEMDELETEARRAY( m_ppcRecoYuvBest ); 162 164 m_ppcRecoYuvBest = NULL; 163 165 } 164 166 if(m_ppcPredYuvTemp) 165 167 { 166 delete [] m_ppcPredYuvTemp;168 MEMDELETEARRAY( m_ppcPredYuvTemp ); 167 169 m_ppcPredYuvTemp = NULL; 168 170 } 169 171 if(m_ppcResiYuvTemp) 170 172 { 171 delete [] m_ppcResiYuvTemp;173 MEMDELETEARRAY( m_ppcResiYuvTemp ); 172 174 m_ppcResiYuvTemp = NULL; 173 175 } 174 176 if(m_ppcRecoYuvTemp) 175 177 { 176 delete [] m_ppcRecoYuvTemp;178 MEMDELETEARRAY( m_ppcRecoYuvTemp ); 177 179 m_ppcRecoYuvTemp = NULL; 178 180 } 179 181 if(m_ppcOrigYuv) 180 182 { 181 delete [] m_ppcOrigYuv;183 MEMDELETEARRAY( m_ppcOrigYuv ); 182 184 m_ppcOrigYuv = NULL; 183 185 } 184 186 } -
source/Lib/TLibEncoder/TEncGOP.cpp
39 39 40 40 #include <time.h> 41 41 42 #include "../TLibCommon/tool_tracemem.h" 43 42 44 // ==================================================================================================================== 43 45 // Constructor / destructor / initialization / destroy 44 46 // ==================================================================================================================== … … 123 125 TComPicYuv cPicOrg; 124 126 TComPic* pcOrgRefList[2][MAX_REF_PIC_NUM]; 125 127 //stats 126 TComBitstream* pcOut = newTComBitstream;128 TComBitstream* pcOut = MEMNEW TComBitstream; 127 129 pcOut->create( 500000 ); 128 130 129 131 xInitGOP( iPOCLast, iNumPicRcvd, rcListPic, rcListPicYuvRecOut ); … … 573 575 } 574 576 575 577 pcOut->destroy(); 576 delete pcOut;578 MEMDELETE( pcOut ); 577 579 578 580 assert ( m_iNumPicCoded == iNumPicRcvd ); 579 581 } … … 993 995 uibits ); 994 996 printf( "[Y %6.4lf dB U %6.4lf dB V %6.4lf dB] ", dYPSNR, dUPSNR, dVPSNR ); 995 997 printf ("[ET %5.0f ] ", dEncTime ); 998 printf( "[MA %.1lf MB, %.1lf KTimes] " , GetMaxMBMemAllocated() , GetTimesMemAllocation() / 1000 ); 996 999 997 1000 for (Int iRefList = 0; iRefList < 2; iRefList++) 998 1001 { -
source/Lib/TLibEncoder/TEncSearch.cpp
37 37 #include "../TLibCommon/TComMotionInfo.h" 38 38 #include "TEncSearch.h" 39 39 40 #include "../TLibCommon/tool_tracemem.h" 41 42 40 43 #ifdef ROUNDING_CONTROL_BIPRED 41 44 __inline Pel xClip (Pel x ) { return ( (x < 0) ? 0 : (x > (Pel)g_uiIBDI_MAX) ? (Pel)g_uiIBDI_MAX : x ); } 42 45 #endif … … 119 122 { 120 123 if ( m_pTempPel ) 121 124 { 122 delete [] m_pTempPel;125 MEMDELETEARRAY( m_pTempPel ); 123 126 m_pTempPel = NULL; 124 127 } 125 128 #if HHI_RQT … … 128 131 const UInt uiNumLayersAllocated = m_pcEncCfg->getQuadtreeTULog2MaxSize()-m_pcEncCfg->getQuadtreeTULog2MinSize()+1; 129 132 for( UInt ui = 0; ui < uiNumLayersAllocated; ++ui ) 130 133 { 131 delete[] m_ppcQTTempCoeffY[ui];132 delete[] m_ppcQTTempCoeffCb[ui];133 delete[] m_ppcQTTempCoeffCr[ui];134 MEMDELETEARRAY( m_ppcQTTempCoeffY[ui] ); 135 MEMDELETEARRAY( m_ppcQTTempCoeffCb[ui] ); 136 MEMDELETEARRAY( m_ppcQTTempCoeffCr[ui] ); 134 137 m_pcQTTempTComYuv[ui].destroy(); 135 138 } 136 delete[] m_ppcQTTempCoeffY;137 delete[] m_ppcQTTempCoeffCb;138 delete[] m_ppcQTTempCoeffCr;139 delete[] m_pcQTTempCoeffY;140 delete[] m_pcQTTempCoeffCb;141 delete[] m_pcQTTempCoeffCr;142 delete[] m_puhQTTempTrIdx;143 delete[] m_puhQTTempCbf[0];144 delete[] m_puhQTTempCbf[1];145 delete[] m_puhQTTempCbf[2];146 delete[] m_pcQTTempTComYuv;139 MEMDELETEARRAY( m_ppcQTTempCoeffY ); 140 MEMDELETEARRAY( m_ppcQTTempCoeffCb ); 141 MEMDELETEARRAY( m_ppcQTTempCoeffCr ); 142 MEMDELETEARRAY( m_pcQTTempCoeffY ); 143 MEMDELETEARRAY( m_pcQTTempCoeffCb ); 144 MEMDELETEARRAY( m_pcQTTempCoeffCr ); 145 MEMDELETEARRAY( m_puhQTTempTrIdx ); 146 MEMDELETEARRAY( m_puhQTTempCbf[0] ); 147 MEMDELETEARRAY( m_puhQTTempCbf[1] ); 148 MEMDELETEARRAY( m_puhQTTempCbf[2] ); 149 MEMDELETEARRAY( m_pcQTTempTComYuv ); 147 150 } 148 151 #endif 149 152 } … … 194 197 195 198 initTempBuff(); 196 199 197 m_pTempPel = newPel[g_uiMaxCUWidth*g_uiMaxCUHeight];200 m_pTempPel = MEMNEWARRAY Pel[g_uiMaxCUWidth*g_uiMaxCUHeight]; 198 201 199 202 m_iDIFTap2 = (m_iDIFTap << 1); 200 203 … … 202 205 if( pcEncCfg->getQuadtreeTUFlag() ) 203 206 { 204 207 const UInt uiNumLayersToAllocate = pcEncCfg->getQuadtreeTULog2MaxSize()-pcEncCfg->getQuadtreeTULog2MinSize()+1; 205 m_ppcQTTempCoeffY = newTCoeff*[uiNumLayersToAllocate];206 m_ppcQTTempCoeffCb = newTCoeff*[uiNumLayersToAllocate];207 m_ppcQTTempCoeffCr = newTCoeff*[uiNumLayersToAllocate];208 m_pcQTTempCoeffY = newTCoeff [g_uiMaxCUWidth*g_uiMaxCUHeight ];209 m_pcQTTempCoeffCb = newTCoeff [g_uiMaxCUWidth*g_uiMaxCUHeight>>2];210 m_pcQTTempCoeffCr = newTCoeff [g_uiMaxCUWidth*g_uiMaxCUHeight>>2];208 m_ppcQTTempCoeffY = MEMNEWARRAY TCoeff*[uiNumLayersToAllocate]; 209 m_ppcQTTempCoeffCb = MEMNEWARRAY TCoeff*[uiNumLayersToAllocate]; 210 m_ppcQTTempCoeffCr = MEMNEWARRAY TCoeff*[uiNumLayersToAllocate]; 211 m_pcQTTempCoeffY = MEMNEWARRAY TCoeff [g_uiMaxCUWidth*g_uiMaxCUHeight ]; 212 m_pcQTTempCoeffCb = MEMNEWARRAY TCoeff [g_uiMaxCUWidth*g_uiMaxCUHeight>>2]; 213 m_pcQTTempCoeffCr = MEMNEWARRAY TCoeff [g_uiMaxCUWidth*g_uiMaxCUHeight>>2]; 211 214 212 215 const UInt uiNumPartitions = 1<<(g_uiMaxCUDepth<<1); 213 m_puhQTTempTrIdx = newUChar [uiNumPartitions];214 m_puhQTTempCbf[0] = newUChar [uiNumPartitions];215 m_puhQTTempCbf[1] = newUChar [uiNumPartitions];216 m_puhQTTempCbf[2] = newUChar [uiNumPartitions];217 m_pcQTTempTComYuv = newTComYuv[uiNumLayersToAllocate];216 m_puhQTTempTrIdx = MEMNEWARRAY UChar [uiNumPartitions]; 217 m_puhQTTempCbf[0] = MEMNEWARRAY UChar [uiNumPartitions]; 218 m_puhQTTempCbf[1] = MEMNEWARRAY UChar [uiNumPartitions]; 219 m_puhQTTempCbf[2] = MEMNEWARRAY UChar [uiNumPartitions]; 220 m_pcQTTempTComYuv = MEMNEWARRAY TComYuv[uiNumLayersToAllocate]; 218 221 for( UInt ui = 0; ui < uiNumLayersToAllocate; ++ui ) 219 222 { 220 m_ppcQTTempCoeffY[ui] = newTCoeff[g_uiMaxCUWidth*g_uiMaxCUHeight ];221 m_ppcQTTempCoeffCb[ui] = newTCoeff[g_uiMaxCUWidth*g_uiMaxCUHeight>>2];222 m_ppcQTTempCoeffCr[ui] = newTCoeff[g_uiMaxCUWidth*g_uiMaxCUHeight>>2];223 m_ppcQTTempCoeffY[ui] = MEMNEWARRAY TCoeff[g_uiMaxCUWidth*g_uiMaxCUHeight ]; 224 m_ppcQTTempCoeffCb[ui] = MEMNEWARRAY TCoeff[g_uiMaxCUWidth*g_uiMaxCUHeight>>2]; 225 m_ppcQTTempCoeffCr[ui] = MEMNEWARRAY TCoeff[g_uiMaxCUWidth*g_uiMaxCUHeight>>2]; 223 226 m_pcQTTempTComYuv[ui].create( g_uiMaxCUWidth, g_uiMaxCUHeight ); 224 227 } 225 228 } -
source/Lib/TLibEncoder/TEncSlice.cpp
36 36 #include "TEncTop.h" 37 37 #include "TEncSlice.h" 38 38 39 #include "../TLibCommon/tool_tracemem.h" 40 39 41 // ==================================================================================================================== 40 42 // Constructor / destructor / create / destroy 41 43 // ==================================================================================================================== … … 66 68 // create prediction picture 67 69 if ( m_apcPicYuvPred == NULL ) 68 70 { 69 m_apcPicYuvPred = newTComPicYuv;71 m_apcPicYuvPred = MEMNEW TComPicYuv; 70 72 m_apcPicYuvPred->create( iWidth, iHeight, iMaxCUWidth, iMaxCUHeight, uhTotalDepth ); 71 73 } 72 74 73 75 // create residual picture 74 76 if( m_apcPicYuvResi == NULL ) 75 77 { 76 m_apcPicYuvResi = newTComPicYuv;78 m_apcPicYuvResi = MEMNEW TComPicYuv; 77 79 m_apcPicYuvResi->create( iWidth, iHeight, iMaxCUWidth, iMaxCUHeight, uhTotalDepth ); 78 80 } 79 81 } … … 84 86 if ( m_apcPicYuvPred ) 85 87 { 86 88 m_apcPicYuvPred->destroy(); 87 delete m_apcPicYuvPred;89 MEMDELETE( m_apcPicYuvPred ); 88 90 m_apcPicYuvPred = NULL; 89 91 } 90 92 … … 92 94 if ( m_apcPicYuvResi ) 93 95 { 94 96 m_apcPicYuvResi->destroy(); 95 delete m_apcPicYuvResi;97 MEMDELETE( m_apcPicYuvResi ); 96 98 m_apcPicYuvResi = NULL; 97 99 } 98 100 … … 103 105 if(m_apcVirtPic[j][i]) 104 106 { 105 107 m_apcVirtPic[j][i]->destroy(); 106 delete m_apcVirtPic[j][i];108 MEMDELETE( m_apcVirtPic[j][i] ); 107 109 m_apcVirtPic[j][i]=NULL; 108 110 } 109 111 } … … 158 160 { 159 161 if ( m_apcVirtPic[j][i] == NULL) 160 162 { 161 m_apcVirtPic[j][i] = newTComPic;163 m_apcVirtPic[j][i] = MEMNEW TComPic; 162 164 m_apcVirtPic[j][i]->create( iWidth, iHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth, true ); 163 165 } 164 166 } -
source/Lib/TLibEncoder/TEncTop.cpp
36 36 #include "../TLibCommon/CommonDef.h" 37 37 #include "TEncTop.h" 38 38 39 #include "../TLibCommon/tool_tracemem.h" 40 39 41 // ==================================================================================================================== 40 42 // Constructor / destructor / create / destroy 41 43 // ==================================================================================================================== … … 83 85 // if SBAC-based RD optimization is used 84 86 if( m_bUseSBACRD ) 85 87 { 86 m_pppcRDSbacCoder = newTEncSbac** [g_uiMaxCUDepth+1];87 m_pppcBinCoderCABAC = newTEncBinCABAC** [g_uiMaxCUDepth+1];88 m_pppcRDSbacCoder = MEMNEWARRAY TEncSbac** [g_uiMaxCUDepth+1]; 89 m_pppcBinCoderCABAC = MEMNEWARRAY TEncBinCABAC** [g_uiMaxCUDepth+1]; 88 90 89 91 for ( Int iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ ) 90 92 { 91 m_pppcRDSbacCoder[iDepth] = newTEncSbac* [CI_NUM];92 m_pppcBinCoderCABAC[iDepth] = newTEncBinCABAC* [CI_NUM];93 m_pppcRDSbacCoder[iDepth] = MEMNEWARRAY TEncSbac* [CI_NUM]; 94 m_pppcBinCoderCABAC[iDepth] = MEMNEWARRAY TEncBinCABAC* [CI_NUM]; 93 95 94 96 for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ ) 95 97 { 96 m_pppcRDSbacCoder[iDepth][iCIIdx] = newTEncSbac;97 m_pppcBinCoderCABAC [iDepth][iCIIdx] = newTEncBinCABAC;98 m_pppcRDSbacCoder[iDepth][iCIIdx] = MEMNEW TEncSbac; 99 m_pppcBinCoderCABAC [iDepth][iCIIdx] = MEMNEW TEncBinCABAC; 98 100 m_pppcRDSbacCoder [iDepth][iCIIdx]->init( m_pppcBinCoderCABAC [iDepth][iCIIdx] ); 99 101 } 100 102 } … … 120 122 { 121 123 for (Int iCIIdx = 0; iCIIdx < CI_NUM; iCIIdx ++ ) 122 124 { 123 delete m_pppcRDSbacCoder[iDepth][iCIIdx];124 delete m_pppcBinCoderCABAC[iDepth][iCIIdx];125 MEMDELETE( m_pppcRDSbacCoder[iDepth][iCIIdx] ); 126 MEMDELETE( m_pppcBinCoderCABAC[iDepth][iCIIdx] ); 125 127 } 126 128 } 127 129 128 130 for ( iDepth = 0; iDepth < g_uiMaxCUDepth+1; iDepth++ ) 129 131 { 130 delete [] m_pppcRDSbacCoder[iDepth];131 delete [] m_pppcBinCoderCABAC[iDepth];132 MEMDELETEARRAY( m_pppcRDSbacCoder[iDepth] ); 133 MEMDELETEARRAY( m_pppcBinCoderCABAC[iDepth] ); 132 134 } 133 135 134 delete [] m_pppcRDSbacCoder;135 delete [] m_pppcBinCoderCABAC;136 MEMDELETEARRAY( m_pppcRDSbacCoder ); 137 MEMDELETEARRAY( m_pppcBinCoderCABAC ); 136 138 } 137 139 138 140 // destroy ROM … … 188 190 TComPic* pcPic = *(iterPic++); 189 191 190 192 pcPic->destroy(); 191 delete pcPic;193 MEMDELETE( pcPic ); 192 194 pcPic = NULL; 193 195 } 194 196 } … … 260 262 rpcPic = *(++iterPic); 261 263 if ( abs(rpcPic->getPOC() - m_iPOCLast) <= m_iGOPSize ) 262 264 { 263 rpcPic = newTComPic;265 rpcPic = MEMNEW TComPic; 264 266 rpcPic->create( m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); 265 267 } 266 268 else … … 272 274 } 273 275 else 274 276 { 275 rpcPic = newTComPic;277 rpcPic = MEMNEW TComPic; 276 278 rpcPic->create( m_iSourceWidth, m_iSourceHeight, g_uiMaxCUWidth, g_uiMaxCUHeight, g_uiMaxCUDepth ); 277 279 } 278 280 -
source/Lib/TLibVideoIO/TVideoIOYuv.cpp
42 42 43 43 #include "TVideoIOYuv.h" 44 44 45 #include "../TLibCommon/tool_tracemem.h" 46 45 47 using namespace std; 46 48 47 49 // ==================================================================================================================== … … 104 106 iHeight = rpcPicYuv->getHeight() - aiPad[1]; 105 107 106 108 // allocate 8-bit buffer 107 Pxl* apuchBuf = newPxl[iWidth];109 Pxl* apuchBuf = MEMNEWARRAY Pxl[iWidth]; 108 110 109 111 // Y 110 112 Pel* pDst = rpcPicYuv->getLumaAddr(); … … 167 169 pDst += iStride; 168 170 } 169 171 170 delete [] apuchBuf;172 MEMDELETEARRAY( apuchBuf ); 171 173 172 174 return; 173 175 } … … 185 187 Int iStride = pcPicYuv->getStride(); 186 188 187 189 // allocate 8-bit buffer 188 Pxl* apuchBuf = newPxl[iWidth];190 Pxl* apuchBuf = MEMNEWARRAY Pxl[iWidth]; 189 191 190 192 // Y 191 193 Pel* pSrc = pcPicYuv->getLumaAddr(); … … 218 220 pSrc += iStride; 219 221 } 220 222 221 delete [] apuchBuf;223 MEMDELETEARRAY( apuchBuf ); 222 224 } 223 225