[vorbis-dev] patch for decoder_example.c
Steve Nicolai
snicolai at mac.com
Mon Mar 26 19:36:51 PST 2001
Following is a patch that makes decoder_example a bit closer to
the inverse of encoder_example.
It fixes a bug in that it assumed always 2 channels, and it
now writes the samples in little endian format always. Now
you can slap a WAV header on the data and listen to it.
Index: vorbis/examples/decoder_example.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis/examples/decoder_example.c,v
retrieving revision 1.19
diff -r1.19 decoder_example.c
38c38
< ogg_int16_t convbuffer[4096]; /* take 8k out of the data segment, not the
stack */
---
> char convbuffer[8192]; /* take 8k out of the data segment, not the stack */
235c235
< /* convert floats to 16 bit signed ints (host order) and
---
> /* convert floats to 16 bit signed ints (little endian) and
238c238
< ogg_int16_t *ptr=convbuffer+i;
---
> char *ptr=convbuffer+(i*2);
255,256c255,257
< *ptr=val;
< ptr+=2;
---
> ptr[0]=val&0xff;
> ptr[1]=(val>>8)&0xff;
> ptr+=2*vi.channels;
--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'vorbis-dev-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the Vorbis-dev
mailing list