• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2023 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef ANDROID_ULTRAHDR_ULTRAHDR_H
18 #define ANDROID_ULTRAHDR_ULTRAHDR_H
19 
20 namespace android::ultrahdr {
21 // Color gamuts for image data
22 typedef enum {
23   ULTRAHDR_COLORGAMUT_UNSPECIFIED = -1,
24   ULTRAHDR_COLORGAMUT_BT709,
25   ULTRAHDR_COLORGAMUT_P3,
26   ULTRAHDR_COLORGAMUT_BT2100,
27   ULTRAHDR_COLORGAMUT_MAX = ULTRAHDR_COLORGAMUT_BT2100,
28 } ultrahdr_color_gamut;
29 
30 // Transfer functions for image data
31 typedef enum {
32   ULTRAHDR_TF_UNSPECIFIED = -1,
33   ULTRAHDR_TF_LINEAR = 0,
34   ULTRAHDR_TF_HLG = 1,
35   ULTRAHDR_TF_PQ = 2,
36   ULTRAHDR_TF_SRGB = 3,
37   ULTRAHDR_TF_MAX = ULTRAHDR_TF_SRGB,
38 } ultrahdr_transfer_function;
39 
40 // Target output formats for decoder
41 typedef enum {
42   ULTRAHDR_OUTPUT_UNSPECIFIED = -1,
43   ULTRAHDR_OUTPUT_SDR,          // SDR in RGBA_8888 color format
44   ULTRAHDR_OUTPUT_HDR_LINEAR,   // HDR in F16 color format (linear)
45   ULTRAHDR_OUTPUT_HDR_PQ,       // HDR in RGBA_1010102 color format (PQ transfer function)
46   ULTRAHDR_OUTPUT_HDR_HLG,      // HDR in RGBA_1010102 color format (HLG transfer function)
47   ULTRAHDR_OUTPUT_MAX = ULTRAHDR_OUTPUT_HDR_HLG,
48 } ultrahdr_output_format;
49 
50 /*
51  * Holds information for gain map related metadata.
52  *
53  * Not: all values stored in linear. This differs from the metadata encoding in XMP, where
54  * maxContentBoost (aka gainMapMax), minContentBoost (aka gainMapMin), hdrCapacityMin, and
55  * hdrCapacityMax are stored in log2 space.
56  */
57 struct ultrahdr_metadata_struct {
58   // Ultra HDR format version
59   std::string version;
60   // Max Content Boost for the map
61   float maxContentBoost;
62   // Min Content Boost for the map
63   float minContentBoost;
64   // Gamma of the map data
65   float gamma;
66   // Offset for SDR data in map calculations
67   float offsetSdr;
68   // Offset for HDR data in map calculations
69   float offsetHdr;
70   // HDR capacity to apply the map at all
71   float hdrCapacityMin;
72   // HDR capacity to apply the map completely
73   float hdrCapacityMax;
74 };
75 typedef struct ultrahdr_metadata_struct* ultrahdr_metadata_ptr;
76 
77 }  // namespace android::ultrahdr
78 
79 #endif //ANDROID_ULTRAHDR_ULTRAHDR_H
80