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.
This commit is contained in:
wm4 2017-01-27 09:57:01 +01:00
parent a9e0f4b279
commit cfda696580
3 changed files with 60 additions and 44 deletions

View File

@ -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

View File

@ -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
};

93
wscript
View File

@ -386,54 +386,67 @@ 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
libav_pkg_config_checks = [
'libavutil', '>= 55.20.0',
'libavcodec', '>= 57.25.0',
'libavformat', '>= 57.07.0',
'libswscale', '>= 4.0.0',
'libavfilter', '>= 6.7.0',
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_versions_string = "FFmpeg 3.2.2 or Libav 12"
libav_version = "12"
libav_pkg_config_checks = [
'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 %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',