From f42d0e5dc9ebe5ff3a76c176b79136d1f7657703 Mon Sep 17 00:00:00 2001 From: DaydreamCoding Date: Sun, 4 Jul 2021 07:13:30 +0800 Subject: [PATCH] fix warpaffine_bilinear_yuv420sp uv matrix (#3048) --- src/mat_pixel_affine.cpp | 11 ++++++++++- tests/test_mat_pixel_affine.cpp | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/mat_pixel_affine.cpp b/src/mat_pixel_affine.cpp index 43afa8c66..750475910 100644 --- a/src/mat_pixel_affine.cpp +++ b/src/mat_pixel_affine.cpp @@ -1600,9 +1600,18 @@ void warpaffine_bilinear_yuv420sp(const unsigned char* src, int srcw, int srch, unsigned char* dstY = dst; warpaffine_bilinear_c1(srcY, srcw, srch, dstY, w, h, tm, type, v_y); + const float tm_uv[6] = { + tm[0], + tm[1], + tm[2] / 2.0f, + tm[3], + tm[4], + tm[5] / 2.0f, + }; + const unsigned char* srcUV = src + srcw * srch; unsigned char* dstUV = dst + w * h; - warpaffine_bilinear_c2(srcUV, srcw / 2, srch / 2, dstUV, w / 2, h / 2, tm, type, v_uv); + warpaffine_bilinear_c2(srcUV, srcw / 2, srch / 2, dstUV, w / 2, h / 2, tm_uv, type, v_uv); } #endif // NCNN_PIXEL_AFFINE diff --git a/tests/test_mat_pixel_affine.cpp b/tests/test_mat_pixel_affine.cpp index 2b01d742f..2158a9c28 100644 --- a/tests/test_mat_pixel_affine.cpp +++ b/tests/test_mat_pixel_affine.cpp @@ -494,7 +494,7 @@ static int test_mat_pixel_affine_yuv420sp(int w, int h) static int test_mat_pixel_affine_1() { return 0 - || test_mat_pixel_affine_yuv420sp(60, 40) + || test_mat_pixel_affine_yuv420sp(40, 40) || test_mat_pixel_affine_yuv420sp(120, 160) || test_mat_pixel_affine_yuv420sp(220, 340); }