From fbbdce0bab55b8232f202a7bfa4880e2d10258f8 Mon Sep 17 00:00:00 2001 From: Denes Tarjan Date: Fri, 5 Apr 2024 09:33:35 +0200 Subject: [PATCH 1/4] [NFC] Remove superfluous condition which is never fullfilled --- intrinsiccv/include/intrinsiccv/workspace/separable.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/intrinsiccv/include/intrinsiccv/workspace/separable.h b/intrinsiccv/include/intrinsiccv/workspace/separable.h index 5398f1db4..4013cbf5b 100644 --- a/intrinsiccv/include/intrinsiccv/workspace/separable.h +++ b/intrinsiccv/include/intrinsiccv/workspace/separable.h @@ -127,10 +127,6 @@ class SeparableFilterWorkspace final { Rows dst_rows, size_t channels, typename FilterType::BorderType border_type, FilterType filter) INTRINSICCV_STREAMING_COMPATIBLE { - if (INTRINSICCV_UNLIKELY(rect.width() == 0 || rect.height() == 0)) { - return; - } - // Border helper which calculates border offsets. typename FilterType::BorderInfoType vertical_border{rect.height(), border_type}; -- GitLab From 3707d114c9b6ea53389546474b8a8736f12ce722 Mon Sep 17 00:00:00 2001 From: Denes Tarjan Date: Fri, 5 Apr 2024 14:16:49 +0200 Subject: [PATCH 2/4] [test] Add allocation test for sobel_3x3_vertical --- test/api/test_sobel.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/api/test_sobel.cpp b/test/api/test_sobel.cpp index ce08c4bfa..62b22171d 100644 --- a/test/api/test_sobel.cpp +++ b/test/api/test_sobel.cpp @@ -237,6 +237,12 @@ TYPED_TEST(Sobel, CannotAllocateImageHorizontal) { sobel_3x3_horizontal()( src, sizeof(src), dst, sizeof(dst), INTRINSICCV_MAX_IMAGE_PIXELS / 2, validSize, INTRINSICCV_MAXIMUM_CHANNEL_COUNT)); + + EXPECT_EQ(INTRINSICCV_ERROR_ALLOCATION, + sobel_3x3_vertical()(src, sizeof(src), dst, sizeof(dst), + INTRINSICCV_MAX_IMAGE_PIXELS / 2, + validSize, + INTRINSICCV_MAXIMUM_CHANNEL_COUNT)); MockMallocToFail::disable(); } #endif -- GitLab From 1f5cedcdbf03b7a335e2a65e2bdcd3ac72c1620a Mon Sep 17 00:00:00 2001 From: Denes Tarjan Date: Fri, 5 Apr 2024 14:24:26 +0200 Subject: [PATCH 3/4] [test] Add more NotImplemented testcases to test_resize_linear --- test/api/test_resize_linear.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/api/test_resize_linear.cpp b/test/api/test_resize_linear.cpp index a011a259b..86902d00d 100644 --- a/test/api/test_resize_linear.cpp +++ b/test/api/test_resize_linear.cpp @@ -20,6 +20,10 @@ TEST(ResizeLinear, NotImplemented) { intrinsiccv_resize_linear_u8(src, 1, 1, 1, dst, 2, 2, 1)); EXPECT_EQ(INTRINSICCV_ERROR_NOT_IMPLEMENTED, intrinsiccv_resize_linear_u8(src, 1, 1, 1, dst, 1, 1, 2)); + EXPECT_EQ(INTRINSICCV_ERROR_NOT_IMPLEMENTED, + intrinsiccv_resize_linear_u8(src, 1, 1, 1, dst, 4, 4, 2)); + EXPECT_EQ(INTRINSICCV_ERROR_NOT_IMPLEMENTED, + intrinsiccv_resize_linear_u8(src, 1, 1, 1, dst, 2, 2, 4)); } TEST(ResizeLinear, NullPointer) { -- GitLab From c8cf5004198e742eadeec4f8803b36ac14c8621f Mon Sep 17 00:00:00 2001 From: Denes Tarjan Date: Fri, 5 Apr 2024 18:50:48 +0200 Subject: [PATCH 4/4] [NFC] Eliminate an unneeded function call from resize_neon --- intrinsiccv/src/resize/resize_neon.cpp | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/intrinsiccv/src/resize/resize_neon.cpp b/intrinsiccv/src/resize/resize_neon.cpp index 55c5e7317..1e18a37fe 100644 --- a/intrinsiccv/src/resize/resize_neon.cpp +++ b/intrinsiccv/src/resize/resize_neon.cpp @@ -25,10 +25,14 @@ static intrinsiccv_error_t check_dimensions(size_t src_dim, size_t dst_dim) { return INTRINSICCV_ERROR_RANGE; } +// Disable the warning, as the complexity is just above the threshold, it's +// better to leave it in one piece. +// NOLINTBEGIN(readability-function-cognitive-complexity) INTRINSICCV_TARGET_FN_ATTRS -static intrinsiccv_error_t check_resize_args( - const uint8_t *src, size_t src_stride, size_t src_width, size_t src_height, - uint8_t *dst, size_t dst_stride, size_t dst_width, size_t dst_height) { +intrinsiccv_error_t resize_to_quarter_u8(const uint8_t *src, size_t src_stride, + size_t src_width, size_t src_height, + uint8_t *dst, size_t dst_stride, + size_t dst_width, size_t dst_height) { CHECK_POINTER_AND_STRIDE(src, src_stride); CHECK_POINTER_AND_STRIDE(dst, dst_stride); CHECK_IMAGE_SIZE(src_width, src_height); @@ -41,20 +45,6 @@ static intrinsiccv_error_t check_resize_args( return ret; } - return INTRINSICCV_OK; -} - -INTRINSICCV_TARGET_FN_ATTRS -intrinsiccv_error_t resize_to_quarter_u8(const uint8_t *src, size_t src_stride, - size_t src_width, size_t src_height, - uint8_t *dst, size_t dst_stride, - size_t dst_width, size_t dst_height) { - if (intrinsiccv_error_t ret = - check_resize_args(src, src_stride, src_width, src_height, dst, - dst_stride, dst_width, dst_height)) { - return ret; - } - for (; src_height >= 2; src_height -= 2, src += (src_stride * 2), --dst_height, dst += dst_stride) { const uint8_t *src_l = src; @@ -129,5 +119,6 @@ intrinsiccv_error_t resize_to_quarter_u8(const uint8_t *src, size_t src_stride, } return INTRINSICCV_OK; } +// NOLINTEND(readability-function-cognitive-complexity) } // namespace intrinsiccv::neon -- GitLab