On 2014-02-28 12:29:07 +0200, Martin Storsjö wrote:
> Without this cast, the BE_32() expression is sign extended when
> assigned to an uint64_t, since the uint8_t|uint8_t expression
> is promoted to an int.
> 
> Based on a patch by Michael Niedermayer.
> ---
>  tools/qt-faststart.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/tools/qt-faststart.c b/tools/qt-faststart.c
> index b4a6555..312ec8f 100644
> --- a/tools/qt-faststart.c
> +++ b/tools/qt-faststart.c
> @@ -41,10 +41,10 @@
>  
>  #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])
> +#define BE_32(x) (uint32_t)((((uint8_t*)(x))[0] << 24) |  \

The left side of the first shift has to be casted to uint32_t, shifting
into the sign bit is undefined.

Janne
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to