Print warnings on ignored clap,irot,imir (#2564)
diff --git a/apps/avifdec.c b/apps/avifdec.c index 1a6006d..f79c31f 100644 --- a/apps/avifdec.c +++ b/apps/avifdec.c
@@ -376,7 +376,7 @@ goto cleanup; } else if (outputFormat == AVIF_APP_FILE_FORMAT_Y4M) { if (decoder->image->icc.size || decoder->image->exif.size || decoder->image->xmp.size) { - printf("Warning: metadata dropped when saving to y4m.\n"); + fprintf(stderr, "Warning: metadata dropped when saving to y4m.\n"); } if (!y4mWrite(outputFilename, decoder->image)) { goto cleanup;
diff --git a/apps/shared/avifjpeg.c b/apps/shared/avifjpeg.c index de0aa7f..5e10d11 100644 --- a/apps/shared/avifjpeg.c +++ b/apps/shared/avifjpeg.c
@@ -1297,6 +1297,21 @@ write_icc_profile(&cinfo, avif->icc.data, (unsigned int)avif->icc.size); } + if (avif->transformFlags & AVIF_TRANSFORM_CLAP) { + avifCropRect cropRect; + avifDiagnostics diag; + if (avifCropRectConvertCleanApertureBox(&cropRect, &avif->clap, avif->width, avif->height, avif->yuvFormat, &diag) && + (cropRect.x != 0 || cropRect.y != 0 || cropRect.width != avif->width || cropRect.height != avif->height)) { + // TODO: https://github.com/AOMediaCodec/libavif/issues/2427 - Implement. + fprintf(stderr, + "Warning: Clean Aperture values were ignored, the output image was NOT cropped to rectangle {%u,%u,%u,%u}\n", + cropRect.x, + cropRect.y, + cropRect.width, + cropRect.height); + } + } + if (avif->exif.data && (avif->exif.size > 0)) { size_t exifTiffHeaderOffset; avifResult result = avifGetExifTiffHeaderOffset(avif->exif.data, avif->exif.size, &exifTiffHeaderOffset); @@ -1337,7 +1352,10 @@ avifRWDataFree(&exif); } else if (avifImageGetExifOrientationFromIrotImir(avif) != 1) { // There is no Exif yet, but we need to store the orientation. - // TODO(yguyon): Add a valid Exif payload or rotate the samples. + // TODO: https://github.com/AOMediaCodec/libavif/issues/2427 - Add a valid Exif payload or rotate the samples. + fprintf(stderr, + "Warning: Orientation %u was ignored, the output image was NOT rotated or mirrored\n", + avifImageGetExifOrientationFromIrotImir(avif)); } if (avif->xmp.data && (avif->xmp.size > 0)) {
diff --git a/apps/shared/avifpng.c b/apps/shared/avifpng.c index c2f8a47..cb630bf 100644 --- a/apps/shared/avifpng.c +++ b/apps/shared/avifpng.c
@@ -727,8 +727,26 @@ rowPointers[y] = row; row += rowBytes; } + + if (avif->transformFlags & AVIF_TRANSFORM_CLAP) { + avifCropRect cropRect; + avifDiagnostics diag; + if (avifCropRectConvertCleanApertureBox(&cropRect, &avif->clap, avif->width, avif->height, avif->yuvFormat, &diag) && + (cropRect.x != 0 || cropRect.y != 0 || cropRect.width != avif->width || cropRect.height != avif->height)) { + // TODO: https://github.com/AOMediaCodec/libavif/issues/2427 - Implement. + fprintf(stderr, + "Warning: Clean Aperture values were ignored, the output image was NOT cropped to rectangle {%u,%u,%u,%u}\n", + cropRect.x, + cropRect.y, + cropRect.width, + cropRect.height); + } + } if (avifImageGetExifOrientationFromIrotImir(avif) != 1) { - // TODO(yguyon): Rotate the samples. + // TODO: https://github.com/AOMediaCodec/libavif/issues/2427 - Rotate the samples. + fprintf(stderr, + "Warning: Orientation %u was ignored, the output image was NOT rotated or mirrored\n", + avifImageGetExifOrientationFromIrotImir(avif)); } if (rgbDepth > 8) {
diff --git a/apps/shared/y4m.c b/apps/shared/y4m.c index afdb59f..f569122 100644 --- a/apps/shared/y4m.c +++ b/apps/shared/y4m.c
@@ -13,6 +13,7 @@ #include <string.h> #include "avif/avif.h" +#include "avifexif.h" #include "avifutil.h" #define Y4M_MAX_LINE_SIZE 2048 // Arbitrary limit. Y4M headers should be much smaller than this @@ -492,6 +493,27 @@ fprintf(stderr, "WARNING: writing alpha is currently only supported in 8bpc YUV444, ignoring alpha channel: %s\n", outputFilename); } + if (avif->transformFlags & AVIF_TRANSFORM_CLAP) { + avifCropRect cropRect; + avifDiagnostics diag; + if (avifCropRectConvertCleanApertureBox(&cropRect, &avif->clap, avif->width, avif->height, avif->yuvFormat, &diag) && + (cropRect.x != 0 || cropRect.y != 0 || cropRect.width != avif->width || cropRect.height != avif->height)) { + // TODO: https://github.com/AOMediaCodec/libavif/issues/2427 - Implement. + fprintf(stderr, + "Warning: Clean Aperture values were ignored, the output image was NOT cropped to rectangle {%u,%u,%u,%u}\n", + cropRect.x, + cropRect.y, + cropRect.width, + cropRect.height); + } + } + if (avifImageGetExifOrientationFromIrotImir(avif) != 1) { + // TODO: https://github.com/AOMediaCodec/libavif/issues/2427 - Rotate the samples. + fprintf(stderr, + "Warning: Orientation %u was ignored, the output image was NOT rotated or mirrored\n", + avifImageGetExifOrientationFromIrotImir(avif)); + } + switch (avif->depth) { case 8: switch (avif->yuvFormat) {