[PATCH] Re: [speex-dev] Decoding .spx with 1.0 on ppc produces noise!
bds02 at uow.edu.au
Thu Apr 17 08:22:38 PDT 2003
On Thu, 2003-04-17 at 07:48, Kaveh Goudarzi wrote:
> I had a similar question ... is the endian-ness of the encoded
> speex file, system dependent? or is it always little endian? If it's
> always little endian (like the header seems to be) then big endian
> machines (or java) will need to map everything to bigendian before
> decoding ...
I have spent some time looking into this now...
The file only has 'endianness' in the header, as that is the only place
it stores multi-byte quantities directly. All other numerical quantities
are un-packed bit-by-bit by speex_bits_unpack_unsigned, which will be
guaranteed to work OK on any host platform. Thus the input to the
decoder is OK.
However, what happens to the output is another problem. The speexdec
decoder tells the OSS output driver that the data format is Little
Endian. It also converts the data from native endian to little endian
before writing the data to the driver. While this should work in theory,
in practice there seems to be a problem with the driver on my PowerBook,
so this produces *nasty hissing noise*. It's also inefficient, as we
should just open the driver in native endian mode and output native
endian directly. (Native endian is just a convenient notation for
whatever the endian of the host platform is. Of course, we can only have
big endian or little endian systems.)
I have attached a couple of patches which sort out this issue, and a
typo I found (there were others I didn't fix too...). I have only tested
it on my powerbook, and not on my i386! I'll leave that to you guys for
<p>> thanks in advance,
> Ben Stanley wrote:
> > Hi,
> > I got my hands on the LCA 2003 CD today and I tried to listen to it on
> > my powerbook running Linux. Instead of getting speech, I got an earfull
> > of noise! Attempting the same experiment on an i386 with the same CD
> > produced understandable speech.
> > It seems that the output routine in speexdec converts the output data to
> > little endian short format, which is incorrect on the ppc architecture.
> > The data written to the sound device should be in native endian format
> > (this may be different from what is required if the data is being
> > written to a file). However, removing the endian conversion does not fix
> > the problem, and speexdec continues to play noise.
> > Ben.
> > --- >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 'speex-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.
> --- >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 'speex-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.
Ben Stanley <bds02 at uow.edu.au>
University of Wollongong
--- speex-1.0/src/speexdec.c Fri Mar 21 08:52:39 2003
+++ speex-1.0-works/src/speexdec.c Thu Apr 17 06:39:23 2003
@@ -136,7 +136,7 @@
if (ioctl(audio_fd, SNDCTL_DSP_SETFMT, &format)==-1)
@@ -612,7 +612,7 @@
/*Convert to short and save to output file*/
#if defined WIN32 || defined _WIN32
WIN_Play_Samples (out, sizeof(short) * frame_size*channels);
--- speex-1.0-works/libspeex/nb_celp.c.orig Thu Apr 17 06:13:47 2003
+++ speex-1.0-works/libspeex/nb_celp.c Thu Apr 17 06:13:52 2003
@@ -1067,7 +1067,7 @@
wideband = speex_bits_unpack_unsigned(bits, 1);
- speex_warning ("More than to wideband layers found: corrupted stream?");
+ speex_warning ("More than two wideband layers found: corrupted stream?");
<p>--- >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 'speex-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 Speex-dev