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