[speex-dev] minor suggestions

Daniel Vogel vogel at epicgames.com
Thu Jan 30 19:02:43 PST 2003



> I understood that the problem was a mismatch between the the declaration
> and definition in for some codebooks (exc_*_tables.c).

The problem is the following:

If you compile libspeex with default settings or maybe use a precompiled
binary the code that handles the structs passed in via the API assumes a
certain layout in memory (by default the max alignment is 8 bytes).

If I include speex.h when using say the /Zp1 compiler option (max alignment
== 1 bytes, everything is tightly packed) the structs I use in my code are
tightly packed so the memory layout of the structs differ. This becomes a
problem when I have to pass structs to the library.

Here's an example

---- header.h ----

truct my_struct
{
        char c;
        int i;
};

void my_function( my_struct* a );

---- library, 8 byte packing ----

#include "header.h"

void my_function( my_struct* a )
{
        bzero( a, sizeof(my_struct) );
        // sizeof(my_struct) == 8
}

---- app, 1 byte packing ----

#include "header.h"

void main()
{
        my_struct a;
        my_function( &a ); // will crash
        // sizeof(my_struct) == 4
}

This can be avoided by either manually wrapping header.h with pragmas by the
app or doing this in the header. The latter is common practice on Windows.

<p>> What are the offending files then?

vq.c
vbr.c
stereo.c
quant.lsp
ltp.c
lsp.c
lpc.c
filter.c

<p>> BTW, aside from the warnings, does the code compile and work?

It compiles fine - haven't written enough code yet to see whether it works
as expected but rest assured, I'll complain if I run into issues ;-)

<p>-- Daniel, Epic Games Inc.

--- >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 mailing list