changeset 22336:760c74c078ce

copy the content of QDM2 atom as extradata for ffqdm2 playback; patch by Carl Eugen Hoyos
author nicodvb
date Mon, 26 Feb 2007 21:54:52 +0000
parents 2f43fee89f0e
children d79bd226342d
files libmpdemux/demux_rtp_codec.cpp
diffstat 1 files changed, 19 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_rtp_codec.cpp	Mon Feb 26 19:08:29 2007 +0000
+++ b/libmpdemux/demux_rtp_codec.cpp	Mon Feb 26 21:54:52 2007 +0000
@@ -238,6 +238,25 @@
 
     wf->wFormatTag = sh_audio->format = fourcc;
     wf->nChannels = numChannels;
+
+    uint8_t *pos = (uint8_t*)qtRTPSource->qtState.sdAtom + 52;
+    uint8_t *endpos = (uint8_t*)qtRTPSource->qtState.sdAtom
+                      + qtRTPSource->qtState.sdAtomSize;
+    while (pos+8 < endpos) {
+      unsigned atomLength = pos[0]<<24 | pos[1]<<16 | pos[2]<<8 | pos[3];
+      if (atomLength == 0 || atomLength > endpos-pos) break;
+      if (!memcmp(pos+4, "wave", 4) && fourcc==mmioFOURCC('Q','D','M','2') &&
+          atomLength > 8 &&
+          atomLength <= INT_MAX) {
+        sh_audio->codecdata = (unsigned char*) malloc(atomLength-8);
+        if (sh_audio->codecdata) {
+          memcpy(sh_audio->codecdata, pos+8, atomLength-8);
+          sh_audio->codecdata_len = atomLength-8;
+        }
+        break;
+      }
+      pos += atomLength;
+    }
   } else {
     fprintf(stderr,
 	    "Unknown MPlayer format code for MIME type \"audio/%s\"\n",