Skip to content

Commit 6ba8922

Browse files
authored
Fix some boolean logic (#2737)
1 parent 0921d30 commit 6ba8922

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/read.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6699,7 +6699,8 @@ static avifResult avifDecoderApplySampleTransform(const avifDecoder * decoder, a
66996699
return result;
67006700
}
67016701

6702-
for (avifBool alpha = AVIF_FALSE; alpha <= decoder->alphaPresent ? AVIF_TRUE : AVIF_FALSE; ++alpha) {
6702+
for (int pass = 0; pass < (decoder->alphaPresent ? 2 : 1); ++pass) {
6703+
avifBool alpha = (pass == 0) ? AVIF_FALSE : AVIF_TRUE;
67036704
AVIF_ASSERT_OR_RETURN(decoder->data->sampleTransformNumInputImageItems <= AVIF_SAMPLE_TRANSFORM_MAX_NUM_INPUT_IMAGE_ITEMS);
67046705
const avifImage * inputImages[AVIF_SAMPLE_TRANSFORM_MAX_NUM_INPUT_IMAGE_ITEMS];
67056706
for (uint32_t i = 0; i < decoder->data->sampleTransformNumInputImageItems; ++i) {

src/write.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -975,10 +975,10 @@ static avifBool avifGainMapIdenticalChannels(const avifGainMap * gainMap)
975975
}
976976

977977
// Returns the number of bytes written by avifWriteGainmapMetadata().
978-
static avifBool avifGainMapMetadataSize(const avifGainMap * gainMap)
978+
static uint32_t avifGainMapMetadataSize(const avifGainMap * gainMap)
979979
{
980980
const uint8_t channelCount = avifGainMapIdenticalChannels(gainMap) ? 1u : 3u;
981-
return sizeof(uint16_t) * 2 + sizeof(uint8_t) + sizeof(uint32_t) * 4 + channelCount * sizeof(uint32_t) * 10;
981+
return (uint32_t)(sizeof(uint16_t) * 2 + sizeof(uint8_t) + sizeof(uint32_t) * 4 + channelCount * sizeof(uint32_t) * 10);
982982
}
983983

984984
static avifResult avifWriteGainmapMetadata(avifRWStream * s, const avifGainMap * gainMap, avifDiagnostics * diag)

0 commit comments

Comments
 (0)