home *** CD-ROM | disk | FTP | other *** search
/ Compressed Image File Formats / CompressedImageFileFormatsJohnMiano.iso / pc / Examples / c06 / inc / jpdehuff.h next >
Encoding:
C/C++ Source or Header  |  1998-12-20  |  1.9 KB  |  75 lines

  1. #ifndef __JPDEHUFF_H
  2. #define __JPDEHUFF_H
  3. //
  4. //  Title:  JPEG Definitions and Utility Functions
  5. //
  6. //  Author:  John M. Miano  miano@colosseumbuilders.com
  7. //
  8.  
  9.  
  10. //
  11. //  Title:  JPEG Decoder Huffman Table Class Implementation
  12. //
  13. //  Author:  John M. Miano  miano@colosseumbuilders.com
  14. //
  15. //  Description:
  16. //
  17. //    This class represents a Huffman Table used by the JpegDecoder
  18. //    class.
  19. //
  20.  
  21.  
  22. #include "jpeg.h"
  23. #include "bitimage.h"
  24.  
  25. using namespace std ;
  26.  
  27. class JpegDecoder ;
  28.  
  29. class JpegHuffmanDecoder
  30. {
  31. public:
  32.   JpegHuffmanDecoder () ;
  33.   virtual ~JpegHuffmanDecoder () {}
  34.  
  35.   // DECODING FUNCTIONS
  36.  
  37.   // Returns true if the table has been defined...in other words,
  38.   // if ReadTable () has completed successfully. This function is
  39.   // called before the table is used to decode a scan to ensure
  40.   // the the image does not reference a Huffman Table that has
  41.   // not been defined.
  42.   bool Defined () const ;
  43.  
  44.   // This function reads a Huffman table from the input stream.
  45.   unsigned int ReadTable (JpegDecoder &) ;
  46.  
  47.   // Function to decode the next value in the input stream.
  48.   int Decode (JpegDecoder &) ;
  49.  
  50.   // This is a debugging function that writes the Huffman table
  51.   // to a streamt.
  52.   void Dump (std::ostream &strm) const ;
  53.  
  54. private:
  55.   JpegHuffmanDecoder (const JpegHuffmanDecoder &) ;
  56.   JpegHuffmanDecoder &operator=(const JpegHuffmanDecoder &) ;
  57.  
  58.   // This function builds the structures needed for Huffman
  59.   // decoding after the table data has been read.
  60.   void MakeTable (UBYTE1 huffbits [JpegMaxHuffmanCodeLength]) ;
  61.  
  62.   // Maximum Huffman code value of length N
  63.   int maxcode [JpegMaxHuffmanCodeLength] ;
  64.   // Minimum Huffman code value of length N
  65.   int mincode [JpegMaxHuffmanCodeLength] ;
  66.   // Index into "values" for minimum code of length N
  67.   UBYTE1 valptr [JpegMaxHuffmanCodeLength] ;
  68.   // Huffman values
  69.   UBYTE1 huff_values [JpegMaxNumberOfHuffmanCodes] ;
  70.  
  71.   bool table_defined ;
  72. } ;
  73.  
  74. #endif
  75.