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 PLUGINS_COMMON_LIBS_IMAGE_LIBEXTPLUGIN_INCLUDE_HDR_HDR_HELPER_H 17 #define PLUGINS_COMMON_LIBS_IMAGE_LIBEXTPLUGIN_INCLUDE_HDR_HDR_HELPER_H 18 19 #include "box/item_property_display_box.h" 20 #include "include/codec/SkCodec.h" 21 #include "hdr_type.h" 22 23 namespace OHOS { 24 namespace ImagePlugin { 25 class HdrHelper { 26 public: 27 static Media::ImageHdrType CheckHdrType(SkCodec* codec, uint32_t& offset); 28 static bool GetMetadata(SkCodec* codec, Media::ImageHdrType type, Media::HdrMetadata& metadata); 29 }; 30 31 class HdrJpegPackerHelper { 32 public: 33 static uint32_t SpliceHdrStream(sk_sp<SkData>& baseImage, sk_sp<SkData>& gainmapImage, 34 SkWStream& output, Media::HdrMetadata& metadata); 35 private: 36 static std::vector<uint8_t> PackVividMetadataMarker(Media::HdrMetadata& metadata); 37 static std::vector<uint8_t> PackISOMetadataMarker(Media::HdrMetadata& metadata); 38 static std::vector<uint8_t> PackBaseVividMarker(uint32_t gainmapOffset, uint32_t preOffset, uint32_t appSize); 39 static std::vector<uint8_t> PackBaseMpfMarker(uint32_t baseSize, uint32_t gainmapSize, uint32_t appOffset); 40 static std::vector<uint8_t> PackBaseISOMarker(); 41 static std::vector<uint8_t> PackHdrMediaTypeMarker(Media::HdrMetadata& hdrMetadata); 42 static uint32_t GetBaseVividMarkerSize(); 43 static uint32_t GetMpfMarkerSize(); 44 }; 45 46 class HdrHeifPackerHelper { 47 public: 48 static bool PackIT35Info(Media::HdrMetadata& metadata, std::vector<uint8_t>& info); 49 }; 50 } // namespace Media 51 } // namespace OHOS 52 53 #endif // PLUGINS_COMMON_LIBS_IMAGE_LIBEXTPLUGIN_INCLUDE_HDR_HDR_HELPER_H