diff options
Diffstat (limited to 'libmpdemux/demux_lavf.c')
-rw-r--r-- | libmpdemux/demux_lavf.c | 47 |
1 files changed, 22 insertions, 25 deletions
diff --git a/libmpdemux/demux_lavf.c b/libmpdemux/demux_lavf.c index 4314a96c02..5fb66adb9d 100644 --- a/libmpdemux/demux_lavf.c +++ b/libmpdemux/demux_lavf.c @@ -25,6 +25,13 @@ #include <stdbool.h> #include <string.h> +#include <libavformat/avformat.h> +#include <libavformat/avio.h> +#include <libavutil/avutil.h> +#include <libavutil/avstring.h> +#include <libavutil/mathematics.h> +#include <libavutil/opt.h> + #include "config.h" #include "options.h" #include "mp_msg.h" @@ -38,13 +45,6 @@ #include "m_option.h" #include "sub/sub.h" -#include "libavformat/avformat.h" -#include "libavformat/avio.h" -#include "libavutil/avutil.h" -#include "libavutil/avstring.h" -#include <libavutil/mathematics.h> -#include "libavcodec/opt.h" - #include "mp_taglists.h" #define INITIAL_PROBE_SIZE STREAM_BUFFER_SIZE @@ -109,9 +109,12 @@ static int64_t mp_seek(void *opaque, int64_t pos, int whence) pos += stream->end_pos; else if (whence == SEEK_SET) pos += stream->start_pos; - else if (whence == AVSEEK_SIZE && stream->end_pos > 0) + else if (whence == AVSEEK_SIZE && stream->end_pos > 0) { + off_t size; + if (stream_control(stream, STREAM_CTRL_GET_SIZE, &size) == STREAM_OK) + return size; return stream->end_pos - stream->start_pos; - else + } else return -1; if (pos < 0) @@ -293,8 +296,7 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) if (matches_avinputformat_name(priv, "mpeg") || matches_avinputformat_name(priv, "mpegts")) codec->codec_tag = 0; - int override_tag = mp_av_codec_get_tag(mp_codecid_override_taglists, - codec->codec_id); + int override_tag = mp_taglist_override(codec->codec_id); // For some formats (like PCM) always trust CODEC_ID_* more than codec_tag if (override_tag) codec->codec_tag = override_tag; @@ -313,8 +315,7 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) if (codec->codec_tag == MKTAG('m', 'p', '4', 'a')) codec->codec_tag = 0; if (!codec->codec_tag) - codec->codec_tag = mp_av_codec_get_tag(mp_wav_taglists, - codec->codec_id); + codec->codec_tag = mp_taglist_audio(codec->codec_id); wf->wFormatTag = codec->codec_tag; wf->nChannels = codec->channels; wf->nSamplesPerSec = codec->sample_rate; @@ -399,8 +400,7 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) codec->codec_tag = avcodec_pix_fmt_to_codec_tag(codec->pix_fmt); } if (!codec->codec_tag) - codec->codec_tag = mp_av_codec_get_tag(mp_bmp_taglists, - codec->codec_id); + codec->codec_tag = mp_taglist_video(codec->codec_id); bih->biSize = sizeof(*bih) + codec->extradata_size; bih->biWidth = codec->width; bih->biHeight = codec->height; @@ -534,7 +534,6 @@ static demuxer_t *demux_open_lavf(demuxer_t *demuxer) struct MPOpts *opts = demuxer->opts; struct lavfdopts *lavfdopts = &opts->lavfdopts; AVFormatContext *avfc; - const AVOption *opt; AVDictionaryEntry *t = NULL; lavf_priv_t *priv = demuxer->priv; int i; @@ -559,16 +558,14 @@ static demuxer_t *demux_open_lavf(demuxer_t *demuxer) avfc->flags |= AVFMT_FLAG_IGNIDX; if (lavfdopts->probesize) { - opt = av_set_int(avfc, "probesize", lavfdopts->probesize); - if (!opt) + if (av_opt_set_int(avfc, "probesize", lavfdopts->probesize, 0) < 0) mp_msg(MSGT_HEADER, MSGL_ERR, "demux_lavf, couldn't set option probesize to %u\n", lavfdopts->probesize); } if (lavfdopts->analyzeduration) { - opt = av_set_int(avfc, "analyzeduration", - lavfdopts->analyzeduration * AV_TIME_BASE); - if (!opt) + if (av_opt_set_int(avfc, "analyzeduration", + lavfdopts->analyzeduration * AV_TIME_BASE, 0) < 0) mp_msg(MSGT_HEADER, MSGL_ERR, "demux_lavf, couldn't set option " "analyzeduration to %u\n", lavfdopts->analyzeduration); } @@ -609,7 +606,7 @@ static demuxer_t *demux_open_lavf(demuxer_t *demuxer) priv->avfc = avfc; - if (av_find_stream_info(avfc) < 0) { + if (avformat_find_stream_info(avfc, NULL) < 0) { mp_msg(MSGT_HEADER, MSGL_ERR, "LAVF_header: av_find_stream_info() failed\n"); return NULL; @@ -617,7 +614,7 @@ static demuxer_t *demux_open_lavf(demuxer_t *demuxer) /* Add metadata. */ while ((t = av_dict_get(avfc->metadata, "", t, - AV_METADATA_IGNORE_SUFFIX))) + AV_DICT_IGNORE_SUFFIX))) demux_info_add(demuxer, t->key, t->value); for (i = 0; i < avfc->nb_chapters; i++) { @@ -708,7 +705,7 @@ static void check_internet_radio_hack(struct demuxer *demuxer) AVDictionaryEntry *t = NULL; AVStream *stream = avfc->streams[avfc->nb_streams - 1]; while ((t = av_dict_get(stream->metadata, "", t, - AV_METADATA_IGNORE_SUFFIX))) + AV_DICT_IGNORE_SUFFIX))) demux_info_add(demuxer, t->key, t->value); } else { if (priv->internet_radio_hack) @@ -995,7 +992,7 @@ static void demux_close_lavf(demuxer_t *demuxer) if (priv) { if (priv->avfc) { av_freep(&priv->avfc->key); - av_close_input_file(priv->avfc); + avformat_close_input(&priv->avfc); } av_freep(&priv->pb); free(priv); |