xref: /aosp_15_r20/external/libultrahdr/README.md (revision 89a0ef05262152531a00a15832a2d3b1e3990773)
1*89a0ef05SAndroid Build Coastguard Worker## Introduction
2*89a0ef05SAndroid Build Coastguard Worker
3*89a0ef05SAndroid Build Coastguard Workerlibultrahdr is an image compression library that uses gain map technology
4*89a0ef05SAndroid Build Coastguard Workerto store and distribute HDR images. Conceptually on the encoding side, the
5*89a0ef05SAndroid Build Coastguard Workerlibrary accepts SDR and HDR rendition of an image and from these a Gain Map
6*89a0ef05SAndroid Build Coastguard Worker(quotient between the two renditions) is computed. The library then uses
7*89a0ef05SAndroid Build Coastguard Workerbackward compatible means to store the base image (SDR), gain map image and
8*89a0ef05SAndroid Build Coastguard Workersome associated metadata. Legacy readers that do not support handling the
9*89a0ef05SAndroid Build Coastguard Workergain map image and/or metadata, will display the base image. Readers that
10*89a0ef05SAndroid Build Coastguard Workersupport the format combine the base image with the gain map and render a
11*89a0ef05SAndroid Build Coastguard Workerhigh dynamic range image on compatible displays.
12*89a0ef05SAndroid Build Coastguard Worker
13*89a0ef05SAndroid Build Coastguard WorkerFor additional information, see android hdr-image-format
14*89a0ef05SAndroid Build Coastguard Worker[guide](https://developer.android.com/guide/topics/media/platform/hdr-image-format).
15*89a0ef05SAndroid Build Coastguard Worker
16*89a0ef05SAndroid Build Coastguard Worker## Build from source using CMake
17*89a0ef05SAndroid Build Coastguard Worker
18*89a0ef05SAndroid Build Coastguard WorkerThis software suite has been built and tested on platforms:
19*89a0ef05SAndroid Build Coastguard Worker- Android
20*89a0ef05SAndroid Build Coastguard Worker- Linux
21*89a0ef05SAndroid Build Coastguard Worker- macOS
22*89a0ef05SAndroid Build Coastguard Worker- Windows
23*89a0ef05SAndroid Build Coastguard Worker
24*89a0ef05SAndroid Build Coastguard WorkerRefer to [building.md](docs/building.md) for complete instructions.
25*89a0ef05SAndroid Build Coastguard Worker
26*89a0ef05SAndroid Build Coastguard Worker## Using libultrahdr
27*89a0ef05SAndroid Build Coastguard Worker
28*89a0ef05SAndroid Build Coastguard WorkerA detailed description of libultrahdr encode and decode api is included in [ultrahdr_api.h](ultrahdr_api.h)
29*89a0ef05SAndroid Build Coastguard Workerand for sample usage refer [demo app](examples/ultrahdr_app.cpp).
30*89a0ef05SAndroid Build Coastguard Worker
31*89a0ef05SAndroid Build Coastguard Workerlibultrahdr includes two classes of APIs, one to compress and the other to decompress HDR images:
32*89a0ef05SAndroid Build Coastguard Worker
33*89a0ef05SAndroid Build Coastguard Worker### Encoding api outline:
34*89a0ef05SAndroid Build Coastguard Worker
35*89a0ef05SAndroid Build Coastguard Worker| Scenario  | Hdr intent raw | Sdr intent raw | Sdr intent compressed | Gain map compressed | Quality |   Exif   | Use Case |
36*89a0ef05SAndroid Build Coastguard Worker|:---------:| :----------: | :----------: | :---------------------: | :-------------------: | :-------: | :---------: | :-------- |
37*89a0ef05SAndroid Build Coastguard Worker| API - 0 | P010 or rgba1010102 or rgbaf16 |    No   |  No  |  No  | Optional| Optional | Used if, only hdr raw intent is present. [^1] |
38*89a0ef05SAndroid Build Coastguard Worker| API - 1 | P010 or rgba1010102 or rgbaf16 | YUV420 or rgba8888 |  No  |  No  | Optional| Optional | Used if, hdr raw and sdr raw intents are present.[^2] |
39*89a0ef05SAndroid Build Coastguard Worker| API - 2 | P010 or rgba1010102 or rgbaf16 | YUV420 or rgba8888 | Yes  |  No  |    No   |    No    | Used if, hdr raw, sdr raw and sdr compressed intents are present.[^3] |
40*89a0ef05SAndroid Build Coastguard Worker| API - 3 | P010 or rgba1010102 or rgbaf16 |    No   | Yes  |  No  |    No   |    No    | Used if, hdr raw and sdr compressed intents are present.[^4] |
41*89a0ef05SAndroid Build Coastguard Worker| API - 4 |  No  |    No   | Yes  | Yes  |    No   |    No    | Used if, sdr compressed, gain map compressed and GainMap Metadata are present.[^5] |
42*89a0ef05SAndroid Build Coastguard Worker
43*89a0ef05SAndroid Build Coastguard Worker[^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.
44*89a0ef05SAndroid Build Coastguard Worker[^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.
45*89a0ef05SAndroid Build Coastguard Worker[^3]: Compute gain map from hdr and raw sdr. Compress gainmap. Combine sdr compressed, gainmap in multi picture format with gainmap metadata.
46*89a0ef05SAndroid Build Coastguard Worker[^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.
47*89a0ef05SAndroid Build Coastguard Worker[^5]: Combine sdr compressed, gainmap in multi picture format with gainmap metadata.
48*89a0ef05SAndroid Build Coastguard Worker
49*89a0ef05SAndroid Build Coastguard Worker### Decoding api outline:
50*89a0ef05SAndroid Build Coastguard Worker
51*89a0ef05SAndroid Build Coastguard WorkerConfigure display device characteristics (display transfer characteristics, max display boost) for optimal usage.
52*89a0ef05SAndroid Build Coastguard Worker
53*89a0ef05SAndroid Build Coastguard Worker| Input  | Usage |
54*89a0ef05SAndroid Build Coastguard Worker| ------------- | ------------- |
55*89a0ef05SAndroid Build Coastguard Worker| max_display_boost  | (optional, >= 1.0) the maximum available boost supported by a display. |
56*89a0ef05SAndroid Build Coastguard Worker| 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> |
57