sound codec patch
This patch corrects some quirks and errors in the icculus.org/quake3 sound codec and Ogg Vorbis decoder.
The function S_FileExtension() in code/client/snd_codec.c tries to find the
file extension of a file. It did so by starting at the beginning of the filename
and searching to the first '.' . This could lead to problems with relative paths.
It did not because Quake 3 filters out relative paths.
Now the function starts at the end of the filename and searches backwards
to the next '/'.
In function S_FindCodecForFile() in code/client/snd_codec.c when there is no
extension in the filename it tries all available codecs.
For this it copied the filename to a temporary buffer minus the last four chars
for the extension. As there is no extension we must copy the whole string.
In functions S_CodecLoad() and S_CodecOpenStream() in code/client/snd_codec.c
I changed the default behavior. Originally the sound codec tried to load/open the
sound with the exact name given. Now it tries all available codecs to open
a sound file with the same name but an other extension. This allows to recompress
sounds e.g. from WAV to OGG without recompiling the map.
In function S_OGG_CodecReadStream() in code/client/snd_codec_ogg.c I added support
for big endian machines. Up until now the Ogg Vorbis decoder always returned
little endian samples. Now it takes the endianess of the host into acount and returns
big endian samples for big endian machines.
This patch was tested in SuSE Linux 10.1, Windows 2000 with MinGW and MacOS 10.4
on an G4 Mac mini.
> Now the function starts at the end of the filename and searches backwards
> to the next '/'.
That seems fine :)
> Now it tries all available codecs to open
> a sound file with the same name but an other extension. This allows to
> recompress sounds e.g. from WAV to OGG without recompiling the map.
This looks more like a dirty hack than a good feature. ID only did that for original quake3 for image formats, because they realized their game wouldn't fit on a CD if they had all textures in .tga very shortly before it went gold. So they quickly converted the files to .jpg and added a jpeg decoder.
I wouldn't want to have a hack like that included.
> In function S_OGG_CodecReadStream() in code/client/snd_codec_ogg.c I added
> support for big endian machines. Up until now the Ogg Vorbis decoder always
> returned little endian samples. Now it takes the endianess of the host into
> acount and returns big endian samples for big endian machines.
Ok that's probably a good thing to do.
(In reply to comment #2)
> > Now it tries all available codecs to open
> > a sound file with the same name but an other extension. This allows to
> > recompress sounds e.g. from WAV to OGG without recompiling the map.
>
> This looks more like a dirty hack than a good feature. ID only did that for
> original quake3 for image formats, because they realized their game wouldn't
> fit on a CD if they had all textures in .tga very shortly before it went gold.
> So they quickly converted the files to .jpg and added a jpeg decoder.
> I wouldn't want to have a hack like that included.
This is a valid argument. On the other hand we get format independence.
We don't need to care if a sound is a WAV, an OGG or whatever as long
as it is available in any form.
If this feature is not wanted apply the patch and revert the two
functions S_CodecLoad() and S_CodecOpenStream() in code/client/snd_codec.c
to their original state. It is only an one line change.
Setting a QA contact on all ioquake3 bugs, even resolved ones. Sorry if you get a flood of email from this, it should only happen once. Apologies for the incovenience.
--ryan.
Created attachment 919 [details] The patch for the errors.