From 25671ca219fa0cabf13cc5858e7e69161d5c3aa9 Mon Sep 17 00:00:00 2001 From: Andrei Gorbachev Date: Tue, 20 Dec 2022 17:02:46 +0000 Subject: [PATCH] [GPU] Fix convert color I420 (#14679) --- .../src/kernel_selector/cl_kernels/convert_color_ref.cl | 6 +++++- .../plugin/gpu/shared_tests_instances/skip_tests_config.cpp | 1 - .../shared_test_classes/single_layer/convert_color_i420.hpp | 4 ++-- .../shared_test_classes/single_layer/convert_color_nv12.hpp | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/convert_color_ref.cl b/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/convert_color_ref.cl index 76de00ee7c9..1b595f81859 100644 --- a/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/convert_color_ref.cl +++ b/src/plugins/intel_gpu/src/kernel_selector/cl_kernels/convert_color_ref.cl @@ -30,9 +30,13 @@ KERNEL(convert_color_ref)(const __global INPUT0_TYPE* input1, float V = input2[GET_DATA_INDEX(INPUT1, b, 1, y / 2, x / 2)]; #else // Single plane uint input_uv_offset = INPUT0_SIZE_X * INPUT0_SIZE_Y / 3 * 2; - +#ifdef CONVERT_FROM_NV12 float U = input1[GET_DATA_INDEX(INPUT0, b, 0, y / 2, (x / 2) * 2) + input_uv_offset]; float V = input1[GET_DATA_INDEX(INPUT0, b, 1, y / 2, (x / 2) * 2) + input_uv_offset]; +#else + float U = input1[GET_DATA_INDEX(INPUT0, b, 0, 0, x / 2 + (y / 2)*(INPUT0_Y_PITCH / 2)) + input_uv_offset]; + float V = input1[GET_DATA_INDEX(INPUT0, b, 0, 0, x / 2 + (y / 2)*(INPUT0_Y_PITCH / 2)) + 5 * input_uv_offset / 4]; +#endif #endif float Ycomponent = mad(Y, 1.164f, -18.624f); diff --git a/src/tests/functional/plugin/gpu/shared_tests_instances/skip_tests_config.cpp b/src/tests/functional/plugin/gpu/shared_tests_instances/skip_tests_config.cpp index 578c007e191..02a4f39b992 100644 --- a/src/tests/functional/plugin/gpu/shared_tests_instances/skip_tests_config.cpp +++ b/src/tests/functional/plugin/gpu/shared_tests_instances/skip_tests_config.cpp @@ -125,6 +125,5 @@ std::vector disabledTestPatterns() { R"(.*smoke_GroupConvolution1D_ExplicitPadding_Disabled.*)", R"(.*smoke_GroupConvolutionLayerGPUTest_dynamic1DSymPad_Disabled.*)", R"(.*smoke_ConvolutionLayerGPUTest_dynamic1DSymPad.*)", - R"(.*TestsConvertColorI420.*)", }; } diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/convert_color_i420.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/convert_color_i420.hpp index e641d0a7e66..95495b28d04 100644 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/convert_color_i420.hpp +++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/convert_color_i420.hpp @@ -72,8 +72,8 @@ inline std::vector color_test_image(size_t height, size_t width, int b_ int u_val = ((-38 * r - 74 * g + 112 * b + 128) / 256) + 128; int v_val = ((112 * r - 94 * g + 18 * b + 128) / 256) + 128; - size_t b_offset = height * width * b / b_step; - size_t u_index = b_offset + height * width + y * width / 2 + x * 2; + size_t b_offset = height * width * b / b_step * 3 / 2; + size_t u_index = b_offset + height * width + y * width / 2 + x; size_t v_index = u_index + height * width / 4; input_yuv[u_index] = u_val; input_yuv[v_index] = v_val; diff --git a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/convert_color_nv12.hpp b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/convert_color_nv12.hpp index 5bd771fbe9a..c0dfb7702f2 100644 --- a/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/convert_color_nv12.hpp +++ b/src/tests/functional/shared_test_classes/include/shared_test_classes/single_layer/convert_color_nv12.hpp @@ -72,7 +72,7 @@ inline std::vector color_test_image(size_t height, size_t width, int b_ int u_val = ((-38 * r - 74 * g + 112 * b + 128) / 256) + 128; int v_val = ((112 * r - 94 * g + 18 * b + 128) / 256) + 128; - size_t b_offset = height * width * b / b_step; + size_t b_offset = height * width * b / b_step * 3 / 2; size_t uv_index = b_offset + height * width + y * width + x * 2; input_yuv[uv_index] = u_val; input_yuv[uv_index + 1] = v_val;