Enabled tons of warnings, and warnings-as-errors; Fixed associated fallout
diff --git a/src/avif.c b/src/avif.c
index ea38f1c..4006d35 100644
--- a/src/avif.c
+++ b/src/avif.c
@@ -177,7 +177,7 @@
if (srcImage->alphaPlane) {
avifImageAllocatePlanes(dstImage, AVIF_PLANES_A);
- for (int j = 0; j < dstImage->height; ++j) {
+ for (uint32_t j = 0; j < dstImage->height; ++j) {
uint8_t * srcAlphaRow = &srcImage->alphaPlane[j * srcImage->alphaRowBytes];
uint8_t * dstAlphaRow = &dstImage->alphaPlane[j * dstImage->alphaRowBytes];
memcpy(dstAlphaRow, srcAlphaRow, dstImage->alphaRowBytes);
diff --git a/src/codec_aom.c b/src/codec_aom.c
index 3d41208..5a8ca21 100644
--- a/src/codec_aom.c
+++ b/src/codec_aom.c
@@ -274,14 +274,14 @@
seqLevelIdx0 = 13; // 5.1
}
- outputConfig->seqProfile = cfg.g_profile;
+ outputConfig->seqProfile = (uint8_t)cfg.g_profile;
outputConfig->seqLevelIdx0 = seqLevelIdx0;
outputConfig->seqTier0 = 0;
outputConfig->highBitdepth = (image->depth > 8) ? 1 : 0;
outputConfig->twelveBit = (image->depth == 12) ? 1 : 0;
outputConfig->monochrome = alphaOnly ? 1 : 0;
- outputConfig->chromaSubsamplingX = formatInfo.chromaShiftX;
- outputConfig->chromaSubsamplingY = formatInfo.chromaShiftY;
+ outputConfig->chromaSubsamplingX = (uint8_t)formatInfo.chromaShiftX;
+ outputConfig->chromaSubsamplingY = (uint8_t)formatInfo.chromaShiftY;
// TODO: choose the correct one from below:
// * 0 - CSP_UNKNOWN Unknown (in this case the source video transfer function must be signaled outside the AV1 bitstream)
@@ -315,20 +315,20 @@
aom_codec_control(&aomEncoder, AV1E_SET_ROW_MT, 1);
}
- int uvHeight = image->height >> yShift;
+ uint32_t uvHeight = image->height >> yShift;
aom_image_t * aomImage = aom_img_alloc(NULL, aomFormat, image->width, image->height, 16);
if (alphaOnly) {
aomImage->range = AOM_CR_FULL_RANGE; // Alpha is always full range
aom_codec_control(&aomEncoder, AV1E_SET_COLOR_RANGE, aomImage->range);
aomImage->monochrome = 1;
- for (int j = 0; j < image->height; ++j) {
+ for (uint32_t j = 0; j < image->height; ++j) {
uint8_t * srcAlphaRow = &image->alphaPlane[j * image->alphaRowBytes];
uint8_t * dstAlphaRow = &aomImage->planes[0][j * aomImage->stride[0]];
memcpy(dstAlphaRow, srcAlphaRow, image->alphaRowBytes);
}
- for (int j = 0; j < uvHeight; ++j) {
+ for (uint32_t j = 0; j < uvHeight; ++j) {
// Zero out U and V
memset(&aomImage->planes[1][j * aomImage->stride[1]], 0, aomImage->stride[1]);
memset(&aomImage->planes[2][j * aomImage->stride[2]], 0, aomImage->stride[2]);
diff --git a/src/codec_dav1d.c b/src/codec_dav1d.c
index 50e3b54..14f1aaa 100644
--- a/src/codec_dav1d.c
+++ b/src/codec_dav1d.c
@@ -80,7 +80,8 @@
static avifBool dav1dCodecGetNextImage(avifCodec * codec, avifImage * image)
{
avifBool gotPicture = AVIF_FALSE;
- Dav1dPicture nextFrame = { 0 };
+ Dav1dPicture nextFrame;
+ memset(&nextFrame, 0, sizeof(Dav1dPicture));
for (;;) {
avifBool sentData = dav1dFeedData(codec);
@@ -128,8 +129,8 @@
}
if (image->width && image->height) {
- if ((image->width != dav1dImage->p.w) || (image->height != dav1dImage->p.h) || (image->depth != dav1dImage->p.bpc) ||
- (image->yuvFormat != yuvFormat)) {
+ if ((image->width != (uint32_t)dav1dImage->p.w) || (image->height != (uint32_t)dav1dImage->p.h) ||
+ (image->depth != (uint32_t)dav1dImage->p.bpc) || (image->yuvFormat != yuvFormat)) {
// Throw it all out
avifImageFreePlanes(image, AVIF_PLANES_ALL);
}
diff --git a/src/colr.c b/src/colr.c
index ab22fdb..a59d606 100644
--- a/src/colr.c
+++ b/src/colr.c
@@ -18,7 +18,7 @@
struct
{
float x, y;
- };
+ } xy;
float e[2];
} gbVec2;
@@ -27,11 +27,11 @@
struct
{
float x, y, z;
- };
+ } xyz;
struct
{
float r, g, b;
- };
+ } rgb;
gbVec2 xy;
float e[3];
@@ -42,7 +42,7 @@
struct
{
gbVec3 x, y, z;
- };
+ } xyz;
gbVec3 col[3];
float e[9];
} gbMat3;
@@ -54,9 +54,9 @@
static void gb_float33_mul_vec3(gbVec3 * out, float m[3][3], gbVec3 v)
{
- out->x = m[0][0] * v.x + m[0][1] * v.y + m[0][2] * v.z;
- out->y = m[1][0] * v.x + m[1][1] * v.y + m[1][2] * v.z;
- out->z = m[2][0] * v.x + m[2][1] * v.y + m[2][2] * v.z;
+ out->xyz.x = m[0][0] * v.xyz.x + m[0][1] * v.xyz.y + m[0][2] * v.xyz.z;
+ out->xyz.y = m[1][0] * v.xyz.x + m[1][1] * v.xyz.y + m[1][2] * v.xyz.z;
+ out->xyz.z = m[2][0] * v.xyz.x + m[2][1] * v.xyz.y + m[2][2] * v.xyz.z;
}
static void gb_mat3_mul_vec3(gbVec3 * out, gbMat3 * m, gbVec3 in)
@@ -259,7 +259,7 @@
rgb.e[1] = g;
rgb.e[2] = b;
gb_mat3_mul_vec3(&XYZ, colorants, rgb);
- return XYZ.y;
+ return XYZ.xyz.y;
}
static avifBool readXYZ(uint8_t * data, size_t size, float xyz[3])
@@ -408,28 +408,28 @@
gbVec3 U, W;
gbMat3 P, PInv, D;
- P.col[0].x = primaries[0];
- P.col[0].y = primaries[1];
- P.col[0].z = 1 - primaries[0] - primaries[1];
- P.col[1].x = primaries[2];
- P.col[1].y = primaries[3];
- P.col[1].z = 1 - primaries[2] - primaries[3];
- P.col[2].x = primaries[4];
- P.col[2].y = primaries[5];
- P.col[2].z = 1 - primaries[4] - primaries[5];
+ P.col[0].xyz.x = primaries[0];
+ P.col[0].xyz.y = primaries[1];
+ P.col[0].xyz.z = 1 - primaries[0] - primaries[1];
+ P.col[1].xyz.x = primaries[2];
+ P.col[1].xyz.y = primaries[3];
+ P.col[1].xyz.z = 1 - primaries[2] - primaries[3];
+ P.col[2].xyz.x = primaries[4];
+ P.col[2].xyz.y = primaries[5];
+ P.col[2].xyz.z = 1 - primaries[4] - primaries[5];
gb_mat3_inverse(&PInv, &P);
- W.x = primaries[6];
- W.y = primaries[7];
- W.z = 1 - primaries[6] - primaries[7];
+ W.xyz.x = primaries[6];
+ W.xyz.y = primaries[7];
+ W.xyz.z = 1 - primaries[6] - primaries[7];
gb_mat3_mul_vec3(&U, &PInv, W);
memset(&D, 0, sizeof(D));
- D.col[0].x = U.x / W.y;
- D.col[1].y = U.y / W.y;
- D.col[2].z = U.z / W.y;
+ D.col[0].xyz.x = U.xyz.x / W.xyz.y;
+ D.col[1].xyz.y = U.xyz.y / W.xyz.y;
+ D.col[2].xyz.z = U.xyz.z / W.xyz.y;
gb_mat3_mul(colorants, &P, &D);
gb_mat3_transpose(colorants);
diff --git a/src/read.c b/src/read.c
index 63f085d..cb979b4 100644
--- a/src/read.c
+++ b/src/read.c
@@ -320,9 +320,11 @@
// ---------------------------------------------------------------------------
// BMFF Parsing
-#define BEGIN_STREAM(VARNAME, PTR, SIZE) \
- avifStream VARNAME; \
- avifRawData VARNAME##_rawData = { PTR, SIZE }; \
+#define BEGIN_STREAM(VARNAME, PTR, SIZE) \
+ avifStream VARNAME; \
+ avifRawData VARNAME##_rawData; \
+ VARNAME##_rawData.data = PTR; \
+ VARNAME##_rawData.size = SIZE; \
avifStreamStart(&VARNAME, &VARNAME##_rawData)
static avifBool avifParseItemLocationBox(avifData * data, uint8_t * raw, size_t rawLen)
@@ -1350,15 +1352,15 @@
// Naughty! Alpha planes are supposed to be full range. Correct that here.
avifImageCopyDecoderAlpha(decoder->image);
if (avifImageUsesU16(decoder->image)) {
- for (int j = 0; j < decoder->image->height; ++j) {
- for (int i = 0; i < decoder->image->height; ++i) {
+ for (uint32_t j = 0; j < decoder->image->height; ++j) {
+ for (uint32_t i = 0; i < decoder->image->height; ++i) {
uint16_t * alpha = (uint16_t *)&decoder->image->alphaPlane[(i * 2) + (j * decoder->image->alphaRowBytes)];
*alpha = (uint16_t)avifLimitedToFullY(decoder->image->depth, *alpha);
}
}
} else {
- for (int j = 0; j < decoder->image->height; ++j) {
- for (int i = 0; i < decoder->image->height; ++i) {
+ for (uint32_t j = 0; j < decoder->image->height; ++j) {
+ for (uint32_t i = 0; i < decoder->image->height; ++i) {
uint8_t * alpha = &decoder->image->alphaPlane[i + (j * decoder->image->alphaRowBytes)];
*alpha = (uint8_t)avifLimitedToFullY(decoder->image->depth, *alpha);
}
diff --git a/src/reformat.c b/src/reformat.c
index beab6f9..f0bbd15 100644
--- a/src/reformat.c
+++ b/src/reformat.c
@@ -75,8 +75,8 @@
uint32_t * rgbRowBytes = image->rgbRowBytes;
uint8_t ** yuvPlanes = image->yuvPlanes;
uint32_t * yuvRowBytes = image->yuvRowBytes;
- for (int outerJ = 0; outerJ < image->height; outerJ += 2) {
- for (int outerI = 0; outerI < image->width; outerI += 2) {
+ for (uint32_t outerJ = 0; outerJ < image->height; outerJ += 2) {
+ for (uint32_t outerI = 0; outerI < image->width; outerI += 2) {
int blockW = 2, blockH = 2;
if ((outerI + 1) >= image->width) {
blockW = 1;
@@ -219,8 +219,8 @@
float maxChannel = (float)((1 << image->depth) - 1);
uint8_t ** rgbPlanes = image->rgbPlanes;
uint32_t * rgbRowBytes = image->rgbRowBytes;
- for (int j = 0; j < image->height; ++j) {
- for (int i = 0; i < image->width; ++i) {
+ for (uint32_t j = 0; j < image->height; ++j) {
+ for (uint32_t i = 0; i < image->width; ++i) {
// Unpack YUV into unorm
int uvI = i >> state.formatInfo.chromaShiftX;
int uvJ = j >> state.formatInfo.chromaShiftY;
diff --git a/src/stream.c b/src/stream.c
index 826d4a1..8eb7edc 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -240,7 +240,7 @@
makeRoom(stream, headerSize);
memset(stream->raw->data + stream->offset, 0, headerSize);
if (version != -1) {
- stream->raw->data[stream->offset + 8] = version;
+ stream->raw->data[stream->offset + 8] = (uint8_t)version;
}
uint32_t noSize = avifNTOHL((uint32_t)(headerSize + contentSize));
memcpy(stream->raw->data + stream->offset, &noSize, sizeof(uint32_t));
diff --git a/src/write.c b/src/write.c
index 8bfced6..4d4a79c 100644
--- a/src/write.c
+++ b/src/write.c
@@ -271,10 +271,10 @@
}
avifBoxMarker pixiC = avifStreamWriteBox(&s, "pixi", 0, 0);
- avifStreamWriteU8(&s, 3); // unsigned int (8) num_channels;
- avifStreamWriteU8(&s, image->depth); // unsigned int (8) bits_per_channel;
- avifStreamWriteU8(&s, image->depth); // unsigned int (8) bits_per_channel;
- avifStreamWriteU8(&s, image->depth); // unsigned int (8) bits_per_channel;
+ avifStreamWriteU8(&s, 3); // unsigned int (8) num_channels;
+ avifStreamWriteU8(&s, (uint8_t)image->depth); // unsigned int (8) bits_per_channel;
+ avifStreamWriteU8(&s, (uint8_t)image->depth); // unsigned int (8) bits_per_channel;
+ avifStreamWriteU8(&s, (uint8_t)image->depth); // unsigned int (8) bits_per_channel;
avifStreamFinishBox(&s, pixiC);
++ipcoIndex;
ipmaPush(&ipmaColor, ipcoIndex);
@@ -287,8 +287,8 @@
if (hasAlpha) {
avifBoxMarker pixiA = avifStreamWriteBox(&s, "pixi", 0, 0);
- avifStreamWriteU8(&s, 1); // unsigned int (8) num_channels;
- avifStreamWriteU8(&s, image->depth); // unsigned int (8) bits_per_channel;
+ avifStreamWriteU8(&s, 1); // unsigned int (8) num_channels;
+ avifStreamWriteU8(&s, (uint8_t)image->depth); // unsigned int (8) bits_per_channel;
avifStreamFinishBox(&s, pixiA);
++ipcoIndex;
ipmaPush(&ipmaAlpha, ipcoIndex);
@@ -395,8 +395,8 @@
int maxChannel = (1 << image->depth) - 1;
if (avifImageUsesU16(image)) {
- for (int j = 0; j < image->height; ++j) {
- for (int i = 0; i < image->width; ++i) {
+ for (uint32_t j = 0; j < image->height; ++j) {
+ for (uint32_t i = 0; i < image->width; ++i) {
uint16_t * p = (uint16_t *)&image->alphaPlane[(i * 2) + (j * image->alphaRowBytes)];
if (*p != maxChannel) {
return AVIF_FALSE;
@@ -404,8 +404,8 @@
}
}
} else {
- for (int j = 0; j < image->height; ++j) {
- for (int i = 0; i < image->width; ++i) {
+ for (uint32_t j = 0; j < image->height; ++j) {
+ for (uint32_t i = 0; i < image->width; ++i) {
if (image->alphaPlane[i + (j * image->alphaRowBytes)] != maxChannel) {
return AVIF_FALSE;
}