• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 INTERFACES_INNERKITS_INCLUDE_IMAGE_SOURCE_H
17 #define INTERFACES_INNERKITS_INCLUDE_IMAGE_SOURCE_H
18 
19 #include <cstdint>
20 #include <iostream>
21 #include <map>
22 #include <memory>
23 #include <mutex>
24 #include <optional>
25 #include <set>
26 
27 #include "decode_listener.h"
28 #include "image_type.h"
29 #include "incremental_pixel_map.h"
30 #include "peer_listener.h"
31 #include "pixel_map.h"
32 #if !defined(IOS_PLATFORM) && !defined(ANDROID_PLATFORM)
33 #include "picture.h"
34 #endif
35 
36 namespace OHOS {
37 namespace MultimediaPlugin {
38 constexpr float EPSILON = 1e-6;
39 const int MAX_BUFFER_SIZE = 1024 * 1024 * 1024;
40 
41 class PluginServer;
42 } // namespace MultimediaPlugin
43 } // namespace OHOS
44 
45 namespace OHOS {
46 namespace ImagePlugin {
47 class AbsImageFormatAgent;
48 class AbsImageDecoder;
49 struct DataStreamBuffer;
50 struct PixelDecodeOptions;
51 struct PlImageInfo;
52 struct DecodeContext;
53 } // namespace ImagePlugin
54 } // namespace OHOS
55 
56 #if !defined(IOS_PLATFORM) && !defined(ANDROID_PLATFORM)
57 namespace OHOS::HDI::Display::Graphic::Common::V1_0 {
58 enum CM_ColorSpaceType : int32_t;
59 }
60 #else
61 enum CM_ColorSpaceType : int32_t;
62 #endif
63 
64 namespace OHOS {
65 namespace Media {
66 #if !defined(IOS_PLATFORM) && !defined(ANDROID_PLATFORM)
67 using namespace HDI::Display::Graphic::Common::V1_0;
68 #endif
69 class ImageEvent;
70 struct SourceOptions {
71     std::string formatHint;
72     int32_t baseDensity = 0;
73     PixelFormat pixelFormat = PixelFormat::UNKNOWN;
74     Size size;
75 };
76 
77 struct IncrementalSourceOptions {
78     SourceOptions sourceOptions;
79     IncrementalMode incrementalMode = IncrementalMode::FULL_DATA;
80 };
81 
82 struct NinePatchInfo {
83     void *ninePatch = nullptr;
84     size_t patchSize = 0;
85 };
86 
87 enum class DecodeEvent : int32_t {
88     EVENT_COMPLETE_DECODE = 0,
89     EVENT_PARTIAL_DECODE = 1,
90     EVENT_HEADER_DECODE = 2,
91     EVENT_LAST = 3
92 };
93 
94 enum class ImageDecodingState : int32_t {
95     UNRESOLVED = 0,
96     BASE_INFO_ERROR = 1,
97     BASE_INFO_PARSED = 2,
98     IMAGE_DECODING = 3,
99     IMAGE_ERROR = 4,
100     PARTIAL_IMAGE = 5,
101     IMAGE_DECODED = 6
102 };
103 
104 enum class SourceDecodingState : int32_t {
105     UNRESOLVED = 0,
106     SOURCE_ERROR = 1,
107     UNKNOWN_FORMAT = 2,
108     FORMAT_RECOGNIZED = 3,
109     UNSUPPORTED_FORMAT = 4,
110     FILE_INFO_ERROR = 5,
111     FILE_INFO_DECODED = 6,
112     IMAGE_DECODING = 7,
113     ALL_IMAGES_ERROR = 8
114 };
115 
116 enum class SourceInfoState : int32_t {
117     SOURCE_ERROR = 0,
118     SOURCE_INCOMPLETE = 1,
119     UNKNOWN_FORMAT = 2,
120     UNSUPPORTED_FORMAT = 3,
121     FILE_INFO_ERROR = 4,
122     FILE_INFO_PARSED = 5
123 };
124 
125 struct ImageDecodingStatus {
126     ImageInfo imageInfo;
127     ImageDecodingState imageState = ImageDecodingState::UNRESOLVED;
128 };
129 
130 struct SourceInfo {
131     int32_t baseDensity = 0;
132     uint32_t topLevelImageNum = 0;
133     std::string encodedFormat;
134     SourceInfoState state = SourceInfoState::SOURCE_ERROR;
135 };
136 
137 struct IncrementalDecodingContext {
138     std::unique_ptr<ImagePlugin::AbsImageDecoder> decoder;
139     ImageDecodingState IncrementalState = ImageDecodingState::UNRESOLVED;
140     uint8_t decodingProgress = 0;
141 };
142 
143 struct PixelMapAddrInfos {
144     uint8_t *addr;
145     uint8_t *context;
146     uint32_t size;
147     AllocatorType type;
148     CustomFreePixelMap func;
149 };
150 
151 struct ASTCInfo {
152     Size size;
153     Size blockFootprint;
154 };
155 
156 class SourceStream;
157 enum class ImageHdrType;
158 struct HdrMetadata;
159 class MetadataAccessor;
160 class ExifMetadata;
161 
162 class ImageSource {
163 public:
164     ~ImageSource();
165     NATIVEEXPORT static uint32_t GetSupportedFormats(std::set<std::string> &formats);
166     NATIVEEXPORT static std::unique_ptr<ImageSource> CreateImageSource(std::unique_ptr<std::istream> is,
167                                                                        const SourceOptions &opts, uint32_t &errorCode);
168     NATIVEEXPORT static std::unique_ptr<ImageSource> CreateImageSource(const uint8_t *data, uint32_t size,
169                                                                        const SourceOptions &opts, uint32_t &errorCode);
170     NATIVEEXPORT static std::unique_ptr<ImageSource> CreateImageSource(const std::string &pathName,
171                                                                        const SourceOptions &opts, uint32_t &errorCode);
172     NATIVEEXPORT static std::unique_ptr<ImageSource> CreateImageSource(const int fd, const SourceOptions &opts,
173                                                        uint32_t &errorCode);
174     NATIVEEXPORT static std::unique_ptr<ImageSource> CreateImageSource(
175         const int fd, int32_t offset, int32_t length, const SourceOptions &opts, uint32_t &errorCode);
176     NATIVEEXPORT static std::unique_ptr<ImageSource> CreateIncrementalImageSource(const IncrementalSourceOptions &opts,
177                                                                                   uint32_t &errorCode);
178     NATIVEEXPORT static bool IsASTC(const uint8_t *fileData, size_t fileSize);
179 
180     NATIVEEXPORT static bool GetASTCInfo(const uint8_t *fileData, size_t fileSize, ASTCInfo& astcInfo);
181 
182     NATIVEEXPORT static bool IsSupportGenAstc();
183 
184     NATIVEEXPORT static CM_ColorSpaceType ConvertColorSpaceType(ColorManager::ColorSpaceName colorSpace, bool base);
185 
186     NATIVEEXPORT static void SetVividMetaColor(HdrMetadata& metadata, CM_ColorSpaceType base,
187                                                 CM_ColorSpaceType gainmap, CM_ColorSpaceType hdr);
188 
CreatePixelMap(const DecodeOptions & opts,uint32_t & errorCode)189     NATIVEEXPORT std::unique_ptr<PixelMap> CreatePixelMap(const DecodeOptions &opts, uint32_t &errorCode)
190     {
191         return CreatePixelMapEx(0, opts, errorCode);
192     }
193     NATIVEEXPORT AllocatorType ConvertAutoAllocatorType(const DecodeOptions &opts);
194     NATIVEEXPORT std::unique_ptr<PixelMap> CreatePixelMapEx(uint32_t index, const DecodeOptions &opts,
195                                                             uint32_t &errorCode);
196     NATIVEEXPORT std::unique_ptr<PixelMap> CreatePixelMap(uint32_t index, const DecodeOptions &opts,
197                                                           uint32_t &errorCode);
198     NATIVEEXPORT std::unique_ptr<IncrementalPixelMap> CreateIncrementalPixelMap(uint32_t index,
199                                                                                 const DecodeOptions &opts,
200                                                                                 uint32_t &errorCode);
201 #if !defined(IOS_PLATFORM) && !defined(ANDROID_PLATFORM)
202     NATIVEEXPORT std::unique_ptr<Picture> CreatePicture(const DecodingOptionsForPicture &opts, uint32_t &errorCode);
203 #endif
204     // for incremental source.
205     NATIVEEXPORT uint32_t UpdateData(const uint8_t *data, uint32_t size, bool isCompleted);
206     // for obtaining basic image information without decoding image data.
GetImageInfo(ImageInfo & imageInfo)207     NATIVEEXPORT uint32_t GetImageInfo(ImageInfo &imageInfo)
208     {
209         return GetImageInfo(0, imageInfo);
210     }
211     NATIVEEXPORT uint32_t GetImageInfo(uint32_t index, ImageInfo &imageInfo);
212     NATIVEEXPORT uint32_t GetImageInfoFromExif(uint32_t index, ImageInfo &imageInfo);
213     NATIVEEXPORT const SourceInfo &GetSourceInfo(uint32_t &errorCode);
214     NATIVEEXPORT void RegisterListener(PeerListener *listener);
215     NATIVEEXPORT void UnRegisterListener(PeerListener *listener);
216     NATIVEEXPORT DecodeEvent GetDecodeEvent();
217     NATIVEEXPORT void AddDecodeListener(DecodeListener *listener);
218     NATIVEEXPORT void RemoveDecodeListener(DecodeListener *listener);
219     NATIVEEXPORT bool IsIncrementalSource();
220     NATIVEEXPORT uint32_t GetImagePropertyInt(uint32_t index, const std::string &key, int32_t &value);
221     NATIVEEXPORT uint32_t GetImagePropertyString(uint32_t index, const std::string &key, std::string &value);
222     NATIVEEXPORT uint32_t ModifyImageProperty(uint32_t index, const std::string &key, const std::string &value,
223         const std::string &path);
224     NATIVEEXPORT uint32_t ModifyImageProperty(uint32_t index, const std::string &key, const std::string &value,
225         const int fd);
226     NATIVEEXPORT uint32_t ModifyImageProperty(uint32_t index, const std::string &key, const std::string &value,
227         uint8_t *data, uint32_t size);
228     NATIVEEXPORT uint32_t ModifyImageProperty(uint32_t index, const std::string &key, const std::string &value);
229     NATIVEEXPORT uint32_t ModifyImagePropertyEx(uint32_t index, const std::string &key, const std::string &value);
230     NATIVEEXPORT uint32_t RemoveImageProperties(uint32_t index, const std::set<std::string> &keys,
231         const std::string &path);
232     NATIVEEXPORT uint32_t RemoveImageProperties(uint32_t index, const std::set<std::string> &keys,
233         const int fd);
234     NATIVEEXPORT uint32_t RemoveImageProperties(uint32_t index, const std::set<std::string> &keys,
235         uint8_t *data, uint32_t size);
236     NATIVEEXPORT const NinePatchInfo &GetNinePatchInfo() const;
237     NATIVEEXPORT void SetMemoryUsagePreference(const MemoryUsagePreference preference);
238     NATIVEEXPORT MemoryUsagePreference GetMemoryUsagePreference();
239     NATIVEEXPORT uint32_t GetFilterArea(const int &privacyType, std::vector<std::pair<uint32_t, uint32_t>> &ranges);
240     NATIVEEXPORT uint32_t GetFilterArea(const std::vector<std::string> &exifKeys,
241                                         std::vector<std::pair<uint32_t, uint32_t>> &ranges);
242     NATIVEEXPORT std::unique_ptr<std::vector<std::unique_ptr<PixelMap>>> CreatePixelMapList(const DecodeOptions &opts,
243         uint32_t &errorCode);
244     NATIVEEXPORT std::unique_ptr<std::vector<int32_t>> GetDelayTime(uint32_t &errorCode);
245     NATIVEEXPORT std::unique_ptr<std::vector<int32_t>> GetDisposalType(uint32_t &errorCode);
246     NATIVEEXPORT int32_t GetLoopCount(uint32_t &errorCode);
247     NATIVEEXPORT uint32_t GetFrameCount(uint32_t &errorCode);
248 #ifdef IMAGE_PURGEABLE_PIXELMAP
249     NATIVEEXPORT size_t GetSourceSize() const;
250 #endif
251     void SetSource(const std::string &source);
252     NATIVEEXPORT bool IsHdrImage();
253 
254     NATIVEEXPORT std::shared_ptr<ExifMetadata> GetExifMetadata();
255     NATIVEEXPORT void SetExifMetadata(std::shared_ptr<ExifMetadata> &ptr);
256     NATIVEEXPORT static void ContextToAddrInfos(ImagePlugin::DecodeContext &context, PixelMapAddrInfos &addrInfos);
257     NATIVEEXPORT static bool IsYuvFormat(PixelFormat format);
258     NATIVEEXPORT bool IsDecodeHdrImage(const DecodeOptions &opts);
259     NATIVEEXPORT bool IsSvgUseDma(const DecodeOptions &opts);
260     NATIVEEXPORT bool IsSupportAllocatorType(DecodeOptions& decOps, int32_t allocatorType);
261 
262 private:
263     DISALLOW_COPY_AND_MOVE(ImageSource);
264     using FormatAgentMap = std::map<std::string, ImagePlugin::AbsImageFormatAgent *>;
265     using ImageStatusMap = std::map<uint32_t, ImageDecodingStatus>;
266     using IncrementalRecordMap = std::map<PixelMap *, IncrementalDecodingContext>;
267     ImageSource(std::unique_ptr<SourceStream> &&stream, const SourceOptions &opts);
268     uint32_t CheckEncodedFormat(ImagePlugin::AbsImageFormatAgent &agent);
269     uint32_t GetData(ImagePlugin::DataStreamBuffer &outData, size_t size);
270     static FormatAgentMap InitClass();
271     uint32_t GetEncodedFormat(const std::string &formatHint, std::string &format);
272     uint32_t DecodeImageInfo(uint32_t index, ImageStatusMap::iterator &iter);
273     uint32_t DecodeSourceInfo(bool isAcquiredImageNum);
274     uint32_t InitMainDecoder();
275     ImagePlugin::AbsImageDecoder *CreateDecoder(uint32_t &errorCode);
276     void CopyOptionsToPlugin(const DecodeOptions &opts, ImagePlugin::PixelDecodeOptions &plOpts);
277     void CopyOptionsToProcOpts(const DecodeOptions &opts, DecodeOptions &procOpts, PixelMap &pixelMap);
278     uint32_t CheckFormatHint(const std::string &formatHint, FormatAgentMap::iterator &formatIter);
279     uint32_t GetSourceInfo();
280     uint32_t OnSourceRecognized(bool isAcquiredImageNum);
281     uint32_t OnSourceUnresolved();
282     uint32_t SetDecodeOptions(std::unique_ptr<ImagePlugin::AbsImageDecoder> &decoder, uint32_t index,
283                               const DecodeOptions &opts, ImagePlugin::PlImageInfo &plInfo);
284     uint32_t UpdatePixelMapInfo(const DecodeOptions &opts, ImagePlugin::PlImageInfo &plInfo, PixelMap &pixelMap);
285     uint32_t UpdatePixelMapInfo(const DecodeOptions &opts, ImagePlugin::PlImageInfo &plInfo,
286                                 PixelMap &pixelMap, int32_t fitDensity, bool isReUsed = false);
287     // declare friend class, only IncrementalPixelMap can call PromoteDecoding function.
288     friend class IncrementalPixelMap;
289     uint32_t PromoteDecoding(uint32_t index, const DecodeOptions &opts, PixelMap &pixelMap, ImageDecodingState &state,
290                              uint8_t &decodeProgress);
291     void DetachIncrementalDecoding(PixelMap &pixelMap);
292     ImageStatusMap::iterator GetValidImageStatus(uint32_t index, uint32_t &errorCode);
293     uint32_t AddIncrementalContext(PixelMap &pixelMap, IncrementalRecordMap::iterator &iterator);
294     uint32_t DoIncrementalDecoding(uint32_t index, const DecodeOptions &opts, PixelMap &pixelMap,
295                                    IncrementalDecodingContext &recordContext);
296     void SetIncrementalSource(const bool isIncrementalSource);
297     bool IsStreamCompleted();
298     uint32_t GetImagePropertyCommon(uint32_t index, const std::string &key, std::string &value);
299     FinalOutputStep GetFinalOutputStep(const DecodeOptions &opts, PixelMap &pixelMap, bool hasNinePatch);
300     bool HasDensityChange(const DecodeOptions &opts, ImageInfo &srcImageInfo, bool hasNinePatch);
301     bool ImageSizeChange(int32_t width, int32_t height, int32_t desiredWidth, int32_t desiredHeight);
302     bool ImageConverChange(const Rect &cropRect, ImageInfo &dstImageInfo, ImageInfo &srcImageInfo);
303     void Reset();
304     static std::unique_ptr<SourceStream> DecodeBase64(const uint8_t *data, uint32_t size);
305     static std::unique_ptr<SourceStream> DecodeBase64(const std::string &data);
306     bool IsSpecialYUV();
307     bool GetImageInfoForASTC(ImageInfo& imageInfo, const uint8_t *sourceFilePtr);
308     bool ConvertYUV420ToRGBA(uint8_t *data, uint32_t size, bool isSupportOdd, bool isAddUV, uint32_t &errorCode);
309     std::unique_ptr<PixelMap> CreatePixelMapForYUV(uint32_t &errorCode);
310     std::unique_ptr<PixelMap> CreatePixelMapForASTC(uint32_t &errorCode, bool fastAstc = false);
311     uint32_t GetFormatExtended(std::string &format);
312     static std::unique_ptr<ImageSource> DoImageSourceCreate(
313         std::function<std::unique_ptr<SourceStream>(void)> stream,
314         const SourceOptions &opts, uint32_t &errorCode, const std::string traceName = "");
315     std::unique_ptr<PixelMap> CreatePixelMapExtended(uint32_t index, const DecodeOptions &opts,
316                                                      uint32_t &errorCode);
317     std::unique_ptr<PixelMap> CreatePixelMapByInfos(ImagePlugin::PlImageInfo &plInfo,
318                                                     ImagePlugin::DecodeContext& context, uint32_t &errorCode);
319     bool ApplyGainMap(ImageHdrType hdrType, ImagePlugin::DecodeContext& baseCtx,
320                       ImagePlugin::DecodeContext& hdrCtx, float scale);
321     void ApplyMemoryForHdr(ImagePlugin::DecodeContext& hdrCtx, CM_ColorSpaceType hdrCmColor, ImageHdrType hdrType);
322     bool ComposeHdrImage(ImageHdrType hdrType, ImagePlugin::DecodeContext& baseCtx,
323         ImagePlugin::DecodeContext& gainMapCtx, ImagePlugin::DecodeContext& hdrCtx, HdrMetadata metadata);
324     uint32_t SetGainMapDecodeOption(std::unique_ptr<ImagePlugin::AbsImageDecoder>& decoder,
325                                     ImagePlugin::PlImageInfo& plInfo, float scale);
326     ImagePlugin::DecodeContext DecodeImageDataToContext(uint32_t index, ImageInfo info,
327                                                         ImagePlugin::PlImageInfo& outInfo, uint32_t& errorCode);
328     bool DecodeJpegGainMap(ImageHdrType hdrType, float scale,
329         ImagePlugin::DecodeContext& gainMapCtx, HdrMetadata& metadata);
330     void DumpInputData(const std::string& fileSuffix = "dat");
331     static uint64_t GetNowTimeMicroSeconds();
332     uint32_t ModifyImageProperty(std::shared_ptr<MetadataAccessor> metadataAccessor,
333                                  const std::string &key, const std::string &value);
334     uint32_t RemoveImageProperties(std::shared_ptr<MetadataAccessor> metadataAccessor,
335                                     const std::set<std::string> &key);
336     uint32_t ModifyImageProperty(const std::string &key, const std::string &value);
337     uint32_t CreatExifMetadataByImageSource(bool addFlag = false);
338     uint32_t CreateExifMetadata(uint8_t *buffer, const uint32_t size, bool addFlag);
339     void SetDecodeInfoOptions(uint32_t index, const DecodeOptions &opts, const ImageInfo &info, ImageEvent &imageEvent);
340     void SetDecodeInfoOptions(uint32_t index, const DecodeOptions &opts, const ImagePlugin::PlImageInfo &plInfo,
341         ImageEvent &imageEvent);
342     void UpdateDecodeInfoOptions(const ImagePlugin::DecodeContext &context, ImageEvent &imageEvent);
343     void SetImageEventHeifParseErr(ImageEvent &event);
344     bool CheckDecodeOptions(Size imageSize, bool &needAisr, bool &needHdr);
345     uint32_t DecodeImageDataToContext(uint32_t index, ImageInfo &info, ImagePlugin::PlImageInfo &plInfo,
346                                       ImagePlugin::DecodeContext &context, uint32_t &errorCode);
347     void TransformSizeWithDensity(const Size &srcSize, int32_t srcDensity, const Size &wantSize,
348                                   int32_t wantDensity, Size &dstSize);
349     uint32_t DoAiHdrProcessDl(const ImagePlugin::DecodeContext &srcCtx, ImagePlugin::DecodeContext &dstCtx,
350                               bool needAisr, bool needHdr);
351     uint32_t ImageAiProcess(Size imageSize, const DecodeOptions &opts, bool isHdr,
352                             ImagePlugin::DecodeContext &context, ImagePlugin::PlImageInfo &plInfo);
353     ImagePlugin::DecodeContext DecodeImageDataToContextExtended(uint32_t index, ImageInfo &info,
354         ImagePlugin::PlImageInfo &plInfo, ImageEvent &imageEvent, uint32_t &errorCode);
355     void SetDngImageSize(uint32_t index, ImageInfo &imageInfo);
356     void SetPixelMapColorSpace(ImagePlugin::DecodeContext& context, std::unique_ptr<PixelMap>& pixelMap,
357         std::unique_ptr<ImagePlugin::AbsImageDecoder>& decoder);
358     bool IsSingleHdrImage(ImageHdrType type);
359     bool IsDualHdrImage(ImageHdrType type);
360     ImagePlugin::DecodeContext HandleSingleHdrImage(ImageHdrType decodedHdrType,
361         ImagePlugin::DecodeContext& context, ImagePlugin::PlImageInfo& plInfo);
362     ImagePlugin::DecodeContext HandleDualHdrImage(ImageHdrType decodedHdrType, ImageInfo info,
363         ImagePlugin::DecodeContext& context, ImagePlugin::PlImageInfo& plInfo);
364     ImagePlugin::DecodeContext InitDecodeContext(const DecodeOptions &opts, const ImageInfo &info,
365         const MemoryUsagePreference &preference, bool hasDesiredSizeOptions, ImagePlugin::PlImageInfo& plInfo);
366     bool ParseHdrType();
367     bool PrereadSourceStream();
368     void SetDmaContextYuvInfo(ImagePlugin::DecodeContext& context);
369     uint8_t* ReadSourceBuffer(uint32_t bufferSize, uint32_t &errorCode);
370     void SetSrcFd(const int& fd);
371     void SetSrcFilePath(const std::string& pathName);
372     void SetSrcBuffer(const uint8_t* buffer, uint32_t size);
373     #if !defined(IOS_PLATFORM) && !defined(ANDROID_PLATFORM)
374     void SetHdrMetadataForPicture(std::unique_ptr<Picture> &picture);
375     void DecodeHeifAuxiliaryPictures(const std::set<AuxiliaryPictureType> &auxTypes, std::unique_ptr<Picture> &picture,
376                                      uint32_t &errorCode);
377     void DecodeJpegAuxiliaryPicture(std::set<AuxiliaryPictureType> &auxTypes, std::unique_ptr<Picture> &picture,
378                                     uint32_t &errorCode);
379     bool CheckJpegSourceStream(uint8_t *&streamBuffer, uint32_t &streamSize);
380     #endif
381 
382     const std::string NINE_PATCH = "ninepatch";
383     const std::string SKIA_DECODER = "SKIA_DECODER";
384     static MultimediaPlugin::PluginServer &pluginServer_;
385     static FormatAgentMap formatAgentMap_;
386     std::unique_ptr<SourceStream> sourceStreamPtr_;
387     SourceDecodingState decodeState_ = SourceDecodingState::UNRESOLVED;
388     SourceInfo sourceInfo_;
389     SourceOptions sourceOptions_;
390     NinePatchInfo ninePatchInfo_;
391     ImageStatusMap imageStatusMap_;
392     IncrementalRecordMap incDecodingMap_;
393     // The main decoder is responsible for ordinary decoding (non-Incremental decoding),
394     // as well as decoding SourceInfo and ImageInfo.
395     std::unique_ptr<ImagePlugin::AbsImageDecoder> mainDecoder_;
396     std::unique_ptr<ImagePlugin::AbsImageDecoder> jpegGainmapDecoder_;
397     DecodeOptions opts_;
398     std::set<PeerListener *> listeners_;
399     DecodeEvent decodeEvent_ = DecodeEvent::EVENT_COMPLETE_DECODE;
400     std::map<int32_t, int32_t> decodeEventMap_;
401     std::set<DecodeListener *> decodeListeners_;
402     std::mutex listenerMutex_;
403     std::mutex decodingMutex_;
404     bool isIncrementalSource_ = false;
405     bool isIncrementalCompleted_ = false;
406     bool hasDesiredSizeOptions = false;
407     MemoryUsagePreference preference_ = MemoryUsagePreference::DEFAULT;
408     std::optional<bool> isAstc_;
409     uint64_t imageId_; // generated from the last six bits of the current timestamp
410     ImageHdrType sourceHdrType_; // source image hdr type;
411     std::shared_ptr<ExifMetadata> exifMetadata_ = nullptr;
412     std::string source_; // Image source fd buffer etc
413     bool isExifReadFailed_ = false;
414     uint32_t exifReadStatus_ = 0;
415     uint32_t heifParseErr_ = 0;
416     std::string srcFilePath_ = "";
417     int srcFd_ = -1;
418     uint8_t* srcBuffer_ = nullptr;
419     uint32_t srcBufferSize_ = 0;
420 };
421 } // namespace Media
422 } // namespace OHOS
423 
424 #endif // INTERFACES_INNERKITS_INCLUDE_IMAGE_SOURCE_H
425