zftape-compress.h 2.8 KB

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