From: cristy Date: Sat, 23 Feb 2013 02:28:08 +0000 (+0000) Subject: (no commit message) X-Git-Tag: 7.0.1-0~4196 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0b7a033066b1f6beca5cbc376d3c6abc78566cd0;p=imagemagick --- diff --git a/coders/webp.c b/coders/webp.c index 6f57eb239..a56317e11 100644 --- a/coders/webp.c +++ b/coders/webp.c @@ -137,30 +137,36 @@ static MagickBooleanType IsWEBP(const unsigned char *magick,const size_t length) % */ -static inline uint32_t get_le24(const unsigned char *const data) +static inline uint32_t ReadWebPLSBWord(const unsigned char *restrict data) { - return((uint32_t) (data[0] | (data[1] << 8) | (data[2] << 16))); -} + register const unsigned char + *p; -static inline uint32_t get_le32(const unsigned char *const data) -{ - return((uint32_t) (get_le24(data) | (data[3] << 24))); + register uint32_t + value; + + p=data; + value=(uint32_t) (*p++); + value|=((uint32_t) (*p++)) << 8; + value|=((uint32_t) (*p++)) << 16; + value|=((uint32_t) (*p++)) << 24; + return(value); } static MagickBooleanType IsWEBPImageLossless(const unsigned char *stream, const size_t length) { -#define VP8_CHUNK_INDEX 15 /* file/header type */ +#define VP8_CHUNK_INDEX 15 #define LOSSLESS_FLAG 'L' #define EXTENDED_HEADER 'X' #define VP8_CHUNK_HEADER "VP8" #define VP8_CHUNK_HEADER_SIZE 3 -#define RIFF_HEADER_SIZE 12 /* size of the RIFF header ("RIFFnnnnWEBP") */ +#define RIFF_HEADER_SIZE 12 #define VP8X_CHUNK_SIZE 10 #define TAG_SIZE 4 #define CHUNK_SIZE_BYTES 4 #define CHUNK_HEADER_SIZE 8 -#define MAX_CHUNK_PAYLOAD (~0U-CHUNK_HEADER_SIZE-1) /* header padding */ +#define MAX_CHUNK_PAYLOAD (~0U-CHUNK_HEADER_SIZE-1) ssize_t offset; @@ -180,7 +186,7 @@ static MagickBooleanType IsWEBPImageLossless(const unsigned char *stream, chunk_size, chunk_size_pad; - chunk_size=get_le32(stream+pos+TAG_SIZE); + chunk_size=ReadWebPLSBWord(stream+pos+TAG_SIZE); if (chunk_size > MAX_CHUNK_PAYLOAD) break; chunk_size_pad=(CHUNK_HEADER_SIZE+chunk_size+1) & ~1; @@ -218,10 +224,10 @@ static Image *ReadWEBPImage(const ImageInfo *image_info, configure; WebPDecBuffer - *const webp_image = &configure.output; + *restrict webp_image = &configure.output; WebPBitstreamFeatures - *const features = &configure.input; + *restrict features = &configure.input; /* Open image file.