[Mplayer-cvslog] CVS: main/libmpdemux demux_mkv.cpp,1.48,1.49

Moritz Bunkus CVS mosu at mplayerhq.hu
Sun Nov 16 21:05:31 CET 2003


Update of /cvsroot/mplayer/main/libmpdemux
In directory mail:/var/tmp.root/cvs-serv31729

Modified Files:
	demux_mkv.cpp 
Log Message:
Support for FLAC tracks that already contain the "fLaC" header.

Index: demux_mkv.cpp
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_mkv.cpp,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -r1.48 -r1.49
--- demux_mkv.cpp	16 Nov 2003 19:24:43 -0000	1.48
+++ demux_mkv.cpp	16 Nov 2003 20:05:09 -0000	1.49
@@ -2357,24 +2357,29 @@
 
     } else if (!strcmp(track->codec_id, MKV_A_FLAC) ||
                (track->a_formattag == 0xf1ac)) {
+      unsigned char *ptr;
+      int size;
       free(sh_a->wf);
       sh_a->wf = NULL;
 
-      dp = new_demux_packet(4);
-      memcpy(dp->buffer, "fLaC", 4);
-      dp->pts = 0;
-      dp->flags = 0;
-      ds_add_packet(demuxer->audio, dp);
       if (track->a_formattag == mmioFOURCC('f', 'L', 'a', 'C')) {
-        dp = new_demux_packet(track->private_size);
-        memcpy(dp->buffer, track->private_data, track->private_size);
+        ptr = (unsigned char *)track->private_data;
+        size = track->private_size;
       } else {
         sh_a->format = mmioFOURCC('f', 'L', 'a', 'C');
-        dp = new_demux_packet(track->private_size - sizeof(WAVEFORMATEX));
-        memcpy(dp->buffer, (unsigned char *)track->private_data +
-               sizeof(WAVEFORMATEX), track->private_size -
-               sizeof(WAVEFORMATEX));
+        ptr = (unsigned char *)track->private_data + sizeof(WAVEFORMATEX);
+        size = track->private_size - sizeof(WAVEFORMATEX);
       }
+      if ((size < 4) || (ptr[0] != 'f') || (ptr[1] != 'L') ||
+          (ptr[2] != 'a') || (ptr[3] != 'C')) {
+        dp = new_demux_packet(4);
+        memcpy(dp->buffer, "fLaC", 4);
+        dp->pts = 0;
+        dp->flags = 0;
+        ds_add_packet(demuxer->audio, dp);
+      }
+      dp = new_demux_packet(size);
+      memcpy(dp->buffer, ptr, size);
       dp->pts = 0;
       dp->flags = 0;
       ds_add_packet(demuxer->audio, dp);



More information about the MPlayer-cvslog mailing list