From aae4b307faaee29f25641f83935d697d699828d5 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Fri, 6 Nov 2015 19:11:12 +0000 Subject: [PATCH] Fix histogram reset after recalculation --- app/PlaYUVerApp.cpp | 1 + lib/LibMemory.h | 49 +++++++++++-------------------------------- lib/PlaYUVerDefs.h | 10 --------- lib/PlaYUVerFrame.cpp | 2 ++ 4 files changed, 15 insertions(+), 47 deletions(-) diff --git a/app/PlaYUVerApp.cpp b/app/PlaYUVerApp.cpp index 7ca1b0d..e607c80 100644 --- a/app/PlaYUVerApp.cpp +++ b/app/PlaYUVerApp.cpp @@ -639,6 +639,7 @@ Void PlaYUVerApp::createActions() m_arrayActions[RELOAD_ACT] = new QAction( tr( "&Reload" ), this ); m_arrayActions[RELOAD_ACT]->setIcon( style()->standardIcon( QStyle::SP_BrowserReload ) ); m_arrayActions[RELOAD_ACT]->setShortcut( Qt::CTRL + Qt::Key_R ); + m_arrayActions[RELOAD_ACT]->setShortcut( Qt::Key_F5 ); m_arrayActions[RELOAD_ACT]->setStatusTip( tr( "Reload current sequence" ) ); connect( m_arrayActions[RELOAD_ACT], SIGNAL( triggered() ), this, SLOT( reload() ) ); diff --git a/lib/LibMemory.h b/lib/LibMemory.h index 6d84b72..3e685cd 100644 --- a/lib/LibMemory.h +++ b/lib/LibMemory.h @@ -50,31 +50,21 @@ typedef long long Int64; typedef unsigned long long UInt64; #endif -static inline void* mem_malloc( size_t nitems ) -{ - void *d; - if( ( d = malloc( nitems ) ) == NULL ) - { - return NULL; - } - return d; -} - - -static inline void mem_free( void *ptr ) -{ - if( ptr != NULL ) - { - free( ptr ); - ptr = NULL; - } -} - +#define DATA_ALIGN 1 ///< use 32-bit aligned malloc/free +#if DATA_ALIGN && _WIN32 && ( _MSC_VER > 1300 ) +#define xMalloc( len ) _aligned_malloc( len, 32 ) +#define xFree( ptr ) _aligned_free ( ptr ) +#define xMemSet( type, len, ptr ) +#else +#define xMemSet( type, len, ptr ) memset ( ptr, 0, (len)*sizeof(type) ) +#define xMalloc( len ) malloc ( len ) +#define xFreeMem( ptr ) free ( ptr ) +#endif static inline Void* xMallocMem( SizeT nitems ) { Void *d; - if( ( d = malloc( nitems ) ) == NULL ) + if( ( d = xMalloc( nitems ) ) == NULL ) { printf( "malloc failed.\n" ); return NULL; @@ -90,20 +80,6 @@ static inline Void* xCallocMem( SizeT nitems, SizeT size ) return d; } -static inline Void xFreePointer( Void *pointer ) -{ - if( pointer != NULL ) - { - free( pointer ); - pointer = NULL; - } -} - -static inline Void xFreeMem( Void *mem ) -{ - xFreePointer( mem ); -} - template Int getMem1D( T **array1D, Int dim0 ) { @@ -182,7 +158,7 @@ Void freeMem1D( T *array1D ) { if( array1D ) { - mem_free( array1D ); + xFreeMem( array1D ); } } @@ -258,7 +234,6 @@ Void freeMem3ImageComponents( T*** array3D ) } } - } // NAMESPACE #endif // __LIBMEMORY_H__ diff --git a/lib/PlaYUVerDefs.h b/lib/PlaYUVerDefs.h index 00c2985..7a65276 100644 --- a/lib/PlaYUVerDefs.h +++ b/lib/PlaYUVerDefs.h @@ -91,16 +91,6 @@ typedef UChar Byte; // Macro functions // ==================================================================================================================== -#define DATA_ALIGN 1 ///< use 32-bit aligned malloc/free -#if DATA_ALIGN && _WIN32 && ( _MSC_VER > 1300 ) -#define xMalloc( type, len ) _aligned_malloc( sizeof(type)*(len), 32 ) -#define xFree( ptr ) _aligned_free ( ptr ) -#define xMemSet( type, len, ptr ) -#else -#define xMemSet( type, len, ptr ) memset ( ptr, 0, (len)*sizeof(type) ) -#define xMalloc( type, len ) malloc ( sizeof(type)*(len) ) -#define xFree( ptr ) free ( ptr ) -#endif // ==================================================================================================================== // PlaYUVer definitions diff --git a/lib/PlaYUVerFrame.cpp b/lib/PlaYUVerFrame.cpp index befdfa0..cee327b 100644 --- a/lib/PlaYUVerFrame.cpp +++ b/lib/PlaYUVerFrame.cpp @@ -504,6 +504,8 @@ Void PlaYUVerFrame::calcHistogram() } m_bRunningFlag = true; + xMemSet( UInt, m_uiHistoSegments * m_uiHistoChannels, m_puiHistogram ); + UInt i, j; UInt numberChannels = m_pcPelFormat->numberChannels; Int colorSpace = m_pcPelFormat->colorSpace;