From e6e53848328777ad54a4df2594fce231d1f19473 Mon Sep 17 00:00:00 2001 From: Ram Mohan M Date: Tue, 19 Nov 2024 15:18:55 +0530 Subject: [PATCH] enable support for xmp, iso to be build time configurable 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 --- Android.bp | 3 ++- CMakeLists.txt | 12 ++++++++++++ lib/src/jpegr.cpp | 8 ++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/Android.bp b/Android.bp index 194fc1c3..09ee9d5e 100644 --- a/Android.bp +++ b/Android.bp @@ -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", diff --git a/CMakeLists.txt b/CMakeLists.txt index c518d85e..45251e8e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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") @@ -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) diff --git a/lib/src/jpegr.cpp b/lib/src/jpegr.cpp index 4a222149..4bdef687 100644 --- a/lib/src/jpegr.cpp +++ b/lib/src/jpegr.cpp @@ -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";