changeset 14843:bbb693d3b130

Fix the ogg fourcc nightmare!!! The problem: once upon a time, windows idiots decided to try to store vorbis-in-ogg-in-avi. Of course this failed miserably, but they used the audio format tag 0xfffe for "extended" to do this. Later someone working on MPlayer somehow decided 0xfffe was the format for vorbis, which is nonsense, and now that's conflicting with real wav files with extended audio format. This patch changes demux_ogg (and mkv) to use sane fourcc's for vorbis and theora and gets rid of the 0xfffe nonsense so hopefully wav files with extended audio will work now. If there are problems, we'll have to find workarounds...and drive an 18-wheeler full of cola thru the house of whoever wrote this 0xfffe nonsense in MPlayer to begin with...
author rfelker
date Sun, 27 Feb 2005 18:11:17 +0000
parents 31ab04004943
children 35d160ed656a
files etc/codecs.conf libmpdemux/demux_mkv.c libmpdemux/demux_ogg.c
diffstat 3 files changed, 19 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/etc/codecs.conf	Sun Feb 27 14:42:40 2005 +0000
+++ b/etc/codecs.conf	Sun Feb 27 18:11:17 2005 +0000
@@ -200,7 +200,6 @@
   info "Theora (free, reworked VP3)"
   status working
   fourcc theo,Thra
-  format 0xFFFC
   driver theora
   dll libtheora
   out YV12
@@ -2173,6 +2172,7 @@
   format 0x0
   format 0x1
   format 0x3         ; IEEE float
+  format 0xfffe      ; Extended
   format 0x20776172  ; "raw " (MOV files)
   format 0x736f7774  ; "twos" (MOV files)
   format 0x74776f73  ; "sowt" (MOV files)
@@ -2479,7 +2479,7 @@
   info "OggVorbis Audio Decoder"
   status working
   comment "OggVorbis driver using libvorbis"
-  format 0xFFFE
+  fourcc vrbs
   driver libvorbis
   dll "libvorbis"
 ; acm codec doesn't work, haven't tried zorannt dshow codec
--- a/libmpdemux/demux_mkv.c	Sun Feb 27 14:42:40 2005 +0000
+++ b/libmpdemux/demux_mkv.c	Sun Feb 27 18:11:17 2005 +0000
@@ -1823,7 +1823,7 @@
           track->header_sizes[2] = track->private_size - offset
             - track->header_sizes[0] - track->header_sizes[1];
 
-          track->a_formattag = 0xFFFE;
+          track->a_formattag = mmioFOURCC('v', 'r', 'b', 's');
         }
       else if (!strcmp(track->codec_id, MKV_A_QDMC))
         track->a_formattag = mmioFOURCC('Q', 'D', 'M', 'C');
@@ -1952,7 +1952,7 @@
           track->default_duration = 1024.0 / (float)sh_a->samplerate;
         }
     }
-  else if (track->a_formattag == 0xFFFE)  /* VORBIS */
+  else if (track->a_formattag == mmioFOURCC('v', 'r', 'b', 's'))  /* VORBIS */
     {
       for (i=0; i < 3; i++)
         {
--- a/libmpdemux/demux_ogg.c	Sun Feb 27 14:42:40 2005 +0000
+++ b/libmpdemux/demux_ogg.c	Sun Feb 27 18:11:17 2005 +0000
@@ -15,6 +15,9 @@
 #include "demuxer.h"
 #include "stheader.h"
 
+#define FOURCC_VORBIS mmioFOURCC('v', 'r', 'b', 's')
+#define FOURCC_THEORA mmioFOURCC('t', 'h', 'e', 'o')
+
 #ifdef TREMOR
 #include <tremor/ogg.h>
 #include <tremor/ivorbiscodec.h>
@@ -527,17 +530,17 @@
   // We jump nothing for FLAC. Ain't this great? Packet contents have to be
   // handled differently for each and every stream type. The joy! The joy!
   if(!os->flac && ((*pack->packet & PACKET_TYPE_HEADER) && 
-     (ds != d->audio || ( ((sh_audio_t*)ds->sh)->format != 0xFFFE || os->hdr_packets >= NUM_VORBIS_HDR_PACKETS ) ) &&
-     (ds != d->video || (((sh_video_t*)ds->sh)->format != 0xFFFC))))
+     (ds != d->audio || ( ((sh_audio_t*)ds->sh)->format != FOURCC_VORBIS || os->hdr_packets >= NUM_VORBIS_HDR_PACKETS ) ) &&
+     (ds != d->video || (((sh_video_t*)ds->sh)->format != FOURCC_THEORA))))
     return 0;
 
   // For vorbis packet the packet is the data, for other codec we must jump
   // the header
