Cleanup unnecessary avifBool ternary expressions
Fixes: #104
diff --git a/src/avif.c b/src/avif.c
index 70a748c..e7918cb 100644
--- a/src/avif.c
+++ b/src/avif.c
@@ -341,7 +341,7 @@
avifBool avifImageUsesU16(avifImage * image)
{
- return (image->depth > 8) ? AVIF_TRUE : AVIF_FALSE;
+ return (image->depth > 8);
}
// avifCodecCreate*() functions are in their respective codec_*.c files
diff --git a/src/codec_aom.c b/src/codec_aom.c
index 7515681..2f40af3 100644
--- a/src/codec_aom.c
+++ b/src/codec_aom.c
@@ -300,7 +300,7 @@
minQuantizer = AVIF_CLAMP(encoder->minQuantizerAlpha, 0, 63);
maxQuantizer = AVIF_CLAMP(encoder->maxQuantizerAlpha, 0, 63);
}
- avifBool lossless = ((minQuantizer == AVIF_QUANTIZER_LOSSLESS) && (maxQuantizer == AVIF_QUANTIZER_LOSSLESS)) ? AVIF_TRUE : AVIF_FALSE;
+ avifBool lossless = ((minQuantizer == AVIF_QUANTIZER_LOSSLESS) && (maxQuantizer == AVIF_QUANTIZER_LOSSLESS));
cfg.rc_min_quantizer = minQuantizer;
cfg.rc_max_quantizer = maxQuantizer;
diff --git a/src/colr.c b/src/colr.c
index 7cc45ec..69287ea 100644
--- a/src/colr.c
+++ b/src/colr.c
@@ -150,7 +150,7 @@
static avifBool matchesTo3RoundedPlaces(float a, float b)
{
- return (fabsf(a - b) < 0.001f) ? AVIF_TRUE : AVIF_FALSE;
+ return (fabsf(a - b) < 0.001f);
}
static avifBool primariesMatch(const float p1[8], const float p2[8])
diff --git a/src/read.c b/src/read.c
index 8a0d3e4..245c229 100644
--- a/src/read.c
+++ b/src/read.c
@@ -571,7 +571,7 @@
for (unsigned int i = 1; i < tileCount; ++i) {
avifTile * tile = &data->tiles.tile[firstTileIndex + i];
- avifBool uvPresent = (tile->image->yuvPlanes[AVIF_CHAN_U] && tile->image->yuvPlanes[AVIF_CHAN_V]) ? AVIF_TRUE : AVIF_FALSE;
+ avifBool uvPresent = (tile->image->yuvPlanes[AVIF_CHAN_U] && tile->image->yuvPlanes[AVIF_CHAN_V]);
if ((tile->image->width != tileWidth) || (tile->image->height != tileHeight) || (tile->image->depth != tileDepth) ||
(tile->image->yuvFormat != tileFormat) || (tile->image->yuvRange != tileRange) || (uvPresent != tileUVPresent) ||
((tileProfile == AVIF_PROFILE_FORMAT_NCLX) &&
@@ -1001,7 +1001,7 @@
uint8_t version;
uint8_t flags[3];
CHECK(avifROStreamReadVersionAndFlags(&s, &version, flags));
- avifBool propertyIndexIsU16 = (flags[2] & 0x1) ? AVIF_TRUE : AVIF_FALSE; // is flags[2] correct?
+ avifBool propertyIndexIsU16 = ((flags[2] & 0x1) != 0);
uint32_t entryCount;
CHECK(avifROStreamReadU32(&s, &entryCount));
@@ -1021,12 +1021,12 @@
uint16_t propertyIndex = 0;
if (propertyIndexIsU16) {
CHECK(avifROStreamReadU16(&s, &propertyIndex));
- // essential = (propertyIndex & 0x8000) ? AVIF_TRUE : AVIF_FALSE;
+ // essential = ((propertyIndex & 0x8000) != 0);
propertyIndex &= 0x7fff;
} else {
uint8_t tmp;
CHECK(avifROStreamRead(&s, &tmp, 1));
- // essential = (tmp & 0x80) ? AVIF_TRUE : AVIF_FALSE;
+ // essential = ((tmp & 0x80) != 0);
propertyIndex = tmp & 0x7f;
}
@@ -1716,12 +1716,12 @@
static avifBool avifFileTypeIsCompatible(avifFileType * ftyp)
{
- avifBool avifCompatible = (memcmp(ftyp->majorBrand, "avif", 4) == 0) ? AVIF_TRUE : AVIF_FALSE;
+ avifBool avifCompatible = (memcmp(ftyp->majorBrand, "avif", 4) == 0);
if (!avifCompatible) {
- avifCompatible = (memcmp(ftyp->majorBrand, "avis", 4) == 0) ? AVIF_TRUE : AVIF_FALSE;
+ avifCompatible = (memcmp(ftyp->majorBrand, "avis", 4) == 0);
}
if (!avifCompatible) {
- avifCompatible = (memcmp(ftyp->majorBrand, "av01", 4) == 0) ? AVIF_TRUE : AVIF_FALSE;
+ avifCompatible = (memcmp(ftyp->majorBrand, "av01", 4) == 0);
}
if (!avifCompatible) {
for (int compatibleBrandIndex = 0; compatibleBrandIndex < ftyp->compatibleBrandsCount; ++compatibleBrandIndex) {
@@ -2004,7 +2004,7 @@
if (!item->id || !item->size) {
break;
}
- avifBool isGrid = (memcmp(item->type, "grid", 4) == 0) ? AVIF_TRUE : AVIF_FALSE;
+ avifBool isGrid = (memcmp(item->type, "grid", 4) == 0);
if (memcmp(item->type, "av01", 4) && !isGrid) {
// probably exif or some other data
continue;
@@ -2045,7 +2045,7 @@
if (!item->id || !item->size) {
break;
}
- avifBool isGrid = (memcmp(item->type, "grid", 4) == 0) ? AVIF_TRUE : AVIF_FALSE;
+ avifBool isGrid = (memcmp(item->type, "grid", 4) == 0);
if (memcmp(item->type, "av01", 4) && !isGrid) {
// probably exif or some other data
continue;
diff --git a/src/stream.c b/src/stream.c
index 809ab1c..676fb3b 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -185,7 +185,7 @@
{
uint8_t version;
CHECK(avifROStreamReadVersionAndFlags(stream, &version, NULL));
- return (version == enforcedVersion) ? AVIF_TRUE : AVIF_FALSE;
+ return (version == enforcedVersion);
}
// ---------------------------------------------------------------------------
diff --git a/src/write.c b/src/write.c
index 5ca31df..bef902d 100644
--- a/src/write.c
+++ b/src/write.c
@@ -139,9 +139,9 @@
}
// TODO: consider collapsing all items into local structs for iteration / code sharing
- avifBool hasAlpha = (alphaOBU.size > 0) ? AVIF_TRUE : AVIF_FALSE;
- avifBool hasExif = (image->exif.size > 0) ? AVIF_TRUE : AVIF_FALSE;
- avifBool hasXMP = (image->xmp.size > 0) ? AVIF_TRUE : AVIF_FALSE;
+ avifBool hasAlpha = (alphaOBU.size > 0);
+ avifBool hasExif = (image->exif.size > 0);
+ avifBool hasXMP = (image->xmp.size > 0);
// -----------------------------------------------------------------------
// Write ftyp