diff --git a/CHANGELOG.md b/CHANGELOG.md index eea1bb7884..383bfd2097 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,8 +39,6 @@ The changes are relative to the previous release, unless the baseline is specifi utility functions. * Turn on the gain map API. Remove the AVIF_ENABLE_EXPERIMENTAL_GAIN_MAP compile flag. - Rename AVIF_ENABLE_EXPERIMENTAL_JPEG_GAIN_MAP_CONVERSION to - AVIF_ENABLE_JPEG_GAIN_MAP_CONVERSION. ## [1.1.1] - 2024-07-30 diff --git a/CMakeLists.txt b/CMakeLists.txt index b3c21d6490..c4edea5b38 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -269,7 +269,7 @@ if(AVIF_LIBSHARPYUV_ENABLED) endif(AVIF_LIBSHARPYUV_ENABLED) set_local_or_system_option( - "LIBXML2" "OFF" "Use libxml2. When enabled, allows converting jpeg files with gain maps to avif using avifenc" + "LIBXML2" "OFF" "Use libxml2. When enabled, allows converting JPEG files with gain maps to AVIF using avifenc" ) check_avif_option(AVIF_LIBXML2 TARGET LibXml2::LibXml2 PKG_NAME LibXml2) @@ -668,7 +668,7 @@ if(AVIF_BUILD_APPS OR (AVIF_BUILD_TESTS AND (AVIF_ENABLE_FUZZTEST OR AVIF_ENABLE set(AVIF_ENABLE_JPEG_GAIN_MAP_CONVERSION TRUE) add_compile_definitions(AVIF_ENABLE_JPEG_GAIN_MAP_CONVERSION) else() - message(STATUS "libavif: libxml2 not found; avifenc will ignore any gain map in jpeg files") + message(STATUS "libavif: libxml2 not found; avifenc will ignore any gain map in JPEG files") endif() set(AVIF_APPS_SRCS apps/shared/avifexif.c apps/shared/avifjpeg.c apps/shared/avifpng.c apps/shared/avifutil.c diff --git a/src/read.c b/src/read.c index bda4522e2d..2a8b4ce096 100644 --- a/src/read.c +++ b/src/read.c @@ -4571,11 +4571,10 @@ static avifResult avifParse(avifDecoder * decoder) // * If the brand 'avif' is present, require a meta box // * If the brand 'avis' is present, require a moov box // * If AVIF_ENABLE_EXPERIMENTAL_MINI is defined and the brand 'mif3' is present, require a mini box - avifBool sawEverythingNeeded = ftypSeen && (!needsMeta || metaSeen) && (!needsMoov || moovSeen); + avifBool sawEverythingNeeded = ftypSeen && (!needsMeta || metaSeen) && (!needsMoov || moovSeen) && (!needsTmap || tmapSeen); #if defined(AVIF_ENABLE_EXPERIMENTAL_MINI) sawEverythingNeeded = sawEverythingNeeded && (!needsMini || miniSeen); #endif - sawEverythingNeeded = sawEverythingNeeded && (!needsTmap || tmapSeen); if (sawEverythingNeeded) { return AVIF_RESULT_OK; } @@ -6256,28 +6255,25 @@ static avifResult avifDecoderDecodeTiles(avifDecoder * decoder, uint32_t nextIma AVIF_ASSERT_OR_RETURN(tileIndex == 0); avifImage * src = tile->image; - switch (tile->input->itemCategory) { - case AVIF_ITEM_GAIN_MAP: - AVIF_ASSERT_OR_RETURN(decoder->image->gainMap && decoder->image->gainMap->image); - decoder->image->gainMap->image->width = src->width; - decoder->image->gainMap->image->height = src->height; - decoder->image->gainMap->image->depth = src->depth; - break; - default: - if ((decoder->image->width != src->width) || (decoder->image->height != src->height) || - (decoder->image->depth != src->depth)) { - if (avifIsAlpha(tile->input->itemCategory)) { - avifDiagnosticsPrintf(&decoder->diag, - "The color image item does not match the alpha image item in width, height, or bit depth"); - return AVIF_RESULT_DECODE_ALPHA_FAILED; - } - avifImageFreePlanes(decoder->image, AVIF_PLANES_ALL); - - decoder->image->width = src->width; - decoder->image->height = src->height; - decoder->image->depth = src->depth; + if (tile->input->itemCategory == AVIF_ITEM_GAIN_MAP) { + AVIF_ASSERT_OR_RETURN(decoder->image->gainMap && decoder->image->gainMap->image); + decoder->image->gainMap->image->width = src->width; + decoder->image->gainMap->image->height = src->height; + decoder->image->gainMap->image->depth = src->depth; + } else { + if ((decoder->image->width != src->width) || (decoder->image->height != src->height) || + (decoder->image->depth != src->depth)) { + if (avifIsAlpha(tile->input->itemCategory)) { + avifDiagnosticsPrintf(&decoder->diag, + "The color image item does not match the alpha image item in width, height, or bit depth"); + return AVIF_RESULT_DECODE_ALPHA_FAILED; } - break; + avifImageFreePlanes(decoder->image, AVIF_PLANES_ALL); + + decoder->image->width = src->width; + decoder->image->height = src->height; + decoder->image->depth = src->depth; + } } if (avifIsAlpha(tile->input->itemCategory)) { diff --git a/tests/gtest/avifincrtest_helpers.cc b/tests/gtest/avifincrtest_helpers.cc index 97a74e34cf..371133d1ab 100644 --- a/tests/gtest/avifincrtest_helpers.cc +++ b/tests/gtest/avifincrtest_helpers.cc @@ -362,10 +362,9 @@ avifResult DecodeIncrementally(const avifRWData& encoded_avif, previously_decoded_row_count, decoded_row_count); AVIF_CHECKERR(false, AVIF_RESULT_INVALID_ARGUMENT); } - const bool has_gain_map = (reference.gainMap != nullptr); const uint32_t min_decoded_row_count = GetMinDecodedRowCount( reference.height, cell_height, reference.alphaPlane != nullptr, - has_gain_map, data.available.size, data.full_size, + reference.gainMap != nullptr, data.available.size, data.full_size, enable_fine_incremental_check); if (decoded_row_count < min_decoded_row_count) { printf(