37 #include "NE10_imgproc.h" 39 #include "unit_test_common.h" 45 #define SRC_HEIGHT 512 47 #define DST_HEIGHT 734 //sqrt(512*512 + 512*512) + 10 48 #define DST_WIDTH 734 //sqrt(512*512 + 512*512) + 10 49 #define TEST_COUNT 5000 58 static ne10_uint8_t * in_c = NULL;
59 static ne10_uint8_t * in_neon = NULL;
61 static ne10_uint8_t * out_c = NULL;
62 static ne10_uint8_t * out_neon = NULL;
64 #ifdef ENABLE_NE10_IMG_ROTATE_RGBA_NEON 65 void test_rotate_conformance_case()
68 ne10_int32_t channels = 4;
69 ne10_int32_t in_size = SRC_HEIGHT * SRC_WIDTH * channels;
70 ne10_int32_t out_size = DST_HEIGHT * DST_WIDTH * channels;
71 ne10_float32_t PSNR = 0.0f;
72 ne10_int32_t srcw = SRC_WIDTH;
73 ne10_int32_t srch = SRC_HEIGHT;
74 ne10_uint32_t dstw_c, dsth_c;
75 ne10_uint32_t dstw_neon, dsth_neon;
79 in_c = NE10_MALLOC (in_size *
sizeof (ne10_uint8_t));
80 in_neon = NE10_MALLOC (in_size *
sizeof (ne10_uint8_t));
83 out_c = NE10_MALLOC (out_size *
sizeof (ne10_uint8_t));
84 out_neon = NE10_MALLOC (out_size *
sizeof (ne10_uint8_t));
86 for (i = 0; i < in_size; i++)
88 in_c[i] = in_neon[i] = (rand() & 0xff);
91 for (angle = -360; angle <= 360; angle += 30)
93 printf (
"rotate angle %d \n", angle);
95 memset (out_c, 0, out_size);
98 memset (out_neon, 0, out_size);
99 ne10_img_rotate_rgba_neon (out_neon, &dstw_neon, &dsth_neon, in_neon, srcw, srch, angle);
101 PSNR = CAL_PSNR_UINT8 (out_c, out_neon, dstw_c * dsth_c * 4);
102 assert_false ( (PSNR < PSNR_THRESHOLD));
108 NE10_FREE (out_neon);
110 #endif // ENABLE_NE10_IMG_ROTATE_RGBA_NEON 112 void test_rotate_performance_case()
115 ne10_int32_t channels = 4;
116 ne10_int32_t in_size = SRC_HEIGHT * SRC_WIDTH * channels;
117 ne10_int32_t out_size = DST_HEIGHT * DST_WIDTH * channels;
118 ne10_int32_t srcw = SRC_WIDTH;
119 ne10_int32_t srch = SRC_HEIGHT;
120 ne10_uint32_t dstw_c, dsth_c;
121 ne10_uint32_t dstw_neon, dsth_neon;
123 ne10_int64_t time_c = 0;
124 ne10_int64_t time_neon = 0;
127 in_c = NE10_MALLOC (in_size *
sizeof (ne10_uint8_t));
128 in_neon = NE10_MALLOC (in_size *
sizeof (ne10_uint8_t));
131 out_c = NE10_MALLOC (out_size *
sizeof (ne10_uint8_t));
132 out_neon = NE10_MALLOC (out_size *
sizeof (ne10_uint8_t));
134 for (i = 0; i < in_size; i++)
136 in_c[i] = in_neon[i] = (rand() & 0xff);
140 for (angle = 45; angle <= 45; angle += 5)
142 printf (
"rotate angle %d \n", angle);
144 memset (out_c, 0, out_size);
149 for (i = 0; i < TEST_COUNT; i++)
154 #ifdef ENABLE_NE10_IMG_ROTATE_RGBA_NEON 155 memset (out_neon, 0, out_size);
160 for (i = 0; i < TEST_COUNT; i++)
161 ne10_img_rotate_rgba_neon (out_neon, &dstw_neon, &dsth_neon, in_neon, srcw, srch, angle);
164 #endif // ENABLE_NE10_IMG_ROTATE_RGBA_NEON 168 ne10_log (__FUNCTION__,
"IMAGEROTATE%20d%20lld%20lld%19.2f%%%18.2f:1\n", angle, time_c, time_neon, 0, 0);
174 NE10_FREE (out_neon);
179 #ifdef ENABLE_NE10_IMG_ROTATE_RGBA_NEON 180 #if defined (SMOKE_TEST)||(REGRESSION_TEST) 181 test_rotate_conformance_case();
183 #endif // ENABLE_NE10_IMG_ROTATE_RGBA_NEON 185 #if defined PERFORMANCE_TEST 186 test_rotate_performance_case();
190 static void my_test_setup (
void)
192 ne10_log_buffer_ptr = ne10_log_buffer;
195 void test_fixture_rotate (
void)
197 test_fixture_start();
199 fixture_setup (my_test_setup);
201 run_test (test_rotate);
void ne10_img_rotate_rgba_c(ne10_uint8_t *dst, ne10_uint32_t *dst_width, ne10_uint32_t *dst_height, ne10_uint8_t *src, ne10_uint32_t src_width, ne10_uint32_t src_height, ne10_int32_t angle)
image resize of 8-bit data.