2 * Image Library -- Computation of image signatures
4 * (c) 2006 Pavel Charvat <pchar@ucw.cz>
6 * This software may be freely distributed and used according to the terms
7 * of the GNU Lesser General Public License.
12 #include "sherlock/sherlock.h"
13 #include "lib/fastbuf.h"
14 #include "images/images.h"
15 #include "images/signature.h"
18 image_signature_read(struct fastbuf *fb, struct image_signature *sig)
20 uns size = image_signature_size(bpeekc(sig));
21 breadb(fb, sig, size);
22 #ifndef CPU_ALLOW_UNALIGNED
23 #define FIX_U16(x) PUT_U16(&(x), x)
25 struct image_region *reg = sig->reg;
26 for (uns i = 0; i < sig->len; i++, reg++)
28 for (uns j = 0; j < IMAGE_REG_H; j++)
39 image_signature_write(struct fastbuf *fb, struct image_signature *sig)
41 uns size = image_signature_size(sig->len);
42 #ifdef CPU_ALLOW_UNALIGNED
43 bwrite(fb, sig, size);
45 struct image_signature tmp;
46 memcpy(tmp, sig, size);
47 #define FIX_U16(x) do { x = GET_U16(&(x)); } while(0)
49 struct image_region *reg = tmp.reg;
50 for (uns i = 0; i < tmp.len; i++, reg++)
52 for (uns j = 0; j < IMAGE_REG_H; j++)
57 bwrite(fb, &tmp, size);