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

  1. #ifndef __JPDEDU_H
  2. #define __JPDEDU_H
  3. //
  4. //  Title:  JPEG Definitions and Utility Functions
  5. //
  6. //  Author:  John M. Miano  miano@colosseumbuilders.com
  7. //
  8.  
  9.  
  10. //
  11. //  Decoder Data Unit Class Definition
  12. //
  13. //  Author:  John M. Miano  miano@colosseumbuilders.com
  14. //
  15. //  Descrition:
  16. //
  17. //    The DataUnit class represents an 8x8 sample block for one
  18. //    component of the JPEG image.
  19. //
  20. //
  21.  
  22. #include <iostream>
  23.  
  24. #include "jpeg.h"
  25. #include "jpdequan.h"
  26. #include "jpdecobk.h"
  27.  
  28. class JpegDecoderDataUnit ;
  29.  
  30. std::ostream &operator<<(std::ostream &, JpegDecoderDataUnit &) ;
  31.  
  32. class JpegDecoderDataUnit
  33. {
  34. public:
  35.   // Declaration of a type for pointers to member functions
  36.   // for implementing the IDCT. The input parameters are
  37.   // The IDCT coefficients and the [de]quantization table.
  38.   typedef JpegDecoderDataUnit &(JpegDecoderDataUnit::*IDctFunction) (
  39.                                 const JpegDecoderCoefficientBlock,
  40.                                 const JpegDecoderQuantizationTable  &) ;
  41.  
  42.   JpegDecoderDataUnit() {}
  43.   virtual ~JpegDecoderDataUnit () {}
  44.  
  45.   // Utility function to write the IDCT values to an output stream.
  46.   void Print (std::ostream &) const ;
  47.  
  48.   // General IDCT Function
  49.   JpegDecoderDataUnit &JpegDecoderDataUnit::InverseDCT (
  50.                         const JpegDecoderCoefficientBlock cb,
  51.                         const JpegDecoderQuantizationTable  &qt) ;
  52.  
  53.   // These are the IDCT implementations.
  54.   JpegDecoderDataUnit &FloatInverseDCT (const JpegDecoderCoefficientBlock,
  55.                              const JpegDecoderQuantizationTable  &) ;
  56.   JpegDecoderDataUnit &IntegerInverseDCT (const JpegDecoderCoefficientBlock,
  57.                                const JpegDecoderQuantizationTable  &) ;
  58.  
  59.   // Operators to retrieve the individual IDCT values.
  60.   JPEGSAMPLE *operator [] (unsigned int ii) ;
  61.   JPEGSAMPLE const* operator [] (unsigned int ii) const ;
  62.  
  63. private:
  64.   // Dummy Declarations For Required Members Functions 
  65.   JpegDecoderDataUnit (const JpegDecoderDataUnit &) ;
  66.   JpegDecoderDataUnit &operator=(const JpegDecoderDataUnit &) ;
  67.  
  68.   // The IDCT values.
  69.   UBYTE1 values [JpegSampleWidth][JpegSampleWidth] ;
  70.  
  71.   // This is a pointer to the member function that implements
  72.   // the desired IDCT function.
  73.   static IDctFunction idct_function ;
  74. } ;
  75.  
  76. inline JPEGSAMPLE *JpegDecoderDataUnit::operator [] (unsigned int ii)
  77. {
  78.  return values [ii] ;
  79. }
  80.  
  81. inline JPEGSAMPLE const* JpegDecoderDataUnit::operator [] (unsigned int ii) const
  82. {
  83.   return values [ii] ;
  84. }
  85.  
  86. inline std::ostream &operator<<(std::ostream &strm, const JpegDecoderDataUnit &du)
  87. {
  88.   du.Print (strm) ;
  89.   return strm ;
  90. }
  91.  
  92. inline JpegDecoderDataUnit &JpegDecoderDataUnit::InverseDCT (
  93.                         const JpegDecoderCoefficientBlock cb,
  94.                         const JpegDecoderQuantizationTable  &qt)
  95. {
  96.   return (this->*idct_function) (cb, qt) ;
  97. }
  98.  
  99.  
  100. #endif
  101.