Ticket #67: MemLeak_SIFO.patch

File MemLeak_SIFO.patch, 3.3 KB (added by anonymous, 14 years ago)
  • TEncSIFO.cpp

     
    6262  SequenceAccErrorP     = NULL;                    // [Filter][Sppos]
    6363  SequenceAccErrorB     = NULL;                    // [FilterF][FilterB][SpposF][SpposB]
    6464  SIFO_FILTER           = NULL;                    // [num_SIFO][16 subpels][SQR_FILTER]
     65#ifdef FIX_TICKET67
     66  m_pcPredSearch = NULL;
     67#if USE_DIAGONAL_FILT==1
     68  SIFO_FILTER_DIAG = NULL;
     69#endif
     70#endif
    6571}
    6672TEncSIFO::~TEncSIFO()
    6773{
    6874}
     75
     76#ifdef FIX_TICKET67
     77Void TEncSIFO::destropy()
     78{
     79        if( m_pcPredSearch != NULL )
     80        {
     81                UInt num_SIFO = m_pcPredSearch->getNum_SIFOFilters();
     82                xFree_mem2Ddouble(AccErrorP);
     83                xFree_mem2Ddouble(SequenceAccErrorP);
     84                xFree_mem4Ddouble(SequenceAccErrorB, num_SIFO, num_SIFO);
     85                xFree_mem3Ddouble(SIFO_FILTER, num_SIFO);
     86#if USE_DIAGONAL_FILT==1
     87                xFree_mem2Ddouble(SIFO_FILTER_DIAG);
     88#endif
     89        }
     90}
     91#endif
     92
    6993// ====================================================================================================================
    7094// Public member functions
    7195// ====================================================================================================================
     
    601625  return idx*frames*rows*columns*sizeof(Double);
    602626}
    603627
     628#ifdef FIX_TICKET67
     629Void TEncSIFO::xFree_mem2Ddouble(Double **array2D)
     630{
     631        if(array2D)
     632        {
     633                if(array2D[0])
     634                        free (array2D[0]);
     635                else
     636                {
     637                        printf("xFree_mem2Ddouble: trying to free unused memory");
     638                        exit(100);
     639                }
     640                free (array2D);
     641        }
     642}
     643
     644Void TEncSIFO::xFree_mem3Ddouble(Double ***array3D, Int frames)
     645{
     646        int i;
     647
     648        if(array3D)
     649        {
     650                for(i=0;i<frames;i++)
     651                {
     652                        xFree_mem2Ddouble(array3D[i]);
     653                }
     654                free(array3D);
     655        }
     656}
     657
     658Void TEncSIFO::xFree_mem4Ddouble(Double ****array4D, Int idx, Int frames)
     659{
     660        int  j;
     661
     662        if(array4D)
     663        {
     664                for(j=0;j<idx;j++)
     665                        xFree_mem3Ddouble( array4D[j], frames) ;
     666                free(array4D);
     667        }
     668}
     669#endif
     670
    604671Void TEncSIFO::xResetSequenceFilters()
    605672{
    606673  Int i;
  • TEncSIFO.h

     
    4545class TEncTop;
    4646class TEncGOP;
    4747
     48#define FIX_TICKET67
     49
    4850// ====================================================================================================================
    4951// Class definition
    5052// ====================================================================================================================
     
    6971  Int xGet_mem2Ddouble(Double ***array2D, Int rows, Int columns);
    7072  Int xGet_mem3Ddouble(Double ****array3D, Int frames, Int rows, Int columns);
    7173  Int xGet_mem4Ddouble(Double *****array4D, Int idx, Int frames, Int rows, Int columns );
     74#ifdef FIX_TICKET67
     75  Void xFree_mem2Ddouble(Double **array2D);
     76  Void xFree_mem3Ddouble(Double ***array3D, Int frames);
     77  Void xFree_mem4Ddouble(Double ****array4D, Int idx, Int frames);
     78#endif
    7279  Double  xComputeImgSum                        ( Pel* img,                                                                             Int width, Int height, Int stride               );      ///< compute sum of pixel values
    7380  Void xResetAll(TComSlice* pcSlice);
    7481  Void xResetSequenceFilters();
     
    96103public:
    97104  TEncSIFO();
    98105  virtual ~TEncSIFO();
     106#ifdef FIX_TICKET67
     107  Void destropy();
     108#endif
    99109
    100110  Void    init                                                          ( TEncTop* pcEncTop, Int Tap);
    101111  Void    initEncSIFO                             ( TComSlice*& rpcSlice );