kusano 7d535a
/* lzo1a_de.h -- definitions for the the LZO1A algorithm
kusano 7d535a
kusano 7d535a
   This file is part of the LZO real-time data compression library.
kusano 7d535a
kusano 7d535a
   Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer
kusano 7d535a
   Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer
kusano 7d535a
   Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer
kusano 7d535a
   Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer
kusano 7d535a
   Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer
kusano 7d535a
   Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer
kusano 7d535a
   Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
kusano 7d535a
   Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
kusano 7d535a
   Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
kusano 7d535a
   Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
kusano 7d535a
   Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
kusano 7d535a
   Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
kusano 7d535a
   Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
kusano 7d535a
   All Rights Reserved.
kusano 7d535a
kusano 7d535a
   The LZO library is free software; you can redistribute it and/or
kusano 7d535a
   modify it under the terms of the GNU General Public License as
kusano 7d535a
   published by the Free Software Foundation; either version 2 of
kusano 7d535a
   the License, or (at your option) any later version.
kusano 7d535a
kusano 7d535a
   The LZO library is distributed in the hope that it will be useful,
kusano 7d535a
   but WITHOUT ANY WARRANTY; without even the implied warranty of
kusano 7d535a
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
kusano 7d535a
   GNU General Public License for more details.
kusano 7d535a
kusano 7d535a
   You should have received a copy of the GNU General Public License
kusano 7d535a
   along with the LZO library; see the file COPYING.
kusano 7d535a
   If not, write to the Free Software Foundation, Inc.,
kusano 7d535a
   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
kusano 7d535a
kusano 7d535a
   Markus F.X.J. Oberhumer
kusano 7d535a
   <markus@oberhumer.com></markus@oberhumer.com>
kusano 7d535a
   http://www.oberhumer.com/opensource/lzo/
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
kusano 7d535a
/* WARNING: this file should *not* be used by applications. It is
kusano 7d535a
   part of the implementation of the LZO package and is subject
kusano 7d535a
   to change.
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
kusano 7d535a
#ifndef __LZO_DEFS_H
kusano 7d535a
#define __LZO_DEFS_H
kusano 7d535a
kusano 7d535a
#ifdef __cplusplus
kusano 7d535a
extern "C" {
kusano 7d535a
#endif
kusano 7d535a
kusano 7d535a
kusano 7d535a
/***********************************************************************
kusano 7d535a
//
kusano 7d535a
************************************************************************/
kusano 7d535a
kusano 7d535a
/*
kusano 7d535a
     Format of the marker byte
kusano 7d535a
kusano 7d535a
kusano 7d535a
     76543210
kusano 7d535a
     --------
kusano 7d535a
     00000000   a long literal run ('R0' run) - there are short and long R0 runs
kusano 7d535a
     000rrrrr   a short literal run with len r
kusano 7d535a
     mmmooooo   a short match (len = 2+m, o = offset low bits)
kusano 7d535a
     111ooooo   a long match (o = offset low bits)
kusano 7d535a
*/
kusano 7d535a
kusano 7d535a
kusano 7d535a
#define RSIZE   (1 << RBITS)
kusano 7d535a
#define RMASK   (RSIZE - 1)
kusano 7d535a
kusano 7d535a
#define MBITS   (8 - OBITS)
kusano 7d535a
#define MSIZE   (1 << MBITS)
kusano 7d535a
#define MMASK   (MSIZE - 1)
kusano 7d535a
kusano 7d535a
#define OBITS   RBITS               /* offset and run-length use same bits */
kusano 7d535a
#define OSIZE   (1 << OBITS)
kusano 7d535a
#define OMASK   (OSIZE - 1)
kusano 7d535a
kusano 7d535a
kusano 7d535a
/* additional bits for coding the length in a long match */
kusano 7d535a
#define LBITS   8
kusano 7d535a
#define LSIZE   (1 << LBITS)
kusano 7d535a
#define LMASK   (LSIZE - 1)
kusano 7d535a
kusano 7d535a
kusano 7d535a
/***********************************************************************
kusano 7d535a
// some macros to improve readability
kusano 7d535a
************************************************************************/
kusano 7d535a
kusano 7d535a
/* Minimum len of a match */
kusano 7d535a
#define MIN_MATCH           3
kusano 7d535a
#define THRESHOLD           (MIN_MATCH - 1)
kusano 7d535a
kusano 7d535a
/* Min-/Maximum len of a match coded in 2 bytes */
kusano 7d535a
#define MIN_MATCH_SHORT     (MIN_MATCH)
kusano 7d535a
#define MAX_MATCH_SHORT     (MIN_MATCH_SHORT + (MSIZE - 2) - 1)
kusano 7d535a
/* why (MSIZE - 2) ? because 0 is used to mark runs,
kusano 7d535a
 *                   and MSIZE-1 is used to mark a long match */
