diff options
Diffstat (limited to 'libmpdemux')
-rw-r--r-- | libmpdemux/asfheader.c | 5 | ||||
-rw-r--r-- | libmpdemux/aviheader.c | 6 | ||||
-rw-r--r-- | libmpdemux/demux_asf.c | 3 | ||||
-rw-r--r-- | libmpdemux/demux_audio.c | 11 | ||||
-rw-r--r-- | libmpdemux/demux_lavf.c | 47 | ||||
-rw-r--r-- | libmpdemux/demux_mkv.c | 22 | ||||
-rw-r--r-- | libmpdemux/demux_mov.c | 21 | ||||
-rw-r--r-- | libmpdemux/demux_ogg.c | 3 | ||||
-rw-r--r-- | libmpdemux/demux_real.c | 5 | ||||
-rw-r--r-- | libmpdemux/demux_rtp_codec.cpp | 2 | ||||
-rw-r--r-- | libmpdemux/demux_ty.c | 5 | ||||
-rw-r--r-- | libmpdemux/demux_vqf.c | 5 | ||||
-rw-r--r-- | libmpdemux/demuxer.c | 2 | ||||
-rw-r--r-- | libmpdemux/ebml.c | 10 | ||||
-rw-r--r-- | libmpdemux/mp_taglists.c | 54 | ||||
-rw-r--r-- | libmpdemux/mp_taglists.h | 10 |
16 files changed, 120 insertions, 91 deletions
diff --git a/libmpdemux/asfheader.c b/libmpdemux/asfheader.c index 857a899bef..bd775b7660 100644 --- a/libmpdemux/asfheader.c +++ b/libmpdemux/asfheader.c @@ -22,9 +22,10 @@ #include <stdlib.h> #include <unistd.h> +#include <libavutil/intreadwrite.h> +#include <libavutil/common.h> + #include "config.h" -#include "libavutil/common.h" -#include "ffmpeg_files/intreadwrite.h" #include "mp_msg.h" #include "stream/stream.h" diff --git a/libmpdemux/aviheader.c b/libmpdemux/aviheader.c index 3f18af28f8..1b0683339e 100644 --- a/libmpdemux/aviheader.c +++ b/libmpdemux/aviheader.c @@ -21,6 +21,9 @@ #include <unistd.h> #include <errno.h> +#include <libavutil/common.h> +#include <libavutil/intreadwrite.h> + #include "config.h" #include "mp_msg.h" @@ -29,7 +32,6 @@ #include "stheader.h" #include "aviprint.h" #include "aviheader.h" -#include "libavutil/common.h" static MainAVIHeader avih; @@ -232,7 +234,7 @@ while(1){ s->bIndexSubType = stream_read_char(demuxer->stream); s->bIndexType = stream_read_char(demuxer->stream); s->nEntriesInUse = stream_read_dword_le(demuxer->stream); - *(uint32_t *)s->dwChunkId = stream_read_dword_le(demuxer->stream); + AV_WN32(s->dwChunkId, stream_read_dword_le(demuxer->stream)); stream_read(demuxer->stream, (char *)s->dwReserved, 3*4); memset(s->dwReserved, 0, 3*4); diff --git a/libmpdemux/demux_asf.c b/libmpdemux/demux_asf.c index c10fd3e14b..eb71d4ef96 100644 --- a/libmpdemux/demux_asf.c +++ b/libmpdemux/demux_asf.c @@ -24,6 +24,8 @@ #include <unistd.h> #include <limits.h> +#include <libavutil/intreadwrite.h> + #include "config.h" #include "mp_msg.h" @@ -33,7 +35,6 @@ #include "demuxer.h" #include "libmpcodecs/dec_audio.h" #include "libvo/fastmemcpy.h" -#include "ffmpeg_files/intreadwrite.h" // based on asf file-format doc by Eugene [http://divx.euro.ru] diff --git a/libmpdemux/demux_audio.c b/libmpdemux/demux_audio.c index 815d3aec9c..bc14b530c1 100644 --- a/libmpdemux/demux_audio.c +++ b/libmpdemux/demux_audio.c @@ -16,21 +16,22 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include <stdlib.h> +#include <stdio.h> +#include <string.h> + +#include <libavutil/intreadwrite.h> + #include "config.h" #include "options.h" #include "mp_msg.h" -#include <stdlib.h> -#include <stdio.h> #include "stream/stream.h" #include "aviprint.h" #include "demuxer.h" #include "stheader.h" #include "genres.h" #include "mp3_hdr.h" -#include "ffmpeg_files/intreadwrite.h" - -#include <string.h> #define MP3 1 #define WAV 2 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); diff --git a/libmpdemux/demux_mkv.c b/libmpdemux/demux_mkv.c index 00990f50d4..27bc45acc9 100644 --- a/libmpdemux/demux_mkv.c +++ b/libmpdemux/demux_mkv.c @@ -21,14 +21,23 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "config.h" - #include <stdlib.h> #include <stdio.h> #include <ctype.h> #include <inttypes.h> #include <stdbool.h> +#include <libavutil/common.h> +#include <libavutil/lzo.h> +#include <libavutil/intreadwrite.h> +#include <libavutil/avstring.h> + +#include "config.h" + +#if CONFIG_ZLIB +#include <zlib.h> +#endif + #include "talloc.h" #include "options.h" #include "bstr.h" @@ -43,20 +52,11 @@ #include "sub/sub.h" -#include "libavutil/common.h" #ifdef CONFIG_QTX_CODECS #include "loader/qtx/qtxsdk/components.h" #endif -#if CONFIG_ZLIB -#include <zlib.h> -#endif - -#include "libavutil/lzo.h" -#include "ffmpeg_files/intreadwrite.h" -#include "libavutil/avstring.h" - static const unsigned char sipr_swaps[38][2] = { {0,63},{1,22},{2,44},{3,90},{5,81},{7,31},{8,86},{9,58},{10,36},{12,68}, {13,39},{14,73},{15,53},{16,69},{17,57},{19,88},{20,34},{21,71},{24,46}, diff --git a/libmpdemux/demux_mov.c b/libmpdemux/demux_mov.c index 521b499ff6..bccf808465 100644 --- a/libmpdemux/demux_mov.c +++ b/libmpdemux/demux_mov.c @@ -44,6 +44,9 @@ #include <unistd.h> #include <inttypes.h> +#include <libavutil/common.h> +#include <libavutil/intreadwrite.h> + #include "config.h" #ifdef CONFIG_QUICKTIME @@ -54,6 +57,14 @@ #include "loader/qtx/qtxsdk/components.h" #endif +#if CONFIG_ZLIB +#include <zlib.h> +#endif + +#ifndef _FCNTL_H +#include <fcntl.h> +#endif + #include "mp_msg.h" #include "stream/stream.h" @@ -61,8 +72,6 @@ #include "stheader.h" #include "libmpcodecs/img_format.h" -#include "libavutil/common.h" -#include "ffmpeg_files/intreadwrite.h" #include "sub/sub.h" @@ -70,14 +79,6 @@ #include "qtpalette.h" #include "parse_mp4.h" // .MP4 specific stuff -#if CONFIG_ZLIB -#include <zlib.h> -#endif - -#ifndef _FCNTL_H -#include <fcntl.h> -#endif - #define char2short(x,y) AV_RB16(&(x)[(y)]) #define char2int(x,y) AV_RB32(&(x)[(y)]) diff --git a/libmpdemux/demux_ogg.c b/libmpdemux/demux_ogg.c index 61828fd9d7..d38d68cb79 100644 --- a/libmpdemux/demux_ogg.c +++ b/libmpdemux/demux_ogg.c @@ -25,13 +25,14 @@ #include <math.h> #include <inttypes.h> +#include <libavutil/intreadwrite.h> + #include "options.h" #include "mp_msg.h" #include "talloc.h" #include "stream/stream.h" #include "demuxer.h" #include "stheader.h" -#include "ffmpeg_files/intreadwrite.h" #include "aviprint.h" #include "demux_mov.h" #include "demux_ogg.h" diff --git a/libmpdemux/demux_real.c b/libmpdemux/demux_real.c index d68dfb2b8e..687441f863 100644 --- a/libmpdemux/demux_real.c +++ b/libmpdemux/demux_real.c @@ -39,11 +39,12 @@ #include <unistd.h> #include <inttypes.h> +#include <libavutil/intreadwrite.h> +#include <libavutil/common.h> + #include "config.h" #include "mp_msg.h" #include "mpbswap.h" -#include "libavutil/common.h" -#include "ffmpeg_files/intreadwrite.h" #include "stream/stream.h" #include "aviprint.h" #include "demuxer.h" diff --git a/libmpdemux/demux_rtp_codec.cpp b/libmpdemux/demux_rtp_codec.cpp index 28fb51e96e..cb21e6b633 100644 --- a/libmpdemux/demux_rtp_codec.cpp +++ b/libmpdemux/demux_rtp_codec.cpp @@ -135,7 +135,7 @@ void rtpCodecInitialize_video(demuxer_t* demuxer, int fooLen; const uint8_t* fooData; h264parserctx = av_parser_init(CODEC_ID_H264); - avcctx = avcodec_alloc_context(); + avcctx = avcodec_alloc_context3(NULL); // Pass the config to the parser h264parserctx->parser->parser_parse(h264parserctx, avcctx, &fooData, &fooLen, configData, configLen); diff --git a/libmpdemux/demux_ty.c b/libmpdemux/demux_ty.c index f81ea3d57b..7664eddc98 100644 --- a/libmpdemux/demux_ty.c +++ b/libmpdemux/demux_ty.c @@ -35,6 +35,9 @@ #include <time.h> #include <stdarg.h> +#include <libavutil/avstring.h> +#include <libavutil/intreadwrite.h> + #include "config.h" #include "mp_msg.h" @@ -47,8 +50,6 @@ #include "parse_es.h" #include "stheader.h" #include "sub/sub_cc.h" -#include "libavutil/avstring.h" -#include "ffmpeg_files/intreadwrite.h" extern int sub_justify; diff --git a/libmpdemux/demux_vqf.c b/libmpdemux/demux_vqf.c index 8a3cff66b7..051e912339 100644 --- a/libmpdemux/demux_vqf.c +++ b/libmpdemux/demux_vqf.c @@ -20,9 +20,8 @@ #include <stdlib.h> #include <stdio.h> -#include "libavutil/common.h" -#include "ffmpeg_files/intreadwrite.h" -#include "mpbswap.h" +#include <libavutil/common.h> +#include <libavutil/intreadwrite.h> #include "stream/stream.h" #include "demuxer.h" diff --git a/libmpdemux/demuxer.c b/libmpdemux/demuxer.c index 4e39cedb1a..f8309b9f49 100644 --- a/libmpdemux/demuxer.c +++ b/libmpdemux/demuxer.c @@ -549,7 +549,7 @@ static void allocate_parser(AVCodecContext **avctx, AVCodecParserContext **parse break; } if (codec_id != CODEC_ID_NONE) { - *avctx = avcodec_alloc_context(); + *avctx = avcodec_alloc_context3(NULL); if (!*avctx) return; *parser = av_parser_init(codec_id); diff --git a/libmpdemux/ebml.c b/libmpdemux/ebml.c index 28b4a4643a..9bce3b5182 100644 --- a/libmpdemux/ebml.c +++ b/libmpdemux/ebml.c @@ -29,7 +29,7 @@ #include <stddef.h> #include <assert.h> -#include <libavutil/intfloat_readwrite.h> +#include <libavutil/intfloat.h> #include <libavutil/common.h> #include "talloc.h" #include "ebml.h" @@ -191,11 +191,11 @@ double ebml_read_float(stream_t *s, uint64_t *length) len = ebml_read_length(s, &l); switch (len) { case 4: - value = av_int2flt(stream_read_dword(s)); + value = av_int2float(stream_read_dword(s)); break; case 8: - value = av_int2dbl(stream_read_qword(s)); + value = av_int2double(stream_read_qword(s)); break; default: @@ -382,9 +382,9 @@ static double ebml_parse_float(uint8_t *data, int length) assert(length == 4 || length == 8); uint64_t i = ebml_parse_uint(data, length); if (length == 4) - return av_int2flt(i); + return av_int2float(i); else - return av_int2dbl(i); + return av_int2double(i); } diff --git a/libmpdemux/mp_taglists.c b/libmpdemux/mp_taglists.c index c04c700f8a..afd1b971ce 100644 --- a/libmpdemux/mp_taglists.c +++ b/libmpdemux/mp_taglists.c @@ -16,16 +16,17 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "config.h" - -#include "libavformat/avformat.h" -#include <libavcodec/avcodec.h> +#include <libavformat/avformat.h> +#include "config.h" #include "mp_taglists.h" -#include "ffmpeg_files/taglists.c" +struct tag { + enum CodecID id; + unsigned int tag; +}; -static const struct mp_AVCodecTag mp_wav_tags[] = { +static const struct tag mp_wav_tags[] = { { CODEC_ID_ADPCM_4XM, MKTAG('4', 'X', 'M', 'A')}, { CODEC_ID_ADPCM_ADX, MKTAG('S', 'a', 'd', 'x')}, { CODEC_ID_ADPCM_EA, MKTAG('A', 'D', 'E', 'A')}, @@ -60,9 +61,7 @@ static const struct mp_AVCodecTag mp_wav_tags[] = { { 0, 0 }, }; -const struct mp_AVCodecTag * const mp_wav_taglists[] = {mp_ff_codec_wav_tags, mp_wav_tags, 0}; - -static const struct mp_AVCodecTag mp_codecid_override_tags[] = { +static const struct tag mp_codecid_override_tags[] = { { CODEC_ID_AAC, MKTAG('M', 'P', '4', 'A')}, { CODEC_ID_AAC_LATM, MKTAG('M', 'P', '4', 'L')}, { CODEC_ID_AC3, 0x2000}, @@ -89,9 +88,7 @@ static const struct mp_AVCodecTag mp_codecid_override_tags[] = { { 0, 0 }, }; -const struct mp_AVCodecTag * const mp_codecid_override_taglists[] = {mp_codecid_override_tags, 0}; - -static const struct mp_AVCodecTag mp_bmp_tags[] = { +static const struct tag mp_bmp_tags[] = { { CODEC_ID_AMV, MKTAG('A', 'M', 'V', 'V')}, { CODEC_ID_ANM, MKTAG('A', 'N', 'M', ' ')}, { CODEC_ID_AVS, MKTAG('A', 'V', 'S', ' ')}, @@ -127,4 +124,35 @@ static const struct mp_AVCodecTag mp_bmp_tags[] = { { 0, 0 }, }; -const struct mp_AVCodecTag * const mp_bmp_taglists[] = {mp_ff_codec_bmp_tags, mp_bmp_tags, 0}; +static unsigned int codec_get_tag(const struct tag *tags, enum CodecID id) +{ + while (tags->id != CODEC_ID_NONE) { + if (tags->id == id) + return tags->tag; + tags++; + } + return 0; +} + +unsigned int mp_taglist_override(enum CodecID id) +{ + return codec_get_tag(mp_codecid_override_tags, id); +} + +unsigned int mp_taglist_video(enum CodecID id) +{ + const struct AVCodecTag *tags[] = {avformat_get_riff_video_tags(), NULL }; + unsigned int tag = av_codec_get_tag(tags, id); + if (tag) + return tag; + return codec_get_tag(mp_bmp_tags, id); +} + +unsigned int mp_taglist_audio(enum CodecID id) +{ + const struct AVCodecTag *tags[] = {avformat_get_riff_audio_tags(), NULL }; + unsigned int tag = av_codec_get_tag(tags, id); + if (tag) + return tag; + return codec_get_tag(mp_wav_tags, id); +} diff --git a/libmpdemux/mp_taglists.h b/libmpdemux/mp_taglists.h index 381b77a8db..d23a982a93 100644 --- a/libmpdemux/mp_taglists.h +++ b/libmpdemux/mp_taglists.h @@ -21,12 +21,8 @@ #include <libavcodec/avcodec.h> -#include "ffmpeg_files/taglists.h" - -extern const struct mp_AVCodecTag * const mp_wav_taglists[]; - -extern const struct mp_AVCodecTag * const mp_codecid_override_taglists[]; - -extern const struct mp_AVCodecTag * const mp_bmp_taglists[]; +unsigned int mp_taglist_override(enum CodecID id); +unsigned int mp_taglist_video(enum CodecID id); +unsigned int mp_taglist_audio(enum CodecID id); #endif /* MPLAYER_MP_TAGLISTS_H */ |