]> mj.ucw.cz Git - libucw.git/blobdiff - images/sig-init.c
Opt: Documented opt and its interaction with conf
[libucw.git] / images / sig-init.c
index 1332db15b0d248997c5a18ded1ffa4281f12f75c..3c76920fb36fc79d103b3b202270847332eb6389 100644 (file)
@@ -9,19 +9,20 @@
 
 #undef LOCAL_DEBUG
 
-#include "sherlock/sherlock.h"
-#include "lib/fastbuf.h"
-#include "lib/conf.h"
-#include "lib/math.h"
-#include "images/math.h"
-#include "images/images.h"
-#include "images/color.h"
-#include "images/signature.h"
+#include <ucw/lib.h>
+#include <ucw/fastbuf.h>
+#include <ucw/conf.h>
+#include <images/images.h>
+#include <images/math.h>
+#include <images/error.h>
+#include <images/color.h>
+#include <images/signature.h>
 
 #include <alloca.h>
+#include <math.h>
 
 int
-image_sig_init(struct image_thread *thread, struct image_sig_data *data, struct image *image)
+image_sig_init(struct image_context *ctx, struct image_sig_data *data, struct image *image)
 {
   ASSERT((image->flags & IMAGE_PIXEL_FORMAT) == COLOR_SPACE_RGB);
   data->image = image;
@@ -33,7 +34,7 @@ image_sig_init(struct image_thread *thread, struct image_sig_data *data, struct
   data->blocks_count = data->cols * data->rows;
   if (data->blocks_count >= 0x10000)
     {
-      image_thread_err(thread, IMAGE_ERR_INVALID_DIMENSIONS, "Image too large for implemented signature algorithm.");
+      IMAGE_ERROR(ctx, IMAGE_ERROR_INVALID_DIMENSIONS, "Image too large for implemented signature algorithm.");
       return 0;
     }
   data->blocks = xmalloc(data->blocks_count * sizeof(struct image_sig_block));
@@ -103,14 +104,14 @@ image_sig_preprocess(struct image_sig_data *data)
                    }
                  for (; x < 4; x++)
                    {
-                     *tp = tp[-square_cols];
+                     *tp = tp[-(int)square_cols];
                      tp++;
                    }
                }
              for (; y < 4; y++)
                for (x = 0; x < 4; x++)
                  {
-                   *tp = tp[-square_rows * 4];
+                   *tp = tp[-(int)square_rows * 4];
                    tp++;
                  }
              block->area = square_cols * square_rows;
@@ -187,7 +188,7 @@ image_sig_finish(struct image_sig_data *data, struct image_signature *sig)
   sig->flags = data->flags;
   if (!sig->len)
     return;
-  
+
   /* For each region */
   u64 w_total = 0;
   uns w_border = MIN(data->cols, data->rows) * image_sig_border_size;
@@ -284,6 +285,10 @@ image_sig_finish(struct image_sig_data *data, struct image_signature *sig)
   sig->reg[0].wa = wa;
   sig->reg[0].wb = wb;
 
+  /* Store image dimensions */
+  sig->cols = data->image->cols;
+  sig->rows = data->image->rows;
+
   /* Dump regions features */
 #ifdef LOCAL_DEBUG
   for (uns i = 0; i < sig->len; i++)
@@ -302,10 +307,10 @@ image_sig_cleanup(struct image_sig_data *data)
 }
 
 int
-compute_image_signature(struct image_thread *thread, struct image_signature *sig, struct image *image)
+compute_image_signature(struct image_context *ctx, struct image_signature *sig, struct image *image)
 {
   struct image_sig_data data;
-  if (!image_sig_init(thread, &data, image))
+  if (!image_sig_init(ctx, &data, image))
     return 0;
   image_sig_preprocess(&data);
   if (data.valid)