home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2004 March / PCWELT_3_2004.ISO / pcwsoft / flaskmpeg_078_39_src.z.exe / flaskmpeg / Audio / MPEG / AMPDecoder.h < prev    next >
Encoding:
C/C++ Source or Header  |  2002-10-28  |  3.8 KB  |  161 lines

  1. #ifndef f_AMPLIB_AMPDECODER_H
  2. #define f_AMPLIB_AMPDECODER_H
  3.  
  4. #include "IAMPDecoder.h"
  5. #include "AMPBitstream.h"
  6.  
  7. #define SBLIMIT (32)
  8. #define SSLIMIT (18)
  9.  
  10. struct gr_info_s {
  11.     unsigned part2_3_length;
  12.     unsigned big_values;
  13.     unsigned global_gain;
  14.     unsigned scalefac_compress;
  15.     unsigned window_switching_flag;
  16.     unsigned block_type;
  17.     unsigned mixed_block_flag;
  18.     unsigned table_select[3];
  19.     unsigned subblock_gain[3];
  20.     unsigned region0_count;
  21.     unsigned region1_count;
  22.     unsigned preflag;
  23.     unsigned scalefac_scale;
  24.     unsigned count1table_select;
  25. };
  26.  
  27. typedef struct {
  28.     unsigned main_data_begin;
  29.     unsigned private_bits;
  30.     struct {
  31.         unsigned scfsi[4];
  32.         struct gr_info_s gr[2];
  33.         } ch[2];
  34.     } III_side_info_t;
  35.  
  36. typedef struct III_scalefac1_t {
  37.     int l[23];            /* [cb] */
  38.     int s[3][13];         /* [window][cb] */
  39.     } III_scalefac_t[2];  /* [ch] */
  40.  
  41. class AMPDecoder : public IAMPDecoder, AMPBitstream {
  42. public:
  43.     AMPDecoder();
  44.     ~AMPDecoder();
  45.  
  46.     void Destroy();
  47.  
  48.     char *    GetAmpVersionString();
  49.     void    Init();
  50.     void    setSource(IAMPBitsource *pSource);
  51.     void    setDestination(short *psDest);
  52.     long    getSampleCount();
  53.     void    getStreamInfo(AMPStreamInfo *pasi);
  54.     char *    getErrorString(int err);
  55.     void    Reset();
  56.     void    ReadHeader();
  57.     void    PrereadFrame();
  58.     bool    DecodeFrame();
  59.  
  60. private:
  61.     float    window[2][512];
  62.     float    prevblck[2][SBLIMIT][SSLIMIT];
  63.     int        winptr;
  64.     short *    psDest;
  65.     long    lSampleCount;
  66.  
  67.     unsigned char *l3bitptr;
  68.     int        l3bitidx;
  69.  
  70.     long    frame_size;
  71.  
  72.     int        bitrate;
  73.     int        frequency;
  74.     int        br_index;
  75.     int        sr_index;
  76.     int        is_mpeg2;
  77.     bool    is_errorprotected;
  78.     bool    is_padded;
  79.     bool    is_extended;
  80.     bool    is_copyrighted;
  81.     bool    is_original;
  82.     int        layer;
  83.     int        mode;
  84.     int        mode_ext;
  85.     int        channels;
  86.     int        emphasis;
  87.  
  88.     III_side_info_t        sideinfo;
  89.     int        sideinfo_size;
  90.  
  91.     int        slen[4];                // MPEG-2 layer 3
  92.     const int *    scale_block_indexes;    // MPEG-2 layer 3
  93.  
  94.     static    int init_count;
  95.  
  96.     static    signed char group3[31][3];
  97.     static    signed char group5[127][3];
  98.     static    signed char group9[1023][3];
  99.     static    signed char (*group_tbls[3])[3];
  100.  
  101.     static    void Initialize();
  102.     static    void Deinitialize();
  103.  
  104.     void    L1_PrereadFrame();
  105.     bool    L1_DecodeFrame();
  106.  
  107.     void    L2_PrereadFrame();
  108.     bool    L2_DecodeFrame();
  109.  
  110.     int        L3_GetBits(int bits);
  111.     void    L3_GetSideInfo();
  112.     void    L3_PrereadFrame();
  113.     bool    L3_DecodeFrame();
  114.  
  115.     void    L3_GetScaleFactors1(III_scalefac_t *scalefac, int gr, int ch);
  116.     void    L3_GetScaleFactors2(III_scalefac_t *scalefac, int ch);
  117.  
  118.     int        L3_HuffmanDecode(long int is[SBLIMIT*SSLIMIT],
  119.                             int ch,
  120.                             int gr,
  121.                             int part2_start);
  122.     int        L3_DequantizeSample(long int is[SBLIMIT*SSLIMIT],
  123.                                 float xr[SBLIMIT*SSLIMIT],
  124.                                 const III_scalefac1_t *scalefac,
  125.                                 struct gr_info_s *gr_info,
  126.                                 int ch, int limit);
  127.     int        L3_Stereo(
  128.                     float lr[2][SBLIMIT*SSLIMIT],
  129.                     const III_scalefac_t *scalefac,
  130.                     struct gr_info_s *gr_info,
  131.                     int nz0, int nz1);
  132.  
  133.     void    L3_Reorder (float xr[SBLIMIT*SSLIMIT],
  134.                 float ro[SBLIMIT*SSLIMIT],
  135.                 struct gr_info_s *gr_info);
  136.  
  137.     void    L3_Antialias(float xr[SBLIMIT][SSLIMIT],
  138.                         struct gr_info_s *gr_info);
  139.  
  140.     void    L3_Hybrid(float fsIn[SBLIMIT][SSLIMIT],
  141.                 float fsOut[SSLIMIT][SBLIMIT],
  142.                 int ch,
  143.                 struct gr_info_s *gr_info,
  144.                 int nonzero_entries);
  145.  
  146.     void    L3_GetHuffmanBig(int table_id, long *is, int count) throw();
  147.     int        L3_GetHuffmanCount1_32(long *is, int i, int bit_threshold) throw();
  148.     int        L3_GetHuffmanCount1_33(long *is, int i, int bit_threshold) throw();
  149.  
  150.     void    polyphase(float *band_l, float *band_r, short *samples, bool invert_odd);
  151. //    void    polyphase_single(float *band, int ch, short *samples);
  152.     void    polyphase_retract(int amount);
  153. };
  154.  
  155. #define MODE_STEREO            (0)
  156. #define    MODE_JOINTSTEREO    (1)
  157. #define    MODE_DUALCHANNEL    (2)
  158. #define MODE_MONO            (3)
  159.  
  160. #endif
  161.