home *** CD-ROM | disk | FTP | other *** search
/ Compressed Image File Formats / CompressedImageFileFormatsJohnMiano.iso / pc / Library / include / jpdehuff.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-12-17  |  1.9 KB  |  73 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. class JpegDecoder ;
  26.  
  27. class JpegHuffmanDecoder
  28. {
  29. public:
  30.   JpegHuffmanDecoder () ;
  31.   virtual ~JpegHuffmanDecoder () {}
  32.  
  33.   // DECODING FUNCTIONS
  34.  
  35.   // Returns true if the table has been defined...in other words,
  36.   // if ReadTable () has completed successfully. This function is
  37.   // called before the table is used to decode a scan to ensure
  38.   // the the image does not reference a Huffman Table that has
  39.   // not been defined.
  40.   bool Defined () const ;
  41.  
  42.   // This function reads a Huffman table from the input stream.
  43.   unsigned int ReadTable (JpegDecoder &) ;
  44.  
  45.   // Function to decode the next value in the input stream.
  46.   int Decode (JpegDecoder &) ;
  47.  
  48.   // This is a debugging function that writes the Huffman table
  49.   // to a streamt.
  50.   void Dump (std::ostream &strm) const ;
  51.  
  52. private:
  53.   JpegHuffmanDecoder (const JpegHuffmanDecoder &) ;
  54.   JpegHuffmanDecoder &operator=(const JpegHuffmanDecoder &) ;
  55.  
  56.   // This function builds the structures needed for Huffman
  57.   // decoding after the table data has been read.
  58.   void MakeTable (UBYTE1 huffbits [JpegMaxHuffmanCodeLength]) ;
  59.  
  60.   // Maximum Huffman code value of length N
  61.   int maxcode [JpegMaxHuffmanCodeLength] ;
  62.   // Minimum Huffman code value of length N
  63.   int mincode [JpegMaxHuffmanCodeLength] ;
  64.   // Index into "values" for minimum code of length N
  65.   UBYTE1 valptr [JpegMaxHuffmanCodeLength] ;
  66.   // Huffman values
  67.   UBYTE1 huff_values [JpegMaxNumberOfHuffmanCodes] ;
  68.  
  69.   bool table_defined ;
  70. } ;
  71.  
  72. #endif
  73.