videoeditorengine/mp3aacManipLib/inc/mstream.h
changeset 0 951a5db380a0
equal deleted inserted replaced
-1:000000000000 0:951a5db380a0
       
     1 /*
       
     2 * Copyright (c) 2010 Ixonos Plc.
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - Initial contribution
       
    11 *
       
    12 * Contributors:
       
    13 * Ixonos Plc
       
    14 *
       
    15 * Description:
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef MP_STREAM_H_
       
    21 #define MP_STREAM_H_
       
    22 
       
    23 /**************************************************************************
       
    24   External Objects Needed
       
    25   *************************************************************************/
       
    26 
       
    27 /*-- Project Headers --*/
       
    28 #include "nok_bits.h"
       
    29 #include "defines.h"
       
    30 #include "param.h"
       
    31 #include "mp3def.h"
       
    32 #include "auddef.h"
       
    33 #include <e32base.h>
       
    34 
       
    35 
       
    36 
       
    37 /**************************************************************************
       
    38   External Objects Provided
       
    39   *************************************************************************/
       
    40 
       
    41 /**************************************************************************
       
    42                 Common structure definitions for all layers
       
    43   *************************************************************************/
       
    44 
       
    45 /*
       
    46    Purpose:     Parent structure for error checking.
       
    47    Explanation: The number of bits that are protected varies between different 
       
    48                 versions (MPEG-1, MPEG-2). */
       
    49 class TCRC_Check
       
    50 {
       
    51 public:
       
    52   uint8 crc_payload[CRC_MAX_PAYLOAD]; /* Protected bits.         */
       
    53   uint16 bufLen;                       /* Length of 'crc_payload' */
       
    54   int16 crc;                         /* CRC error-check word.   */
       
    55 
       
    56 };
       
    57 
       
    58 /*
       
    59    Purpose:     Parent structure for mp1, mp2, and mp3 header.
       
    60    Explanation: - */
       
    61 
       
    62 class TMPEG_Header
       
    63 {
       
    64 public:
       
    65   uint32 header; // Header bits. 
       
    66 
       
    67 };
       
    68 
       
    69 /*
       
    70    Purpose:     Parent Structure for mp1, mp2, and mp3 frames.
       
    71    Explanation: - */
       
    72 class TMPEG_Frame
       
    73 {
       
    74 public:
       
    75   uint8 *scale_factors;           /* Scale factor of each subband and group. */
       
    76   int16 *quant;                  /* Quantized spectral data for this frame. */
       
    77   int16 *ch_quant[MAX_CHANNELS]; /* Channel pointers.                       */
       
    78 
       
    79 };
       
    80 
       
    81  /*
       
    82    Purpose:     Parent Structure for mp1, mp2, and mp3 buffer.
       
    83    Explanation: - */
       
    84 class TMPEG_Buffer
       
    85 {
       
    86 public:
       
    87   FLOAT *synthesis_buffer[MAX_CHANNELS]; /* Samples for windowing.     */
       
    88   int16 buf_idx[MAX_CHANNELS];           /* Start index for windowing. */
       
    89   int16 dct_idx[MAX_CHANNELS];           /* DCT buffer index.          */
       
    90   FLOAT *reconstructed;                  /* Dequantized samples.       */
       
    91   FLOAT *ch_reconstructed[MAX_CHANNELS]; /* Channel pointers.          */
       
    92 
       
    93 };
       
    94 
       
    95  /*
       
    96    Purpose:     Parent Structure for frame detection.
       
    97    Explanation: - */
       
    98 class TSyncInfoMix
       
    99 {
       
   100 public:
       
   101   int16 sync_length;       /* Length of sync word.                    */
       
   102   int16 sync_word;         /* Synchronization word.                   */
       
   103   int16 sync_mask;         /* Bitmask for sync word detection.        */
       
   104   MIX_SYNC_STATUS sync_status; /* Which layer we supposed to be decoding. */
       
   105 
       
   106 };
       
   107 
       
   108 /**************************************************************************
       
   109                Structure definitions applicable only to layer III
       
   110   *************************************************************************/
       
   111 /*
       
   112    Purpose:     Parent Structure for layer III Granule Info.
       
   113    Explanation: - */
       
   114 class TGranule_Info
       
   115 {
       
   116 public:
       
   117   uint8 global_gain;
       
   118   uint8 flags;
       
   119   uint8 table_select[3];
       
   120   uint8 subblock_gain[3];
       
   121   uint8 region0_count;
       
   122   uint8 region1_count;
       
   123   int32 part2_3_length;
       
   124   int32 big_values;
       
   125   int32 scalefac_compress;
       
   126   MP3_WINDOW_TYPE block_mode;
       
   127   int16 zero_part_start;
       
   128 
       
   129 };
       
   130 
       
   131 /*
       
   132    Purpose:     Parent Structure for layer III Scale Factors.
       
   133    Explanation: - */
       
   134 class CIII_Scale_Factors : public CBase
       
   135 {
       
   136 
       
   137 public:
       
   138 
       
   139   uint8 *scalefac_long;     /* Scalefactors for long blocks.  */
       
   140   uint8 *scalefac_short[3]; /* Scalefactors for short blocks. */
       
   141 
       
   142 
       
   143 };
       
   144 
       
   145 /*
       
   146    Purpose:     Parent Structure for layer III Channel Info.
       
   147    Explanation: - */
       
   148 class CIII_Channel_Info : public CBase
       
   149 {
       
   150 public:
       
   151 
       
   152   static CIII_Channel_Info* NewL();
       
   153   ~CIII_Channel_Info();
       
   154   TGranule_Info *gr_info[2];     /* Granule info for this channel. */
       
   155   CIII_Scale_Factors *scale_fac; /* Scalefactors for this channel. */
       
   156 
       
   157 private:
       
   158    void ConstructL();
       
   159    CIII_Channel_Info();
       
   160 
       
   161 };
       
   162 
       
   163 /*
       
   164    Purpose:     Structure to hold MPEG-2 IS stereo positions.
       
   165    Explanation: - */
       
   166 class TIS_Info
       
   167 {
       
   168 public:
       
   169   int16 is_len[3];
       
   170   int16 nr_sfb[3];
       
   171 
       
   172 };
       
   173 
       
   174 /*
       
   175    Purpose:     Structure to hold scalefactor band tables
       
   176                 and related parameters.
       
   177    Explanation: - */
       
   178 class CIII_SfbData : public CBase
       
   179 {
       
   180 public:
       
   181 
       
   182   static CIII_SfbData* NewL();
       
   183   ~CIII_SfbData();
       
   184 
       
   185   /* Scalefactor band boundaries for long and short blocks. */
       
   186   int16* sfbOffsetLong;
       
   187   int16* sfbOffsetShort;
       
   188 
       
   189   /* Scalefactor band widths for short blocks. */
       
   190   int16* sfbWidthShort;
       
   191 
       
   192   int16 *sfbLong;  /* Pointer to long sfb offset table.  */
       
   193   int16 *sfbShort; /* Pointer to short sfb offset table. */
       
   194   int16 *sfbWidth; /* Pointer to short sfb width table.  */
       
   195   int16 bandLimit; /* # of spectral bins to be decoded.  */ 
       
   196 
       
   197 private:
       
   198     void ConstructL();
       
   199     CIII_SfbData();
       
   200 
       
   201 };
       
   202 
       
   203 /*
       
   204    Purpose:     Structure to map the file parameters into
       
   205                 total length, average bitrate, etc.
       
   206    Explanation: - */
       
   207 class TMP_BrInfo
       
   208 {
       
   209 public:
       
   210   BOOL vbr;          /* TRUE for VBR files, FALSE otherwise.        */
       
   211   BOOL tmp;          /* Used for counting the verage bitrate.       */
       
   212   BOOL true_br;      /* The 'start_br' represents the true bitrate. */
       
   213   BOOL free_br;      /* Free format flag.                           */
       
   214   uint32 cum_br;     /* Cumulative bitrate.                         */
       
   215   uint32 cum_frames; /* Cumulative # of frames.                     */
       
   216   uint16 start_br;   /* Initial and/or average bitrate.             */
       
   217   
       
   218 };
       
   219 
       
   220 /*
       
   221    Purpose:     Parent Structure for Layer III Side Information.
       
   222    Explanation: - */
       
   223 class CIII_Side_Info : public CBase
       
   224 {
       
   225 public:
       
   226 
       
   227   static CIII_Side_Info* NewL();
       
   228   ~CIII_Side_Info();
       
   229 
       
   230   /*-- Side information read from the bit stream. --*/
       
   231   uint8 private_bits;
       
   232   uint8 scfsi[2][4];
       
   233   int32 main_data_begin;
       
   234   CIII_Channel_Info *ch_info[MAX_CHANNELS];
       
   235 
       
   236   /*-- General side information. --*/
       
   237   StereoMode *s_mode_long;    /* Stereo modes for long blocks.               */
       
   238   StereoMode *s_mode_short[3];/* Stereo modes for short blocks.              */
       
   239   
       
   240   int16 max_gr;               /* Number of granules within each stream frame.*/
       
   241   BOOL ms_stereo;             /* MS (Mid/Side) stereo used.                  */
       
   242   BOOL is_stereo;             /* Intensity stereo used.                      */
       
   243   BOOL lsf;                   /* MPEG-2 LSF stream present.                  */
       
   244   BOOL mpeg25;                /* MPEG-2.5 stream present.                    */
       
   245   int16 sb_limit;
       
   246   TIS_Info is_info;
       
   247   CIII_SfbData* sfbData;
       
   248 
       
   249 private:
       
   250   void ConstructL();
       
   251   CIII_Side_Info();
       
   252 
       
   253 };
       
   254 
       
   255 /*
       
   256    Purpose:     Parent Structure for Huffman Decoding.
       
   257    Explanation: This structure can be used if dynamic memory allocation
       
   258                 is not available or if memory consumption is important.
       
   259                 At worst we have to process the number of codewords equal to
       
   260                 the size of the codebook. */
       
   261 class CHuffman : public CBase
       
   262 {
       
   263 public:
       
   264   int16 tree_len;        /* Size of the Huffman tree.                      */
       
   265   int16 linbits;         /* Number of extra bits.                          */
       
   266   const int16 *codeword;       /* Huffman codewords.                             */
       
   267   const int16 *packed_symbols; /* x, y and length of the corresponding codeword. */
       
   268 
       
   269 };
       
   270 
       
   271 /*
       
   272    Purpose:     Structure for buffer handling.
       
   273    Explanation: - */
       
   274 class CMCUBuf : public CBase
       
   275 {
       
   276 public:
       
   277 
       
   278    static CMCUBuf* NewL(TInt aBufLen);
       
   279   ~CMCUBuf();
       
   280 
       
   281   TBitStream *bs;      /* Bitstream parser.                 */
       
   282   uint32 bufOffset;   /* Current file or buffer offset.    */
       
   283   uint32 bufLen;      /* Length of 'mcuBufbits', in bytes. */
       
   284   uint32 writeIdx;    /* Write index of the buffer.        */
       
   285   uint32 readSlots;   /* Bytes read from the buffer.       */
       
   286   uint8 *mcuBufbits;  /* Buffer for the compressed bits.   */
       
   287 
       
   288 private:
       
   289     
       
   290     void ConstructL(TInt aBufLen);
       
   291     CMCUBuf();
       
   292 
       
   293 };
       
   294 
       
   295 /*
       
   296    Purpose:     More definitions for the buffer handling.
       
   297    Explanation: - */
       
   298 typedef enum StreamMode
       
   299 {
       
   300   IS_UNKNOWN,
       
   301   IS_FILE,
       
   302   IS_STREAM,
       
   303   READ_MODE,
       
   304   WRITE_MODE,
       
   305   APPEND_MODE
       
   306 
       
   307 } StreamMode;
       
   308 
       
   309 
       
   310 /*
       
   311    Purpose:     Structure implementing ring buffer.
       
   312    Explanation: - */
       
   313 class CRingBuffer : public CBase
       
   314 {
       
   315 public:
       
   316   TBitStream *bs;    /* Bit parser for the 'bitBuffer'.  */
       
   317   uint32 bufLen;    /* Length of 'bitBuffer', in bytes. */
       
   318   uint32 readIdx;   /* Read index.                      */
       
   319   uint8 *bitBuffer; /* Buffer holding encoded data.     */
       
   320 
       
   321 };
       
   322 
       
   323 /*
       
   324    Purpose:     Layer 3 bitstream formatter (encoder side).
       
   325                 The header+side info and payload are in separate
       
   326         buffers. The output mp3 frames are a combination
       
   327         of these two buffers.
       
   328    Explanation: - */
       
   329 class CL3FormatBitstream : public CBase
       
   330 {
       
   331 public:
       
   332     static CL3FormatBitstream* NewL(uint16 sideInfoEntries, 
       
   333             uint16 sideInfoBytes, uint32 dataBytesBuffer);
       
   334 
       
   335 
       
   336     ~CL3FormatBitstream();
       
   337 
       
   338     void L3FormatBitstreamAddMainDataEntry(uint16 dataBytes);
       
   339     void L3FormatBitstreamAddMainDataBits(uint32 dataBits);
       
   340     uint32 L3WriteOutFrame(uint8 *outBuf);
       
   341   /* Number of bits present in 'frameData'. */
       
   342   uint32 numDataBits;
       
   343 
       
   344   /* Number of bytes reserved for payload part of the frame. */
       
   345   uint16 *payloadBytes;
       
   346 
       
   347   /* Read index to field 'payloadBytes'. */
       
   348   uint16 payloadReadIdx;
       
   349 
       
   350   /* Write index to field 'payloadBytes'. */
       
   351   uint16 payloadWriteIdx;
       
   352 
       
   353   /* Number of items in field 'payloadBytes'. */
       
   354   uint16 numPayloads;
       
   355 
       
   356   /* Payload data for layer 3 frames. */
       
   357   CRingBuffer *frameData;
       
   358 
       
   359 
       
   360   /* Number of frames present in 'frameHeader'. */
       
   361   uint32 framesPresent;
       
   362 
       
   363   /* Number of bytes reserved for side info per frame (fixed value). */
       
   364   uint16 sideInfoBytes;
       
   365 
       
   366   /* Buffer holding header and side info frames. */
       
   367   CRingBuffer *frameHeader;
       
   368   
       
   369 private:
       
   370     
       
   371     void ConstructL(uint16 sideInfoEntries, uint16 sideInfoBytes, uint32 dataBytesBuffer);
       
   372     CL3FormatBitstream();
       
   373 };
       
   374 
       
   375 /*
       
   376    Purpose:     Bitrate of the mixer.
       
   377    Explanation: - */
       
   378 class TL3BitRate
       
   379 {
       
   380 public:
       
   381   /*-- Bitrate of mixed stream and index of the rate. --*/
       
   382   uint16 bitRate;
       
   383   uint8 bitRateIdx;
       
   384 
       
   385   /*-- Status of padding bit in frame header. --*/
       
   386   uint8 padding;
       
   387   
       
   388   /*-- Number of bytes available for a frame. --*/
       
   389   uint16 frameBytes;
       
   390   
       
   391   /*-- Fractional part of the bytes reserved for each frame. --*/
       
   392   FLOAT frac_SpF;
       
   393   FLOAT slot_lag;
       
   394 
       
   395 };
       
   396 
       
   397 class THuffmanData
       
   398 {
       
   399 public:
       
   400   /* # of bits reserved for 'hufWord'. */
       
   401   uint8 hufBits;
       
   402   /* total # of bits reserved for codeword + sign bits + linbits. */
       
   403   uint8 hufBitsCount;
       
   404   /* Huffman codeword. */
       
   405   uint16 hufWord;
       
   406 
       
   407 };
       
   408 
       
   409 /*
       
   410    Purpose:     Huffman table parameters for layer 3.
       
   411    Explanation: - */
       
   412 class CHuffmanCodTab : public CBase
       
   413 {
       
   414 public:
       
   415   uint8 xlen;
       
   416   uint8 ylen;
       
   417   uint8 linbits;
       
   418   uint8 xoffset;
       
   419   uint16 linmax;
       
   420   THuffmanData *hData;
       
   421 
       
   422 };
       
   423 
       
   424 /*
       
   425    Purpose:     # of pair and quadruple tables.
       
   426    Explanation: - */
       
   427 #define L3HUFPAIRTBLS  (31)
       
   428 #define L3HUFFQUADTBLS ( 2)
       
   429 
       
   430 /*
       
   431    Purpose:     Parent structure to hold layer 3 Huffman 
       
   432                 coding parameters.
       
   433    Explanation: - */
       
   434 class CL3HuffmanTab : public CBase
       
   435 {
       
   436 public:
       
   437 
       
   438     static CL3HuffmanTab* NewL();
       
   439     ~CL3HuffmanTab();
       
   440 
       
   441     THuffmanData *quadTable[L3HUFFQUADTBLS];  // Tables 32 - 33. 
       
   442     CHuffmanCodTab *pairTable[L3HUFPAIRTBLS]; // Tables 1 - 31.  
       
   443 
       
   444     CHuffmanCodTab* tree;
       
   445 
       
   446 private:
       
   447     CL3HuffmanTab();
       
   448     void ConstructL();
       
   449 
       
   450 };
       
   451 
       
   452 /*
       
   453    Purpose:     Helper parameters for mp3 mixer.
       
   454    Explanation: - */
       
   455 class CL3MixerHelper : public CBase
       
   456 {
       
   457 public:
       
   458   /*-------- Encoding related parameters. --------*/
       
   459 
       
   460   /*-- Scalefactor encoding patterns for LSF streams. --*/
       
   461   uint8 blkNum;
       
   462   uint8 slen[4];
       
   463   uint8 blkTypeNum;
       
   464   int16 numRegions;
       
   465 
       
   466   /*-- Huffman tables for layer 3. --*/
       
   467   CL3HuffmanTab *l3Huf;
       
   468   
       
   469   /*-- Bitstream formatter for layer 3 encoder. --*/
       
   470   CL3FormatBitstream *l3bs;
       
   471   
       
   472   /*-- Window sequence of previous frame. --*/
       
   473   MP3_WINDOW_TYPE winTypeOld[MAX_CHANNELS];
       
   474   
       
   475   /*-- Window sequence of previous frame (source stream). --*/
       
   476   uint32 winTypeIdx;
       
   477   MP3_WINDOW_TYPE *winTypeCurrentFrame;
       
   478   MP3_WINDOW_TYPE *winTypePreviousFrame;
       
   479   MP3_WINDOW_TYPE *winTypePrt[MAX_CHANNELS];
       
   480   MP3_WINDOW_TYPE _winTypeOld1[2 * MAX_CHANNELS];
       
   481   MP3_WINDOW_TYPE _winTypeOld2[2 * MAX_CHANNELS];
       
   482 
       
   483   /*-- Overlap buffer for MDCT. --*/
       
   484   FLOAT** L3EncOverlapBuf;//[MAX_CHANNELS][MAX_MONO_SAMPLES];
       
   485   FLOAT* L3EncOverlapBufMem;
       
   486 
       
   487   /*-- Granule parameters of previous frame. --*/
       
   488   TGranule_Info *grInfoSave[MAX_CHANNELS];
       
   489 
       
   490   
       
   491   /*-- Scalefactors of previous frame. --*/
       
   492   CIII_Scale_Factors *scaleFacSave[MAX_CHANNELS];
       
   493 
       
   494   /*-- Spectrum limit of previous frame. --*/
       
   495   int16 specBinsPresent;
       
   496 
       
   497   /*-- Scalefactor selection information of previous frame. --*/
       
   498   BOOL IsScfsi;
       
   499   uint8 scfsi[2][4];
       
   500   
       
   501   /*-- Number of bits unused (bit reservoir). --*/
       
   502   uint32 bitPool;
       
   503  
       
   504   /*-- Level adjustment for the spectrum to be mixed. --*/
       
   505   FLOAT mixGain;
       
   506   
       
   507   /*-- Level adjustment for the mixed spectrum. --*/
       
   508   FLOAT overallGain;
       
   509 
       
   510   /*-- Level adjustment for the global gain. --*/
       
   511   int16 gainDec;
       
   512 
       
   513   /*-- Number of spectral bins to be mixed. --*/
       
   514   int16 mixSpectralBins;
       
   515 
       
   516 
       
   517   /*-------- Bitrate related parameters. --------*/
       
   518   
       
   519   /*-- Bytes reserved for side info. --*/
       
   520   int16 sideInfoBytes;
       
   521 
       
   522   /*-- Bitrate mappings. --*/
       
   523   BOOL needVBR;
       
   524   uint32 brIdx;
       
   525   TL3BitRate *l3br;
       
   526   TL3BitRate *_l3br[2];
       
   527   TL3BitRate l3brLong;
       
   528   TL3BitRate l3brShort;
       
   529   uint32 numFramesLong;
       
   530   uint32 numFramesShort;
       
   531 
       
   532   /*-- # of bytes reserved for the payload part of current frame. --*/
       
   533   int16 nSlots;
       
   534   
       
   535   /*-- 'main_data_begin' for next frame. --*/
       
   536   int16 main_data_begin;
       
   537   
       
   538   /*-- Max value of 'main_data_begin'. --*/
       
   539   int16 max_br_value;
       
   540   
       
   541 };
       
   542 
       
   543 
       
   544 /*
       
   545    Purpose:     Stream seeking constants.
       
   546    Explanation: - */
       
   547 typedef enum StreamPos
       
   548 {
       
   549   CURRENT_POS,
       
   550   START_POS,
       
   551   END_POS
       
   552 
       
   553 } StreamPos;
       
   554 
       
   555 /*
       
   556    Purpose:     Parameters of core engine.
       
   557    Explanation: - */
       
   558 class CMP_Stream : public CBase
       
   559 {
       
   560 
       
   561 public:
       
   562   /*-- Common to all layers. --*/
       
   563   TBitStream *bs;
       
   564   TMPEG_Header *header;
       
   565   TMPEG_Header headerOld;
       
   566   TMPEG_Frame *frame;
       
   567   TMPEG_Buffer *buffer;
       
   568   TSyncInfoMix syncInfo;
       
   569   TMP_BrInfo brInfo;
       
   570   TCRC_Check mp3_crc;
       
   571 
       
   572   /*-- Layer III specific parameters. --*/
       
   573   TBitStream *br;
       
   574   CIII_Side_Info *side_info;
       
   575   CHuffman *huffman;
       
   576   FLOAT *spectrum[MAX_CHANNELS][SBLIMIT];
       
   577   uint16 OverlapBufPtr[MAX_CHANNELS];
       
   578   FLOAT OverlapBlck[2][MAX_CHANNELS][MAX_MONO_SAMPLES];
       
   579   /*
       
   580     Purpose:     Indices for reordering the short blocks.
       
   581     Explanation: First row describes the destination and second row 
       
   582                  the source index. */
       
   583   int16 reorder_idx[2][MAX_MONO_SAMPLES];
       
   584   
       
   585   /*-- Common complexity reduction and output stream parameters. --*/
       
   586   Out_Complexity *complex;
       
   587   Out_Param *out_param;
       
   588 
       
   589   int16 idx_increment;
       
   590   int16 FreeFormatSlots;
       
   591   int16 PrevSlots;
       
   592   int32 FrameStart;
       
   593   BOOL SkipBr;
       
   594   BOOL WasSeeking;
       
   595   int16 SlotTable[15];
       
   596   int16 FrameTable[15];
       
   597   int32 PrevStreamInfo[2];
       
   598 
       
   599   
       
   600 };
       
   601 
       
   602 
       
   603 BOOL InitBrInfo(CMP_Stream *mp, TMP_BrInfo *brInfo);
       
   604 inline void SetBitrate(CMP_Stream *mp, int16 br)
       
   605 { mp->brInfo.cum_br += br; mp->brInfo.cum_frames++; }
       
   606 BOOL CountAveBr(CMP_Stream *mp, TBitStream *bs_mcu, TMP_BrInfo *brInfo);
       
   607 void FinishAveBr(TMP_BrInfo *brInfo, BOOL FullCount);
       
   608 
       
   609 /* Implementations defined in module 'mstream.cpp'. */
       
   610 CMP_Stream *GetMP3HandleL(void);
       
   611 void ReleaseMP3Decoder(CMP_Stream *mp);
       
   612 int32 main_data_slots(CMP_Stream *mp);
       
   613 void decode_header(CMP_Stream *mp, TBitStream *bs);
       
   614 void  MP3DecPrepareInit(CMP_Stream *mp, Out_Param *out_param, 
       
   615             Out_Complexity *complex, DSP_BYTE *br_buffer, 
       
   616             uint32 br_size);
       
   617 void MP3DecCompleteInit(CMP_Stream *mp, int16 *frameBytes);
       
   618 
       
   619 /* Implementations defined in module 'mp3.cpp'. */
       
   620 SEEK_STATUS FreeFormat(CMP_Stream *mp, TBitStream *bs_mcu, 
       
   621                ExecState *execState, int16 *nSlots);
       
   622 SEEK_STATUS SeekSync(CMP_Stream *mp, TBitStream *bs_mcu, 
       
   623              ExecState *execState, int16 *frameBytes);
       
   624 void ReInitEngine(CMP_Stream *mp);
       
   625 void ResetEngine(CMP_Stream *mp);
       
   626 MP3_Error DecodeFrame(CMP_Stream *mp, int16 *pcm_sample, int16 idx_increment);
       
   627 int16 L3BitReservoir(CMP_Stream *mp);
       
   628 
       
   629 /* Implementations defined in module 'sfb.cpp'. */
       
   630 void III_SfbDataInit(CIII_SfbData *sfbData, TMPEG_Header *header);
       
   631 void III_BandLimit(CIII_SfbData *sfbData, uint16 binLimit);
       
   632 
       
   633 
       
   634 /*
       
   635  * Low level implementations for the mp3 engine. 
       
   636  */
       
   637 
       
   638 /* Implementations defined in module 'layer3.cpp'. */
       
   639 BOOL III_get_side_info(CMP_Stream *mp, TBitStream *bs);
       
   640 void III_get_scale_factors(CMP_Stream *mp, int16 gr, int16 ch);
       
   641 void init_III_reorder(int16 reorder_idx[2][MAX_MONO_SAMPLES],
       
   642               int16 *sfb_table, int16 *sfb_width_table);
       
   643 void III_reorder(CMP_Stream *mp, int16 ch, int16 gr);
       
   644 
       
   645 /* Implementations defined in module 'mp3_q.cpp'. */
       
   646 void III_dequantize(CMP_Stream *mp, int16 gr);
       
   647 
       
   648 /* Implementations defined in module 'stereo.cpp'. */
       
   649 void III_stereo_mode(CMP_Stream *mp, int16 gr);
       
   650 
       
   651 /* Implementations defined in module 'huffman.cpp'. */
       
   652 int16 III_huffman_decode(CMP_Stream *mp, int16 gr, int16 ch, int32 part2);
       
   653 void
       
   654 pairtable(CMP_Stream *mp, int16 section_length, int16 table_num, int16 *quant);
       
   655 int16
       
   656 quadtable(CMP_Stream *mp, int16 start, int16 part2, int16 table_num, int16 *quant,
       
   657           int16 max_sfb_bins);
       
   658 
       
   659 void init_huffman(CHuffman *h);
       
   660 
       
   661 /*-- Include encoder interface. --*/
       
   662 #ifdef L3ENC
       
   663 //#include "l3enc.h"
       
   664 #endif /*-- L3ENC --*/
       
   665 
       
   666 #endif /* MP_STREAM_H_ */