diff options
Diffstat (limited to 'common/av_log.c')
-rw-r--r-- | common/av_log.c | 43 |
1 files changed, 16 insertions, 27 deletions
diff --git a/common/av_log.c b/common/av_log.c index afc66b0ed2..8122d3a65b 100644 --- a/common/av_log.c +++ b/common/av_log.c @@ -35,6 +35,7 @@ #include <libavcodec/avcodec.h> #include <libavformat/avformat.h> +#include <libswresample/swresample.h> #include <libswscale/swscale.h> #include <libavfilter/avfilter.h> @@ -42,18 +43,6 @@ #include <libavdevice/avdevice.h> #endif -#if HAVE_LIBAV -#include <libavresample/avresample.h> -#else -#include <libswresample/swresample.h> -#endif - -#if LIBAVCODEC_VERSION_MICRO >= 100 -#define LIB_PREFIX "ffmpeg" -#else -#define LIB_PREFIX "libav" -#endif - // Needed because the av_log callback does not provide a library-safe message // callback. static pthread_mutex_t log_lock = PTHREAD_MUTEX_INITIALIZER; @@ -151,7 +140,7 @@ void init_libav(struct mpv_global *global) pthread_mutex_lock(&log_lock); if (!log_mpv_instance) { log_mpv_instance = global; - log_root = mp_log_new(NULL, global->log, LIB_PREFIX); + log_root = mp_log_new(NULL, global->log, "ffmpeg"); log_decaudio = mp_log_new(log_root, log_root, "audio"); log_decvideo = mp_log_new(log_root, log_root, "video"); log_demuxer = mp_log_new(log_root, log_root, "demuxer"); @@ -177,7 +166,9 @@ void uninit_libav(struct mpv_global *global) pthread_mutex_unlock(&log_lock); } -#define V(x) (x)>>16, (x)>>8 & 255, (x) & 255 +#define V(x) AV_VERSION_MAJOR(x), \ + AV_VERSION_MINOR(x), \ + AV_VERSION_MICRO(x) struct lib { const char *name; @@ -185,7 +176,7 @@ struct lib { unsigned runv; }; -bool print_libav_versions(struct mp_log *log, int v) +void check_library_versions(struct mp_log *log, int v) { const struct lib libs[] = { {"libavutil", LIBAVUTIL_VERSION_INT, avutil_version()}, @@ -193,29 +184,27 @@ 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_LIBAV - {"libavresample", LIBAVRESAMPLE_VERSION_INT, avresample_version()}, -#else {"libswresample", LIBSWRESAMPLE_VERSION_INT, swresample_version()}, -#endif }; - mp_msg(log, v, "%s library versions:\n", LIB_PREFIX); + mp_msg(log, v, "FFmpeg library versions:\n"); - bool mismatch = false; for (int n = 0; n < MP_ARRAY_SIZE(libs); n++) { const struct lib *l = &libs[n]; mp_msg(log, v, " %-15s %d.%d.%d", l->name, V(l->buildv)); - if (l->buildv != l->runv) { + if (l->buildv != l->runv) mp_msg(log, v, " (runtime %d.%d.%d)", V(l->runv)); - mismatch = true; - } mp_msg(log, v, "\n"); + if (l->buildv > l->runv || + AV_VERSION_MAJOR(l->buildv) != AV_VERSION_MAJOR(l->runv)) + { + fprintf(stderr, "%s: %d.%d.%d -> %d.%d.%d\n", + l->name, V(l->buildv), V(l->runv)); + abort(); + } } - mp_msg(log, v, "%s version: %s\n", LIB_PREFIX, av_version_info()); - - return !mismatch; + mp_msg(log, v, "FFmpeg version: %s\n", av_version_info()); } #undef V |