Bugfixes and improvements
Uniform the use of unsigned long in the frame number by defining a ClpULong type CalypFrame Add function to copyTo a specific position
This commit is contained in:
22 files changed
+88
-53
No files matched your search
+4
-4
@@ -157,7 +157,7 @@ IF (NOT CMAKE_BUILD_TYPE )
|
||||
SET(CMAKE_BUILD_TYPE "Release")
|
||||
ENDIF()
|
||||
|
||||
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall" )
|
||||
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-deprecated-declarations" )
|
||||
|
||||
ADD_DEFINITIONS(-DQT_NO_CAST_TO_ASCII
|
||||
#-DQT_NO_CAST_FROM_ASCII
|
||||
@@ -167,9 +167,9 @@ ADD_DEFINITIONS(-DQT_NO_CAST_TO_ASCII
|
||||
#-DQT_USE_QSTRINGBUILDER
|
||||
)
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic")
|
||||
endif()
|
||||
# if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic")
|
||||
# endif()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.0.0")
|
||||
|
||||
@@ -562,8 +562,8 @@ void ModulesHandle::applyAllModuleIf( CalypAppModuleIf* pcCurrModuleIf )
|
||||
if( pcCurrModuleIf->m_pcModuleStream )
|
||||
{
|
||||
unsigned int numberOfWindows = pcCurrModuleIf->m_pcModule->m_uiNumberOfFrames;
|
||||
unsigned long long int currFrames = 0;
|
||||
unsigned long long int numberOfFrames = INT_MAX;
|
||||
ClpULong currFrames = 0;
|
||||
ClpULong numberOfFrames = -1;
|
||||
for( unsigned int i = 0; i < numberOfWindows; i++ )
|
||||
{
|
||||
currFrames = pcCurrModuleIf->m_pcSubWindow[i]->getInputStream()->getFrameNum();
|
||||
|
||||
@@ -156,12 +156,12 @@ void QualityHandle::update( VideoSubWindow* currSubWindow )
|
||||
|
||||
void QualityHandle::measureQuality( QVector<VideoSubWindow*> apcWindowList )
|
||||
{
|
||||
int numberOfWindows = apcWindowList.size();
|
||||
unsigned long long int currFrames = 0;
|
||||
unsigned long long int numberOfFrames = INT_MAX;
|
||||
unsigned numberOfWindows = apcWindowList.size();
|
||||
ClpULong currFrames = 0;
|
||||
ClpULong numberOfFrames = -1;
|
||||
|
||||
//! Check reference window
|
||||
for( int i = 0; i < numberOfWindows; i++ )
|
||||
for( unsigned i = 0; i < numberOfWindows; i++ )
|
||||
{
|
||||
if( !apcWindowList.at( i )->getRefSubWindow() )
|
||||
{
|
||||
@@ -171,7 +171,7 @@ void QualityHandle::measureQuality( QVector<VideoSubWindow*> apcWindowList )
|
||||
VideoSubWindow* pcReferenceWindow = apcWindowList.at( 0 )->getRefSubWindow();
|
||||
|
||||
numberOfFrames = pcReferenceWindow->getInputStream()->getFrameNum();
|
||||
for( int i = 0; i < numberOfWindows; i++ )
|
||||
for( unsigned i = 0; i < numberOfWindows; i++ )
|
||||
{
|
||||
currFrames = apcWindowList.at( i )->getInputStream()->getFrameNum();
|
||||
if( currFrames < numberOfFrames )
|
||||
@@ -186,7 +186,7 @@ void QualityHandle::measureQuality( QVector<VideoSubWindow*> apcWindowList )
|
||||
double* padAverageQuality = new double[numberOfWindows + 1];
|
||||
double dCurrentQuality;
|
||||
|
||||
for( unsigned int i = 0; i < numberOfWindows + 1; i++ )
|
||||
for( unsigned i = 0; i < numberOfWindows + 1; i++ )
|
||||
{
|
||||
padAverageQuality[i] = 0;
|
||||
}
|
||||
|
||||
+5
-5
@@ -320,8 +320,8 @@ void VideoHandle::update()
|
||||
CalypStream* pcStream = m_pcCurrentVideoSubWindow->getInputStream();
|
||||
CalypFrame* pcFrame = m_pcCurrentVideoSubWindow->getCurrFrame();
|
||||
|
||||
int frame_num = 0;
|
||||
unsigned long long int total_frame_num = 1;
|
||||
unsigned long frame_num = 0;
|
||||
unsigned long total_frame_num = 1;
|
||||
|
||||
m_pcVideoFormatLabel->setText( m_pcCurrentVideoSubWindow->getStreamInformation() );
|
||||
|
||||
@@ -519,10 +519,10 @@ void VideoHandle::moveAllScrollBars( const double& horRatio, const double& verRa
|
||||
}
|
||||
#endif
|
||||
|
||||
unsigned long long int VideoHandle::getMaxFrameNumber()
|
||||
unsigned long VideoHandle::getMaxFrameNumber()
|
||||
{
|
||||
unsigned int currFrames;
|
||||
unsigned long long int maxFrames = INT_MAX;
|
||||
unsigned long currFrames;
|
||||
unsigned long maxFrames = INT_MAX;
|
||||
if( m_pcCurrentVideoSubWindow )
|
||||
{
|
||||
if( m_acPlayingSubWindows.contains( m_pcCurrentVideoSubWindow ) )
|
||||
|
||||
+1
-1
@@ -128,7 +128,7 @@ private:
|
||||
QElapsedTimer* m_pcPlayControlTimer;
|
||||
#endif
|
||||
|
||||
unsigned long long int getMaxFrameNumber();
|
||||
unsigned long getMaxFrameNumber();
|
||||
void setTimerStatus();
|
||||
|
||||
Q_SIGNALS:
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
|
||||
typedef unsigned short ClpPel; ///< 16-bit pixel type
|
||||
typedef unsigned char ClpByte;
|
||||
typedef unsigned long long ClpULong;
|
||||
|
||||
typedef std::string ClpString;
|
||||
|
||||
|
||||
+34
-7
@@ -388,15 +388,15 @@ unsigned int CalypFrame::getHeight( int channel ) const
|
||||
return CHROMASHIFT( d->m_uiHeight, channel > 0 ? d->m_pcPelFormat->log2ChromaHeight : 0 );
|
||||
}
|
||||
|
||||
unsigned int CalypFrame::getPixels( int channel ) const
|
||||
ClpULong CalypFrame::getPixels( int channel ) const
|
||||
{
|
||||
return getWidth( channel ) * getHeight( channel );
|
||||
}
|
||||
|
||||
unsigned long CalypFrame::getTotalNumberOfPixels() const
|
||||
ClpULong CalypFrame::getTotalNumberOfPixels() const
|
||||
{
|
||||
unsigned long numberPixels = 0;
|
||||
for( int i = 0; i < getNumberChannels(); i++ )
|
||||
ClpULong numberPixels = 0;
|
||||
for( unsigned i = 0; i < getNumberChannels(); i++ )
|
||||
{
|
||||
numberPixels += getPixels( i );
|
||||
}
|
||||
@@ -413,7 +413,7 @@ unsigned char CalypFrame::getChromaHeightRatio() const
|
||||
return d->m_pcPelFormat->log2ChromaHeight;
|
||||
}
|
||||
|
||||
unsigned int CalypFrame::getChromaLength() const
|
||||
ClpULong CalypFrame::getChromaLength() const
|
||||
{
|
||||
return getWidth( 1 ) * getHeight( 1 );
|
||||
}
|
||||
@@ -423,12 +423,12 @@ unsigned int CalypFrame::getBitsPel() const
|
||||
return d->m_uiBitsPel;
|
||||
}
|
||||
|
||||
unsigned long CalypFrame::getBytesPerFrame()
|
||||
ClpULong CalypFrame::getBytesPerFrame()
|
||||
{
|
||||
return getBytesPerFrame( d->m_uiWidth, d->m_uiHeight, d->m_iPixelFormat, d->m_uiBitsPel );
|
||||
}
|
||||
|
||||
unsigned long CalypFrame::getBytesPerFrame( unsigned int uiWidth, unsigned int uiHeight, int iPixelFormat, unsigned int bitsPixel )
|
||||
ClpULong CalypFrame::getBytesPerFrame( unsigned int uiWidth, unsigned int uiHeight, int iPixelFormat, unsigned int bitsPixel )
|
||||
{
|
||||
const CalypPixelFormatDescriptor* pcPelFormat = &( g_CalypPixFmtDescriptorsMap.at( iPixelFormat ) );
|
||||
unsigned int bytesPerPixel = ( bitsPixel - 1 ) / 8 + 1;
|
||||
@@ -541,6 +541,7 @@ void CalypFrame::copyFrom( const CalypFrame& other, unsigned int xPos, unsigned
|
||||
{
|
||||
if( !haveSameFmt( other, MATCH_COLOR_SPACE | MATCH_PEL_FMT | MATCH_BITS ) )
|
||||
return;
|
||||
// TODO: Protect width and height
|
||||
ClpPel*** pInput = other.getPelBufferYUV();
|
||||
for( unsigned int ch = 0; ch < d->m_pcPelFormat->numberChannels; ch++ )
|
||||
{
|
||||
@@ -562,6 +563,32 @@ void CalypFrame::copyFrom( const CalypFrame* other, unsigned int x, unsigned int
|
||||
copyFrom( *other, x, y );
|
||||
}
|
||||
|
||||
void CalypFrame::copyTo( const CalypFrame& other, unsigned int xPos, unsigned int yPos )
|
||||
{
|
||||
if( !haveSameFmt( other, MATCH_COLOR_SPACE | MATCH_PEL_FMT | MATCH_BITS ) )
|
||||
return;
|
||||
ClpPel*** pInput = other.getPelBufferYUV();
|
||||
// TODO: Protect width and height
|
||||
for( unsigned int ch = 0; ch < d->m_pcPelFormat->numberChannels; ch++ )
|
||||
{
|
||||
int ratioH = ch > 0 ? d->m_pcPelFormat->log2ChromaWidth : 0;
|
||||
int ratioW = ch > 0 ? d->m_pcPelFormat->log2ChromaHeight : 0;
|
||||
for( unsigned int i = 0; i < CHROMASHIFT( other.getHeight(), ratioH ); i++ )
|
||||
{
|
||||
memcpy( &( d->m_pppcInputPel[ch][( yPos >> ratioH ) + i][( xPos >> ratioW )] ), &( pInput[ch][i][0] ),
|
||||
( other.getWidth() >> ratioW ) * sizeof( ClpPel ) );
|
||||
}
|
||||
}
|
||||
d->m_bHasRGBPel = false;
|
||||
d->m_bHasHistogram = false;
|
||||
}
|
||||
|
||||
void CalypFrame::copyTo( const CalypFrame* other, unsigned int x, unsigned int y )
|
||||
{
|
||||
if( other )
|
||||
copyTo( *other, x, y );
|
||||
}
|
||||
|
||||
void CalypFrame::frameFromBuffer( ClpByte* Buff, int iEndianness, unsigned long uiBuffSize )
|
||||
{
|
||||
if( uiBuffSize != getBytesPerFrame() )
|
||||
|
||||
+8
-5
@@ -200,13 +200,13 @@ public:
|
||||
* @param channel/component
|
||||
* @return number of pixels
|
||||
*/
|
||||
unsigned int getPixels( int channel = 0 ) const;
|
||||
ClpULong getPixels( int channel = 0 ) const;
|
||||
|
||||
/**
|
||||
* Get the total number of pixels of the frame
|
||||
* @return number of pixels
|
||||
*/
|
||||
unsigned long getTotalNumberOfPixels() const;
|
||||
ClpULong getTotalNumberOfPixels() const;
|
||||
|
||||
/**
|
||||
* Get chroma width ratio
|
||||
@@ -224,7 +224,7 @@ public:
|
||||
* Get number of pixels in each chroma channel
|
||||
* @return number of pixels
|
||||
*/
|
||||
unsigned int getChromaLength() const;
|
||||
ClpULong getChromaLength() const;
|
||||
|
||||
/**
|
||||
* Get number of bits per pixel
|
||||
@@ -236,13 +236,13 @@ public:
|
||||
* Get number of bytes per frame of an existing frame
|
||||
* @return number of bytes per frame
|
||||
*/
|
||||
unsigned long getBytesPerFrame();
|
||||
ClpULong getBytesPerFrame();
|
||||
|
||||
/**
|
||||
* Get number of bytes per frame of a specific pixel format
|
||||
* @return number of bytes per frame
|
||||
*/
|
||||
static unsigned long getBytesPerFrame( unsigned int uiWidth, unsigned int uiHeight, int iPixelFormat, unsigned int bitsPixel );
|
||||
static ClpULong getBytesPerFrame( unsigned int uiWidth, unsigned int uiHeight, int iPixelFormat, unsigned int bitsPixel );
|
||||
|
||||
/**
|
||||
* Reset frame pixels to zero
|
||||
@@ -301,6 +301,9 @@ public:
|
||||
void copyFrom( const CalypFrame&, unsigned int, unsigned int );
|
||||
void copyFrom( const CalypFrame*, unsigned int, unsigned int );
|
||||
|
||||
void copyTo( const CalypFrame&, unsigned int, unsigned int );
|
||||
void copyTo( const CalypFrame*, unsigned int, unsigned int );
|
||||
|
||||
void frameFromBuffer( ClpByte*, int, unsigned long );
|
||||
void frameFromBuffer( ClpByte*, int );
|
||||
void frameToBuffer( ClpByte*, int );
|
||||
|
||||
+5
-1
@@ -159,7 +159,11 @@ public:
|
||||
virtual ClpString moduleInfo() { return ClpString(); }
|
||||
|
||||
virtual bool needFrame() { return true; };
|
||||
virtual bool flush() { return false; };
|
||||
virtual bool flush()
|
||||
{
|
||||
m_iFrameBufferCount = 0;
|
||||
return true;
|
||||
};
|
||||
};
|
||||
|
||||
#endif // __CALYPMODULESIF_H__
|
||||
+2
-2
@@ -401,7 +401,7 @@ bool CalypStream::isNative()
|
||||
return d->handler->m_bNative;
|
||||
}
|
||||
|
||||
unsigned int CalypStream::getFrameNum()
|
||||
ClpULong CalypStream::getFrameNum()
|
||||
{
|
||||
return d->handler->m_uiTotalNumberFrames;
|
||||
}
|
||||
@@ -422,7 +422,7 @@ double CalypStream::getFrameRate()
|
||||
return d->handler->m_dFrameRate;
|
||||
}
|
||||
|
||||
int CalypStream::getCurrFrameNum()
|
||||
long CalypStream::getCurrFrameNum()
|
||||
{
|
||||
return d->iCurrFrameNum;
|
||||
}
|
||||
|
||||
+2
-2
@@ -79,11 +79,11 @@ public:
|
||||
|
||||
bool isNative();
|
||||
ClpString getFileName();
|
||||
unsigned int getFrameNum();
|
||||
ClpULong getFrameNum();
|
||||
unsigned int getWidth() const;
|
||||
unsigned int getHeight() const;
|
||||
int getEndianess() const;
|
||||
int getCurrFrameNum();
|
||||
long getCurrFrameNum();
|
||||
double getFrameRate();
|
||||
void getFormat( unsigned int& rWidth, unsigned int& rHeight, int& rInputFormat, unsigned int& rBitsPerPel, int& rEndianness,
|
||||
unsigned int& rFrameRate );
|
||||
|
||||
@@ -70,13 +70,13 @@ public:
|
||||
CalypStreamHandlerIf()
|
||||
: m_bIsInput( true )
|
||||
, m_bNative( true )
|
||||
, m_uiCurrFrameFileIdx( 0 )
|
||||
, m_uiWidth( 0 )
|
||||
, m_uiHeight( 0 )
|
||||
, m_iPixelFormat( -1 )
|
||||
, m_uiBitsPerPixel( 8 )
|
||||
, m_iEndianness( -1 )
|
||||
, m_dFrameRate( 30 )
|
||||
, m_uiCurrFrameFileIdx( 0 )
|
||||
, m_uiTotalNumberFrames( 0 )
|
||||
, m_pStreamBuffer( NULL )
|
||||
, m_uiNBytesPerFrame( 0 )
|
||||
@@ -89,7 +89,7 @@ public:
|
||||
virtual bool openHandler( ClpString strFilename, bool bInput ) = 0;
|
||||
virtual void closeHandler() = 0;
|
||||
virtual bool configureBuffer( CalypFrame* pcFrame ) = 0;
|
||||
virtual bool seek( unsigned long long int iFrameNum ) = 0;
|
||||
virtual bool seek( ClpULong iFrameNum ) = 0;
|
||||
virtual bool read( CalypFrame* pcFrame ) = 0;
|
||||
virtual bool write( CalypFrame* pcFrame ) = 0;
|
||||
|
||||
@@ -105,7 +105,6 @@ protected:
|
||||
ClpString m_strCodecName;
|
||||
bool m_bIsInput;
|
||||
bool m_bNative;
|
||||
unsigned long m_uiCurrFrameFileIdx;
|
||||
ClpString m_cFilename;
|
||||
unsigned int m_uiWidth;
|
||||
unsigned int m_uiHeight;
|
||||
@@ -113,9 +112,10 @@ protected:
|
||||
unsigned int m_uiBitsPerPixel;
|
||||
int m_iEndianness;
|
||||
double m_dFrameRate;
|
||||
unsigned long m_uiTotalNumberFrames;
|
||||
ClpULong m_uiCurrFrameFileIdx;
|
||||
ClpULong m_uiTotalNumberFrames;
|
||||
ClpByte* m_pStreamBuffer;
|
||||
unsigned long m_uiNBytesPerFrame;
|
||||
ClpULong m_uiNBytesPerFrame;
|
||||
bool m_isEOF;
|
||||
};
|
||||
|
||||
|
||||
@@ -335,7 +335,7 @@ bool StreamHandlerLibav::configureBuffer( CalypFrame* pcFrame )
|
||||
|
||||
void StreamHandlerLibav::calculateFrameNumber()
|
||||
{
|
||||
unsigned long long int num_frames;
|
||||
ClpULong num_frames;
|
||||
/*if( m_cStream->nb_frames )
|
||||
{
|
||||
num_frames = m_cStream->nb_frames;
|
||||
@@ -442,7 +442,7 @@ bool StreamHandlerLibav::write( CalypFrame* pcFrame )
|
||||
return false;
|
||||
}
|
||||
|
||||
bool StreamHandlerLibav::seek( unsigned long long int iFrameNum )
|
||||
bool StreamHandlerLibav::seek( ClpULong iFrameNum )
|
||||
{
|
||||
if( m_uiTotalNumberFrames == 1 )
|
||||
return true;
|
||||
|
||||
@@ -66,7 +66,7 @@ public:
|
||||
void closeHandler();
|
||||
bool configureBuffer( CalypFrame* pcFrame );
|
||||
void calculateFrameNumber();
|
||||
bool seek( unsigned long long int iFrameNum );
|
||||
bool seek( ClpULong iFrameNum );
|
||||
bool read( CalypFrame* pcFrame );
|
||||
bool write( CalypFrame* pcFrame );
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ bool StreamHandlerOpenCV::configureBuffer( CalypFrame* pcFrame )
|
||||
return true;
|
||||
}
|
||||
|
||||
bool StreamHandlerOpenCV::seek( unsigned long long int iFrameNum )
|
||||
bool StreamHandlerOpenCV::seek( ClpULong iFrameNum )
|
||||
{
|
||||
// m_uiCurrFrameFileIdx =
|
||||
return true;
|
||||
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
bool openHandler( ClpString strFilename, bool bInput );
|
||||
void closeHandler();
|
||||
bool configureBuffer( CalypFrame* pcFrame );
|
||||
bool seek( unsigned long long int iFrameNum );
|
||||
bool seek( ClpULong iFrameNum );
|
||||
bool read( CalypFrame* pcFrame );
|
||||
bool write( CalypFrame* pcFrame );
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ bool StreamHandlerPortableMap::configureBuffer( CalypFrame* pcFrame )
|
||||
return getMem1D<ClpByte>( &m_pStreamBuffer, pcFrame->getBytesPerFrame() );
|
||||
}
|
||||
|
||||
bool StreamHandlerPortableMap::seek( unsigned long long int iFrameNum )
|
||||
bool StreamHandlerPortableMap::seek( ClpULong iFrameNum )
|
||||
{
|
||||
// m_uiCurrFrameFileIdx =
|
||||
return true;
|
||||
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
bool openHandler( ClpString strFilename, bool bInput );
|
||||
void closeHandler();
|
||||
bool configureBuffer( CalypFrame* pcFrame );
|
||||
bool seek( unsigned long long int iFrameNum );
|
||||
bool seek( ClpULong iFrameNum );
|
||||
bool read( CalypFrame* pcFrame );
|
||||
bool write( CalypFrame* pcFrame );
|
||||
|
||||
|
||||
@@ -78,13 +78,13 @@ void StreamHandlerRaw::calculateFrameNumber()
|
||||
if( m_pFile && m_uiNBytesPerFrame > 0 )
|
||||
{
|
||||
fseek( m_pFile, 0, SEEK_END );
|
||||
unsigned long long int fileSize = ftell( m_pFile );
|
||||
unsigned long long fileSize = ftell( m_pFile );
|
||||
fseek( m_pFile, 0, SEEK_SET );
|
||||
m_uiTotalNumberFrames = fileSize / m_uiNBytesPerFrame;
|
||||
}
|
||||
}
|
||||
|
||||
bool StreamHandlerRaw::seek( unsigned long long int iFrameNum )
|
||||
bool StreamHandlerRaw::seek( ClpULong iFrameNum )
|
||||
{
|
||||
if( m_bIsInput && m_pFile )
|
||||
{
|
||||
|
||||
@@ -46,7 +46,7 @@ public:
|
||||
void closeHandler();
|
||||
bool configureBuffer( CalypFrame* pcFrame );
|
||||
void calculateFrameNumber();
|
||||
bool seek( unsigned long long int iFrameNum );
|
||||
bool seek( ClpULong iFrameNum );
|
||||
bool read( CalypFrame* pcFrame );
|
||||
bool write( CalypFrame* pcFrame );
|
||||
};
|
||||
|
||||
@@ -118,13 +118,13 @@ int CalypTools::openInputs()
|
||||
}
|
||||
}
|
||||
|
||||
m_uiNumberOfFrames = UINT_MAX;
|
||||
m_uiNumberOfFrames = -1;
|
||||
if( Opts().hasOpt( "frames" ) )
|
||||
{
|
||||
m_uiNumberOfFrames = m_iFrames;
|
||||
}
|
||||
|
||||
m_uiNumberOfComponents = UINT_MAX;
|
||||
m_uiNumberOfComponents = -1;
|
||||
for( unsigned int i = 0; i < m_apcInputStreams.size(); i++ )
|
||||
{
|
||||
m_uiNumberOfFrames = std::min( m_uiNumberOfFrames, m_apcInputStreams[i]->getFrameNum() );
|
||||
|
||||
+1
-1
@@ -78,7 +78,7 @@ private:
|
||||
MODULE_OPERATION,
|
||||
};
|
||||
|
||||
unsigned int m_uiNumberOfFrames;
|
||||
ClpULong m_uiNumberOfFrames;
|
||||
unsigned int m_uiNumberOfComponents;
|
||||
std::vector<CalypStream*> m_apcInputStreams;
|
||||
std::vector<CalypStream*> m_apcOutputStreams;
|
||||
|
||||
Reference in new issue
Block a user