diff options
author | Sebastian Parborg <darkdefende@gmail.com> | 2022-11-07 19:44:14 +0300 |
---|---|---|
committer | Sebastian Parborg <darkdefende@gmail.com> | 2022-11-07 19:46:13 +0300 |
commit | 3e71220efcc11afaedb33a1cb2c9d3cd2cb50228 (patch) | |
tree | da103abac79b4c5dcd31746d34fb70c29a042793 /intern | |
parent | 95631c94c4bd08f8a7e9c713f624e934eb7eb7ae (diff) |
Fix support for building with ffmpeg < 5.0
Seems like the new audio channel api was not as backwards compatible as we thought.
Therefore we need to reintroduce the usage of the old api to make older ffmpeg version be able to compile Blender.
This change is only intended to stick around for two releases or so. After that we hope that most Linux distros ship
ffmpeg >=5.0 so we can switch to it.
Reviewed By: Sergey
Differential Revision: http://developer.blender.org/D16408
Diffstat (limited to 'intern')
-rw-r--r-- | intern/ffmpeg/CMakeLists.txt | 1 | ||||
-rw-r--r-- | intern/ffmpeg/ffmpeg_compat.h | 8 | ||||
-rw-r--r-- | intern/ffmpeg/tests/ffmpeg_codecs.cc | 6 |
3 files changed, 15 insertions, 0 deletions
diff --git a/intern/ffmpeg/CMakeLists.txt b/intern/ffmpeg/CMakeLists.txt index 0de8496f3f3..4fb5df9d4cd 100644 --- a/intern/ffmpeg/CMakeLists.txt +++ b/intern/ffmpeg/CMakeLists.txt @@ -6,6 +6,7 @@ if(WITH_GTESTS) tests/ffmpeg_codecs.cc ) set(TEST_INC + . ) set(TEST_INC_SYS ${FFMPEG_INCLUDE_DIRS} diff --git a/intern/ffmpeg/ffmpeg_compat.h b/intern/ffmpeg/ffmpeg_compat.h index f311e04d8e0..f7d87af8bca 100644 --- a/intern/ffmpeg/ffmpeg_compat.h +++ b/intern/ffmpeg/ffmpeg_compat.h @@ -36,6 +36,14 @@ # define FFMPEG_INLINE static inline #endif +#if (LIBAVFORMAT_VERSION_MAJOR < 59) +/* For versions older than ffmpeg 5.0, use the old channel layout variables. + * We intend to only keep this workaround for around two releases (3.5, 3.6). + * If it sticks around any longer, then we should consider refactoring this. + */ +# define FFMPEG_USE_OLD_CHANNEL_VARS +#endif + #if (LIBAVFORMAT_VERSION_MAJOR < 58) || \ ((LIBAVFORMAT_VERSION_MAJOR == 58) && (LIBAVFORMAT_VERSION_MINOR < 76)) # define FFMPEG_USE_DURATION_WORKAROUND 1 diff --git a/intern/ffmpeg/tests/ffmpeg_codecs.cc b/intern/ffmpeg/tests/ffmpeg_codecs.cc index 10cbe4b938b..cd06917f59b 100644 --- a/intern/ffmpeg/tests/ffmpeg_codecs.cc +++ b/intern/ffmpeg/tests/ffmpeg_codecs.cc @@ -3,6 +3,8 @@ #include "testing/testing.h" extern "C" { +#include "ffmpeg_compat.h" + #include <libavcodec/avcodec.h> #include <libavutil/channel_layout.h> #include <libavutil/log.h> @@ -40,7 +42,11 @@ bool test_acodec(const AVCodec *codec, AVSampleFormat fmt) if (ctx) { ctx->sample_fmt = fmt; ctx->sample_rate = 48000; +#ifdef FFMPEG_USE_OLD_CHANNEL_VARS + ctx->channel_layout = AV_CH_LAYOUT_MONO; +#else av_channel_layout_from_mask(&ctx->ch_layout, AV_CH_LAYOUT_MONO); +#endif ctx->bit_rate = 128000; int open = avcodec_open2(ctx, codec, NULL); if (open >= 0) { |