1 /* 2 * Copyright (C) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef FRAMEWORKS_INNERKITSIMPL_UTILS_INCLUDE_HDR_TYPE_H 17 #define FRAMEWORKS_INNERKITSIMPL_UTILS_INCLUDE_HDR_TYPE_H 18 #include <vector> 19 namespace OHOS { 20 namespace Media { 21 22 constexpr uint8_t GAINMAP_CHANNEL_NUM_ONE = 0x01; 23 constexpr uint8_t GAINMAP_CHANNEL_NUM_THREE = 0x03; 24 25 enum class ImageHdrType : int32_t { 26 UNKNOWN = 0, 27 SDR, 28 HDR_ISO_DUAL, 29 HDR_CUVA, 30 HDR_VIVID_DUAL, 31 HDR_VIVID_SINGLE, 32 HDR_ISO_SINGLE, 33 HDR_LOG_DUAL, 34 }; 35 36 typedef struct ISOMetadata { 37 unsigned short writeVersion; 38 unsigned short miniVersion; 39 unsigned char gainmapChannelNum; 40 unsigned char useBaseColorFlag; 41 float baseHeadroom; 42 float alternateHeadroom; 43 float enhanceClippedThreholdMaxGainmap[3]; 44 float enhanceClippedThreholdMinGainmap[3]; 45 float enhanceMappingGamma[3]; 46 float enhanceMappingBaselineOffset[3]; 47 float enhanceMappingAlternateOffset[3]; 48 } ISOMetadata; 49 50 typedef struct GainmapColorMetadata { 51 unsigned char enhanceDataColorPrimary; 52 unsigned char enhanceDataTransFunction; 53 unsigned char enhanceDataColorModel; 54 55 unsigned char combineColorPrimary; 56 unsigned char combineTransFunction; 57 unsigned char combineColorModel; 58 59 unsigned char alternateColorPrimary; 60 unsigned char alternateTransFunction; 61 unsigned char alternateColorModel; 62 63 unsigned short enhanceICCSize; 64 std::vector<unsigned char> enhanceICC; 65 66 unsigned char combineMappingFlag; 67 unsigned short combineMappingSize; 68 unsigned char combineMappingMatrix[9]; 69 std::vector<unsigned char> combineMapping; 70 } GainmapColorMetadata; 71 72 typedef struct BaseColorMetadata { 73 unsigned char baseColorPrimary; 74 unsigned char baseTransFunction; 75 unsigned char baseColorModel; 76 77 unsigned short baseIccSize; 78 std::vector<unsigned char> baseICC; 79 80 unsigned char baseMappingFlag; 81 unsigned short baseMappingSize; 82 unsigned char baseMappingMatrix[9]; 83 std::vector<unsigned char> baseMapping; 84 } BaseColorMetadata; 85 86 typedef struct HDRVividExtendMetadata { 87 ISOMetadata metaISO; 88 GainmapColorMetadata gainmapColorMeta; 89 BaseColorMetadata baseColorMeta; 90 } HDRVividExtendMetadata; 91 92 struct HdrMetadata { 93 std::vector<uint8_t> staticMetadata; 94 std::vector<uint8_t> dynamicMetadata; 95 bool extendMetaFlag = false; 96 HDRVividExtendMetadata extendMeta; 97 int32_t hdrMetadataType; 98 }; 99 100 struct LogResMapMetadata { 101 uint16_t height; 102 uint16_t width; 103 uint16_t pixelFormat; 104 uint16_t primaries; 105 uint16_t transfunc; 106 uint16_t matrix; 107 uint16_t range; 108 }; 109 } // namespace Media 110 } // namespace OHOS 111 112 #endif // FRAMEWORKS_INNERKITSIMPL_UTILS_INCLUDE_HDR_TYPE_H