diff options
author | Peter Schlaile <peter@schlaile.de> | 2011-05-28 03:33:40 +0400 |
---|---|---|
committer | Peter Schlaile <peter@schlaile.de> | 2011-05-28 03:33:40 +0400 |
commit | 42121590f4bfd65f26e8ec705a660f4cc1bd826e (patch) | |
tree | d57d4cf5b303c81ecdd43b89d503b481d48a2be8 /source/blender | |
parent | a9467182fb00be9fb6dd276e80b69fb650b2cac3 (diff) |
== FFMPEG ==
Added central compatibility header file, which enables blender to compile
against very old ffmpeg versions as well as very new versions using the
*NEW* API. (Old API functions are simulated using macros and inline functions)
Added a whole lot of additional checks, tested against 6 different versions
down the timeline, hopefully, now finally all is well.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/CMakeLists.txt | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/SConscript | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/writeffmpeg.c | 41 | ||||
-rw-r--r-- | source/blender/imbuf/CMakeLists.txt | 1 | ||||
-rw-r--r-- | source/blender/imbuf/SConscript | 2 | ||||
-rw-r--r-- | source/blender/imbuf/intern/anim_movie.c | 50 | ||||
-rw-r--r-- | source/blender/imbuf/intern/util.c | 8 |
7 files changed, 11 insertions, 93 deletions
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index 2831636361f..44d20b6c651 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -44,6 +44,7 @@ set(INC ../editors/include ../render/extern/include ../../../intern/audaspace/intern + ../../../intern/ffmpeg ../../../intern/bsp/extern ../blenfont ../../../intern/decimation/extern ../../../intern/elbeem/extern diff --git a/source/blender/blenkernel/SConscript b/source/blender/blenkernel/SConscript index ea19b51c044..b5f845acacb 100644 --- a/source/blender/blenkernel/SConscript +++ b/source/blender/blenkernel/SConscript @@ -14,6 +14,7 @@ incs += ' ../gpu #/extern/glew/include' incs += ' #/intern/smoke/extern' incs += ' #/intern/mikktspace' incs += ' #/intern/audaspace/intern' +incs += ' #/intern/ffmpeg' incs += ' ' + env['BF_OPENGL_INC'] incs += ' ' + env['BF_ZLIB_INC'] diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index 48930ae2eb8..c729565533f 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -61,34 +61,7 @@ #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" -#if (LIBAVFORMAT_VERSION_MAJOR > 52) || ((LIBAVFORMAT_VERSION_MAJOR >= 52) && (LIBAVFORMAT_VERSION_MINOR >= 105)) -#define FFMPEG_HAVE_AVIO 1 -#endif - -#if (LIBAVFORMAT_VERSION_MAJOR > 53) || ((LIBAVFORMAT_VERSION_MAJOR >= 53) && (LIBAVFORMAT_VERSION_MINOR >= 1)) -#define FFMPEG_HAVE_DEFAULT_VAL_UNION 1 -#endif - -#if (LIBAVFORMAT_VERSION_MAJOR > 52) || ((LIBAVFORMAT_VERSION_MAJOR >= 52) && (LIBAVFORMAT_VERSION_MINOR >= 101)) -#define FFMPEG_HAVE_AV_DUMP_FORMAT 1 -#endif - -#ifndef FFMPEG_HAVE_AVIO -#define AVIO_FLAG_WRITE URL_WRONLY -#define avio_open url_fopen -#define avio_tell url_ftell -#define avio_close url_fclose -#endif - -/* make OpenSuSe special "in-between" ffmpeg 0.6.2 version(tm) happy... - Arrrrgh */ -#ifndef AVIO_FLAG_WRITE -#define AVIO_FLAG_WRITE URL_WRONLY -#endif - -#ifndef FFMPEG_HAVE_AV_DUMP_FORMAT -#define av_dump_format dump_format -#endif +#include "ffmpeg_compat.h" extern void do_init_ffmpeg(void); @@ -1080,20 +1053,12 @@ IDProperty *ffmpeg_property_add(RenderData *rd, char * type, int opt_index, int switch (o->type) { case FF_OPT_TYPE_INT: case FF_OPT_TYPE_INT64: -#ifdef FFMPEG_HAVE_DEFAULT_VAL_UNION - val.i = o->default_val.i64; -#else - val.i = o->default_val; -#endif + val.i = FFMPEG_DEF_OPT_VAL_INT(o); idp_type = IDP_INT; break; case FF_OPT_TYPE_DOUBLE: case FF_OPT_TYPE_FLOAT: -#ifdef FFMPEG_HAVE_DEFAULT_VAL_UNION - val.f = o->default_val.dbl; -#else - val.f = o->default_val; -#endif + val.f = FFMPEG_DEF_OPT_VAL_DOUBLE(o); idp_type = IDP_FLOAT; break; case FF_OPT_TYPE_STRING: diff --git a/source/blender/imbuf/CMakeLists.txt b/source/blender/imbuf/CMakeLists.txt index 6404ae3de75..2522bcfed92 100644 --- a/source/blender/imbuf/CMakeLists.txt +++ b/source/blender/imbuf/CMakeLists.txt @@ -38,6 +38,7 @@ set(INC ../makesdna ../../../intern/memutil ../../../intern/guardedalloc + ../../../intern/ffmpeg ${JPEG_INCLUDE_DIR} ${PNG_INCLUDE_DIR} ${ZLIB_INCLUDE_DIRS} diff --git a/source/blender/imbuf/SConscript b/source/blender/imbuf/SConscript index ecb9a89c274..a80f92b4421 100644 --- a/source/blender/imbuf/SConscript +++ b/source/blender/imbuf/SConscript @@ -5,7 +5,7 @@ sources = env.Glob('intern/*.c') incs = '. ../makesdna #/intern/guardedalloc #/intern/memutil ../blenlib' incs += ' ../avi ../blenkernel ../blenloader' - +incs += ' #/intern/ffmpeg' incs += ' ' + env['BF_JPEG_INC'] incs += ' ' + env['BF_PNG_INC'] diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c index a0051d85c5b..919b0eb0c29 100644 --- a/source/blender/imbuf/intern/anim_movie.c +++ b/source/blender/imbuf/intern/anim_movie.c @@ -97,24 +97,7 @@ #include <libavutil/rational.h> #include <libswscale/swscale.h> -#if LIBAVFORMAT_VERSION_INT < (49 << 16) -#define FFMPEG_OLD_FRAME_RATE 1 -#else -#define FFMPEG_CODEC_IS_POINTER 1 -#endif - -#if (LIBAVCODEC_VERSION_MAJOR >= 52) && (LIBAVCODEC_VERSION_MINOR >= 29) && \ - (LIBSWSCALE_VERSION_MAJOR >= 0) && (LIBSWSCALE_VERSION_MINOR >= 10) -#define FFMPEG_SWSCALE_COLOR_SPACE_SUPPORT -#endif - -#if (LIBAVFORMAT_VERSION_MAJOR > 52) || ((LIBAVFORMAT_VERSION_MAJOR >= 52) && (LIBAVFORMAT_VERSION_MINOR >= 101)) -#define FFMPEG_HAVE_AV_DUMP_FORMAT 1 -#endif - -#ifndef FFMPEG_HAVE_AV_DUMP_FORMAT -#define av_dump_format dump_format -#endif +#include "ffmpeg_compat.h" #endif //WITH_FFMPEG @@ -528,18 +511,6 @@ static ImBuf * avi_fetchibuf (struct anim *anim, int position) { extern void do_init_ffmpeg(void); -#ifdef FFMPEG_CODEC_IS_POINTER -static AVCodecContext* get_codec_from_stream(AVStream* stream) -{ - return stream->codec; -} -#else -static AVCodecContext* get_codec_from_stream(AVStream* stream) -{ - return &stream->codec; -} -#endif - static int startffmpeg(struct anim * anim) { int i, videoStream; @@ -573,7 +544,7 @@ static int startffmpeg(struct anim * anim) { /* Find the first video stream */ videoStream=-1; for(i=0; i<pFormatCtx->nb_streams; i++) - if(get_codec_from_stream(pFormatCtx->streams[i])->codec_type + if(pFormatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) { videoStream=i; break; @@ -584,7 +555,7 @@ static int startffmpeg(struct anim * anim) { return -1; } - pCodecCtx = get_codec_from_stream(pFormatCtx->streams[videoStream]); + pCodecCtx = pFormatCtx->streams[videoStream]->codec; /* Find the decoder for the video stream */ pCodec=avcodec_find_decoder(pCodecCtx->codec_id); @@ -600,19 +571,10 @@ static int startffmpeg(struct anim * anim) { return -1; } -#ifdef FFMPEG_OLD_FRAME_RATE - if(pCodecCtx->frame_rate>1000 && pCodecCtx->frame_rate_base==1) - pCodecCtx->frame_rate_base=1000; - - - anim->duration = pFormatCtx->duration * pCodecCtx->frame_rate - / pCodecCtx->frame_rate_base / AV_TIME_BASE; -#else anim->duration = ceil(pFormatCtx->duration * av_q2d(pFormatCtx->streams[videoStream]->r_frame_rate) / AV_TIME_BASE); -#endif anim->params = 0; anim->x = pCodecCtx->width; @@ -866,15 +828,9 @@ static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position) { #endif if (position != anim->curposition + 1) { -#ifdef FFMPEG_OLD_FRAME_RATE - double frame_rate = - (double) anim->pCodecCtx->frame_rate - / (double) anim->pCodecCtx->frame_rate_base; -#else double frame_rate = av_q2d(anim->pFormatCtx->streams[anim->videoStream] ->r_frame_rate); -#endif double pts_time_base = av_q2d(anim->pFormatCtx->streams[anim->videoStream]->time_base); long long pos; long long st_time = anim->pFormatCtx->start_time; diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c index 3eed69f4c52..6e5e87d7e5c 100644 --- a/source/blender/imbuf/intern/util.c +++ b/source/blender/imbuf/intern/util.c @@ -63,13 +63,7 @@ #include <libavdevice/avdevice.h> #include <libavutil/log.h> -#if (LIBAVFORMAT_VERSION_MAJOR > 52) || ((LIBAVFORMAT_VERSION_MAJOR >= 52) && (LIBAVFORMAT_VERSION_MINOR >= 101)) -#define FFMPEG_HAVE_AV_DUMP_FORMAT 1 -#endif - -#ifndef FFMPEG_HAVE_AV_DUMP_FORMAT -#define av_dump_format dump_format -#endif +#include "ffmpeg_compat.h" #endif |