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_BASIC_BOX_H
17 #define PLUGINS_COMMON_LIBS_IMAGE_LIBEXTPLUGIN_INCLUDE_HEIF_PARSER_ITEM_PROPERTY_BASIC_BOX_H
18 
19 #include "box/heif_box.h"
20 
21 namespace OHOS {
22 namespace ImagePlugin {
23 class HeifIspeBox : public HeifFullBox {
24 public:
HeifIspeBox()25     HeifIspeBox() : HeifFullBox(BOX_TYPE_ISPE) {}
26 
GetWidth()27     uint32_t GetWidth() const { return width_; }
28 
GetHeight()29     uint32_t GetHeight() const { return height_; }
30 
SetDimension(uint32_t width,uint32_t height)31     void SetDimension(uint32_t width, uint32_t height)
32     {
33         width_ = width;
34         height_ = height;
35     }
36 
37     heif_error Write(HeifStreamWriter &writer) const override;
38 
39 protected:
40     heif_error ParseContent(HeifStreamReader &reader) override;
41 
42 private:
43     uint32_t width_ = 0;
44     uint32_t height_ = 0;
45 };
46 
47 class HeifPixiBox : public HeifFullBox {
48 public:
HeifPixiBox()49     HeifPixiBox() : HeifFullBox(BOX_TYPE_PIXI) {}
50 
GetChannelNum()51     int GetChannelNum() const { return (int) bitNums_.size(); }
52 
GetBitNum(int channel)53     int GetBitNum(int channel) const { return bitNums_[channel]; }
54 
AddBitNum(uint8_t c)55     void AddBitNum(uint8_t c)
56     {
57         bitNums_.push_back(c);
58     }
59 
60     heif_error Write(HeifStreamWriter &writer) const override;
61 
62 protected:
63     heif_error ParseContent(HeifStreamReader &reader) override;
64 
65 private:
66     std::vector<uint8_t> bitNums_;
67 };
68 
69 class HeifRlocBox : public HeifFullBox {
70 public:
HeifRlocBox()71     HeifRlocBox() : HeifFullBox(BOX_TYPE_RLOC) {}
72 
GetX()73     uint32_t GetX() const { return horizontalOffset_; }
74 
GetY()75     uint32_t GetY() const { return verticalOffset_; }
76 
SetLocation(const uint32_t horizontalOffset,const uint32_t verticalOffset)77     void SetLocation(const uint32_t horizontalOffset, const uint32_t verticalOffset)
78     {
79         horizontalOffset_ = horizontalOffset;
80         verticalOffset_ = verticalOffset;
81     }
82 
83     heif_error Write(HeifStreamWriter &writer) const override;
84 
85 protected:
86     heif_error ParseContent(HeifStreamReader &reader) override;
87 
88 private:
89     uint32_t horizontalOffset_ = 0;
90     uint32_t verticalOffset_ = 0;
91 };
92 } // namespace ImagePlugin
93 } // namespace OHOS
94 
95 #endif // PLUGINS_COMMON_LIBS_IMAGE_LIBEXTPLUGIN_INCLUDE_HEIF_PARSER_ITEM_PROPERTY_BASIC_BOX_H
96