Merge branch 'jfmcarreira-dev'

This commit is contained in:
jfmcarreira committed 2014-03-30 22:58:06 +01:00
commit b16ba1718c
6 files changed
+24 -26

No files matched your search

+9 -5
View File
@@ -71,6 +71,7 @@ QString InputStream::supportedReadFormats()
formats = "*.yuv " // Raw video
#ifdef USE_FFMPEG
"*.avi " // Audio video interleaved
"*.mp4 "
"*.wmv "// Windows media video
#endif
;
@@ -94,6 +95,7 @@ QStringList InputStream::supportedReadFormatsList()
formats << "Raw video (*.yuv)"
#ifdef USE_FFMPEG
<< "Audio video interleaved (*.avi)"
<< "MPEG4 (*.mp4)"
<< "Windows media video (*.wmv)"
#endif
;
@@ -126,7 +128,8 @@ Bool InputStream::guessFormat( QString filename, UInt& rWidth, UInt& rHeight, In
{
resolutionString.remove( "_" );
QStringList resolutionArgs = resolutionString.split( "x" );
qDebug( ) << "Found resolution = " << resolutionArgs;
qDebug( ) << "Found resolution = "
<< resolutionArgs;
if( resolutionArgs.size() == 2 )
{
rWidth = resolutionArgs.at( 0 ).toUInt();
@@ -194,6 +197,7 @@ Bool InputStream::open( QString filename, UInt width, UInt height, Int input_for
if( !avStatus )
{
m_pFile = NULL;
m_pFile = fopen( m_cFilename.toLocal8Bit().data(), "rb" );
if( m_pFile == NULL )
{
@@ -250,7 +254,7 @@ Void InputStream::close()
if( m_pInputBuffer )
freeMem1D<Pel>( m_pInputBuffer );
m_iStatus = 0;
m_bInit = false;
}
Void InputStream::readNextFrame()
@@ -328,9 +332,9 @@ cv::Mat InputStream::getFrameCvMat()
}
#endif
Void InputStream::seekInput( Int new_frame_num )
Void InputStream::seekInput( UInt64 new_frame_num )
{
if( new_frame_num < 0 || new_frame_num >= ( Int )m_uiTotalFrameNum )
if( new_frame_num < 0 || new_frame_num >= m_uiTotalFrameNum )
return;
#ifdef USE_FFMPEG
if( m_cLibAvContext.getStatus() )
@@ -343,8 +347,8 @@ Void InputStream::seekInput( Int new_frame_num )
UInt64 frame_bytes_input = m_ppcFrameBuffer[0]->getBytesPerFrame();
UInt64 nbytes_seek = frame_bytes_input * new_frame_num;
fseek( m_pFile, nbytes_seek, SEEK_SET );
m_iCurrFrameNum = new_frame_num - 1;
}
m_iCurrFrameNum = new_frame_num - 1;
readNextFrame();
setNextFrame();
readNextFrame();
+2 -2
View File
@@ -86,7 +86,7 @@ private:
UInt m_uiWidth;
UInt m_uiHeight;
UInt m_uiFrameRate;
UInt m_uiTotalFrameNum;
UInt64 m_uiTotalFrameNum;
Int m_iCurrFrameNum;
public:
@@ -118,7 +118,7 @@ public:
PlaYUVerFrame* getCurrFrame();
PlaYUVerFrame* getCurrFrame( PlaYUVerFrame * );
Void seekInput( Int new_frame_num );
Void seekInput( UInt64 new_frame_num );
Bool checkErrors( Int error_type );
+4 -8
View File
@@ -51,7 +51,6 @@ SubWindowHandle::SubWindowHandle( QWidget * parent ) :
m_pCurrStream = new InputStream;
m_pCurrFrameQImage = NULL;
m_pcCurrentModule = NULL;
m_cWindowName = QString( " " );
@@ -63,8 +62,6 @@ SubWindowHandle::~SubWindowHandle()
delete m_cViewArea;
delete m_cScrollArea;
delete m_pCurrStream;
if( m_pCurrFrameQImage )
delete m_pCurrFrameQImage;
if( m_pcCurrentModule )
{
m_pcCurrentModule->m_pcAction->setChecked( false );
@@ -76,7 +73,7 @@ SubWindowHandle::~SubWindowHandle()
Bool SubWindowHandle::loadFile( const QString &fileName )
{
UInt Width = 0, Height = 0, FrameRate = 30;
Int InputFormat = 0;
Int InputFormat = -1;
if( m_pCurrStream->guessFormat( fileName, Width, Height, InputFormat, FrameRate ) )
{
@@ -93,9 +90,6 @@ Bool SubWindowHandle::loadFile( const QString &fileName )
return false;
}
m_pCurrFrameQImage = new QImage( m_pCurrStream->getCurrFrame()->getQImageBuffer(), m_pCurrStream->getWidth(), m_pCurrStream->getHeight(),
QImage::Format_RGB888 );
m_cViewArea->setInputStream( m_pCurrStream );
QApplication::restoreOverrideCursor();
@@ -167,7 +161,9 @@ Bool SubWindowHandle::save()
return false;
QApplication::setOverrideCursor( Qt::WaitCursor );
if( m_pCurrFrameQImage->save( fileName ) )
m_pCurrStream->getCurrFrame()->FrametoRGB8();
QImage qimg = QImage( m_pCurrStream->getCurrFrame()->getQImageBuffer(), m_pCurrStream->getCurrFrame()->getWidth(), m_pCurrStream->getCurrFrame()->getHeight(), QImage::Format_RGB888 );
if( qimg.save( fileName ) )
{
QApplication::restoreOverrideCursor();
QMessageBox::warning( this, tr( "plaYUVer" ), tr( "Cannot save file %1" ).arg( fileName ) );
-1
View File
@@ -53,7 +53,6 @@ private:
PlaYUVerModuleIf* m_pcCurrentModule;
InputStream* m_pCurrStream;
QImage* m_pCurrFrameQImage;
QString m_cWindowName;
QString m_cCurrFileName;
+8 -9
View File
@@ -102,7 +102,7 @@ Bool LibAvContextHandle::initAvFormat( char* filename, UInt& width, UInt& height
/* register all formats and codecs */
av_register_all();
if( width >= 0 && height >= 0 )
if( width > 0 && height > 0 )
{
Char aux_string[10];
sprintf( aux_string, "%dx%d", width, height );
@@ -220,19 +220,19 @@ Bool LibAvContextHandle::initAvFormat( char* filename, UInt& width, UInt& height
Bool LibAvContextHandle::decodeAvFormat()
{
Int got_frame;
int ret;
Bool bRet = false;
/* read frames from the file */
if( av_read_frame( fmt_ctx, &pkt ) >= 0 )
while( av_read_frame( fmt_ctx, &pkt ) >= 0 && !bRet )
{
if( pkt.stream_index == video_stream_idx )
{
/* decode video frame */
ret = avcodec_decode_video2( video_dec_ctx, frame, &got_frame, &pkt );
Int ret = avcodec_decode_video2( video_dec_ctx, frame, &got_frame, &pkt );
if( ret < 0 )
{
fprintf( stderr, "Error decoding video frame\n" );
return false;
return bRet;
}
if( got_frame )
@@ -242,13 +242,12 @@ Bool LibAvContextHandle::decodeAvFormat()
av_image_copy( video_dst_data, video_dst_linesize, ( const uint8_t ** )( frame->data ), frame->linesize, video_dec_ctx->pix_fmt, video_dec_ctx->width,
video_dec_ctx->height );
/* write to rawvideo file */
//fwrite( video_dst_data[0], 1, video_dst_bufsize, video_dst_file );
bRet = true;
}
}
av_free_packet( &pkt );
}
return bRet;
// /* flush cached frames */
// pkt.data = NULL;
// pkt.size = 0;
@@ -261,7 +260,7 @@ Bool LibAvContextHandle::decodeAvFormat()
return true;
}
Void LibAvContextHandle::seekAvFormat( UInt frame_num )
Void LibAvContextHandle::seekAvFormat( UInt64 frame_num )
{
av_seek_frame( fmt_ctx, video_stream_idx, frame_num, AVSEEK_FLAG_ANY );
}
+1 -1
View File
@@ -60,7 +60,7 @@ public:
Void closeAvFormat();
Bool decodeAvFormat();
Void seekAvFormat( UInt frame_num );
Void seekAvFormat( UInt64 frame_num );
Bool getStatus()
{