Add a variable to control the number of bits per pixel

This commit is contained in:
2015-04-02 17:34:43 +01:00
parent 32c224a49d
commit d8952ce953
11 changed files with 84 additions and 52 deletions
+19 -1
View File
@@ -174,6 +174,21 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget *parent ) :
pixelGridLayout->addItem( new QSpacerItem( 10, 10, QSizePolicy::Expanding, QSizePolicy::Minimum ), 1, 1 ); pixelGridLayout->addItem( new QSpacerItem( 10, 10, QSizePolicy::Expanding, QSizePolicy::Minimum ), 1, 1 );
pixelGridLayout->addWidget( m_comboBoxPixelFormat, 1, 2 ); pixelGridLayout->addWidget( m_comboBoxPixelFormat, 1, 2 );
/*
* Frame rate format
*/
QHBoxLayout* bitsPerPelLayout = new QHBoxLayout();
QLabel* bitsPerPelLabel = new QLabel();
bitsPerPelLabel->setFont( menusFont );
bitsPerPelLabel->setText( "Frame Rate" );
m_spinBoxBits = new QSpinBox();
m_spinBoxBits->setMinimumWidth( 30 );
m_spinBoxBits->setRange( 0, 16 );
m_spinBoxBits->setValue( 8 );
bitsPerPelLayout->addWidget( bitsPerPelLabel );
bitsPerPelLayout->addItem( new QSpacerItem( 20, 10, QSizePolicy::Expanding, QSizePolicy::Minimum ) );
bitsPerPelLayout->addWidget( m_spinBoxBits );
/* /*
* Frame rate format * Frame rate format
*/ */
@@ -204,6 +219,7 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget *parent ) :
MainLayout->addWidget( resolutionGroup ); MainLayout->addWidget( resolutionGroup );
MainLayout->addItem( new QSpacerItem( 10, 5, QSizePolicy::Minimum ) ); MainLayout->addItem( new QSpacerItem( 10, 5, QSizePolicy::Minimum ) );
MainLayout->addWidget( pixelGroup ); MainLayout->addWidget( pixelGroup );
MainLayout->addLayout( bitsPerPelLayout );
MainLayout->addItem( new QSpacerItem( 10, 5, QSizePolicy::Minimum ) ); MainLayout->addItem( new QSpacerItem( 10, 5, QSizePolicy::Minimum ) );
MainLayout->addLayout( framerateFormatLayout ); MainLayout->addLayout( framerateFormatLayout );
MainLayout->addItem( new QSpacerItem( 10, 5, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); MainLayout->addItem( new QSpacerItem( 10, 5, QSizePolicy::Minimum, QSizePolicy::Expanding ) );
@@ -218,7 +234,7 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget *parent ) :
} }
Int ConfigureFormatDialog::runConfigureFormatDialog( QString Filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate ) Int ConfigureFormatDialog::runConfigureFormatDialog( QString Filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rBits, UInt& rFrameRate )
{ {
// Set default values // Set default values
//setWindowTitle( "Configure resolution for " + Filename ); //setWindowTitle( "Configure resolution for " + Filename );
@@ -246,6 +262,7 @@ Int ConfigureFormatDialog::runConfigureFormatDialog( QString Filename, UInt& rWi
} }
m_comboBoxColorSpace->setCurrentIndex( colorSpace ); m_comboBoxColorSpace->setCurrentIndex( colorSpace );
m_comboBoxPixelFormat->setCurrentIndex( sampling ); m_comboBoxPixelFormat->setCurrentIndex( sampling );
m_spinBoxBits->setValue( rBits );
m_spinBoxFrameRate->setValue( rFrameRate ); m_spinBoxFrameRate->setValue( rFrameRate );
for( Int i = 0; i < standardResolutionSizes.size(); i++ ) for( Int i = 0; i < standardResolutionSizes.size(); i++ )
{ {
@@ -270,6 +287,7 @@ Int ConfigureFormatDialog::runConfigureFormatDialog( QString Filename, UInt& rWi
rInputFormat = i; rInputFormat = i;
} }
} }
rBits = m_spinBoxBits->value();
rFrameRate = m_spinBoxFrameRate->value(); rFrameRate = m_spinBoxFrameRate->value();
return QDialog::Accepted; return QDialog::Accepted;
} }
+2 -3
View File
@@ -34,8 +34,6 @@
#endif #endif
#include <QtCore> #include <QtCore>
class QPixmap; class QPixmap;
class QColor; class QColor;
@@ -52,7 +50,7 @@ Q_OBJECT
public: public:
ConfigureFormatDialog( QWidget *parent = 0 ); ConfigureFormatDialog( QWidget *parent = 0 );
Int runConfigureFormatDialog ( QString Filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate ); Int runConfigureFormatDialog( QString Filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rBits, UInt& rFrameRate );
private Q_SLOTS: private Q_SLOTS:
void StandardResolutionSelection(); void StandardResolutionSelection();
@@ -68,6 +66,7 @@ private:
QSpinBox *m_spinBoxheight; QSpinBox *m_spinBoxheight;
QComboBox *m_comboBoxColorSpace; QComboBox *m_comboBoxColorSpace;
QComboBox *m_comboBoxPixelFormat; QComboBox *m_comboBoxPixelFormat;
QSpinBox *m_spinBoxBits;
QSpinBox *m_spinBoxFrameRate; QSpinBox *m_spinBoxFrameRate;
}; };
+9 -6
View File
@@ -44,6 +44,7 @@ QDataStream& operator<<( QDataStream& out, const PlaYUVerStreamInfoVector& array
<< d.m_uiHeight << d.m_uiHeight
<< d.m_iPelFormat << d.m_iPelFormat
<< d.m_uiFrameRate << d.m_uiFrameRate
<< d.m_uiBitsPelPixel
<< d.m_uiFileSize; << d.m_uiFileSize;
} }
return out; return out;
@@ -60,6 +61,7 @@ QDataStream& operator>>( QDataStream& in, PlaYUVerStreamInfoVector& array )
in >> d.m_uiWidth; in >> d.m_uiWidth;
in >> d.m_uiHeight; in >> d.m_uiHeight;
in >> d.m_iPelFormat; in >> d.m_iPelFormat;
in >> d.m_uiBitsPelPixel;
in >> d.m_uiFrameRate; in >> d.m_uiFrameRate;
in >> d.m_uiFileSize; in >> d.m_uiFileSize;
array.append( d ); array.append( d );
@@ -141,16 +143,16 @@ Void VideoSubWindow::refreshSubWindow()
Bool VideoSubWindow::loadFile( QString cFilename, Bool bForceDialog ) Bool VideoSubWindow::loadFile( QString cFilename, Bool bForceDialog )
{ {
UInt Width = 0, Height = 0, FrameRate = 30; UInt Width = 0, Height = 0, BitsPel = 8, FrameRate = 30;
Int InputFormat = PlaYUVerFrame::YUV420p; Int InputFormat = PlaYUVerFrame::YUV420p;
if( m_pCurrStream ) if( m_pCurrStream )
m_pCurrStream->getFormat( Width, Height, InputFormat, FrameRate ); m_pCurrStream->getFormat( Width, Height, InputFormat, BitsPel, FrameRate );
if( guessFormat( cFilename, Width, Height, InputFormat, FrameRate ) || bForceDialog ) if( guessFormat( cFilename, Width, Height, InputFormat, FrameRate ) || bForceDialog )
{ {
ConfigureFormatDialog formatDialog( this ); ConfigureFormatDialog formatDialog( this );
if( formatDialog.runConfigureFormatDialog( QFileInfo( cFilename ).fileName(), Width, Height, InputFormat, FrameRate ) == QDialog::Rejected ) if( formatDialog.runConfigureFormatDialog( QFileInfo( cFilename ).fileName(), Width, Height, InputFormat, BitsPel, FrameRate ) == QDialog::Rejected )
{ {
return false; return false;
} }
@@ -166,12 +168,13 @@ Bool VideoSubWindow::loadFile( QString cFilename, Bool bForceDialog )
m_pCurrStream = new PlaYUVerStream; m_pCurrStream = new PlaYUVerStream;
} }
m_pCurrStream->open( cFilename.toStdString(), Width, Height, InputFormat, FrameRate ); m_pCurrStream->open( cFilename.toStdString(), Width, Height, InputFormat, BitsPel, FrameRate );
m_sStreamInfo.m_cFilename = cFilename; m_sStreamInfo.m_cFilename = cFilename;
m_sStreamInfo.m_uiWidth = Width; m_sStreamInfo.m_uiWidth = Width;
m_sStreamInfo.m_uiHeight = Height; m_sStreamInfo.m_uiHeight = Height;
m_sStreamInfo.m_iPelFormat = InputFormat; m_sStreamInfo.m_iPelFormat = InputFormat;
m_sStreamInfo.m_uiBitsPelPixel = BitsPel;
m_sStreamInfo.m_uiFrameRate = FrameRate; m_sStreamInfo.m_uiFrameRate = FrameRate;
m_sStreamInfo.m_uiFileSize = QFileInfo( cFilename ).size(); m_sStreamInfo.m_uiFileSize = QFileInfo( cFilename ).size();
@@ -198,7 +201,7 @@ Bool VideoSubWindow::loadFile( PlaYUVerStreamInfo* streamInfo )
} }
if( !m_pCurrStream->open( streamInfo->m_cFilename.toStdString(), streamInfo->m_uiWidth, streamInfo->m_uiHeight, streamInfo->m_iPelFormat, if( !m_pCurrStream->open( streamInfo->m_cFilename.toStdString(), streamInfo->m_uiWidth, streamInfo->m_uiHeight, streamInfo->m_iPelFormat,
streamInfo->m_uiFrameRate ) ) streamInfo->m_uiBitsPelPixel, streamInfo->m_uiFrameRate ) )
{ {
return false; return false;
} }
@@ -317,7 +320,7 @@ Bool VideoSubWindow::guessFormat( QString filename, UInt& rWidth, UInt& rHeight,
Int count = 0, module, frame_bytes, match; Int count = 0, module, frame_bytes, match;
for( UInt i = 0; i < stdResList.size(); i++ ) for( UInt i = 0; i < stdResList.size(); i++ )
{ {
frame_bytes = PlaYUVerFrame::getBytesPerFrame( stdResList[i].uiWidth, stdResList[i].uiHeight, rInputFormat ); frame_bytes = PlaYUVerFrame::getBytesPerFrame( stdResList[i].uiWidth, stdResList[i].uiHeight, rInputFormat, 8 );
module = uiFileSize % frame_bytes; module = uiFileSize % frame_bytes;
if( module == 0 ) if( module == 0 )
{ {
+1
View File
@@ -49,6 +49,7 @@ typedef struct
UInt m_uiWidth; UInt m_uiWidth;
UInt m_uiHeight; UInt m_uiHeight;
Int m_iPelFormat; Int m_iPelFormat;
UInt m_uiBitsPelPixel;
UInt m_uiFrameRate; UInt m_uiFrameRate;
UInt64 m_uiFileSize; UInt64 m_uiFileSize;
} PlaYUVerStreamInfo; } PlaYUVerStreamInfo;
+1
View File
@@ -76,6 +76,7 @@ typedef unsigned long long UInt64;
// ==================================================================================================================== // ====================================================================================================================
typedef UChar Pel; ///< 8-bit pixel type typedef UChar Pel; ///< 8-bit pixel type
typedef UChar SBytePel; ///< 8-bit pixel type
//typedef Short Pel; ///< 16-bit pixel type //typedef Short Pel; ///< 16-bit pixel type
// ==================================================================================================================== // ====================================================================================================================
+16 -17
View File
@@ -99,14 +99,14 @@ PlaYUVerFrame::Pixel PlaYUVerFrame::ConvertPixel( Pixel inputPixel, ColorSpace e
return outPixel; return outPixel;
} }
PlaYUVerFrame::PlaYUVerFrame( UInt width, UInt height, Int pel_format ) PlaYUVerFrame::PlaYUVerFrame( UInt width, UInt height, Int pelFormat, Int bitsPixel )
{ {
init( width, height, pel_format ); init( width, height, pelFormat, bitsPixel );
} }
PlaYUVerFrame::PlaYUVerFrame( PlaYUVerFrame *other ) PlaYUVerFrame::PlaYUVerFrame( PlaYUVerFrame *other )
{ {
init( other->getWidth(), other->getHeight(), other->getPelFormat() ); init( other->getWidth(), other->getHeight(), other->getPelFormat(), other->getBitsPel() );
copyFrom( other ); copyFrom( other );
} }
@@ -130,7 +130,7 @@ PlaYUVerFrame::PlaYUVerFrame( PlaYUVerFrame *other, UInt posX, UInt posY, UInt a
areaHeight++; areaHeight++;
} }
init( areaWidth, areaHeight, other->getPelFormat() ); init( areaWidth, areaHeight, other->getPelFormat(), other->getBitsPel() );
copyFrom( other, posX, posY ); copyFrom( other, posX, posY );
} }
@@ -145,16 +145,16 @@ PlaYUVerFrame::~PlaYUVerFrame()
closePixfc(); closePixfc();
} }
static Int getMem3ImageComponents( Pel**** array3D, Int dim1, Int dim2, Int log2ChromaHeight, Int log2ChromaWidth ) static Int getMem3ImageComponents( SBytePel**** array3D, Int dim1, Int dim2, Int log2ChromaHeight, Int log2ChromaWidth )
{ {
Int dim0 = 3; Int dim0 = 3;
Int i; Int i;
UInt64 total_mem_size = 0; UInt64 total_mem_size = 0;
UInt64 mem_size = ( dim1 * dim2 + CHROMASHIFT( dim1, log2ChromaHeight ) * CHROMASHIFT( dim2, log2ChromaWidth ) * 2 ); UInt64 mem_size = ( dim1 * dim2 + CHROMASHIFT( dim1, log2ChromaHeight ) * CHROMASHIFT( dim2, log2ChromaWidth ) * 2 );
total_mem_size += getMem2D<Pel*>( array3D, dim0, dim1 ); total_mem_size += getMem2D<SBytePel*>( array3D, dim0, dim1 );
if( ( ( *array3D )[0][0] = ( Pel* )xCallocMem( mem_size, sizeof(Pel) ) ) == NULL ) if( ( ( *array3D )[0][0] = ( SBytePel* )xCallocMem( mem_size, sizeof(Pel) ) ) == NULL )
printf( "getMem3DImageComponents: array1D" ); printf( "getMem3DImageComponents: array1D" );
total_mem_size += mem_size * sizeof(Pel); total_mem_size += mem_size * sizeof(Pel);
@@ -179,7 +179,7 @@ static Int getMem3ImageComponents( Pel**** array3D, Int dim1, Int dim2, Int log2
return total_mem_size; return total_mem_size;
} }
Void PlaYUVerFrame::init( UInt width, UInt height, Int pel_format ) Void PlaYUVerFrame::init( UInt width, UInt height, Int pel_format, Int bitsPixel )
{ {
m_pppcInputPel = NULL; m_pppcInputPel = NULL;
m_pcARGB32 = NULL; m_pcARGB32 = NULL;
@@ -187,13 +187,11 @@ Void PlaYUVerFrame::init( UInt width, UInt height, Int pel_format )
m_uiHeight = height; m_uiHeight = height;
m_iPixelFormat = pel_format; m_iPixelFormat = pel_format;
m_iNumberChannels = 3; m_iNumberChannels = 3;
m_iBitsChannels = 8; m_iBitsPel = bitsPixel;
Int max_bits_per_pel = sizeof(Pel) * 8; if( m_uiWidth == 0 || m_uiHeight == 0 || m_iPixelFormat == -1 || bitsPixel > 16 )
if( m_uiWidth == 0 || m_uiHeight == 0 || m_iPixelFormat == -1 || m_iBitsChannels > max_bits_per_pel )
{ {
return; throw "Cannot create a PlYUVerFrame of this type";
} }
m_pcPelFormat = &( g_PlaYUVerPixFmtDescriptorsList[pel_format] ); m_pcPelFormat = &( g_PlaYUVerPixFmtDescriptorsList[pel_format] );
@@ -225,19 +223,20 @@ UInt PlaYUVerFrame::getNumberChannels() const
UInt64 PlaYUVerFrame::getBytesPerFrame() UInt64 PlaYUVerFrame::getBytesPerFrame()
{ {
return getBytesPerFrame( m_uiWidth, m_uiHeight, m_iPixelFormat ); return getBytesPerFrame( m_uiWidth, m_uiHeight, m_iPixelFormat, m_iBitsPel );
} }
UInt64 PlaYUVerFrame::getBytesPerFrame( UInt uiWidth, UInt uiHeight, Int iPixelFormat ) UInt64 PlaYUVerFrame::getBytesPerFrame( UInt uiWidth, UInt uiHeight, Int iPixelFormat, Int bitsPixel )
{ {
PlaYUVerPixFmtDescriptor* pcPelFormat = &( g_PlaYUVerPixFmtDescriptorsList[iPixelFormat] ); PlaYUVerPixFmtDescriptor* pcPelFormat = &( g_PlaYUVerPixFmtDescriptorsList[iPixelFormat] );
UInt bytesPerPixel = bitsPixel / 8;
UInt64 numberBytes = uiWidth * uiHeight; UInt64 numberBytes = uiWidth * uiHeight;
if( pcPelFormat->numberChannels > 1 ) if( pcPelFormat->numberChannels > 1 )
{ {
UInt64 numberBytesChroma = CHROMASHIFT( uiWidth, pcPelFormat->log2ChromaWidth ) * CHROMASHIFT( uiHeight, pcPelFormat->log2ChromaHeight ); UInt64 numberBytesChroma = CHROMASHIFT( uiWidth, pcPelFormat->log2ChromaWidth ) * CHROMASHIFT( uiHeight, pcPelFormat->log2ChromaHeight );
numberBytes += ( pcPelFormat->numberChannels - 1 ) * numberBytesChroma; numberBytes += ( pcPelFormat->numberChannels - 1 ) * numberBytesChroma;
} }
return numberBytes; return numberBytes * bytesPerPixel;
} }
UInt PlaYUVerFrame::getChromaWidth() const UInt PlaYUVerFrame::getChromaWidth() const
@@ -501,7 +500,7 @@ Void PlaYUVerFrame::fromCvMat( Void* voidFrame )
if( !isValid() ) if( !isValid() )
{ {
init( opencvFrame->cols, opencvFrame->rows, m_iPixelFormat ); init( opencvFrame->cols, opencvFrame->rows, m_iPixelFormat, 8 );
} }
m_bHasRGBPel = false; m_bHasRGBPel = false;
+6 -6
View File
@@ -158,7 +158,7 @@ public:
* pixel format * pixel format
* @return number of bytes per frame * @return number of bytes per frame
*/ */
static UInt64 getBytesPerFrame( UInt, UInt, Int ); static UInt64 getBytesPerFrame( UInt uiWidth, UInt uiHeight, Int iPixelFormat, Int bitsPixel );
/** /**
* Convert a Pixel to a new color space * Convert a Pixel to a new color space
@@ -177,7 +177,7 @@ public:
* *
* @note this function might misbehave if the pixel format enum is not correct * @note this function might misbehave if the pixel format enum is not correct
*/ */
PlaYUVerFrame( UInt width, UInt height, Int pel_format = 0 ); PlaYUVerFrame( UInt width, UInt height, Int pelFormat = 0, Int bitsPixel = 8 );
/** /**
* Creates and new frame with the configuration of an * Creates and new frame with the configuration of an
@@ -236,9 +236,9 @@ public:
{ {
return m_iPixelFormat; return m_iPixelFormat;
} }
Int getBitsChannel() const Int getBitsPel() const
{ {
return m_iBitsChannels; return m_iBitsPel;
} }
Bool isValid() const Bool isValid() const
{ {
@@ -334,7 +334,7 @@ private:
UInt m_uiHeight; //!< Height of the frame UInt m_uiHeight; //!< Height of the frame
Int m_iPixelFormat; //!< Pixel format number (it follows the list of supported pixel formats) Int m_iPixelFormat; //!< Pixel format number (it follows the list of supported pixel formats)
Int m_iNumberChannels; //!< Number of channels Int m_iNumberChannels; //!< Number of channels
Int m_iBitsChannels; //!< Bits per pixel/channel Int m_iBitsPel; //!< Bits per pixel/channel
Pel*** m_pppcInputPel; Pel*** m_pppcInputPel;
@@ -349,7 +349,7 @@ private:
* @param pel_format pixel format index (always use PixelFormats enum) * @param pel_format pixel format index (always use PixelFormats enum)
* *
*/ */
Void init( UInt width, UInt height, Int pel_format ); Void init( UInt width, UInt height, Int pel_format, Int bitsPixel );
Void openPixfc(); Void openPixfc();
Void closePixfc(); Void closePixfc();
+1 -1
View File
@@ -56,7 +56,7 @@ Void PlaYUVerFrameStats::xSetupStatistics( const PlaYUVerFrame *pcFrame, UInt op
m_uiImageHeight = pcFrame->getHeight(); m_uiImageHeight = pcFrame->getHeight();
m_uiChannels = pcFrame->getNumberChannels(); m_uiChannels = pcFrame->getNumberChannels();
m_uiHistoSegments = ( pcFrame->getBitsChannel() == 16 ) ? 65536 : 256; m_uiHistoSegments = 1 << pcFrame->getBitsPel();
imageColorSpace = pcFrame->getColorSpace(); imageColorSpace = pcFrame->getColorSpace();
imageChromaSize = pcFrame->getChromaLength(); imageChromaSize = pcFrame->getChromaLength();
+18 -8
View File
@@ -163,7 +163,7 @@ PlaYUVerStream::~PlaYUVerStream()
close(); close();
} }
Bool PlaYUVerStream::open( std::string filename, std::string resolution, std::string input_format_name, UInt frame_rate, Bool bInput ) Bool PlaYUVerStream::open( std::string filename, std::string resolution, std::string input_format_name, UInt bitsPel, UInt frame_rate, Bool bInput )
{ {
UInt width; UInt width;
UInt height; UInt height;
@@ -185,10 +185,10 @@ Bool PlaYUVerStream::open( std::string filename, std::string resolution, std::st
break; break;
} }
} }
return open( filename, width, height, input_format, frame_rate, bInput ); return open( filename, width, height, input_format, bitsPel, frame_rate, bInput );
} }
Bool PlaYUVerStream::open( std::string filename, UInt width, UInt height, Int input_format, UInt frame_rate, Bool bInput ) Bool PlaYUVerStream::open( std::string filename, UInt width, UInt height, Int input_format, UInt bitsPel, UInt frame_rate, Bool bInput )
{ {
if( m_bInit ) if( m_bInit )
{ {
@@ -200,6 +200,7 @@ Bool PlaYUVerStream::open( std::string filename, UInt width, UInt height, Int in
m_uiWidth = width; m_uiWidth = width;
m_uiHeight = height; m_uiHeight = height;
m_iPixelFormat = input_format; m_iPixelFormat = input_format;
m_uiBitsPerPixel = bitsPel;
m_dFrameRate = frame_rate; m_dFrameRate = frame_rate;
m_pchFilename = new Char[m_cFilename.size() + 1]; m_pchFilename = new Char[m_cFilename.size() + 1];
@@ -254,6 +255,10 @@ Bool PlaYUVerStream::open( std::string filename, UInt width, UInt height, Int in
} }
} }
#endif #endif
if( m_uiBitsPerPixel != 8 )
{
m_uiStreamHandler = YUV_IO;
}
m_uiFrameBufferSize = 2; m_uiFrameBufferSize = 2;
} }
else else
@@ -311,8 +316,11 @@ Bool PlaYUVerStream::open( std::string filename, UInt width, UInt height, Int in
getMem1D<PlaYUVerFrame*>( &m_ppcFrameBuffer, m_uiFrameBufferSize ); getMem1D<PlaYUVerFrame*>( &m_ppcFrameBuffer, m_uiFrameBufferSize );
for( UInt i = 0; i < m_uiFrameBufferSize; i++ ) for( UInt i = 0; i < m_uiFrameBufferSize; i++ )
{ {
m_ppcFrameBuffer[i] = new PlaYUVerFrame( m_uiWidth, m_uiHeight, m_iPixelFormat ); try
if( !m_ppcFrameBuffer[i] ) {
m_ppcFrameBuffer[i] = new PlaYUVerFrame( m_uiWidth, m_uiHeight, m_iPixelFormat, m_uiBitsPerPixel );
}
catch( const char *msg )
{ {
close(); close();
throw "[PlaYUVerStream] Cannot allocated frame buffer"; throw "[PlaYUVerStream] Cannot allocated frame buffer";
@@ -384,7 +392,7 @@ Bool PlaYUVerStream::openFile()
{ {
return false; return false;
} }
if ( m_bIsInput ) if( m_bIsInput )
{ {
fseek( m_pFile, m_iCurrFrameNum >= 0 ? m_iCurrFrameNum : 0, SEEK_SET ); fseek( m_pFile, m_iCurrFrameNum >= 0 ? m_iCurrFrameNum : 0, SEEK_SET );
} }
@@ -433,13 +441,14 @@ Void PlaYUVerStream::close()
m_bInit = false; m_bInit = false;
} }
Void PlaYUVerStream::getFormat( UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate ) Void PlaYUVerStream::getFormat( UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rBitsPerPel, UInt& rFrameRate )
{ {
if( m_bInit ) if( m_bInit )
{ {
rWidth = m_uiWidth; rWidth = m_uiWidth;
rHeight = m_uiHeight; rHeight = m_uiHeight;
rInputFormat = m_iPixelFormat; rInputFormat = m_iPixelFormat;
rBitsPerPel = m_uiBitsPerPixel;
rFrameRate = m_dFrameRate; rFrameRate = m_dFrameRate;
} }
else else
@@ -447,6 +456,7 @@ Void PlaYUVerStream::getFormat( UInt& rWidth, UInt& rHeight, Int& rInputFormat,
rWidth = 0; rWidth = 0;
rHeight = 0; rHeight = 0;
rInputFormat = PlaYUVerFrame::YUV420p; rInputFormat = PlaYUVerFrame::YUV420p;
rBitsPerPel = 8;
rFrameRate = 30; rFrameRate = 30;
} }
} }
@@ -471,7 +481,7 @@ Void PlaYUVerStream::loadAll()
getMem1D<PlaYUVerFrame*>( &m_ppcFrameBuffer, m_uiFrameBufferSize ); getMem1D<PlaYUVerFrame*>( &m_ppcFrameBuffer, m_uiFrameBufferSize );
for( UInt i = 0; i < m_uiFrameBufferSize; i++ ) for( UInt i = 0; i < m_uiFrameBufferSize; i++ )
{ {
m_ppcFrameBuffer[i] = new PlaYUVerFrame( m_uiWidth, m_uiHeight, m_iPixelFormat ); m_ppcFrameBuffer[i] = new PlaYUVerFrame( m_uiWidth, m_uiHeight, m_iPixelFormat, m_uiBitsPerPixel );
if( !m_ppcFrameBuffer[i] ) if( !m_ppcFrameBuffer[i] )
{ {
close(); close();
+4 -3
View File
@@ -82,6 +82,7 @@ private:
Int m_iFileFormat; Int m_iFileFormat;
Int m_iPixelFormat; Int m_iPixelFormat;
UInt m_uiBitsPerPixel;
Pel* m_pStreamBuffer; Pel* m_pStreamBuffer;
@@ -121,14 +122,14 @@ public:
END_OF_SEQ, END_OF_SEQ,
}; };
Bool open( std::string filename, std::string resolution, std::string input_format, UInt frame_rate, Bool bInput = true ); Bool open( std::string filename, std::string resolution, std::string input_format, UInt bitsPel, UInt frame_rate, Bool bInput = true );
Bool open( std::string filename, UInt width, UInt height, Int input_format, UInt frame_rate, Bool bInput = true ); Bool open( std::string filename, UInt width, UInt height, Int input_format, UInt bitsPel, UInt frame_rate, Bool bInput = true );
Void close(); Void close();
Bool openFile(); Bool openFile();
Void closeFile(); Void closeFile();
Void getFormat( UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rFrameRate ); Void getFormat( UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rBitsPerPel, UInt& rFrameRate );
Void loadAll(); Void loadAll();
+7 -7
View File
@@ -79,7 +79,7 @@ Int PlaYUVerTools::openInputs()
pcStream = new PlaYUVerStream; pcStream = new PlaYUVerStream;
try try
{ {
if( !pcStream->open( inputFileNames[i], resolutionString, fmtString, 1 ) ) if( !pcStream->open( inputFileNames[i], resolutionString, fmtString, 8, 1 ) )
{ {
m_cCmdLineHandler.log( CommandLineHandle::ERROR, "Cannot open input stream %s! ", inputFileNames[i].c_str() ); m_cCmdLineHandler.log( CommandLineHandle::ERROR, "Cannot open input stream %s! ", inputFileNames[i].c_str() );
return 2; return 2;
@@ -132,11 +132,11 @@ Int PlaYUVerTools::Open( Int argc, Char *argv[] )
if( m_cCmdLineHandler.Opts()["quality"]->count() ) if( m_cCmdLineHandler.Opts()["quality"]->count() )
{ {
std::string qualityMetric = m_cCmdLineHandler.m_strQualityMetric; std::string qualityMetric = m_cCmdLineHandler.m_strQualityMetric;
if( m_apcInputStreams.size() != 2 ) // if( m_apcInputStreams.size() != 2 )
{ // {
m_cCmdLineHandler.log( CommandLineHandle::ERROR, "Invalid number of inputs! " ); // m_cCmdLineHandler.log( CommandLineHandle::ERROR, "Invalid number of inputs! " );
return 2; // return 2;
} // }
for( UInt i = 0; i < PlaYUVerFrame::supportedQualityMetricsList().size(); i++ ) for( UInt i = 0; i < PlaYUVerFrame::supportedQualityMetricsList().size(); i++ )
{ {
if( lowercase( PlaYUVerFrame::supportedQualityMetricsList()[i] ) == lowercase( qualityMetric ) ) if( lowercase( PlaYUVerFrame::supportedQualityMetricsList()[i] ) == lowercase( qualityMetric ) )
@@ -193,7 +193,7 @@ Int PlaYUVerTools::Open( Int argc, Char *argv[] )
{ {
PlaYUVerFrame* pcModFrame = applyFrameModule(); PlaYUVerFrame* pcModFrame = applyFrameModule();
PlaYUVerStream* pcModStream = new PlaYUVerStream; PlaYUVerStream* pcModStream = new PlaYUVerStream;
if( !pcModStream->open( outputFileNames[0], pcModFrame->getWidth(), pcModFrame->getHeight(), pcModFrame->getPelFormat(), 1, false ) ) if( !pcModStream->open( outputFileNames[0], pcModFrame->getWidth(), pcModFrame->getHeight(), pcModFrame->getPelFormat(), 8, 1, false ) )
{ {
delete pcModStream; delete pcModStream;
pcModStream = NULL; pcModStream = NULL;