From a24009d87070926055e53e9934d243b4199d7ef7 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Mon, 3 Feb 2014 01:41:34 +0000 Subject: [PATCH] Add compatibility defines into LibAvContextHandle --- source/lib/ffmpeg/LibAvContextHandle.cpp | 14 ++++++++++---- source/lib/ffmpeg/LibAvContextHandle.h | 23 +++++++++++++++-------- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/source/lib/ffmpeg/LibAvContextHandle.cpp b/source/lib/ffmpeg/LibAvContextHandle.cpp index 969b270..31b6fb4 100755 --- a/source/lib/ffmpeg/LibAvContextHandle.cpp +++ b/source/lib/ffmpeg/LibAvContextHandle.cpp @@ -81,7 +81,6 @@ Void LibAvContextHandle::closeAvFormat() Bool LibAvContextHandle::initAvFormat( char* filename, UInt& width, UInt& height, Int& pixel_format, UInt& frame_rate ) { - Bool bRet = true; int ret = 0; fmt_ctx = NULL; @@ -117,6 +116,8 @@ Bool LibAvContextHandle::initAvFormat( char* filename, UInt& width, UInt& height case YUV400: av_dict_set( &format_opts, "pixel_format", av_get_pix_fmt_name( AV_PIX_FMT_GRAY8 ), 0 ); break; + default: + break; } /* open input file, and allocate format context */ @@ -173,6 +174,8 @@ Bool LibAvContextHandle::initAvFormat( char* filename, UInt& width, UInt& height case AV_PIX_FMT_GRAY8: pixel_format = YUV400; break; + default: + break; } /* dump input information to stderr */ @@ -180,12 +183,15 @@ Bool LibAvContextHandle::initAvFormat( char* filename, UInt& width, UInt& height if( !video_stream ) { //qDebug( ) << " Could not find audio or video stream in the input, aborting !!!" << endl; - bRet = false; closeAvFormat(); return false; } - + +#if( LIBAVFORMAT_VERSION_MAJOR >= 55 ) + frame = av_frame_alloc(); +#else frame = avcodec_alloc_frame(); +#endif if( !frame ) { //qDebug( ) << " Could not allocate frame !!!" << endl; @@ -245,7 +251,7 @@ Bool LibAvContextHandle::decodeAvFormat() // } // while( got_frame ); - true; + return true; } Void LibAvContextHandle::seekAvFormat( UInt frame_num ) diff --git a/source/lib/ffmpeg/LibAvContextHandle.h b/source/lib/ffmpeg/LibAvContextHandle.h index 435dd7e..4445816 100755 --- a/source/lib/ffmpeg/LibAvContextHandle.h +++ b/source/lib/ffmpeg/LibAvContextHandle.h @@ -24,19 +24,26 @@ #ifndef __LIBAVCONTEXTHANDLE_H__ #define __LIBAVCONTEXTHANDLE_H__ -//#include "config.h" +#include + +#ifndef __PRI64_PREFIX +#define __PRI64_PREFIX "l" +#endif + +#ifndef PRId64 +#define PRId64 __PRI64_PREFIX "d" +#endif extern "C" { -#include "libavutil/imgutils.h" -#include "libavutil/samplefmt.h" -#include "libavutil/timestamp.h" -#include "libavformat/avformat.h" +#include +#include +#include +#include +#include } -#ifndef __STDC_CONSTANT_MACROS -#define smprintf _snprintf -#endif + #include "TypeDef.h"