- for (uns i = 0; i < IMAGE_VEC_K; i++)
- {
- uns v;
- if (sscanf(argv[i + 1], "%d", &v) != 1)
- die("Invalid numeric format");
- query.f[i] = v;
- }
-
-
- struct image_search is;
- oid_t best[BEST_CNT];
- uns dist[BEST_CNT];
- uns cardpos[BEST_CNT];
- uns best_n = 0;
-
- image_tree_init();
- log(L_INFO, "Executing query (%s)", stk_print_image_vector(&query));
- image_search_init(&is, &image_tree, &query, IMAGE_SEARCH_DIST_UNLIMITED);
- for (uns i = 0; i < BEST_CNT; i++)
+ pool = mp_new(1024);
+ image_context_init(&ctx);
+
+ /* Image allocation */
+ i1 = image_new(&ctx, 731, 327, COLOR_SPACE_RGB, NULL);
+ ASSERT(i1);
+ ASSERT(i1->pixel_size == 3);
+ image_destroy(i1);
+
+ /* Test invalid image size */
+ ctx.msg_callback = image_context_msg_silent;
+ i1 = image_new(&ctx, 2214, 0, COLOR_SPACE_RGB, NULL);
+ ASSERT(!i1);
+ i1 = image_new(&ctx, 0xffffff, 0xffffff, COLOR_SPACE_RGB, NULL);
+ ASSERT(!i1);
+ ctx.msg_callback = image_context_msg_default;
+
+ /* Various image allocatio parameters */
+ i1 = image_new(&ctx, 370, 100, COLOR_SPACE_GRAYSCALE, pool);
+ ASSERT(i1);
+ ASSERT(i1->pixel_size == 1);
+ image_destroy(i1);
+ mp_flush(pool);
+
+ i1 = image_new(&ctx, 373, 101, COLOR_SPACE_RGB | IMAGE_ALIGNED, NULL);
+ ASSERT(i1);
+ ASSERT(i1->pixel_size == 4);
+ ASSERT(IMAGE_SSE_ALIGN_SIZE >= 16);
+ ASSERT(!(i1->row_size & (IMAGE_SSE_ALIGN_SIZE - 1)));
+ ASSERT(!((uintptr_t)i1->pixels & (IMAGE_SSE_ALIGN_SIZE - 1)));
+ image_destroy(i1);
+
+ i1 = image_new(&ctx, 283, 329, COLOR_SPACE_RGB, NULL);
+ ASSERT(i1);
+ ASSERT(i1->pixel_size == 3);
+
+ /* Image structures cloning */
+ i2 = image_clone(&ctx, i1, COLOR_SPACE_RGB, NULL);
+ ASSERT(i2);
+ ASSERT(i2->pixel_size == 3);
+ image_destroy(i2);
+
+ i2 = image_clone(&ctx, i1, COLOR_SPACE_RGB | IMAGE_PIXELS_ALIGNED, NULL);
+ ASSERT(i2);
+ ASSERT(i2->pixel_size == 4);
+ image_destroy(i2);
+
+ /* Subimages */
+ i2 = image_init_subimage(&ctx, &s1, i1, 29, 39, 283 - 29, 100);
+ ASSERT(i2);
+ image_destroy(&s1);
+
+ image_destroy(i1);
+
+ image_context_cleanup(&ctx);
+ mp_delete(pool);
+}
+
+#ifdef CONFIG_UCW_THREADS
+
+#define TEST_THREADS_COUNT 4
+
+static void *
+test_threads_thread(void *param UNUSED)
+{
+ DBG("Starting thread");
+ struct image_context ctx;
+ struct image_io io;
+ image_context_init(&ctx);
+ TRY(image_io_init(&ctx, &io));
+
+ for (uns num = 0; num < 200; num++)