X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=images%2Fdup-cmp.c;h=c0232a4d4813c7d5e8b95447eb166811fdc3442c;hb=eec6d2c37cbcbf9c350aa4ca80e5a316e5144087;hp=39dc595948bfe19440cf7d4b870df2c262a735fe;hpb=f1e59f17c216849d1988d874e7fd945c2cd68e5a;p=libucw.git diff --git a/images/dup-cmp.c b/images/dup-cmp.c index 39dc5959..c0232a4d 100644 --- a/images/dup-cmp.c +++ b/images/dup-cmp.c @@ -9,11 +9,11 @@ #undef LOCAL_DEBUG -#include "lib/lib.h" -#include "lib/mempool.h" -#include "lib/fastbuf.h" -#include "images/images.h" -#include "images/duplicates.h" +#include +#include +#include +#include +#include #include @@ -104,6 +104,7 @@ blocks_compare(struct image_dup_context *ctx, struct image_dup *dup1, struct ima case 0: ; uns err = (err_sum(block1, block2, 1 << (tab_col + tab_row)) >> (tab_col + tab_row)); DBG("average error=%d", err); + ctx->error = err; return err <= ctx->error_threshold; case 1: col_step = -3; @@ -144,6 +145,7 @@ blocks_compare(struct image_dup_context *ctx, struct image_dup *dup1, struct ima } uns err = (err_sum_transformed(block1, block2, (1 << tab_col), (1 << tab_row), (3 << tab_col), col_step, row_step) >> (tab_col + tab_row)); DBG("average error=%d", err); + ctx->error = err; return err <= ctx->error_threshold; } @@ -152,6 +154,8 @@ same_size_compare(struct image_dup_context *ctx, struct image_dup *dup1, struct { struct image *img1 = &dup1->image; struct image *img2 = &dup2->image; + if (!img1->pixels || !img2->pixels) + return 1; ctx->sum_pixels += img1->cols * img1->rows; byte *block1 = img1->pixels; byte *block2 = img2->pixels; @@ -202,13 +206,14 @@ same_size_compare(struct image_dup_context *ctx, struct image_dup *dup1, struct } uns err = (err_sum_transformed(block1, block2, img1->cols, img1->rows, img1->row_size, col_step, row_step) / ((u64)img1->cols * img1->rows)); DBG("average error=%d", err); + ctx->error = err; return err <= ctx->error_threshold; } uns image_dup_compare(struct image_dup_context *ctx, struct image_dup *dup1, struct image_dup *dup2) { - DBG("image_dup_compare()"); + DBG("image_dup_compare(%p, %p)", dup1, dup2); if (!average_compare(ctx, dup1, dup2)) return 0; struct image *img1 = &dup1->image;