• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "ext_stream.h"
22 #ifdef USE_M133_SKIA
23 #include "include/core/SkStream.h"
24 #endif
25 #include "hdr_type.h"
26 
27 namespace OHOS {
28 namespace ImagePlugin {
29 class HdrHelper {
30 public:
31     static Media::ImageHdrType CheckHdrType(SkCodec* codec, uint32_t& offset);
32     static void ValidateAndCorrectMetaData(Media::HdrMetadata& metadata, Media::ImageHdrType type);
33     static bool GetMetadata(SkCodec* codec, Media::ImageHdrType type, Media::HdrMetadata& metadata);
34     static bool CheckGainmapOffset(Media::ImageHdrType type, InputDataStream *stream, uint32_t& offset);
35 };
36 
37 class HdrJpegPackerHelper {
38 public:
39     static uint32_t SpliceHdrStream(sk_sp<SkData>& baseImage, sk_sp<SkData>& gainmapImage,
40         SkWStream& output, Media::HdrMetadata& metadata);
41     uint32_t SpliceLogHdrStream(sk_sp<SkData>& baseImage,
42         SkWStream& output, Media::HdrMetadata& metadata);
43 private:
44     static std::vector<uint8_t> PackVividMetadataMarker(Media::HdrMetadata& metadata);
45     static std::vector<uint8_t> PackISOMetadataMarker(Media::HdrMetadata& metadata);
46     static std::vector<uint8_t> PackBaseVividMarker(uint32_t gainmapOffset, uint32_t preOffset, uint32_t appSize);
47     static std::vector<uint8_t> PackBaseMpfMarker(uint32_t baseSize, uint32_t gainmapSize, uint32_t appOffset);
48     static std::vector<uint8_t> PackBaseISOMarker();
49     static std::vector<uint8_t> PackHdrMediaTypeMarker(Media::HdrMetadata& hdrMetadata);
50     static uint32_t GetBaseVividMarkerSize();
51     static uint32_t GetMpfMarkerSize();
52 };
53 
54 class HdrHeifPackerHelper {
55 public:
56     static bool PackIT35Info(Media::HdrMetadata& metadata, std::vector<uint8_t>& info);
57 };
58 } // namespace Media
59 } // namespace OHOS
60 
61 #endif // PLUGINS_COMMON_LIBS_IMAGE_LIBEXTPLUGIN_INCLUDE_HDR_HDR_HELPER_H