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...


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@14844 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
rfelker 2005-02-27 18:11:17 +00:00
parent 0fc2c5de81
commit 4eb1b755bb
3 changed files with 19 additions and 16 deletions

View File

@ -200,7 +200,6 @@ videocodec theora
info "Theora (free, reworked VP3)"
status working
fourcc theo,Thra
format 0xFFFC
driver theora
dll libtheora
out YV12
@ -2173,6 +2172,7 @@ audiocodec pcm
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 @@ audiocodec vorbis
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

View File

@ -1823,7 +1823,7 @@ demux_mkv_open_audio (demuxer_t *demuxer, mkv_track_t *track)
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 @@ demux_mkv_open_audio (demuxer_t *demuxer, mkv_track_t *track)
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++)
{

View File

@ -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 @@ static int demux_ogg_add_packet(demux_stream_t* ds,ogg_stream_t* os,int id,ogg_p
// 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 @@ void demux_ogg_scan_stream(demuxer_t* demuxer) {
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 @@ int demux_ogg_open(demuxer_t* demuxer) {
// 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 @@ int demux_ogg_open(demuxer_t* demuxer) {
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 @@ int demux_ogg_open(demuxer_t* demuxer) {
}
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 @@ demuxer_t* init_avi_with_ogg(demuxer_t* demuxer) {
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 @@ void demux_ogg_seek(demuxer_t *demuxer,float rel_seek_secs,int flags) {
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;