From 36759e2bd2352146caa979237bf593a9e693e1a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B1=B6=E8=B0=8F?= Date: Sat, 13 Sep 2025 08:16:22 +0000 Subject: [PATCH 1/3] add checkHdrType MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 刘汶谏 --- .../innerkitsimpl/codec/src/image_source.cpp | 22 +++- .../image_source_test/image_source_test.cpp | 103 ++++++++++++++++++ interfaces/innerkits/include/image_source.h | 3 + 3 files changed, 127 insertions(+), 1 deletion(-) diff --git a/frameworks/innerkitsimpl/codec/src/image_source.cpp b/frameworks/innerkitsimpl/codec/src/image_source.cpp index 68f077254..a5a5f8c55 100644 --- a/frameworks/innerkitsimpl/codec/src/image_source.cpp +++ b/frameworks/innerkitsimpl/codec/src/image_source.cpp @@ -84,7 +84,6 @@ #include "include/core/SkData.h" #endif #include "string_ex.h" -#include "hdr_type.h" #include "image_mime_type.h" #ifdef IMAGE_QOS_ENABLE #include "qos.h" @@ -5386,6 +5385,27 @@ std::string ImageSource::GetPixelMapName(PixelMap* pixelMap) IMAGE_LOGD("pixelMapStr is %{public}s", pixelMapStr.c_str()); return pixelMapStr; } +ImageHdrType ImageSource::CheckHdrType() +{ + IMAGE_LOGD("start CheckHdrType()"); + + if (checkHdrType_ != ImageHdrType::UNKNOWN) { + IMAGE_LOGD("already have checkHdrType_: %{public}d", checkHdrType_); + return checkHdrType_; + } + if (ImageSource::ParseHdrType()) { + IMAGE_LOGD("ParseHdrType checkHdrType_: %{public}d", sourceHdrType_); + checkHdrType_ = sourceHdrType_; + if (checkHdrType_ == ImageHdrType::HDR_LOG_DUAL) { + checkHdrType_ = ImageHdrType::SDR; + } + IMAGE_LOGD("final checkHdrType_: %{public}d", checkHdrType_); + } else { + checkHdrType_ = ImageHdrType::UNKNOWN; + IMAGE_LOGD("fail checkHdrType_: %{public}d", checkHdrType_); + } + return checkHdrType_; +} } // namespace Media } // namespace OHOS diff --git a/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_test.cpp b/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_test.cpp index 29c4828b7..ce9ea2a6d 100644 --- a/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_test.cpp +++ b/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_test.cpp @@ -59,6 +59,16 @@ static const std::string IMAGE_JPG_THREE_GAINMAP_HDR_PATH = "/data/local/tmp/ima static const std::string IMAGE_HEIC_THREE_GAINMAP_HDR_PATH = "/data/local/tmp/image/three_gainmap_hdr.heic"; static const std::string IMAGE_GIF_LARGE_SIZE_PATH = "/data/local/tmp/image/fake_large_size_test.gif"; // 50000x50000 static const std::string IMAGE_JPG_LARGE_SIZE_PATH = "/data/local/tmp/image/fake_large_size_test.jpg"; // 30000x30000 +static const std::string IMAGE_HEIC_ISO_HDR_VIVID_SINGLE_PATH = + "/data/local/tmp/image/iso_hdr_vivid_single.heic"; +static const std::string IMAGE_JPG_JPEG_UWA_SINGLE_BASE_COLOR_PATH = + "/data/local/tmp/image/jpeg_uwa_single_base_color.jpg"; +static const std::string IMAGE_JPG_JPEG_UWA_SINGLE_ALTERNATE_COLOR_PATH = + "/data/local/tmp/image/jpeg_uwa_single_alternate_color.jpg"; +static const std::string IMAGE_JPG_JPEG_UWA_MULTI_BASE_COLOR_PATH = + "/data/local/tmp/image/jpeg_uwa_multi_base_color.jpg"; +static const std::string IMAGE_JPG_JPEG_UWA_MULTI_ALTERNATE_COLOR_PATH = + "/data/local/tmp/image/jpeg_uwa_multi_alternate_color.jpg"; static const int32_t DECODE_DESIRED_WIDTH = 7500; static const int32_t DECODE_DESIRED_HEIGHT = 7500; static const int32_t DESIRED_REGION_WIDTH = 4096; @@ -3332,5 +3342,98 @@ HWTEST_F(ImageSourceTest, LargeImageTest005, TestSize.Level3) ASSERT_EQ(pixelMap->GetWidth(), DECODE_DESIRED_WIDTH); ASSERT_EQ(pixelMap->GetHeight(), DECODE_DESIRED_HEIGHT); } + +/** + * @tc.name: CheckHdrType001 + * @tc.desc: test the HdrType ImageHdrType::UNKNOWN + * @tc.type: FUNC + */ +HWTEST_F(ImageSourceTest, CheckHdrType001, TestSize.Level3) +{ + uint32_t errorCode = 0; + SourceOptions opts; + std::unique_ptr imageSource = ImageSource::CreateImageSource(IMAGE_INPUT_HEIF_PATH, opts, errorCode); + ImageHdrType hdrType; + hdrType = imageSource->CheckHdrType(); + ASSERT_EQ(hdrType, ImageHdrType::UNKNOWN); +} + +/** + * @tc.name: CheckHdrType002 + * @tc.desc: test the HdrType ImageHdrType::SDR + * @tc.type: FUNC + */ +HWTEST_F(ImageSourceTest, CheckHdrType002, TestSize.Level3) +{ + uint32_t errorCode = 0; + SourceOptions opts; + std::unique_ptr imageSource = ImageSource::CreateImageSource(IMAGE_INPUT_JPEG_PATH, opts, errorCode); + ImageHdrType hdrType; + hdrType = imageSource->CheckHdrType(); + ASSERT_EQ(hdrType, ImageHdrType::SDR); +} + +/** + * @tc.name: CheckHdrType003 + * @tc.desc: test the HdrType ImageHdrType::SDR + * @tc.type: FUNC + */ +HWTEST_F(ImageSourceTest, CheckHdrType003, TestSize.Level3) +{ + uint32_t errorCode = 0; + SourceOptions opts; + std::unique_ptr imageSource = ImageSource::CreateImageSource(IMAGE_INPUT_EXIF_JPEG_PATH, opts, errorCode); + ImageHdrType hdrType; + hdrType = imageSource->CheckHdrType(); + ASSERT_EQ(hdrType, ImageHdrType::SDR); +} + +/** + * @tc.name: CheckHdrType005 + * @tc.desc: test the HdrType ImageHdrType::HDR_CUVA + * @tc.type: FUNC + */ +HWTEST_F(ImageSourceTest, CheckHdrType005, TestSize.Level3) +{ + uint32_t errorCode = 0; + SourceOptions opts; + std::unique_ptr imageSource = ImageSource::CreateImageSource(IMAGE_INPUT_JPEG_HDR_PATH, opts, errorCode); + ImageHdrType hdrType; + hdrType = imageSource->CheckHdrType(); + ASSERT_EQ(hdrType, ImageHdrType::HDR_CUVA); +} + + +/** + * @tc.name: CheckHdrType007 + * @tc.desc: test the HdrType ImageHdrType::HDR_VIVID_DUAL + * @tc.type: FUNC + */ +HWTEST_F(ImageSourceTest, CheckHdrType007, TestSize.Level3) +{ + uint32_t errorCode = 0; + SourceOptions opts; + std::unique_ptr imageSource = + ImageSource::CreateImageSource(IMAGE_JPG_THREE_GAINMAP_HDR_PATH, opts, errorCode); + ImageHdrType hdrType; + hdrType = imageSource->CheckHdrType(); + ASSERT_EQ(hdrType, ImageHdrType::HDR_VIVID_DUAL); +} + +/** + * @tc.name: CheckHdrType008 + * @tc.desc: test the HdrType ImageHdrType::HDR_VIVID_DUAL + * @tc.type: FUNC + */ +HWTEST_F(ImageSourceTest, CheckHdrType008, TestSize.Level3) +{ + uint32_t errorCode = 0; + SourceOptions opts; + std::unique_ptr imageSource = + ImageSource::CreateImageSource(IMAGE_HEIC_THREE_GAINMAP_HDR_PATH, opts, errorCode); + ImageHdrType hdrType; + hdrType = imageSource->CheckHdrType(); + ASSERT_EQ(hdrType, ImageHdrType::HDR_VIVID_DUAL); +} } // namespace Multimedia } // namespace OHOS \ No newline at end of file diff --git a/interfaces/innerkits/include/image_source.h b/interfaces/innerkits/include/image_source.h index 9052f7052..7262a5333 100644 --- a/interfaces/innerkits/include/image_source.h +++ b/interfaces/innerkits/include/image_source.h @@ -25,6 +25,7 @@ #include #include "decode_listener.h" +#include "hdr_type.h" #include "image_type.h" #include "incremental_pixel_map.h" #include "peer_listener.h" @@ -261,6 +262,7 @@ public: NATIVEEXPORT uint64_t GetImageId(); NATIVEEXPORT bool IsSvgUseDma(const DecodeOptions &opts); NATIVEEXPORT bool IsSupportAllocatorType(DecodeOptions& decOps, int32_t allocatorType); + ImageHdrType CheckHdrType(); private: DISALLOW_COPY_AND_MOVE(ImageSource); @@ -427,6 +429,7 @@ private: std::optional isAstc_; uint64_t imageId_; // generated from the last six bits of the current timestamp ImageHdrType sourceHdrType_; // source image hdr type; + ImageHdrType checkHdrType_ = ImageHdrType::UNKNOWN; std::shared_ptr exifMetadata_ = nullptr; std::string source_; // Image source fd buffer etc bool isExifReadFailed_ = false; -- Gitee From 7d13b6943db497f22e136648363116278848a60f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B1=B6=E8=B0=8F?= Date: Sat, 13 Sep 2025 08:33:39 +0000 Subject: [PATCH 2/3] fix codecheck MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 刘汶谏 --- .../test/unittest/image_source_test/image_source_test.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_test.cpp b/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_test.cpp index ce9ea2a6d..26cf43809 100644 --- a/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_test.cpp +++ b/frameworks/innerkitsimpl/test/unittest/image_source_test/image_source_test.cpp @@ -3382,7 +3382,8 @@ HWTEST_F(ImageSourceTest, CheckHdrType003, TestSize.Level3) { uint32_t errorCode = 0; SourceOptions opts; - std::unique_ptr imageSource = ImageSource::CreateImageSource(IMAGE_INPUT_EXIF_JPEG_PATH, opts, errorCode); + std::unique_ptr imageSource = + ImageSource::CreateImageSource(IMAGE_INPUT_EXIF_JPEG_PATH, opts, errorCode); ImageHdrType hdrType; hdrType = imageSource->CheckHdrType(); ASSERT_EQ(hdrType, ImageHdrType::SDR); @@ -3397,7 +3398,8 @@ HWTEST_F(ImageSourceTest, CheckHdrType005, TestSize.Level3) { uint32_t errorCode = 0; SourceOptions opts; - std::unique_ptr imageSource = ImageSource::CreateImageSource(IMAGE_INPUT_JPEG_HDR_PATH, opts, errorCode); + std::unique_ptr imageSource = + ImageSource::CreateImageSource(IMAGE_INPUT_JPEG_HDR_PATH, opts, errorCode); ImageHdrType hdrType; hdrType = imageSource->CheckHdrType(); ASSERT_EQ(hdrType, ImageHdrType::HDR_CUVA); -- Gitee From 6b2a3cab3af0afcbd31a4cf5c3d48fe019e16a6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B1=B6=E8=B0=8F?= Date: Sat, 13 Sep 2025 08:53:40 +0000 Subject: [PATCH 3/3] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=A4=96=E9=83=A8?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=E6=89=BE=E4=B8=8D=E5=88=B0=E5=A4=B4=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 刘汶谏 --- frameworks/innerkitsimpl/codec/src/image_source.cpp | 4 +++- interfaces/innerkits/include/image_source.h | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/frameworks/innerkitsimpl/codec/src/image_source.cpp b/frameworks/innerkitsimpl/codec/src/image_source.cpp index a5a5f8c55..815bddc27 100644 --- a/frameworks/innerkitsimpl/codec/src/image_source.cpp +++ b/frameworks/innerkitsimpl/codec/src/image_source.cpp @@ -84,6 +84,7 @@ #include "include/core/SkData.h" #endif #include "string_ex.h" +#include "hdr_type.h" #include "image_mime_type.h" #ifdef IMAGE_QOS_ENABLE #include "qos.h" @@ -5389,7 +5390,7 @@ ImageHdrType ImageSource::CheckHdrType() { IMAGE_LOGD("start CheckHdrType()"); - if (checkHdrType_ != ImageHdrType::UNKNOWN) { + if (checkHdrTypeHasSet) { IMAGE_LOGD("already have checkHdrType_: %{public}d", checkHdrType_); return checkHdrType_; } @@ -5405,6 +5406,7 @@ ImageHdrType ImageSource::CheckHdrType() checkHdrType_ = ImageHdrType::UNKNOWN; IMAGE_LOGD("fail checkHdrType_: %{public}d", checkHdrType_); } + checkHdrTypeHasSet = true; return checkHdrType_; } } // namespace Media diff --git a/interfaces/innerkits/include/image_source.h b/interfaces/innerkits/include/image_source.h index 7262a5333..c08b2c640 100644 --- a/interfaces/innerkits/include/image_source.h +++ b/interfaces/innerkits/include/image_source.h @@ -25,7 +25,6 @@ #include #include "decode_listener.h" -#include "hdr_type.h" #include "image_type.h" #include "incremental_pixel_map.h" #include "peer_listener.h" @@ -429,7 +428,8 @@ private: std::optional isAstc_; uint64_t imageId_; // generated from the last six bits of the current timestamp ImageHdrType sourceHdrType_; // source image hdr type; - ImageHdrType checkHdrType_ = ImageHdrType::UNKNOWN; + ImageHdrType checkHdrType_; + bool checkHdrTypeHasSet = false; std::shared_ptr exifMetadata_ = nullptr; std::string source_; // Image source fd buffer etc bool isExifReadFailed_ = false; -- Gitee