diff src/dmzlib.h @ 949:6ed9465f3913

Initial import of separated zlib decoding routines lifted from Sean Barrett's stb_image module (which is public domain). Still needs work to be more in line with DMLib standards.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 26 Feb 2015 18:28:32 +0200
parents
children 985225a93aeb
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/dmzlib.h	Thu Feb 26 18:28:32 2015 +0200
@@ -0,0 +1,62 @@
+/*
+ * DMLib
+ * -- ZLib implementation
+ * Public domain zlib decode v0.2 by Sean Barrett 2006-11-18
+ * Modified and reformatted for DMLib by Matti 'ccr' Hamalainen
+ */
+#ifndef DMZLIB_H
+#define DMZLIB_H
+
+#include "dmlib.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// fast-way is faster to check than jpeg huffman, but slow way is slower
+#define STBI__ZFAST_BITS  9     // accelerate all cases in default tables
+#define STBI__ZFAST_SIZE  (1 << STBI__ZFAST_BITS)
+#define STBI__ZFAST_MASK  (STBI__ZFAST_SIZE - 1)
+
+
+typedef struct
+{
+    Uint16  fast[STBI__ZFAST_SIZE];
+    Uint16  firstCode[16];
+    int     maxCode[17];
+    Uint16  firstSymbol[16];
+    Uint8   size[288];
+    Uint16  value[288];
+} DMZHuffmanContext;
+
+
+typedef struct
+{
+    Uint8 *zbuffer, *zbuffer_end;
+
+    int num_bits;
+    Uint32 code_buffer;
+
+    char *zout, *zout_start, *zout_end;
+    int z_expandable;
+
+    DMZHuffmanContext z_length, z_distance;
+} DMZLibContext;
+
+
+void dmZLibInit();
+
+char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int initial_size, int *outlen);
+char *stbi_zlib_decode_malloc(char const *buffer, int len, int *outlen);
+char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer,
+    int len, int initial_size, int *outlen, BOOL parse_header);
+int stbi_zlib_decode_buffer(char *obuffer, int olen, char const *ibuffer, int ilen);
+char *stbi_zlib_decode_noheader_malloc(char const *buffer, int len, int *outlen);
+int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char *ibuffer, int ilen);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // DMZLIB_H