|
|
@ -277,12 +277,10 @@ imdb_search(imdb_t * const db, |
|
|
|
return -1; |
|
|
|
return -1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!sample->data[0]) { |
|
|
|
if (search->limit == 0) |
|
|
|
db->errstr = "Source sample not exists"; |
|
|
|
search->limit = -1; /* unsigned -> max */ |
|
|
|
return -1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (search->tresh_ratio > 0.0) |
|
|
|
if (search->maxdiff_ratio > 0.0) |
|
|
|
ratio_s = ratio_from_rec_data(sample->data); |
|
|
|
ratio_s = ratio_from_rec_data(sample->data); |
|
|
|
|
|
|
|
|
|
|
|
*matches = NULL; |
|
|
|
*matches = NULL; |
|
|
@ -296,16 +294,16 @@ imdb_search(imdb_t * const db, |
|
|
|
if (ratio_s > 0.0 && (ratio_t = ratio_from_rec_data(p)) > 0.0) { |
|
|
|
if (ratio_s > 0.0 && (ratio_t = ratio_from_rec_data(p)) > 0.0) { |
|
|
|
diff = ratio_s - ratio_t; |
|
|
|
diff = ratio_s - ratio_t; |
|
|
|
diff *= (ratio_s > ratio_t) ? 1.0 : -1.0; |
|
|
|
diff *= (ratio_s > ratio_t) ? 1.0 : -1.0; |
|
|
|
if (diff > search->tresh_ratio) |
|
|
|
if (diff > search->maxdiff_ratio) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
/* either ratio not set, can't compare, skipping test */ |
|
|
|
/* either source or target ratio not set, can't compare, skip test */ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* - compare bitmap - more expensive */ |
|
|
|
/* - compare bitmap - more expensive */ |
|
|
|
diff = (float) bitmap_compare(p + REC_OFF_BM, sample->data + REC_OFF_BM); |
|
|
|
diff = (float) bitmap_compare(p + REC_OFF_BM, sample->data + REC_OFF_BM); |
|
|
|
diff /= BITMAP_BITS; |
|
|
|
diff /= BITMAP_BITS; |
|
|
|
if (diff > search->tresh_bitmap) |
|
|
|
if (diff > search->maxdiff_bitmap) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
/* allocate more memory, if needed */ |
|
|
|
/* allocate more memory, if needed */ |
|
|
@ -323,11 +321,11 @@ imdb_search(imdb_t * const db, |
|
|
|
(*matches)[found].num = blk.start + i; |
|
|
|
(*matches)[found].num = blk.start + i; |
|
|
|
(*matches)[found].diff = diff; |
|
|
|
(*matches)[found].diff = diff; |
|
|
|
found++; |
|
|
|
found++; |
|
|
|
if (search->limit && found >= search->limit) |
|
|
|
if (found >= search->limit) |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
FREE(blk.data); |
|
|
|
FREE(blk.data); |
|
|
|
if (search->limit && found >= search->limit) |
|
|
|
if (found >= search->limit) |
|
|
|
break; |
|
|
|
break; |
|
|
|
blk.start += blk_size; |
|
|
|
blk.start += blk_size; |
|
|
|
} |
|
|
|
} |
|
|
|