• 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 
40 class PluginServer;
41 } // namespace MultimediaPlugin
42 } // namespace OHOS
43 
44 namespace OHOS {
45 namespace ImagePlugin {
46 class AbsImageFormatAgent;
47 class AbsImageDecoder;
48 struct DataStreamBuffer;
49 struct PixelDecodeOptions;
50 struct PlImageInfo;
51 struct DecodeContext;
52 } // namespace ImagePlugin
53 } // namespace OHOS
54 
55 #if !defined(IOS_PLATFORM) && !defined(ANDROID_PLATFORM)
56 namespace OHOS::HDI::Display::Graphic::Common::V1_0 {
57 enum CM_ColorSpaceType : int32_t;
58 }
59 #else
60 enum CM_ColorSpaceType : int32_t;
61 #endif
62 
63 namespace OHOS {
64 namespace Media {
65 #if !defined(IOS_PLATFORM) && !defined(ANDROID_PLATFORM)
66 using namespace HDI::Display::Graphic::Common::V1_0;
67 #endif
68 class ImageEvent;
69 struct SourceOptions {
70     std::string formatHint;
71     int32_t baseDensity = 0;
72     PixelFormat pixelFormat = PixelFormat::UNKNOWN;
73     Size size;
74 };
75 
76 struct IncrementalSourceOptions {
77     SourceOptions sourceOptions;
78     IncrementalMode incrementalMode = IncrementalMode::FULL_DATA;
79 };
80 
81 struct NinePatchInfo {
82     void *ninePatch = nullptr;
83     size_t patchSize = 0;
84 };
85 
86 enum class DecodeEvent : int32_t {
87     EVENT_COMPLETE_DECODE = 0,
88     EVENT_PARTIAL_DECODE = 1,
89     EVENT_HEADER_DECODE = 2,
90     EVENT_LAST = 3
91 };
92 
93 enum class ImageDecodingState : int32_t {
94     UNRESOLVED = 0,
95     BASE_INFO_ERROR = 1,
96     BASE_INFO_PARSED = 2,
97     IMAGE_DECODING = 3,
98     IMAGE_ERROR = 4,
99     PARTIAL_IMAGE = 5,
100     IMAGE_DECODED = 6
101 };
102 
103 enum class SourceDecodingState : int32_t {
104     UNRESOLVED = 0,
105     SOURCE_ERROR = 1,
106     UNKNOWN_FORMAT = 2,
107     FORMAT_RECOGNIZED = 3,
108     UNSUPPORTED_FORMAT = 4,
109     FILE_INFO_ERROR = 5,
110     FILE_INFO_DECODED = 6,
111     IMAGE_DECODING = 7,
112     ALL_IMAGES_ERROR = 8
113 };
114 
115 enum class SourceInfoState : int32_t {
116     SOURCE_ERROR = 0,
117     SOURCE_INCOMPLETE = 1,
118     UNKNOWN_FORMAT = 2,
119     UNSUPPORTED_FORMAT = 3,
120     FILE_INFO_ERROR = 4,
121     FILE_INFO_PARSED = 5
122 };
123 
124 struct ImageDecodingStatus {
125     ImageInfo imageInfo;
126     ImageDecodingState imageState = ImageDecodingState::UNRESOLVED;
127 };
128 
129 struct SourceInfo {
130     int32_t baseDensity = 0;
131     uint32_t topLevelImageNum = 0;
132     std::string encodedFormat;
133     SourceInfoState state = SourceInfoState::SOURCE_ERROR;
134 };
135 
136 struct IncrementalDecodingContext {
137     std::unique_ptr<ImagePlugin::AbsImageDecoder> decoder;
138     ImageDecodingState IncrementalState = ImageDecodingState::UNRESOLVED;
139     uint8_t decodingProgress = 0;
140 };
141 
142 struct PixelMapAddrInfos {
143     uint8_t *addr;
144     uint8_t *context;
145     uint32_t size;
146     AllocatorType type;
147     CustomFreePixelMap func;
148 };
149 
150 struct ASTCInfo {
151     Size size;
152     Size blockFootprint;
153 };
154 
155 class SourceStream;
156 enum class ImageHdrType;
157 struct HdrMetadata;
158 class MetadataAccessor;
159 class ExifMetadata;
160 struct StreamInfo;
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 uint64_t GetImageId();
260     NATIVEEXPORT bool IsSvgUseDma(const DecodeOptions &opts);
261     NATIVEEXPORT bool IsSupportAllocatorType(DecodeOptions& decOps, int32_t allocatorType);
262 
263 private:
264     DISALLOW_COPY_AND_MOVE(ImageSource);
265     using FormatAgentMap = std::map<std::string, ImagePlugin::AbsImageFormatAgent *>;
266     using ImageStatusMap = std::map<uint32_t, ImageDecodingStatus>;
267     using IncrementalRecordMap = std::map<PixelMap *, IncrementalDecodingContext>;
268     ImageSource(std::unique_ptr<SourceStream> &&stream, const SourceOptions &opts);
269     uint32_t CheckEncodedFormat(ImagePlugin::AbsImageFormatAgent &agent);
270     uint32_t GetData(ImagePlugin::DataStreamBuffer &outData, size_t size);
271     static FormatAgentMap InitClass();
272     uint32_t GetEncodedFormat(const std::string &formatHint, std::string &format);
273     uint32_t DecodeImageInfo(uint32_t index, ImageStatusMap::iterator &iter);
274     uint32_t DecodeSourceInfo(bool isAcquiredImageNum);
275     uint32_t InitMainDecoder();
276     ImagePlugin::AbsImageDecoder *CreateDecoder(uint32_t &errorCode);
277     void CopyOptionsToPlugin(const DecodeOptions &opts, ImagePlugin::PixelDecodeOptions &plOpts);
278     void CopyOptionsToProcOpts(const DecodeOptions &opts, DecodeOptions &procOpts, PixelMap &pixelMap);
279     uint32_t CheckFormatHint(const std::string &formatHint, FormatAgentMap::iterator &formatIter);
280     uint32_t GetSourceInfo();
281     uint32_t OnSourceRecognized(bool isAcquiredImageNum);
282     uint32_t OnSourceUnresolved();
283     uint32_t SetDecodeOptions(std::unique_ptr<ImagePlugin::AbsImageDecoder> &decoder, uint32_t index,
284                               const DecodeOptions &opts, ImagePlugin::PlImageInfo &plInfo);
285     uint32_t UpdatePixelMapInfo(const DecodeOptions &opts, ImagePlugin::PlImageInfo &plInfo, PixelMap &pixelMap);
286     uint32_t UpdatePixelMapInfo(const DecodeOptions &opts, ImagePlugin::PlImageInfo &plInfo,
287                                 PixelMap &pixelMap, int32_t fitDensity, bool isReUsed = false);
288     // declare friend class, only IncrementalPixelMap can call PromoteDecoding function.
289     friend class IncrementalPixelMap;
290     uint32_t PromoteDecoding(uint32_t index, const DecodeOptions &opts, PixelMap &pixelMap, ImageDecodingState &state,
291                              uint8_t &decodeProgress);
292     void DetachIncrementalDecoding(PixelMap &pixelMap);
293     ImageStatusMap::iterator GetValidImageStatus(uint32_t index, uint32_t &errorCode);
294     uint32_t AddIncrementalContext(PixelMap &pixelMap, IncrementalRecordMap::iterator &iterator);
295     uint32_t DoIncrementalDecoding(uint32_t index, const DecodeOptions &opts, PixelMap &pixelMap,
296                                    IncrementalDecodingContext &recordContext);
297     void SetIncrementalSource(const bool isIncrementalSource);
298     bool IsStreamCompleted();
299     uint32_t GetImagePropertyCommon(uint32_t index, const std::string &key, std::string &value);
300     FinalOutputStep GetFinalOutputStep(const DecodeOptions &opts, PixelMap &pixelMap, bool hasNinePatch);
301     bool HasDensityChange(const DecodeOptions &opts, ImageInfo &srcImageInfo, bool hasNinePatch);
302     bool ImageSizeChange(int32_t width, int32_t height, int32_t desiredWidth, int32_t desiredHeight);
303     bool ImageConverChange(const Rect &cropRect, ImageInfo &dstImageInfo, ImageInfo &srcImageInfo);
304     void Reset();
305     static std::unique_ptr<SourceStream> DecodeBase64(const uint8_t *data, uint32_t size);
306     static std::unique_ptr<SourceStream> DecodeBase64(const std::string &data);
307     bool IsSpecialYUV();
308     bool GetImageInfoForASTC(ImageInfo& imageInfo, const uint8_t *sourceFilePtr);
309     bool ConvertYUV420ToRGBA(uint8_t *data, uint32_t size, bool isSupportOdd, bool isAddUV, uint32_t &errorCode);
310     std::unique_ptr<PixelMap> CreatePixelMapForYUV(uint32_t &errorCode);
311     std::unique_ptr<PixelMap> CreatePixelMapForASTC(uint32_t &errorCode, const DecodeOptions &opts);
312     bool CompressToAstcFromPixelmap(const DecodeOptions &opts, std::unique_ptr<PixelMap> &rgbaPixelmap,
313         std::unique_ptr<AbsMemory> &dstMemory);
314     std::unique_ptr<PixelMap> CreatePixelAstcFromImageFile(uint32_t index, const DecodeOptions &opts,
315         uint32_t &errorCode);
316     uint32_t GetFormatExtended(std::string &format);
317     static std::unique_ptr<ImageSource> DoImageSourceCreate(
318         std::function<std::unique_ptr<SourceStream>(void)> stream,
319         const SourceOptions &opts, uint32_t &errorCode, const std::string traceName = "");
320     std::unique_ptr<PixelMap> CreatePixelMapExtended(uint32_t index, const DecodeOptions &opts,
321                                                      uint32_t &errorCode);
322     std::unique_ptr<PixelMap> CreatePixelMapByInfos(ImagePlugin::PlImageInfo &plInfo,
323                                                     ImagePlugin::DecodeContext& context, uint32_t &errorCode);
324     bool ApplyGainMap(ImageHdrType hdrType, ImagePlugin::DecodeContext& baseCtx,
325                       ImagePlugin::DecodeContext& hdrCtx, float scale);
326     void ApplyMemoryForHdr(ImagePlugin::DecodeContext& hdrCtx, CM_ColorSpaceType hdrCmColor, ImageHdrType hdrType);
327     bool ComposeHdrImage(ImageHdrType hdrType, ImagePlugin::DecodeContext& baseCtx,
328         ImagePlugin::DecodeContext& gainMapCtx, ImagePlugin::DecodeContext& hdrCtx, HdrMetadata metadata);
329     uint32_t SetGainMapDecodeOption(std::unique_ptr<ImagePlugin::AbsImageDecoder>& decoder,
330                                     ImagePlugin::PlImageInfo& plInfo, float scale);
331     ImagePlugin::DecodeContext DecodeImageDataToContext(uint32_t index, ImageInfo info,
332                                                         ImagePlugin::PlImageInfo& outInfo, uint32_t& errorCode);
333     bool DecodeJpegGainMap(ImageHdrType hdrType, float scale,
334         ImagePlugin::DecodeContext& gainMapCtx, HdrMetadata& metadata);
335     void DumpInputData(const std::string& fileSuffix = "dat");
336     static uint64_t GetNowTimeMicroSeconds();
337     uint32_t ModifyImageProperty(std::shared_ptr<MetadataAccessor> metadataAccessor,
338                                  const std::string &key, const std::string &value);
339     uint32_t RemoveImageProperties(std::shared_ptr<MetadataAccessor> metadataAccessor,
340                                     const std::set<std::string> &key);
341     uint32_t ModifyImageProperty(const std::string &key, const std::string &value);
342     uint32_t CreatExifMetadataByImageSource(bool addFlag = false);
343     uint32_t CreateExifMetadata(uint8_t *buffer, const uint32_t size, bool addFlag, bool hasOriginalFd = false);
344     void SetDecodeInfoOptions(uint32_t index, const DecodeOptions &opts, const ImageInfo &info, ImageEvent &imageEvent);
345     void SetDecodeInfoOptions(uint32_t index, const DecodeOptions &opts, const ImagePlugin::PlImageInfo &plInfo,
346         ImageEvent &imageEvent);
347     void UpdateDecodeInfoOptions(const ImagePlugin::DecodeContext &context, ImageEvent &imageEvent);
348     void SetImageEventHeifParseErr(ImageEvent &event);
349     bool CheckDecodeOptions(Size imageSize, bool &needAisr, bool &needHdr);
350     uint32_t DecodeImageDataToContext(uint32_t index, ImageInfo &info, ImagePlugin::PlImageInfo &plInfo,
351                                       ImagePlugin::DecodeContext &context, uint32_t &errorCode);
352     void TransformSizeWithDensity(const Size &srcSize, int32_t srcDensity, const Size &wantSize,
353                                   int32_t wantDensity, Size &dstSize);
354     uint32_t DoAiHdrProcessDl(const ImagePlugin::DecodeContext &srcCtx, ImagePlugin::DecodeContext &dstCtx,
355                               bool needAisr, bool needHdr);
356     uint32_t ImageAiProcess(Size imageSize, const DecodeOptions &opts, bool isHdr,
357                             ImagePlugin::DecodeContext &context, ImagePlugin::PlImageInfo &plInfo);
358     ImagePlugin::DecodeContext DecodeImageDataToContextExtended(uint32_t index, ImageInfo &info,
359         ImagePlugin::PlImageInfo &plInfo, ImageEvent &imageEvent, uint32_t &errorCode);
360     void SetDngImageSize(uint32_t index, ImageInfo &imageInfo);
361     void SetPixelMapColorSpace(ImagePlugin::DecodeContext& context, std::unique_ptr<PixelMap>& pixelMap,
362         std::unique_ptr<ImagePlugin::AbsImageDecoder>& decoder);
363     bool IsSingleHdrImage(ImageHdrType type);
364     bool IsDualHdrImage(ImageHdrType type);
365     ImagePlugin::DecodeContext HandleSingleHdrImage(ImageHdrType decodedHdrType,
366         ImagePlugin::DecodeContext& context, ImagePlugin::PlImageInfo& plInfo);
367     ImagePlugin::DecodeContext HandleDualHdrImage(ImageHdrType decodedHdrType, ImageInfo info,
368         ImagePlugin::DecodeContext& context, ImagePlugin::PlImageInfo& plInfo);
369     ImagePlugin::DecodeContext InitDecodeContext(const DecodeOptions &opts, const ImageInfo &info,
370         const MemoryUsagePreference &preference, bool hasDesiredSizeOptions, ImagePlugin::PlImageInfo& plInfo);
371     bool ParseHdrType();
372     bool PrereadSourceStream();
373     void SetDmaContextYuvInfo(ImagePlugin::DecodeContext& context);
374     uint8_t* ReadSourceBuffer(uint32_t bufferSize, uint32_t &errorCode);
375     void SetSrcFd(const int& fd);
376     void SetSrcFilePath(const std::string& pathName);
377     void SetSrcBuffer(const uint8_t* buffer, uint32_t size);
378     bool CheckDecodeOptions(const DecodeOptions &opts);
379     bool CheckAllocatorTypeValid(const DecodeOptions &opts);
380     bool CheckCropRectValid(const DecodeOptions &opts);
381 
382 #if !defined(IOS_PLATFORM) && !defined(ANDROID_PLATFORM)
383     void SetHdrMetadataForPicture(std::unique_ptr<Picture> &picture);
384     void DecodeHeifAuxiliaryPictures(const std::set<AuxiliaryPictureType> &auxTypes, std::unique_ptr<Picture> &picture,
385                                      uint32_t &errorCode);
386     void DecodeJpegAuxiliaryPicture(std::set<AuxiliaryPictureType> &auxTypes, std::unique_ptr<Picture> &picture,
387                                     uint32_t &errorCode);
388     bool CheckJpegSourceStream(StreamInfo &streamInfo);
389 #endif
390 
391     const std::string NINE_PATCH = "ninepatch";
392     const std::string SKIA_DECODER = "SKIA_DECODER";
393     static MultimediaPlugin::PluginServer &pluginServer_;
394     static FormatAgentMap formatAgentMap_;
395     std::unique_ptr<SourceStream> sourceStreamPtr_;
396     SourceDecodingState decodeState_ = SourceDecodingState::UNRESOLVED;
397     SourceInfo sourceInfo_;
398     SourceOptions sourceOptions_;
399     NinePatchInfo ninePatchInfo_;
400     ImageStatusMap imageStatusMap_;
401     IncrementalRecordMap incDecodingMap_;
402     // The main decoder is responsible for ordinary decoding (non-Incremental decoding),
403     // as well as decoding SourceInfo and ImageInfo.
404     std::unique_ptr<ImagePlugin::AbsImageDecoder> mainDecoder_;
405     std::unique_ptr<ImagePlugin::AbsImageDecoder> jpegGainmapDecoder_;
406     DecodeOptions opts_;
407     std::set<PeerListener *> listeners_;
408     DecodeEvent decodeEvent_ = DecodeEvent::EVENT_COMPLETE_DECODE;
409     std::map<int32_t, int32_t> decodeEventMap_;
410     std::set<DecodeListener *> decodeListeners_;
411     std::mutex listenerMutex_;
412     std::mutex decodingMutex_;
413     std::mutex fileMutex_;
414     bool isIncrementalSource_ = false;
415     bool isIncrementalCompleted_ = false;
416     bool hasDesiredSizeOptions = false;
417     MemoryUsagePreference preference_ = MemoryUsagePreference::DEFAULT;
418     std::optional<bool> isAstc_;
419     uint64_t imageId_; // generated from the last six bits of the current timestamp
420     ImageHdrType sourceHdrType_; // source image hdr type;
421     std::shared_ptr<ExifMetadata> exifMetadata_ = nullptr;
422     std::string source_; // Image source fd buffer etc
423     bool isExifReadFailed_ = false;
424     uint32_t exifReadStatus_ = 0;
425     uint32_t heifParseErr_ = 0;
426     std::string srcFilePath_ = "";
427     int srcFd_ = -1;
428     uint8_t* srcBuffer_ = nullptr;
429     uint32_t srcBufferSize_ = 0;
430 };
431 } // namespace Media
432 } // namespace OHOS
433 
434 #endif // INTERFACES_INNERKITS_INCLUDE_IMAGE_SOURCE_H
435