-  if(ds == d->audio && ((sh_audio_t*)ds->sh)->format == 0xFFFE) {
+  if(ds == d->audio && ((sh_audio_t*)ds->sh)->format == FOURCC_VORBIS) {
      context = ((sh_audio_t *)ds->sh)->context;
      samplesize = ((sh_audio_t *)ds->sh)->samplesize;
   }
-  if (ds == d->video && ((sh_audio_t*)ds->sh)->format == 0xFFFC)
+  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(d->video->id < 0)
@@ -589,13 +592,13 @@
   if(demuxer->video->id >= 0) {
     sid = demuxer->video->id;
     /* demux_ogg_read_packet needs decoder context for Theora streams */
-    if (((sh_video_t*)demuxer->video->sh)->format == 0xFFFC)
+    if (((sh_video_t*)demuxer->video->sh)->format == FOURCC_THEORA)
       context = ((sh_video_t*)demuxer->video->sh)->context;
   }
   else {
     sid = demuxer->audio->id;
     /* demux_ogg_read_packet needs decoder context for Vorbis streams */
-    if(((sh_audio_t*)demuxer->audio->sh)->format == 0xFFFE) {
+    if(((sh_audio_t*)demuxer->audio->sh)->format == FOURCC_VORBIS) {
       context = ((sh_audio_t*)demuxer->audio->sh)->context;
       samplesize = ((sh_audio_t*)demuxer->audio->sh)->samplesize;
     }
@@ -813,7 +816,7 @@
     // Check for Vorbis
     if(pack.bytes >= 7 && ! strncmp(&pack.packet[1],"vorbis", 6) ) {
       sh_a = new_sh_audio(demuxer,ogg_d->num_sub);
-      sh_a->format = 0xFFFE;
+      sh_a->format = FOURCC_VORBIS;
       ogg_d->subs[ogg_d->num_sub].vorbis = 1;
       if (identify)
         mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_AUDIO_ID=%d\n", n_audio);
@@ -842,7 +845,7 @@
 	    sh_v->context = NULL;
 	    sh_v->bih = (BITMAPINFOHEADER*)calloc(1,sizeof(BITMAPINFOHEADER));
 	    sh_v->bih->biSize=sizeof(BITMAPINFOHEADER);
-	    sh_v->bih->biCompression= sh_v->format = 0xFFFC;
+	    sh_v->bih->biCompression= sh_v->format = FOURCC_THEORA;
 	    sh_v->fps = ((double)inf.fps_numerator)/
 		(double)inf.fps_denominator;
 	    sh_v->frametime = ((double)inf.fps_denominator)/
@@ -1092,7 +1095,7 @@
   }
 
   mp_msg(MSGT_DEMUX,MSGL_V,"Ogg demuxer : found %d audio stream%s, %d video stream%s and %d text stream%s\n",n_audio,n_audio>1?"s":"",n_video,n_video>1?"s":"",ogg_d->n_text,ogg_d->n_text>1?"s":"");
- 
+
   return 1;
 
 err_out:
@@ -1267,7 +1270,7 @@
   od->video->id = -2;
   od->audio->sh = sh_audio;
   sh_audio->ds = od->audio;
-  sh_audio->format = 0xFFFE;
+  sh_audio->format = FOURCC_VORBIS;
 
   /// Return the joined demuxers
   return new_demuxers_demuxer(demuxer,od,demuxer);
@@ -1304,13 +1307,13 @@
   if(demuxer->video->id >= 0) {
     ds = demuxer->video;
     /* demux_ogg_read_packet needs decoder context for Theora streams */
-    if (((sh_video_t*)demuxer->video->sh)->format == 0xFFFC)
+    if (((sh_video_t*)demuxer->video->sh)->format == FOURCC_THEORA)
       context = ((sh_video_t*)demuxer->video->sh)->context;
     rate = ogg_d->subs[ds->id].samplerate;
   } else {
     ds = demuxer->audio;
     /* demux_ogg_read_packet needs decoder context for Vorbis streams */
-    if(((sh_audio_t*)demuxer->audio->sh)->format == 0xFFFE)
+    if(((sh_audio_t*)demuxer->audio->sh)->format == FOURCC_VORBIS)
       context = ((sh_audio_t*)demuxer->audio->sh)->context;
     vi = &((ov_struct_t*)((sh_audio_t*)ds->sh)->context)->vi;
     rate = (float)vi->rate;