Add support for little and big endian with an option

This commit is contained in:
jfmcarreira committed 2016-03-31 00:52:11 +01:00
1 parent f596fda8dc
commit b68bbded34
14 files changed
+104 -35

No files matched your search

+38 -6
View File
@@ -174,7 +174,7 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget *parent ) :
pixelGridLayout->addItem( new QSpacerItem( 10, 10, QSizePolicy::Expanding, QSizePolicy::Minimum ), 1, 1 );
pixelGridLayout->addWidget( m_comboBoxPixelFormat, 1, 2 );
QHBoxLayout* bitsPerPelLayout = new QHBoxLayout();
QLabel* bitsPerPelLabel = new QLabel();
bitsPerPelLabel->setFont( normalFont );
bitsPerPelLabel->setText( "Pixel bit depth" );
@@ -187,6 +187,27 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget *parent ) :
pixelGridLayout->addItem( new QSpacerItem( 20, 10, QSizePolicy::Expanding, QSizePolicy::Minimum ), 2, 1 );
pixelGridLayout->addWidget( m_spinBoxBits, 2, 2 );
/*
* Endianess
*/
QHBoxLayout* endiannessLayout = new QHBoxLayout();
QLabel* endiannessLabel = new QLabel();
endiannessLabel->setFont( menusFont );
endiannessLabel->setText( "Endianness" );
QComboBox* endiannessComboBox = new QComboBox();
endiannessComboBox->setFont( normalFont );
endiannessComboBox->setSizePolicy( sizePolicy );
endiannessComboBox->clear();
endiannessComboBox->addItem( QStringLiteral("Big Endian") );
endiannessComboBox->addItem( QStringLiteral("Little Endian") );
endiannessComboBox->setCurrentIndex( 0 );
endiannessLayout->addWidget( endiannessLabel );
endiannessLayout->addItem( new QSpacerItem( 20, 10, QSizePolicy::Expanding, QSizePolicy::Minimum ) );
endiannessLayout->addWidget( endiannessComboBox );
m_widgetEndianness = new QWidget();
m_widgetEndianness->setLayout( endiannessLayout );
m_widgetEndianness->setVisible( true );
/*
* Frame rate format
*/
@@ -212,13 +233,11 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget *parent ) :
dialogButtonOkCancel->setCenterButtons( false );
MainLayout->addItem( new QSpacerItem( 10, 5, QSizePolicy::Minimum ) );
// MainLayout->addLayout( standardResolutionLayout );
// MainLayout->addItem( new QSpacerItem( 10, 10, QSizePolicy::Minimum ) );
MainLayout->addWidget( resolutionGroup );
MainLayout->addItem( new QSpacerItem( 10, 5, QSizePolicy::Minimum ) );
MainLayout->addWidget( pixelGroup );
MainLayout->addLayout( bitsPerPelLayout );
MainLayout->addItem( new QSpacerItem( 10, 5, QSizePolicy::Minimum ) );
MainLayout->addWidget( m_widgetEndianness );
MainLayout->addLayout( framerateFormatLayout );
MainLayout->addItem( new QSpacerItem( 10, 5, QSizePolicy::Minimum, QSizePolicy::Expanding ) );
MainLayout->addWidget( dialogButtonOkCancel );
@@ -226,8 +245,9 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget *parent ) :
connect( m_comboBoxStandardResolution, SIGNAL( currentIndexChanged(int) ), this, SLOT( slotStandardResolutionSelected(int) ) );
connect( m_spinBoxWidth, SIGNAL( valueChanged(int) ), this, SLOT( slotResolutionChange() ) );
connect( m_spinBoxheight, SIGNAL( valueChanged(int) ), this, SLOT( slotResolutionChange() ) );
connect( m_comboBoxColorSpace, SIGNAL( currentIndexChanged(int) ), this, SLOT( slotColorSpaceChange(int) ) );
connect( m_spinBoxBits, SIGNAL( valueChanged(int) ), this, SLOT( slotBitsChange(int) ) );
connect( dialogButtonOkCancel, SIGNAL( accepted() ), this, SLOT( accept() ) );
connect( dialogButtonOkCancel, SIGNAL( rejected() ), this, SLOT( reject() ) );
@@ -237,7 +257,7 @@ ConfigureFormatDialog::ConfigureFormatDialog( QWidget *parent ) :
}
Int ConfigureFormatDialog::runConfigureFormatDialog( QString Filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rBits, UInt& rFrameRate )
Int ConfigureFormatDialog::runConfigureFormatDialog( QString Filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rBits, UInt& rEndianess, UInt& rFrameRate )
{
// Set default values
//setWindowTitle( "Configure resolution for " + Filename );
@@ -340,4 +360,16 @@ Void ConfigureFormatDialog::slotColorSpaceChange( Int idx )
m_comboBoxPixelFormat->setCurrentIndex( 0 );
}
Void ConfigureFormatDialog::slotBitsChange( Int idx )
{
if( idx > 8 )
{
m_widgetEndianness->setVisible( true );
}
else
{
m_widgetEndianness->setVisible( false );
}
}
} // NAMESPACE
+4 -1
View File
@@ -50,12 +50,13 @@ Q_OBJECT
public:
ConfigureFormatDialog( QWidget *parent = 0 );
Int runConfigureFormatDialog( QString Filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rBits, UInt& rFrameRate );
Int runConfigureFormatDialog( QString Filename, UInt& rWidth, UInt& rHeight, Int& rInputFormat, UInt& rBits, UInt& rEndianess, UInt& rFrameRate );
private Q_SLOTS:
void slotStandardResolutionSelected( int );
void slotResolutionChange();
void slotColorSpaceChange( int );
void slotBitsChange( int );
private:
QStringList standardResolutionNames;
@@ -68,6 +69,8 @@ private:
QComboBox *m_comboBoxColorSpace;
QComboBox *m_comboBoxPixelFormat;
QSpinBox *m_spinBoxBits;
QWidget* m_widgetEndianness;
QHBoxLayout* framerateFormatLayout;
QSpinBox *m_spinBoxFrameRate;
};
+8 -6
View File
@@ -51,6 +51,7 @@ QDataStream& operator<<( QDataStream& out, const PlaYUVerStreamInfoVector& array
<< d.m_uiHeight
<< d.m_iPelFormat
<< d.m_uiBitsPelPixel
<< d.m_uiEndianness
<< d.m_uiFrameRate
<< d.m_uiFileSize;
}
@@ -69,6 +70,7 @@ QDataStream& operator>>( QDataStream& in, PlaYUVerStreamInfoVector& array )
in >> d.m_uiHeight;
in >> d.m_iPelFormat;
in >> d.m_uiBitsPelPixel;
in >> d.m_uiEndianness;
in >> d.m_uiFrameRate;
in >> d.m_uiFileSize;
array.append( d );
@@ -306,7 +308,7 @@ Void VideoSubWindow::refreshSubWindow()
Bool VideoSubWindow::loadFile( QString cFilename, Bool bForceDialog )
{
ConfigureFormatDialog formatDialog( this );
UInt Width = 0, Height = 0, BitsPel = 8, FrameRate = 30;
UInt Width = 0, Height = 0, BitsPel = 8, Endianness = 0, FrameRate = 30;
Int InputFormat = PlaYUVerFrame::YUV420p;
if( m_pCurrStream )
@@ -319,7 +321,7 @@ Bool VideoSubWindow::loadFile( QString cFilename, Bool bForceDialog )
if( guessFormat( cFilename, Width, Height, InputFormat, FrameRate ) || bForceDialog )
{
if( formatDialog.runConfigureFormatDialog( QFileInfo( cFilename ).fileName(), Width, Height, InputFormat, BitsPel, FrameRate ) == QDialog::Rejected )
if( formatDialog.runConfigureFormatDialog( QFileInfo( cFilename ).fileName(), Width, Height, InputFormat, BitsPel, Endianness, FrameRate ) == QDialog::Rejected )
{
return false;
}
@@ -327,15 +329,15 @@ Bool VideoSubWindow::loadFile( QString cFilename, Bool bForceDialog )
try
{
m_pCurrStream->open( cFilename.toStdString(), Width, Height, InputFormat, BitsPel, FrameRate );
m_pCurrStream->open( cFilename.toStdString(), Width, Height, InputFormat, BitsPel, Endianness, FrameRate );
}
catch( const char *msg )
{
if( formatDialog.runConfigureFormatDialog( QFileInfo( cFilename ).fileName(), Width, Height, InputFormat, BitsPel, FrameRate ) == QDialog::Rejected )
if( formatDialog.runConfigureFormatDialog( QFileInfo( cFilename ).fileName(), Width, Height, InputFormat, BitsPel, Endianness, FrameRate ) == QDialog::Rejected )
{
return false;
}
m_pCurrStream->open( cFilename.toStdString(), Width, Height, InputFormat, BitsPel, FrameRate );
m_pCurrStream->open( cFilename.toStdString(), Width, Height, InputFormat, BitsPel, Endianness, FrameRate );
}
m_sStreamInfo.m_cFilename = cFilename;
@@ -365,7 +367,7 @@ Bool VideoSubWindow::loadFile( PlaYUVerStreamInfo* streamInfo )
}
if( !m_pCurrStream->open( streamInfo->m_cFilename.toStdString(), streamInfo->m_uiWidth, streamInfo->m_uiHeight, streamInfo->m_iPelFormat,
streamInfo->m_uiBitsPelPixel, streamInfo->m_uiFrameRate ) )
streamInfo->m_uiBitsPelPixel, streamInfo->m_uiEndianness, streamInfo->m_uiFrameRate ) )
{
return false;
}
+1
View File
@@ -52,6 +52,7 @@ typedef struct
UInt m_uiHeight;
Int m_iPelFormat;
UInt m_uiBitsPelPixel;
UInt m_uiEndianness;
UInt m_uiFrameRate;
UInt64 m_uiFileSize;
} PlaYUVerStreamInfo;