]> mj.ucw.cz Git - libucw.git/commitdiff
reverted invalid usage of GET*/PUT* macros
authorPavel Charvat <pavel.charvat@netcentrum.cz>
Tue, 12 Sep 2006 13:38:28 +0000 (15:38 +0200)
committerPavel Charvat <pavel.charvat@netcentrum.cz>
Tue, 12 Sep 2006 13:38:28 +0000 (15:38 +0200)
images/object.c
images/object.h
images/sig-dump.c
images/signature.h

index 5e0fa825fc4773a8a729c84ce30016355103543b..d817e1c92f10c519d087073e316c2f10fc5fd242 100644 (file)
@@ -81,43 +81,27 @@ read_image_obj_thumb(struct image_obj_info *ioi, struct fastbuf *fb, struct imag
   return img;
 error:
   DBG("Failed to decompress thumbnail: %s", io->thread->err_msg);
-  return NULL;
-}
-
-uns
-encode_image_obj_signature(byte *buf, struct image_signature *sig)
-{
-  /* signatures should be short enough to fit one attribute */
-  byte tmp[sizeof(struct image_signature)];
-  uns size = put_image_signature(tmp, sig);
-  ASSERT(MAX_ATTR_SIZE > BASE224_ENC_LENGTH(size));
-  uns len = base224_encode(buf, tmp, size);
-  buf[len] = 0;
-  return len;
-}
-
-uns
-decode_image_obj_signature(byte *buf, struct image_signature *sig)
-{
-  if (!buf)
-    return 0;
-  byte tmp[sizeof(struct image_signature)];
-  UNUSED uns size = base224_decode(tmp, buf, strlen(buf));
-  ASSERT(size == image_signature_size(*tmp));
-  get_image_signature(tmp, sig);
-  return 1;
+  return NULL;  
 }
 
 void
 put_image_obj_signature(struct odes *o, struct image_signature *sig)
 {
+  /* signatures should be short enough to fit one attribute */
   byte buf[MAX_ATTR_SIZE];
-  encode_image_obj_signature(buf, sig);
+  uns size = image_signature_size(sig->len);
+  ASSERT(MAX_ATTR_SIZE > BASE224_ENC_LENGTH(size));
+  buf[base224_encode(buf, (byte *)sig, size)] = 0;
   obj_set_attr(o, 'H', buf);
 }
 
 uns
-get_image_obj_signature(struct odes *o, struct image_signature *sig)
+get_image_obj_signature(struct image_signature *sig, struct odes *o)
 {
-  return decode_image_obj_signature(obj_find_aval(o, 'H'), sig);
+  byte *a = obj_find_aval(o, 'H');
+  if (!a)
+    return 0;
+  UNUSED uns size = base224_decode((byte *)sig, a, strlen(a));
+  ASSERT(size == image_signature_size(sig->len));
+  return 1;
 }
index 2f2bc0b1aa64d49f325fd87d3d21d318a0870978..189b3c0b2de7f9b3add91d2e7f6c116c9e38b7b3 100644 (file)
@@ -21,9 +21,7 @@ struct image_signature;
 uns get_image_obj_info(struct image_obj_info *ioi, struct odes *o);
 uns get_image_obj_thumb(struct image_obj_info *ioi, struct odes *o, struct mempool *pool);
 struct image *read_image_obj_thumb(struct image_obj_info *ioi, struct fastbuf *fb, struct image_io *io, struct mempool *pool);
-uns encode_image_obj_signature(byte *buf, struct image_signature *sig);
-uns decode_image_obj_signature(byte *buf, struct image_signature *sig);
 void put_image_obj_signature(struct odes *o, struct image_signature *sig);
-uns get_image_obj_signature(struct odes *o, struct image_signature *sig);
+uns get_image_obj_signature(struct image_signature *sig, struct odes *o);
 
 #endif
index 5c35eefcb328b17e97cf5567c5fb925ac6295172..a150f612dab4f271f18f289c9af431d01cc29072 100644 (file)
@@ -8,8 +8,6 @@
  */
 
 #include "lib/lib.h"
-#include "lib/fastbuf.h"
-#include "lib/unaligned.h"
 #include "images/images.h"
 #include "images/signature.h"
 #include <stdio.h>
@@ -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;
-}
index 868f4d1c8b0aece82eb2b30ad56d953774cb3582..e84c7f3164fbb01784fb9c527af634756f39b2d7 100644 (file)
@@ -1,8 +1,6 @@
 #ifndef _IMAGES_SIGNATURE_H
 #define _IMAGES_SIGNATURE_H
 
-#include "lib/fastbuf.h"
-
 /* Configuration */
 extern uns image_sig_min_width, image_sig_min_height;
 extern uns *image_sig_prequant_thresholds;
@@ -44,13 +42,13 @@ struct image_cluster {
   union {
     struct {
       s32 dot;                 /* Dot product of the splitting plane */
-      byte vec[IMAGE_VEC_F];   /* Normal vector of the splitting plane */
-    };
+      s8 vec[IMAGE_VEC_F];     /* Normal vector of the splitting plane */
+    } PACKED;
     struct {
       u64 pos;                 /* Cluster size in bytes */
-    };
-  };
-};
+    } PACKED;
+  } PACKED;
+} PACKED;
 
 static inline uns
 image_signature_size(uns len)
@@ -100,34 +98,6 @@ struct image_sig_data {
   u32 f[IMAGE_VEC_F];
 };
 
-#define IMAGE_VECTOR_SIZE (sizeof(struct image_vector))
-
-static inline uns
-bget_image_vector(struct fastbuf *fb, struct image_vector *vec)
-{
-  breadb(fb, vec, sizeof(*vec));
-  return IMAGE_VECTOR_SIZE;
-}
-
-static inline uns
-bput_image_vector(struct fastbuf *fb, struct image_vector *vec)
-{
-  bwrite(fb, vec, sizeof(*vec));
-  return IMAGE_VECTOR_SIZE;
-}
-
-static inline uns
-bpeek_image_signature(struct fastbuf *fb)
-{
-  return image_signature_size(bpeekc(fb));
-}
-
-uns get_image_signature(byte *buf, struct image_signature *sig);
-uns put_image_signature(byte *buf, struct image_signature *sig);
-
-uns bget_image_signature(struct fastbuf *fb, struct image_signature *sig);
-uns bput_image_signature(struct fastbuf *fb, struct image_signature *sig);
-
 /* sig-init.c */
 
 int compute_image_signature(struct image_thread *thread, struct image_signature *sig, struct image *image);