Skip to content

Commit

Permalink
enable support for xmp, iso to be build time configurable
Browse files Browse the repository at this point in the history
Android.bp enables xmp support by default, cmakelists.txt enables iso
support by default. Based on the build system the encoded bitstream
may vary. This change has no effect on decoder. The decoder by default
supports both iso and xmp. If both exists iso packet is preferred.

Test: ./ultrahdr_unit_test
  • Loading branch information
ram-mohan committed Dec 10, 2024
1 parent 60291cc commit e6e5384
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ cc_library {
"lib/include",
],
local_include_dirs: ["lib/include"],
cflags: ["-DUHDR_ENABLE_INTRINSICS"],
cflags: ["-DUHDR_ENABLE_INTRINSICS",
"-DUHDR_WRITE_XMP",],
srcs: [
"lib/src/icc.cpp",
"lib/src/jpegr.cpp",
Expand Down
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ option_if_not_defined(UHDR_ENABLE_INTRINSICS "Build with SIMD acceleration " TRU
option_if_not_defined(UHDR_ENABLE_GLES "Build with GPU acceleration " FALSE)
option_if_not_defined(UHDR_ENABLE_WERROR "Build with -Werror" FALSE)

# These options effect only encoding process.
# Decoding continues to support both iso and xmp irrespective of this configuration.
# Also, if both packets are present iso is prioritized over xmp.
option_if_not_defined(UHDR_WRITE_XMP "Write gainmap metadata in XMP packet" FALSE)
option_if_not_defined(UHDR_WRITE_ISO "Write gainmap metadata in ISO 21496_1 packet" TRUE)

# pre-requisites
if(UHDR_BUILD_TESTS AND EMSCRIPTEN)
message(FATAL_ERROR "Building tests not supported for wasm targets")
Expand Down Expand Up @@ -199,6 +205,12 @@ endif()
if(UHDR_ENABLE_INTRINSICS)
add_compile_options(-DUHDR_ENABLE_INTRINSICS)
endif()
if(UHDR_WRITE_XMP)
add_compile_options(-DUHDR_WRITE_XMP)
endif()
if(UHDR_WRITE_ISO)
add_compile_options(-DUHDR_WRITE_ISO)
endif()

include(CheckCXXCompilerFlag)
function(CheckCompilerOption opt res)
Expand Down
8 changes: 8 additions & 0 deletions lib/src/jpegr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,16 @@ uhdr_error_info_t applyGainMapGLES(uhdr_raw_image_t* sdr_intent, uhdr_raw_image_
#endif

// Gain map metadata
#ifdef UHDR_WRITE_XMP
static const bool kWriteXmpMetadata = true;
#else
static const bool kWriteXmpMetadata = false;
#endif
#ifdef UHDR_WRITE_ISO
static const bool kWriteIso21496_1Metadata = true;
#else
static const bool kWriteIso21496_1Metadata = false;
#endif

static const string kXmpNameSpace = "http://ns.adobe.com/xap/1.0/";
static const string kIsoNameSpace = "urn:iso:std:iso:ts:21496:-1";
Expand Down

0 comments on commit e6e5384

Please sign in to comment.