Transfer endianess from frame to stream only
This commit is contained in:
1 parent
c8d7fb1c43
commit
a69c32bfbf
12 files changed
+52
-51
No files matched your search
@@ -501,7 +501,7 @@ Void ModulesHandle::applyAllModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf )
|
||||
if( !pcCurrModuleIf->m_pcModuleStream )
|
||||
{
|
||||
UInt Width = 0, Height = 0, FrameRate = 30;
|
||||
Int BitsPixel, Endianness, InputFormat = -1;
|
||||
Int BitsPixel, InputFormat = -1;
|
||||
|
||||
QString supported = tr( "Supported Files (" );
|
||||
QStringList formatsList;
|
||||
@@ -531,11 +531,10 @@ Void ModulesHandle::applyAllModuleIf( PlaYUVerAppModuleIf *pcCurrModuleIf )
|
||||
Height = pcCurrModuleIf->m_pcProcessedFrame->getHeight();
|
||||
InputFormat = pcCurrModuleIf->m_pcProcessedFrame->getPelFormat();
|
||||
BitsPixel = pcCurrModuleIf->m_pcProcessedFrame->getBitsPel();
|
||||
Endianness = pcCurrModuleIf->m_pcProcessedFrame->getEndianness();
|
||||
FrameRate = pcCurrModuleIf->m_pcSubWindow[0]->getInputStream()->getFrameRate();
|
||||
|
||||
pcCurrModuleIf->m_pcModuleStream = new PlaYUVerStream;
|
||||
if( !pcCurrModuleIf->m_pcModuleStream->open( fileName.toStdString(), Width, Height, InputFormat, BitsPixel, Endianness, FrameRate, false ) )
|
||||
if( !pcCurrModuleIf->m_pcModuleStream->open( fileName.toStdString(), Width, Height, InputFormat, BitsPixel, PLAYUVER_LITTLE_ENDIAN, FrameRate, false ) )
|
||||
{
|
||||
delete pcCurrModuleIf->m_pcModuleStream;
|
||||
pcCurrModuleIf->m_pcModuleStream = NULL;
|
||||
|
||||
+12
-1
@@ -319,8 +319,19 @@ Void VideoHandle::update()
|
||||
if( pcFrame )
|
||||
{
|
||||
resolution.append( QString( " %1 bpp" ).arg( pcFrame->getBitsPel() ) );
|
||||
m_pcResolutionLabel->setText( resolution );
|
||||
}
|
||||
if( pcStream && pcFrame->getBitsPel() > 8 )
|
||||
{
|
||||
if( pcStream->getEndianess() == PLAYUVER_BIG_ENDIAN )
|
||||
{
|
||||
resolution.append( QStringLiteral( " (BE)" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
resolution.append( QStringLiteral( " (LE)" ) );
|
||||
}
|
||||
}
|
||||
m_pcResolutionLabel->setText( resolution );
|
||||
|
||||
m_pcFramePropertiesSideBar->setFrame( pcFrame );
|
||||
|
||||
|
||||
+15
-24
@@ -135,7 +135,7 @@ struct PlaYUVerFramePrivate
|
||||
Int m_iPixelFormat; //!< Pixel format number (it follows the list of supported pixel formats)
|
||||
Int m_iNumberChannels; //!< Number of channels
|
||||
UInt m_uiBitsPel; //!< Bits per pixel/channel
|
||||
Int m_iEndianness; //!< Endiannes of bytes
|
||||
// Int m_iEndianness; //!< Endiannes of bytes
|
||||
UInt m_uiHalfPelValue; //!< Bits per pixel/channel
|
||||
|
||||
Pel*** m_pppcInputPel;
|
||||
@@ -165,7 +165,7 @@ struct PlaYUVerFramePrivate
|
||||
* @param pel_format pixel format index (always use PixelFormats enum)
|
||||
*
|
||||
*/
|
||||
Void init( UInt width, UInt height, Int pel_format, Int bitsPixel, Int endianness )
|
||||
Void init( UInt width, UInt height, Int pel_format, Int bitsPixel )
|
||||
{
|
||||
m_bInit = false;
|
||||
m_pppcInputPel = NULL;
|
||||
@@ -175,11 +175,6 @@ struct PlaYUVerFramePrivate
|
||||
m_iPixelFormat = pel_format;
|
||||
m_iNumberChannels = 3;
|
||||
m_uiBitsPel = bitsPixel > 8 ? bitsPixel : 8;
|
||||
m_iEndianness = endianness;
|
||||
if( m_uiBitsPel > 8 && m_iEndianness == -1 )
|
||||
{
|
||||
throw PlaYUVerFailure( "PlaYUVerFrame", "Invalid endianness type for Bits per Pixel greater than 8" );
|
||||
}
|
||||
m_uiHalfPelValue = 1 << ( m_uiBitsPel - 1 );
|
||||
|
||||
if( m_uiWidth == 0 || m_uiHeight == 0 || m_iPixelFormat == -1 || bitsPixel > 16 )
|
||||
@@ -220,16 +215,16 @@ struct PlaYUVerFramePrivate
|
||||
* \brief Constructors
|
||||
*/
|
||||
|
||||
PlaYUVerFrame::PlaYUVerFrame( UInt width, UInt height, Int pelFormat, Int bitsPixel, Int endianness ) :
|
||||
PlaYUVerFrame::PlaYUVerFrame( UInt width, UInt height, Int pelFormat, Int bitsPixel ) :
|
||||
d( new PlaYUVerFramePrivate )
|
||||
{
|
||||
d->init( width, height, pelFormat, bitsPixel, endianness );
|
||||
d->init( width, height, pelFormat, bitsPixel );
|
||||
}
|
||||
|
||||
PlaYUVerFrame::PlaYUVerFrame( const PlaYUVerFrame& other ) :
|
||||
d( new PlaYUVerFramePrivate )
|
||||
{
|
||||
d->init( other.getWidth(), other.getHeight(), other.getPelFormat(), other.getBitsPel(), other.getEndianness() );
|
||||
d->init( other.getWidth(), other.getHeight(), other.getPelFormat(), other.getBitsPel() );
|
||||
copyFrom( &other );
|
||||
}
|
||||
|
||||
@@ -239,7 +234,7 @@ PlaYUVerFrame::PlaYUVerFrame( const PlaYUVerFrame *other ) :
|
||||
{
|
||||
if( other )
|
||||
{
|
||||
d->init( other->getWidth(), other->getHeight(), other->getPelFormat(), other->getBitsPel(), other->getEndianness() );
|
||||
d->init( other->getWidth(), other->getHeight(), other->getPelFormat(), other->getBitsPel() );
|
||||
copyFrom( other );
|
||||
}
|
||||
}
|
||||
@@ -265,7 +260,7 @@ PlaYUVerFrame::PlaYUVerFrame( const PlaYUVerFrame& other, UInt x, UInt y, UInt w
|
||||
height++;
|
||||
}
|
||||
|
||||
d->init( width, height, other.getPelFormat(), other.getBitsPel(), other.getEndianness() );
|
||||
d->init( width, height, other.getPelFormat(), other.getBitsPel() );
|
||||
copyFrom( other, x, y );
|
||||
}
|
||||
|
||||
@@ -293,7 +288,7 @@ PlaYUVerFrame::PlaYUVerFrame( const PlaYUVerFrame *other, UInt posX, UInt posY,
|
||||
areaHeight++;
|
||||
}
|
||||
|
||||
d->init( areaWidth, areaHeight, other->getPelFormat(), other->getBitsPel(), other->getEndianness() );
|
||||
d->init( areaWidth, areaHeight, other->getPelFormat(), other->getBitsPel() );
|
||||
copyFrom( other, posX, posY );
|
||||
}
|
||||
|
||||
@@ -410,10 +405,6 @@ UInt PlaYUVerFrame::getBitsPel() const
|
||||
{
|
||||
return d->m_uiBitsPel;
|
||||
}
|
||||
Int PlaYUVerFrame::getEndianness() const
|
||||
{
|
||||
return d->m_iEndianness;
|
||||
}
|
||||
|
||||
UInt64 PlaYUVerFrame::getBytesPerFrame()
|
||||
{
|
||||
@@ -556,15 +547,15 @@ Void PlaYUVerFrame::copyFrom( const PlaYUVerFrame* other, UInt x, UInt y )
|
||||
copyFrom( *other, x, y );
|
||||
}
|
||||
|
||||
Void PlaYUVerFrame::frameFromBuffer( Byte *Buff, UInt64 uiBuffSize )
|
||||
Void PlaYUVerFrame::frameFromBuffer( Byte *Buff, Int iEndianness, UInt64 uiBuffSize )
|
||||
{
|
||||
if( uiBuffSize != getBytesPerFrame() )
|
||||
return;
|
||||
|
||||
frameFromBuffer( Buff );
|
||||
frameFromBuffer( Buff, iEndianness );
|
||||
}
|
||||
|
||||
Void PlaYUVerFrame::frameFromBuffer( Byte *Buff )
|
||||
Void PlaYUVerFrame::frameFromBuffer( Byte *Buff, Int iEndianness )
|
||||
{
|
||||
Byte* ppBuff[MAX_NUMBER_PLANES];
|
||||
Byte* pTmpBuff;
|
||||
@@ -578,7 +569,7 @@ Void PlaYUVerFrame::frameFromBuffer( Byte *Buff )
|
||||
Int b;
|
||||
Int maxval = pow(2, d->m_uiBitsPel) - 1;
|
||||
|
||||
if( d->m_iEndianness == 0 )
|
||||
if( iEndianness == 0 )
|
||||
{
|
||||
startByte = bytesPixel - 1;
|
||||
endByte = -1;
|
||||
@@ -622,7 +613,7 @@ Void PlaYUVerFrame::frameFromBuffer( Byte *Buff )
|
||||
d->m_bHasHistogram = false;
|
||||
}
|
||||
|
||||
Void PlaYUVerFrame::frameToBuffer( Byte *output_buffer )
|
||||
Void PlaYUVerFrame::frameToBuffer( Byte *output_buffer, Int iEndianness )
|
||||
{
|
||||
UInt bytesPixel = ( d->m_uiBitsPel - 1 ) / 8 + 1;
|
||||
Byte* ppBuff[MAX_NUMBER_PLANES];
|
||||
@@ -635,7 +626,7 @@ Void PlaYUVerFrame::frameToBuffer( Byte *output_buffer )
|
||||
Int incByte = 1;
|
||||
Int b;
|
||||
|
||||
if( d->m_iEndianness == 0 )
|
||||
if( iEndianness == 0 )
|
||||
{
|
||||
startByte = bytesPixel - 1;
|
||||
endByte = -1;
|
||||
@@ -1225,7 +1216,7 @@ Bool PlaYUVerFrame::fromMat( cv::Mat& cvMat )
|
||||
return false;
|
||||
}
|
||||
}
|
||||
d->init( cvMat.cols, cvMat.rows, d->m_iPixelFormat, 8, -1 );
|
||||
d->init( cvMat.cols, cvMat.rows, d->m_iPixelFormat, 8 );
|
||||
}
|
||||
|
||||
d->m_bHasRGBPel = false;
|
||||
|
||||
+4
-5
@@ -101,7 +101,7 @@ public:
|
||||
*
|
||||
* @note this function might misbehave if the pixel format enum is not correct
|
||||
*/
|
||||
PlaYUVerFrame( UInt width, UInt height, Int pelFormat, Int bitsPixel = 8, Int endianness = -1 );
|
||||
PlaYUVerFrame( UInt width, UInt height, Int pelFormat, Int bitsPixel = 8 );
|
||||
|
||||
/**
|
||||
* Copy contructor
|
||||
@@ -178,7 +178,6 @@ public:
|
||||
UInt getChromaSize() const;
|
||||
|
||||
UInt getBitsPel() const;
|
||||
Int getEndianness() const;
|
||||
|
||||
/**
|
||||
* Get number of bytes per frame of an existing frame
|
||||
@@ -213,9 +212,9 @@ public:
|
||||
Void copyFrom( const PlaYUVerFrame&, UInt, UInt );
|
||||
Void copyFrom( const PlaYUVerFrame*, UInt, UInt );
|
||||
|
||||
Void frameFromBuffer( Byte*, UInt64 );
|
||||
Void frameFromBuffer( Byte* );
|
||||
Void frameToBuffer( Byte* );
|
||||
Void frameFromBuffer( Byte*, Int, UInt64 );
|
||||
Void frameFromBuffer( Byte*, Int );
|
||||
Void frameToBuffer( Byte*, Int );
|
||||
|
||||
Void fillRGBBuffer();
|
||||
|
||||
|
||||
@@ -240,8 +240,7 @@ Bool PlaYUVerStream::open( String filename, UInt width, UInt height, Int input_f
|
||||
{
|
||||
try
|
||||
{
|
||||
m_ppcFrameBuffer[i] = new PlaYUVerFrame( m_pcHandler->m_uiWidth, m_pcHandler->m_uiHeight, m_pcHandler->m_iPixelFormat, m_pcHandler->m_uiBitsPerPixel,
|
||||
m_pcHandler->m_iEndianness );
|
||||
m_ppcFrameBuffer[i] = new PlaYUVerFrame( m_pcHandler->m_uiWidth, m_pcHandler->m_uiHeight, m_pcHandler->m_iPixelFormat, m_pcHandler->m_uiBitsPerPixel );
|
||||
}
|
||||
catch( PlaYUVerFailure& e )
|
||||
{
|
||||
@@ -349,6 +348,10 @@ UInt PlaYUVerStream::getHeight() const
|
||||
{
|
||||
return m_pcHandler->m_uiHeight;
|
||||
}
|
||||
Int PlaYUVerStream::getEndianess() const
|
||||
{
|
||||
return m_pcHandler->m_iEndianness;
|
||||
}
|
||||
Double PlaYUVerStream::getFrameRate()
|
||||
{
|
||||
return m_pcHandler->m_dFrameRate;
|
||||
@@ -498,7 +501,7 @@ Bool PlaYUVerStream::saveFrame( const String& filename, PlaYUVerFrame *saveFrame
|
||||
{
|
||||
PlaYUVerStream auxSaveStream;
|
||||
if( !auxSaveStream.open( filename, saveFrame->getWidth(), saveFrame->getHeight(), saveFrame->getPelFormat(), saveFrame->getBitsPel(),
|
||||
saveFrame->getEndianness(), 1, false ) )
|
||||
PLAYUVER_LITTLE_ENDIAN, 1, false ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -105,6 +105,7 @@ public:
|
||||
UInt getFrameNum();
|
||||
UInt getWidth() const;
|
||||
UInt getHeight() const;
|
||||
Int getEndianess() const;
|
||||
Int getCurrFrameNum();
|
||||
Double getFrameRate();
|
||||
Void getFormat( UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rBitsPerPel, Int& rEndianness, UInt& rFrameRate );
|
||||
|
||||
@@ -358,7 +358,7 @@ Bool StreamHandlerLibav::read( PlaYUVerFrame* pcFrame )
|
||||
if( orig_pkt.size )
|
||||
av_free_packet( &orig_pkt );
|
||||
|
||||
pcFrame->frameFromBuffer( m_pStreamBuffer );
|
||||
pcFrame->frameFromBuffer( m_pStreamBuffer, m_iEndianness );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ Bool StreamHandlerPortableMap::read( PlaYUVerFrame* pcFrame )
|
||||
UInt64 processed_bytes = fread( m_pStreamBuffer, sizeof(Byte), m_uiNBytesPerFrame, m_pFile );
|
||||
if( processed_bytes != m_uiNBytesPerFrame )
|
||||
return false;
|
||||
pcFrame->frameFromBuffer( m_pStreamBuffer );
|
||||
pcFrame->frameFromBuffer( m_pStreamBuffer, PLAYUVER_BIG_ENDIAN );
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ Bool StreamHandlerPortableMap::write( PlaYUVerFrame* pcFrame )
|
||||
{
|
||||
fprintf( m_pFile, "%d\n", m_iMaxValue );
|
||||
}
|
||||
pcFrame->frameToBuffer( m_pStreamBuffer );
|
||||
pcFrame->frameToBuffer( m_pStreamBuffer, PLAYUVER_BIG_ENDIAN );
|
||||
UInt64 processed_bytes = fwrite( m_pStreamBuffer, sizeof(Byte), m_uiNBytesPerFrame, m_pFile );
|
||||
if( processed_bytes != m_uiNBytesPerFrame )
|
||||
return false;
|
||||
|
||||
@@ -81,13 +81,13 @@ Bool StreamHandlerRaw::read( PlaYUVerFrame* pcFrame )
|
||||
UInt64 processed_bytes = fread( m_pStreamBuffer, sizeof(Byte), m_uiNBytesPerFrame, m_pFile );
|
||||
if( processed_bytes != m_uiNBytesPerFrame )
|
||||
return false;
|
||||
pcFrame->frameFromBuffer( m_pStreamBuffer );
|
||||
pcFrame->frameFromBuffer( m_pStreamBuffer, m_iEndianness );
|
||||
return true;
|
||||
}
|
||||
|
||||
Bool StreamHandlerRaw::write( PlaYUVerFrame* pcFrame )
|
||||
{
|
||||
pcFrame->frameToBuffer( m_pStreamBuffer );
|
||||
pcFrame->frameToBuffer( m_pStreamBuffer, m_iEndianness );
|
||||
UInt64 processed_bytes = fwrite( m_pStreamBuffer, sizeof(Byte), m_uiNBytesPerFrame, m_pFile );
|
||||
if( processed_bytes != m_uiNBytesPerFrame )
|
||||
return false;
|
||||
|
||||
@@ -31,10 +31,10 @@ FilterComponentModule::FilterComponentModule()
|
||||
m_pcFilteredFrame = NULL;
|
||||
}
|
||||
|
||||
Bool FilterComponentModule::createFilter( UInt uiWidth, UInt uiHeight, UInt bitsPixel, UInt uiEndianness )
|
||||
Bool FilterComponentModule::createFilter( UInt uiWidth, UInt uiHeight, UInt bitsPixel )
|
||||
{
|
||||
m_pcFilteredFrame = NULL;
|
||||
m_pcFilteredFrame = new PlaYUVerFrame( uiWidth, uiHeight, PlaYUVerFrame::GRAY, bitsPixel, uiEndianness );
|
||||
m_pcFilteredFrame = new PlaYUVerFrame( uiWidth, uiHeight, PlaYUVerFrame::GRAY, bitsPixel );
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -69,8 +69,7 @@ FilterComponentLuma::FilterComponentLuma()
|
||||
|
||||
Bool FilterComponentLuma::create( std::vector<PlaYUVerFrame*> apcFrameList )
|
||||
{
|
||||
return createFilter( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), apcFrameList[0]->getBitsPel(),
|
||||
apcFrameList[0]->getEndianness() );
|
||||
return createFilter( apcFrameList[0]->getWidth(), apcFrameList[0]->getHeight(), apcFrameList[0]->getBitsPel() );
|
||||
}
|
||||
|
||||
PlaYUVerFrame* FilterComponentLuma::process( std::vector<PlaYUVerFrame*> apcFrameList )
|
||||
@@ -94,8 +93,7 @@ Bool FilterComponentChromaU::create( std::vector<PlaYUVerFrame*> apcFrameList )
|
||||
{
|
||||
if( apcFrameList[0]->getNumberChannels() > 1 )
|
||||
{
|
||||
return createFilter( apcFrameList[0]->getChromaWidth(), apcFrameList[0]->getChromaHeight(), apcFrameList[0]->getBitsPel(),
|
||||
apcFrameList[0]->getEndianness() );
|
||||
return createFilter( apcFrameList[0]->getChromaWidth(), apcFrameList[0]->getChromaHeight(), apcFrameList[0]->getBitsPel() );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -121,8 +119,7 @@ Bool FilterComponentChromaV::create( std::vector<PlaYUVerFrame*> apcFrameList )
|
||||
{
|
||||
if( apcFrameList[0]->getNumberChannels() > 1 )
|
||||
{
|
||||
return createFilter( apcFrameList[0]->getChromaWidth(), apcFrameList[0]->getChromaHeight(), apcFrameList[0]->getBitsPel(),
|
||||
apcFrameList[0]->getEndianness() );
|
||||
return createFilter( apcFrameList[0]->getChromaWidth(), apcFrameList[0]->getChromaHeight(), apcFrameList[0]->getBitsPel() );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ private:
|
||||
PlaYUVerFrame* process( std::vector<PlaYUVerFrame*> apcFrameList ) = 0;
|
||||
Void destroy();
|
||||
|
||||
Bool createFilter( UInt uiWidth, UInt uiHeight, UInt bitsPixel, UInt uiEndianness );
|
||||
Bool createFilter( UInt uiWidth, UInt uiHeight, UInt bitsPixel );
|
||||
PlaYUVerFrame* filterComponent( PlaYUVerFrame* InputFrame, Int Component );
|
||||
};
|
||||
|
||||
|
||||
@@ -283,7 +283,7 @@ Int PlaYUVerTools::Open( Int argc, Char *argv[] )
|
||||
PlaYUVerStream* pcModStream = new PlaYUVerStream;
|
||||
try
|
||||
{
|
||||
pcModStream->open( outputFileNames[0], pcModFrame->getWidth(), pcModFrame->getHeight(), pcModFrame->getPelFormat(), pcModFrame->getBitsPel(), pcModFrame->getEndianness(), 1, false );
|
||||
pcModStream->open( outputFileNames[0], pcModFrame->getWidth(), pcModFrame->getHeight(), pcModFrame->getPelFormat(), pcModFrame->getBitsPel(), PLAYUVER_LITTLE_ENDIAN, 1, false );
|
||||
}
|
||||
catch( const char *msg )
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user