diff --git a/frameworks/innerkitsimpl/converter/src/post_proc.cpp b/frameworks/innerkitsimpl/converter/src/post_proc.cpp index f0202327b7ecc9250e914c5bd35efbe4d24edfe9..412b7904cdbf882e5b9fbdcd76bf0d2d37c22ade 100644 --- a/frameworks/innerkitsimpl/converter/src/post_proc.cpp +++ b/frameworks/innerkitsimpl/converter/src/post_proc.cpp @@ -1196,7 +1196,8 @@ bool PostProc::ScalePixelMapEx(const Size &desiredSize, PixelMap &pixelMap, cons desiredSize.width * ImageUtils::GetPixelBytes(imgInfo.pixelFormat); void *inBuf = nullptr; - if (srcWidth % HALF != 0 && pixelMap.GetAllocatorType() == AllocatorType::SHARE_MEM_ALLOC) { + if (srcWidth % HALF != 0 && + (pixelMap.GetAllocatorType() == AllocatorType::SHARE_MEM_ALLOC || pixelMap.GetNoPaddingUsage())) { // Workaround for crash on odd number width, caused by FFmpeg 5.0 upgrade uint64_t byteCount = static_cast(srcRowStride[0]) * static_cast(srcHeight); uint64_t allocSize = static_cast(srcWidth + 1) * static_cast(srcHeight) * diff --git a/frameworks/innerkitsimpl/test/unittest/post_proc_test.cpp b/frameworks/innerkitsimpl/test/unittest/post_proc_test.cpp index 3a3a53fe3d3ea1a3cd9cfaaaac64cc5733e827f7..0414c5d7508920420814f5f958b3fbcadd24b87e 100644 --- a/frameworks/innerkitsimpl/test/unittest/post_proc_test.cpp +++ b/frameworks/innerkitsimpl/test/unittest/post_proc_test.cpp @@ -1052,6 +1052,56 @@ HWTEST_F(PostProcTest, ScalePixelMapExTest001, TestSize.Level3) GTEST_LOG_(INFO) << "PostProcTest: ScalePixelMapExTest001 end"; } +/** + * @tc.name: ScalePixelMapExOddWidthTest001 + * @tc.desc: Test ScalePixelMapEx with odd number PixelMap width + * @tc.type: FUNC + */ +HWTEST_F(PostProcTest, ScalePixelMapExOddWidthTest001, TestSize.Level3) +{ + GTEST_LOG_(INFO) << "PostProcTest: ScalePixelMapExOddWidthTest001 start"; + + InitializationOptions opts; + opts.size = {1, 1}; + opts.allocatorType = AllocatorType::SHARE_MEM_ALLOC; + std::unique_ptr pixelMap = PixelMap::Create(opts); + if (!pixelMap) { + return; + } + PostProc postProc; + Size desiredSize = {10, 10}; + bool ret = postProc.ScalePixelMapEx(desiredSize, *(pixelMap.get())); + ASSERT_EQ(ret, true); + + GTEST_LOG_(INFO) << "PostProcTest: ScalePixelMapExOddWidthTest001 end"; +} + +/** + * @tc.name: ScalePixelMapExOddWidthTest002 + * @tc.desc: Test ScalePixelMapEx with odd number PixelMap width + * @tc.type: FUNC + */ +HWTEST_F(PostProcTest, ScalePixelMapExOddWidthTest002, TestSize.Level3) +{ + GTEST_LOG_(INFO) << "PostProcTest: ScalePixelMapExOddWidthTest002 start"; + + InitializationOptions opts; + opts.size = {513, 512}; + opts.pixelFormat = PixelFormat::RGBA_8888; + opts.allocatorType = AllocatorType::SHARE_MEM_ALLOC; + opts.useDMA = true; + std::unique_ptr pixelMap = PixelMap::Create(opts); + if (!pixelMap) { + return; + } + PostProc postProc; + Size desiredSize = {11, 10}; + bool ret = postProc.ScalePixelMapEx(desiredSize, *(pixelMap.get())); + ASSERT_EQ(ret, true); + + GTEST_LOG_(INFO) << "PostProcTest: ScalePixelMapExOddWidthTest002 end"; +} + /** * @tc.name: DecodePostProc001 * @tc.desc: Vertify that DecodePostProc when cropAndScaleStrategy is scale first.