From 85847996a23da6ee205cf35a4d8230c1cc66c6a5 Mon Sep 17 00:00:00 2001 From: lilo_booter Date: Thu, 4 May 2006 20:06:48 +0000 Subject: [PATCH] + Big endian patch courtesy of Goncalo Carvalho (glslang at gmail dot com) - specifically, corrects colour space conversions on the Intel Mac git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@909 d19143bc-622f-0410-bfdd-b5b2a6649095 --- src/modules/avformat/filter_avcolour_space.c | 22 +++++++++++++--------- 1 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/modules/avformat/filter_avcolour_space.c b/src/modules/avformat/filter_avcolour_space.c index 53b6780..9ea2b8f 100644 --- a/src/modules/avformat/filter_avcolour_space.c +++ b/src/modules/avformat/filter_avcolour_space.c @@ -28,6 +28,14 @@ #include #include +static inline int is_big_endian( ) +{ + union { int i; char c[ 4 ]; } big_endian_test; + big_endian_test.i = 1; + + return big_endian_test.c[ 0 ] != 1; +} + static inline int convert_mlt_to_av_cs( mlt_image_format format ) { int value = 0; @@ -96,10 +104,8 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format * register uint8_t *bits = *image; register int n = ( len + 7 ) / 8; - // TODO: Proper check for big endian systems - #ifndef __DARWIN__ - bits += 3; - #endif + if( !is_big_endian( ) ) + bits += 3; // Extract alpha mask from the image using Duff's Device switch( len % 8 ) @@ -134,11 +140,9 @@ static int filter_get_image( mlt_frame this, uint8_t **image, mlt_image_format * register uint8_t *bits = *image; register int len = *width * *height; register int n = ( len + 7 ) / 8; - - // TODO: Proper check for big endian systems - #ifndef __DARWIN__ - bits += 3; - #endif + + if( !is_big_endian( ) ) + bits += 3; // Merge the alpha mask into the RGB image using Duff's Device switch( len % 8 ) -- 1.7.4.4