summaryrefslogtreecommitdiffstats
path: root/libmpdemux
diff options
context:
space:
mode:
authorUoti Urpala <uau@mplayer2.org>2012-02-01 18:34:51 +0200
committerUoti Urpala <uau@mplayer2.org>2012-02-01 22:46:27 +0200
commitcdb6d157ccb2d311afb72b7cbf128c3866e85ec6 (patch)
tree94dfc8f8a2fc895d796657ea74e995fb33687ca5 /libmpdemux
parentdb8cdc73e38c3490389212d94ae9b92dfddd5975 (diff)
downloadmpv-cdb6d157ccb2d311afb72b7cbf128c3866e85ec6.tar.bz2
mpv-cdb6d157ccb2d311afb72b7cbf128c3866e85ec6.tar.xz
demux_lavf: use Libav RIFF tag lists directly
Change demux_lavf to use CodecID -> RIFF tag mappings that are now available through the public Libav API. Previously it used a copy in ffmpeg_files/taglists.c. That can now be deleted.
Diffstat (limited to 'libmpdemux')
-rw-r--r--libmpdemux/demux_lavf.c9
-rw-r--r--libmpdemux/mp_taglists.c54
-rw-r--r--libmpdemux/mp_taglists.h10
3 files changed, 47 insertions, 26 deletions
diff --git a/libmpdemux/demux_lavf.c b/libmpdemux/demux_lavf.c
index cf17664aab..02eff0d4b8 100644
--- a/libmpdemux/demux_lavf.c
+++ b/libmpdemux/demux_lavf.c
@@ -293,8 +293,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 +312,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 +397,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;
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 */