[FFmpeg-devel] ffmpeg's alignment troubles

Gonzalo Garramuño ggarra
Thu Jan 3 07:37:52 CET 2008


In libavutil's mem.h, there's a macro used to align declarations of 
variables.

Under linux, this macro works flawlessly.  But under mingw32 (gcc 
3.4.5), I am finding that it doesn't.

Here's a simple example:

----------
#include <stdio.h>

#define DECLARE_ALIGNED(n,t,v)       t v __attribute__ ((aligned (n)))
#define DECLARE_ALIGNED_16(t,v) DECLARE_ALIGNED(16,t,v)

DECLARE_ALIGNED_16(int, align1);
DECLARE_ALIGNED_16(int, align2);
DECLARE_ALIGNED_16(int, align3);


int main()
{
   DECLARE_ALIGNED_16( int, align4 );
   static DECLARE_ALIGNED_16( int, align5 );

#define TEST_ALIGN(x) \
   if ( ((long) &(align##x)) & 15 )		\
    fprintf( stderr, "align" #x " not aligned %p\n", &align##x );

   TEST_ALIGN(1);
   TEST_ALIGN(2);
   TEST_ALIGN(3);
   TEST_ALIGN(4);
   TEST_ALIGN(5);

   return 0;
}
------

When I cross-compile it on my AMD64 box, I get:

$ i586-mingw32msvc-g++ -o main.exe main.c
$ wine main.exe
align4 not aligned 006AFEB4
align5 not aligned 00404038

This is somewhat problematic in ffmpeg, as dsputil, for example, has 
many such declarations.  I've also tried compiling it with a native 
mingw with similar results.

I was wondering if this is something you were aware of (or it is 
something obvious I am doing wrong).

I'm trying to trace a problem with a mingw32 compiled ffmpeg and this is 
one issue that has certainly cropped.




-- 
Gonzalo Garramu?o
ggarra at advancedsl.com.ar

AMD4400 - ASUS48N-E
GeForce7300GT
Xubuntu Gutsy




More information about the ffmpeg-devel mailing list