home *** CD-ROM | disk | FTP | other *** search
/ Compressed Image File Formats / CompressedImageFileFormatsJohnMiano.iso / pc / Examples / c08 / inc / jpdecomp.h next >
Encoding:
C/C++ Source or Header  |  1998-12-23  |  3.6 KB  |  138 lines

  1. #ifndef __JPDECOMP_H
  2. #define __JPDECOMP_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 Component Class Definition
  12. //
  13. //  Author:  John M. Miano  miano@colosseumbuilders.com
  14. //
  15. //  Description:
  16. //
  17. //    This class represents a component within the JPEG decoder.
  18. //
  19.  
  20.  
  21. #include "jpeg.h"
  22. #include "jfif.h"
  23. #include "jpdedu.h"
  24. #include "jpdehuff.h"
  25. #include "jpdecobk.h"
  26. #include "jpdehuff.h"
  27. #include "bitimage.h"
  28.  
  29. class JpegDecoderComponent
  30. {
  31. public:
  32.   JpegDecoderComponent () ;
  33.   ~JpegDecoderComponent () ;
  34.  
  35.   // We have made the color conversions static because RGB
  36.   // conversion requires the data from three components.
  37.   // Grayscale conversion is static strictly for consistency
  38.   // with RGB.
  39.   static void RGBConvert (JpegDecoderComponent &c1,
  40.                           JpegDecoderComponent &c2,
  41.                           JpegDecoderComponent &c3,
  42.                           BitmapImage &image) ;
  43.   static void GrayscaleConvert (JpegDecoderComponent &cc, BitmapImage &image) ;
  44.  
  45.   unsigned int HorizontalFrequency () const ;
  46.   void HorizontalFrequency (unsigned int) ;
  47.  
  48.   unsigned int VerticalFrequency () const ;
  49.   void VerticalFrequency (unsigned int) ;
  50.  
  51.   void SetQuantizationTable (JpegDecoderQuantizationTable &table) ;
  52.   void AllocateComponentBuffers (const JpegDecoder &decoder) ;
  53.   void FreeComponentBuffers () ;
  54.   void SetHuffmanTables (JpegHuffmanDecoder &dc, JpegHuffmanDecoder &ac) ;
  55.   void Upsample () ;
  56.  
  57.   void CheckAcTable () ;
  58.   void CheckDcTable () ;
  59.   void CheckQuantizationTable () ;
  60.  
  61.   void DecodeSequential (JpegDecoder &decoder,
  62.                          unsigned int mcurow,
  63.                          unsigned int mcucol) ;
  64.  
  65.   unsigned long NoninterleavedRows () const ;
  66.   unsigned long NoninterleavedCols () const ;
  67.   void ResetDcDifference () ;
  68.  
  69.   void ProgressiveInverseDct () ;
  70.  
  71. private:
  72.   // Dummy Declarations for Required Member Functions
  73.   JpegDecoderComponent (const JpegDecoderComponent &) ;
  74.   JpegDecoderComponent operator=(const JpegDecoderComponent &) ;
  75.  
  76.   // Jfif/Frame component ID
  77.   unsigned int component_id ;
  78.  
  79.   // Sampling Frequencies
  80.   unsigned int horizontal_frequency ;
  81.   unsigned int vertical_frequency ;
  82.  
  83.   // These values are the numnber of samples to take for each data
  84.   // point. They come from the sampling frequencies and the maximum
  85.   // sampling frequencies of all the components in the image.
  86.   // sampling frequencies of all the components in the image.
  87.   unsigned int v_sampling ;
  88.   unsigned int h_sampling ;
  89.  
  90.   // Last encoded DC value.
  91.   int last_dc_value ;
  92.  
  93.   // Entropy tables used by the component.
  94.   JpegHuffmanDecoder *ac_table ;
  95.   JpegHuffmanDecoder *dc_table ;
  96.  
  97.   // Quantization table used by the component
  98.   JpegDecoderQuantizationTable *quantization_table ;
  99.  
  100.   // Non-interleaved dimensions.
  101.   unsigned int noninterleaved_rows ;
  102.   unsigned int noninterleaved_cols ;
  103.  
  104.   unsigned int du_rows ;
  105.   unsigned int du_cols ;
  106.  
  107.   JpegDecoderDataUnit *data_units ;
  108.   JPEGSAMPLE *upsample_data ;
  109. } ;
  110.  
  111. inline unsigned int JpegDecoderComponent::HorizontalFrequency () const
  112. {
  113.   return horizontal_frequency ;
  114. }
  115.  
  116. inline unsigned int JpegDecoderComponent::VerticalFrequency () const
  117. {
  118.   return vertical_frequency ;
  119. }
  120.  
  121. inline unsigned long JpegDecoderComponent::NoninterleavedRows () const
  122. {
  123.   return noninterleaved_rows ;
  124. }
  125.  
  126. inline unsigned long JpegDecoderComponent::NoninterleavedCols () const
  127. {
  128.   return noninterleaved_cols ;
  129. }
  130.  
  131. inline void JpegDecoderComponent::ResetDcDifference ()
  132. {
  133.   last_dc_value = 0 ;
  134.   return ;
  135. }
  136.  
  137. #endif
  138.