Add new information to the format properties side bar
Improve InputStream and LibAvHandle to detect the stream duration in order to present it on the side bar Improvements in the LibAvHandle to return NOFMT if format is unknown
This commit is contained in:
1 parent
2917ed175e
commit
7ccf255a94
6 files changed
+87
-24
No files matched your search
@@ -133,10 +133,9 @@ Bool InputStream::open( QString filename, UInt width, UInt height, Int input_for
|
||||
#ifdef USE_FFMPEG
|
||||
if( QFileInfo( filename ).completeSuffix().compare( QString( "yuv" ) ) )
|
||||
{
|
||||
avStatus = m_cLibAvContext.initAvFormat( m_cFilename.toLocal8Bit().data(), m_uiWidth, m_uiHeight, m_iPixelFormat, m_uiFrameRate );
|
||||
avStatus = m_cLibAvContext.initAvFormat( m_cFilename.toLocal8Bit().data(), m_uiWidth, m_uiHeight, m_iPixelFormat, m_uiFrameRate, m_uiTotalFrameNum );
|
||||
m_cFormatName = QFileInfo( filename ).completeSuffix().toUpper();
|
||||
m_cCodedName = QString::fromUtf8( m_cLibAvContext.getCodecName() ).toUpper();
|
||||
m_uiTotalFrameNum = 100;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -222,7 +221,9 @@ Void InputStream::close()
|
||||
if( m_pInputBuffer )
|
||||
freeMem1D<Pel>( m_pInputBuffer );
|
||||
|
||||
qDebug() << "Frame read time: " << QString::number( 1000 / (m_uiAveragePlayInterval+1) ) << " fps";
|
||||
qDebug( ) << "Frame read time: "
|
||||
<< QString::number( 1000 / ( m_uiAveragePlayInterval + 1 ) )
|
||||
<< " fps";
|
||||
|
||||
m_bInit = false;
|
||||
}
|
||||
@@ -286,6 +287,28 @@ Bool InputStream::guessFormat( QString filename, UInt& rWidth, UInt& rHeight, In
|
||||
return bRet;
|
||||
}
|
||||
|
||||
Void InputStream::getDuration( Int* duration_array )
|
||||
{
|
||||
Int hours, mins, secs;
|
||||
#ifdef USE_FFMPEG
|
||||
if( m_cLibAvContext.getStatus() )
|
||||
{
|
||||
secs = m_cLibAvContext.getStreamDuration();
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
secs = m_uiTotalFrameNum * m_uiFrameRate;
|
||||
}
|
||||
mins = secs / 60;
|
||||
secs %= 60;
|
||||
hours = mins / 60;
|
||||
mins %= 60;
|
||||
*duration_array++ = hours;
|
||||
*duration_array++ = mins;
|
||||
*duration_array++ = secs;
|
||||
}
|
||||
|
||||
Void InputStream::readNextFrame()
|
||||
{
|
||||
UInt64 bytes_read = 0;
|
||||
@@ -396,7 +419,7 @@ Void InputStream::seekInput( UInt64 new_frame_num )
|
||||
readNextFrame();
|
||||
setNextFrame();
|
||||
if( m_uiTotalFrameNum > 1 )
|
||||
readNextFrame();
|
||||
readNextFrame();
|
||||
}
|
||||
|
||||
Bool InputStream::checkErrors( Int error_type )
|
||||
|
||||
@@ -167,6 +167,7 @@ public:
|
||||
{
|
||||
return m_uiFrameRate;
|
||||
}
|
||||
Void getDuration( Int* duration_array );
|
||||
|
||||
Void setWidth( UInt new_width )
|
||||
{
|
||||
|
||||
@@ -39,7 +39,7 @@ static inline QSize bestSize( QSize currSize );
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
StreamPropertiesSideBar::StreamPropertiesSideBar( QWidget* parent ) :
|
||||
QWidget( parent )
|
||||
QWidget( parent )
|
||||
{
|
||||
// -------------- Variables definition --------------
|
||||
m_pcStream = NULL;
|
||||
@@ -58,12 +58,20 @@ StreamPropertiesSideBar::StreamPropertiesSideBar( QWidget* parent ) :
|
||||
labelCodecValue = new QLabel;
|
||||
labelCodecValue->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
|
||||
|
||||
QLabel *sizeLabel = new QLabel( tr( "Size (pixels):" ) );
|
||||
QLabel *durationLabel = new QLabel( tr( "Duration:" ) );
|
||||
durationLabel->setAlignment( Qt::AlignLeft | Qt::AlignVCenter );
|
||||
labelDurationValueTime = new QLabel;
|
||||
labelDurationValueTime->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
|
||||
|
||||
labelDurationValueFrames = new QLabel;
|
||||
labelDurationValueFrames->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
|
||||
|
||||
QLabel *sizeLabel = new QLabel( tr( "Resolution:" ) );
|
||||
sizeLabel->setAlignment( Qt::AlignLeft | Qt::AlignVCenter );
|
||||
labelSizeValue = new QLabel;
|
||||
labelSizeValue->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
|
||||
|
||||
QLabel *colorSpaceLabel = new QLabel( tr( "Colorspace:" ) );
|
||||
QLabel *colorSpaceLabel = new QLabel( tr( "Color Space:" ) );
|
||||
colorSpaceLabel->setAlignment( Qt::AlignLeft | Qt::AlignVCenter );
|
||||
labelColorSpaceValue = new QLabel;
|
||||
labelColorSpaceValue->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
|
||||
@@ -76,20 +84,26 @@ StreamPropertiesSideBar::StreamPropertiesSideBar( QWidget* parent ) :
|
||||
propertiesLayout->addWidget( codecLabel, layout_line, 0 );
|
||||
propertiesLayout->addWidget( labelCodecValue, layout_line, 1 );
|
||||
layout_line++;
|
||||
propertiesLayout->addWidget( durationLabel, layout_line, 0 );
|
||||
propertiesLayout->addWidget( labelDurationValueTime, layout_line, 1 );
|
||||
layout_line++;
|
||||
propertiesLayout->addWidget( labelDurationValueFrames, layout_line, 1 );
|
||||
layout_line++;
|
||||
propertiesLayout->addWidget( sizeLabel, layout_line, 0 );
|
||||
propertiesLayout->addWidget( labelSizeValue, layout_line, 1 );
|
||||
layout_line++;
|
||||
propertiesLayout->addWidget( colorSpaceLabel, layout_line, 0 );
|
||||
propertiesLayout->addWidget( labelColorSpaceValue, layout_line, 1 );
|
||||
|
||||
QGroupBox *propertiesGroup = new QGroupBox( tr( "Properties" ) );
|
||||
propertiesGroup->setLayout( propertiesLayout );
|
||||
mainLayout->addWidget( propertiesGroup, 6, 0, 1, 4 );
|
||||
// QGroupBox *propertiesGroup = new QGroupBox;
|
||||
// propertiesGroup->setLayout( propertiesLayout );
|
||||
// mainLayout->addWidget( propertiesGroup );
|
||||
// mainLayout->setRowStretch( 8, 10 );
|
||||
|
||||
mainLayout->setRowStretch( 8, 10 );
|
||||
setLayout( mainLayout );
|
||||
propertiesLayout->setRowStretch( 8, 10 );
|
||||
setLayout( propertiesLayout );
|
||||
//setLayout( mainLayout );
|
||||
setEnabled( false );
|
||||
|
||||
}
|
||||
|
||||
StreamPropertiesSideBar::~StreamPropertiesSideBar()
|
||||
@@ -122,9 +136,16 @@ Void StreamPropertiesSideBar::setData( InputStream* pcStream )
|
||||
QString value;
|
||||
labelFormatValue->setText( m_pcStream->getFormatName() );
|
||||
labelCodecValue->setText( m_pcStream->getCodecName() );
|
||||
uint width = m_pcStream->getWidth();
|
||||
uint height = m_pcStream->getHeight();
|
||||
value = QString( tr( "%1 x %2" ) ).arg( width ).arg( height );
|
||||
Int duration[3];
|
||||
m_pcStream->getDuration( duration );
|
||||
value = QString( tr( "%1h:%2m:%3s" ) ).arg( duration[0] ).arg( duration[1] ).arg( duration[2] );
|
||||
labelDurationValueTime->setText( value );
|
||||
value = QString( tr( "%1 frms" ) ).arg( m_pcStream->getFrameNum() );
|
||||
labelDurationValueFrames->setText( value );
|
||||
UInt width = m_pcStream->getWidth();
|
||||
UInt height = m_pcStream->getHeight();
|
||||
UInt fps = m_pcStream->getFrameRate();
|
||||
value = QString( tr( "%1 x %2 @ %3 Hz" ) ).arg( width ).arg( height ).arg( fps );
|
||||
labelSizeValue->setText( value );
|
||||
value = QString( PlaYUVerFrame::supportedPixelFormatList().at( m_pcStream->getCurrFrame()->getPelFormat() ) );
|
||||
labelColorSpaceValue->setText( value );
|
||||
@@ -136,7 +157,7 @@ Void StreamPropertiesSideBar::setData( InputStream* pcStream )
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
FramePropertiesSideBar::FramePropertiesSideBar( QWidget* parent ) :
|
||||
QWidget( parent )
|
||||
QWidget( parent )
|
||||
{
|
||||
// -------------- Variables definition --------------
|
||||
m_pcFrame = NULL;
|
||||
@@ -244,6 +265,5 @@ static inline QSize bestSize( QSize currSize )
|
||||
return currSize;
|
||||
}
|
||||
|
||||
|
||||
} // NAMESPACE
|
||||
|
||||
@@ -53,6 +53,8 @@ private:
|
||||
|
||||
QLabel* labelFormatValue;
|
||||
QLabel* labelCodecValue;
|
||||
QLabel* labelDurationValueTime;
|
||||
QLabel* labelDurationValueFrames;
|
||||
QLabel* labelSizeValue;
|
||||
QLabel* labelColorSpaceValue;
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user