Fix warnings
This commit is contained in:
5 files changed
+103
-154
No files matched your search
+37
-39
@@ -41,6 +41,9 @@
|
||||
#include <opencv2/imgproc/imgproc.hpp>
|
||||
#endif
|
||||
|
||||
constexpr auto kMinBitsPerPixel = 8;
|
||||
constexpr auto kMaxBitsPerPixel = 16;
|
||||
|
||||
std::vector<ClpString> CalypFrame::supportedColorSpacesListNames()
|
||||
{
|
||||
return std::vector<ClpString>{
|
||||
@@ -74,7 +77,7 @@ std::vector<ClpString> CalypFrame::supportedPixelFormatListNames( int colorSpace
|
||||
|
||||
int CalypFrame::numberOfFormats()
|
||||
{
|
||||
return g_CalypPixFmtDescriptorsMap.size();
|
||||
return static_cast<int>( g_CalypPixFmtDescriptorsMap.size() );
|
||||
}
|
||||
|
||||
int CalypFrame::findPixelFormat( const ClpString& name )
|
||||
@@ -95,40 +98,39 @@ int CalypFrame::pelformatColorSpace( const int idx )
|
||||
class CalypFrame::CalypFramePrivate
|
||||
{
|
||||
public:
|
||||
bool m_bInit;
|
||||
bool m_bInit{ false };
|
||||
|
||||
//! Struct with the pixel format description.
|
||||
const CalypPixelFormatDescriptor* m_pcPelFormat;
|
||||
const CalypPixelFormatDescriptor* m_pcPelFormat{ nullptr };
|
||||
ClpString m_cPelFmtName;
|
||||
|
||||
unsigned int m_uiWidth; //!< Width of the frame
|
||||
unsigned int m_uiHeight; //!< Height of the frame
|
||||
int m_iPixelFormat; //!< Pixel format number (it follows the list of supported pixel formats)
|
||||
unsigned int m_uiBitsPel; //!< Bits per pixel/channel
|
||||
unsigned int m_uiHalfPelValue; //!< Bits per pixel/channel
|
||||
bool m_bHasNegativeValues; //!< Half of the scale correspond to negative values
|
||||
unsigned int m_uiWidth{ 0 }; //!< Width of the frame
|
||||
unsigned int m_uiHeight{ 0 }; //!< Height of the frame
|
||||
int m_iPixelFormat{ 0 }; //!< Pixel format number (it follows the list of supported pixel formats)
|
||||
unsigned int m_uiBitsPel{ 0 }; //!< Bits per pixel/channel
|
||||
unsigned int m_uiHalfPelValue{ 0 }; //!< Bits per pixel/channel
|
||||
bool m_bHasNegativeValues{ false }; //!< Half of the scale correspond to negative values
|
||||
|
||||
ClpPel*** m_pppcInputPel;
|
||||
ClpPel*** m_pppcInputPel{ nullptr };
|
||||
|
||||
bool m_bHasRGBPel; //!< Flag indicating that the ARGB buffer was computed
|
||||
bool m_bHasRGBPel{ false }; //!< Flag indicating that the ARGB buffer was computed
|
||||
std::vector<std::uint8_t> m_pcARGB32; //!< Buffer with the ARGB pixels used in Qt libs
|
||||
|
||||
/** Histogram control variables **/
|
||||
bool m_bHasHistogram;
|
||||
bool m_bHistogramRunning;
|
||||
bool m_bHasHistogram{ false };
|
||||
bool m_bHistogramRunning{ false };
|
||||
/** The histogram data.*/
|
||||
std::vector<unsigned int> m_puiHistogram;
|
||||
/** If the image is RGB and calcLuma is true, we have 1 more channel */
|
||||
unsigned int m_uiHistoChannels;
|
||||
unsigned int m_uiHistoChannels{ 0 };
|
||||
/** Numbers of histogram segments depending of image bytes depth*/
|
||||
unsigned int m_uiHistoSegments;
|
||||
unsigned int m_uiHistoSegments{ 0 };
|
||||
|
||||
CalypFramePrivate()
|
||||
{
|
||||
m_bInit = false;
|
||||
m_bHasRGBPel = false;
|
||||
m_pppcInputPel = nullptr;
|
||||
}
|
||||
CalypFramePrivate() = default;
|
||||
CalypFramePrivate( const CalypFramePrivate& ) = delete;
|
||||
CalypFramePrivate( CalypFramePrivate&& ) = delete;
|
||||
CalypFramePrivate& operator=( const CalypFramePrivate& ) = delete;
|
||||
CalypFramePrivate& operator=( CalypFramePrivate&& ) = delete;
|
||||
|
||||
void init( unsigned int width, unsigned int height, int pel_format, unsigned bitsPixel )
|
||||
{
|
||||
@@ -140,11 +142,11 @@ public:
|
||||
m_uiWidth = width;
|
||||
m_uiHeight = height;
|
||||
m_iPixelFormat = pel_format;
|
||||
m_uiBitsPel = bitsPixel < 8 ? 8 : bitsPixel;
|
||||
m_uiBitsPel = bitsPixel < kMinBitsPerPixel ? kMinBitsPerPixel : bitsPixel;
|
||||
m_uiHalfPelValue = 1 << ( m_uiBitsPel - 1 );
|
||||
m_bHasNegativeValues = has_negative_values;
|
||||
|
||||
if( m_uiWidth == 0 || m_uiHeight == 0 || m_iPixelFormat == -1 || bitsPixel > 16 )
|
||||
if( m_uiWidth == 0 || m_uiHeight == 0 || m_iPixelFormat == -1 || bitsPixel > kMaxBitsPerPixel )
|
||||
{
|
||||
throw CalypFailure( "CalypFrame", "Cannot create a CalypFrame of this type" );
|
||||
}
|
||||
@@ -809,7 +811,7 @@ void CalypFrame::fillRGBBuffer() const
|
||||
if( d->m_pcPelFormat->colorSpace == CLP_COLOR_GRAY )
|
||||
{
|
||||
ClpPel* pY = d->m_pppcInputPel[CLP_LUMA][0];
|
||||
unsigned char finalPel;
|
||||
unsigned char finalPel{ 0 };
|
||||
for( unsigned int i = 0; i < d->m_uiHeight * d->m_uiWidth; i++ )
|
||||
{
|
||||
finalPel = ( *pY++ ) >> shiftBits;
|
||||
@@ -844,32 +846,28 @@ void CalypFrame::fillRGBBuffer() const
|
||||
ClpPel* pLineU = d->m_pppcInputPel[CLP_CHROMA_U][0];
|
||||
ClpPel* pLineV = d->m_pppcInputPel[CLP_CHROMA_V][0];
|
||||
unsigned int uiChromaStride = CHROMASHIFT( d->m_uiWidth, d->m_pcPelFormat->log2ChromaWidth );
|
||||
ClpPel* pY;
|
||||
ClpPel* pU;
|
||||
ClpPel* pV;
|
||||
|
||||
int iY, iU, iV, iR, iG, iB;
|
||||
uint32_t* pARGBLine = pARGB;
|
||||
uint32_t* pARGBAux;
|
||||
|
||||
unsigned int y, x;
|
||||
int i, j;
|
||||
for( y = 0; y < CHROMASHIFT( d->m_uiHeight, d->m_pcPelFormat->log2ChromaHeight ); y++ )
|
||||
for( int y = 0; y < CHROMASHIFT( d->m_uiHeight, d->m_pcPelFormat->log2ChromaHeight ); y++ )
|
||||
{
|
||||
for( i = 0; i < 1 << d->m_pcPelFormat->log2ChromaHeight; i++ )
|
||||
for( int i = 0; i < 1 << d->m_pcPelFormat->log2ChromaHeight; i++ )
|
||||
{
|
||||
pY = pLineY;
|
||||
pU = pLineU;
|
||||
pV = pLineV;
|
||||
ClpPel* pY = pLineY;
|
||||
ClpPel* pU = pLineU;
|
||||
ClpPel* pV = pLineV;
|
||||
pARGBAux = pARGBLine;
|
||||
for( x = 0; x < CHROMASHIFT( d->m_uiWidth, d->m_pcPelFormat->log2ChromaWidth ); x++ )
|
||||
for( int x = 0; x < CHROMASHIFT( d->m_uiWidth, d->m_pcPelFormat->log2ChromaWidth ); x++ )
|
||||
{
|
||||
iU = *pU++;
|
||||
int iU = *pU++;
|
||||
iU >>= shiftBits;
|
||||
iV = *pV++;
|
||||
int iV = *pV++;
|
||||
iV >>= shiftBits;
|
||||
for( j = 0; j < ( 1 << d->m_pcPelFormat->log2ChromaWidth ); j++ )
|
||||
for( int j = 0; j < ( 1 << d->m_pcPelFormat->log2ChromaWidth ); j++ )
|
||||
{
|
||||
iY = *pY++;
|
||||
int iY = *pY++;
|
||||
iY >>= shiftBits;
|
||||
YUV2RGB( iY, iU, iV, iR, iG, iB );
|
||||
*pARGBAux++ = PEL_RGB( iR, iG, iB );
|
||||
|
||||
+16
-107
@@ -46,6 +46,9 @@
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
constexpr auto kDefaultBitsPerPixel = 8;
|
||||
constexpr auto kDefaultFrameRate = 30;
|
||||
|
||||
std::vector<CalypStreamFormat> CalypStream::supportedReadFormats()
|
||||
{
|
||||
INI_REGIST_CALYP_SUPPORTED_FMT;
|
||||
@@ -102,109 +105,6 @@ std::vector<CalypStandardResolution> CalypStream::stdResolutionSizes()
|
||||
return stdResList;
|
||||
}
|
||||
|
||||
class CalypStreamBufferPrivate
|
||||
{
|
||||
private:
|
||||
std::vector<CalypFrame> m_framePool;
|
||||
std::deque<CalypFrame> m_frameBuffer;
|
||||
std::int64_t m_iSize;
|
||||
std::int64_t m_iReadIndex;
|
||||
std::int64_t m_iWriteIndex;
|
||||
|
||||
public:
|
||||
CalypStreamBufferPrivate( std::size_t size, unsigned int width, unsigned int height, int pelFormat, unsigned int bitsPixel, bool hasNegative )
|
||||
{
|
||||
m_framePool.reserve( size );
|
||||
for( std::size_t i = 0; i < size; i++ )
|
||||
{
|
||||
m_framePool.push_back( CalypFrame{ width, height, pelFormat, bitsPixel, hasNegative } );
|
||||
}
|
||||
m_iSize = std::ssize( m_framePool );
|
||||
m_iReadIndex = -1;
|
||||
m_iWriteIndex = 0;
|
||||
}
|
||||
|
||||
~CalypStreamBufferPrivate() = default;
|
||||
|
||||
void increase( std::size_t newSize )
|
||||
{
|
||||
m_framePool.reserve( newSize );
|
||||
for( std::size_t i = m_iSize; i < newSize; i++ )
|
||||
{
|
||||
m_framePool.push_back( CalypFrame{ m_framePool[0].getWidth(),
|
||||
m_framePool[0].getHeight(),
|
||||
m_framePool[0].getPelFormat(),
|
||||
m_framePool[0].getBitsPel(),
|
||||
m_framePool[0].getHasNegativeValues() } );
|
||||
}
|
||||
m_iSize = std::ssize( m_framePool );
|
||||
}
|
||||
|
||||
void setIndex( std::int64_t i )
|
||||
{
|
||||
m_iWriteIndex = m_iReadIndex = i;
|
||||
m_iWriteIndex = nextIndex( m_iWriteIndex );
|
||||
}
|
||||
void reset()
|
||||
{
|
||||
m_iReadIndex = -1;
|
||||
m_iWriteIndex = 0;
|
||||
}
|
||||
void startRead()
|
||||
{
|
||||
assert( m_iWriteIndex >= 0 );
|
||||
m_iReadIndex = 0;
|
||||
}
|
||||
CalypFrame& frame( int i ) { return m_framePool.at( i ); }
|
||||
|
||||
CalypFrame& currentRead()
|
||||
{
|
||||
assert( m_iReadIndex < m_iWriteIndex && ( m_iReadIndex % m_iSize ) < m_iSize );
|
||||
return m_framePool.at( m_iReadIndex % m_iSize );
|
||||
}
|
||||
|
||||
const CalypFrame& ref() { return m_framePool.at( m_iWriteIndex % m_iSize ); }
|
||||
|
||||
CalypFrame& readOneFrame()
|
||||
{
|
||||
assert( m_iReadIndex < m_iWriteIndex && ( m_iReadIndex % m_iSize ) < m_iSize );
|
||||
CalypFrame& frameToRead = m_framePool.at( m_iReadIndex % m_iSize );
|
||||
m_iReadIndex = nextIndex( m_iReadIndex );
|
||||
return frameToRead;
|
||||
}
|
||||
CalypFrame& writeOneFrame()
|
||||
{
|
||||
assert( m_iWriteIndex > m_iReadIndex && ( m_iReadIndex % m_iSize ) != ( m_iWriteIndex % m_iSize ) );
|
||||
CalypFrame& frameToWrite = m_framePool.at( m_iWriteIndex % m_iSize );
|
||||
m_iWriteIndex = nextIndex( m_iWriteIndex );
|
||||
return frameToWrite;
|
||||
}
|
||||
|
||||
bool hasWritingSlot()
|
||||
{
|
||||
if( ( m_iReadIndex % m_iSize ) != ( m_iWriteIndex % m_iSize ) )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::shared_ptr<CalypFrame> retrieveFrame()
|
||||
{
|
||||
assert( m_iReadIndex < m_iWriteIndex && ( m_iReadIndex % m_iSize ) < m_iSize );
|
||||
auto ptr = std::make_shared<CalypFrame>( std::move( m_framePool[m_iReadIndex % m_iSize] ) );
|
||||
m_framePool[m_iReadIndex % m_iSize] = CalypFrame{ ptr->getWidth(),
|
||||
ptr->getHeight(),
|
||||
ptr->getPelFormat(),
|
||||
ptr->getBitsPel(),
|
||||
ptr->getHasNegativeValues() };
|
||||
m_iReadIndex = nextIndex( m_iReadIndex );
|
||||
return ptr;
|
||||
}
|
||||
|
||||
private:
|
||||
//inline int nextIndex( std::int64_t curr ) { return curr + 1 >= m_iSize ? 0 : curr + 1; }
|
||||
inline int nextIndex( std::int64_t curr ) { return curr + 1; }
|
||||
};
|
||||
|
||||
struct CalypStreamFrameBuffer : std::enable_shared_from_this<CalypStreamFrameBuffer>
|
||||
{
|
||||
std::mutex buffer_mutex;
|
||||
@@ -221,6 +121,11 @@ struct CalypStreamFrameBuffer : std::enable_shared_from_this<CalypStreamFrameBuf
|
||||
bufferIdx = framePool.size();
|
||||
}
|
||||
|
||||
CalypStreamFrameBuffer( const CalypStreamFrameBuffer& ) = delete;
|
||||
CalypStreamFrameBuffer( CalypStreamFrameBuffer&& ) = delete;
|
||||
CalypStreamFrameBuffer& operator=( const CalypStreamFrameBuffer& ) = delete;
|
||||
CalypStreamFrameBuffer& operator=( CalypStreamFrameBuffer&& ) = delete;
|
||||
|
||||
~CalypStreamFrameBuffer() = default;
|
||||
|
||||
void increase( std::size_t newSize )
|
||||
@@ -276,6 +181,10 @@ public:
|
||||
long long int iCurrFrameNum;
|
||||
bool bLoadAll;
|
||||
|
||||
CalypStreamPrivate( const CalypStreamPrivate& ) = delete;
|
||||
CalypStreamPrivate( CalypStreamPrivate&& ) = delete;
|
||||
CalypStreamPrivate& operator=( const CalypStreamPrivate& ) = delete;
|
||||
CalypStreamPrivate& operator=( CalypStreamPrivate&& ) = delete;
|
||||
CalypStreamPrivate()
|
||||
{
|
||||
handler = nullptr;
|
||||
@@ -549,7 +458,7 @@ bool CalypStream::reload()
|
||||
{
|
||||
d->iCurrFrameNum = 0;
|
||||
}
|
||||
int currFrameNum = d->iCurrFrameNum;
|
||||
auto currFrameNum = d->iCurrFrameNum;
|
||||
d->iCurrFrameNum = -1;
|
||||
seekInput( currFrameNum );
|
||||
return true;
|
||||
@@ -605,16 +514,16 @@ void CalypStream::getFormat( unsigned int& rWidth, unsigned int& rHeight, int& r
|
||||
rInputFormat = d->handler->m_iPixelFormat;
|
||||
rBitsPerPel = d->handler->m_uiBitsPerPixel;
|
||||
rEndianness = d->handler->m_iEndianness;
|
||||
rFrameRate = d->handler->m_dFrameRate;
|
||||
rFrameRate = static_cast<unsigned>( std::max( 0.0, d->handler->m_dFrameRate ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
rWidth = 0;
|
||||
rHeight = 0;
|
||||
rInputFormat = CLP_YUV420P;
|
||||
rBitsPerPel = 8;
|
||||
rBitsPerPel = kDefaultBitsPerPixel;
|
||||
rEndianness = 0;
|
||||
rFrameRate = 30;
|
||||
rFrameRate = kDefaultFrameRate;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user