2 * Image Library -- Dumping 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.
11 #include "lib/fastbuf.h"
12 #include "lib/unaligned.h"
13 #include "images/images.h"
14 #include "images/signature.h"
18 image_vector_dump(byte *buf, struct image_vector *vec)
22 for (uns i = 0; i < IMAGE_VEC_F; i++)
26 p += sprintf(p, "%u", vec->f[i]);
34 image_region_dump(byte *buf, struct image_region *reg)
37 p += sprintf(p, "(txt=");
38 for (uns i = 0; i < IMAGE_REG_F; i++)
42 p += sprintf(p, "%u", reg->f[i]);
44 p += sprintf(p, " shp=");
45 for (uns i = 0; i < IMAGE_REG_H; i++)
49 p += sprintf(p, "%u", reg->h[i]);
51 p += sprintf(p, " wa=%u wb=%u)", reg->wa, reg->wb);
57 get_image_signature(byte *buf, struct image_signature *sig)
59 uns size = image_signature_size(*buf);
60 memcpy(sig, buf, size);
61 #ifndef CPU_ALLOW_UNALIGNED
62 #define FIX_U16(x) PUT_U16(&(x), x)
64 struct image_region *reg = sig->reg;
65 for (uns i = 0; i < sig->len; i++, reg++)
67 for (uns j = 0; j < IMAGE_REG_H; j++)
78 put_image_signature(byte *buf, struct image_signature *sig)
80 uns size = image_signature_size(sig->len);
81 memcpy(buf, sig, size);
82 #ifndef CPU_ALLOW_UNALIGNED
83 #define FIX_U16(x) do { x = GET_U16(&(x)); } while(0)
84 struct image_signature *tmp = (struct image_signature *)buf;
86 struct image_region *reg = tmp->reg;
87 for (uns i = 0; i < tmp->len; i++, reg++)
89 for (uns j = 0; j < IMAGE_REG_H; j++)
99 bget_image_signature(struct fastbuf *fb, struct image_signature *sig)
101 uns size = image_signature_size(bpeekc(sig));
102 breadb(fb, sig, size);
103 #ifndef CPU_ALLOW_UNALIGNED
104 #define FIX_U16(x) PUT_U16(&(x), x)
106 struct image_region *reg = sig->reg;
107 for (uns i = 0; i < sig->len; i++, reg++)
109 for (uns j = 0; j < IMAGE_REG_H; j++)
120 bput_image_signature(struct fastbuf *fb, struct image_signature *sig)
122 uns size = image_signature_size(sig->len);
123 #ifdef CPU_ALLOW_UNALIGNED
124 bwrite(fb, sig, size);
126 struct image_signature tmp;
127 memcpy(tmp, sig, size);
128 #define FIX_U16(x) do { x = GET_U16(&(x)); } while(0)
130 struct image_region *reg = tmp.reg;
131 for (uns i = 0; i < tmp.len; i++, reg++)
133 for (uns j = 0; j < IMAGE_REG_H; j++)
138 bwrite(fb, &tmp, size);