home *** CD-ROM | disk | FTP | other *** search
/ Compressed Image File Formats / CompressedImageFileFormatsJohnMiano.iso / pc / Examples / c11 / inc / jpdecomp.h next >
Encoding:
C/C++ Source or Header  |  1998-12-17  |  4.8 KB  |  165 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 DecodeDcFirst (JpegDecoder &decoder,
  70.                                     unsigned int row,
  71.                                     unsigned int col,
  72.                                     unsigned int ssa) ;
  73.   void DecodeDcRefine (JpegDecoder &decoder,
  74.                                      unsigned int row,
  75.                                      unsigned int col,
  76.                                      unsigned int ssa) ;
  77.  
  78.   void DecodeAcFirst (JpegDecoder &decoder,
  79.                                     unsigned int row,
  80.                                     unsigned int col,
  81.                                     unsigned int sss,
  82.                                     unsigned int sse,
  83.                                     unsigned int ssa) ;
  84.  
  85.   void DecodeAcRefine (JpegDecoder &decoder,
  86.                                      unsigned int row,
  87.                                      unsigned int col,
  88.                                      unsigned int sss,
  89.                                      unsigned int sse,
  90.                                      unsigned int ssa) ;
  91.  
  92.   void ProgressiveInverseDct () ;
  93.  
  94. private:
  95.   // Dummy Declarations for Required Member Functions
  96.   JpegDecoderComponent (const JpegDecoderComponent &) ;
  97.   JpegDecoderComponent operator=(const JpegDecoderComponent &) ;
  98.  
  99.   // Jfif/Frame component ID
  100.   unsigned int component_id ;
  101.  
  102.   // Sampling Frequencies
  103.   unsigned int horizontal_frequency ;
  104.   unsigned int vertical_frequency ;
  105.  
  106.   // These values are the numnber of samples to take for each data
  107.   // point. They come from the sampling frequencies and the maximum
  108.   // sampling frequencies of all the components in the image.
  109.   // sampling frequencies of all the components in the image.
  110.   unsigned int v_sampling ;
  111.   unsigned int h_sampling ;
  112.  
  113.   // Last encoded DC value.
  114.   int last_dc_value ;
  115.  
  116.   // Entropy tables used by the component.
  117.   JpegHuffmanDecoder *ac_table ;
  118.   JpegHuffmanDecoder *dc_table ;
  119.  
  120.   // Quantization table used by the component
  121.   JpegDecoderQuantizationTable *quantization_table ;
  122.  
  123.   // End of band Run - Progressive Specific
  124.   unsigned int eob_run ;
  125.  
  126.   // Non-interleaved dimensions.
  127.   unsigned int noninterleaved_rows ;
  128.   unsigned int noninterleaved_cols ;
  129.  
  130.   unsigned int du_rows ;
  131.   unsigned int du_cols ;
  132.  
  133.   JpegDecoderDataUnit *data_units ;
  134.   JPEGSAMPLE *upsample_data ;
  135.   JpegDecoderCoefficientBlock *coefficient_blocks ;
  136. } ;
  137.  
  138. inline unsigned int JpegDecoderComponent::HorizontalFrequency () const
  139. {
  140.   return horizontal_frequency ;
  141. }
  142.  
  143. inline unsigned int JpegDecoderComponent::VerticalFrequency () const
  144. {
  145.   return vertical_frequency ;
  146. }
  147.  
  148. inline unsigned long JpegDecoderComponent::NoninterleavedRows () const
  149. {
  150.   return noninterleaved_rows ;
  151. }
  152.  
  153. inline unsigned long JpegDecoderComponent::NoninterleavedCols () const
  154. {
  155.   return noninterleaved_cols ;
  156. }
  157.  
  158. inline void JpegDecoderComponent::ResetDcDifference ()
  159. {
  160.   last_dc_value = 0 ;
  161.   return ;
  162. }
  163.  
  164. #endif
  165.