diff options
author | wm4 <wm4@nowhere> | 2017-01-27 09:57:01 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2017-01-27 09:57:01 +0100 |
commit | cfda696580a994055e4532a273ce86c867ffdac4 (patch) | |
tree | ec58b108f5444ca888732576c79e076088e931b0 | |
parent | a9e0f4b2793091991dfca4fba715f7a6635e797d (diff) | |
download | mpv-cfda696580a994055e4532a273ce86c867ffdac4.tar.bz2 mpv-cfda696580a994055e4532a273ce86c867ffdac4.tar.xz |
build: explicitly check for FFmpeg vs. Libav, and their exact versions
In a first pass, we check whether libavcodec is present.
Then we try to compile a snippet and check for FFmpeg vs. Libav. (This
could probably also be done by somehow checking the pkgconfig version.
But pkg-config can't deal with that idiotic FFmpeg idea that a micro
version number >= 100 identifies FFmpeg vs. Libav.)
After that we check the project-specific version numbers. This means it
can no longer happen that we accidentally allow older, unsupported
versions of FFmpeg, just because the Libav version numbers are somehow
this way.
Also drop the resampler checks. We hardcode which resampler to each with
each project. A user can no longer force use of libavresample with
FFmpeg.
-rw-r--r-- | audio/filter/af_lavrresample.c | 3 | ||||
-rw-r--r-- | common/av_log.c | 8 | ||||
-rw-r--r-- | wscript | 91 |
3 files changed, 59 insertions, 43 deletions
diff --git a/audio/filter/af_lavrresample.c b/audio/filter/af_lavrresample.c index 828be66247..47c374b227 100644 --- a/audio/filter/af_lavrresample.c +++ b/audio/filter/af_lavrresample.c @@ -36,6 +36,9 @@ #include "common/common.h" #include "config.h" +#define HAVE_LIBSWRESAMPLE HAVE_IS_FFMPEG +#define HAVE_LIBAVRESAMPLE HAVE_IS_LIBAV + #if HAVE_LIBAVRESAMPLE #include <libavresample/avresample.h> #elif HAVE_LIBSWRESAMPLE diff --git a/common/av_log.c b/common/av_log.c index e2a4c3316e..c779fe9c8d 100644 --- a/common/av_log.c +++ b/common/av_log.c @@ -42,10 +42,10 @@ #include <libavdevice/avdevice.h> #endif -#if HAVE_LIBAVRESAMPLE +#if HAVE_IS_LIBAV #include <libavresample/avresample.h> #endif -#if HAVE_LIBSWRESAMPLE +#if HAVE_IS_FFMPEG #include <libswresample/swresample.h> #endif @@ -197,10 +197,10 @@ bool print_libav_versions(struct mp_log *log, int v) {"libavformat", LIBAVFORMAT_VERSION_INT, avformat_version()}, {"libswscale", LIBSWSCALE_VERSION_INT, swscale_version()}, {"libavfilter", LIBAVFILTER_VERSION_INT, avfilter_version()}, -#if HAVE_LIBAVRESAMPLE +#if HAVE_IS_LIBAV {"libavresample", LIBAVRESAMPLE_VERSION_INT, avresample_version()}, #endif -#if HAVE_LIBSWRESAMPLE +#if HAVE_IS_FFMPEG {"libswresample", LIBSWRESAMPLE_VERSION_INT, swresample_version()}, #endif }; @@ -386,55 +386,68 @@ iconv support use --disable-iconv.", } ] -# Libav 12: -# libavutil 55.20.0 -# libavcodec 57.25.0 -# libavformat 57.7.2 -# libswscale 4.0.0 -# libavfilter 6.7.0 -# libavresample 3.0.0 -# FFmpeg 3.2.2: -# libavutil 55.34.100 -# libavcodec 57.64.101 -# libavformat 57.56.100 -# libswscale 4.2.100 -# libavfilter 6.65.100 -# libswresample 2.3.100 - +ffmpeg_version = "3.2.2" +ffmpeg_pkg_config_checks = [ + 'libavutil', '>= 55.34.100', + 'libavcodec', '>= 57.64.100', + 'libavformat', '>= 57.56.100', + 'libswscale', '>= 4.2.100', + 'libavfilter', '>= 6.65.100', + 'libswresample', '>= 2.3.100', +] +libav_version = "12" libav_pkg_config_checks = [ - 'libavutil', '>= 55.20.0', - 'libavcodec', '>= 57.25.0', - 'libavformat', '>= 57.07.0', - 'libswscale', '>= 4.0.0', - 'libavfilter', '>= 6.7.0', + 'libavutil', '>= 55.20.0', + 'libavcodec', '>= 57.25.0', + 'libavformat', '>= 57.7.0', + 'libswscale', '>= 4.0.0', + 'libavfilter', '>= 6.7.0', + 'libavresample', '>= 3.0.0', ] -libav_versions_string = "FFmpeg 3.2.2 or Libav 12" + +libav_versions_string = "FFmpeg %s or Libav %s" % (ffmpeg_version, libav_version) + +def check_ffmpeg_or_libav_versions(): + def fn(ctx, dependency_identifier, **kw): + versions = ffmpeg_pkg_config_checks + if ctx.dependency_satisfied('is_libav'): + versions = libav_pkg_config_checks + return check_pkg_config(*versions)(ctx, dependency_identifier, **kw) + return fn libav_dependencies = [ { + 'name': 'libavcodec', + 'desc': 'FFmpeg/Libav present', + 'func': check_pkg_config('libavcodec'), + 'req': True, + 'fmsg': "FFmpeg/Libav development files not found.", + }, { + 'name': 'is_ffmpeg', + 'desc': 'libav* is FFmpeg', + # FFmpeg <=> LIBAVUTIL_VERSION_MICRO>=100 + 'func': check_statement('libavcodec/version.h', + 'int x[LIBAVCODEC_VERSION_MICRO >= 100 ? 1 : -1]', + use='libavcodec') + }, { + # This check should always result in the opposite of is_ffmpeg. + # Run it to make sure is_ffmpeg didn't fail for some other reason than + # the actual version check. + 'name': 'is_libav', + 'desc': 'libav* is Libav', + # FFmpeg <=> LIBAVUTIL_VERSION_MICRO>=100 + 'func': check_statement('libavcodec/version.h', + 'int x[LIBAVCODEC_VERSION_MICRO >= 100 ? -1 : 1]', + use='libavcodec') + }, { 'name': 'libav', - 'desc': 'libav/ffmpeg', - 'func': check_pkg_config(*libav_pkg_config_checks), + 'desc': 'Libav/FFmpeg library versions', + 'deps_any': [ 'is_ffmpeg', 'is_libav' ], + 'func': check_ffmpeg_or_libav_versions(), 'req': True, 'fmsg': "Unable to find development files for some of the required \ FFmpeg/Libav libraries. You need at least {0}. Aborting.".format(libav_versions_string) }, { - 'name': '--libswresample', - 'desc': 'libswresample', - 'func': check_pkg_config('libswresample', '>= 2.3.100'), - }, { - 'name': '--libavresample', - 'desc': 'libavresample', - 'func': check_pkg_config('libavresample', '>= 3.0.0'), - 'deps_neg': ['libswresample'], - }, { - 'name': 'resampler', - 'desc': 'usable resampler found', - 'deps_any': [ 'libavresample', 'libswresample' ], - 'func': check_true, - 'req': True, - 'fmsg': 'No resampler found. Install libavresample or libswresample (FFmpeg).' - }, { 'name': '--libavdevice', 'desc': 'libavdevice', 'func': check_pkg_config('libavdevice', '>= 57.0.0'), |