diff options
author | wm4 <wm4@nowhere> | 2018-02-12 19:28:30 +0100 |
---|---|---|
committer | Kevin Mitchell <kevmitch@gmail.com> | 2018-02-13 17:45:29 -0800 |
commit | 706bb1d0c756be95e8646c6e433d5d24f7c75dca (patch) | |
tree | 6cbb460e04f4b394fc65cce2a17bbde6ae80e3ec /common/av_common.c | |
parent | 3ffa70e2da121b1924f3fb74b0de0787184de237 (diff) | |
download | mpv-706bb1d0c756be95e8646c6e433d5d24f7c75dca.tar.bz2 mpv-706bb1d0c756be95e8646c6e433d5d24f7c75dca.tar.xz |
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.
Diffstat (limited to 'common/av_common.c')
-rw-r--r-- | common/av_common.c | 33 |
1 files changed, 17 insertions, 16 deletions
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)); |