From 706bb1d0c756be95e8646c6e433d5d24f7c75dca Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 12 Feb 2018 19:28:30 +0100 Subject: Fix recent FFmpeg deprecations This includes codec/muxer/demuxer iteration (different iteration function, registration functions deprecated), and the renaming of AVFormatContext.filename to url (plus making it a malloced string). Libav doesn't have the new API yet, so it will break. I hope they will add the new APIs too. --- common/av_common.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'common/av_common.c') diff --git a/common/av_common.c b/common/av_common.c index 0981e919e1..a76dd37117 100644 --- a/common/av_common.c +++ b/common/av_common.c @@ -219,42 +219,43 @@ void mp_set_avcodec_threads(struct mp_log *l, AVCodecContext *avctx, int threads avctx->thread_count = threads; } -void mp_add_lavc_decoders(struct mp_decoder_list *list, enum AVMediaType type) +static void add_codecs(struct mp_decoder_list *list, enum AVMediaType type, + bool decoders) { - AVCodec *cur = NULL; + const AVCodec *cur = NULL; + void *iter = NULL; for (;;) { - cur = av_codec_next(cur); + cur = av_codec_iterate(&iter); if (!cur) break; - if (av_codec_is_decoder(cur) && cur->type == type) { + if (av_codec_is_decoder(cur) == decoders && + (type == AVMEDIA_TYPE_UNKNOWN || cur->type == type)) + { mp_add_decoder(list, mp_codec_from_av_codec_id(cur->id), cur->name, cur->long_name); } } } +void mp_add_lavc_decoders(struct mp_decoder_list *list, enum AVMediaType type) +{ + add_codecs(list, type, true); +} + // (Abuses the decoder list data structures.) void mp_add_lavc_encoders(struct mp_decoder_list *list) { - AVCodec *cur = NULL; - for (;;) { - cur = av_codec_next(cur); - if (!cur) - break; - if (av_codec_is_encoder(cur)) { - mp_add_decoder(list, mp_codec_from_av_codec_id(cur->id), - cur->name, cur->long_name); - } - } + add_codecs(list, AVMEDIA_TYPE_UNKNOWN, false); } char **mp_get_lavf_demuxers(void) { char **list = NULL; - AVInputFormat *cur = NULL; + const AVInputFormat *cur = NULL; + void *iter = NULL; int num = 0; for (;;) { - cur = av_iformat_next(cur); + cur = av_demuxer_iterate(&iter); if (!cur) break; MP_TARRAY_APPEND(NULL, list, num, talloc_strdup(NULL, cur->name)); -- cgit v1.2.3