jpeg.h

来自「In term project, we will take the baseli」· C头文件 代码 · 共 71 行

H
71
字号
#ifndef __jpeg__
#define __jpeg__

#include "type.h"
#include "stream.h"

#include "marker.h"

struct HuffmanDC
{ Byte CodeLength[16];
  Word CodeWord  [16];
};


struct HuffmanAC
{ Byte CodeLength[16][11];
  Word CodeWord  [16][11];
};

class JPEG: public BitStream , public Picture
{private:
   Byte Nf, Ss, Se, Precision;

   void _initial_dc_table(Byte identifier, Byte (*dc_length)[17], Byte (*dc_value)[12 ]);
   void _initial_ac_table(Byte identifier, Byte (*ac_length)[17], Byte (*ac_value)[162]);

   void _encoding_block_value(Byte identifier, int (*block)[8]);
   void _decoding_block_value(Byte identifier, int (*block)[8]);

   void _quantize(Byte identifier, int (*block)[8] );
   void _dequantize(Byte identifier, int (*block)[8] );

 protected:
   HuffmanDC DC[3];
   HuffmanAC AC[3];

   void ChenFDCT(int (*block)[8]);
   void ChenIDCT(int (*block)[8]);
   
   friend void _fdct( int (*m)[8] );
   friend void _idct( int (*m)[8] );
   
   inline void Marker_SOI(){ PutStream(0xFFD8, 16); };

          bool Marker_DQT(Byte identifier, bool extend=false);
          bool Marker_SOF(Byte index=0);

          bool Marker_DHT(Byte identifier, Byte table_class); /* table_class==0 for DC */
          bool Marker_SOS();

   inline void Marker_EOI(){ PutStream(0xFFD9, 16); };

          bool Rip_DQT();
          bool Rip_SOF(Byte index=0);

          bool Rip_DHT();
          bool Rip_SOS();

          void Rip_Marker();

 public:

   bool Encode();
   bool Decode();

   JPEG();
  ~JPEG();
};

#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?