1 /* 2 * Copyright (C) 2021 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 HEIF_DECODER_H 17 #define HEIF_DECODER_H 18 19 #include <memory> 20 #include "abs_image_decoder.h" 21 #include "heif_decoder_wrapper.h" 22 #include "hilog/log.h" 23 #include "log_tags.h" 24 #include "nocopyable.h" 25 #include "plugin_class_base.h" 26 27 namespace OHOS { 28 namespace ImagePlugin { 29 class HeifDecoder : public AbsImageDecoder, public MultimediaPlugin::PluginClassBase { 30 public: 31 HeifDecoder() = default; ~HeifDecoder()32 virtual ~HeifDecoder() override{}; 33 virtual void SetSource(InputDataStream &sourceStream) override; 34 virtual void Reset() override; 35 virtual uint32_t SetDecodeOptions(uint32_t index, const PixelDecodeOptions &opts, PlImageInfo &info) override; 36 virtual uint32_t Decode(uint32_t index, DecodeContext &context) override; 37 virtual uint32_t PromoteIncrementalDecode(uint32_t index, ProgDecodeContext &context) override; 38 virtual uint32_t GetTopLevelImageNum(uint32_t &num) override; 39 virtual uint32_t GetImageSize(uint32_t index, PlSize &size) override; 40 41 private: 42 DISALLOW_COPY_AND_MOVE(HeifDecoder); 43 bool AllocHeapBuffer(DecodeContext &context); 44 bool IsHeifImageParaValid(PlSize heifSize, uint32_t bytesPerPixel); 45 std::unique_ptr<HeifDecoderInterface> heifDecoderInterface_ = nullptr; 46 PlSize heifSize_; 47 int32_t bytesPerPixel_ = 0; 48 }; 49 } // namespace ImagePlugin 50 } // namespace OHOS 51 52 #endif // HEIF_DECODER_H 53