Skip to content

Commit

Permalink
Fix some clang-cl warnings. (#2275)
Browse files Browse the repository at this point in the history
  • Loading branch information
vrabaud authored Jul 22, 2024
1 parent 5236863 commit 6d5341d
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 31 deletions.
4 changes: 2 additions & 2 deletions apps/shared/avifjpeg.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,13 +297,13 @@ static uint32_t avifJPEGReadUint32LittleEndian(const uint8_t * src)
// Reads a 2-byte unsigned integer in big-endian format from the raw bitstream src.
static uint16_t avifJPEGReadUint16BigEndian(const uint8_t * src)
{
return ((uint32_t)src[0] << 8) | ((uint32_t)src[1] << 0);
return (uint16_t)((src[0] << 8) | (src[1] << 0));
}

// Reads a 2-byte unsigned integer in little-endian format from the raw bitstream src.
static uint16_t avifJPEGReadUint16LittleEndian(const uint8_t * src)
{
return ((uint32_t)src[0] << 0) | ((uint32_t)src[1] << 8);
return (uint16_t)((src[0] << 0) | (src[1] << 8));
}

// Reads 'numBytes' at 'offset', stores them in 'bytes' and increases 'offset'.
Expand Down
2 changes: 1 addition & 1 deletion apps/shared/y4m.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ static avifBool y4mColorSpaceParse(const char * formatString, struct y4mFrameIte

// Returns an unsigned integer value parsed from [start:end[.
// Returns -1 in case of failure.
int y4mReadUnsignedInt(const char * start, const char * end)
static int y4mReadUnsignedInt(const char * start, const char * end)
{
const char * p = start;
int64_t value = 0;
Expand Down
2 changes: 1 addition & 1 deletion include/avif/avif.h
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ typedef struct avifGainMap

// Allocates a gain map. Returns NULL if a memory allocation failed.
// The 'image' field is NULL by default and must be allocated separately.
AVIF_API avifGainMap * avifGainMapCreate();
AVIF_API avifGainMap * avifGainMapCreate(void);
// Frees a gain map, including the 'image' field if non NULL.
AVIF_API void avifGainMapDestroy(avifGainMap * gainMap);

Expand Down
24 changes: 12 additions & 12 deletions include/avif/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -558,19 +558,19 @@ struct avifCodecInternal;

typedef enum avifEncoderChange
{
AVIF_ENCODER_CHANGE_MIN_QUANTIZER = (1u << 0),
AVIF_ENCODER_CHANGE_MAX_QUANTIZER = (1u << 1),
AVIF_ENCODER_CHANGE_MIN_QUANTIZER_ALPHA = (1u << 2),
AVIF_ENCODER_CHANGE_MAX_QUANTIZER_ALPHA = (1u << 3),
AVIF_ENCODER_CHANGE_TILE_ROWS_LOG2 = (1u << 4),
AVIF_ENCODER_CHANGE_TILE_COLS_LOG2 = (1u << 5),
AVIF_ENCODER_CHANGE_QUANTIZER = (1u << 6),
AVIF_ENCODER_CHANGE_QUANTIZER_ALPHA = (1u << 7),
AVIF_ENCODER_CHANGE_SCALING_MODE = (1u << 8),

AVIF_ENCODER_CHANGE_CODEC_SPECIFIC = (1u << 31)
AVIF_ENCODER_CHANGE_MIN_QUANTIZER = (1 << 0),
AVIF_ENCODER_CHANGE_MAX_QUANTIZER = (1 << 1),
AVIF_ENCODER_CHANGE_MIN_QUANTIZER_ALPHA = (1 << 2),
AVIF_ENCODER_CHANGE_MAX_QUANTIZER_ALPHA = (1 << 3),
AVIF_ENCODER_CHANGE_TILE_ROWS_LOG2 = (1 << 4),
AVIF_ENCODER_CHANGE_TILE_COLS_LOG2 = (1 << 5),
AVIF_ENCODER_CHANGE_QUANTIZER = (1 << 6),
AVIF_ENCODER_CHANGE_QUANTIZER_ALPHA = (1 << 7),
AVIF_ENCODER_CHANGE_SCALING_MODE = (1 << 8),

AVIF_ENCODER_CHANGE_CODEC_SPECIFIC = (1 << 30)
} avifEncoderChange;
typedef uint32_t avifEncoderChanges;
typedef int avifEncoderChanges;

typedef avifBool (*avifCodecGetNextImageFunc)(struct avifCodec * codec,
struct avifDecoder * decoder,
Expand Down
2 changes: 1 addition & 1 deletion src/avif.c
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,7 @@ void avifCodecVersions(char outBuffer[256])
}

#if defined(AVIF_ENABLE_EXPERIMENTAL_GAIN_MAP)
avifGainMap * avifGainMapCreate()
avifGainMap * avifGainMapCreate(void)
{
avifGainMap * gainMap = (avifGainMap *)avifAlloc(sizeof(avifGainMap));
if (!gainMap) {
Expand Down
2 changes: 1 addition & 1 deletion src/codec_aom.c
Original file line number Diff line number Diff line change
Expand Up @@ -1099,7 +1099,7 @@ static avifResult aomCodecEncodeImage(avifCodec * codec,
}
// Set the U plane to 0.5.
if (image->depth > 8) {
const uint16_t half = 1 << (image->depth - 1);
const uint16_t half = (uint16_t)(1 << (image->depth - 1));
for (uint32_t j = 0; j < monoUVHeight; ++j) {
uint16_t * dstRow = (uint16_t *)&aomImage.planes[1][(size_t)j * aomImage.stride[1]];
for (uint32_t i = 0; i < monoUVWidth; ++i) {
Expand Down
2 changes: 2 additions & 0 deletions src/obu.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,8 @@ static avifBool parseSequenceHeaderColorConfig(avifBits * bits, avifSequenceHead
header->yuvFormat = AVIF_PIXEL_FORMAT_YUV444;
}
break;
default:
return AVIF_FALSE;
}

if (subsampling_x && subsampling_y) {
Expand Down
12 changes: 6 additions & 6 deletions src/read.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ typedef struct avifSampleTable

static void avifSampleTableDestroy(avifSampleTable * sampleTable);

static avifSampleTable * avifSampleTableCreate()
static avifSampleTable * avifSampleTableCreate(void)
{
avifSampleTable * sampleTable = (avifSampleTable *)avifAlloc(sizeof(avifSampleTable));
if (sampleTable == NULL) {
Expand Down Expand Up @@ -750,7 +750,7 @@ typedef struct avifMeta

static void avifMetaDestroy(avifMeta * meta);

static avifMeta * avifMetaCreate()
static avifMeta * avifMetaCreate(void)
{
avifMeta * meta = (avifMeta *)avifAlloc(sizeof(avifMeta));
if (meta == NULL) {
Expand Down Expand Up @@ -883,7 +883,7 @@ typedef struct avifDecoderData

static void avifDecoderDataDestroy(avifDecoderData * data);

static avifDecoderData * avifDecoderDataCreate()
static avifDecoderData * avifDecoderDataCreate(void)
{
avifDecoderData * data = (avifDecoderData *)avifAlloc(sizeof(avifDecoderData));
if (data == NULL) {
Expand Down Expand Up @@ -5351,7 +5351,7 @@ avifResult avifDecoderReset(avifDecoder * decoder)
if (!foundItem) {
AVIF_CHECKERR(numExtraInputImageItems < AVIF_SAMPLE_TRANSFORM_MAX_NUM_EXTRA_INPUT_IMAGE_ITEMS,
AVIF_RESULT_NOT_IMPLEMENTED);
*category = AVIF_ITEM_SAMPLE_TRANSFORM_INPUT_0_COLOR + numExtraInputImageItems;
*category = (avifItemCategory)(AVIF_ITEM_SAMPLE_TRANSFORM_INPUT_0_COLOR + numExtraInputImageItems);
alphaCategory = AVIF_ITEM_SAMPLE_TRANSFORM_INPUT_0_ALPHA + numExtraInputImageItems;
mainItems[*category] = inputImageItem;
++numExtraInputImageItems;
Expand Down Expand Up @@ -5441,7 +5441,7 @@ avifResult avifDecoderReset(avifDecoder * decoder)
if (avifIsAlpha((avifItemCategory)c) && !isAlphaItemInInput) {
// In this case, the made up grid item will not have an associated pixi property. So validate everything else
// but the pixi property.
strictFlags &= ~AVIF_STRICT_PIXI_REQUIRED;
strictFlags &= ~(avifStrictFlags)AVIF_STRICT_PIXI_REQUIRED;
}
AVIF_CHECKRES(
avifDecoderItemValidateProperties(mainItems[c], avifGetConfigurationPropertyName(codecType[c]), &decoder->diag, strictFlags));
Expand Down Expand Up @@ -5807,7 +5807,7 @@ static avifBool avifDecoderDataFrameFullyDecoded(const avifDecoderData * data)
}

#if defined(AVIF_ENABLE_EXPERIMENTAL_SAMPLE_TRANSFORM)
avifResult avifDecoderApplySampleTransform(const avifDecoder * decoder, avifImage * dstImage)
static avifResult avifDecoderApplySampleTransform(const avifDecoder * decoder, avifImage * dstImage)
{
if (dstImage->depth != decoder->data->meta->sampleTransformDepth) {
AVIF_ASSERT_OR_RETURN(dstImage->yuvPlanes[0] != NULL);
Expand Down
8 changes: 4 additions & 4 deletions src/reformat.c
Original file line number Diff line number Diff line change
Expand Up @@ -1747,10 +1747,10 @@ void avifGetRGBAPixel(const avifRGBImage * src, uint32_t x, uint32_t y, const av

const uint8_t * const srcPixel = &src->pixels[y * src->rowBytes + x * info->pixelBytes];
if (info->channelBytes > 1) {
uint16_t r = *((uint16_t *)(&srcPixel[info->offsetBytesR]));
uint16_t g = *((uint16_t *)(&srcPixel[info->offsetBytesG]));
uint16_t b = *((uint16_t *)(&srcPixel[info->offsetBytesB]));
uint16_t a = avifRGBFormatHasAlpha(src->format) ? *((uint16_t *)(&srcPixel[info->offsetBytesA])) : (uint16_t)info->maxChannel;
uint16_t r = *((const uint16_t *)(&srcPixel[info->offsetBytesR]));
uint16_t g = *((const uint16_t *)(&srcPixel[info->offsetBytesG]));
uint16_t b = *((const uint16_t *)(&srcPixel[info->offsetBytesB]));
uint16_t a = avifRGBFormatHasAlpha(src->format) ? *((const uint16_t *)(&srcPixel[info->offsetBytesA])) : (uint16_t)info->maxChannel;
if (src->isFloat) {
rgbaPixel[0] = avifF16ToFloat(r);
rgbaPixel[1] = avifF16ToFloat(g);
Expand Down
6 changes: 3 additions & 3 deletions src/write.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ typedef struct avifEncoderData
static void avifEncoderDataDestroy(avifEncoderData * data);

// Returns NULL if a memory allocation failed.
static avifEncoderData * avifEncoderDataCreate()
static avifEncoderData * avifEncoderDataCreate(void)
{
avifEncoderData * data = (avifEncoderData *)avifAlloc(sizeof(avifEncoderData));
if (!data) {
Expand Down Expand Up @@ -982,7 +982,7 @@ static avifResult avifEncoderWriteSampleTransformTokens(avifRWStream * s, const

if (token->type == AVIF_SAMPLE_TRANSFORM_CONSTANT) {
// TODO(yguyon): Verify two's complement representation is guaranteed here.
const uint32_t constant = *(uint32_t *)&token->constant;
const uint32_t constant = *(const uint32_t *)&token->constant;
AVIF_CHECKRES(avifRWStreamWriteU32(s, constant)); // signed int(1<<(bit_depth+3)) constant;
} else if (token->type == AVIF_SAMPLE_TRANSFORM_INPUT_IMAGE_ITEM_INDEX) {
AVIF_CHECKRES(avifRWStreamWriteU8(s, token->inputImageItemIndex)); // unsigned int(8) input_image_item_index;
Expand Down Expand Up @@ -1289,7 +1289,7 @@ static avifResult avifImageApplyImgOpConst(avifImage * result,
// Postfix notation.
const avifSampleTransformToken tokens[] = { { AVIF_SAMPLE_TRANSFORM_INPUT_IMAGE_ITEM_INDEX, 0, /*inputImageItemIndex=*/1 },
{ AVIF_SAMPLE_TRANSFORM_CONSTANT, constant, 0 },
{ op, 0, 0 } };
{ (uint8_t)op, 0, 0 } };
return avifImageApplyOperations(result, AVIF_SAMPLE_TRANSFORM_BIT_DEPTH_32, /*numTokens=*/3, tokens, /*numInputImageItems=*/1, &inputImageItem, planes);
}

Expand Down

0 comments on commit 6d5341d

Please sign in to comment.