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 std::unique_ptr<PixelMap> CreatePixelMapEx(uint32_t index, const DecodeOptions &opts,
194                                                             uint32_t &errorCode);
195     NATIVEEXPORT std::unique_ptr<PixelMap> CreatePixelMap(uint32_t index, const DecodeOptions &opts,
196                                                           uint32_t &errorCode);
197     NATIVEEXPORT std::unique_ptr<IncrementalPixelMap> CreateIncrementalPixelMap(uint32_t index,
198                                                                                 const DecodeOptions &opts,
199                                                                                 uint32_t &errorCode);
200 #if !defined(IOS_PLATFORM) && !defined(ANDROID_PLATFORM)
201     NATIVEEXPORT std::unique_ptr<Picture> CreatePicture(const DecodingOptionsForPicture &opts, uint32_t &errorCode);
202 #endif
203     // for incremental source.
204     NATIVEEXPORT uint32_t UpdateData(const uint8_t *data, uint32_t size, bool isCompleted);
205     // for obtaining basic image information without decoding image data.
GetImageInfo(ImageInfo & imageInfo)206     NATIVEEXPORT uint32_t GetImageInfo(ImageInfo &imageInfo)
207     {
208         return GetImageInfo(0, imageInfo);
209     }
210     NATIVEEXPORT uint32_t GetImageInfo(uint32_t index, ImageInfo &imageInfo);
211     NATIVEEXPORT uint32_t GetImageInfoFromExif(uint32_t index, ImageInfo &imageInfo);
212     NATIVEEXPORT const SourceInfo &GetSourceInfo(uint32_t &errorCode);
213     NATIVEEXPORT void RegisterListener(PeerListener *listener);
214     NATIVEEXPORT void UnRegisterListener(PeerListener *listener);
215     NATIVEEXPORT DecodeEvent GetDecodeEvent();
216     NATIVEEXPORT void AddDecodeListener(DecodeListener *listener);
217     NATIVEEXPORT void RemoveDecodeListener(DecodeListener *listener);
218     NATIVEEXPORT bool IsIncrementalSource();
219     NATIVEEXPORT uint32_t GetImagePropertyInt(uint32_t index, const std::string &key, int32_t &value);
220     NATIVEEXPORT uint32_t GetImagePropertyString(uint32_t index, const std::string &key, std::string &value);
221     NATIVEEXPORT uint32_t ModifyImageProperty(uint32_t index, const std::string &key, const std::string &value,
222         const std::string &path);
223     NATIVEEXPORT uint32_t ModifyImageProperty(uint32_t index, const std::string &key, const std::string &value,
224         const int fd);
225     NATIVEEXPORT uint32_t ModifyImageProperty(uint32_t index, const std::string &key, const std::string &value,
226         uint8_t *data, uint32_t size);
227     NATIVEEXPORT uint32_t ModifyImageProperty(uint32_t index, const std::string &key, const std::string &value);
228     NATIVEEXPORT uint32_t RemoveImageProperties(uint32_t index, const std::set<std::string> &keys,
229         const std::string &path);
230     NATIVEEXPORT uint32_t RemoveImageProperties(uint32_t index, const std::set<std::string> &keys,
231         const int fd);
232     NATIVEEXPORT uint32_t RemoveImageProperties(uint32_t index, const std::set<std::string> &keys,
233         uint8_t *data, uint32_t size);
234     NATIVEEXPORT const NinePatchInfo &GetNinePatchInfo() const;
235     NATIVEEXPORT void SetMemoryUsagePreference(const MemoryUsagePreference preference);
236     NATIVEEXPORT MemoryUsagePreference GetMemoryUsagePreference();
237     NATIVEEXPORT uint32_t GetFilterArea(const int &privacyType, std::vector<std::pair<uint32_t, uint32_t>> &ranges);
238     NATIVEEXPORT uint32_t GetFilterArea(const std::vector<std::string> &exifKeys,
239                                         std::vector<std::pair<uint32_t, uint32_t>> &ranges);
240     NATIVEEXPORT std::unique_ptr<std::vector<std::unique_ptr<PixelMap>>> CreatePixelMapList(const DecodeOptions &opts,
241         uint32_t &errorCode);
242     NATIVEEXPORT std::unique_ptr<std::vector<int32_t>> GetDelayTime(uint32_t &errorCode);
243     NATIVEEXPORT std::unique_ptr<std::vector<int32_t>> GetDisposalType(uint32_t &errorCode);
244     NATIVEEXPORT int32_t GetLoopCount(uint32_t &errorCode);
245     NATIVEEXPORT uint32_t GetFrameCount(uint32_t &errorCode);
246 #ifdef IMAGE_PURGEABLE_PIXELMAP
247     NATIVEEXPORT size_t GetSourceSize() const;
248 #endif
249     void SetSource(const std::string &source);
250     NATIVEEXPORT bool IsHdrImage();
251 
252     NATIVEEXPORT std::shared_ptr<ExifMetadata> GetExifMetadata();
253     NATIVEEXPORT void SetExifMetadata(std::shared_ptr<ExifMetadata> &ptr);
254     NATIVEEXPORT static void ContextToAddrInfos(ImagePlugin::DecodeContext &context, PixelMapAddrInfos &addrInfos);
255     NATIVEEXPORT static bool IsYuvFormat(PixelFormat format);
256 
257 private:
258     DISALLOW_COPY_AND_MOVE(ImageSource);
259     using FormatAgentMap = std::map<std::string, ImagePlugin::AbsImageFormatAgent *>;
260     using ImageStatusMap = std::map<uint32_t, ImageDecodingStatus>;
261     using IncrementalRecordMap = std::map<PixelMap *, IncrementalDecodingContext>;
262     ImageSource(std::unique_ptr<SourceStream> &&stream, const SourceOptions &opts);
263     uint32_t CheckEncodedFormat(ImagePlugin::AbsImageFormatAgent &agent);
264     uint32_t GetData(ImagePlugin::DataStreamBuffer &outData, size_t size);
265     static FormatAgentMap InitClass();
266     uint32_t GetEncodedFormat(const std::string &formatHint, std::string &format);
267     uint32_t DecodeImageInfo(uint32_t index, ImageStatusMap::iterator &iter);
268     uint32_t DecodeSourceInfo(bool isAcquiredImageNum);
269     uint32_t InitMainDecoder();
270     ImagePlugin::AbsImageDecoder *CreateDecoder(uint32_t &errorCode);
271     void CopyOptionsToPlugin(const DecodeOptions &opts, ImagePlugin::PixelDecodeOptions &plOpts);
272     void CopyOptionsToProcOpts(const DecodeOptions &opts, DecodeOptions &procOpts, PixelMap &pixelMap);
273     uint32_t CheckFormatHint(const std::string &formatHint, FormatAgentMap::iterator &formatIter);
274     uint32_t GetSourceInfo();
275     uint32_t OnSourceRecognized(bool isAcquiredImageNum);
276     uint32_t OnSourceUnresolved();
277     uint32_t SetDecodeOptions(std::unique_ptr<ImagePlugin::AbsImageDecoder> &decoder, uint32_t index,
278                               const DecodeOptions &opts, ImagePlugin::PlImageInfo &plInfo);
279     uint32_t UpdatePixelMapInfo(const DecodeOptions &opts, ImagePlugin::PlImageInfo &plInfo, PixelMap &pixelMap);
280     uint32_t UpdatePixelMapInfo(const DecodeOptions &opts, ImagePlugin::PlImageInfo &plInfo,
281                                 PixelMap &pixelMap, int32_t fitDensity, bool isReUsed = false);
282     // declare friend class, only IncrementalPixelMap can call PromoteDecoding function.
283     friend class IncrementalPixelMap;
284     uint32_t PromoteDecoding(uint32_t index, const DecodeOptions &opts, PixelMap &pixelMap, ImageDecodingState &state,
285                              uint8_t &decodeProgress);
286     void DetachIncrementalDecoding(PixelMap &pixelMap);
287     ImageStatusMap::iterator GetValidImageStatus(uint32_t index, uint32_t &errorCode);
288     uint32_t AddIncrementalContext(PixelMap &pixelMap, IncrementalRecordMap::iterator &iterator);
289     uint32_t DoIncrementalDecoding(uint32_t index, const DecodeOptions &opts, PixelMap &pixelMap,
290                                    IncrementalDecodingContext &recordContext);
291     void SetIncrementalSource(const bool isIncrementalSource);
292     bool IsStreamCompleted();
293     uint32_t GetImagePropertyCommon(uint32_t index, const std::string &key, std::string &value);
294     FinalOutputStep GetFinalOutputStep(const DecodeOptions &opts, PixelMap &pixelMap, bool hasNinePatch);
295     bool HasDensityChange(const DecodeOptions &opts, ImageInfo &srcImageInfo, bool hasNinePatch);
296     bool ImageSizeChange(int32_t width, int32_t height, int32_t desiredWidth, int32_t desiredHeight);
297     bool ImageConverChange(const Rect &cropRect, ImageInfo &dstImageInfo, ImageInfo &srcImageInfo);
298     void Reset();
299     static std::unique_ptr<SourceStream> DecodeBase64(const uint8_t *data, uint32_t size);
300     static std::unique_ptr<SourceStream> DecodeBase64(const std::string &data);
301     bool IsSpecialYUV();
302     bool GetImageInfoForASTC(ImageInfo& imageInfo, const uint8_t *sourceFilePtr);
303     bool ConvertYUV420ToRGBA(uint8_t *data, uint32_t size, bool isSupportOdd, bool isAddUV, uint32_t &errorCode);
304     std::unique_ptr<PixelMap> CreatePixelMapForYUV(uint32_t &errorCode);
305     std::unique_ptr<PixelMap> CreatePixelMapForASTC(uint32_t &errorCode, bool fastAstc = false);
306     uint32_t GetFormatExtended(std::string &format);
307     static std::unique_ptr<ImageSource> DoImageSourceCreate(
308         std::function<std::unique_ptr<SourceStream>(void)> stream,
309         const SourceOptions &opts, uint32_t &errorCode, const std::string traceName = "");
310     std::unique_ptr<PixelMap> CreatePixelMapExtended(uint32_t index, const DecodeOptions &opts,
311                                                      uint32_t &errorCode);
312     std::unique_ptr<PixelMap> CreatePixelMapByInfos(ImagePlugin::PlImageInfo &plInfo,
313                                                     ImagePlugin::DecodeContext& context, uint32_t &errorCode);
314     bool ApplyGainMap(ImageHdrType hdrType, ImagePlugin::DecodeContext& baseCtx,
315                       ImagePlugin::DecodeContext& hdrCtx, float scale);
316     bool ComposeHdrImage(ImageHdrType hdrType, ImagePlugin::DecodeContext& baseCtx,
317         ImagePlugin::DecodeContext& gainMapCtx, ImagePlugin::DecodeContext& hdrCtx, HdrMetadata metadata);
318     uint32_t SetGainMapDecodeOption(std::unique_ptr<ImagePlugin::AbsImageDecoder>& decoder,
319                                     ImagePlugin::PlImageInfo& plInfo, float scale);
320     ImagePlugin::DecodeContext DecodeImageDataToContext(uint32_t index, ImageInfo info,
321                                                         ImagePlugin::PlImageInfo& outInfo, uint32_t& errorCode);
322     bool DecodeJpegGainMap(ImageHdrType hdrType, float scale,
323         ImagePlugin::DecodeContext& gainMapCtx, HdrMetadata& metadata);
324     void DumpInputData(const std::string& fileSuffix = "dat");
325     static uint64_t GetNowTimeMicroSeconds();
326     uint32_t ModifyImageProperty(std::shared_ptr<MetadataAccessor> metadataAccessor,
327                                  const std::string &key, const std::string &value);
328     uint32_t RemoveImageProperties(std::shared_ptr<MetadataAccessor> metadataAccessor,
329                                     const std::set<std::string> &key);
330     uint32_t ModifyImageProperty(const std::string &key, const std::string &value);
331     uint32_t CreatExifMetadataByImageSource(bool addFlag = false);
332     uint32_t CreateExifMetadata(uint8_t *buffer, const uint32_t size, bool addFlag);
333     void SetDecodeInfoOptions(uint32_t index, const DecodeOptions &opts, const ImageInfo &info, ImageEvent &imageEvent);
334     void SetDecodeInfoOptions(uint32_t index, const DecodeOptions &opts, const ImagePlugin::PlImageInfo &plInfo,
335         ImageEvent &imageEvent);
336     void UpdateDecodeInfoOptions(const ImagePlugin::DecodeContext &context, ImageEvent &imageEvent);
337     void SetImageEventHeifParseErr(ImageEvent &event);
338     bool CheckDecodeOptions(Size imageSize, bool &needAisr, bool &needHdr);
339     uint32_t DecodeImageDataToContext(uint32_t index, ImageInfo &info, ImagePlugin::PlImageInfo &plInfo,
340                                       ImagePlugin::DecodeContext &context, uint32_t &errorCode);
341     void TransformSizeWithDensity(const Size &srcSize, int32_t srcDensity, const Size &wantSize,
342                                   int32_t wantDensity, Size &dstSize);
343     uint32_t DoAiHdrProcessDl(const ImagePlugin::DecodeContext &srcCtx, ImagePlugin::DecodeContext &dstCtx,
344                               bool needAisr, bool needHdr);
345     uint32_t ImageAiProcess(Size imageSize, const DecodeOptions &opts, bool isHdr,
346                             ImagePlugin::DecodeContext &context, ImagePlugin::PlImageInfo &plInfo);
347     ImagePlugin::DecodeContext DecodeImageDataToContextExtended(uint32_t index, ImageInfo &info,
348         ImagePlugin::PlImageInfo &plInfo, ImageEvent &imageEvent, uint32_t &errorCode);
349     void SetDngImageSize(uint32_t index, ImageInfo &imageInfo);
350     void SetPixelMapColorSpace(ImagePlugin::DecodeContext& context, std::unique_ptr<PixelMap>& pixelMap,
351         std::unique_ptr<ImagePlugin::AbsImageDecoder>& decoder);
352     bool IsSingleHdrImage(ImageHdrType type);
353     bool IsDualHdrImage(ImageHdrType type);
354     ImagePlugin::DecodeContext HandleSingleHdrImage(ImageHdrType decodedHdrType,
355         ImagePlugin::DecodeContext& context, ImagePlugin::PlImageInfo& plInfo);
356     ImagePlugin::DecodeContext HandleDualHdrImage(ImageHdrType decodedHdrType, ImageInfo info,
357         ImagePlugin::DecodeContext& context, ImagePlugin::PlImageInfo& plInfo);
358     ImagePlugin::DecodeContext InitDecodeContext(const DecodeOptions &opts, const ImageInfo &info,
359         const MemoryUsagePreference &preference, bool hasDesiredSizeOptions, ImagePlugin::PlImageInfo& plInfo);
360     bool ParseHdrType();
361     bool PrereadSourceStream();
362     void SetDmaContextYuvInfo(ImagePlugin::DecodeContext& context);
363     uint8_t* ReadSourceBuffer(uint32_t bufferSize, uint32_t &errorCode);
364     #if !defined(IOS_PLATFORM) && !defined(ANDROID_PLATFORM)
365     void SetHdrMetadataForPicture(std::unique_ptr<Picture> &picture);
366     void DecodeHeifAuxiliaryPictures(const std::set<AuxiliaryPictureType> &auxTypes, std::unique_ptr<Picture> &picture,
367                                      uint32_t &errorCode);
368     void DecodeJpegAuxiliaryPicture(std::set<AuxiliaryPictureType> &auxTypes, std::unique_ptr<Picture> &picture,
369                                     uint32_t &errorCode);
370     bool CheckJpegSourceStream(uint8_t *&streamBuffer, uint32_t &streamSize);
371     #endif
372 
373     const std::string NINE_PATCH = "ninepatch";
374     const std::string SKIA_DECODER = "SKIA_DECODER";
375     static MultimediaPlugin::PluginServer &pluginServer_;
376     static FormatAgentMap formatAgentMap_;
377     std::unique_ptr<SourceStream> sourceStreamPtr_;
378     SourceDecodingState decodeState_ = SourceDecodingState::UNRESOLVED;
379     SourceInfo sourceInfo_;
380     SourceOptions sourceOptions_;
381     NinePatchInfo ninePatchInfo_;
382     ImageStatusMap imageStatusMap_;
383     IncrementalRecordMap incDecodingMap_;
384     // The main decoder is responsible for ordinary decoding (non-Incremental decoding),
385     // as well as decoding SourceInfo and ImageInfo.
386     std::unique_ptr<ImagePlugin::AbsImageDecoder> mainDecoder_;
387     std::unique_ptr<ImagePlugin::AbsImageDecoder> jpegGainmapDecoder_;
388     DecodeOptions opts_;
389     std::set<PeerListener *> listeners_;
390     DecodeEvent decodeEvent_ = DecodeEvent::EVENT_COMPLETE_DECODE;
391     std::map<int32_t, int32_t> decodeEventMap_;
392     std::set<DecodeListener *> decodeListeners_;
393     std::mutex listenerMutex_;
394     std::mutex decodingMutex_;
395     bool isIncrementalSource_ = false;
396     bool isIncrementalCompleted_ = false;
397     bool hasDesiredSizeOptions = false;
398     MemoryUsagePreference preference_ = MemoryUsagePreference::DEFAULT;
399     std::optional<bool> isAstc_;
400     uint64_t imageId_; // generated from the last six bits of the current timestamp
401     ImageHdrType sourceHdrType_; // source image hdr type;
402     std::shared_ptr<ExifMetadata> exifMetadata_ = nullptr;
403     std::string source_; // Image source fd buffer etc
404     bool isExifReadFailed_ = false;
405     uint32_t exifReadStatus_ = 0;
406     uint32_t heifParseErr_ = 0;
407 };
408 } // namespace Media
409 } // namespace OHOS
410 
411 #endif // INTERFACES_INNERKITS_INCLUDE_IMAGE_SOURCE_H
412