• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2025 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 #define MLOG_TAG "Thumbnail"
16 
17 #include "thumbnail_image_framework_utils.h"
18 
19 #include <securec.h>
20 
21 #include "hdr_type.h"
22 #include "image_source.h"
23 #include "v1_0/buffer_handle_meta_key_type.h"
24 
25 #include "medialibrary_errno.h"
26 #include "medialibrary_tracer.h"
27 #include "media_image_framework_utils.h"
28 #include "media_log.h"
29 #include "thumbnail_const.h"
30 
31 using namespace std;
32 using namespace OHOS::HDI::Display::Graphic::Common::V1_0;
33 
34 namespace OHOS {
35 namespace Media {
36 
37 static constexpr int32_t PLANE_Y = 0;
38 static constexpr int32_t PLANE_U = 1;
39 static constexpr int32_t PLANE_V = 2;
40 static constexpr uint8_t HDR_PIXEL_SIZE = 2;
41 static constexpr uint8_t SDR_PIXEL_SIZE = 1;
42 
43 // LCOV_EXCL_START
IsYuvPixelMap(std::shared_ptr<PixelMap> pixelMap)44 bool ThumbnailImageFrameWorkUtils::IsYuvPixelMap(std::shared_ptr<PixelMap> pixelMap)
45 {
46     CHECK_AND_RETURN_RET_LOG(pixelMap != nullptr, false, "PixelMap is nullptr");
47     PixelFormat format = pixelMap->GetPixelFormat();
48     return format == PixelFormat::NV21 || format == PixelFormat::NV12 ||
49         format == PixelFormat::YCRCB_P010 || format == PixelFormat::YCBCR_P010;
50 }
51 
IsSupportCopyPixelMap(std::shared_ptr<PixelMap> pixelMap)52 bool ThumbnailImageFrameWorkUtils::IsSupportCopyPixelMap(std::shared_ptr<PixelMap> pixelMap)
53 {
54     CHECK_AND_RETURN_RET_LOG(pixelMap != nullptr, false, "PixelMap is nullptr");
55     if (!IsYuvPixelMap(pixelMap)) {
56         return true;
57     }
58     PixelFormat format = pixelMap->GetPixelFormat();
59     CHECK_AND_RETURN_RET_LOG(format == PixelFormat::NV21 || format == PixelFormat::NV12, false,
60         "Not support copy pixelMap, format:%{public}d", format);
61     return true;
62 }
63 
CopyPictureSource(std::shared_ptr<Picture> picture)64 std::shared_ptr<Picture> ThumbnailImageFrameWorkUtils::CopyPictureSource(std::shared_ptr<Picture> picture)
65 {
66     CHECK_AND_RETURN_RET_LOG(picture != nullptr, nullptr, "Picture is nullptr");
67     MediaLibraryTracer tracer;
68     tracer.Start("CopyPictureSource");
69     auto pixelMap = picture->GetMainPixel();
70     auto gainMap = picture->GetGainmapPixelMap();
71     CHECK_AND_RETURN_RET_LOG(pixelMap != nullptr && gainMap != nullptr, nullptr,
72         "PixelMap or gainMap is nullptr");
73     MEDIA_INFO_LOG("Picture information: pixelMap format:%{public}d isHdr:%{public}d allocatorType:%{public}d, "
74         "gainMap format:%{public}d isHdr:%{public}d allocatorType:%{public}d, size: %{public}d * %{public}d",
75         pixelMap->GetPixelFormat(), pixelMap->IsHdr(), pixelMap->GetAllocatorType(), gainMap->GetPixelFormat(),
76         gainMap->IsHdr(), gainMap->GetAllocatorType(), pixelMap->GetWidth(), pixelMap->GetHeight());
77 
78     std::shared_ptr<PixelMap> copyPixelMap = CopyPixelMapSource(pixelMap);
79     CHECK_AND_RETURN_RET_LOG(copyPixelMap != nullptr, nullptr, "Copy pixelMap failed");
80 
81     std::shared_ptr<PixelMap> copyGainMap = CopyPixelMapSource(gainMap);
82     CHECK_AND_RETURN_RET_LOG(copyGainMap != nullptr, nullptr, "Copy gainMap failed");
83 
84     Size copyGainMapSize = {copyGainMap->GetWidth(), copyGainMap->GetHeight()};
85     auto auxiliaryPicturePtr = AuxiliaryPicture::Create(copyGainMap, AuxiliaryPictureType::GAINMAP, copyGainMapSize);
86     std::shared_ptr<AuxiliaryPicture> auxiliaryPicture = std::move(auxiliaryPicturePtr);
87     CHECK_AND_RETURN_RET_LOG(auxiliaryPicture != nullptr, nullptr, "Create auxiliaryPicture failed");
88 
89     auto copySourcePtr = Picture::Create(copyPixelMap);
90     std::shared_ptr<Picture> copySource = std::move(copySourcePtr);
91     copySource->SetAuxiliaryPicture(auxiliaryPicture);
92     return copySource;
93 }
94 
CopyPixelMapSource(std::shared_ptr<PixelMap> pixelMap)95 std::shared_ptr<PixelMap> ThumbnailImageFrameWorkUtils::CopyPixelMapSource(std::shared_ptr<PixelMap> pixelMap)
96 {
97     CHECK_AND_RETURN_RET_LOG(IsSupportCopyPixelMap(pixelMap), nullptr, "Not support copy pixelMap");
98     if (IsYuvPixelMap(pixelMap)) {
99         return CopyYuvPixelmap(pixelMap);
100     }
101     return CopyNormalPixelmap(pixelMap);
102 }
103 
CopyNormalPixelmap(std::shared_ptr<PixelMap> pixelMap)104 std::shared_ptr<PixelMap> ThumbnailImageFrameWorkUtils::CopyNormalPixelmap(std::shared_ptr<PixelMap> pixelMap)
105 {
106     MediaLibraryTracer tracer;
107     tracer.Start("CopyNormalPixelmap");
108     Media::InitializationOptions pixelMapOpts = {
109         .size = {pixelMap->GetWidth(), pixelMap->GetHeight()},
110         .pixelFormat = pixelMap->GetPixelFormat(),
111         .alphaType = pixelMap->GetAlphaType()
112     };
113     auto copyPixelMapPtr = PixelMap::Create(*pixelMap, pixelMapOpts);
114     std::shared_ptr<PixelMap> copyPixelMap = std::move(copyPixelMapPtr);
115     CHECK_AND_RETURN_RET_LOG(copyPixelMap != nullptr, nullptr, "CopyNormalPixelmap failed");
116     return copyPixelMap;
117 }
118 
CopyYuvPixelmap(std::shared_ptr<PixelMap> pixelMap)119 std::shared_ptr<PixelMap> ThumbnailImageFrameWorkUtils::CopyYuvPixelmap(std::shared_ptr<PixelMap> pixelMap)
120 {
121     if (pixelMap->GetAllocatorType() == AllocatorType::DMA_ALLOC) {
122         return CopyYuvPixelmapWithSurfaceBuffer(pixelMap);
123     }
124     return CopyNoSurfaceBufferYuvPixelmap(pixelMap);
125 }
126 
CopyYuvPixelmapWithSurfaceBuffer(std::shared_ptr<PixelMap> pixelMap)127 std::shared_ptr<PixelMap> ThumbnailImageFrameWorkUtils::CopyYuvPixelmapWithSurfaceBuffer(
128     std::shared_ptr<PixelMap> pixelMap)
129 {
130     MediaLibraryTracer tracer;
131     tracer.Start("CopyYuvPixelmapWithSurfaceBuffer");
132     CHECK_AND_RETURN_RET_LOG(pixelMap->GetFd() != nullptr, nullptr, "Get fd failed");
133     sptr<SurfaceBuffer> surfaceBuffer = reinterpret_cast<SurfaceBuffer *>(pixelMap->GetFd());
134     CHECK_AND_RETURN_RET_LOG(surfaceBuffer != nullptr, nullptr, "Get surfaceBuffer failed");
135     sptr<SurfaceBuffer> dstSurfaceBuffer = SurfaceBuffer::Create();
136     CHECK_AND_RETURN_RET_LOG(dstSurfaceBuffer != nullptr, nullptr, "Create surfaceBuffer failed");
137 
138     BufferRequestConfig requestConfig = {
139         .width = surfaceBuffer->GetWidth(),
140         .height = surfaceBuffer->GetHeight(),
141         .strideAlignment = 0x2,
142         .format = surfaceBuffer->GetFormat(),
143         .usage = surfaceBuffer->GetUsage(),
144         .timeout = 0,
145     };
146     GSError allocRes = dstSurfaceBuffer->Alloc(requestConfig);
147     CHECK_AND_RETURN_RET_LOG(allocRes == 0, nullptr, "Alloc surfaceBuffer failed, err:%{public}d", allocRes);
148     CopySurfaceBufferInfo(surfaceBuffer, dstSurfaceBuffer);
149     int32_t copyRes = memcpy_s(dstSurfaceBuffer->GetVirAddr(), dstSurfaceBuffer->GetSize(),
150                                surfaceBuffer->GetVirAddr(), surfaceBuffer->GetSize());
151     CHECK_AND_RETURN_RET_LOG(copyRes == E_OK, nullptr,
152         "Copy surface buffer pixels failed, copyRes %{public}d", copyRes);
153 
154     InitializationOptions opts;
155     opts.size.width = pixelMap->GetWidth();
156     opts.size.height = pixelMap->GetHeight();
157     opts.srcPixelFormat = pixelMap->GetPixelFormat();
158     opts.pixelFormat = pixelMap->GetPixelFormat();
159     opts.useDMA = true;
160     std::shared_ptr<PixelMap> copyPixelMap = PixelMap::Create(opts);
161     CHECK_AND_RETURN_RET_LOG(copyPixelMap != nullptr, nullptr, "Create pixelMap failed");
162 
163     void* nativeBuffer = dstSurfaceBuffer.GetRefPtr();
164     RefBase *ref = reinterpret_cast<RefBase *>(nativeBuffer);
165     ref->IncStrongRef(ref);
166     copyPixelMap->SetHdrType(pixelMap->GetHdrType());
167     copyPixelMap->InnerSetColorSpace(pixelMap->InnerGetGrColorSpace());
168     copyPixelMap->SetPixelsAddr(dstSurfaceBuffer->GetVirAddr(), dstSurfaceBuffer.GetRefPtr(),
169         dstSurfaceBuffer->GetSize(), AllocatorType::DMA_ALLOC, nullptr);
170     CHECK_AND_RETURN_RET_LOG(SetPixelMapYuvInfo(dstSurfaceBuffer, copyPixelMap, pixelMap->IsHdr()), nullptr,
171         "SetPixelMapYuvInfo failed");
172     return copyPixelMap;
173 }
174 
CopyNoSurfaceBufferYuvPixelmap(std::shared_ptr<PixelMap> pixelMap)175 std::shared_ptr<PixelMap> ThumbnailImageFrameWorkUtils::CopyNoSurfaceBufferYuvPixelmap(
176     std::shared_ptr<PixelMap> pixelMap)
177 {
178     MediaLibraryTracer tracer;
179     tracer.Start("CopyNoSurfaceBufferYuvPixelmap");
180     auto startPtr = pixelMap->GetPixels();
181     InitializationOptions opts;
182     opts.size.width = pixelMap->GetWidth();
183     opts.size.height = pixelMap->GetHeight();
184     opts.pixelFormat = pixelMap->GetPixelFormat();
185     std::shared_ptr<PixelMap> copyPixelMap = PixelMap::Create(opts);
186     CHECK_AND_RETURN_RET_LOG(copyPixelMap != nullptr, nullptr, "Create pixelMap failed");
187 
188     int32_t copyRes = memcpy_s(copyPixelMap->GetWritablePixels(), pixelMap->GetByteCount(),
189         startPtr, pixelMap->GetByteCount());
190     CHECK_AND_RETURN_RET_LOG(copyRes == E_OK, nullptr,
191         "CopyNoSurfaceBufferYuvPixelmap failed, copyRes:%{public}d", copyRes);
192     sptr<SurfaceBuffer> surfaceBuffer = nullptr;
193     CHECK_AND_RETURN_RET_LOG(SetPixelMapYuvInfo(surfaceBuffer, copyPixelMap, false), nullptr,
194         "SetPixelMapYuvInfo failed");
195     return copyPixelMap;
196 }
197 
SetPixelMapYuvInfo(sptr<SurfaceBuffer> & surfaceBuffer,std::shared_ptr<PixelMap> pixelMap,bool isHdr)198 bool ThumbnailImageFrameWorkUtils::SetPixelMapYuvInfo(sptr<SurfaceBuffer> &surfaceBuffer,
199     std::shared_ptr<PixelMap> pixelMap, bool isHdr)
200 {
201     CHECK_AND_RETURN_RET_LOG(pixelMap != nullptr, false, "PixelMap is nullptr");
202     uint8_t ratio = isHdr ? HDR_PIXEL_SIZE : SDR_PIXEL_SIZE;
203     int32_t srcWidth = pixelMap->GetWidth();
204     int32_t srcHeight = pixelMap->GetHeight();
205     YUVDataInfo yuvDataInfo = { .yWidth = srcWidth,
206                                 .yHeight = srcHeight,
207                                 .uvWidth = srcWidth / 2,
208                                 .uvHeight = srcHeight / 2,
209                                 .yStride = srcWidth,
210                                 .uvStride = srcWidth,
211                                 .uvOffset = srcWidth * srcHeight};
212 
213     if (surfaceBuffer == nullptr) {
214         pixelMap->SetImageYUVInfo(yuvDataInfo);
215         return true;
216     }
217     OH_NativeBuffer_Planes *planes = nullptr;
218     GSError retVal = surfaceBuffer->GetPlanesInfo(reinterpret_cast<void**>(&planes));
219     if (retVal != OHOS::GSERROR_OK || planes == nullptr) {
220         pixelMap->SetImageYUVInfo(yuvDataInfo);
221         return true;
222     }
223 
224     auto format = pixelMap->GetPixelFormat();
225     if (format == PixelFormat::NV12) {
226         yuvDataInfo.yStride = planes->planes[PLANE_Y].columnStride / ratio;
227         yuvDataInfo.uvStride = planes->planes[PLANE_U].columnStride / ratio;
228         yuvDataInfo.yOffset = planes->planes[PLANE_Y].offset / ratio;
229         yuvDataInfo.uvOffset = planes->planes[PLANE_U].offset / ratio;
230     } else if (format == PixelFormat::NV21) {
231         yuvDataInfo.yStride = planes->planes[PLANE_Y].columnStride / ratio;
232         yuvDataInfo.uvStride = planes->planes[PLANE_V].columnStride / ratio;
233         yuvDataInfo.yOffset = planes->planes[PLANE_Y].offset / ratio;
234         yuvDataInfo.uvOffset = planes->planes[PLANE_V].offset / ratio;
235     } else {
236         MEDIA_ERR_LOG("Not support SetImageYUVInfo, format:%{public}d", format);
237         return false;
238     }
239 
240     pixelMap->SetImageYUVInfo(yuvDataInfo);
241     return true;
242 }
243 
CopySurfaceBufferInfo(sptr<SurfaceBuffer> & source,sptr<SurfaceBuffer> & dst)244 void ThumbnailImageFrameWorkUtils::CopySurfaceBufferInfo(sptr<SurfaceBuffer> &source, sptr<SurfaceBuffer> &dst)
245 {
246     MediaLibraryTracer tracer;
247     tracer.Start("CopySurfaceBufferInfo");
248     CHECK_AND_RETURN_LOG(source != nullptr && dst != nullptr,
249         "CopySurfaceBufferInfo failed, source or dst is nullptr");
250     std::vector<uint8_t> hdrMetadataTypeVec;
251     std::vector<uint8_t> colorSpaceInfoVec;
252     std::vector<uint8_t> staticData;
253     std::vector<uint8_t> dynamicData;
254 
255     if (source->GetMetadata(ATTRKEY_HDR_METADATA_TYPE, hdrMetadataTypeVec) == GSERROR_OK) {
256         dst->SetMetadata(ATTRKEY_HDR_METADATA_TYPE, hdrMetadataTypeVec);
257     }
258     if (source->GetMetadata(ATTRKEY_COLORSPACE_INFO, colorSpaceInfoVec) == GSERROR_OK) {
259         dst->SetMetadata(ATTRKEY_COLORSPACE_INFO, colorSpaceInfoVec);
260     }
261     if (GetSbStaticMetadata(source, staticData) && (staticData.size() > 0)) {
262         SetSbStaticMetadata(dst, staticData);
263     }
264     if (GetSbDynamicMetadata(source, dynamicData) && (dynamicData.size()) > 0) {
265         SetSbDynamicMetadata(dst, dynamicData);
266     }
267 }
268 
GetSbStaticMetadata(const sptr<SurfaceBuffer> & buffer,std::vector<uint8_t> & staticMetadata)269 bool ThumbnailImageFrameWorkUtils::GetSbStaticMetadata(const sptr<SurfaceBuffer> &buffer,
270     std::vector<uint8_t> &staticMetadata)
271 {
272     return buffer->GetMetadata(ATTRKEY_HDR_STATIC_METADATA, staticMetadata) == GSERROR_OK;
273 }
274 
GetSbDynamicMetadata(const sptr<SurfaceBuffer> & buffer,std::vector<uint8_t> & dynamicMetadata)275 bool ThumbnailImageFrameWorkUtils::GetSbDynamicMetadata(const sptr<SurfaceBuffer> &buffer,
276     std::vector<uint8_t> &dynamicMetadata)
277 {
278     return buffer->GetMetadata(ATTRKEY_HDR_DYNAMIC_METADATA, dynamicMetadata) == GSERROR_OK;
279 }
280 
SetSbStaticMetadata(sptr<SurfaceBuffer> & buffer,const std::vector<uint8_t> & staticMetadata)281 bool ThumbnailImageFrameWorkUtils::SetSbStaticMetadata(sptr<SurfaceBuffer> &buffer,
282     const std::vector<uint8_t> &staticMetadata)
283 {
284     return buffer->SetMetadata(ATTRKEY_HDR_STATIC_METADATA, staticMetadata) == GSERROR_OK;
285 }
286 
SetSbDynamicMetadata(sptr<SurfaceBuffer> & buffer,const std::vector<uint8_t> & dynamicMetadata)287 bool ThumbnailImageFrameWorkUtils::SetSbDynamicMetadata(sptr<SurfaceBuffer> &buffer,
288     const std::vector<uint8_t> &dynamicMetadata)
289 {
290     return buffer->SetMetadata(ATTRKEY_HDR_DYNAMIC_METADATA, dynamicMetadata) == GSERROR_OK;
291 }
292 
IsSupportGenAstc()293 bool ThumbnailImageFrameWorkUtils::IsSupportGenAstc()
294 {
295     return ImageSource::IsSupportGenAstc();
296 }
297 
IsPictureValid(const std::shared_ptr<Picture> & picture)298 bool ThumbnailImageFrameWorkUtils::IsPictureValid(const std::shared_ptr<Picture>& picture)
299 {
300     CHECK_AND_RETURN_RET_LOG(picture != nullptr, false, "Picture is null");
301     CHECK_AND_RETURN_RET_LOG(picture->GetMainPixel() != nullptr, false, "Picture main pixel is null");
302     CHECK_AND_RETURN_RET_LOG(picture->GetGainmapPixelMap() != nullptr, false, "Picture gain pixel is null");
303     auto mainWidth = picture->GetMainPixel()->GetWidth();
304     auto mainHeight = picture->GetMainPixel()->GetHeight();
305     CHECK_AND_RETURN_RET_LOG(mainWidth > 0 && mainHeight > 0, false,
306         "Invalid main pixel map size: width %{public}d, height: %{public}d", mainWidth, mainHeight);
307     return true;
308 }
309 
IsPixelMapValid(const std::shared_ptr<PixelMap> & pixelMap)310 bool ThumbnailImageFrameWorkUtils::IsPixelMapValid(const std::shared_ptr<PixelMap>& pixelMap)
311 {
312     CHECK_AND_RETURN_RET_LOG(pixelMap != nullptr, false, "Picture is null");
313     auto width = pixelMap->GetWidth();
314     auto height = pixelMap->GetHeight();
315     CHECK_AND_RETURN_RET_LOG(width > 0 && height > 0, false,
316         "Invalid pixel map size: width %{public}d, height: %{public}d", width, height);
317     return true;
318 }
319 
CopyAndScalePicture(const std::shared_ptr<Picture> & picture,const Size & desiredSize)320 std::shared_ptr<Picture> ThumbnailImageFrameWorkUtils::CopyAndScalePicture(const std::shared_ptr<Picture>& picture,
321     const Size& desiredSize)
322 {
323     std::shared_ptr<Picture> copyPicture = nullptr;
324     CHECK_AND_RETURN_RET_LOG(desiredSize.width > 0 && desiredSize.height > 0, nullptr,
325         "Invalid desired size: width: %{public}d, height: %{public}d", desiredSize.width, desiredSize.height);
326     CHECK_AND_RETURN_RET_LOG(ThumbnailImageFrameWorkUtils::IsPictureValid(picture), nullptr, "picture is invalid");
327 
328     copyPicture = ThumbnailImageFrameWorkUtils::CopyPictureSource(picture);
329     CHECK_AND_RETURN_RET_LOG(IsPictureValid(copyPicture), nullptr, "CopyPictureSource failed");
330 
331     float widthScale = (1.0f * desiredSize.width) / picture->GetMainPixel()->GetWidth();
332     float heightScale = (1.0f * desiredSize.height) / picture->GetMainPixel()->GetHeight();
333     copyPicture->GetMainPixel()->scale(widthScale, heightScale);
334     copyPicture->GetGainmapPixelMap()->scale(widthScale, heightScale);
335     return copyPicture;
336 }
337 
CopyAndScalePixelMap(const std::shared_ptr<PixelMap> & pixelMap,const Size & desiredSize)338 std::shared_ptr<PixelMap> ThumbnailImageFrameWorkUtils::CopyAndScalePixelMap(const std::shared_ptr<PixelMap>& pixelMap,
339     const Size& desiredSize)
340 {
341     CHECK_AND_RETURN_RET_LOG(ThumbnailImageFrameWorkUtils::IsPixelMapValid(pixelMap), nullptr, "PixelMap is invalid");
342     CHECK_AND_RETURN_RET_LOG(desiredSize.width > 0 && desiredSize.height > 0, nullptr,
343         "Invalid desired size: width: %{public}d, height: %{public}d", desiredSize.width, desiredSize.height);
344     auto copySource = ThumbnailImageFrameWorkUtils::CopyPixelMapSource(pixelMap);
345     CHECK_AND_RETURN_RET_LOG(IsPixelMapValid(copySource), nullptr, "CopyPixelMapSource failed");
346     float widthScale = (1.0f * desiredSize.width) / pixelMap->GetWidth();
347     float heightScale = (1.0f * desiredSize.height) / pixelMap->GetHeight();
348     copySource->scale(widthScale, heightScale);
349     return copySource;
350 }
351 
FlipAndRotatePicture(std::shared_ptr<Picture> picture,int32_t exifRotate)352 bool ThumbnailImageFrameWorkUtils::FlipAndRotatePicture(std::shared_ptr<Picture> picture, int32_t exifRotate)
353 {
354     FlipAndRotateInfo info;
355     CHECK_AND_RETURN_RET_LOG(ExifRotateUtils::GetFlipAndRotateInfo(exifRotate, info), false,
356         "ExifRotate:%{public}d is invalid", exifRotate);
357     return FlipAndRotatePicture(picture, info);
358 }
359 
FlipAndRotatePicture(std::shared_ptr<Picture> picture,const FlipAndRotateInfo & info)360 bool ThumbnailImageFrameWorkUtils::FlipAndRotatePicture(std::shared_ptr<Picture> picture, const FlipAndRotateInfo &info)
361 {
362     CHECK_AND_RETURN_RET_LOG(IsPictureValid(picture), false, "Picture is invalid");
363     auto pixelMap = picture->GetMainPixel();
364     CHECK_AND_RETURN_RET_LOG(ThumbnailImageFrameWorkUtils::FlipAndRotatePixelMap(pixelMap, info),
365         false, "FlipAndRotate pixelMap failed");
366 
367     auto gainMap = picture->GetGainmapPixelMap();
368     CHECK_AND_RETURN_RET_LOG(ThumbnailImageFrameWorkUtils::FlipAndRotatePixelMap(gainMap, info),
369         false, "FlipAndRotate gainMap failed");
370     return true;
371 }
372 
FlipAndRotatePixelMap(std::shared_ptr<PixelMap> pixelMap,int32_t exifRotate)373 bool ThumbnailImageFrameWorkUtils::FlipAndRotatePixelMap(std::shared_ptr<PixelMap> pixelMap, int32_t exifRotate)
374 {
375     FlipAndRotateInfo info;
376     CHECK_AND_RETURN_RET_LOG(ExifRotateUtils::GetFlipAndRotateInfo(exifRotate, info), false,
377         "GetFlipAndRotateInfo failed, exifRotate:%{public}d", exifRotate);
378     return FlipAndRotatePixelMap(pixelMap, info);
379 }
380 
FlipAndRotatePixelMap(std::shared_ptr<PixelMap> pixelMap,const FlipAndRotateInfo & info)381 bool ThumbnailImageFrameWorkUtils::FlipAndRotatePixelMap(std::shared_ptr<PixelMap> pixelMap,
382     const FlipAndRotateInfo &info)
383 {
384     CHECK_AND_RETURN_RET_LOG(pixelMap != nullptr, false, "PixelMap is nullptr");
385     return MediaImageFrameWorkUtils::FlipAndRotatePixelMap(*(pixelMap.get()), info);
386 }
387 // LCOV_EXCL_STOP
388 } // namespace Media
389 } // namespace OHOS