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_HEIF_PARSER_ITEM_PROPERTY_DISPLAY_BOX_H
17 #define PLUGINS_COMMON_LIBS_IMAGE_LIBEXTPLUGIN_INCLUDE_HEIF_PARSER_ITEM_PROPERTY_DISPLAY_BOX_H
18 
19 #include "box/heif_box.h"
20 
21 namespace OHOS {
22 namespace ImagePlugin {
23 
24 typedef struct {
25     uint16_t x;
26     uint16_t y;
27 } DisplayPrimariesXY;
28 
29 typedef struct {
30     DisplayPrimariesXY red;
31     DisplayPrimariesXY green;
32     DisplayPrimariesXY blue;
33     DisplayPrimariesXY whitePoint;
34     uint32_t luminanceMax;
35     uint32_t luminanceMin;
36 } DisplayColourVolume;
37 
38 typedef struct {
39     uint16_t maxContentLightLevel;
40     uint16_t maxPicAverageLightLevel;
41 } ContentLightLevelInfo;
42 
43 
44 class HeifMdcvBox : public HeifBox {
45 public:
HeifMdcvBox()46     HeifMdcvBox() : HeifBox(BOX_TYPE_MDCV) {}
47 
GetColourVolume()48     DisplayColourVolume GetColourVolume() const { return colourVolume_; };
49 
SetColourVolume(DisplayColourVolume colourVolume)50     void SetColourVolume(DisplayColourVolume colourVolume) { colourVolume_ = colourVolume; };
51 protected:
52     heif_error ParseContent(HeifStreamReader &reader) override;
53 
54     heif_error Write(HeifStreamWriter &writer) const override;
55 
56 private:
57     DisplayColourVolume colourVolume_{};
58 };
59 
60 class HeifClliBox : public HeifBox {
61 public:
HeifClliBox()62     HeifClliBox() : HeifBox(BOX_TYPE_CLLI) {}
63 
GetLightLevel()64     ContentLightLevelInfo GetLightLevel() const { return lightLevel_; };
SetLightLevel(ContentLightLevelInfo lightLevel)65     void SetLightLevel(ContentLightLevelInfo lightLevel) { lightLevel_ = lightLevel; };
66 protected:
67     heif_error ParseContent(HeifStreamReader &reader) override;
68 
69     heif_error Write(HeifStreamWriter &writer) const override;
70 
71 private:
72     ContentLightLevelInfo lightLevel_;
73 };
74 }
75 }
76 #endif //PLUGINS_COMMON_LIBS_IMAGE_LIBEXTPLUGIN_INCLUDE_HEIF_PARSER_ITEM_PROPERTY_DISPLAY_BOX_H