diff --git a/frameworks/native/utils/common/common_utils.cpp b/frameworks/native/utils/common/common_utils.cpp index 1ae37e38c3fd48b79b672c0e61ca891efbceb479..050f201277a84f0a8b7638d38c886d2eaf4ae014 100644 --- a/frameworks/native/utils/common/common_utils.cpp +++ b/frameworks/native/utils/common/common_utils.cpp @@ -100,6 +100,11 @@ std::vector AUX_MAP_TYPE_LIST = { EffectPixelmapType::LINEAR, }; +std::vector HDR_P010_LIST = { + GRAPHIC_PIXEL_FMT_YCBCR_P010, + GRAPHIC_PIXEL_FMT_YCRCB_P010, +}; + template ErrorCode ParseJson(const std::string &key, Plugin::Any &any, EffectJsonPtr &json) { @@ -832,6 +837,12 @@ ErrorCode CommonUtils::ParsePicture(Picture *picture, std::shared_ptrGetWidth(); @@ -844,12 +855,15 @@ void ProcessYUVInfo(PixelMap *pixelMap, const SurfaceBuffer *sBuffer, const OH_N info.uvHeight = static_cast(height / YUV_HALF); if (planes->planeCount >= YUV_PLANE_COUNT) { int32_t pixelFmt = sBuffer->GetFormat(); + bool isYuvP010 = IsYuvP010(pixelFmt); int uvPlaneOffset = (pixelFmt == GRAPHIC_PIXEL_FMT_YCBCR_420_SP || pixelFmt == GRAPHIC_PIXEL_FMT_YCBCR_P010) ? 1 : 2; - info.yStride = planes->planes[0].columnStride; - info.uvStride = planes->planes[uvPlaneOffset].columnStride; - info.yOffset = planes->planes[0].offset; - info.uvOffset = planes->planes[uvPlaneOffset].offset; + info.yStride = isYuvP010 ? (planes->planes[0].columnStride / YUV_HALF) : planes->planes[0].columnStride; + info.uvStride = isYuvP010 ? (planes->planes[uvPlaneOffset].columnStride / YUV_HALF) : + (planes->planes[uvPlaneOffset].columnStride); + info.yOffset = isYuvP010 ? (planes->planes[0].offset / YUV_HALF) : (planes->planes[0].offset); + info.uvOffset = + isYuvP010 ? (planes->planes[uvPlaneOffset].offset / YUV_HALF) : (planes->planes[uvPlaneOffset].offset); pixelMap->SetImageYUVInfo(info); } } @@ -920,7 +934,7 @@ ErrorCode ModifyYUVInfo(PixelMap *pixelMap, void *context, const MemoryInfo &mem { CHECK_AND_RETURN_RET_LOG(context != nullptr, ErrorCode::ERR_INPUT_NULL, "handle yuv info, context is null."); SurfaceBuffer *sBuffer = reinterpret_cast(context); - if (memoryInfo.bufferType == BufferType::SHARED_MEMORY) { + if (memoryInfo.bufferType == BufferType::SHARED_MEMORY || memoryInfo.bufferType == BufferType::HEAP_MEMORY) { int32_t width = memoryInfo.bufferInfo.width_; int32_t height = memoryInfo.bufferInfo.height_; YUVDataInfo info;