X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=images%2Fsig-dump.c;h=7163fa47da13eec905822e9a682438c914d03c48;hb=4313ba1d176383101791bcfad9660dd16ea30a84;hp=5c35eefcb328b17e97cf5567c5fb925ac6295172;hpb=c08e5b6cf16ac7fdf810a142bf2f1f48951ba3fc;p=libucw.git diff --git a/images/sig-dump.c b/images/sig-dump.c index 5c35eefc..7163fa47 100644 --- a/images/sig-dump.c +++ b/images/sig-dump.c @@ -7,11 +7,9 @@ * of the GNU Lesser General Public License. */ -#include "lib/lib.h" -#include "lib/fastbuf.h" -#include "lib/unaligned.h" -#include "images/images.h" -#include "images/signature.h" +#include +#include +#include #include byte * @@ -19,7 +17,7 @@ image_vector_dump(byte *buf, struct image_vector *vec) { byte *p = buf; *p++ = '('; - for (uns i = 0; i < IMAGE_VEC_F; i++) + for (uint i = 0; i < IMAGE_VEC_F; i++) { if (i) *p++ = ' '; @@ -35,14 +33,14 @@ image_region_dump(byte *buf, struct image_region *reg) { byte *p = buf; p += sprintf(p, "(txt="); - for (uns i = 0; i < IMAGE_REG_F; i++) + for (uint i = 0; i < IMAGE_REG_F; i++) { if (i) *p++ = ' '; p += sprintf(p, "%u", reg->f[i]); } p += sprintf(p, " shp="); - for (uns i = 0; i < IMAGE_REG_H; i++) + for (uint i = 0; i < IMAGE_REG_H; i++) { if (i) *p++ = ' '; @@ -52,91 +50,3 @@ image_region_dump(byte *buf, struct image_region *reg) *p = 0; return buf; } - -uns -get_image_signature(byte *buf, struct image_signature *sig) -{ - uns size = image_signature_size(*buf); - memcpy(sig, buf, size); -#ifndef CPU_ALLOW_UNALIGNED -#define FIX_U16(x) PUT_U16(&(x), x) - FIX_U16(sig->dh); - struct image_region *reg = sig->reg; - for (uns i = 0; i < sig->len; i++, reg++) - { - for (uns j = 0; j < IMAGE_REG_H; j++) - FIX_U16(reg->h[j]); - FIX_U16(reg->wa); - FIX_U16(reg->wb); - } -#undef FIX_U16 -#endif - return size; -} - -uns -put_image_signature(byte *buf, struct image_signature *sig) -{ - uns size = image_signature_size(sig->len); - memcpy(buf, sig, size); -#ifndef CPU_ALLOW_UNALIGNED -#define FIX_U16(x) do { x = GET_U16(&(x)); } while(0) - struct image_signature *tmp = (struct image_signature *)buf; - FIX_U16(tmp->dh); - struct image_region *reg = tmp->reg; - for (uns i = 0; i < tmp->len; i++, reg++) - { - for (uns j = 0; j < IMAGE_REG_H; j++) - FIX_U16(reg->h[j]); - FIX_U16(reg->wa); - FIX_U16(reg->wb); - } -#undef FIX_U16 -#endif - return size; -} -uns -bget_image_signature(struct fastbuf *fb, struct image_signature *sig) -{ - uns size = image_signature_size(bpeekc(sig)); - breadb(fb, sig, size); -#ifndef CPU_ALLOW_UNALIGNED -#define FIX_U16(x) PUT_U16(&(x), x) - FIX_U16(sig->dh); - struct image_region *reg = sig->reg; - for (uns i = 0; i < sig->len; i++, reg++) - { - for (uns j = 0; j < IMAGE_REG_H; j++) - FIX_U16(reg->h[j]); - FIX_U16(reg->wa); - FIX_U16(reg->wb); - } -#undef FIX_U16 -#endif - return size; -} - -uns -bput_image_signature(struct fastbuf *fb, struct image_signature *sig) -{ - uns size = image_signature_size(sig->len); -#ifdef CPU_ALLOW_UNALIGNED - bwrite(fb, sig, size); -#else - struct image_signature tmp; - memcpy(tmp, sig, size); -#define FIX_U16(x) do { x = GET_U16(&(x)); } while(0) - FIX_U16(tmp.dh); - struct image_region *reg = tmp.reg; - for (uns i = 0; i < tmp.len; i++, reg++) - { - for (uns j = 0; j < IMAGE_REG_H; j++) - FIX_U16(reg->h[j]); - FIX_U16(reg->wa); - FIX_U16(reg->wb); - } - bwrite(fb, &tmp, size); -#undef FIX_U16 -#endif - return size; -}