From 4523accb0799366fa9503bed57c3270c3a33455c Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sun, 2 Feb 2014 14:07:42 +0000 Subject: [PATCH] Read steam information from LibAvContextHandle when it is possible --- source/InputStream.cpp | 3 +-- source/LibAvContextHandle.cpp | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/source/InputStream.cpp b/source/InputStream.cpp index 07f36d4..083dcb5 100755 --- a/source/InputStream.cpp +++ b/source/InputStream.cpp @@ -109,7 +109,6 @@ QStringList InputStream::supportedPixelFormatList() Bool InputStream::needFormatDialog( QString filename ) { - return true; QString fileExtension = QFileInfo( filename ).completeSuffix(); if( !fileExtension.compare( QString( "yuv" ) ) ) { @@ -130,7 +129,7 @@ Void InputStream::init( QString filename, UInt width, UInt height, Int input_for m_iPixelFormat = input_format; #ifdef USE_FFMPEG - Bool avStatus = m_cLibAvContext.initAvFormat( filename, width, height, input_format ); + Bool avStatus = m_cLibAvContext.initAvFormat( filename, m_uiWidth, m_uiHeight, m_iPixelFormat ); #endif if( m_uiWidth <= 0 || m_uiHeight <= 0 ) diff --git a/source/LibAvContextHandle.cpp b/source/LibAvContextHandle.cpp index 73e08ed..e926a69 100755 --- a/source/LibAvContextHandle.cpp +++ b/source/LibAvContextHandle.cpp @@ -24,7 +24,7 @@ #include "LibAvContextHandle.h" #ifdef USE_FFMPEG - + #include #include @@ -135,6 +135,19 @@ Bool LibAvContextHandle::initAvFormat( QString filename, UInt& width, UInt& heig video_dst_bufsize = ret; } + AVCodecContext *in_codec = fmt_ctx->streams[0]->codec; + width = in_codec->width; + height = in_codec->height; + switch( in_codec->pix_fmt ) + { + case AV_PIX_FMT_YUV420P: + pixel_format = PlaYUVerFrame::YUV420; + break; + case AV_PIX_FMT_GRAY8: + pixel_format = PlaYUVerFrame::YUV400; + break; + } + /* dump input information to stderr */ av_dump_format( fmt_ctx, 0, src_filename, 0 ); if( !video_stream )