changeset 34636:fde1a35cf043

Simplify codec id <-> tag mapping using avformat_get_riff_*_tags. This also ensures that again only audio mappings will be used for audio and video mappings for video. This fixes bug #2038. Based on patch by Andrew Wason [rectalogic rectalogic com].
author reimar
date Tue, 14 Feb 2012 19:22:22 +0000
parents 7e0f50b4921c
children 9a109f995b4c
files configure libmpdemux/mp_taglists.c
diffstat 2 files changed, 12 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/configure	Tue Feb 14 17:06:09 2012 +0000
+++ b/configure	Tue Feb 14 19:22:22 2012 +0000
@@ -7068,8 +7068,6 @@
 if test "$_mencoder" = no ; then
   # mpeg1video for vf_lavc, snow for vf_uspp / vf_mcdeint,
   libavencoders="$mplayer_encoders MPEG1VIDEO_ENCODER SNOW_ENCODER"
-  # needed for codec id -> tag conversion
-  libavmuxers="AVI_MUXER"
 fi
 echores "$_mencoder"
 
--- a/libmpdemux/mp_taglists.c	Tue Feb 14 17:06:09 2012 +0000
+++ b/libmpdemux/mp_taglists.c	Tue Feb 14 19:22:22 2012 +0000
@@ -72,8 +72,6 @@
     { 0, 0 },
 };
 
-static const struct AVCodecTag * const mp_wav_taglists[] = {mp_wav_tags, 0};
-
 static const struct AVCodecTag mp_codecid_override_tags[] = {
     { CODEC_ID_8SVX_EXP,          MKTAG('8', 'e', 'x', 'p')},
     { CODEC_ID_8SVX_FIB,          MKTAG('8', 'f', 'i', 'b')},
@@ -157,25 +155,23 @@
     { 0, 0 },
 };
 
-static const struct AVCodecTag * const mp_bmp_taglists[] = {mp_bmp_tags, 0};
+static void get_taglists(const struct AVCodecTag *dst[3], int audio)
+{
+    dst[0] = audio ? mp_wav_tags : mp_bmp_tags;
+    dst[1] = audio ? avformat_get_riff_audio_tags() : avformat_get_riff_video_tags();
+    dst[2] = NULL;
+}
 
 enum CodecID mp_tag2codec_id(uint32_t tag, int audio)
 {
-    AVOutputFormat *avi_format;
-    enum CodecID id = av_codec_get_id(audio ? mp_wav_taglists : mp_bmp_taglists, tag);
-    if (id != CODEC_ID_NONE)
-        return id;
-    avi_format = av_guess_format("avi", NULL, NULL);
-    if (!avi_format) {
-        mp_msg(MSGT_DEMUXER, MSGL_FATAL, "MPlayer cannot work properly without AVI muxer in libavformat!\n");
-        return 0;
-    }
-    return av_codec_get_id(avi_format->codec_tag, tag);
+    const struct AVCodecTag *taglists[3];
+    get_taglists(taglists, audio);
+    return av_codec_get_id(taglists, tag);
 }
 
 uint32_t mp_codec_id2tag(enum CodecID codec_id, uint32_t old_tag, int audio)
 {
-    AVOutputFormat *avi_format;
+    const struct AVCodecTag *taglists[3];
     // For some formats (like PCM) always trust CODEC_ID_* more than codec_tag
     uint32_t tag = av_codec_get_tag(mp_codecid_override_taglists, codec_id);
     if (tag)
@@ -189,14 +185,6 @@
     if (tag)
         return tag;
 
-    tag = av_codec_get_tag(audio ? mp_wav_taglists : mp_bmp_taglists, codec_id);
-    if (tag)
-        return tag;
-
-    avi_format = av_guess_format("avi", NULL, NULL);
-    if (!avi_format) {
-        mp_msg(MSGT_DEMUXER, MSGL_FATAL, "MPlayer cannot work properly without AVI muxer in libavformat!\n");
-        return 0;
-    }
-    return av_codec_get_tag(avi_format->codec_tag, codec_id);
+    get_taglists(taglists, audio);
+    return av_codec_get_tag(taglists, codec_id);
 }