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_REF_BOX_H 17 #define PLUGINS_COMMON_LIBS_IMAGE_LIBEXTPLUGIN_INCLUDE_HEIF_PARSER_ITEM_REF_BOX_H 18 19 #include "heif_box.h" 20 21 namespace OHOS { 22 namespace ImagePlugin { 23 class HeifIrefBox : public HeifFullBox { 24 public: HeifIrefBox()25 HeifIrefBox() : HeifFullBox(BOX_TYPE_IREF) {} 26 27 struct Reference { 28 HeifBox box; 29 heif_item_id fromItemId; 30 std::vector<heif_item_id> toItemIds; 31 }; 32 33 bool HasReferences(heif_item_id itemId) const; 34 35 std::vector<heif_item_id> GetReferences(heif_item_id itemId, uint32_t ref_type) const; 36 37 std::vector<Reference> GetReferencesFrom(heif_item_id itemId) const; 38 39 void AddReferences(heif_item_id from_id, uint32_t type, const std::vector<heif_item_id> &to_ids); 40 41 protected: 42 heif_error ParseContent(HeifStreamReader &reader) override; 43 44 heif_error Write(HeifStreamWriter &writer) const override; 45 46 void InferFullBoxVersion() override; 47 48 private: 49 void ParseItemRef(HeifStreamReader &reader, Reference& ref); 50 51 std::vector<Reference> references_; 52 }; 53 } // namespace ImagePlugin 54 } // namespace OHOS 55 56 #endif // PLUGINS_COMMON_LIBS_IMAGE_LIBEXTPLUGIN_INCLUDE_HEIF_PARSER_ITEM_REF_BOX_H 57