aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRam Mohan M <ram.mohan@ittiam.com>2024-04-05 17:27:13 +0530
committerDichenZhang1 <140119224+DichenZhang1@users.noreply.github.com>2024-04-05 15:29:08 -0700
commit74993de0cd2f8264a85281e35f551dfd06c6d37f (patch)
tree3c66f03b0603804e1b3674831ce0ab7f45782d44
parent1cdc2a99c72b82dd60462b2fe004d2238f92149f (diff)
downloadlibultrahdr-74993de0cd2f8264a85281e35f551dfd06c6d37f.tar.gz
improve ce9d00b
- restrict install and uninstall targets to Un*x - improvements in cmakelists.txt and pc template (thanks to milos) - Fixes #95 - Updates to readme.md Test: make install
-rw-r--r--CMakeLists.txt32
-rw-r--r--README.md178
-rw-r--r--fuzzer/README.md13
-rw-r--r--libuhdr.pc.template8
4 files changed, 109 insertions, 122 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4f78435..7d8f0ba 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -92,8 +92,8 @@ if(UHDR_BUILD_BENCHMARK AND WIN32)
endif()
# side effects
-if(UHDR_BUILD_FUZZERS)
- set(UHDR_ENABLE_INSTALL FALSE) # during fuzz testing dont install targets
+if(UHDR_BUILD_FUZZERS OR UHDR_BUILD_DEPS)
+ set(UHDR_ENABLE_INSTALL FALSE) # during fuzz testing dont enable install/uninstall targets
set(UHDR_BUILD_DEPS TRUE) # for fuzz testing its best to build all dependencies from source.
# This is to instrument dependencies libs as well
endif()
@@ -119,21 +119,9 @@ if(MSVC)
if(UHDR_BUILD_FUZZERS)
message(FATAL_ERROR "Building fuzzers not supported in MSVC path")
endif()
- foreach(flag_var
- CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
- CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
- CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
- CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
- if(${flag_var} MATCHES "/MD")
- string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
- endif()
- if (${flag_var} MATCHES "/MDd")
- string(REGEX REPLACE "/MDd" "/MTd" ${flag_var} "${${flag_var}}")
- endif()
- endforeach()
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
# Disable specific warnings
- # TODO: None of these should be disabled, but for now,for a warning-free msvc build these are
+ # TODO: None of these should be disabled, but for now, for a warning-free msvc build these are
# added. fix the warnings and remove these filters
add_compile_options(/wd4244) # conversion from 'type1' to 'type2', possible loss of data
add_compile_options(/wd4267) # conversion from 'size_t' to 'type' possible loss of data
@@ -289,6 +277,9 @@ if(UHDR_BUILD_TESTS)
set(GTEST_LIB_PREFIX ${GTEST_BINARY_DIR}/lib/)
endif()
set(GTEST_BOTH_LIBRARIES ${GTEST_LIB_PREFIX}${GTEST_LIB} ${GTEST_LIB_PREFIX}${GTEST_LIB_MAIN})
+ if(MSVC)
+ set(MSVC_ARGS "-Dgtest_force_shared_crt=ON")
+ endif()
ExternalProject_Add(${GTEST_TARGET_NAME}
GIT_REPOSITORY https://github.com/google/googletest
GIT_TAG v1.14.0
@@ -303,6 +294,7 @@ if(UHDR_BUILD_TESTS)
-DCMAKE_CXX_FLAGS_MINSIZEREL=${CMAKE_CXX_FLAGS_MINSIZEREL}
-DCMAKE_CXX_FLAGS_RELWITHDEBINFO=${CMAKE_CXX_FLAGS_RELWITHDEBINFO}
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
+ ${MSVC_ARGS}
BUILD_BYPRODUCTS ${GTEST_BOTH_LIBRARIES}
INSTALL_COMMAND ""
)
@@ -379,7 +371,6 @@ target_include_directories(${UHDR_CORE_LIB_NAME} PRIVATE
"${THIRD_PARTY_DIR}/image_io/includes/"
)
target_include_directories(${UHDR_CORE_LIB_NAME} PUBLIC ${EXPORT_INCLUDE_DIR})
-
target_link_libraries(${UHDR_CORE_LIB_NAME} PRIVATE ${COMMON_LIBS_LIST} ${IMAGEIO_TARGET_NAME})
if(UHDR_BUILD_EXAMPLES)
@@ -495,20 +486,21 @@ if(UHDR_ENABLE_INSTALL)
set(UHDR_TARGET_NAME uhdr)
add_library(${UHDR_TARGET_NAME} SHARED)
add_dependencies(${UHDR_TARGET_NAME} ${UHDR_CORE_LIB_NAME})
+ target_link_libraries(${UHDR_TARGET_NAME} PRIVATE ${JPEG_LIBRARIES})
set_target_properties(${UHDR_TARGET_NAME} PROPERTIES PUBLIC_HEADER ultrahdr_api.h)
combine_static_libs(${UHDR_CORE_LIB_NAME} ${UHDR_TARGET_NAME})
- if(NOT MSVC)
+ if(NOT(WIN32 OR XCODE))
include(GNUInstallDirs)
# pkg-config: libuhdr.pc
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/libuhdr.pc.template"
"${CMAKE_CURRENT_BINARY_DIR}/libuhdr.pc" @ONLY NEWLINE_STYLE UNIX)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libuhdr.pc"
- DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig")
+ DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
install(TARGETS ${UHDR_TARGET_NAME}
- DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/${CMAKE_LIBRARY_ARCHITECTURE}/"
- PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_PREFIX}/include")
+ DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+ PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
add_custom_target(uninstall)
add_custom_command(TARGET uninstall
diff --git a/README.md b/README.md
index b8fa4e7..58f0b71 100644
--- a/README.md
+++ b/README.md
@@ -1,130 +1,126 @@
-Background
-==========
+# Background
libultrahdr is an image compression library that uses gain map technology
to store and distribute HDR images. Conceptually on the encoding side, the
library accepts SDR and HDR rendition of an image and from these a Gain Map
(quotient between the two renditions) is computed. The library then uses
backward compatible means to store the base image (SDR), gain map image and
-some associated metadata. Legacy readers that do not support parsing the
+some associated metadata. Legacy readers that do not support handling the
gain map image and/or metadata, will display the base image. Readers that
support the format combine the base image with the gain map and render a
high dynamic range image on compatible displays.
-More information about libultrahdr can be found at
-<https://developer.android.com/guide/topics/media/platform/hdr-image-format>.
+For additional information about libultrahdr, see android hdr-image-format
+[guide](https://developer.android.com/guide/topics/media/platform/hdr-image-format).
-Building libultrahdr
-======================
+## Building libultrahdr
-libultrahdr compresses base image and gain map image in to jpeg format.
-For this libjpeg-turbo is used. This is cloned from
-<https://github.com/libjpeg-turbo/libjpeg-turbo.git> and included in the
-build process.
-
-Requirements
---------------
+### Requirements
- [CMake](http://www.cmake.org) v3.13 or later
-
-- [NASM](http://www.nasm.us) or [Yasm](http://yasm.tortall.net)
- (If libjpeg-turbo needs to be built with SIMD extensions)
+- C++ compiler, supporting at least C++17.
+- libultrahdr uses jpeg compression format to store sdr image and gainmap quotient.
+ So, libjpeg or any other jpeg codec that is ABI and API compatible with libjpeg.
+
+The library offers a way to skip installing libjpeg by passing `UHDR_BUILD_DEPS=1`
+at the time of configure. That is, `cmake -DUHDR_BUILD_DEPS=1` will clone jpeg codec
+from [link](https://github.com/libjpeg-turbo/libjpeg-turbo.git) and include it in
+the build process. This is however not recommended.
+
+If jpeg is included in the build process then to build jpeg with simd extensions,
+- C compiler
+- [NASM](http://www.nasm.us) or [Yasm](http://yasm.tortall.net) are needed.
* If using NASM, 2.13 or later is required.
* If using Yasm, 1.2.0 or later is required.
- * If building on macOS, NASM or Yasm can be obtained from
- [MacPorts](http://www.macports.org/) or [Homebrew](http://brew.sh/).
-
-- Compilers with support for C++17
-Should work with GCC v7 (or later) and Clang 5 (or later) on Linux and Mac Platforms.
-
-Should work with Microsoft Visual C++ 2019 (or later) on Windows Platforms.
-
-Build Procedure
----------------
+### Build Procedure
To build libultrahdr, examples, unit tests:
### Un*x (including Linux, Mac)
- mkdir {build_directory}
- cd {build_directory}
- cmake -G "Unix Makefiles" -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DUHDR_BUILD_TESTS=1 ../
+ mkdir build_directory
+ cd build_directory
+ cmake -G "Unix Makefiles" -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DUHDR_BUILD_TESTS=1 ../
make
ctest
+ make install
-This will generate the following files under *{build_directory}*:
+This will generate the following files under `build_directory`:
-**libultrahdr.a**<br> Static link library for the ultrahdr API
+**libuhdr.so or libuhdr.dylib**<br> ultrahdr shared library
-**ultrahdr_app**<br> Sample application demonstrating ultrahdr API
+**libuhdr.pc**<br> ultrahdr pkg-config file
-**ultrahdr_unit_test**<br> Unit tests
+**ultrahdr_app**<br> Statically linked sample application demonstrating ultrahdr API usage
-### Visual C++ (IDE)
-
- mkdir {build_directory}
- cd {build_directory}
- cmake -G "Visual Studio 16 2019" -DUHDR_BUILD_TESTS=1 ../
- cmake --build ./ --config=Release
- ctest -C Release
+**ultrahdr_unit_test**<br> Unit tests
-This will generate the following files under *{build_directory/Release}*:
+`make install` will install libuhdr.so, ultrahdr_api.h, libuhdr.pc for system-wide usage and
+`make uninstall` will remove the same.
-**ultrahdr.lib**<br> Static link library for the ultrahdr API
+NOTE: you may need to run `ldconfig` after install/uninstall
-**ultrahdr_app.exe**<br> Sample application demonstrating ultrahdr API
+### MinGW
-**ultrahdr_unit_test.exe**<br> Unit tests
+NOTE: This assumes that you are building on a Windows machine using the MSYS
+environment.
-### Visual C++ (Command line)
+ mkdir build_directory
+ cd build_directory
+ cmake -G "MSYS Makefiles" -DUHDR_BUILD_TESTS=1 ../
+ cmake --build ./
+ ctest
- mkdir {build_directory}
- cd {build_directory}
- cmake -G "NMake Makefiles" -DUHDR_BUILD_TESTS=1 ../
+ mkdir build_directory
+ cd build_directory
+ cmake -G "MinGW Makefiles" -DUHDR_BUILD_TESTS=1 ../
cmake --build ./
ctest
-This will generate the following files under *{build_directory}*:
+This will generate the following files under `build_directory`:
-**ultrahdr.lib**<br> Static link library for the ultrahdr API
+**libuhdr.dll**<br> ultrahdr shared library
**ultrahdr_app.exe**<br> Sample application demonstrating ultrahdr API
**ultrahdr_unit_test.exe**<br> Unit tests
-### MinGW
+### Visual C++ (IDE)
-NOTE: This assumes that you are building on a Windows machine using the MSYS
-environment.
+ mkdir build_directory
+ cd build_directory
+ cmake -G "Visual Studio 16 2019" -DUHDR_BUILD_DEPS=1 -DUHDR_BUILD_TESTS=1 ../
+ cmake --build ./ --config=Release
+ ctest -C Release
- mkdir {build_directory}
- cd {build_directory}
- cmake -G "MSYS Makefiles" -DUHDR_BUILD_TESTS=1 ../
- cmake --build ./
- ctest
+This will generate the following files under `build_directory/Release`:
- mkdir {build_directory}
- cd {build_directory}
- cmake -G "MinGW Makefiles" -DUHDR_BUILD_TESTS=1 ../
+**ultrahdr_app.exe**<br> Sample application demonstrating ultrahdr API
+
+**ultrahdr_unit_test.exe**<br> Unit tests
+
+### Visual C++ (Command line)
+
+ mkdir build_directory
+ cd build_directory
+ cmake -G "NMake Makefiles" -DUHDR_BUILD_DEPS=1 -DUHDR_BUILD_TESTS=1 ../
cmake --build ./
ctest
-This will generate the following files under *{build_directory}*:
-
-**libultrahdr.a**<br> Static link library for the ultrahdr API
+This will generate the following files under `build_directory`:
**ultrahdr_app.exe**<br> Sample application demonstrating ultrahdr API
**ultrahdr_unit_test.exe**<br> Unit tests
-NOTE: To not build unit tests, skip passing -DUHDR_BUILD_TESTS=1
+NOTE: To not build unit tests, skip passing `-DUHDR_BUILD_TESTS=1`
### Building Benchmark
-To build benchmarks, pass -DUHDR_BUILD_BENCHMARK=1 to cmake configure command and build.
+To build benchmarks, pass `-DUHDR_BUILD_BENCHMARK=1` to cmake configure command and build.
This will additionally generate,
@@ -135,32 +131,34 @@ This will additionally generate,
Refer to [README.md](fuzzer/README.md) for complete instructions.
-Using libultrahdr
-===================
+## Using libultrahdr
+
+A detailed description of libultrahdr encode and decode api is included in [ultrahdr_api.h](ultrahdr_api.h)
+and for sample usage refer [demo app](examples/ultrahdr_app.cpp).
+
+libultrahdr includes two classes of APIs, one to compress and the other to decompress HDR images:
+
+### Encoding api outline:
+
+| Scenario | Hdr intent raw | Sdr intent raw | Sdr intent compressed | Gain map compressed | Quality | Exif | Use Case |
+|:---------:| :----------: | :----------: | :---------------------: | :-------------------: | :-------: | :---------: | :-------- |
+| API - 0 | P010 | No | No | No | Optional| Optional | Used if, only hdr raw intent is present. (Experimental).[^1] |
+| API - 1 | P010 | YUV420 | No | No | Optional| Optional | Used if, hdr raw and sdr raw intents are present.[^2] |
+| API - 2 | P010 | YUV420 | Yes | No | No | No | Used if, hdr raw, sdr raw and sdr compressed intents are present.[^3] |
+| API - 3 | P010 | No | Yes | No | No | No | Used if, hdr raw and sdr compressed intents are present.[^4] |
+| API - 4 | No | No | Yes | Yes | No | No | Used if, sdr compressed, gain map compressed and GainMap Metadata are present.[^5] |
+
+[^1]: Tonemap hdr to sdr. Compute gain map from hdr and sdr. Compress sdr and gainmap at quality configured. Add exif if provided. Combine sdr compressed, gainmap in multi picture format with gainmap metadata.
+[^2]: Compute gain map from hdr and sdr. Compress sdr and gainmap at quality configured. Add exif if provided. Combine sdr compressed, gainmap in multi picture format with gainmap metadata.
+[^3]: Compute gain map from hdr and raw sdr. Compress gainmap. Combine sdr compressed, gainmap in multi picture format with gainmap metadata.
+[^4]: Decode compressed sdr input. Compute gain map from hdr and decoded sdr. Compress gainmap. Combine sdr compressed, gainmap in multi picture format with gainmap metadata.
+[^5]: Combine sdr compressed, gainmap in multi picture format with gainmap metadata.
-libultrahdr includes two classes of APIs, one to compress and the other to
-decompress HDR images:
+### Decoding api outline:
-List of encode APIs:
-| Input | HDR YUV | SDR YUV | JPEG | Encoded gainmap | Quality (0 ~ 100) | EXIF | Use case |
-| ------------- | ------------- | ------------- | ------------- | ------------- | ------------- | ------------- | ------------- |
-| API-0 | P010 | No | No | No | Required | Optional | Experimental only. |
-| API-1 | P010 | YUV_420 | No | No | Required | Optional | Raw SDR input. Primary image will be encoded from the raw SDR input in the library. |
-| API-2 | P010 | YUV_420 | Yes | No | No | No | Both JPEG and raw SDR inputs. Gainmap will be calculated from raw HDR and raw SDR inputs, the JPEG input will be preserved (including metadata) as the primary image. |
-| API-3 | P010 | No | Yes | No | No | No | SDR JPEG input. Gainmap will be calculated from raw HDR and the decoding result of the JPEG input, the JPEG input will be preserved (including metadata) as the primary image. |
-| API-4 | No | No | Yes | Yes | No | No | SDR JPEG and gainmap inputs. The library will only generate the Ultra HDR related metadata and write everything into the Ultra HDR format, all other metadata from the JPEG input will be preserved. |
+Configure display device characteristics (display transfer characteristics, max display boost) for optimal usage.
-List of decode API:
| Input | Usage |
| ------------- | ------------- |
-| compressed_jpegr_image | The input data. Pointer to JPEG/R stream. |
-| dest | The output data. Destination that decoded data to be written. |
| max_display_boost | (optional, >= 1.0) the maximum available boost supported by a display. |
-| exif | (optional, default to NULL) Destination that exif data to be written. |
-| gain_map | (optional, default to NULL) Destination that decoded gain map data to be written. |
-| output_format | <table><thead><tr><th>Value</th><th>Color format to be written</th></tr></thead><tbody><tr><td>SDR</td><td>RGBA_8888</td></tr><tr><td>HDR_LINEAR</td><td>(default) RGBA_F16 linear</td></tr><tr><td>HDR_PQ</td><td>RGBA_1010102 PQ</td></tr><tr><td>HDR_HLG</td><td>RGBA_1010102 HLG</td></tr></tbody></table> |
-| metadata | (optional, default to NULL) Destination of metadata (gain map version, min/max content boost). |
-
-For more info:
-- Refer to [ultrahdr_api.h](ultrahdr_api.h) for detailed description of various encode and decode api.
-- Refer to [ultrahdr_app.cpp](examples/ultrahdr_app.cpp) for examples of its usage.
+| supported color transfer format pairs | <table><thead><tr><th>color transfer</th><th>Color format </th></tr></thead><tbody><tr><td>SDR</td><td>32bppRGBA8888</td></tr><tr><td>HDR_LINEAR</td><td>64bppRGBAHalfFloat</td></tr><tr><td>HDR_PQ</td><td>32bppRGBA1010102 PQ</td></tr><tr><td>HDR_HLG</td><td>32bppRGBA1010102 HLG</td></tr></tbody></table> |
diff --git a/fuzzer/README.md b/fuzzer/README.md
index e48d859..0550eae 100644
--- a/fuzzer/README.md
+++ b/fuzzer/README.md
@@ -1,12 +1,11 @@
-Building fuzzers for libultrahdr
-================================
+## Building fuzzers for libultrahdr
### Requirements
- Refer [Requirements](../README.md#Requirements)
-- Additionally compilers are required to support options *-fsanitize=fuzzer, -fsanitize=fuzzer-no-link*.
- For instance, clang 12 (or later)
+- Additionally compilers are required to support options `-fsanitize=fuzzer, -fsanitize=fuzzer-no-link`.
+ For instance, `clang 12` (or later)
### Building Commands
@@ -15,16 +14,14 @@ Building fuzzers for libultrahdr
cmake ../ -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DUHDR_BUILD_FUZZERS=1
make
-This will generate the following files under *{build_directory}*:
-
-**libultrahdr.a**<br> Instrumented ultrahdr library
+This will generate the following files under `build_directory`:
**ultrahdr_enc_fuzzer**<br> ultrahdr encoder fuzzer
**ultrahdr_dec_fuzzer**<br> ultrahdr decoder fuzzer
Additionally, while building fuzzers, user can enable sanitizers by providing desired
-sanitizer option(s) through UHDR_SANITIZE_OPTIONS.
+sanitizer option(s) through `UHDR_SANITIZE_OPTIONS`.
To enable ASan,
diff --git a/libuhdr.pc.template b/libuhdr.pc.template
index b0a83ca..d50ec00 100644
--- a/libuhdr.pc.template
+++ b/libuhdr.pc.template
@@ -1,11 +1,11 @@
-prefix="@CMAKE_INSTALL_PREFIX@"
-libdir="${prefix}/lib/@CMAKE_LIBRARY_ARCHITECTURE@"
-includedir="${prefix}/include"
+prefix=@CMAKE_INSTALL_PREFIX@
+libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
+includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
Name: @PROJECT_NAME@
Description: @CMAKE_PROJECT_DESCRIPTION@
Version: @PROJECT_VERSION@
-Requires: libjpeg
+Requires.private: libjpeg
Cflags: -I${includedir}
Libs: -L${libdir} -l@UHDR_TARGET_NAME@
Libs.private: @CMAKE_THREAD_LIBS_INIT@