[x264-devel] commit: Work around gcc/ld alignment bug on win32 (Anton Mitrofanov )
git at videolan.org
git at videolan.org
Wed Dec 15 04:19:32 CET 2010
x264 | branch: master | Anton Mitrofanov <BugMaster at narod.ru> | Tue Dec 7 17:49:21 2010 +0300| [fd8ff3330de3cc2cbabb0bba785fe7a92eb0a305] | committer: Jason Garrett-Glaser
Work around gcc/ld alignment bug on win32
Fixes problems due to misalignment of static zero arrays (win32 ld can't align .bss properly).
> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=fd8ff3330de3cc2cbabb0bba785fe7a92eb0a305
---
configure | 7 ++++++-
encoder/me.c | 2 --
encoder/rdo.c | 2 +-
encoder/slicetype.c | 2 +-
4 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/configure b/configure
index 9cd7770..4e30819 100755
--- a/configure
+++ b/configure
@@ -368,7 +368,7 @@ case $host_cpu in
x86_64)
ARCH="X86_64"
AS="yasm"
- if [ "$SYS" = MACOSX ];then
+ if [ "$SYS" = MACOSX ]; then
ASFLAGS="$ASFLAGS -f macho64 -m amd64 -DPIC -DPREFIX"
if cc_check '' "-arch x86_64"; then
CFLAGS="$CFLAGS -arch x86_64"
@@ -718,6 +718,11 @@ if cc_check '' -fno-tree-vectorize ; then
CFLAGS="$CFLAGS -fno-tree-vectorize"
fi
+if [ $SYS = MINGW -a $ARCH = X86 ] ; then
+ # workaround gcc/ld bug with alignment of static variables/arrays that are initialized to zero
+ cc_check '' -fno-zero-initialized-in-bss && CFLAGS="$CFLAGS -fno-zero-initialized-in-bss"
+fi
+
if cc_check "stdio.h" "" "fseeko(stdin,0,0);" ; then
define fseek fseeko
define ftell ftello
diff --git a/encoder/me.c b/encoder/me.c
index bd0a082..8833973 100644
--- a/encoder/me.c
+++ b/encoder/me.c
@@ -589,8 +589,6 @@ void x264_me_search_ref( x264_t *h, x264_me_t *m, int16_t (*mvc)[2], int i_mvc,
/* successive elimination by comparing DC before a full SAD,
* because sum(abs(diff)) >= abs(diff(sum)). */
uint16_t *sums_base = m->integral;
- /* due to a GCC bug on some platforms (win32?), zero[] may not actually be aligned.
- * this is not a problem because it is not used for any SSE instructions. */
ALIGNED_16( static pixel zero[8*FENC_STRIDE] );
ALIGNED_ARRAY_16( int, enc_dc,[4] );
int sad_size = i_pixel <= PIXEL_8x8 ? PIXEL_8x8 : PIXEL_4x4;
diff --git a/encoder/rdo.c b/encoder/rdo.c
index effbefc..c5c744e 100644
--- a/encoder/rdo.c
+++ b/encoder/rdo.c
@@ -119,7 +119,7 @@ static ALWAYS_INLINE int cached_satd( x264_t *h, int size, int x, int y )
static inline int ssd_plane( x264_t *h, int size, int p, int x, int y )
{
- ALIGNED_16(static pixel zero[16]);
+ ALIGNED_16( static pixel zero[16] );
int satd = 0;
pixel *fdec = h->mb.pic.p_fdec[p] + x + y*FDEC_STRIDE;
pixel *fenc = h->mb.pic.p_fenc[p] + x + y*FENC_STRIDE;
diff --git a/encoder/slicetype.c b/encoder/slicetype.c
index e6018f1..93d3ea7 100644
--- a/encoder/slicetype.c
+++ b/encoder/slicetype.c
@@ -191,7 +191,7 @@ static NOINLINE unsigned int x264_weight_cost_chroma( x264_t *h, x264_frame_t *f
pixel *src = ref + i_offset;
ALIGNED_ARRAY_16( pixel, buf, [8*8] );
int pixoff = 0;
- ALIGNED_16( static pixel flat[9] ) = {0,0,0,0,0,0,0,0,1}; //hack for win32
+ ALIGNED_16( static pixel flat[8] );
if( w )
{
for( int y = 0; y < i_lines; y += 8, pixoff = y*i_stride )
More information about the x264-devel
mailing list