istereo2

diff libs/zlib/compress.c @ 2:81d35769f546

added the tunnel effect source
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 19 Sep 2015 05:51:51 +0300
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/libs/zlib/compress.c	Sat Sep 19 05:51:51 2015 +0300
     1.3 @@ -0,0 +1,79 @@
     1.4 +/* compress.c -- compress a memory buffer
     1.5 + * Copyright (C) 1995-2003 Jean-loup Gailly.
     1.6 + * For conditions of distribution and use, see copyright notice in zlib.h
     1.7 + */
     1.8 +
     1.9 +/* @(#) $Id$ */
    1.10 +
    1.11 +#define ZLIB_INTERNAL
    1.12 +#include "zlib.h"
    1.13 +
    1.14 +/* ===========================================================================
    1.15 +     Compresses the source buffer into the destination buffer. The level
    1.16 +   parameter has the same meaning as in deflateInit.  sourceLen is the byte
    1.17 +   length of the source buffer. Upon entry, destLen is the total size of the
    1.18 +   destination buffer, which must be at least 0.1% larger than sourceLen plus
    1.19 +   12 bytes. Upon exit, destLen is the actual size of the compressed buffer.
    1.20 +
    1.21 +     compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
    1.22 +   memory, Z_BUF_ERROR if there was not enough room in the output buffer,
    1.23 +   Z_STREAM_ERROR if the level parameter is invalid.
    1.24 +*/
    1.25 +int ZEXPORT compress2 (dest, destLen, source, sourceLen, level)
    1.26 +    Bytef *dest;
    1.27 +    uLongf *destLen;
    1.28 +    const Bytef *source;
    1.29 +    uLong sourceLen;
    1.30 +    int level;
    1.31 +{
    1.32 +    z_stream stream;
    1.33 +    int err;
    1.34 +
    1.35 +    stream.next_in = (Bytef*)source;
    1.36 +    stream.avail_in = (uInt)sourceLen;
    1.37 +#ifdef MAXSEG_64K
    1.38 +    /* Check for source > 64K on 16-bit machine: */
    1.39 +    if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR;
    1.40 +#endif
    1.41 +    stream.next_out = dest;
    1.42 +    stream.avail_out = (uInt)*destLen;
    1.43 +    if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
    1.44 +
    1.45 +    stream.zalloc = (alloc_func)0;
    1.46 +    stream.zfree = (free_func)0;
    1.47 +    stream.opaque = (voidpf)0;
    1.48 +
    1.49 +    err = deflateInit(&stream, level);
    1.50 +    if (err != Z_OK) return err;
    1.51 +
    1.52 +    err = deflate(&stream, Z_FINISH);
    1.53 +    if (err != Z_STREAM_END) {
    1.54 +        deflateEnd(&stream);
    1.55 +        return err == Z_OK ? Z_BUF_ERROR : err;
    1.56 +    }
    1.57 +    *destLen = stream.total_out;
    1.58 +
    1.59 +    err = deflateEnd(&stream);
    1.60 +    return err;
    1.61 +}
    1.62 +
    1.63 +/* ===========================================================================
    1.64 + */
    1.65 +int ZEXPORT compress (dest, destLen, source, sourceLen)
    1.66 +    Bytef *dest;
    1.67 +    uLongf *destLen;
    1.68 +    const Bytef *source;
    1.69 +    uLong sourceLen;
    1.70 +{
    1.71 +    return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
    1.72 +}
    1.73 +
    1.74 +/* ===========================================================================
    1.75 +     If the default memLevel or windowBits for deflateInit() is changed, then
    1.76 +   this function needs to be updated.
    1.77 + */
    1.78 +uLong ZEXPORT compressBound (sourceLen)
    1.79 +    uLong sourceLen;
    1.80 +{
    1.81 +    return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + 11;
    1.82 +}