parent
e57c4dcd71
commit
afa9fae024
@ -0,0 +1,451 @@
|
|||||||
|
/* lzoconf.h -- configuration for the LZO real-time data compression library
|
||||||
|
|
||||||
|
This file is part of the LZO real-time data compression library.
|
||||||
|
|
||||||
|
Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
|
||||||
|
Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
|
||||||
|
Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
|
||||||
|
Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
|
||||||
|
Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
|
||||||
|
Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
|
||||||
|
Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
|
||||||
|
All Rights Reserved.
|
||||||
|
|
||||||
|
The LZO library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License as
|
||||||
|
published by the Free Software Foundation; either version 2 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
The LZO library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with the LZO library; see the file COPYING.
|
||||||
|
If not, write to the Free Software Foundation, Inc.,
|
||||||
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
Markus F.X.J. Oberhumer
|
||||||
|
<markus@oberhumer.com>
|
||||||
|
http://www.oberhumer.com/opensource/lzo/
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef __LZOCONF_H
|
||||||
|
#define __LZOCONF_H
|
||||||
|
|
||||||
|
#define LZO_VERSION 0x1080
|
||||||
|
#define LZO_VERSION_STRING "1.08"
|
||||||
|
#define LZO_VERSION_DATE "Jul 12 2002"
|
||||||
|
|
||||||
|
/* internal Autoconf configuration file - only used when building LZO */
|
||||||
|
#if defined(LZO_HAVE_CONFIG_H)
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
// LZO requires a conforming <limits.h>
|
||||||
|
************************************************************************/
|
||||||
|
|
||||||
|
#if !defined(CHAR_BIT) || (CHAR_BIT != 8)
|
||||||
|
# error "invalid CHAR_BIT"
|
||||||
|
#endif
|
||||||
|
#if !defined(UCHAR_MAX) || !defined(UINT_MAX) || !defined(ULONG_MAX)
|
||||||
|
# error "check your compiler installation"
|
||||||
|
#endif
|
||||||
|
#if (USHRT_MAX < 1) || (UINT_MAX < 1) || (ULONG_MAX < 1)
|
||||||
|
# error "your limits.h macros are broken"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* workaround a cpp bug under hpux 10.20 */
|
||||||
|
#define LZO_0xffffffffL 4294967295ul
|
||||||
|
|
||||||
|
#if !defined(LZO_UINT32_C)
|
||||||
|
# if (UINT_MAX < LZO_0xffffffffL)
|
||||||
|
# define LZO_UINT32_C(c) c ## UL
|
||||||
|
# else
|
||||||
|
# define LZO_UINT32_C(c) c ## U
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
// architecture defines
|
||||||
|
************************************************************************/
|
||||||
|
|
||||||
|
#if !defined(__LZO_WIN) && !defined(__LZO_DOS) && !defined(__LZO_OS2)
|
||||||
|
# if defined(__WINDOWS__) || defined(_WINDOWS) || defined(_Windows)
|
||||||
|
# define __LZO_WIN
|
||||||
|
# elif defined(__WIN32__) || defined(_WIN32) || defined(WIN32)
|
||||||
|
# define __LZO_WIN
|
||||||
|
# elif defined(__NT__) || defined(__NT_DLL__) || defined(__WINDOWS_386__)
|
||||||
|
# define __LZO_WIN
|
||||||
|
# elif defined(__DOS__) || defined(__MSDOS__) || defined(MSDOS)
|
||||||
|
# define __LZO_DOS
|
||||||
|
# elif defined(__OS2__) || defined(__OS2V2__) || defined(OS2)
|
||||||
|
# define __LZO_OS2
|
||||||
|
# elif defined(__palmos__)
|
||||||
|
# define __LZO_PALMOS
|
||||||
|
# elif defined(__TOS__) || defined(__atarist__)
|
||||||
|
# define __LZO_TOS
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (UINT_MAX < LZO_0xffffffffL)
|
||||||
|
# if defined(__LZO_WIN)
|
||||||
|
# define __LZO_WIN16
|
||||||
|
# elif defined(__LZO_DOS)
|
||||||
|
# define __LZO_DOS16
|
||||||
|
# elif defined(__LZO_PALMOS)
|
||||||
|
# define __LZO_PALMOS16
|
||||||
|
# elif defined(__LZO_TOS)
|
||||||
|
# define __LZO_TOS16
|
||||||
|
# elif defined(__C166__)
|
||||||
|
# else
|
||||||
|
/* porting hint: for pure 16-bit architectures try compiling
|
||||||
|
* everything with -D__LZO_STRICT_16BIT */
|
||||||
|
# error "16-bit target not supported - contact me for porting hints"
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(__LZO_i386)
|
||||||
|
# if defined(__LZO_DOS) || defined(__LZO_WIN16)
|
||||||
|
# define __LZO_i386
|
||||||
|
# elif defined(__i386__) || defined(__386__) || defined(_M_IX86)
|
||||||
|
# define __LZO_i386
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__LZO_STRICT_16BIT)
|
||||||
|
# if (UINT_MAX < LZO_0xffffffffL)
|
||||||
|
# include <lzo16bit.h>
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* memory checkers */
|
||||||
|
#if !defined(__LZO_CHECKER)
|
||||||
|
# if defined(__BOUNDS_CHECKING_ON)
|
||||||
|
# define __LZO_CHECKER
|
||||||
|
# elif defined(__CHECKER__)
|
||||||
|
# define __LZO_CHECKER
|
||||||
|
# elif defined(__INSURE__)
|
||||||
|
# define __LZO_CHECKER
|
||||||
|
# elif defined(__PURIFY__)
|
||||||
|
# define __LZO_CHECKER
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
// integral and pointer types
|
||||||
|
************************************************************************/
|
||||||
|
|
||||||
|
/* Integral types with 32 bits or more */
|
||||||
|
#if !defined(LZO_UINT32_MAX)
|
||||||
|
# if (UINT_MAX >= LZO_0xffffffffL)
|
||||||
|
typedef unsigned int lzo_uint32;
|
||||||
|
typedef int lzo_int32;
|
||||||
|
# define LZO_UINT32_MAX UINT_MAX
|
||||||
|
# define LZO_INT32_MAX INT_MAX
|
||||||
|
# define LZO_INT32_MIN INT_MIN
|
||||||
|
# elif (ULONG_MAX >= LZO_0xffffffffL)
|
||||||
|
typedef unsigned long lzo_uint32;
|
||||||
|
typedef long lzo_int32;
|
||||||
|
# define LZO_UINT32_MAX ULONG_MAX
|
||||||
|
# define LZO_INT32_MAX LONG_MAX
|
||||||
|
# define LZO_INT32_MIN LONG_MIN
|
||||||
|
# else
|
||||||
|
# error "lzo_uint32"
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* lzo_uint is used like size_t */
|
||||||
|
#if !defined(LZO_UINT_MAX)
|
||||||
|
# if (UINT_MAX >= LZO_0xffffffffL)
|
||||||
|
typedef unsigned int lzo_uint;
|
||||||
|
typedef int lzo_int;
|
||||||
|
# define LZO_UINT_MAX UINT_MAX
|
||||||
|
# define LZO_INT_MAX INT_MAX
|
||||||
|
# define LZO_INT_MIN INT_MIN
|
||||||
|
# elif (ULONG_MAX >= LZO_0xffffffffL)
|
||||||
|
typedef unsigned long lzo_uint;
|
||||||
|
typedef long lzo_int;
|
||||||
|
# define LZO_UINT_MAX ULONG_MAX
|
||||||
|
# define LZO_INT_MAX LONG_MAX
|
||||||
|
# define LZO_INT_MIN LONG_MIN
|
||||||
|
# else
|
||||||
|
# error "lzo_uint"
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef int lzo_bool;
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
// memory models
|
||||||
|
************************************************************************/
|
||||||
|
|
||||||
|
/* Memory model for the public code segment. */
|
||||||
|
#if !defined(__LZO_CMODEL)
|
||||||
|
# if defined(__LZO_DOS16) || defined(__LZO_WIN16)
|
||||||
|
# define __LZO_CMODEL __far
|
||||||
|
# elif defined(__LZO_i386) && defined(__WATCOMC__)
|
||||||
|
# define __LZO_CMODEL __near
|
||||||
|
# else
|
||||||
|
# define __LZO_CMODEL
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Memory model for the public data segment. */
|
||||||
|
#if !defined(__LZO_DMODEL)
|
||||||
|
# if defined(__LZO_DOS16) || defined(__LZO_WIN16)
|
||||||
|
# define __LZO_DMODEL __far
|
||||||
|
# elif defined(__LZO_i386) && defined(__WATCOMC__)
|
||||||
|
# define __LZO_DMODEL __near
|
||||||
|
# else
|
||||||
|
# define __LZO_DMODEL
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Memory model that allows to access memory at offsets of lzo_uint. */
|
||||||
|
#if !defined(__LZO_MMODEL)
|
||||||
|
# if (LZO_UINT_MAX <= UINT_MAX)
|
||||||
|
# define __LZO_MMODEL
|
||||||
|
# elif defined(__LZO_DOS16) || defined(__LZO_WIN16)
|
||||||
|
# define __LZO_MMODEL __huge
|
||||||
|
# define LZO_999_UNSUPPORTED
|
||||||
|
# elif defined(__LZO_PALMOS16) || defined(__LZO_TOS16)
|
||||||
|
# define __LZO_MMODEL
|
||||||
|
# else
|
||||||
|
# error "__LZO_MMODEL"
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* no typedef here because of const-pointer issues */
|
||||||
|
#define lzo_byte unsigned char __LZO_MMODEL
|
||||||
|
#define lzo_bytep unsigned char __LZO_MMODEL *
|
||||||
|
#define lzo_charp char __LZO_MMODEL *
|
||||||
|
#define lzo_voidp void __LZO_MMODEL *
|
||||||
|
#define lzo_shortp short __LZO_MMODEL *
|
||||||
|
#define lzo_ushortp unsigned short __LZO_MMODEL *
|
||||||
|
#define lzo_uint32p lzo_uint32 __LZO_MMODEL *
|
||||||
|
#define lzo_int32p lzo_int32 __LZO_MMODEL *
|
||||||
|
#define lzo_uintp lzo_uint __LZO_MMODEL *
|
||||||
|
#define lzo_intp lzo_int __LZO_MMODEL *
|
||||||
|
#define lzo_voidpp lzo_voidp __LZO_MMODEL *
|
||||||
|
#define lzo_bytepp lzo_bytep __LZO_MMODEL *
|
||||||
|
|
||||||
|
#ifndef lzo_sizeof_dict_t
|
||||||
|
# define lzo_sizeof_dict_t sizeof(lzo_bytep)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
// calling conventions and function types
|
||||||
|
************************************************************************/
|
||||||
|
|
||||||
|
/* linkage */
|
||||||
|
#if !defined(__LZO_EXTERN_C)
|
||||||
|
# ifdef __cplusplus
|
||||||
|
# define __LZO_EXTERN_C extern "C"
|
||||||
|
# else
|
||||||
|
# define __LZO_EXTERN_C extern
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* calling convention */
|
||||||
|
#if !defined(__LZO_CDECL)
|
||||||
|
# if defined(__LZO_DOS16) || defined(__LZO_WIN16)
|
||||||
|
# define __LZO_CDECL __LZO_CMODEL __cdecl
|
||||||
|
# elif defined(__LZO_i386) && defined(_MSC_VER)
|
||||||
|
# define __LZO_CDECL __LZO_CMODEL __cdecl
|
||||||
|
# elif defined(__LZO_i386) && defined(__WATCOMC__)
|
||||||
|
# define __LZO_CDECL __LZO_CMODEL __cdecl
|
||||||
|
# else
|
||||||
|
# define __LZO_CDECL __LZO_CMODEL
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#if !defined(__LZO_ENTRY)
|
||||||
|
# define __LZO_ENTRY __LZO_CDECL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* C++ exception specification for extern "C" function types */
|
||||||
|
#if !defined(__cplusplus)
|
||||||
|
# undef LZO_NOTHROW
|
||||||
|
# define LZO_NOTHROW
|
||||||
|
#elif !defined(LZO_NOTHROW)
|
||||||
|
# define LZO_NOTHROW
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
typedef int
|
||||||
|
(__LZO_ENTRY *lzo_compress_t) ( const lzo_byte *src, lzo_uint src_len,
|
||||||
|
lzo_byte *dst, lzo_uintp dst_len,
|
||||||
|
lzo_voidp wrkmem );
|
||||||
|
|
||||||
|
typedef int
|
||||||
|
(__LZO_ENTRY *lzo_decompress_t) ( const lzo_byte *src, lzo_uint src_len,
|
||||||
|
lzo_byte *dst, lzo_uintp dst_len,
|
||||||
|
lzo_voidp wrkmem );
|
||||||
|
|
||||||
|
typedef int
|
||||||
|
(__LZO_ENTRY *lzo_optimize_t) ( lzo_byte *src, lzo_uint src_len,
|
||||||
|
lzo_byte *dst, lzo_uintp dst_len,
|
||||||
|
lzo_voidp wrkmem );
|
||||||
|
|
||||||
|
typedef int
|
||||||
|
(__LZO_ENTRY *lzo_compress_dict_t)(const lzo_byte *src, lzo_uint src_len,
|
||||||
|
lzo_byte *dst, lzo_uintp dst_len,
|
||||||
|
lzo_voidp wrkmem,
|
||||||
|
const lzo_byte *dict, lzo_uint dict_len );
|
||||||
|
|
||||||
|
typedef int
|
||||||
|
(__LZO_ENTRY *lzo_decompress_dict_t)(const lzo_byte *src, lzo_uint src_len,
|
||||||
|
lzo_byte *dst, lzo_uintp dst_len,
|
||||||
|
lzo_voidp wrkmem,
|
||||||
|
const lzo_byte *dict, lzo_uint dict_len );
|
||||||
|
|
||||||
|
|
||||||
|
/* assembler versions always use __cdecl */
|
||||||
|
typedef int
|
||||||
|
(__LZO_CDECL *lzo_compress_asm_t)( const lzo_byte *src, lzo_uint src_len,
|
||||||
|
lzo_byte *dst, lzo_uintp dst_len,
|
||||||
|
lzo_voidp wrkmem );
|
||||||
|
|
||||||
|
typedef int
|
||||||
|
(__LZO_CDECL *lzo_decompress_asm_t)( const lzo_byte *src, lzo_uint src_len,
|
||||||
|
lzo_byte *dst, lzo_uintp dst_len,
|
||||||
|
lzo_voidp wrkmem );
|
||||||
|
|
||||||
|
|
||||||
|
/* a progress indicator callback function */
|
||||||
|
typedef void (__LZO_ENTRY *lzo_progress_callback_t) (lzo_uint, lzo_uint);
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
// export information
|
||||||
|
************************************************************************/
|
||||||
|
|
||||||
|
/* DLL export information */
|
||||||
|
#if !defined(__LZO_EXPORT1)
|
||||||
|
# define __LZO_EXPORT1
|
||||||
|
#endif
|
||||||
|
#if !defined(__LZO_EXPORT2)
|
||||||
|
# define __LZO_EXPORT2
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* exported calling convention for C functions */
|
||||||
|
#if !defined(LZO_PUBLIC)
|
||||||
|
# define LZO_PUBLIC(_rettype) \
|
||||||
|
__LZO_EXPORT1 _rettype __LZO_EXPORT2 __LZO_ENTRY
|
||||||
|
#endif
|
||||||
|
#if !defined(LZO_EXTERN)
|
||||||
|
# define LZO_EXTERN(_rettype) __LZO_EXTERN_C LZO_PUBLIC(_rettype)
|
||||||
|
#endif
|
||||||
|
#if !defined(LZO_PRIVATE)
|
||||||
|
# define LZO_PRIVATE(_rettype) static _rettype __LZO_ENTRY
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* exported __cdecl calling convention for assembler functions */
|
||||||
|
#if !defined(LZO_PUBLIC_CDECL)
|
||||||
|
# define LZO_PUBLIC_CDECL(_rettype) \
|
||||||
|
__LZO_EXPORT1 _rettype __LZO_EXPORT2 __LZO_CDECL
|
||||||
|
#endif
|
||||||
|
#if !defined(LZO_EXTERN_CDECL)
|
||||||
|
# define LZO_EXTERN_CDECL(_rettype) __LZO_EXTERN_C LZO_PUBLIC_CDECL(_rettype)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* exported global variables (LZO currently uses no static variables and
|
||||||
|
* is fully thread safe) */
|
||||||
|
#if !defined(LZO_PUBLIC_VAR)
|
||||||
|
# define LZO_PUBLIC_VAR(_type) \
|
||||||
|
__LZO_EXPORT1 _type __LZO_EXPORT2 __LZO_DMODEL
|
||||||
|
#endif
|
||||||
|
#if !defined(LZO_EXTERN_VAR)
|
||||||
|
# define LZO_EXTERN_VAR(_type) extern LZO_PUBLIC_VAR(_type)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
// error codes and prototypes
|
||||||
|
************************************************************************/
|
||||||
|
|
||||||
|
/* Error codes for the compression/decompression functions. Negative
|
||||||
|
* values are errors, positive values will be used for special but
|
||||||
|
* normal events.
|
||||||
|
*/
|
||||||
|
#define LZO_E_OK 0
|
||||||
|
#define LZO_E_ERROR (-1)
|
||||||
|
#define LZO_E_OUT_OF_MEMORY (-2) /* not used right now */
|
||||||
|
#define LZO_E_NOT_COMPRESSIBLE (-3) /* not used right now */
|
||||||
|
#define LZO_E_INPUT_OVERRUN (-4)
|
||||||
|
#define LZO_E_OUTPUT_OVERRUN (-5)
|
||||||
|
#define LZO_E_LOOKBEHIND_OVERRUN (-6)
|
||||||
|
#define LZO_E_EOF_NOT_FOUND (-7)
|
||||||
|
#define LZO_E_INPUT_NOT_CONSUMED (-8)
|
||||||
|
|
||||||
|
|
||||||
|
/* lzo_init() should be the first function you call.
|
||||||
|
* Check the return code !
|
||||||
|
*
|
||||||
|
* lzo_init() is a macro to allow checking that the library and the
|
||||||
|
* compiler's view of various types are consistent.
|
||||||
|
*/
|
||||||
|
#define lzo_init() __lzo_init2(LZO_VERSION,(int)sizeof(short),(int)sizeof(int),\
|
||||||
|
(int)sizeof(long),(int)sizeof(lzo_uint32),(int)sizeof(lzo_uint),\
|
||||||
|
(int)lzo_sizeof_dict_t,(int)sizeof(char *),(int)sizeof(lzo_voidp),\
|
||||||
|
(int)sizeof(lzo_compress_t))
|
||||||
|
LZO_EXTERN(int) __lzo_init2(unsigned,int,int,int,int,int,int,int,int,int);
|
||||||
|
|
||||||
|
/* version functions (useful for shared libraries) */
|
||||||
|
LZO_EXTERN(unsigned) lzo_version(void);
|
||||||
|
LZO_EXTERN(const char *) lzo_version_string(void);
|
||||||
|
LZO_EXTERN(const char *) lzo_version_date(void);
|
||||||
|
LZO_EXTERN(const lzo_charp) _lzo_version_string(void);
|
||||||
|
LZO_EXTERN(const lzo_charp) _lzo_version_date(void);
|
||||||
|
|
||||||
|
/* string functions */
|
||||||
|
LZO_EXTERN(int)
|
||||||
|
lzo_memcmp(const lzo_voidp _s1, const lzo_voidp _s2, lzo_uint _len);
|
||||||
|
LZO_EXTERN(lzo_voidp)
|
||||||
|
lzo_memcpy(lzo_voidp _dest, const lzo_voidp _src, lzo_uint _len);
|
||||||
|
LZO_EXTERN(lzo_voidp)
|
||||||
|
lzo_memmove(lzo_voidp _dest, const lzo_voidp _src, lzo_uint _len);
|
||||||
|
LZO_EXTERN(lzo_voidp)
|
||||||
|
lzo_memset(lzo_voidp _s, int _c, lzo_uint _len);
|
||||||
|
|
||||||
|
/* checksum functions */
|
||||||
|
LZO_EXTERN(lzo_uint32)
|
||||||
|
lzo_adler32(lzo_uint32 _adler, const lzo_byte *_buf, lzo_uint _len);
|
||||||
|
LZO_EXTERN(lzo_uint32)
|
||||||
|
lzo_crc32(lzo_uint32 _c, const lzo_byte *_buf, lzo_uint _len);
|
||||||
|
|
||||||
|
/* misc. */
|
||||||
|
LZO_EXTERN(lzo_bool) lzo_assert(int _expr);
|
||||||
|
LZO_EXTERN(int) _lzo_config_check(void);
|
||||||
|
typedef union { lzo_bytep p; lzo_uint u; } __lzo_pu_u;
|
||||||
|
typedef union { lzo_bytep p; lzo_uint32 u32; } __lzo_pu32_u;
|
||||||
|
typedef union { void *vp; lzo_bytep bp; lzo_uint32 u32; long l; } lzo_align_t;
|
||||||
|
|
||||||
|
/* align a char pointer on a boundary that is a multiple of `size' */
|
||||||
|
LZO_EXTERN(unsigned) __lzo_align_gap(const lzo_voidp _ptr, lzo_uint _size);
|
||||||
|
#define LZO_PTR_ALIGN_UP(_ptr,_size) \
|
||||||
|
((_ptr) + (lzo_uint) __lzo_align_gap((const lzo_voidp)(_ptr),(lzo_uint)(_size)))
|
||||||
|
|
||||||
|
/* deprecated - only for backward compatibility */
|
||||||
|
#define LZO_ALIGN(_ptr,_size) LZO_PTR_ALIGN_UP(_ptr,_size)
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} /* extern "C" */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* already included */
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,100 @@
|
|||||||
|
/* minilzo.h -- mini subset of the LZO real-time data compression library
|
||||||
|
|
||||||
|
This file is part of the LZO real-time data compression library.
|
||||||
|
|
||||||
|
Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
|
||||||
|
Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
|
||||||
|
Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
|
||||||
|
Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
|
||||||
|
Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
|
||||||
|
Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
|
||||||
|
Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
|
||||||
|
All Rights Reserved.
|
||||||
|
|
||||||
|
The LZO library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License as
|
||||||
|
published by the Free Software Foundation; either version 2 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
The LZO library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with the LZO library; see the file COPYING.
|
||||||
|
If not, write to the Free Software Foundation, Inc.,
|
||||||
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
Markus F.X.J. Oberhumer
|
||||||
|
<markus@oberhumer.com>
|
||||||
|
http://www.oberhumer.com/opensource/lzo/
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NOTE:
|
||||||
|
* the full LZO package can be found at
|
||||||
|
* http://www.oberhumer.com/opensource/lzo/
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef __MINILZO_H
|
||||||
|
#define __MINILZO_H
|
||||||
|
|
||||||
|
#define MINILZO_VERSION 0x1080
|
||||||
|
|
||||||
|
#ifdef __LZOCONF_H
|
||||||
|
# error "you cannot use both LZO and miniLZO"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#undef LZO_HAVE_CONFIG_H
|
||||||
|
#include "lzoconf.h"
|
||||||
|
|
||||||
|
#if !defined(LZO_VERSION) || (LZO_VERSION != MINILZO_VERSION)
|
||||||
|
# error "version mismatch in header files"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
//
|
||||||
|
************************************************************************/
|
||||||
|
|
||||||
|
/* Memory required for the wrkmem parameter.
|
||||||
|
* When the required size is 0, you can also pass a NULL pointer.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define LZO1X_MEM_COMPRESS LZO1X_1_MEM_COMPRESS
|
||||||
|
#define LZO1X_1_MEM_COMPRESS ((lzo_uint32) (16384L * lzo_sizeof_dict_t))
|
||||||
|
#define LZO1X_MEM_DECOMPRESS (0)
|
||||||
|
|
||||||
|
|
||||||
|
/* compression */
|
||||||
|
LZO_EXTERN(int)
|
||||||
|
lzo1x_1_compress ( const lzo_byte *src, lzo_uint src_len,
|
||||||
|
lzo_byte *dst, lzo_uintp dst_len,
|
||||||
|
lzo_voidp wrkmem );
|
||||||
|
|
||||||
|
/* decompression */
|
||||||
|
LZO_EXTERN(int)
|
||||||
|
lzo1x_decompress ( const lzo_byte *src, lzo_uint src_len,
|
||||||
|
lzo_byte *dst, lzo_uintp dst_len,
|
||||||
|
lzo_voidp wrkmem /* NOT USED */ );
|
||||||
|
|
||||||
|
/* safe decompression with overrun testing */
|
||||||
|
LZO_EXTERN(int)
|
||||||
|
lzo1x_decompress_safe ( const lzo_byte *src, lzo_uint src_len,
|
||||||
|
lzo_byte *dst, lzo_uintp dst_len,
|
||||||
|
lzo_voidp wrkmem /* NOT USED */ );
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} /* extern "C" */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* already included */
|
||||||
|
|
@ -0,0 +1,214 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2000 Tridia Corporation. All Rights Reserved.
|
||||||
|
* Copyright (C) 1999 AT&T Laboratories Cambridge. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* This is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this software; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
||||||
|
* USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef LIBVNCSERVER_HAVE_LIBZ
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ultrazip.c - handle ultrazip encoding.
|
||||||
|
*
|
||||||
|
* This file shouldn't be compiled directly. It is included multiple times by
|
||||||
|
* rfbproto.c, each time with a different definition of the macro BPP. For
|
||||||
|
* each value of BPP, this file defines a function which handles an zlib
|
||||||
|
* encoded rectangle with BPP bits per pixel.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define HandleUltraZipBPP CONCAT2E(HandleUltraZip,BPP)
|
||||||
|
#define HandleUltraBPP CONCAT2E(HandleUltra,BPP)
|
||||||
|
#define CARDBPP CONCAT3E(uint,BPP,_t)
|
||||||
|
|
||||||
|
static rfbBool
|
||||||
|
HandleUltraBPP (rfbClient* client, int rx, int ry, int rw, int rh)
|
||||||
|
{
|
||||||
|
rfbZlibHeader hdr;
|
||||||
|
int toRead=0;
|
||||||
|
int inflateResult=0;
|
||||||
|
int uncompressedBytes = (( rw * rh ) * ( BPP / 8 ));
|
||||||
|
|
||||||
|
if (!ReadFromRFBServer(client, (char *)&hdr, sz_rfbZlibHeader))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
toRead = rfbClientSwap32IfLE(hdr.nBytes);
|
||||||
|
if (toRead==0) return TRUE;
|
||||||
|
|
||||||
|
if (uncompressedBytes==0)
|
||||||
|
{
|
||||||
|
rfbClientLog("ultra error: rectangle has 0 uncomressed bytes ((%dw * %dh) * (%d / 8))\n", rw, rh, BPP);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* First make sure we have a large enough raw buffer to hold the
|
||||||
|
* decompressed data. In practice, with a fixed BPP, fixed frame
|
||||||
|
* buffer size and the first update containing the entire frame
|
||||||
|
* buffer, this buffer allocation should only happen once, on the
|
||||||
|
* first update.
|
||||||
|
*/
|
||||||
|
if ( client->raw_buffer_size < uncompressedBytes) {
|
||||||
|
if ( client->raw_buffer != NULL ) {
|
||||||
|
free( client->raw_buffer );
|
||||||
|
}
|
||||||
|
client->raw_buffer_size = uncompressedBytes;
|
||||||
|
/* buffer needs to be aligned on 4-byte boundaries */
|
||||||
|
if ((client->raw_buffer_size % 4)!=0)
|
||||||
|
client->raw_buffer_size += (4-(client->raw_buffer_size % 4));
|
||||||
|
client->raw_buffer = (char*) malloc( client->raw_buffer_size );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* allocate enough space to store the incoming compressed packet */
|
||||||
|
if ( client->ultra_buffer_size < toRead ) {
|
||||||
|
if ( client->ultra_buffer != NULL ) {
|
||||||
|
free( client->ultra_buffer );
|
||||||
|
}
|
||||||
|
client->ultra_buffer_size = toRead;
|
||||||
|
/* buffer needs to be aligned on 4-byte boundaries */
|
||||||
|
if ((client->ultra_buffer_size % 4)!=0)
|
||||||
|
client->ultra_buffer_size += (4-(client->ultra_buffer_size % 4));
|
||||||
|
client->ultra_buffer = (char*) malloc( client->ultra_buffer_size );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Fill the buffer, obtaining data from the server. */
|
||||||
|
if (!ReadFromRFBServer(client, client->ultra_buffer, toRead))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
/* uncompress the data */
|
||||||
|
uncompressedBytes = client->raw_buffer_size;
|
||||||
|
inflateResult = lzo1x_decompress(
|
||||||
|
(lzo_byte *)client->ultra_buffer, toRead,
|
||||||
|
(lzo_byte *)client->raw_buffer, (lzo_uintp) &uncompressedBytes,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
|
||||||
|
if ((rw * rh * (BPP / 8)) != uncompressedBytes)
|
||||||
|
rfbClientLog("Ultra decompressed too little (%d < %d)", (rw * rh * (BPP / 8)), uncompressedBytes);
|
||||||
|
|
||||||
|
/* Put the uncompressed contents of the update on the screen. */
|
||||||
|
if ( inflateResult == LZO_E_OK )
|
||||||
|
{
|
||||||
|
CopyRectangle(client, (unsigned char *)client->raw_buffer, rx, ry, rw, rh);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rfbClientLog("ultra decompress returned error: %d\n",
|
||||||
|
inflateResult);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* UltraZip is like rre in that it is composed of subrects */
|
||||||
|
static rfbBool
|
||||||
|
HandleUltraZipBPP (rfbClient* client, int rx, int ry, int rw, int rh)
|
||||||
|
{
|
||||||
|
rfbZlibHeader hdr;
|
||||||
|
int i=0;
|
||||||
|
int toRead=0;
|
||||||
|
int inflateResult=0;
|
||||||
|
unsigned char *ptr=NULL;
|
||||||
|
int uncompressedBytes = ry + (rw * 65535);
|
||||||
|
unsigned int numCacheRects = rx;
|
||||||
|
|
||||||
|
if (!ReadFromRFBServer(client, (char *)&hdr, sz_rfbZlibHeader))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
toRead = rfbClientSwap32IfLE(hdr.nBytes);
|
||||||
|
|
||||||
|
if (toRead==0) return TRUE;
|
||||||
|
|
||||||
|
if (uncompressedBytes==0)
|
||||||
|
{
|
||||||
|
rfbClientLog("ultrazip error: rectangle has 0 uncomressed bytes (%dy + (%dw * 65535)) (%d rectangles)\n", ry, rw, rx);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* First make sure we have a large enough raw buffer to hold the
|
||||||
|
* decompressed data. In practice, with a fixed BPP, fixed frame
|
||||||
|
* buffer size and the first update containing the entire frame
|
||||||
|
* buffer, this buffer allocation should only happen once, on the
|
||||||
|
* first update.
|
||||||
|
*/
|
||||||
|
if ( client->raw_buffer_size < (uncompressedBytes + 500)) {
|
||||||
|
if ( client->raw_buffer != NULL ) {
|
||||||
|
free( client->raw_buffer );
|
||||||
|
}
|
||||||
|
client->raw_buffer_size = uncompressedBytes + 500;
|
||||||
|
/* buffer needs to be aligned on 4-byte boundaries */
|
||||||
|
if ((client->raw_buffer_size % 4)!=0)
|
||||||
|
client->raw_buffer_size += (4-(client->raw_buffer_size % 4));
|
||||||
|
client->raw_buffer = (char*) malloc( client->raw_buffer_size );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* allocate enough space to store the incoming compressed packet */
|
||||||
|
if ( client->ultra_buffer_size < toRead ) {
|
||||||
|
if ( client->ultra_buffer != NULL ) {
|
||||||
|
free( client->ultra_buffer );
|
||||||
|
}
|
||||||
|
client->ultra_buffer_size = toRead;
|
||||||
|
client->ultra_buffer = (char*) malloc( client->ultra_buffer_size );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Fill the buffer, obtaining data from the server. */
|
||||||
|
if (!ReadFromRFBServer(client, client->ultra_buffer, toRead))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
/* uncompress the data */
|
||||||
|
uncompressedBytes = client->raw_buffer_size;
|
||||||
|
inflateResult = lzo1x_decompress(
|
||||||
|
(lzo_byte *)client->ultra_buffer, toRead,
|
||||||
|
(lzo_byte *)client->raw_buffer, (lzo_uintp) &uncompressedBytes, NULL);
|
||||||
|
if ( inflateResult != LZO_E_OK )
|
||||||
|
{
|
||||||
|
rfbClientLog("ultra decompress returned error: %d\n",
|
||||||
|
inflateResult);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Put the uncompressed contents of the update on the screen. */
|
||||||
|
ptr = (unsigned char *)client->raw_buffer;
|
||||||
|
for (i=0; i<numCacheRects; i++)
|
||||||
|
{
|
||||||
|
unsigned short sx, sy, sw, sh;
|
||||||
|
unsigned int se;
|
||||||
|
|
||||||
|
memcpy((char *)&sx, ptr, 2); ptr += 2;
|
||||||
|
memcpy((char *)&sy, ptr, 2); ptr += 2;
|
||||||
|
memcpy((char *)&sw, ptr, 2); ptr += 2;
|
||||||
|
memcpy((char *)&sh, ptr, 2); ptr += 2;
|
||||||
|
memcpy((char *)&se, ptr, 4); ptr += 4;
|
||||||
|
|
||||||
|
sx = rfbClientSwap16IfLE(sx);
|
||||||
|
sy = rfbClientSwap16IfLE(sy);
|
||||||
|
sw = rfbClientSwap16IfLE(sw);
|
||||||
|
sh = rfbClientSwap16IfLE(sh);
|
||||||
|
se = rfbClientSwap32IfLE(se);
|
||||||
|
|
||||||
|
if (se == rfbEncodingRaw)
|
||||||
|
{
|
||||||
|
CopyRectangle(client, (unsigned char *)ptr, sx, sy, sw, sh);
|
||||||
|
ptr += ((sw * sh) * (BPP / 8));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef CARDBPP
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,451 @@
|
|||||||
|
/* lzoconf.h -- configuration for the LZO real-time data compression library
|
||||||
|
|
||||||
|
This file is part of the LZO real-time data compression library.
|
||||||
|
|
||||||
|
Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
|
||||||
|
Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
|
||||||
|
Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
|
||||||
|
Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
|
||||||
|
Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
|
||||||
|
Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
|
||||||
|
Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
|
||||||
|
All Rights Reserved.
|
||||||
|
|
||||||
|
The LZO library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License as
|
||||||
|
published by the Free Software Foundation; either version 2 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
The LZO library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with the LZO library; see the file COPYING.
|
||||||
|
If not, write to the Free Software Foundation, Inc.,
|
||||||
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
Markus F.X.J. Oberhumer
|
||||||
|
<markus@oberhumer.com>
|
||||||
|
http://www.oberhumer.com/opensource/lzo/
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef __LZOCONF_H
|
||||||
|
#define __LZOCONF_H
|
||||||
|
|
||||||
|
#define LZO_VERSION 0x1080
|
||||||
|
#define LZO_VERSION_STRING "1.08"
|
||||||
|
#define LZO_VERSION_DATE "Jul 12 2002"
|
||||||
|
|
||||||
|
/* internal Autoconf configuration file - only used when building LZO */
|
||||||
|
#if defined(LZO_HAVE_CONFIG_H)
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
// LZO requires a conforming <limits.h>
|
||||||
|
************************************************************************/
|
||||||
|
|
||||||
|
#if !defined(CHAR_BIT) || (CHAR_BIT != 8)
|
||||||
|
# error "invalid CHAR_BIT"
|
||||||
|
#endif
|
||||||
|
#if !defined(UCHAR_MAX) || !defined(UINT_MAX) || !defined(ULONG_MAX)
|
||||||
|
# error "check your compiler installation"
|
||||||
|
#endif
|
||||||
|
#if (USHRT_MAX < 1) || (UINT_MAX < 1) || (ULONG_MAX < 1)
|
||||||
|
# error "your limits.h macros are broken"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* workaround a cpp bug under hpux 10.20 */
|
||||||
|
#define LZO_0xffffffffL 4294967295ul
|
||||||
|
|
||||||
|
#if !defined(LZO_UINT32_C)
|
||||||
|
# if (UINT_MAX < LZO_0xffffffffL)
|
||||||
|
# define LZO_UINT32_C(c) c ## UL
|
||||||
|
# else
|
||||||
|
# define LZO_UINT32_C(c) c ## U
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
// architecture defines
|
||||||
|
************************************************************************/
|
||||||
|
|
||||||
|
#if !defined(__LZO_WIN) && !defined(__LZO_DOS) && !defined(__LZO_OS2)
|
||||||
|
# if defined(__WINDOWS__) || defined(_WINDOWS) || defined(_Windows)
|
||||||
|
# define __LZO_WIN
|
||||||
|
# elif defined(__WIN32__) || defined(_WIN32) || defined(WIN32)
|
||||||
|
# define __LZO_WIN
|
||||||
|
# elif defined(__NT__) || defined(__NT_DLL__) || defined(__WINDOWS_386__)
|
||||||
|
# define __LZO_WIN
|
||||||
|
# elif defined(__DOS__) || defined(__MSDOS__) || defined(MSDOS)
|
||||||
|
# define __LZO_DOS
|
||||||
|
# elif defined(__OS2__) || defined(__OS2V2__) || defined(OS2)
|
||||||
|
# define __LZO_OS2
|
||||||
|
# elif defined(__palmos__)
|
||||||
|
# define __LZO_PALMOS
|
||||||
|
# elif defined(__TOS__) || defined(__atarist__)
|
||||||
|
# define __LZO_TOS
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (UINT_MAX < LZO_0xffffffffL)
|
||||||
|
# if defined(__LZO_WIN)
|
||||||
|
# define __LZO_WIN16
|
||||||
|
# elif defined(__LZO_DOS)
|
||||||
|
# define __LZO_DOS16
|
||||||
|
# elif defined(__LZO_PALMOS)
|
||||||
|
# define __LZO_PALMOS16
|
||||||
|
# elif defined(__LZO_TOS)
|
||||||
|
# define __LZO_TOS16
|
||||||
|
# elif defined(__C166__)
|
||||||
|
# else
|
||||||
|
/* porting hint: for pure 16-bit architectures try compiling
|
||||||
|
* everything with -D__LZO_STRICT_16BIT */
|
||||||
|
# error "16-bit target not supported - contact me for porting hints"
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined(__LZO_i386)
|
||||||
|
# if defined(__LZO_DOS) || defined(__LZO_WIN16)
|
||||||
|
# define __LZO_i386
|
||||||
|
# elif defined(__i386__) || defined(__386__) || defined(_M_IX86)
|
||||||
|
# define __LZO_i386
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__LZO_STRICT_16BIT)
|
||||||
|
# if (UINT_MAX < LZO_0xffffffffL)
|
||||||
|
# include <lzo16bit.h>
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* memory checkers */
|
||||||
|
#if !defined(__LZO_CHECKER)
|
||||||
|
# if defined(__BOUNDS_CHECKING_ON)
|
||||||
|
# define __LZO_CHECKER
|
||||||
|
# elif defined(__CHECKER__)
|
||||||
|
# define __LZO_CHECKER
|
||||||
|
# elif defined(__INSURE__)
|
||||||
|
# define __LZO_CHECKER
|
||||||
|
# elif defined(__PURIFY__)
|
||||||
|
# define __LZO_CHECKER
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
// integral and pointer types
|
||||||
|
************************************************************************/
|
||||||
|
|
||||||
|
/* Integral types with 32 bits or more */
|
||||||
|
#if !defined(LZO_UINT32_MAX)
|
||||||
|
# if (UINT_MAX >= LZO_0xffffffffL)
|
||||||
|
typedef unsigned int lzo_uint32;
|
||||||
|
typedef int lzo_int32;
|
||||||
|
# define LZO_UINT32_MAX UINT_MAX
|
||||||
|
# define LZO_INT32_MAX INT_MAX
|
||||||
|
# define LZO_INT32_MIN INT_MIN
|
||||||
|
# elif (ULONG_MAX >= LZO_0xffffffffL)
|
||||||
|
typedef unsigned long lzo_uint32;
|
||||||
|
typedef long lzo_int32;
|
||||||
|
# define LZO_UINT32_MAX ULONG_MAX
|
||||||
|
# define LZO_INT32_MAX LONG_MAX
|
||||||
|
# define LZO_INT32_MIN LONG_MIN
|
||||||
|
# else
|
||||||
|
# error "lzo_uint32"
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* lzo_uint is used like size_t */
|
||||||
|
#if !defined(LZO_UINT_MAX)
|
||||||
|
# if (UINT_MAX >= LZO_0xffffffffL)
|
||||||
|
typedef unsigned int lzo_uint;
|
||||||
|
typedef int lzo_int;
|
||||||
|
# define LZO_UINT_MAX UINT_MAX
|
||||||
|
# define LZO_INT_MAX INT_MAX
|
||||||
|
# define LZO_INT_MIN INT_MIN
|
||||||
|
# elif (ULONG_MAX >= LZO_0xffffffffL)
|
||||||
|
typedef unsigned long lzo_uint;
|
||||||
|
typedef long lzo_int;
|
||||||
|
# define LZO_UINT_MAX ULONG_MAX
|
||||||
|
# define LZO_INT_MAX LONG_MAX
|
||||||
|
# define LZO_INT_MIN LONG_MIN
|
||||||
|
# else
|
||||||
|
# error "lzo_uint"
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef int lzo_bool;
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
// memory models
|
||||||
|
************************************************************************/
|
||||||
|
|
||||||
|
/* Memory model for the public code segment. */
|
||||||
|
#if !defined(__LZO_CMODEL)
|
||||||
|
# if defined(__LZO_DOS16) || defined(__LZO_WIN16)
|
||||||
|
# define __LZO_CMODEL __far
|
||||||
|
# elif defined(__LZO_i386) && defined(__WATCOMC__)
|
||||||
|
# define __LZO_CMODEL __near
|
||||||
|
# else
|
||||||
|
# define __LZO_CMODEL
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Memory model for the public data segment. */
|
||||||
|
#if !defined(__LZO_DMODEL)
|
||||||
|
# if defined(__LZO_DOS16) || defined(__LZO_WIN16)
|
||||||
|
# define __LZO_DMODEL __far
|
||||||
|
# elif defined(__LZO_i386) && defined(__WATCOMC__)
|
||||||
|
# define __LZO_DMODEL __near
|
||||||
|
# else
|
||||||
|
# define __LZO_DMODEL
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Memory model that allows to access memory at offsets of lzo_uint. */
|
||||||
|
#if !defined(__LZO_MMODEL)
|
||||||
|
# if (LZO_UINT_MAX <= UINT_MAX)
|
||||||
|
# define __LZO_MMODEL
|
||||||
|
# elif defined(__LZO_DOS16) || defined(__LZO_WIN16)
|
||||||
|
# define __LZO_MMODEL __huge
|
||||||
|
# define LZO_999_UNSUPPORTED
|
||||||
|
# elif defined(__LZO_PALMOS16) || defined(__LZO_TOS16)
|
||||||
|
# define __LZO_MMODEL
|
||||||
|
# else
|
||||||
|
# error "__LZO_MMODEL"
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* no typedef here because of const-pointer issues */
|
||||||
|
#define lzo_byte unsigned char __LZO_MMODEL
|
||||||
|
#define lzo_bytep unsigned char __LZO_MMODEL *
|
||||||
|
#define lzo_charp char __LZO_MMODEL *
|
||||||
|
#define lzo_voidp void __LZO_MMODEL *
|
||||||
|
#define lzo_shortp short __LZO_MMODEL *
|
||||||
|
#define lzo_ushortp unsigned short __LZO_MMODEL *
|
||||||
|
#define lzo_uint32p lzo_uint32 __LZO_MMODEL *
|
||||||
|
#define lzo_int32p lzo_int32 __LZO_MMODEL *
|
||||||
|
#define lzo_uintp lzo_uint __LZO_MMODEL *
|
||||||
|
#define lzo_intp lzo_int __LZO_MMODEL *
|
||||||
|
#define lzo_voidpp lzo_voidp __LZO_MMODEL *
|
||||||
|
#define lzo_bytepp lzo_bytep __LZO_MMODEL *
|
||||||
|
|
||||||
|
#ifndef lzo_sizeof_dict_t
|
||||||
|
# define lzo_sizeof_dict_t sizeof(lzo_bytep)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
// calling conventions and function types
|
||||||
|
************************************************************************/
|
||||||
|
|
||||||
|
/* linkage */
|
||||||
|
#if !defined(__LZO_EXTERN_C)
|
||||||
|
# ifdef __cplusplus
|
||||||
|
# define __LZO_EXTERN_C extern "C"
|
||||||
|
# else
|
||||||
|
# define __LZO_EXTERN_C extern
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* calling convention */
|
||||||
|
#if !defined(__LZO_CDECL)
|
||||||
|
# if defined(__LZO_DOS16) || defined(__LZO_WIN16)
|
||||||
|
# define __LZO_CDECL __LZO_CMODEL __cdecl
|
||||||
|
# elif defined(__LZO_i386) && defined(_MSC_VER)
|
||||||
|
# define __LZO_CDECL __LZO_CMODEL __cdecl
|
||||||
|
# elif defined(__LZO_i386) && defined(__WATCOMC__)
|
||||||
|
# define __LZO_CDECL __LZO_CMODEL __cdecl
|
||||||
|
# else
|
||||||
|
# define __LZO_CDECL __LZO_CMODEL
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
#if !defined(__LZO_ENTRY)
|
||||||
|
# define __LZO_ENTRY __LZO_CDECL
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* C++ exception specification for extern "C" function types */
|
||||||
|
#if !defined(__cplusplus)
|
||||||
|
# undef LZO_NOTHROW
|
||||||
|
# define LZO_NOTHROW
|
||||||
|
#elif !defined(LZO_NOTHROW)
|
||||||
|
# define LZO_NOTHROW
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
typedef int
|
||||||
|
(__LZO_ENTRY *lzo_compress_t) ( const lzo_byte *src, lzo_uint src_len,
|
||||||
|
lzo_byte *dst, lzo_uintp dst_len,
|
||||||
|
lzo_voidp wrkmem );
|
||||||
|
|
||||||
|
typedef int
|
||||||
|
(__LZO_ENTRY *lzo_decompress_t) ( const lzo_byte *src, lzo_uint src_len,
|
||||||
|
lzo_byte *dst, lzo_uintp dst_len,
|
||||||
|
lzo_voidp wrkmem );
|
||||||
|
|
||||||
|
typedef int
|
||||||
|
(__LZO_ENTRY *lzo_optimize_t) ( lzo_byte *src, lzo_uint src_len,
|
||||||
|
lzo_byte *dst, lzo_uintp dst_len,
|
||||||
|
lzo_voidp wrkmem );
|
||||||
|
|
||||||
|
typedef int
|
||||||
|
(__LZO_ENTRY *lzo_compress_dict_t)(const lzo_byte *src, lzo_uint src_len,
|
||||||
|
lzo_byte *dst, lzo_uintp dst_len,
|
||||||
|
lzo_voidp wrkmem,
|
||||||
|
const lzo_byte *dict, lzo_uint dict_len );
|
||||||
|
|
||||||
|
typedef int
|
||||||
|
(__LZO_ENTRY *lzo_decompress_dict_t)(const lzo_byte *src, lzo_uint src_len,
|
||||||
|
lzo_byte *dst, lzo_uintp dst_len,
|
||||||
|
lzo_voidp wrkmem,
|
||||||
|
const lzo_byte *dict, lzo_uint dict_len );
|
||||||
|
|
||||||
|
|
||||||
|
/* assembler versions always use __cdecl */
|
||||||
|
typedef int
|
||||||
|
(__LZO_CDECL *lzo_compress_asm_t)( const lzo_byte *src, lzo_uint src_len,
|
||||||
|
lzo_byte *dst, lzo_uintp dst_len,
|
||||||
|
lzo_voidp wrkmem );
|
||||||
|
|
||||||
|
typedef int
|
||||||
|
(__LZO_CDECL *lzo_decompress_asm_t)( const lzo_byte *src, lzo_uint src_len,
|
||||||
|
lzo_byte *dst, lzo_uintp dst_len,
|
||||||
|
lzo_voidp wrkmem );
|
||||||
|
|
||||||
|
|
||||||
|
/* a progress indicator callback function */
|
||||||
|
typedef void (__LZO_ENTRY *lzo_progress_callback_t) (lzo_uint, lzo_uint);
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
// export information
|
||||||
|
************************************************************************/
|
||||||
|
|
||||||
|
/* DLL export information */
|
||||||
|
#if !defined(__LZO_EXPORT1)
|
||||||
|
# define __LZO_EXPORT1
|
||||||
|
#endif
|
||||||
|
#if !defined(__LZO_EXPORT2)
|
||||||
|
# define __LZO_EXPORT2
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* exported calling convention for C functions */
|
||||||
|
#if !defined(LZO_PUBLIC)
|
||||||
|
# define LZO_PUBLIC(_rettype) \
|
||||||
|
__LZO_EXPORT1 _rettype __LZO_EXPORT2 __LZO_ENTRY
|
||||||
|
#endif
|
||||||
|
#if !defined(LZO_EXTERN)
|
||||||
|
# define LZO_EXTERN(_rettype) __LZO_EXTERN_C LZO_PUBLIC(_rettype)
|
||||||
|
#endif
|
||||||
|
#if !defined(LZO_PRIVATE)
|
||||||
|
# define LZO_PRIVATE(_rettype) static _rettype __LZO_ENTRY
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* exported __cdecl calling convention for assembler functions */
|
||||||
|
#if !defined(LZO_PUBLIC_CDECL)
|
||||||
|
# define LZO_PUBLIC_CDECL(_rettype) \
|
||||||
|
__LZO_EXPORT1 _rettype __LZO_EXPORT2 __LZO_CDECL
|
||||||
|
#endif
|
||||||
|
#if !defined(LZO_EXTERN_CDECL)
|
||||||
|
# define LZO_EXTERN_CDECL(_rettype) __LZO_EXTERN_C LZO_PUBLIC_CDECL(_rettype)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* exported global variables (LZO currently uses no static variables and
|
||||||
|
* is fully thread safe) */
|
||||||
|
#if !defined(LZO_PUBLIC_VAR)
|
||||||
|
# define LZO_PUBLIC_VAR(_type) \
|
||||||
|
__LZO_EXPORT1 _type __LZO_EXPORT2 __LZO_DMODEL
|
||||||
|
#endif
|
||||||
|
#if !defined(LZO_EXTERN_VAR)
|
||||||
|
# define LZO_EXTERN_VAR(_type) extern LZO_PUBLIC_VAR(_type)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
// error codes and prototypes
|
||||||
|
************************************************************************/
|
||||||
|
|
||||||
|
/* Error codes for the compression/decompression functions. Negative
|
||||||
|
* values are errors, positive values will be used for special but
|
||||||
|
* normal events.
|
||||||
|
*/
|
||||||
|
#define LZO_E_OK 0
|
||||||
|
#define LZO_E_ERROR (-1)
|
||||||
|
#define LZO_E_OUT_OF_MEMORY (-2) /* not used right now */
|
||||||
|
#define LZO_E_NOT_COMPRESSIBLE (-3) /* not used right now */
|
||||||
|
#define LZO_E_INPUT_OVERRUN (-4)
|
||||||
|
#define LZO_E_OUTPUT_OVERRUN (-5)
|
||||||
|
#define LZO_E_LOOKBEHIND_OVERRUN (-6)
|
||||||
|
#define LZO_E_EOF_NOT_FOUND (-7)
|
||||||
|
#define LZO_E_INPUT_NOT_CONSUMED (-8)
|
||||||
|
|
||||||
|
|
||||||
|
/* lzo_init() should be the first function you call.
|
||||||
|
* Check the return code !
|
||||||
|
*
|
||||||
|
* lzo_init() is a macro to allow checking that the library and the
|
||||||
|
* compiler's view of various types are consistent.
|
||||||
|
*/
|
||||||
|
#define lzo_init() __lzo_init2(LZO_VERSION,(int)sizeof(short),(int)sizeof(int),\
|
||||||
|
(int)sizeof(long),(int)sizeof(lzo_uint32),(int)sizeof(lzo_uint),\
|
||||||
|
(int)lzo_sizeof_dict_t,(int)sizeof(char *),(int)sizeof(lzo_voidp),\
|
||||||
|
(int)sizeof(lzo_compress_t))
|
||||||
|
LZO_EXTERN(int) __lzo_init2(unsigned,int,int,int,int,int,int,int,int,int);
|
||||||
|
|
||||||
|
/* version functions (useful for shared libraries) */
|
||||||
|
LZO_EXTERN(unsigned) lzo_version(void);
|
||||||
|
LZO_EXTERN(const char *) lzo_version_string(void);
|
||||||
|
LZO_EXTERN(const char *) lzo_version_date(void);
|
||||||
|
LZO_EXTERN(const lzo_charp) _lzo_version_string(void);
|
||||||
|
LZO_EXTERN(const lzo_charp) _lzo_version_date(void);
|
||||||
|
|
||||||
|
/* string functions */
|
||||||
|
LZO_EXTERN(int)
|
||||||
|
lzo_memcmp(const lzo_voidp _s1, const lzo_voidp _s2, lzo_uint _len);
|
||||||
|
LZO_EXTERN(lzo_voidp)
|
||||||
|
lzo_memcpy(lzo_voidp _dest, const lzo_voidp _src, lzo_uint _len);
|
||||||
|
LZO_EXTERN(lzo_voidp)
|
||||||
|
lzo_memmove(lzo_voidp _dest, const lzo_voidp _src, lzo_uint _len);
|
||||||
|
LZO_EXTERN(lzo_voidp)
|
||||||
|
lzo_memset(lzo_voidp _s, int _c, lzo_uint _len);
|
||||||
|
|
||||||
|
/* checksum functions */
|
||||||
|
LZO_EXTERN(lzo_uint32)
|
||||||
|
lzo_adler32(lzo_uint32 _adler, const lzo_byte *_buf, lzo_uint _len);
|
||||||
|
LZO_EXTERN(lzo_uint32)
|
||||||
|
lzo_crc32(lzo_uint32 _c, const lzo_byte *_buf, lzo_uint _len);
|
||||||
|
|
||||||
|
/* misc. */
|
||||||
|
LZO_EXTERN(lzo_bool) lzo_assert(int _expr);
|
||||||
|
LZO_EXTERN(int) _lzo_config_check(void);
|
||||||
|
typedef union { lzo_bytep p; lzo_uint u; } __lzo_pu_u;
|
||||||
|
typedef union { lzo_bytep p; lzo_uint32 u32; } __lzo_pu32_u;
|
||||||
|
typedef union { void *vp; lzo_bytep bp; lzo_uint32 u32; long l; } lzo_align_t;
|
||||||
|
|
||||||
|
/* align a char pointer on a boundary that is a multiple of `size' */
|
||||||
|
LZO_EXTERN(unsigned) __lzo_align_gap(const lzo_voidp _ptr, lzo_uint _size);
|
||||||
|
#define LZO_PTR_ALIGN_UP(_ptr,_size) \
|
||||||
|
((_ptr) + (lzo_uint) __lzo_align_gap((const lzo_voidp)(_ptr),(lzo_uint)(_size)))
|
||||||
|
|
||||||
|
/* deprecated - only for backward compatibility */
|
||||||
|
#define LZO_ALIGN(_ptr,_size) LZO_PTR_ALIGN_UP(_ptr,_size)
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} /* extern "C" */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* already included */
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,100 @@
|
|||||||
|
/* minilzo.h -- mini subset of the LZO real-time data compression library
|
||||||
|
|
||||||
|
This file is part of the LZO real-time data compression library.
|
||||||
|
|
||||||
|
Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
|
||||||
|
Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
|
||||||
|
Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
|
||||||
|
Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
|
||||||
|
Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
|
||||||
|
Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
|
||||||
|
Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
|
||||||
|
All Rights Reserved.
|
||||||
|
|
||||||
|
The LZO library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License as
|
||||||
|
published by the Free Software Foundation; either version 2 of
|
||||||
|
the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
The LZO library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with the LZO library; see the file COPYING.
|
||||||
|
If not, write to the Free Software Foundation, Inc.,
|
||||||
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
Markus F.X.J. Oberhumer
|
||||||
|
<markus@oberhumer.com>
|
||||||
|
http://www.oberhumer.com/opensource/lzo/
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NOTE:
|
||||||
|
* the full LZO package can be found at
|
||||||
|
* http://www.oberhumer.com/opensource/lzo/
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef __MINILZO_H
|
||||||
|
#define __MINILZO_H
|
||||||
|
|
||||||
|
#define MINILZO_VERSION 0x1080
|
||||||
|
|
||||||
|
#ifdef __LZOCONF_H
|
||||||
|
# error "you cannot use both LZO and miniLZO"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#undef LZO_HAVE_CONFIG_H
|
||||||
|
#include "lzoconf.h"
|
||||||
|
|
||||||
|
#if !defined(LZO_VERSION) || (LZO_VERSION != MINILZO_VERSION)
|
||||||
|
# error "version mismatch in header files"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
//
|
||||||
|
************************************************************************/
|
||||||
|
|
||||||
|
/* Memory required for the wrkmem parameter.
|
||||||
|
* When the required size is 0, you can also pass a NULL pointer.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define LZO1X_MEM_COMPRESS LZO1X_1_MEM_COMPRESS
|
||||||
|
#define LZO1X_1_MEM_COMPRESS ((lzo_uint32) (16384L * lzo_sizeof_dict_t))
|
||||||
|
#define LZO1X_MEM_DECOMPRESS (0)
|
||||||
|
|
||||||
|
|
||||||
|
/* compression */
|
||||||
|
LZO_EXTERN(int)
|
||||||
|
lzo1x_1_compress ( const lzo_byte *src, lzo_uint src_len,
|
||||||
|
lzo_byte *dst, lzo_uintp dst_len,
|
||||||
|
lzo_voidp wrkmem );
|
||||||
|
|
||||||
|
/* decompression */
|
||||||
|
LZO_EXTERN(int)
|
||||||
|
lzo1x_decompress ( const lzo_byte *src, lzo_uint src_len,
|
||||||
|
lzo_byte *dst, lzo_uintp dst_len,
|
||||||
|
lzo_voidp wrkmem /* NOT USED */ );
|
||||||
|
|
||||||
|
/* safe decompression with overrun testing */
|
||||||
|
LZO_EXTERN(int)
|
||||||
|
lzo1x_decompress_safe ( const lzo_byte *src, lzo_uint src_len,
|
||||||
|
lzo_byte *dst, lzo_uintp dst_len,
|
||||||
|
lzo_voidp wrkmem /* NOT USED */ );
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} /* extern "C" */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* already included */
|
||||||
|
|
@ -0,0 +1,229 @@
|
|||||||
|
/*
|
||||||
|
* ultra.c
|
||||||
|
*
|
||||||
|
* Routines to implement ultra based encoding (minilzo).
|
||||||
|
* ultrazip supports packed rectangles if the rects are tiny...
|
||||||
|
* This improves performance as lzo has more data to work with at once
|
||||||
|
* This is 'UltraZip' and is currently not implemented.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <rfb/rfb.h>
|
||||||
|
#include "minilzo.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* lzoBeforeBuf contains pixel data in the client's format.
|
||||||
|
* lzoAfterBuf contains the lzo (deflated) encoding version.
|
||||||
|
* If the lzo compressed/encoded version is
|
||||||
|
* larger than the raw data or if it exceeds lzoAfterBufSize then
|
||||||
|
* raw encoding is used instead.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static int lzoBeforeBufSize = 0;
|
||||||
|
static char *lzoBeforeBuf = NULL;
|
||||||
|
|
||||||
|
static int lzoAfterBufSize = 0;
|
||||||
|
static char *lzoAfterBuf = NULL;
|
||||||
|
static int lzoAfterBufLen;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* rfbSendOneRectEncodingZlib - send a given rectangle using one Zlib
|
||||||
|
* rectangle encoding.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define MAX_WRKMEM ((LZO1X_1_MEM_COMPRESS) + (sizeof(lzo_align_t) - 1)) / sizeof(lzo_align_t)
|
||||||
|
|
||||||
|
static rfbBool
|
||||||
|
rfbSendOneRectEncodingUltra(rfbClientPtr cl,
|
||||||
|
int x,
|
||||||
|
int y,
|
||||||
|
int w,
|
||||||
|
int h)
|
||||||
|
{
|
||||||
|
rfbFramebufferUpdateRectHeader rect;
|
||||||
|
rfbZlibHeader hdr;
|
||||||
|
int deflateResult;
|
||||||
|
int i;
|
||||||
|
char *fbptr = (cl->screen->frameBuffer + (cl->screen->paddedWidthInBytes * y)
|
||||||
|
+ (x * (cl->screen->bitsPerPixel / 8)));
|
||||||
|
|
||||||
|
int maxRawSize;
|
||||||
|
int maxCompSize;
|
||||||
|
|
||||||
|
maxRawSize = (w * h * (cl->format.bitsPerPixel / 8));
|
||||||
|
|
||||||
|
if (lzoBeforeBufSize < maxRawSize) {
|
||||||
|
lzoBeforeBufSize = maxRawSize;
|
||||||
|
if (lzoBeforeBuf == NULL)
|
||||||
|
lzoBeforeBuf = (char *)malloc(lzoBeforeBufSize);
|
||||||
|
else
|
||||||
|
lzoBeforeBuf = (char *)realloc(lzoBeforeBuf, lzoBeforeBufSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* lzo requires output buffer to be slightly larger than the input
|
||||||
|
* buffer, in the worst case.
|
||||||
|
*/
|
||||||
|
maxCompSize = (maxRawSize + maxRawSize / 16 + 64 + 3);
|
||||||
|
|
||||||
|
if (lzoAfterBufSize < maxCompSize) {
|
||||||
|
lzoAfterBufSize = maxCompSize;
|
||||||
|
if (lzoAfterBuf == NULL)
|
||||||
|
lzoAfterBuf = (char *)malloc(lzoAfterBufSize);
|
||||||
|
else
|
||||||
|
lzoAfterBuf = (char *)realloc(lzoAfterBuf, lzoAfterBufSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Convert pixel data to client format.
|
||||||
|
*/
|
||||||
|
(*cl->translateFn)(cl->translateLookupTable, &cl->screen->serverFormat,
|
||||||
|
&cl->format, fbptr, lzoBeforeBuf,
|
||||||
|
cl->screen->paddedWidthInBytes, w, h);
|
||||||
|
|
||||||
|
if ( cl->compStreamInitedLZO == FALSE ) {
|
||||||
|
cl->compStreamInitedLZO = TRUE;
|
||||||
|
/* Work-memory needed for compression. Allocate memory in units
|
||||||
|
* of `lzo_align_t' (instead of `char') to make sure it is properly aligned.
|
||||||
|
*/
|
||||||
|
cl->lzoWrkMem = malloc(sizeof(lzo_align_t) * (((LZO1X_1_MEM_COMPRESS) + (sizeof(lzo_align_t) - 1)) / sizeof(lzo_align_t)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Perform the compression here. */
|
||||||
|
deflateResult = lzo1x_1_compress((unsigned char *)lzoBeforeBuf, (lzo_uint)(w * h * (cl->format.bitsPerPixel / 8)), (unsigned char *)lzoAfterBuf, (lzo_uint *)&maxCompSize, cl->lzoWrkMem);
|
||||||
|
/* maxCompSize now contains the compressed size */
|
||||||
|
|
||||||
|
/* Find the total size of the resulting compressed data. */
|
||||||
|
lzoAfterBufLen = maxCompSize;
|
||||||
|
|
||||||
|
if ( deflateResult != LZO_E_OK ) {
|
||||||
|
rfbErr("lzo deflation error: %d\n", deflateResult);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Update statics */
|
||||||
|
cl->rectanglesSent[rfbEncodingUltra]++;
|
||||||
|
cl->bytesSent[rfbEncodingUltra] += (sz_rfbFramebufferUpdateRectHeader
|
||||||
|
+ sz_rfbZlibHeader + lzoAfterBufLen);
|
||||||
|
|
||||||
|
if (cl->ublen + sz_rfbFramebufferUpdateRectHeader + sz_rfbZlibHeader
|
||||||
|
> UPDATE_BUF_SIZE)
|
||||||
|
{
|
||||||
|
if (!rfbSendUpdateBuf(cl))
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
rect.r.x = Swap16IfLE(x);
|
||||||
|
rect.r.y = Swap16IfLE(y);
|
||||||
|
rect.r.w = Swap16IfLE(w);
|
||||||
|
rect.r.h = Swap16IfLE(h);
|
||||||
|
rect.encoding = Swap32IfLE(rfbEncodingUltra);
|
||||||
|
|
||||||
|
memcpy(&cl->updateBuf[cl->ublen], (char *)&rect,
|
||||||
|
sz_rfbFramebufferUpdateRectHeader);
|
||||||
|
cl->ublen += sz_rfbFramebufferUpdateRectHeader;
|
||||||
|
|
||||||
|
hdr.nBytes = Swap32IfLE(lzoAfterBufLen);
|
||||||
|
|
||||||
|
memcpy(&cl->updateBuf[cl->ublen], (char *)&hdr, sz_rfbZlibHeader);
|
||||||
|
cl->ublen += sz_rfbZlibHeader;
|
||||||
|
|
||||||
|
for (i = 0; i < lzoAfterBufLen;) {
|
||||||
|
|
||||||
|
int bytesToCopy = UPDATE_BUF_SIZE - cl->ublen;
|
||||||
|
|
||||||
|
if (i + bytesToCopy > lzoAfterBufLen) {
|
||||||
|
bytesToCopy = lzoAfterBufLen - i;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(&cl->updateBuf[cl->ublen], &lzoAfterBuf[i], bytesToCopy);
|
||||||
|
|
||||||
|
cl->ublen += bytesToCopy;
|
||||||
|
i += bytesToCopy;
|
||||||
|
|
||||||
|
if (cl->ublen == UPDATE_BUF_SIZE) {
|
||||||
|
if (!rfbSendUpdateBuf(cl))
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* rfbSendRectEncodingUltra - send a given rectangle using one or more
|
||||||
|
* LZO encoding rectangles.
|
||||||
|
*/
|
||||||
|
|
||||||
|
rfbBool
|
||||||
|
rfbSendRectEncodingUltra(rfbClientPtr cl,
|
||||||
|
int x,
|
||||||
|
int y,
|
||||||
|
int w,
|
||||||
|
int h)
|
||||||
|
{
|
||||||
|
int maxLines;
|
||||||
|
int linesRemaining;
|
||||||
|
rfbRectangle partialRect;
|
||||||
|
|
||||||
|
partialRect.x = x;
|
||||||
|
partialRect.y = y;
|
||||||
|
partialRect.w = w;
|
||||||
|
partialRect.h = h;
|
||||||
|
|
||||||
|
/* Determine maximum pixel/scan lines allowed per rectangle. */
|
||||||
|
maxLines = ( ULTRA_MAX_SIZE(w) / w );
|
||||||
|
|
||||||
|
/* Initialize number of scan lines left to do. */
|
||||||
|
linesRemaining = h;
|
||||||
|
|
||||||
|
/* Loop until all work is done. */
|
||||||
|
while ( linesRemaining > 0 ) {
|
||||||
|
|
||||||
|
int linesToComp;
|
||||||
|
|
||||||
|
if ( maxLines < linesRemaining )
|
||||||
|
linesToComp = maxLines;
|
||||||
|
else
|
||||||
|
linesToComp = linesRemaining;
|
||||||
|
|
||||||
|
partialRect.h = linesToComp;
|
||||||
|
|
||||||
|
/* Encode (compress) and send the next rectangle. */
|
||||||
|
if ( ! rfbSendOneRectEncodingUltra( cl,
|
||||||
|
partialRect.x,
|
||||||
|
partialRect.y,
|
||||||
|
partialRect.w,
|
||||||
|
partialRect.h )) {
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Technically, flushing the buffer here is not extrememly
|
||||||
|
* efficient. However, this improves the overall throughput
|
||||||
|
* of the system over very slow networks. By flushing
|
||||||
|
* the buffer with every maximum size lzo rectangle, we
|
||||||
|
* improve the pipelining usage of the server CPU, network,
|
||||||
|
* and viewer CPU components. Insuring that these components
|
||||||
|
* are working in parallel actually improves the performance
|
||||||
|
* seen by the user.
|
||||||
|
* Since, lzo is most useful for slow networks, this flush
|
||||||
|
* is appropriate for the desired behavior of the lzo encoding.
|
||||||
|
*/
|
||||||
|
if (( cl->ublen > 0 ) &&
|
||||||
|
( linesToComp == maxLines )) {
|
||||||
|
if (!rfbSendUpdateBuf(cl)) {
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Update remaining and incremental rectangle location. */
|
||||||
|
linesRemaining -= linesToComp;
|
||||||
|
partialRect.y += linesToComp;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in new issue