[MPlayer-dev-eng] Alignment problems in real.c

Stephen Henson lists at drh-consultancy.demon.co.uk
Sat Oct 30 13:47:23 CEST 2004


Sascha Sommer wrote:
> On Tuesday 26 October 2004 00:33, Stephen Henson wrote:
> 
>>
>>I finally traced this to the macros at the start of
>>libmpdemux/realrtsp/real.c:
>>
>>#define BE_32C(x,y) (*((uint32_t*)(x))=be2me_32(y))
>>
>>#define BE_16(x)  be2me_16(*(uint16_t*)(x))
>>
>>#define BE_32(x)  be2me_32(*(uint32_t*)(x))
>>
>>The XScale is big endian and the above causes word alignment problems in
>>select_mlti_data().
>>
>>The file rmff.c has similar macros but defined as:
>>
>>#define BE_16(x)  ((((uint8_t*)(x))[0] << 8) | ((uint8_t*)(x))[1])
>>#define BE_32(x)  ((((uint8_t*)(x))[0] << 24) | \
>>                    (((uint8_t*)(x))[1] << 16) | \
>>                    (((uint8_t*)(x))[2] << 8) | \
>>                     ((uint8_t*)(x))[3])
>>
>>
>>After replacing the BE_16 and BE_32 macros in real.c with those in
>>rmff.c it worked fine. I suppose BE32_C should be fixed too but it only
>>appears to be used on word boundaries in real.c
>>
> 
> 
> I think it would be a good idea to change the be2me_* macros in bswap.h, then
> as they are probably used in more places.
> 

Then you'd need some additional be2me_*() macros for unaligned pointers 
since its the *(uint32_t*)(x) with an unaligned "x" that's the problem 
rather than be2me_*.

Steve.




More information about the MPlayer-dev-eng mailing list