zftape-compress.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:3k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. #ifndef _ZFTAPE_COMPRESS_H
  2. #define _ZFTAPE_COMPRESS_H
  3. /*
  4.  *      Copyright (c) 1994-1997 Claus-Justus Heine
  5.  This program is free software; you can redistribute it and/or
  6.  modify it under the terms of the GNU General Public License as
  7.  published by the Free Software Foundation; either version 2, or (at
  8.  your option) any later version.
  9.  
  10.  This program is distributed in the hope that it will be useful, but
  11.  WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.  General Public License for more details.
  14.  
  15.  You should have received a copy of the GNU General Public License
  16.  along with this program; see the file COPYING.  If not, write to
  17.  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
  18.  USA.
  19.  *
  20.  * $Source: /homes/cvs/ftape-stacked/ftape/compressor/zftape-compress.h,v $
  21.  * $Revision: 1.1 $
  22.  * $Date: 1997/10/05 19:12:32 $
  23.  *
  24.  * This file contains macros and definitions for zftape's
  25.  * builtin compression code.
  26.  *
  27.  */
  28. #include "../zftape/zftape-buffers.h"
  29. #include "../zftape/zftape-vtbl.h"
  30. #include "../compressor/lzrw3.h"
  31. /* CMPR_WRK_MEM_SIZE gives the size of the compression wrk_mem */
  32. /* I got these out of lzrw3.c */
  33. #define U(X)            ((__u32) X)
  34. #define SIZE_P_BYTE     (U(sizeof(__u8 *)))
  35. #define ALIGNMENT_FUDGE (U(16))
  36. #define CMPR_WRK_MEM_SIZE (U(4096)*(SIZE_P_BYTE) + ALIGNMENT_FUDGE)
  37. /* the maximum number of bytes the size of the "compressed" data can
  38.  * exceed the uncompressed data. As it is quite useless to compress
  39.  * data twice it is sometimes the case that it is more efficient to
  40.  * copy a block of data but to feed it to the "compression"
  41.  * algorithm. In this case there are some flag bytes or the like
  42.  * proceding the "compressed" data.  THAT MUST NOT BE THE CASE for the
  43.  * algorithm we use for this driver. Instead, the high bit 15 of
  44.  * compressed_size:
  45.  *
  46.  * compressed_size = ftape_compress()
  47.  *
  48.  * must be set in such a case.
  49.  *
  50.  * Nevertheless, it might also be as for lzrw3 that there is an
  51.  * "intermediate" overrun that exceeds the amount of the compressed
  52.  * data that is actually produced. During the algorithm we need in the
  53.  * worst case MAX_CMP_GROUP bytes more than the input-size.
  54.  */
  55. #define MAX_CMP_GROUP (2+16*2) /* from lzrw3.c */
  56. #define CMPR_OVERRUN      MAX_CMP_GROUP /* during compression */
  57. /****************************************************/
  58. #define     CMPR_BUFFER_SIZE (MAX_BLOCK_SIZE + CMPR_OVERRUN)
  59. /* the compression map stores the byte offset compressed blocks within
  60.  * the current volume for catridges with format code 2,3 and 5
  61.  * (and old versions of zftape) and the offset measured in kilobytes for
  62.  * format code 4 and 6. This gives us a possible max. size of a 
  63.  * compressed volume of 1024*4GIG which should be enough.
  64.  */
  65. typedef __u32 CmprMap;
  66. /* globals 
  67.  */
  68. /* exported functions
  69.  */
  70. #endif /* _ZFTAPE_COMPRESS_H */