This commit is contained in:
Luis Lucas committed 2014-04-05 04:50:56 +01:00
commit 2efc127d7a
6 files changed
+87 -24

No files matched your search

+27 -4
View File
@@ -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 )
+1
View File
@@ -167,6 +167,7 @@ public:
{
return m_uiFrameRate;
}
Void getDuration( Int* duration_array );
Void setWidth( UInt new_width )
{
+34 -14
View File
@@ -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
+2
View File
@@ -53,6 +53,8 @@ private:
QLabel* labelFormatValue;
QLabel* labelCodecValue;
QLabel* labelDurationValueTime;
QLabel* labelDurationValueFrames;
QLabel* labelSizeValue;
QLabel* labelColorSpaceValue;
};
+15 -4
View File
@@ -81,7 +81,7 @@ Void LibAvContextHandle::closeAvFormat()
m_bHasStream = false;
}
Bool LibAvContextHandle::initAvFormat( char* filename, UInt& width, UInt& height, Int& pixel_format, UInt& frame_rate )
Bool LibAvContextHandle::initAvFormat( char* filename, UInt& width, UInt& height, Int& pixel_format, UInt& frame_rate, UInt64& num_frames )
{
int ret = 0;
@@ -152,9 +152,7 @@ Bool LibAvContextHandle::initAvFormat( char* filename, UInt& width, UInt& height
video_dst_bufsize = ret;
}
const char *codec_name = avcodec_get_name(video_dec_ctx->codec_id);
sprintf(m_acCodecName, "%s", codec_name);
Double fr = 30;
@@ -171,6 +169,18 @@ Bool LibAvContextHandle::initAvFormat( char* filename, UInt& width, UInt& height
frame_rate = ( UInt )fr;
if( fmt_ctx->duration != AV_NOPTS_VALUE )
{
Int64 duration = fmt_ctx->duration + 5000;
m_uiSecs = duration / AV_TIME_BASE;
num_frames = m_uiSecs * frame_rate;
m_uiMicroSec = duration % AV_TIME_BASE;
}
else
{
num_frames = 0;
}
width = video_dec_ctx->width;
height = video_dec_ctx->height;
switch( video_dec_ctx->pix_fmt )
@@ -191,6 +201,7 @@ Bool LibAvContextHandle::initAvFormat( char* filename, UInt& width, UInt& height
pixel_format = PlaYUVerFrame::RGB8;
break;
default:
pixel_format = PlaYUVerFrame::NO_FMT;
break;
}
@@ -269,7 +280,7 @@ Bool LibAvContextHandle::decodeAvFormat()
Void LibAvContextHandle::seekAvFormat( UInt64 frame_num )
{
av_seek_frame( fmt_ctx, video_stream_idx, frame_num, AVSEEK_FLAG_ANY );
av_seek_frame( fmt_ctx, video_stream_idx, frame_num, AVSEEK_FLAG_FRAME );
}
} // NAMESPACE
+8 -2
View File
@@ -53,10 +53,10 @@ class LibAvContextHandle
{
public:
LibAvContextHandle() :
m_bHasStream( false )
m_bHasStream( false )
{
}
Bool initAvFormat( char* filename, UInt& width, UInt& height, Int& pixel_format, UInt& frame_rate );
Bool initAvFormat( char* filename, UInt& width, UInt& height, Int& pixel_format, UInt& frame_rate, UInt64& num_frames );
Void closeAvFormat();
Bool decodeAvFormat();
@@ -70,6 +70,10 @@ public:
{
return m_acCodecName;
}
UInt getStreamDuration( )
{
return m_uiSecs;
}
uint8_t *video_dst_data[4];
int video_dst_linesize[4];
@@ -86,6 +90,8 @@ private:
Bool m_bHasStream;
Char m_acCodecName[20];
UInt m_uiSecs;
UInt m_uiMicroSec;
};
} // NAMESPACE