]> git.imager.perl.org - imager.git/blobdiff - imageri.h
avoid re-entrancy into giflib using the mutex API
[imager.git] / imageri.h
index 9b07315b8124d3e1392cd28cab50794b73182fb2..59d333a70f8202baa728035c94a5cc564862a1f2 100644 (file)
--- a/imageri.h
+++ b/imageri.h
@@ -6,6 +6,7 @@
 #define IMAGEI_H_
 
 #include "imager.h"
 #define IMAGEI_H_
 
 #include "imager.h"
+#include <stddef.h>
 
 /* wrapper functions that implement the floating point sample version of a 
    function in terms of the 8-bit sample version
 
 /* wrapper functions that implement the floating point sample version of a 
    function in terms of the 8-bit sample version
@@ -34,14 +35,14 @@ extern int i_setcolors_forward(i_img *im, int index, const i_color *colors,
 extern i_img_dim i_gsamp_bits_fb(i_img *im, i_img_dim x, i_img_dim r, i_img_dim y, unsigned *samp, 
                           const int *chans, int chan_count, int bits);
 
 extern i_img_dim i_gsamp_bits_fb(i_img *im, i_img_dim x, i_img_dim r, i_img_dim y, unsigned *samp, 
                           const int *chans, int chan_count, int bits);
 
-#define SampleFTo16(num) ((int)((num) * 65535.0 + 0.01))
+#define SampleFTo16(num) ((int)((num) * 65535.0 + 0.5))
 /* we add that little bit to avoid rounding issues */
 #define Sample16ToF(num) ((num) / 65535.0)
 
 /* we add that little bit to avoid rounding issues */
 #define Sample16ToF(num) ((num) / 65535.0)
 
-#define SampleFTo8(num) ((int)((num) * 255.0 + 0.01))
+#define SampleFTo8(num) ((int)((num) * 255.0 + 0.5))
 #define Sample8ToF(num) ((num) / 255.0)
 
 #define Sample8ToF(num) ((num) / 255.0)
 
-#define Sample16To8(num) ((num) / 257)
+#define Sample16To8(num) (((num)+128) / 257)
 #define Sample8To16(num) ((num) * 257)
 
 extern void i_get_combine(int combine, i_fill_combine_f *, i_fill_combinef_f *);
 #define Sample8To16(num) ((num) * 257)
 
 extern void i_get_combine(int combine, i_fill_combine_f *, i_fill_combinef_f *);
@@ -111,4 +112,25 @@ i_img_dim i_abs(i_img_dim x);
 
 #define color_to_grey(col) ((col)->rgb.r * 0.222  + (col)->rgb.g * 0.707 + (col)->rgb.b * 0.071)
 
 
 #define color_to_grey(col) ((col)->rgb.r * 0.222  + (col)->rgb.g * 0.707 + (col)->rgb.b * 0.071)
 
+#define IM_ERROR_COUNT 20
+typedef struct im_context_tag {
+  int error_sp;
+  size_t error_alloc[IM_ERROR_COUNT];
+  i_errmsg error_stack[IM_ERROR_COUNT];
+#ifdef IMAGER_LOG
+  int log_level;
+  FILE *lg_file;
+  const char *filename;
+  int line;
+#endif
+
+  /* file size limits */
+  i_img_dim max_width, max_height;
+  size_t max_bytes;
+
+  ptrdiff_t refcount;
+} im_context_struct;
+
+#define DEF_BYTES_LIMIT 0x40000000
+
 #endif
 #endif