view src/dmzlib.h @ 958:985225a93aeb

Add error code parameter to dmError() and dmErrorVA().
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 27 Feb 2015 03:58:25 +0200
parents 6ed9465f3913
children 1832ac20edb2
line wrap: on
line source

/*
 * 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, *zbufferEnd;

    int numBits;
    Uint32 codeBuffer;

    Uint8 *zout, *zoutStart, *zoutEnd;
    BOOL expandable;

    DMZHuffmanContext zlength, zdistance;
} DMZLibContext;


void dmZLibInit();
int  dmZLibDecode(DMZLibContext * ctx);
int  dmZLibParseHeader(DMZLibContext * ctx, BOOL checkPNG);

Uint8 *stbi_zlib_decode_malloc_guesssize(const Uint8 *buffer, const size_t len, const size_t initialSize, size_t *outLen);

#ifdef __cplusplus
}
#endif

#endif // DMZLIB_H