Blame src/lzo1a_99.c

Packit Service 5195f2
/* lzo1a_99.c -- implementation of the LZO1A-99 algorithm
Packit Service 5195f2
Packit Service 5195f2
   This file is part of the LZO real-time data compression library.
Packit Service 5195f2
Packit Service 5195f2
   Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer
Packit Service 5195f2
   All Rights Reserved.
Packit Service 5195f2
Packit Service 5195f2
   The LZO library is free software; you can redistribute it and/or
Packit Service 5195f2
   modify it under the terms of the GNU General Public License as
Packit Service 5195f2
   published by the Free Software Foundation; either version 2 of
Packit Service 5195f2
   the License, or (at your option) any later version.
Packit Service 5195f2
Packit Service 5195f2
   The LZO library is distributed in the hope that it will be useful,
Packit Service 5195f2
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 5195f2
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service 5195f2
   GNU General Public License for more details.
Packit Service 5195f2
Packit Service 5195f2
   You should have received a copy of the GNU General Public License
Packit Service 5195f2
   along with the LZO library; see the file COPYING.
Packit Service 5195f2
   If not, write to the Free Software Foundation, Inc.,
Packit Service 5195f2
   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Packit Service 5195f2
Packit Service 5195f2
   Markus F.X.J. Oberhumer
Packit Service 5195f2
   <markus@oberhumer.com>
Packit Service 5195f2
   http://www.oberhumer.com/opensource/lzo/
Packit Service 5195f2
 */
Packit Service 5195f2
Packit Service 5195f2
Packit Service 5195f2
Packit Service 5195f2
#define COMPRESS_ID     99
Packit Service 5195f2
Packit Service 5195f2
#define DDBITS          3
Packit Service 5195f2
#define CLEVEL          9
Packit Service 5195f2
Packit Service 5195f2
Packit Service 5195f2
/***********************************************************************
Packit Service 5195f2
//
Packit Service 5195f2
************************************************************************/
Packit Service 5195f2
Packit Service 5195f2
#define LZO_NEED_DICT_H 1
Packit Service 5195f2
#include "config1a.h"
Packit Service 5195f2
Packit Service 5195f2
Packit Service 5195f2
/***********************************************************************
Packit Service 5195f2
// compression internal entry point.
Packit Service 5195f2
************************************************************************/
Packit Service 5195f2
Packit Service 5195f2
static int
Packit Service 5195f2
_lzo1a_do_compress ( const lzo_bytep in,  lzo_uint  in_len,
Packit Service 5195f2
                           lzo_bytep out, lzo_uintp out_len,
Packit Service 5195f2
                           lzo_voidp wrkmem,
Packit Service 5195f2
                           lzo_compress_t func )
Packit Service 5195f2
{
Packit Service 5195f2
    int r;
Packit Service 5195f2
Packit Service 5195f2
    /* don't try to compress a block that's too short */
Packit Service 5195f2
    if (in_len == 0)
Packit Service 5195f2
    {
Packit Service 5195f2
        *out_len = 0;
Packit Service 5195f2
        r = LZO_E_OK;
Packit Service 5195f2
    }
Packit Service 5195f2
    else if (in_len <= MIN_LOOKAHEAD + 1)
Packit Service 5195f2
    {
Packit Service 5195f2
#if defined(LZO_RETURN_IF_NOT_COMPRESSIBLE)
Packit Service 5195f2
        *out_len = 0;
Packit Service 5195f2
        r = LZO_E_NOT_COMPRESSIBLE;
Packit Service 5195f2
#else
Packit Service 5195f2
        *out_len = pd(STORE_RUN(out,in,in_len), out);
Packit Service 5195f2
        r = (*out_len > in_len) ? LZO_E_OK : LZO_E_ERROR;
Packit Service 5195f2
#endif
Packit Service 5195f2
    }
Packit Service 5195f2
    else
Packit Service 5195f2
        r = func(in,in_len,out,out_len,wrkmem);
Packit Service 5195f2
Packit Service 5195f2
    return r;
Packit Service 5195f2
}
Packit Service 5195f2
Packit Service 5195f2
Packit Service 5195f2
/***********************************************************************
Packit Service 5195f2
//
Packit Service 5195f2
************************************************************************/
Packit Service 5195f2
Packit Service 5195f2
#if !defined(COMPRESS_ID)
Packit Service 5195f2
#define COMPRESS_ID     _LZO_ECONCAT2(DD_BITS,CLEVEL)
Packit Service 5195f2
#endif
Packit Service 5195f2
Packit Service 5195f2
Packit Service 5195f2
#define LZO_CODE_MATCH_INCLUDE_FILE     "lzo1a_cm.ch"
Packit Service 5195f2
#include "lzo1b_c.ch"
Packit Service 5195f2
Packit Service 5195f2
Packit Service 5195f2
/***********************************************************************
Packit Service 5195f2
//
Packit Service 5195f2
************************************************************************/
Packit Service 5195f2
Packit Service 5195f2
#define LZO_COMPRESS \
Packit Service 5195f2
    LZO_PP_ECONCAT3(lzo1a_,COMPRESS_ID,_compress)
Packit Service 5195f2
Packit Service 5195f2
#define LZO_COMPRESS_FUNC \
Packit Service 5195f2
    LZO_PP_ECONCAT3(_lzo1a_,COMPRESS_ID,_compress_func)
Packit Service 5195f2
Packit Service 5195f2
Packit Service 5195f2
/***********************************************************************
Packit Service 5195f2
//
Packit Service 5195f2
************************************************************************/
Packit Service 5195f2
Packit Service 5195f2
LZO_PUBLIC(int)
Packit Service 5195f2
LZO_COMPRESS ( const lzo_bytep in,  lzo_uint  in_len,
Packit Service 5195f2
                     lzo_bytep out, lzo_uintp out_len,
Packit Service 5195f2
                     lzo_voidp wrkmem )
Packit Service 5195f2
{
Packit Service 5195f2
    return _lzo1a_do_compress(in,in_len,out,out_len,wrkmem,do_compress);
Packit Service 5195f2
}
Packit Service 5195f2
Packit Service 5195f2
Packit Service 5195f2
/*
Packit Service 5195f2
vi:ts=4:et
Packit Service 5195f2
*/