diff --git a/source/app/InputStream.cpp b/source/app/InputStream.cpp index 92d0553..2a5235a 100755 --- a/source/app/InputStream.cpp +++ b/source/app/InputStream.cpp @@ -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(); @@ -329,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() ) @@ -344,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(); diff --git a/source/app/InputStream.h b/source/app/InputStream.h index 4b296e5..9485095 100755 --- a/source/app/InputStream.h +++ b/source/app/InputStream.h @@ -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 ); diff --git a/source/app/SubWindowHandle.cpp b/source/app/SubWindowHandle.cpp index d9716b9..a4db459 100644 --- a/source/app/SubWindowHandle.cpp +++ b/source/app/SubWindowHandle.cpp @@ -73,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 ) ) { diff --git a/source/lib/ffmpeg/LibAvContextHandle.cpp b/source/lib/ffmpeg/LibAvContextHandle.cpp index 8b4c6d0..807dcf7 100755 --- a/source/lib/ffmpeg/LibAvContextHandle.cpp +++ b/source/lib/ffmpeg/LibAvContextHandle.cpp @@ -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 ); } diff --git a/source/lib/ffmpeg/LibAvContextHandle.h b/source/lib/ffmpeg/LibAvContextHandle.h index e8cb989..9fd15be 100755 --- a/source/lib/ffmpeg/LibAvContextHandle.h +++ b/source/lib/ffmpeg/LibAvContextHandle.h @@ -60,7 +60,7 @@ public: Void closeAvFormat(); Bool decodeAvFormat(); - Void seekAvFormat( UInt frame_num ); + Void seekAvFormat( UInt64 frame_num ); Bool getStatus() {