Rename flags to chromaDownsampling,chromaUpsampling
Fix avifenc --sharpyuv.
diff --git a/apps/avifdec.c b/apps/avifdec.c
index 004f681..a0a0251 100644
--- a/apps/avifdec.c
+++ b/apps/avifdec.c
@@ -62,7 +62,7 @@
int pngCompressionLevel = -1; // -1 is a sentinel to avifPNGWrite() to skip calling png_set_compression_level()
avifCodecChoice codecChoice = AVIF_CODEC_CHOICE_AUTO;
avifBool infoOnly = AVIF_FALSE;
- avifChromaUpsampling upsamplingFlags = AVIF_CHROMA_UPSAMPLING_AUTOMATIC;
+ avifChromaUpsampling chromaUpsampling = AVIF_CHROMA_UPSAMPLING_AUTOMATIC;
avifBool ignoreICC = AVIF_FALSE;
avifBool rawColor = AVIF_FALSE;
avifBool allowProgressive = AVIF_FALSE;
@@ -153,15 +153,15 @@
} else if (!strcmp(arg, "-u") || !strcmp(arg, "--upsampling")) {
NEXTARG();
if (!strcmp(arg, "automatic")) {
- upsamplingFlags = AVIF_CHROMA_UPSAMPLING_AUTOMATIC;
+ chromaUpsampling = AVIF_CHROMA_UPSAMPLING_AUTOMATIC;
} else if (!strcmp(arg, "fastest")) {
- upsamplingFlags = AVIF_CHROMA_UPSAMPLING_FASTEST;
+ chromaUpsampling = AVIF_CHROMA_UPSAMPLING_FASTEST;
} else if (!strcmp(arg, "best")) {
- upsamplingFlags = AVIF_CHROMA_UPSAMPLING_BEST_QUALITY;
+ chromaUpsampling = AVIF_CHROMA_UPSAMPLING_BEST_QUALITY;
} else if (!strcmp(arg, "nearest")) {
- upsamplingFlags = AVIF_CHROMA_UPSAMPLING_NEAREST;
+ chromaUpsampling = AVIF_CHROMA_UPSAMPLING_NEAREST;
} else if (!strcmp(arg, "bilinear")) {
- upsamplingFlags = AVIF_CHROMA_UPSAMPLING_BILINEAR;
+ chromaUpsampling = AVIF_CHROMA_UPSAMPLING_BILINEAR;
} else {
fprintf(stderr, "ERROR: invalid upsampling: %s\n", arg);
return 1;
@@ -347,11 +347,11 @@
if (rawColor) {
decoder->image->alphaPremultiplied = AVIF_TRUE;
}
- if (!avifJPEGWrite(outputFilename, decoder->image, jpegQuality, upsamplingFlags)) {
+ if (!avifJPEGWrite(outputFilename, decoder->image, jpegQuality, chromaUpsampling)) {
returnCode = 1;
}
} else if (outputFormat == AVIF_APP_FILE_FORMAT_PNG) {
- if (!avifPNGWrite(outputFilename, decoder->image, requestedDepth, upsamplingFlags, pngCompressionLevel)) {
+ if (!avifPNGWrite(outputFilename, decoder->image, requestedDepth, chromaUpsampling, pngCompressionLevel)) {
returnCode = 1;
}
} else {
diff --git a/apps/avifenc.c b/apps/avifenc.c
index 84fbd8b..f0566b0 100644
--- a/apps/avifenc.c
+++ b/apps/avifenc.c
@@ -266,7 +266,7 @@
avifImage * image,
uint32_t * outDepth,
avifAppSourceTiming * sourceTiming,
- avifChromaDownsampling flags)
+ avifChromaDownsampling chromaDownsampling)
{
if (sourceTiming) {
// A source timing of all 0s is a sentinel value hinting that the value is unset / should be
@@ -293,7 +293,7 @@
const avifAppFileFormat nextInputFormat = avifReadImage(input->files[input->fileIndex].filename,
input->requestedFormat,
input->requestedDepth,
- flags,
+ chromaDownsampling,
ignoreICC,
ignoreExif,
ignoreXMP,
@@ -484,7 +484,7 @@
avifColorPrimaries colorPrimaries = AVIF_COLOR_PRIMARIES_UNSPECIFIED;
avifTransferCharacteristics transferCharacteristics = AVIF_TRANSFER_CHARACTERISTICS_UNSPECIFIED;
avifMatrixCoefficients matrixCoefficients = AVIF_MATRIX_COEFFICIENTS_BT601;
- avifChromaDownsampling flags = AVIF_CHROMA_DOWNSAMPLING_AUTOMATIC;
+ avifChromaDownsampling chromaDownsampling = AVIF_CHROMA_DOWNSAMPLING_AUTOMATIC;
int argIndex = 1;
while (argIndex < argc) {
@@ -789,7 +789,7 @@
} else if (!strcmp(arg, "-p") || !strcmp(arg, "--premultiply")) {
premultiplyAlpha = AVIF_TRUE;
} else if (!strcmp(arg, "--sharpyuv")) {
- flags |= AVIF_CHROMA_DOWNSAMPLING_SHARP_YUV;
+ chromaDownsampling = AVIF_CHROMA_DOWNSAMPLING_SHARP_YUV;
} else if (arg[0] == '-') {
fprintf(stderr, "ERROR: unrecognized option %s\n\n", arg);
syntax();
@@ -854,7 +854,7 @@
uint32_t sourceDepth = 0;
avifAppSourceTiming firstSourceTiming;
avifAppFileFormat inputFormat =
- avifInputReadImage(&input, ignoreICC, ignoreExif, ignoreXMP, image, &sourceDepth, &firstSourceTiming, flags);
+ avifInputReadImage(&input, ignoreICC, ignoreExif, ignoreXMP, image, &sourceDepth, &firstSourceTiming, chromaDownsampling);
if (inputFormat == AVIF_APP_FILE_FORMAT_UNKNOWN) {
fprintf(stderr, "Cannot determine input file format: %s\n", firstFile->filename);
returnCode = 1;
@@ -1062,7 +1062,7 @@
gridCells[gridCellIndex] = cellImage;
avifAppFileFormat nextInputFormat =
- avifInputReadImage(&input, ignoreICC, ignoreExif, ignoreXMP, cellImage, NULL, NULL, flags);
+ avifInputReadImage(&input, ignoreICC, ignoreExif, ignoreXMP, cellImage, NULL, NULL, chromaDownsampling);
if (nextInputFormat == AVIF_APP_FILE_FORMAT_UNKNOWN) {
returnCode = 1;
goto cleanup;
@@ -1221,7 +1221,7 @@
nextImage->alphaPremultiplied = image->alphaPremultiplied;
avifAppFileFormat nextInputFormat =
- avifInputReadImage(&input, ignoreICC, ignoreExif, ignoreXMP, nextImage, NULL, NULL, flags);
+ avifInputReadImage(&input, ignoreICC, ignoreExif, ignoreXMP, nextImage, NULL, NULL, chromaDownsampling);
if (nextInputFormat == AVIF_APP_FILE_FORMAT_UNKNOWN) {
returnCode = 1;
goto cleanup;
diff --git a/apps/shared/avifjpeg.c b/apps/shared/avifjpeg.c
index b20399e..29d915e 100644
--- a/apps/shared/avifjpeg.c
+++ b/apps/shared/avifjpeg.c
@@ -243,7 +243,7 @@
avifImage * avif,
avifPixelFormat requestedFormat,
uint32_t requestedDepth,
- avifChromaDownsampling flags,
+ avifChromaDownsampling chromaDownsampling,
avifBool ignoreICC,
avifBool ignoreExif,
avifBool ignoreXMP)
@@ -318,7 +318,7 @@
avif->depth = requestedDepth ? requestedDepth : 8;
avifRGBImageSetDefaults(&rgb, avif);
rgb.format = AVIF_RGB_FORMAT_RGB;
- rgb.chromaDownsampling = flags;
+ rgb.chromaDownsampling = chromaDownsampling;
rgb.depth = 8;
avifRGBImageAllocatePixels(&rgb);
@@ -384,7 +384,7 @@
return ret;
}
-avifBool avifJPEGWrite(const char * outputFilename, const avifImage * avif, int jpegQuality, avifChromaUpsampling flags)
+avifBool avifJPEGWrite(const char * outputFilename, const avifImage * avif, int jpegQuality, avifChromaUpsampling chromaUpsampling)
{
avifBool ret = AVIF_FALSE;
FILE * f = NULL;
@@ -398,7 +398,7 @@
avifRGBImage rgb;
avifRGBImageSetDefaults(&rgb, avif);
rgb.format = AVIF_RGB_FORMAT_RGB;
- rgb.chromaUpsampling = flags;
+ rgb.chromaUpsampling = chromaUpsampling;
rgb.depth = 8;
avifRGBImageAllocatePixels(&rgb);
if (avifImageYUVToRGB(avif, &rgb) != AVIF_RESULT_OK) {
diff --git a/apps/shared/avifjpeg.h b/apps/shared/avifjpeg.h
index 6611063..63c84c6 100644
--- a/apps/shared/avifjpeg.h
+++ b/apps/shared/avifjpeg.h
@@ -14,11 +14,11 @@
avifImage * avif,
avifPixelFormat requestedFormat,
uint32_t requestedDepth,
- avifChromaDownsampling flags,
+ avifChromaDownsampling chromaDownsampling,
avifBool ignoreICC,
avifBool ignoreExif,
avifBool ignoreXMP);
-avifBool avifJPEGWrite(const char * outputFilename, const avifImage * avif, int jpegQuality, avifChromaUpsampling flags);
+avifBool avifJPEGWrite(const char * outputFilename, const avifImage * avif, int jpegQuality, avifChromaUpsampling chromaUpsampling);
#ifdef __cplusplus
} // extern "C"
diff --git a/apps/shared/avifpng.c b/apps/shared/avifpng.c
index 9512585..90358ac 100644
--- a/apps/shared/avifpng.c
+++ b/apps/shared/avifpng.c
@@ -207,7 +207,7 @@
avifImage * avif,
avifPixelFormat requestedFormat,
uint32_t requestedDepth,
- avifChromaDownsampling flags,
+ avifChromaDownsampling chromaDownsampling,
avifBool ignoreICC,
avifBool ignoreExif,
avifBool ignoreXMP,
@@ -330,7 +330,7 @@
}
avifRGBImageSetDefaults(&rgb, avif);
- rgb.chromaDownsampling = flags;
+ rgb.chromaDownsampling = chromaDownsampling;
rgb.depth = imgBitDepth;
avifRGBImageAllocatePixels(&rgb);
rowPointers = (png_bytep *)malloc(sizeof(png_bytep) * rgb.height);
@@ -370,7 +370,7 @@
return readResult;
}
-avifBool avifPNGWrite(const char * outputFilename, const avifImage * avif, uint32_t requestedDepth, avifChromaUpsampling flags, int compressionLevel)
+avifBool avifPNGWrite(const char * outputFilename, const avifImage * avif, uint32_t requestedDepth, avifChromaUpsampling chromaUpsampling, int compressionLevel)
{
volatile avifBool writeResult = AVIF_FALSE;
png_structp png = NULL;
@@ -391,7 +391,7 @@
}
avifRGBImageSetDefaults(&rgb, avif);
- rgb.chromaUpsampling = flags;
+ rgb.chromaUpsampling = chromaUpsampling;
rgb.depth = rgbDepth;
int colorType = PNG_COLOR_TYPE_RGBA;
if (!avif->alphaPlane) {
diff --git a/apps/shared/avifpng.h b/apps/shared/avifpng.h
index cd52e29..5d1e7f4 100644
--- a/apps/shared/avifpng.h
+++ b/apps/shared/avifpng.h
@@ -15,12 +15,16 @@
avifImage * avif,
avifPixelFormat requestedFormat,
uint32_t requestedDepth,
- avifChromaDownsampling flags,
+ avifChromaDownsampling chromaDownsampling,
avifBool ignoreICC,
avifBool ignoreExif,
avifBool ignoreXMP,
uint32_t * outPNGDepth);
-avifBool avifPNGWrite(const char * outputFilename, const avifImage * avif, uint32_t requestedDepth, avifChromaUpsampling flags, int compressionLevel);
+avifBool avifPNGWrite(const char * outputFilename,
+ const avifImage * avif,
+ uint32_t requestedDepth,
+ avifChromaUpsampling chromaUpsampling,
+ int compressionLevel);
#ifdef __cplusplus
} // extern "C"
diff --git a/apps/shared/avifutil.c b/apps/shared/avifutil.c
index 7d2db88..4989885 100644
--- a/apps/shared/avifutil.c
+++ b/apps/shared/avifutil.c
@@ -227,7 +227,7 @@
avifAppFileFormat avifReadImage(const char * filename,
avifPixelFormat requestedFormat,
int requestedDepth,
- avifChromaDownsampling flags,
+ avifChromaDownsampling chromaDownsampling,
avifBool ignoreICC,
avifBool ignoreExif,
avifBool ignoreXMP,
@@ -245,14 +245,14 @@
*outDepth = image->depth;
}
} else if (format == AVIF_APP_FILE_FORMAT_JPEG) {
- if (!avifJPEGRead(filename, image, requestedFormat, requestedDepth, flags, ignoreICC, ignoreExif, ignoreXMP)) {
+ if (!avifJPEGRead(filename, image, requestedFormat, requestedDepth, chromaDownsampling, ignoreICC, ignoreExif, ignoreXMP)) {
return AVIF_APP_FILE_FORMAT_UNKNOWN;
}
if (outDepth) {
*outDepth = 8;
}
} else if (format == AVIF_APP_FILE_FORMAT_PNG) {
- if (!avifPNGRead(filename, image, requestedFormat, requestedDepth, flags, ignoreICC, ignoreExif, ignoreXMP, outDepth)) {
+ if (!avifPNGRead(filename, image, requestedFormat, requestedDepth, chromaDownsampling, ignoreICC, ignoreExif, ignoreXMP, outDepth)) {
return AVIF_APP_FILE_FORMAT_UNKNOWN;
}
} else {
diff --git a/apps/shared/avifutil.h b/apps/shared/avifutil.h
index d6da3fe..29a2bc2 100644
--- a/apps/shared/avifutil.h
+++ b/apps/shared/avifutil.h
@@ -63,7 +63,7 @@
avifAppFileFormat avifReadImage(const char * filename,
avifPixelFormat requestedFormat,
int requestedDepth,
- avifChromaDownsampling flags,
+ avifChromaDownsampling chromaDownsampling,
avifBool ignoreICC,
avifBool ignoreExif,
avifBool ignoreXMP,
diff --git a/tests/gtest/aviftest_helpers.cc b/tests/gtest/aviftest_helpers.cc
index 701c46f..28c14b8 100644
--- a/tests/gtest/aviftest_helpers.cc
+++ b/tests/gtest/aviftest_helpers.cc
@@ -238,14 +238,15 @@
AvifImagePtr ReadImage(const char* folder_path, const char* file_name,
avifPixelFormat requested_format, int requested_depth,
- avifChromaDownsampling flags, avifBool ignore_icc,
- avifBool ignore_exif, avifBool ignore_xmp) {
+ avifChromaDownsampling chromaDownsampling,
+ avifBool ignore_icc, avifBool ignore_exif,
+ avifBool ignore_xmp) {
testutil::AvifImagePtr image(avifImageCreateEmpty(), avifImageDestroy);
if (!image ||
avifReadImage((std::string(folder_path) + file_name).c_str(),
- requested_format, requested_depth, flags, ignore_icc,
- ignore_exif, ignore_xmp, image.get(), /*outDepth=*/nullptr,
- /*sourceTiming=*/nullptr,
+ requested_format, requested_depth, chromaDownsampling,
+ ignore_icc, ignore_exif, ignore_xmp, image.get(),
+ /*outDepth=*/nullptr, /*sourceTiming=*/nullptr,
/*frameIter=*/nullptr) == AVIF_APP_FILE_FORMAT_UNKNOWN) {
return {nullptr, nullptr};
}
diff --git a/tests/gtest/aviftest_helpers.h b/tests/gtest/aviftest_helpers.h
index 556b244..6ad9d12 100644
--- a/tests/gtest/aviftest_helpers.h
+++ b/tests/gtest/aviftest_helpers.h
@@ -78,7 +78,8 @@
const char* folder_path, const char* file_name,
avifPixelFormat requested_format = AVIF_PIXEL_FORMAT_NONE,
int requested_depth = 0,
- avifChromaDownsampling flags = AVIF_CHROMA_DOWNSAMPLING_AUTOMATIC,
+ avifChromaDownsampling chromaDownsampling =
+ AVIF_CHROMA_DOWNSAMPLING_AUTOMATIC,
avifBool ignore_icc = false, avifBool ignore_exif = false,
avifBool ignore_xmp = false);
diff --git a/tests/oss-fuzz/avif_decode_fuzzer.cc b/tests/oss-fuzz/avif_decode_fuzzer.cc
index ba3f924..4189014 100644
--- a/tests/oss-fuzz/avif_decode_fuzzer.cc
+++ b/tests/oss-fuzz/avif_decode_fuzzer.cc
@@ -8,8 +8,8 @@
static avifRGBFormat rgbFormats[] = { AVIF_RGB_FORMAT_RGB, AVIF_RGB_FORMAT_RGBA };
static size_t rgbFormatsCount = sizeof(rgbFormats) / sizeof(rgbFormats[0]);
- static avifChromaUpsampling upsamplingFlags[] = { AVIF_CHROMA_UPSAMPLING_BILINEAR, AVIF_CHROMA_UPSAMPLING_NEAREST };
- static size_t upsamplingFlagsCount = sizeof(upsamplingFlags) / sizeof(upsamplingFlags[0]);
+ static avifChromaUpsampling chromaUpsamplings[] = { AVIF_CHROMA_UPSAMPLING_BILINEAR, AVIF_CHROMA_UPSAMPLING_NEAREST };
+ static size_t chromaUpsamplingCount = sizeof(chromaUpsamplings) / sizeof(chromaUpsamplings[0]);
static uint32_t rgbDepths[] = { 8, 10 };
static size_t rgbDepthsCount = sizeof(rgbDepths) / sizeof(rgbDepths[0]);
@@ -43,18 +43,18 @@
avifRGBImageSetDefaults(&rgb, decoder->image);
for (size_t rgbFormatsIndex = 0; rgbFormatsIndex < rgbFormatsCount; ++rgbFormatsIndex) {
- for (size_t upsamplingFlagsIndex = 0; upsamplingFlagsIndex < upsamplingFlagsCount; ++upsamplingFlagsIndex) {
+ for (size_t chromaUpsamplingIndex = 0; chromaUpsamplingIndex < chromaUpsamplingCount; ++chromaUpsamplingIndex) {
for (size_t rgbDepthsIndex = 0; rgbDepthsIndex < rgbDepthsCount; ++rgbDepthsIndex) {
// Convert to RGB
rgb.format = rgbFormats[rgbFormatsIndex];
- rgb.chromaUpsampling = upsamplingFlags[upsamplingFlagsIndex];
+ rgb.chromaUpsampling = chromaUpsamplings[chromaUpsamplingIndex];
rgb.avoidLibYUV = AVIF_TRUE;
rgb.depth = rgbDepths[rgbDepthsIndex];
avifRGBImageAllocatePixels(&rgb);
avifResult rgbResult = avifImageYUVToRGB(decoder->image, &rgb);
- // Since avifImageRGBToYUV() ignores upsamplingFlags, we only need
- // to test avifImageRGBToYUV() with a single upsamplingFlagsIndex.
- if ((rgbResult == AVIF_RESULT_OK) && (upsamplingFlagsIndex == 0)) {
+ // Since avifImageRGBToYUV() ignores chromaUpsamplings, we only need
+ // to test avifImageRGBToYUV() with a single chromaUpsamplingIndex.
+ if ((rgbResult == AVIF_RESULT_OK) && (chromaUpsamplingIndex == 0)) {
for (size_t yuvDepthsIndex = 0; yuvDepthsIndex < yuvDepthsCount; ++yuvDepthsIndex) {
// ... and back to YUV
avifImage * tempImage = avifImageCreate(decoder->image->width,