diff --git a/examples/cwebp.c b/examples/cwebp.c index 300d2c4f..0aee03ea 100644 --- a/examples/cwebp.c +++ b/examples/cwebp.c @@ -109,15 +109,15 @@ typedef enum { static InputFileFormat GetImageType(FILE* in_file) { InputFileFormat format = UNSUPPORTED; - unsigned int magic; - unsigned char buf[4]; + uint32_t magic; + uint8_t buf[4]; if ((fread(&buf[0], 4, 1, in_file) != 1) || (fseek(in_file, 0, SEEK_SET) != 0)) { return format; } - magic = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]; + magic = ((uint32_t)buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]; if (magic == 0x89504E47U) { format = PNG_; } else if (magic >= 0xFFD8FF00U && magic <= 0xFFD8FFFFU) { diff --git a/src/enc/picture.c b/src/enc/picture.c index dedbf36d..24f0146d 100644 --- a/src/enc/picture.c +++ b/src/enc/picture.c @@ -710,7 +710,7 @@ static int Import(WebPPicture* const picture, for (y = 0; y < height; ++y) { for (x = 0; x < width; ++x) { const int offset = step * x + y * rgb_stride; - const uint32_t argb = (a_ptr[offset] << 24) | + const uint32_t argb = ((uint32_t)a_ptr[offset] << 24) | (r_ptr[offset] << 16) | (g_ptr[offset] << 8) | (b_ptr[offset]); @@ -810,7 +810,7 @@ int WebPPictureYUVAToARGB(WebPPicture* picture) { const uint8_t* const src = picture->a + y * picture->a_stride; int x; for (x = 0; x < width; ++x) { - argb_dst[x] = (argb_dst[x] & 0x00ffffffu) | (src[x] << 24); + argb_dst[x] = (argb_dst[x] & 0x00ffffffu) | ((uint32_t)src[x] << 24); } } }