[MPlayer-dev-eng] [PATCH] taglists: try to convert codec_id to tag.

Nicolas George nicolas.george at normalesup.org
Mon Jan 2 21:31:33 CET 2012


FFmpeg has recently started to use fourccs as codec_id values. This patch
tries, if everything else has failed, to detect them (by checking that all
four bytes are likely ASCII characters) and use them.

It allows to remove FFWAVESYNTH from the hardcoded list.
Other may possibly also be removed.
---


I tried to remove CODEC_ID_ESCAPE130 too, but it seems that the test:
// mp4a tag is used for all mp4 files no matter what they actually contain
is producing a bad result. As I do not really understand what it does, I
leave it alone for now.

Regards,

-- 
  Nicolas George


 libmpdemux/mp_taglists.c |   25 +++++++++++++++++++++++--
 1 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/libmpdemux/mp_taglists.c b/libmpdemux/mp_taglists.c
index a7a1c7b..7381432 100644
--- a/libmpdemux/mp_taglists.c
+++ b/libmpdemux/mp_taglists.c
@@ -43,7 +43,6 @@ static const struct AVCodecTag mp_wav_tags[] = {
     { CODEC_ID_COOK,              MKTAG('c', 'o', 'o', 'k')},
     { CODEC_ID_DSICINAUDIO,       MKTAG('D', 'C', 'I', 'A')},
     { CODEC_ID_EAC3,              MKTAG('E', 'A', 'C', '3')},
-    { CODEC_ID_FFWAVESYNTH,       MKTAG('F', 'F', 'W', 'S')},
     { CODEC_ID_G723_1,            MKTAG('7', '2', '3', '1')},
     { CODEC_ID_INTERPLAY_DPCM,    MKTAG('I', 'N', 'P', 'A')},
     { CODEC_ID_MLP,               MKTAG('M', 'L', 'P', ' ')},
@@ -169,6 +168,25 @@ enum CodecID mp_tag2codec_id(uint32_t tag, int audio)
     return av_codec_get_id(avi_format->codec_tag, tag);
 }
 
+/**
+ * Detect codec_ids that are likely to be the result of MKBETAG.
+ */
+static uint32_t fourcc_codec_id_to_tag(uint32_t id)
+{
+    int i, c;
+    uint32_t r = 0;
+
+    for (i = 0; i < 4; i++) {
+        c = id & 0xFF;
+        if (!(c == ' ' || (c >= '0' && c <= '9') || (c >= 'A' && c <= 'Z') ||
+              (c >= 'a' && c <= 'z')))
+            return 0;
+        id >>= 8;
+        r = (r << 8) | c;
+    }
+    return r;
+}
+
 uint32_t mp_codec_id2tag(enum CodecID codec_id, uint32_t old_tag, int audio)
 {
     AVOutputFormat *avi_format;
@@ -194,5 +212,8 @@ uint32_t mp_codec_id2tag(enum CodecID codec_id, uint32_t old_tag, int audio)
         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);
+    tag = av_codec_get_tag(avi_format->codec_tag, codec_id);
+    if (tag)
+        return tag;
+    return fourcc_codec_id_to_tag(codec_id);
 }
-- 
1.7.2.5



More information about the MPlayer-dev-eng mailing list