From 7db1d05369f7f1e465481aafea839579449089ed Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Wed, 11 Mar 2020 09:35:25 +0100 Subject: [PATCH 1/8] apps:avifpng: Remove unused variable hasAlpha (#109) apps/shared/avifpng.c: In function 'avifPNGRead': apps/shared/avifpng.c:80:14: error: variable 'hasAlpha' set but not used [-Werror=unused-but-set-variable] avifBool hasAlpha = AVIF_FALSE; ^~~~~~~~ Signed-off-by: Andreas Schneider --- apps/shared/avifpng.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/shared/avifpng.c b/apps/shared/avifpng.c index a14468011d..b34e361eaa 100644 --- a/apps/shared/avifpng.c +++ b/apps/shared/avifpng.c @@ -77,10 +77,8 @@ avifBool avifPNGRead(avifImage * avif, const char * inputFilename, avifPixelForm png_set_expand_gray_1_2_4_to_8(png); } - avifBool hasAlpha = AVIF_FALSE; if (png_get_valid(png, info, PNG_INFO_tRNS)) { png_set_tRNS_to_alpha(png); - hasAlpha = AVIF_TRUE; } if ((rawColorType == PNG_COLOR_TYPE_RGB) || (rawColorType == PNG_COLOR_TYPE_GRAY) || (rawColorType == PNG_COLOR_TYPE_PALETTE)) { From cbfab6b90932383ff7a4111e33b25f76935df666 Mon Sep 17 00:00:00 2001 From: wantehchang Date: Wed, 11 Mar 2020 11:53:53 -0700 Subject: [PATCH 2/8] Minor cleanup of avifEncoderWrite(). (#110) 1. Delete the comnent "Reformat pixels, if need be" because the RGB-to-YUV conversion code is gone. Replace it with the comment "Validate image". 2. Return AVIF_RESULT_NO_YUV_FORMAT_SELECTED if image->yuvFormat is AVIF_PIXEL_FORMAT_NONE. This is the error code returned by the original code (before v0.6.0). --- src/write.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/write.c b/src/write.c index bef902da39..c5a7d33b3b 100644 --- a/src/write.c +++ b/src/write.c @@ -116,13 +116,18 @@ avifResult avifEncoderWrite(avifEncoder * encoder, avifImage * image, avifRWData avifRWStreamStart(&s, output); // ----------------------------------------------------------------------- - // Reformat pixels, if need be + // Validate image - if (!image->width || !image->height || (image->yuvFormat == AVIF_PIXEL_FORMAT_NONE) || !image->yuvPlanes[AVIF_CHAN_Y]) { + if (!image->width || !image->height || !image->yuvPlanes[AVIF_CHAN_Y]) { result = AVIF_RESULT_NO_CONTENT; goto writeCleanup; } + if (image->yuvFormat == AVIF_PIXEL_FORMAT_NONE) { + result = AVIF_RESULT_NO_YUV_FORMAT_SELECTED; + goto writeCleanup; + } + // ----------------------------------------------------------------------- // Encode AV1 OBUs From e5003b1a01c3dd66752278d185df6abf1b020f93 Mon Sep 17 00:00:00 2001 From: Joe Drago Date: Wed, 11 Mar 2020 12:50:08 -0700 Subject: [PATCH 3/8] GitHub automatic deployment (EwoutH) --- appveyor.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index 250fad8960..816cf90393 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -48,3 +48,11 @@ artifacts: name: Static Lib and Includes - path: 'build\*.exe' name: Basic apps + +deploy: + - provider: GitHub + auth_token: + secure: 'DlFHAFoK4/3O5jgutXxPMsYfXftRiazS2GUh171hpDTQerLgfhhpQ+pjQ3sWiiBy' + prerelease: true + on: + appveyor_repo_tag: true From 79e4c6c957aa90d7b7d8e46239ce9af40136b4c8 Mon Sep 17 00:00:00 2001 From: Joe Drago Date: Wed, 11 Mar 2020 13:36:31 -0700 Subject: [PATCH 4/8] Preallocate rowPointers in PNG code to avoid -Wclobbered errors --- apps/shared/avifpng.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/apps/shared/avifpng.c b/apps/shared/avifpng.c index b34e361eaa..5ce5177771 100644 --- a/apps/shared/avifpng.c +++ b/apps/shared/avifpng.c @@ -14,7 +14,7 @@ avifBool avifPNGRead(avifImage * avif, const char * inputFilename, avifPixelForm avifBool readResult = AVIF_FALSE; png_structp png = NULL; png_infop info = NULL; - png_bytep * rowPointers = NULL; + png_bytep * rowPointers = (png_bytep *)malloc(sizeof(png_bytep) * avif->height); avifRGBImage rgb; memset(&rgb, 0, sizeof(avifRGBImage)); @@ -112,7 +112,6 @@ avifBool avifPNGRead(avifImage * avif, const char * inputFilename, avifPixelForm avifRGBImageSetDefaults(&rgb, avif); rgb.depth = imgBitDepth; avifRGBImageAllocatePixels(&rgb); - rowPointers = (png_bytep *)malloc(sizeof(png_bytep) * rgb.height); for (uint32_t y = 0; y < rgb.height; ++y) { rowPointers[y] = &rgb.pixels[y * rgb.rowBytes]; } @@ -127,9 +126,7 @@ avifBool avifPNGRead(avifImage * avif, const char * inputFilename, avifPixelForm if (png) { png_destroy_read_struct(&png, &info, NULL); } - if (rowPointers) { - free(rowPointers); - } + free(rowPointers); avifRGBImageFreePixels(&rgb); return readResult; } @@ -139,7 +136,7 @@ avifBool avifPNGWrite(avifImage * avif, const char * outputFilename, int request avifBool writeResult = AVIF_FALSE; png_structp png = NULL; png_infop info = NULL; - png_bytep * rowPointers = NULL; + png_bytep * rowPointers = (png_bytep *)malloc(sizeof(png_bytep) * avif->height); avifRGBImage rgb; memset(&rgb, 0, sizeof(avifRGBImage)); @@ -192,7 +189,6 @@ avifBool avifPNGWrite(avifImage * avif, const char * outputFilename, int request rgb.depth = rgbDepth; avifRGBImageAllocatePixels(&rgb); avifImageYUVToRGB(avif, &rgb); - rowPointers = (png_bytep *)malloc(sizeof(png_bytep) * rgb.height); for (uint32_t y = 0; y < rgb.height; ++y) { rowPointers[y] = &rgb.pixels[y * rgb.rowBytes]; } @@ -208,9 +204,7 @@ avifBool avifPNGWrite(avifImage * avif, const char * outputFilename, int request if (png) { png_destroy_write_struct(&png, &info); } - if (rowPointers) { - free(rowPointers); - } + free(rowPointers); avifRGBImageFreePixels(&rgb); return writeResult; } From fe92047bf0bb71ca4378364bfc55bf6f7a2ce14c Mon Sep 17 00:00:00 2001 From: Joe Drago Date: Wed, 11 Mar 2020 14:07:19 -0700 Subject: [PATCH 5/8] Revert "Preallocate rowPointers in PNG code to avoid -Wclobbered errors" This reverts commit 79e4c6c957aa90d7b7d8e46239ce9af40136b4c8. --- apps/shared/avifpng.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/apps/shared/avifpng.c b/apps/shared/avifpng.c index 5ce5177771..b34e361eaa 100644 --- a/apps/shared/avifpng.c +++ b/apps/shared/avifpng.c @@ -14,7 +14,7 @@ avifBool avifPNGRead(avifImage * avif, const char * inputFilename, avifPixelForm avifBool readResult = AVIF_FALSE; png_structp png = NULL; png_infop info = NULL; - png_bytep * rowPointers = (png_bytep *)malloc(sizeof(png_bytep) * avif->height); + png_bytep * rowPointers = NULL; avifRGBImage rgb; memset(&rgb, 0, sizeof(avifRGBImage)); @@ -112,6 +112,7 @@ avifBool avifPNGRead(avifImage * avif, const char * inputFilename, avifPixelForm avifRGBImageSetDefaults(&rgb, avif); rgb.depth = imgBitDepth; avifRGBImageAllocatePixels(&rgb); + rowPointers = (png_bytep *)malloc(sizeof(png_bytep) * rgb.height); for (uint32_t y = 0; y < rgb.height; ++y) { rowPointers[y] = &rgb.pixels[y * rgb.rowBytes]; } @@ -126,7 +127,9 @@ avifBool avifPNGRead(avifImage * avif, const char * inputFilename, avifPixelForm if (png) { png_destroy_read_struct(&png, &info, NULL); } - free(rowPointers); + if (rowPointers) { + free(rowPointers); + } avifRGBImageFreePixels(&rgb); return readResult; } @@ -136,7 +139,7 @@ avifBool avifPNGWrite(avifImage * avif, const char * outputFilename, int request avifBool writeResult = AVIF_FALSE; png_structp png = NULL; png_infop info = NULL; - png_bytep * rowPointers = (png_bytep *)malloc(sizeof(png_bytep) * avif->height); + png_bytep * rowPointers = NULL; avifRGBImage rgb; memset(&rgb, 0, sizeof(avifRGBImage)); @@ -189,6 +192,7 @@ avifBool avifPNGWrite(avifImage * avif, const char * outputFilename, int request rgb.depth = rgbDepth; avifRGBImageAllocatePixels(&rgb); avifImageYUVToRGB(avif, &rgb); + rowPointers = (png_bytep *)malloc(sizeof(png_bytep) * rgb.height); for (uint32_t y = 0; y < rgb.height; ++y) { rowPointers[y] = &rgb.pixels[y * rgb.rowBytes]; } @@ -204,7 +208,9 @@ avifBool avifPNGWrite(avifImage * avif, const char * outputFilename, int request if (png) { png_destroy_write_struct(&png, &info); } - free(rowPointers); + if (rowPointers) { + free(rowPointers); + } avifRGBImageFreePixels(&rgb); return writeResult; } From ade6fe69a0398366b6b6f1c82b79580b1a9dc9cb Mon Sep 17 00:00:00 2001 From: Joe Drago Date: Wed, 11 Mar 2020 14:15:56 -0700 Subject: [PATCH 6/8] Mark rowPointers as volatile to satisfy -Wclobbered --- apps/shared/avifpng.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/shared/avifpng.c b/apps/shared/avifpng.c index b34e361eaa..87dab499a3 100644 --- a/apps/shared/avifpng.c +++ b/apps/shared/avifpng.c @@ -14,7 +14,7 @@ avifBool avifPNGRead(avifImage * avif, const char * inputFilename, avifPixelForm avifBool readResult = AVIF_FALSE; png_structp png = NULL; png_infop info = NULL; - png_bytep * rowPointers = NULL; + png_bytep * volatile rowPointers = NULL; // volatile avoids -Wclobbered due to libpng's setjmp avifRGBImage rgb; memset(&rgb, 0, sizeof(avifRGBImage)); @@ -139,7 +139,7 @@ avifBool avifPNGWrite(avifImage * avif, const char * outputFilename, int request avifBool writeResult = AVIF_FALSE; png_structp png = NULL; png_infop info = NULL; - png_bytep * rowPointers = NULL; + png_bytep * volatile rowPointers = NULL; // volatile avoids -Wclobbered due to libpng's setjmp avifRGBImage rgb; memset(&rgb, 0, sizeof(avifRGBImage)); From 369c0634532fd3416859b5eac457d6f8aa60dfaa Mon Sep 17 00:00:00 2001 From: Joe Drago Date: Wed, 11 Mar 2020 15:25:42 -0700 Subject: [PATCH 7/8] Move png_set_swap later in PNG write or it is ignored (fixes 16bpc PNGs) --- apps/shared/avifpng.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/shared/avifpng.c b/apps/shared/avifpng.c index 87dab499a3..933d0e4a9f 100644 --- a/apps/shared/avifpng.c +++ b/apps/shared/avifpng.c @@ -177,10 +177,6 @@ avifBool avifPNGWrite(avifImage * avif, const char * outputFilename, int request } } - if (rgbDepth > 8) { - png_set_swap(png); - } - png_set_IHDR( png, info, avif->width, avif->height, rgbDepth, PNG_COLOR_TYPE_RGBA, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); if (avif->profileFormat == AVIF_PROFILE_FORMAT_ICC) { @@ -197,6 +193,10 @@ avifBool avifPNGWrite(avifImage * avif, const char * outputFilename, int request rowPointers[y] = &rgb.pixels[y * rgb.rowBytes]; } + if (rgbDepth > 8) { + png_set_swap(png); + } + png_write_image(png, rowPointers); png_write_end(png, NULL); From 437ee223fbfb431c3487a8f7099d0d33a02819b9 Mon Sep 17 00:00:00 2001 From: Joe Drago Date: Wed, 11 Mar 2020 15:30:17 -0700 Subject: [PATCH 8/8] v0.6.2 --- CHANGELOG.md | 9 ++++++++- CMakeLists.txt | 4 ++-- include/avif/avif.h | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c6cba621b..3f2dbd3c7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.6.2] - 2020-03-11 +### Changed +- Fix 16bpc PNG output +- Compile fixes to avoid -Wclobbered in PNG code +- GitHub automatic deployment from AppVeyor (EwoutH) + ## [0.6.1] - 2020-03-11 ### Added - PNG support for avifenc/avifdec @@ -336,7 +342,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Constants `AVIF_VERSION`, `AVIF_VERSION_MAJOR`, `AVIF_VERSION_MINOR`, `AVIF_VERSION_PATCH` - `avifVersion()` function -[Unreleased]: https://github.com/AOMediaCodec/libavif/compare/v0.6.1...HEAD +[Unreleased]: https://github.com/AOMediaCodec/libavif/compare/v0.6.2...HEAD +[0.6.1]: https://github.com/AOMediaCodec/libavif/compare/v0.6.1...v0.6.2 [0.6.1]: https://github.com/AOMediaCodec/libavif/compare/v0.6.0...v0.6.1 [0.6.0]: https://github.com/AOMediaCodec/libavif/compare/v0.5.7...v0.6.0 [0.5.7]: https://github.com/AOMediaCodec/libavif/compare/v0.5.6...v0.5.7 diff --git a/CMakeLists.txt b/CMakeLists.txt index 21a8d8025c..882023d264 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ cmake_minimum_required(VERSION 3.5) # and find_package() list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules") -project(libavif LANGUAGES C CXX VERSION 0.6.1) +project(libavif LANGUAGES C CXX VERSION 0.6.2) # SOVERSION scheme: MAJOR.MINOR.PATCH # If there was an incompatible interface change: @@ -18,7 +18,7 @@ project(libavif LANGUAGES C CXX VERSION 0.6.1) # Increment PATCH. set(LIBRARY_VERSION_MAJOR 2) set(LIBRARY_VERSION_MINOR 0) -set(LIBRARY_VERSION_PATCH 1) +set(LIBRARY_VERSION_PATCH 2) set(LIBRARY_VERSION "${LIBRARY_VERSION_MAJOR}.${LIBRARY_VERSION_MINOR}.${LIBRARY_VERSION_PATCH}") set(LIBRARY_SOVERSION ${LIBRARY_VERSION_MAJOR}) diff --git a/include/avif/avif.h b/include/avif/avif.h index 70579829ef..bee16c7190 100644 --- a/include/avif/avif.h +++ b/include/avif/avif.h @@ -16,7 +16,7 @@ extern "C" { #define AVIF_VERSION_MAJOR 0 #define AVIF_VERSION_MINOR 6 -#define AVIF_VERSION_PATCH 1 +#define AVIF_VERSION_PATCH 2 #define AVIF_VERSION (AVIF_VERSION_MAJOR * 10000) + (AVIF_VERSION_MINOR * 100) + AVIF_VERSION_PATCH typedef int avifBool;