X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=images%2Fsig-seg.c;h=d3537840cf5a4aa295c7edd0cd52c8e96c6158f6;hb=924caf6f42990dc99c1d7e4a954da1533e37e537;hp=74798f47fe178f8eae98802cf032ddc98ea43b66;hpb=1aef93f0ed9d05fe4825ff635d49f37d89c2a70c;p=libucw.git diff --git a/images/sig-seg.c b/images/sig-seg.c index 74798f47..d3537840 100644 --- a/images/sig-seg.c +++ b/images/sig-seg.c @@ -9,12 +9,12 @@ #undef LOCAL_DEBUG -#include "lib/lib.h" -#include "lib/conf.h" -#include "lib/heap.h" -#include "images/images.h" -#include "images/signature.h" -#include "images/math.h" +#include +#include +#include +#include +#include +#include #include @@ -93,9 +93,7 @@ prequant_heap_cmp(struct image_sig_region *a, struct image_sig_region *b) #define ASORT_PREFIX(x) prequant_##x #define ASORT_KEY_TYPE uns -#define ASORT_ELT(i) val[i] -#define ASORT_EXTRA_ARGS , uns *val -#include "lib/arraysort.h" +#include static uns prequant(struct image_sig_block *blocks, uns blocks_count, struct image_sig_region *regions) @@ -124,7 +122,7 @@ prequant(struct image_sig_block *blocks, uns blocks_count, struct image_sig_regi if (region->count < 2 || region->e < image_sig_prequant_thresholds[regions_count - 1] * blocks_count) { - HEAP_DELMIN(struct image_sig_region *, heap, heap_count, prequant_heap_cmp, HEAP_SWAP); + HEAP_DELETE_MIN(struct image_sig_region *, heap, heap_count, prequant_heap_cmp, HEAP_SWAP); continue; } @@ -163,7 +161,7 @@ prequant(struct image_sig_block *blocks, uns blocks_count, struct image_sig_regi block = region->blocks; for (uns i = 0; i < region->count; i++, block = block->next) val[i] = block->v[axis]; - prequant_sort(region->count, val); + prequant_sort(val, region->count); cval = 1; cnt[0] = 1; for (uns i = 1; i < region->count; i++) @@ -176,7 +174,7 @@ prequant(struct image_sig_block *blocks, uns blocks_count, struct image_sig_regi cval++; } } - + /* Select split value - to minimize error */ uns b1 = val[0] * cnt[0]; uns c1 = isqr(val[0]) * cnt[0]; @@ -195,7 +193,7 @@ prequant(struct image_sig_block *blocks, uns blocks_count, struct image_sig_regi c2 -= c0; i += cnt[k]; j -= cnt[k]; - u64 err = (u64)c1 - (u64)b1 * b1 / i + (u64)c2 - (u64)b2 * b2 / j; + u64 err = (u64)c1 - (u64)b1 * b1 / i + (u64)c2 - (u64)b2 * b2 / j; if (err < best_err) { best_err = err; @@ -220,9 +218,8 @@ prequant(struct image_sig_block *blocks, uns blocks_count, struct image_sig_regi } prequant_finish_region(region); prequant_finish_region(region2); - HEAP_INCREASE(struct image_sig_region *, heap, heap_count, prequant_heap_cmp, HEAP_SWAP, 1); - heap[++heap_count] = region2; - HEAP_INSERT(struct image_sig_region *, heap, heap_count, prequant_heap_cmp, HEAP_SWAP); + HEAP_INCREASE(struct image_sig_region *, heap, heap_count, prequant_heap_cmp, HEAP_SWAP, 1, region); + HEAP_INSERT(struct image_sig_region *, heap, heap_count, prequant_heap_cmp, HEAP_SWAP, region2); } DBG("Pre-quantized to %u regions", regions_count);