From 12f67e030bf881ab81287f37082d56386446b8a7 Mon Sep 17 00:00:00 2001 From: xiaobjy Date: Mon, 13 May 2024 19:31:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9iso=E5=85=83=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E8=A7=A3=E6=9E=90=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: xiaobjy Change-Id: I139b463854c14dd2106a12172de3c851d35bd8f6 --- .../innerkitsimpl/codec/src/image_source.cpp | 8 +++++++- .../libs/image/libextplugin/src/ext_decoder.cpp | 1 + .../image/libextplugin/src/hdr/hdr_helper.cpp | 16 ++++++++++------ 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/frameworks/innerkitsimpl/codec/src/image_source.cpp b/frameworks/innerkitsimpl/codec/src/image_source.cpp index 87099cc3c..9e7c33f95 100644 --- a/frameworks/innerkitsimpl/codec/src/image_source.cpp +++ b/frameworks/innerkitsimpl/codec/src/image_source.cpp @@ -750,6 +750,8 @@ static void SetPixelMapColorSpace(ImagePlugin::DecodeContext context, unique_ptr #ifdef IMAGE_COLORSPACE_FLAG if (context.hdrType > ImageHdrType::SDR) { pixelMap->InnerSetColorSpace(OHOS::ColorManager::ColorSpace(context.grColorSpaceName)); + IMAGE_LOGD("hdr set pixelmap colorspace is %{public}d-%{public}d", + context.grColorSpaceName, pixelMap->InnerGetGrColorSpace().GetColorSpaceName()); return ; } bool isSupportICCProfile = decoder->IsSupportICCProfile(); @@ -3035,7 +3037,9 @@ bool ImageSource::ApplyGainMap(ImageHdrType hdrType, DecodeContext& baseCtx, Dec IMAGE_LOGI("[ImageSource] jpeg get gainmap failed"); return false; } - + IMAGE_LOGD("get hdr metadata, extend flag is %{public}d, static size is %{public}zu," + "dynamic metadata size is %{public}zu", + metadata.extendMetaFlag, metadata.staticMetadata.size(), metadata.dynamicMetadata.size()); bool result = ComposeHdrImage(hdrType, baseCtx, gainMapCtx, hdrCtx, metadata); FreeContextBuffer(gainMapCtx.freeFunc, gainMapCtx.allocatorType, gainMapCtx.pixelsBuffer); return result; @@ -3107,6 +3111,8 @@ bool ImageSource::ComposeHdrImage(ImageHdrType hdrType, DecodeContext& baseCtx, sptr gainmapSptr(reinterpret_cast(gainMapCtx.pixelsBuffer.context)); CM_ColorSpaceType hdrCmColor = CM_BT2020_HLG_FULL; CM_ColorSpaceType gainmapCmColor = metadata.extendMeta.metaISO.useBaseColorFlag == 0x01 ? baseCmColor : hdrCmColor; + IMAGE_LOGD("ComposeHdrImage color flag = %{public}d, gainmapChannelNum = %{public}d", + metadata.extendMeta.metaISO.useBaseColorFlag, metadata.extendMeta.metaISO.gainmapChannelNum); SetVividMetaColor(metadata, baseCmColor, gainmapCmColor, hdrCmColor); VpeUtils::SetSurfaceBufferInfo(gainmapSptr, true, hdrType, gainmapCmColor, metadata); // hdr image diff --git a/plugins/common/libs/image/libextplugin/src/ext_decoder.cpp b/plugins/common/libs/image/libextplugin/src/ext_decoder.cpp index ca181cea1..28bba636d 100644 --- a/plugins/common/libs/image/libextplugin/src/ext_decoder.cpp +++ b/plugins/common/libs/image/libextplugin/src/ext_decoder.cpp @@ -1628,6 +1628,7 @@ HdrMetadata ExtDecoder::GetHdrMetadata(Media::ImageHdrType type) if (type > Media::ImageHdrType::SDR && HdrHelper::GetMetadata(codec_.get(), type, metadata)) { return metadata; } + IMAGE_LOGD("get hdr metadata failed, type is %{public}d, flag is %{public}d", type, metadata.extendMetaFlag); return {}; #endif } diff --git a/plugins/common/libs/image/libextplugin/src/hdr/hdr_helper.cpp b/plugins/common/libs/image/libextplugin/src/hdr/hdr_helper.cpp index 62c963ed2..71b5e3623 100644 --- a/plugins/common/libs/image/libextplugin/src/hdr/hdr_helper.cpp +++ b/plugins/common/libs/image/libextplugin/src/hdr/hdr_helper.cpp @@ -747,8 +747,8 @@ static bool ParseISOMetadata(uint8_t* data, uint32_t length, HdrMetadata& metada return false; } uint8_t flag = data[dataOffset++]; - metadata.extendMeta.metaISO.gainmapChannelNum = (flag & 0x01) * INDEX_TWO + INDEX_ONE; - metadata.extendMeta.metaISO.useBaseColorFlag = (flag >> INDEX_ONE) & 0x01; + metadata.extendMeta.metaISO.gainmapChannelNum = ((flag & 0x80) == 0x80) ? THREE_COMPONENTS : ONE_COMPONENT; + metadata.extendMeta.metaISO.useBaseColorFlag = ((flag & 0x40) == 0x40) ? 0x01 : 0x00; uint32_t baseHeadroomNumerator = ImageUtils::BytesToUint32(data, dataOffset); uint32_t baseHeadroomDenominator = ImageUtils::BytesToUint32(data, dataOffset); @@ -873,10 +873,6 @@ static bool GetHeifMetadata(HeifDecoder* heifDecoder, ImageHdrType type, HdrMeta } metadata.staticMetadata = ParseHeifStaticMetadata(displayInfo, lightInfo); bool res = ParseVividMetadata(uwaInfo.data(), uwaInfo.size(), metadata); - if (!res) { - IMAGE_LOGI("get heif vivid metadata failed"); - return false; - } if (!metadata.extendMetaFlag) { vector isoMetadata; heifDecoder->getISOMetadata(isoMetadata); @@ -1239,6 +1235,14 @@ vector HdrJpegPackerHelper::PackISOMetadataMarker(HdrMetadata& metadata } index += ISO_GAINMAP_TAG_SIZE; ImageUtils::Uint32ToBytes(extendMeta.metaISO.writeVersion, bytes, index); + bytes[index] = 0x00; + if (extendMeta.metaISO.useBaseColorFlag) { + bytes[index] |= 0x40; + } + if (extendMeta.metaISO.gainmapChannelNum) { + bytes[index] |= 0x80; + } + index++; bytes[index++] = (extendMeta.metaISO.useBaseColorFlag << INDEX_ONE) | (extendMeta.metaISO.gainmapChannelNum & 0x01); uint32_t baseHeadroomNumerator = EMPTY_SIZE; if (extendMeta.metaISO.baseHeadroom > (float)EMPTY_SIZE) { -- Gitee