home *** CD-ROM | disk | FTP | other *** search
/ Compressed Image File Formats / CompressedImageFileFormatsJohnMiano.iso / pc / Examples / c07 / inc / jpdedu.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-06-23  |  3.3 KB  |  107 lines

  1. #ifndef __JPDEDU_H
  2. #define __JPDEDU_H
  3. //
  4. // Copyright (c) 1997,1998 Colosseum Builders, Inc.
  5. // All rights reserved.
  6. //
  7. // Colosseum Builders, Inc. makes no warranty, expressed or implied
  8. // with regards to this software. It is provided as is.
  9. //
  10. // See the README.TXT file that came with this software for information
  11. // on redistribution or send E-mail to info@colosseumbuilders.com
  12. //
  13. // o The user assumes all risk for using this software. The authors of this
  14. //   software shall be liable for no damages of any kind.
  15. //
  16. // o If the source code is distributed then this copyright notice must
  17. //   remain unaltered and any modification must be noted.
  18. //
  19. // o If this code is shipped in binary format the accompanying documentation
  20. //   should state that "this software is based, in part, on the work of
  21. //   Colosseum Builders, Inc."
  22. //
  23.  
  24. //
  25. //  Decoder Data Unit Class Definition
  26. //
  27. //  Author:  John M. Miano  miano@colosseumbuilders.com
  28. //
  29. //  Descrition:
  30. //
  31. //    The DataUnit class represents an 8x8 sample block for one
  32. //    component of the JPEG image.
  33. //
  34. //
  35.  
  36. #include <iostream>
  37.  
  38. #include "jpeg.h"
  39. #include "jpdequan.h"
  40. #include "jpdecobk.h"
  41.  
  42. class JpegDecoderDataUnit ;
  43.  
  44. std::ostream &operator<<(std::ostream &, JpegDecoderDataUnit &) ;
  45.  
  46. class JpegDecoderDataUnit
  47. {
  48. public:
  49.   // Declaration of a type for pointers to member functions
  50.   // for implementing the IDCT. The input parameters are
  51.   // The IDCT coefficients and the [de]quantization table.
  52.   typedef JpegDecoderDataUnit &(JpegDecoderDataUnit::*IDctFunction) (
  53.                                 const JpegDecoderCoefficientBlock,
  54.                                 const JpegDecoderQuantizationTable  &) ;
  55.  
  56.   JpegDecoderDataUnit() {}
  57.   virtual ~JpegDecoderDataUnit () {}
  58.  
  59.   // Utility function to write the IDCT values to an output stream.
  60.   void Print (std::ostream &) const ;
  61.  
  62.   // General IDCT Function
  63.   JpegDecoderDataUnit &JpegDecoderDataUnit::InverseDCT (
  64.                         const JpegDecoderCoefficientBlock cb,
  65.                         const JpegDecoderQuantizationTable  &qt) ;
  66.  
  67.   // These are the IDCT implementations.
  68.   JpegDecoderDataUnit &FloatInverseDCT (const JpegDecoderCoefficientBlock,
  69.                              const JpegDecoderQuantizationTable  &) ;
  70.   JpegDecoderDataUnit &IntegerInverseDCT (const JpegDecoderCoefficientBlock,
  71.                                const JpegDecoderQuantizationTable  &) ;
  72.  
  73.   // Operators to retrieve the individual IDCT values.
  74.   JPEGSAMPLE *operator [] (unsigned int ii) ;
  75.   JPEGSAMPLE const* operator [] (unsigned int ii) const ;
  76.  
  77. private:
  78.   // Dummy Declarations For Required Members Functions 
  79.   JpegDecoderDataUnit (const JpegDecoderDataUnit &) ;
  80.   JpegDecoderDataUnit &operator=(const JpegDecoderDataUnit &) ;
  81.  
  82.   // The IDCT values.
  83.   UBYTE1 values [JpegSampleWidth][JpegSampleWidth] ;
  84.  
  85.   // This is a pointer to the member function that implements
  86.   // the desired IDCT function.
  87.   static IDctFunction idct_function ;
  88. } ;
  89.  
  90. inline JPEGSAMPLE *JpegDecoderDataUnit::operator [] (unsigned int ii)
  91. {
  92.  return values [ii] ;
  93. }
  94.  
  95. inline JPEGSAMPLE const* JpegDecoderDataUnit::operator [] (unsigned int ii) const
  96. {
  97.   return values [ii] ;
  98. }
  99.  
  100. inline std::ostream &operator<<(std::ostream &strm, const JpegDecoderDataUnit &du)
  101. {
  102.   du.Print (strm) ;
  103.   return strm ;
  104. }
  105.  
  106. #endif
  107.