packhead.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* packhead.h: Header definition of compressed data
  2. Copyright (C) 2000 Thomas Nussbaumer
  3. Copyright (C) 2007 Kevin Kofler
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software Foundation,
  14. Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
  15. #ifndef PACKHEAD_H
  16. #define PACKHEAD_H
  17. #define MAGIC_CHAR1 'T'
  18. #define MAGIC_CHAR2 'P'
  19. #define MAX_RLE_ENTRIES 31
  20. // size = 16 bytes
  21. typedef struct {
  22. unsigned char origsize_lo; // original size lowbyte
  23. unsigned char origsize_hi; // original size highbyte
  24. unsigned char magic1; // must be equal to MAGIC_CHAR1
  25. unsigned char magic2; // must be equal to MAGIC_CHAR2
  26. unsigned char compsize_lo; // compressed size lowbyte
  27. unsigned char compsize_hi; // compressed size lowbyte
  28. unsigned char esc1; // escape >> (8-escBits)
  29. unsigned char notused3;
  30. unsigned char notused4;
  31. unsigned char esc2; // escBits
  32. unsigned char gamma1; // maxGamma + 1
  33. unsigned char gamma2; // (1<<maxGamma)
  34. unsigned char extralz; // extraLZPosBits
  35. unsigned char notused1;
  36. unsigned char notused2;
  37. unsigned char rleentries; // rleUsed
  38. } PackedHeader;
  39. #define GetUnPackedSize(p) (unsigned int)((p)->origsize_lo | ((p)->origsize_hi << 8))
  40. #define IsPacked(p) ((p)->magic1 == MAGIC_CHAR1 && (p)->magic2 == MAGIC_CHAR2)
  41. typedef struct {
  42. unsigned char value[MAX_RLE_ENTRIES];
  43. } RLEEntries;
  44. #endif