Skip to content

Commit

Permalink
Remove AVIF_ENABLE_GAIN_MAP flag. (#2516)
Browse files Browse the repository at this point in the history
  • Loading branch information
maryla-uc authored Dec 12, 2024
1 parent 37cb0bf commit 260879c
Show file tree
Hide file tree
Showing 31 changed files with 185 additions and 543 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci-fuzztest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ jobs:
-DAVIF_BUILD_EXAMPLES=ON -DAVIF_BUILD_APPS=ON
-DAVIF_BUILD_TESTS=ON -DAVIF_ENABLE_GTEST=ON -DAVIF_GTEST=LOCAL
-DAVIF_ENABLE_EXPERIMENTAL_YCGCO_R=ON
-DAVIF_ENABLE_GAIN_MAP=ON
-DAVIF_ENABLE_EXPERIMENTAL_MINI=ON
-DAVIF_ENABLE_EXPERIMENTAL_SAMPLE_TRANSFORM=ON
-DAVIF_ENABLE_FUZZTEST=ON
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/ci-linux-golden-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ jobs:
-DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF
-DAVIF_CODEC_AOM=LOCAL -DAVIF_LIBYUV=LOCAL
-DAVIF_BUILD_EXAMPLES=ON -DAVIF_BUILD_APPS=ON
-DAVIF_ENABLE_GAIN_MAP=ON
-DAVIF_LIBXML2=LOCAL
-DAVIF_BUILD_TESTS=ON -DAVIF_ENABLE_GOLDEN_TESTS=ON
-DAVIF_ENABLE_GTEST=OFF -DAVIF_ENABLE_WERROR=ON
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/ci-linux-static-old-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ jobs:
-DAVIF_BUILD_EXAMPLES=ON -DAVIF_BUILD_APPS=ON
-DAVIF_BUILD_TESTS=ON -DAVIF_ENABLE_GTEST=ON -DAVIF_LOCAL_GTEST=ON
-DAVIF_ENABLE_EXPERIMENTAL_YCGCO_R=ON
-DAVIF_ENABLE_GAIN_MAP=ON
-DAVIF_ENABLE_EXPERIMENTAL_MINI=ON
-DAVIF_ENABLE_WERROR=ON
- name: Build libavif (ninja)
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/ci-unix-shared-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ jobs:
-DAVIF_BUILD_EXAMPLES=ON -DAVIF_BUILD_APPS=ON
-DAVIF_BUILD_TESTS=ON -DAVIF_ENABLE_GTEST=ON -DAVIF_GTEST=LOCAL
-DAVIF_ENABLE_EXPERIMENTAL_YCGCO_R=ON
-DAVIF_ENABLE_GAIN_MAP=ON
-DAVIF_ENABLE_EXPERIMENTAL_MINI=ON
-DAVIF_ENABLE_EXPERIMENTAL_SAMPLE_TRANSFORM=ON
-DAVIF_ENABLE_WERROR=ON
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/ci-unix-static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ jobs:
-DAVIF_BUILD_EXAMPLES=ON -DAVIF_BUILD_APPS=ON
-DAVIF_BUILD_TESTS=ON -DAVIF_ENABLE_GTEST=ON -DAVIF_GTEST=LOCAL
-DAVIF_ENABLE_EXPERIMENTAL_YCGCO_R=ON
-DAVIF_ENABLE_GAIN_MAP=ON
-DAVIF_ENABLE_EXPERIMENTAL_MINI=ON
-DAVIF_ENABLE_EXPERIMENTAL_SAMPLE_TRANSFORM=ON
-DAVIF_ENABLE_WERROR=ON
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/ci-windows-installed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ jobs:
-DAVIF_BUILD_EXAMPLES=ON -DAVIF_BUILD_APPS=ON
-DAVIF_BUILD_TESTS=ON -DAVIF_ENABLE_GTEST=ON -DAVIF_GTEST=LOCAL
-DAVIF_ENABLE_EXPERIMENTAL_YCGCO_R=ON
-DAVIF_ENABLE_GAIN_MAP=ON
-DAVIF_ENABLE_EXPERIMENTAL_MINI=ON
-DAVIF_ENABLE_EXPERIMENTAL_SAMPLE_TRANSFORM=ON
-DAVIF_ENABLE_WERROR=ON $env:AVIF_CMAKE_C_COMPILER $env:AVIF_CMAKE_CXX_COMPILER
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/ci-windows-shared-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ jobs:
-DAVIF_BUILD_EXAMPLES=ON -DAVIF_BUILD_APPS=ON
-DAVIF_BUILD_TESTS=ON -DAVIF_ENABLE_GTEST=ON -DAVIF_GTEST=LOCAL
-DAVIF_ENABLE_EXPERIMENTAL_YCGCO_R=ON
-DAVIF_ENABLE_GAIN_MAP=ON
-DAVIF_ENABLE_EXPERIMENTAL_MINI=ON
-DAVIF_ENABLE_EXPERIMENTAL_SAMPLE_TRANSFORM=ON
-DAVIF_ENABLE_WERROR=ON $env:AVIF_CMAKE_C_COMPILER $env:AVIF_CMAKE_CXX_COMPILER
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/ci-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ jobs:
-DAVIF_BUILD_EXAMPLES=ON -DAVIF_BUILD_APPS=ON
-DAVIF_BUILD_TESTS=ON -DAVIF_ENABLE_GTEST=ON -DAVIF_GTEST=LOCAL
-DAVIF_ENABLE_EXPERIMENTAL_YCGCO_R=ON
-DAVIF_ENABLE_GAIN_MAP=ON
-DAVIF_ENABLE_EXPERIMENTAL_MINI=ON
-DAVIF_ENABLE_EXPERIMENTAL_SAMPLE_TRANSFORM=ON
-DAVIF_ENABLE_WERROR=ON
Expand Down
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ The changes are relative to the previous release, unless the baseline is specifi
avifGainMapMetadataDouble structs.
* Add avif(Un)SignedFraction structs and avifDoubleTo(Un)SignedFraction
utility functions.
* Turn on the gain map API by default. Rename the compile flag from
AVIF_ENABLE_EXPERIMENTAL_GAIN_MAP to AVIF_ENABLE_GAIN_MAP.
* Turn on the gain map API. Remove the
AVIF_ENABLE_EXPERIMENTAL_GAIN_MAP compile flag.

## [1.1.1] - 2024-07-30

Expand Down
82 changes: 33 additions & 49 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ option(BUILD_SHARED_LIBS "Build shared avif library" ON)

option(AVIF_ENABLE_WERROR "Treat all compiler warnings as errors" OFF)

option(AVIF_ENABLE_GAIN_MAP
"Enable gain map code (for HDR images that look good both on HDR and SDR displays)" ON
)

option(AVIF_ENABLE_EXPERIMENTAL_YCGCO_R "Enable experimental YCgCo-R matrix code" OFF)
option(AVIF_ENABLE_EXPERIMENTAL_MINI "Enable experimental reduced header" OFF)
option(AVIF_ENABLE_EXPERIMENTAL_SAMPLE_TRANSFORM "Enable experimental sample transform code" OFF)
Expand Down Expand Up @@ -273,13 +269,10 @@ if(AVIF_LIBSHARPYUV_ENABLED)
endif(AVIF_LIBSHARPYUV_ENABLED)

set_local_or_system_option(
"LIBXML2" "OFF" "Use libxml2. When enabled and AVIF_ENABLE_GAIN_MAP is ON, \
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)

if(AVIF_ENABLE_GAIN_MAP)
check_avif_option(AVIF_LIBXML2 TARGET LibXml2::LibXml2 PKG_NAME LibXml2)
endif()
# ---------------------------------------------------------------------------------------

# Enable all warnings
Expand Down Expand Up @@ -365,10 +358,6 @@ if(AVIF_ENABLE_EXPERIMENTAL_YCGCO_R)
add_compile_definitions(AVIF_ENABLE_EXPERIMENTAL_YCGCO_R)
endif()

if(AVIF_ENABLE_GAIN_MAP)
add_compile_definitions(AVIF_ENABLE_GAIN_MAP)
endif()

if(AVIF_ENABLE_EXPERIMENTAL_MINI)
add_compile_definitions(AVIF_ENABLE_EXPERIMENTAL_MINI)
endif()
Expand All @@ -384,6 +373,7 @@ set(AVIF_SRCS
src/colrconvert.c
src/diag.c
src/exif.c
src/gainmap.c
src/io.c
src/mem.c
src/obu.c
Expand All @@ -397,9 +387,6 @@ set(AVIF_SRCS
src/utils.c
src/write.c
)
if(AVIF_ENABLE_GAIN_MAP)
list(APPEND AVIF_SRCS src/gainmap.c)
endif()
if(AVIF_ENABLE_EXPERIMENTAL_SAMPLE_TRANSFORM)
list(APPEND AVIF_SRCS src/sampletransform.c)
endif()
Expand Down Expand Up @@ -585,7 +572,7 @@ if(NOT AVIF_CODEC_AOM_ENABLED
message(WARNING "libavif: No decoding library is enabled.")
endif()

if(AVIF_LIB_USE_CXX OR (AVIF_BUILD_APPS AND AVIF_ENABLE_GAIN_MAP) OR (AVIF_BUILD_TESTS AND (AVIF_ENABLE_FUZZTEST
if(AVIF_LIB_USE_CXX OR AVIF_BUILD_APPS OR (AVIF_BUILD_TESTS AND (AVIF_ENABLE_FUZZTEST
OR AVIF_ENABLE_GTEST))
)
enable_language(CXX)
Expand Down Expand Up @@ -677,13 +664,11 @@ if(AVIF_BUILD_APPS OR (AVIF_BUILD_TESTS AND (AVIF_ENABLE_FUZZTEST OR AVIF_ENABLE
find_package(JPEG REQUIRED)
endif()

if(AVIF_ENABLE_GAIN_MAP)
if(TARGET LibXml2::LibXml2)
set(AVIF_ENABLE_EXPERIMENTAL_JPEG_GAIN_MAP_CONVERSION TRUE)
add_compile_definitions(AVIF_ENABLE_EXPERIMENTAL_JPEG_GAIN_MAP_CONVERSION)
else()
message(STATUS "libavif: libxml2 not found; avifenc will ignore any gain map in jpeg files")
endif()
if(TARGET LibXml2::LibXml2)
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")
endif()

set(AVIF_APPS_SRCS apps/shared/avifexif.c apps/shared/avifjpeg.c apps/shared/avifpng.c apps/shared/avifutil.c
Expand All @@ -696,7 +681,7 @@ if(AVIF_BUILD_APPS OR (AVIF_BUILD_TESTS AND (AVIF_ENABLE_FUZZTEST OR AVIF_ENABLE
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
target_link_libraries(avif_apps${suffix} PRIVATE m)
endif()
if(AVIF_ENABLE_EXPERIMENTAL_JPEG_GAIN_MAP_CONVERSION)
if(AVIF_ENABLE_JPEG_GAIN_MAP_CONVERSION)
target_link_libraries(avif_apps${suffix} PRIVATE LibXml2::LibXml2)
endif()
target_include_directories(avif_apps${suffix} INTERFACE apps/shared)
Expand Down Expand Up @@ -755,33 +740,32 @@ if(AVIF_BUILD_APPS)
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
)
endif()
if(AVIF_ENABLE_GAIN_MAP)
include(LocalLibargparse)
set(AVIFGAINMAPUTIL_SRCS
apps/avifgainmaputil/avifgainmaputil.cc
apps/avifgainmaputil/convert_command.cc
apps/avifgainmaputil/combine_command.cc
apps/avifgainmaputil/extractgainmap_command.cc
apps/avifgainmaputil/imageio.cc
apps/avifgainmaputil/printmetadata_command.cc
apps/avifgainmaputil/tonemap_command.cc
apps/avifgainmaputil/program_command.cc
apps/avifgainmaputil/swapbase_command.cc
)
include(LocalLibargparse)

set(AVIFGAINMAPUTIL_SRCS
apps/avifgainmaputil/avifgainmaputil.cc
apps/avifgainmaputil/convert_command.cc
apps/avifgainmaputil/combine_command.cc
apps/avifgainmaputil/extractgainmap_command.cc
apps/avifgainmaputil/imageio.cc
apps/avifgainmaputil/printmetadata_command.cc
apps/avifgainmaputil/tonemap_command.cc
apps/avifgainmaputil/program_command.cc
apps/avifgainmaputil/swapbase_command.cc
)

add_executable(avifgainmaputil "${AVIFGAINMAPUTIL_SRCS}")
if(WIN32)
if(MSVC)
target_sources(avifgainmaputil PRIVATE apps/utf8.manifest)
elseif(MINGW)
target_sources(avifgainmaputil PRIVATE apps/utf8.rc)
endif()
add_executable(avifgainmaputil "${AVIFGAINMAPUTIL_SRCS}")
if(WIN32)
if(MSVC)
target_sources(avifgainmaputil PRIVATE apps/utf8.manifest)
elseif(MINGW)
target_sources(avifgainmaputil PRIVATE apps/utf8.rc)
endif()
set_target_properties(avifgainmaputil PROPERTIES LINKER_LANGUAGE "CXX")
target_include_directories(avifgainmaputil PRIVATE apps/avifgainmaputil/)
target_link_libraries(avifgainmaputil libargparse avif_apps avif avif_enable_warnings)
# Don't add avifgainmaputil to installed apps for now.
endif()
set_target_properties(avifgainmaputil PROPERTIES LINKER_LANGUAGE "CXX")
target_include_directories(avifgainmaputil PRIVATE apps/avifgainmaputil/)
target_link_libraries(avifgainmaputil libargparse avif_apps avif avif_enable_warnings)
# Don't add avifgainmaputil to installed apps for now.
endif()

if(AVIF_BUILD_TESTS)
Expand Down
21 changes: 10 additions & 11 deletions apps/avifenc.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ typedef struct
avifBool ignoreXMP;
avifBool ignoreColorProfile;

// These settings are only relevant when compiled with AVIF_ENABLE_EXPERIMENTAL_JPEG_GAIN_MAP_CONVERSION
// (which also implies AVIF_ENABLE_GAIN_MAP).
// These settings are only relevant when compiled with AVIF_ENABLE_JPEG_GAIN_MAP_CONVERSION.
avifBool qualityGainMapIsConstrained; // true if qualityGainMap explicitly set by the user
int qualityGainMap;
avifBool ignoreGainMap; // ignore any gain map present in the input file.
Expand Down Expand Up @@ -240,7 +239,7 @@ static void syntaxLong(void)
printf(" --ignore-exif : If the input file contains embedded Exif metadata, ignore it (no-op if absent)\n");
printf(" --ignore-xmp : If the input file contains embedded XMP metadata, ignore it (no-op if absent)\n");
printf(" --ignore-profile,--ignore-icc : If the input file contains an embedded color profile, ignore it (no-op if absent)\n");
#if defined(AVIF_ENABLE_EXPERIMENTAL_JPEG_GAIN_MAP_CONVERSION)
#if defined(AVIF_ENABLE_JPEG_GAIN_MAP_CONVERSION)
printf(" --ignore-gain-map : If the input file contains an embedded gain map, ignore it (no-op if absent)\n");
printf(" --qgain-map Q : Set quality for the gain map (%d-%d, where %d is lossless)\n",
AVIF_QUALITY_WORST,
Expand Down Expand Up @@ -525,7 +524,7 @@ static avifBool avifInputReadImage(avifInput * input,
if (avifImageSetViewRect(image, cached->image, &rect) != AVIF_RESULT_OK) {
assert(AVIF_FALSE);
}
#if defined(AVIF_ENABLE_EXPERIMENTAL_JPEG_GAIN_MAP_CONVERSION)
#if defined(AVIF_ENABLE_JPEG_GAIN_MAP_CONVERSION)
if (cached->image->gainMap && cached->image->gainMap->image) {
image->gainMap->image = avifImageCreateEmpty();
const avifCropRect gainMapRect = { 0, 0, cached->image->gainMap->image->width, cached->image->gainMap->image->height };
Expand Down Expand Up @@ -1143,7 +1142,7 @@ static avifBool avifEncodeImagesFixedQuality(const avifSettings * settings,
if (settings->overrideQualityAlpha != INVALID_QUALITY) {
encoder->qualityAlpha = settings->overrideQualityAlpha;
}
#if defined(AVIF_ENABLE_EXPERIMENTAL_JPEG_GAIN_MAP_CONVERSION)
#if defined(AVIF_ENABLE_JPEG_GAIN_MAP_CONVERSION)
if (settings->qualityGainMap != INVALID_QUALITY) {
encoder->qualityGainMap = settings->qualityGainMap;
}
Expand All @@ -1157,7 +1156,7 @@ static avifBool avifEncodeImagesFixedQuality(const avifSettings * settings,
snprintf(speedStr, sizeof(speedStr), "%d", settings->speed);
}
char gainMapStr[100] = { 0 };
#if defined(AVIF_ENABLE_EXPERIMENTAL_JPEG_GAIN_MAP_CONVERSION)
#if defined(AVIF_ENABLE_JPEG_GAIN_MAP_CONVERSION)
if (firstImage->gainMap && firstImage->gainMap->image) {
snprintf(gainMapStr, sizeof(gainMapStr), ", gain map quality [%d (%s)]", encoder->qualityGainMap, qualityString(encoder->qualityGainMap));
}
Expand Down Expand Up @@ -1241,7 +1240,7 @@ static avifBool avifEncodeImagesFixedQuality(const avifSettings * settings,
success = AVIF_TRUE;
byteSizes->colorSizeBytes = encoder->ioStats.colorOBUSize;
byteSizes->alphaSizeBytes = encoder->ioStats.alphaOBUSize;
#if defined(AVIF_ENABLE_EXPERIMENTAL_JPEG_GAIN_MAP_CONVERSION)
#if defined(AVIF_ENABLE_JPEG_GAIN_MAP_CONVERSION)
byteSizes->gainMapSizeBytes = avifEncoderGetGainMapSizeBytes(encoder);
#endif

Expand Down Expand Up @@ -1269,7 +1268,7 @@ static avifBool avifEncodeImages(avifSettings * settings,

avifBool hasGainMap = AVIF_FALSE;
avifBool allQualitiesConstrained = settings->qualityIsConstrained && settings->qualityAlphaIsConstrained;
#if defined(AVIF_ENABLE_EXPERIMENTAL_JPEG_GAIN_MAP_CONVERSION)
#if defined(AVIF_ENABLE_JPEG_GAIN_MAP_CONVERSION)
hasGainMap = (firstImage->gainMap && firstImage->gainMap->image);
if (hasGainMap) {
allQualitiesConstrained = allQualitiesConstrained && settings->qualityGainMapIsConstrained;
Expand Down Expand Up @@ -1814,7 +1813,7 @@ int main(int argc, char * argv[])
settings.ignoreXMP = AVIF_TRUE;
} else if (!strcmp(arg, "--ignore-profile") || !strcmp(arg, "--ignore-icc")) {
settings.ignoreColorProfile = AVIF_TRUE;
#if defined(AVIF_ENABLE_EXPERIMENTAL_JPEG_GAIN_MAP_CONVERSION)
#if defined(AVIF_ENABLE_JPEG_GAIN_MAP_CONVERSION)
} else if (!strcmp(arg, "--ignore-gain-map")) {
settings.ignoreGainMap = AVIF_TRUE;
} else if (!strcmp(arg, "--qgain-map")) {
Expand Down Expand Up @@ -2253,7 +2252,7 @@ int main(int argc, char * argv[])
image->transferCharacteristics = AVIF_TRANSFER_CHARACTERISTICS_SRGB;
}

#if defined(AVIF_ENABLE_EXPERIMENTAL_JPEG_GAIN_MAP_CONVERSION)
#if defined(AVIF_ENABLE_JPEG_GAIN_MAP_CONVERSION)
if (image->gainMap && !image->gainMap->altICC.size) {
if (image->gainMap->altColorPrimaries == AVIF_COLOR_PRIMARIES_UNSPECIFIED) {
// Assume the alternate image has the same primaries as the base image.
Expand All @@ -2264,7 +2263,7 @@ int main(int argc, char * argv[])
image->gainMap->altTransferCharacteristics = AVIF_TRANSFER_CHARACTERISTICS_PQ;
}
}
#endif // AVIF_ENABLE_EXPERIMENTAL_JPEG_GAIN_MAP_CONVERSION
#endif // AVIF_ENABLE_JPEG_GAIN_MAP_CONVERSION

if (settings.paspPresent) {
image->transformFlags |= AVIF_TRANSFORM_PASP;
Expand Down
12 changes: 6 additions & 6 deletions apps/shared/avifjpeg.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#include "iccjpeg.h"

#if defined(AVIF_ENABLE_EXPERIMENTAL_JPEG_GAIN_MAP_CONVERSION)
#if defined(AVIF_ENABLE_JPEG_GAIN_MAP_CONVERSION)
#include <libxml/parser.h>
#endif

Expand Down Expand Up @@ -286,7 +286,7 @@ static const uint8_t * avifJPEGFindSubstr(const uint8_t * str, size_t strLength,
return AVIF_FALSE; \
} while (0)

#if defined(AVIF_ENABLE_EXPERIMENTAL_JPEG_GAIN_MAP_CONVERSION)
#if defined(AVIF_ENABLE_JPEG_GAIN_MAP_CONVERSION)

// Reads a 4-byte unsigned integer in little-endian format from the raw bitstream src.
static uint32_t avifJPEGReadUint32LittleEndian(const uint8_t * src)
Expand Down Expand Up @@ -833,7 +833,7 @@ static avifBool avifJPEGExtractGainMapImage(FILE * f,
}
return AVIF_FALSE;
}
#endif // AVIF_ENABLE_EXPERIMENTAL_JPEG_GAIN_MAP_CONVERSION
#endif // AVIF_ENABLE_JPEG_GAIN_MAP_CONVERSION

// Note on setjmp() and volatile variables:
//
Expand Down Expand Up @@ -1023,7 +1023,7 @@ static avifBool avifJPEGReadInternal(FILE * f,
}

avifBool readXMP = !ignoreXMP;
#if defined(AVIF_ENABLE_EXPERIMENTAL_JPEG_GAIN_MAP_CONVERSION)
#if defined(AVIF_ENABLE_JPEG_GAIN_MAP_CONVERSION)
readXMP = readXMP || !ignoreGainMap; // Gain map metadata is in XMP.
#endif
if (readXMP) {
Expand Down Expand Up @@ -1172,7 +1172,7 @@ static avifBool avifJPEGReadInternal(FILE * f,
avifImageFixXMP(avif); // Remove one trailing null character if any.
}

#if defined(AVIF_ENABLE_EXPERIMENTAL_JPEG_GAIN_MAP_CONVERSION)
#if defined(AVIF_ENABLE_JPEG_GAIN_MAP_CONVERSION)
// The primary XMP block (for the main image) must contain a node with an hdrgm:Version field if and only if a gain map is present.
if (!ignoreGainMap && avifJPEGHasGainMapXMPNode(avif->xmp.data, avif->xmp.size)) {
avifGainMap * gainMap = avifGainMapCreate();
Expand Down Expand Up @@ -1209,7 +1209,7 @@ static avifBool avifJPEGReadInternal(FILE * f,
assert(AVIF_FALSE);
}
}
#endif // AVIF_ENABLE_EXPERIMENTAL_JPEG_GAIN_MAP_CONVERSION
#endif // AVIF_ENABLE_JPEG_GAIN_MAP_CONVERSION
jpeg_finish_decompress(&cinfo);
ret = AVIF_TRUE;
cleanup:
Expand Down
7 changes: 3 additions & 4 deletions apps/shared/avifjpeg.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ extern "C" {
// At most sizeLimit pixels will be read or an error returned. At most sizeLimit
// bytes of Exif or XMP metadata will be read or an error returned.
// 'ignoreGainMap' is only relevant for jpeg files that have a gain map
// and only if AVIF_ENABLE_EXPERIMENTAL_JPEG_GAIN_MAP_CONVERSION is ON
// (requires AVIF_ENABLE_GAIN_MAP and libxml2). Otherwise
// it has no effect.
// and only if AVIF_ENABLE_JPEG_GAIN_MAP_CONVERSION is ON
// (requires libxml2). Otherwise it has no effect.
avifBool avifJPEGRead(const char * inputFilename,
avifImage * avif,
avifPixelFormat requestedFormat,
Expand All @@ -29,7 +28,7 @@ avifBool avifJPEGRead(const char * inputFilename,
uint32_t sizeLimit);
avifBool avifJPEGWrite(const char * outputFilename, const avifImage * avif, int jpegQuality, avifChromaUpsampling chromaUpsampling);

#if defined(AVIF_ENABLE_EXPERIMENTAL_JPEG_GAIN_MAP_CONVERSION)
#if defined(AVIF_ENABLE_JPEG_GAIN_MAP_CONVERSION)
// Parses XMP gain map metadata. Visible for testing.
avifBool avifJPEGParseGainMapXMP(const uint8_t * xmpData, size_t xmpSize, avifGainMap * gainMap);
#endif
Expand Down
Loading

0 comments on commit 260879c

Please sign in to comment.