home *** CD-ROM | disk | FTP | other *** search
/ Compressed Image File Formats / CompressedImageFileFormatsJohnMiano.iso / pc / Examples / c10 / inc / jpdequan.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-12-17  |  2.3 KB  |  87 lines

  1. #ifndef __JPDEQUAN_H
  2. #define __JPDEQUAN_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 Quantization Table Class Implementation
  12. //
  13. //  Author:  John M. Miano  miano@colosseumbuilders.com
  14. //
  15. //  Description:
  16. //
  17. //    This class represents a quantization table used by the
  18. //    JPEG decoder.
  19. //
  20.  
  21.  
  22. #include <iostream>
  23. #include "jpeg.h"
  24. #include "bitimage.h"
  25.  
  26. class JpegDecoder ;
  27.  
  28. class JpegDecoderQuantizationTable
  29. {
  30. public:
  31.   JpegDecoderQuantizationTable() ;
  32.   ~JpegDecoderQuantizationTable() {}
  33.  
  34.   // This function tells the caller if the quantization table has been
  35.   // defined by the JPEG input stream.
  36.   bool Defined () const ;
  37.  
  38.   // Function to read the quantization table from the input stream.
  39.   void ReadTable (JpegDecoder &decoder, unsigned int precision) ;
  40.  
  41.   // This function builds the scaled quantization tables used in
  42.   // fast IDCT implementations.
  43.   void BuildScaledTables () ;
  44.  
  45.   // This function prints the contents of the quantization table to
  46.   // an output stream.
  47.   void Print (std::ostream &) const ;
  48.  
  49. private:
  50.   // Dummy Declarations for Required Member Functions
  51.   JpegDecoderQuantizationTable (const JpegDecoderQuantizationTable&) ;
  52.   JpegDecoderQuantizationTable &operator=(const JpegDecoderQuantizationTable&) ;
  53.  
  54.   // Quantization Values in Zig-Zag Order.
  55.   UBYTE2 data_values [JpegSampleSize] ;
  56.  
  57.  
  58.   // Scaling factor used for the scaled integer values.
  59.   enum { QuantizationIntegerScale = 12, } ;
  60.  
  61.   // Scaled quantization values used for the fast IDCT implementations.
  62.   double float_scaling [JpegSampleWidth][JpegSampleWidth] ;
  63.   long integer_scaling [JpegSampleWidth][JpegSampleWidth] ;
  64.  
  65.   // This flag gets set to true when the quantization is defined in the
  66.   // JPEG input stream. It is used to ensure that an compressed scan does
  67.   // not attempt to use an undefined quantization table.
  68.   bool table_defined ;
  69.  
  70.   friend class JpegDecoderDataUnit ;
  71. } ;
  72.  
  73. inline bool JpegDecoderQuantizationTable::Defined () const
  74. {
  75.   return table_defined ;
  76. }
  77.  
  78.  
  79. inline std::ostream &operator<<(std::ostream &strm,
  80.                                 const JpegDecoderQuantizationTable &du)
  81. {
  82.   du.Print (strm) ;
  83.   return strm ;
  84. }
  85.  
  86. #endif
  87.