Skip to content

Commit

Permalink
Address minor review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
maryla-uc committed Dec 12, 2024
1 parent c4f7bac commit f135859
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 29 deletions.
2 changes: 0 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down
42 changes: 19 additions & 23 deletions src/read.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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)) {
Expand Down
3 changes: 1 addition & 2 deletions tests/gtest/avifincrtest_helpers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit f135859

Please sign in to comment.