From 21e4f1680c379407d77f0ac976aa8236f8227be0 Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 13 Mar 2013 09:29:34 +0100 Subject: [PATCH] configure: bump minimum FFmpeg/Libav versions, remove compat hacks We consider FFmpeg 1.x and Libav 0.9.x releases compatible. Support for FFmpeg 0.9.x and Libav 0.8.x is considered infeasible and has been dropped in the previous commits. The bits that break compatibility are mainly the CodecID renaming (trivial, but would require nasty hacks everywhere), the avcodec_encode_video2() function (missing in older releases, mandatory in newer ones), and the resampler changes (older releases miss lib{av,sw}resample, newer versions removed the libavcodec resampler). Remove some other compatibility bits that were needed to for releases for which we drop support. The comment about Libav 0.9 in compat/libav.h is incorrect and should have been 0.8 (the symbol is present in Libav 0.9). --- compat/libav.h | 13 --------- configure | 37 +----------------------- core/av_common.c | 74 ------------------------------------------------ 3 files changed, 1 insertion(+), 123 deletions(-) diff --git a/compat/libav.h b/compat/libav.h index ef588fe025..a2957f4b71 100644 --- a/compat/libav.h +++ b/compat/libav.h @@ -32,17 +32,4 @@ #define AV_CODEC_ID_SUBRIP AV_CODEC_ID_TEXT #endif -#if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(51, 36, 0) -#define av_get_packed_sample_fmt(x) (x) -#endif - -#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(54, 28, 0) -#define avcodec_free_frame av_freep -#endif - -// For Libav 0.9 -#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(54, 2, 100) -#define AV_DISPOSITION_ATTACHED_PIC 0x0400 -#endif - #endif /* MPV_LIBAV_COMPAT_H */ diff --git a/configure b/configure index 7413c95498..1b855b9cb8 100755 --- a/configure +++ b/configure @@ -2675,9 +2675,7 @@ fi echores "$_lcms2" -# Test with > against Libav 0.8 versions which will NOT work rather than -# specify minimum version, to allow (future) point releases to possibly work. -all_libav_libs="libavutil > 51.22.0:libavcodec >= 53.35.0:libavformat > 53.20.0:libswscale >= 2.0.0" +all_libav_libs="libavutil > 51.73.0:libavcodec > 54.34.0:libavformat > 54.19.0:libswscale >= 2.0.0" echocheck "Libav ($all_libav_libs)" if test "$ffmpeg" = auto ; then IFS=":" # shell should not be used for programming @@ -2713,37 +2711,6 @@ if test "$_resampler" = no ; then fi -echocheck "Libav 0.8 compatibility hack" -if test "$_encoding" = yes && $_pkg_config "libavcodec >= 54.0.0" ; then - echores "no" -else - _encoding=no - echores "yes" -fi - - -echocheck "libavcodec AVCodecDescriptor API" -_avcodec_codec_desc_api=no -statement_check libavcodec/avcodec.h 'const AVCodecDescriptor *desc = avcodec_descriptor_get_by_name("c")' && _avcodec_codec_desc_api=yes -if test "$_avcodec_codec_desc_api" = yes ; then - def_avcodec_codec_desc_api='#define HAVE_AVCODEC_CODEC_DESC_API 1' -else - def_avcodec_codec_desc_api='#define HAVE_AVCODEC_CODEC_DESC_API 0' -fi -echores "$_avcodec_codec_desc_api" - - -echocheck "libavcodec av_codec_is_decoder API" -_avcodec_is_decoder_api=no -statement_check libavcodec/avcodec.h 'av_codec_is_decoder(NULL)' && _avcodec_is_decoder_api=yes -if test "$_avcodec_is_decoder_api" = yes ; then - def_avcodec_is_decoder_api='#define HAVE_AVCODEC_IS_DECODER_API 1' -else - def_avcodec_is_decoder_api='#define HAVE_AVCODEC_IS_DECODER_API 0' -fi -echores "$_avcodec_is_decoder_api" - - echocheck "libavutil ref-counting API" _avutil_has_refcounting=no statement_check libavutil/frame.h 'av_frame_unref(NULL)' && _avutil_has_refcounting=yes @@ -3253,8 +3220,6 @@ $def_vcd $def_mpg123 $def_zlib -$def_avcodec_codec_desc_api -$def_avcodec_is_decoder_api $def_avutil_has_refcounting $def_libpostproc $def_libavdevice diff --git a/core/av_common.c b/core/av_common.c index 20ca02f484..14a7a6b089 100644 --- a/core/av_common.c +++ b/core/av_common.c @@ -19,7 +19,6 @@ #include -#include "config.h" #include "core/mp_talloc.h" #include "av_common.h" #include "codecs.h" @@ -59,13 +58,6 @@ void mp_copy_lav_codec_headers(AVCodecContext *avctx, AVCodecContext *st) avctx->bits_per_coded_sample = st->bits_per_coded_sample; } -#if !HAVE_AVCODEC_IS_DECODER_API -static int av_codec_is_decoder(AVCodec *codec) -{ - return !!codec->decode; -} -#endif - void mp_add_lavc_decoders(struct mp_decoder_list *list, enum AVMediaType type) { AVCodec *cur = NULL; @@ -86,8 +78,6 @@ void mp_add_lavc_decoders(struct mp_decoder_list *list, enum AVMediaType type) } } -#if HAVE_AVCODEC_CODEC_DESC_API - int mp_codec_to_av_codec_id(const char *codec) { int id = AV_CODEC_ID_NONE; @@ -115,67 +105,3 @@ const char *mp_codec_from_av_codec_id(int codec_id) } return name; } - -#else - -struct mp_av_codec { - const char *name; - int codec_id; -}; - -// Some decoders have a different name from the canonical codec name, for -// example the codec "dts" AV_CODEC_ID_DTS has the decoder named "dca", and -// avcodec_find_decoder_by_name("dts") would return 0. We always want the -// canonical name. -// On newer lavc versions, avcodec_descriptor_get_by_name("dts") will return -// AV_CODEC_ID_DTS, which is what we want, but for older versions we need this -// lookup table. -struct mp_av_codec mp_av_codec_id_list[] = { - {"ra_144", AV_CODEC_ID_RA_144}, - {"ra_288", AV_CODEC_ID_RA_288}, - {"smackaudio", AV_CODEC_ID_SMACKAUDIO}, - {"dts", AV_CODEC_ID_DTS}, - {"musepack7", AV_CODEC_ID_MUSEPACK7}, - {"musepack8", AV_CODEC_ID_MUSEPACK8}, - {"amr_nb", AV_CODEC_ID_AMR_NB}, - {"amr_wb", AV_CODEC_ID_AMR_WB}, - {"adpcm_g722", AV_CODEC_ID_ADPCM_G722}, - {"adpcm_g726", AV_CODEC_ID_ADPCM_G726}, - {"westwood_snd1", AV_CODEC_ID_WESTWOOD_SND1}, - {"mp4als", AV_CODEC_ID_MP4ALS}, - {"vixl", AV_CODEC_ID_VIXL}, - {"flv1", AV_CODEC_ID_FLV1}, - {"msmpeg4v3", AV_CODEC_ID_MSMPEG4V3}, - {"jpeg2000", AV_CODEC_ID_JPEG2000}, - {"ulti", AV_CODEC_ID_ULTI}, - {"smackvideo", AV_CODEC_ID_SMACKVIDEO}, - {"tscc", AV_CODEC_ID_TSCC}, - {"cscd", AV_CODEC_ID_CSCD}, - {"tgv", AV_CODEC_ID_TGV}, - {"roq", AV_CODEC_ID_ROQ}, - {"idcin", AV_CODEC_ID_IDCIN}, - {"ws_vqa", AV_CODEC_ID_WS_VQA}, - {0}, -}; - -int mp_codec_to_av_codec_id(const char *codec) -{ - for (int n = 0; mp_av_codec_id_list[n].name; n++) { - if (strcmp(mp_av_codec_id_list[n].name, codec) == 0) - return mp_av_codec_id_list[n].codec_id; - } - AVCodec *avcodec = avcodec_find_decoder_by_name(codec); - return avcodec ? avcodec->id : AV_CODEC_ID_NONE; -} - -const char *mp_codec_from_av_codec_id(int codec_id) -{ - for (int n = 0; mp_av_codec_id_list[n].name; n++) { - if (mp_av_codec_id_list[n].codec_id == codec_id) - return mp_av_codec_id_list[n].name; - } - AVCodec *avcodec = avcodec_find_decoder(codec_id); - return avcodec ? avcodec->name : NULL; -} - -#endif