From 4c961da2ab65d744a8b2d7788b4d706aa8b42741 Mon Sep 17 00:00:00 2001 From: jiejex Date: Tue, 9 Sep 2025 11:24:45 +0800 Subject: [PATCH] calgainmap by hdr and sdr UT test Signed-off-by: jiejex --- .../image_source_test/image_source_test.cpp | 29 ++++++++++++++- .../test/unittest/picture_ext_test.cpp | 35 ++++++++++++++++++- 2 files changed, 62 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 a9501a3bd..29c4828b7 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 @@ -56,6 +56,7 @@ static const std::string IMAGE_INPUT_JPEG_BROKEN_TWO = "/data/local/tmp/image/te static const std::string IMAGE_URL_PREFIX = "data:image/"; static const std::string IMAGE_INPUT_JPG_PATH_EXACTSIZE = "/data/local/tmp/image/800-500.jpg"; static const std::string IMAGE_JPG_THREE_GAINMAP_HDR_PATH = "/data/local/tmp/image/three_gainmap_hdr.jpg"; +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 int32_t DECODE_DESIRED_WIDTH = 7500; @@ -3127,7 +3128,7 @@ HWTEST_F(ImageSourceTest, DecodeHeifAuxiliaryPicturesTest002, TestSize.Level1) } /** - * @tc.name: WideGamutTest003 + * @tc.name: WideGamutTest001 * @tc.desc: test WideGamut one channel gainmap Jpeg HDR input * @tc.type: FUNC */ @@ -3178,6 +3179,32 @@ HWTEST_F(ImageSourceTest, WideGamutTest002, TestSize.Level3) ASSERT_EQ(pixelFormat, Media::PixelFormat::RGBA_1010102); } +/** + * @tc.name: WideGamutTest003 + * @tc.desc: test WideGamut one channel gainmap Jpeg HDR input + * @tc.type: FUNC + */ +HWTEST_F(ImageSourceTest, WideGamutTest003, TestSize.Level3) +{ + uint32_t errorCode = 0; + SourceOptions opts; + opts.formatHint = "image/heif"; + std::unique_ptr imageSource = ImageSource::CreateImageSource(IMAGE_HEIC_THREE_GAINMAP_HDR_PATH, + opts, errorCode); + ASSERT_EQ(errorCode, SUCCESS); + ASSERT_NE(imageSource.get(), nullptr); + uint32_t index = 0; + DecodeOptions decodeOpts; + decodeOpts.isCreateWideGamutSdrPixelMap = true; + decodeOpts.desiredDynamicRange = Media::DecodeDynamicRange::AUTO; + std::unique_ptr pixelMap = imageSource->CreatePixelMap(index, decodeOpts, errorCode); + ASSERT_EQ(errorCode, SUCCESS); + bool isHdr = pixelMap->IsHdr(); + ASSERT_EQ(isHdr, false); + Media::PixelFormat pixelFormat = pixelMap->GetPixelFormat(); + ASSERT_EQ(pixelFormat, Media::PixelFormat::RGBA_1010102); +} + /** * @tc.name: LargeImageTest001 * @tc.desc: test decode supported large image(JPEG), using default decode options, expect decode fail diff --git a/frameworks/innerkitsimpl/test/unittest/picture_ext_test.cpp b/frameworks/innerkitsimpl/test/unittest/picture_ext_test.cpp index ed663a69d..94adc3bfc 100644 --- a/frameworks/innerkitsimpl/test/unittest/picture_ext_test.cpp +++ b/frameworks/innerkitsimpl/test/unittest/picture_ext_test.cpp @@ -1306,7 +1306,7 @@ HWTEST_F(PictureExtTest, AuxPictureUnmarshallingTest001, TestSize.Level3) /** * @tc.name: CalGainmapTest001 - * @tc.desc: CalGainmap with hdr image and sdr image + * @tc.desc: jpeg decode to pixelmap and CalGainmap with hdr image and sdr image * @tc.type: FUNC */ HWTEST_F(PictureExtTest, CalGainmapTest001, TestSize.Level1) @@ -1337,6 +1337,39 @@ HWTEST_F(PictureExtTest, CalGainmapTest001, TestSize.Level1) #endif } +/** + * @tc.name: CalGainmapTest002 + * @tc.desc: heic decode to pixelmap and CalGainmap with hdr image and sdr image + * @tc.type: FUNC + */ +HWTEST_F(PictureExtTest, CalGainmapTest002, TestSize.Level1) +{ + uint32_t res = 0; + SourceOptions sourceOpts; + sourceOpts.formatHint = "image/heif"; + std::unique_ptr imageSource = ImageSource::CreateImageSource(IMAGE_HEIFHDR_SRC.c_str(), + sourceOpts, res); + ASSERT_NE(imageSource, nullptr); + DecodingOptionsForPicture opts; + opts.desireAuxiliaryPictures.insert(AuxiliaryPictureType::GAINMAP); + uint32_t error_code; + std::unique_ptr picture = imageSource->CreatePicture(opts, error_code); + ASSERT_NE(picture, nullptr); + std::unique_ptr pixelmap = picture->GetHdrComposedPixelMap(); + ASSERT_NE(pixelmap, nullptr); + EXPECT_TRUE(pixelmap->IsHdr()); + PixelFormat format= pixelmap->GetPixelFormat(); + EXPECT_EQ(format, PixelFormat::RGBA_1010102); + std::shared_ptr hdrPixelmap = std::move(pixelmap); + auto sdrPixelmap = picture->GetMainPixel(); + std::unique_ptr newPicture = picture->CreatePictureByHdrAndSdrPixelMap(hdrPixelmap, sdrPixelmap); +#ifdef IMAGE_VPE_FLAG + ASSERT_NE(newPicture, nullptr); +#else + ASSERT_EQ(newPicture, nullptr); +#endif +} + /** * @tc.name: HeifPocTest * @tc.desc: Test Heif Exception POC -- Gitee