kusano 7d535a
kusano 7d535a
/* Min-/Maximum len of a match coded in 3 bytes */
kusano 7d535a
#define MIN_MATCH_LONG      (MAX_MATCH_SHORT + 1)
kusano 7d535a
#define MAX_MATCH_LONG      (MIN_MATCH_LONG + LSIZE - 1)
kusano 7d535a
kusano 7d535a
/* Min-/Maximum offset of a match */
kusano 7d535a
#define MIN_OFFSET          1
kusano 7d535a
#define MAX_OFFSET          (1 << (CHAR_BIT + OBITS))
kusano 7d535a
kusano 7d535a
kusano 7d535a
/* R0 literal run (a long run) */
kusano 7d535a
kusano 7d535a
#define R0MIN   (RSIZE)             /* Minimum len of R0 run of literals */
kusano 7d535a
#define R0MAX   (R0MIN + 255)       /* Maximum len of R0 run of literals */
kusano 7d535a
#define R0FAST  (R0MAX & ~7)        /* R0MAX aligned to 8 byte boundary */
kusano 7d535a
kusano 7d535a
#if (R0MAX - R0FAST != 7) || ((R0FAST & 7) != 0)
kusano 7d535a
#  error "something went wrong"
kusano 7d535a
#endif
kusano 7d535a
kusano 7d535a
/* 7 special codes from R0FAST+1 .. R0MAX
kusano 7d535a
 * these codes mean long R0 runs with lengths
kusano 7d535a
 * 512, 1024, 2048, 4096, 8192, 16384, 32768 */
kusano 7d535a
kusano 7d535a
kusano 7d535a
/*
kusano 7d535a
kusano 7d535a
RBITS | MBITS  MIN  THR.  MSIZE  MAXS  MINL  MAXL   MAXO  R0MAX R0FAST
kusano 7d535a
======+===============================================================
kusano 7d535a
  3   |   5      3    2     32    32    33    288   2048    263   256
kusano 7d535a
  4   |   4      3    2     16    16    17    272   4096    271   264
kusano 7d535a
  5   |   3      3    2      8     8     9    264   8192    287   280
kusano 7d535a
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
kusano 7d535a
/***********************************************************************
kusano 7d535a
//
kusano 7d535a
************************************************************************/
kusano 7d535a
kusano 7d535a
#define DBITS       13
kusano 7d535a
#include "lzo_dict.h"
kusano 7d535a
#define DVAL_LEN    DVAL_LOOKAHEAD
kusano 7d535a
kusano 7d535a
kusano 7d535a
kusano 7d535a
#ifdef __cplusplus
kusano 7d535a
} /* extern "C" */
kusano 7d535a
#endif
kusano 7d535a
kusano 7d535a
#endif /* already included */
kusano 7d535a
kusano 7d535a
/*
kusano 7d535a
vi:ts=4:et
kusano 7d535a
*/
kusano 7d535a