changeset 20489:4419e00b54df

Support new flac-in-ogg, fixes bug #229
author reimar
date Sun, 29 Oct 2006 11:05:49 +0000
parents f485fb548bf3
children eed38650b528
files libmpdemux/demux_ogg.c
diffstat 1 files changed, 15 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_ogg.c	Sun Oct 29 11:00:36 2006 +0000
+++ b/libmpdemux/demux_ogg.c	Sun Oct 29 11:05:49 2006 +0000
@@ -393,6 +393,8 @@
 #endif /* HAVE_OGGTHEORA */
   } else if (os->flac) {
      /* we pass complete packets to flac, mustn't strip the header! */
+     if (os->flac == 2 && pack->packet[0] != 0xff)
+       return NULL;
   } else {
     if(*pack->packet & PACKET_TYPE_HEADER)
       os->hdr_packets++;
@@ -565,6 +567,8 @@
   if (ds == d->video && ((sh_audio_t*)ds->sh)->format == FOURCC_THEORA)
      context = ((sh_video_t *)ds->sh)->context;
   data = demux_ogg_read_packet(os,pack,context,&pts,&flags,samplesize);
+  if (!data)
+    return 0;
 
   /// Clear subtitles if necessary (for broken files)
   if ((clear_sub > 0) && (pts >= clear_sub)) {
@@ -1009,6 +1013,17 @@
 	ogg_d->subs[ogg_d->num_sub].flac = 1;
 	sh_a->wf = NULL;
 	mp_msg(MSGT_DEMUX,MSGL_INFO,"[Ogg] stream %d: audio (FLAC), -aid %d\n",ogg_d->num_sub,n_audio-1);
+    } else if (pack.bytes >= 51 && !strncmp(&pack.packet[1], "FLAC", 4)) {
+	sh_a = new_sh_audio_aid(demuxer,ogg_d->num_sub, n_audio);
+	sh_a->format =  mmioFOURCC('f', 'L', 'a', 'C');
+	ogg_d->subs[ogg_d->num_sub].id = n_audio;
+	n_audio++;
+	ogg_d->subs[ogg_d->num_sub].flac = 2;
+	sh_a->wf = calloc(1, sizeof(WAVEFORMATEX) + 34);
+	sh_a->wf->wFormatTag = sh_a->format;
+	sh_a->wf->cbSize = 34;
+	memcpy(&sh_a->wf[1], &pack.packet[17], 34);
+	mp_msg(MSGT_DEMUX,MSGL_INFO,"[Ogg] stream %d: audio (FLAC, try 2), -aid %d\n",ogg_d->num_sub,n_audio-1);
 
       /// Check for old header
     } else if(pack.bytes >= 142 && ! strncmp(&pack.packet[1],"Direct Show Samples embedded in Ogg",35) ) {