File: /usr/src/linux/drivers/char/ftape/compressor/zftape-compress.h

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