DECODER.H
上传用户:njqiyou
上传日期:2007-01-08
资源大小:574k
文件大小:18k
源码类别:

mpeg/mp3

开发平台:

C/C++

  1. /**********************************************************************
  2.  * ISO MPEG Audio Subgroup Software Simulation Group (1996)
  3.  * ISO 13818-3 MPEG-2 Audio Multichannel Decoder
  4.  *
  5.  * $Id: decoder.h 1.11 1996/04/18 05:37:23 rowlands Exp $
  6.  *
  7.  * $Log: decoder.h $
  8.  * Revision 1.11  1996/04/18 05:37:23  rowlands
  9.  * Release following Florence meeting
  10.  *
  11.  * Revision 1.10  1996/02/12 07:13:06  rowlands
  12.  * Release following Munich meeting
  13.  *
  14.  * Revision 1.9.1.1  1996/01/20  17:28:45  rowlands
  15.  * Received from Ralf Schwalbe (Telekom FTZ) - includes prediction
  16.  *
  17.  * Revision 1.7.1.3  1995/08/14  08:13:06  tenkate
  18.  * ML-LSF added Warner ten Kate 7/8/95 (Philips)
  19.  *
  20.  * Revision 1.7.1.1  1995/07/14  06:12:46  rowlands
  21.  * Updated dynamic crosstalk from FTZ: revision FTZ_03
  22.  *
  23.  * Revision 1.3.3.1  1995/06/16  08:00:46  rowlands
  24.  * Input from Sang Wook Kim (Samsung AIT)
  25.  *
  26.  * Revision 1.3.1.1  1995/06/14  04:35:34  rowlands
  27.  * Added declaration for dematrix procedure 2 routines.
  28.  *
  29.  **********************************************************************/
  30. /**********************************************************************
  31.  *   date   programmers                comment                        *
  32.  * 2/25/91  Douglas Wong        start of version 1.0 records          *
  33.  * 3/06/91  Douglas Wong        rename setup.h to dedef.h             *
  34.  *                              removed extraneous variables          *
  35.  *                              removed window_samples (now part of   *
  36.  *                              filter_samples)                       *
  37.  * 3/07/91  Davis Pan           changed output file to "codmusic"     *
  38.  * 5/10/91  Vish (PRISM)        Ported to Macintosh and Unix.         *
  39.  *                              Incorporated new "out_fifo()" which   *
  40.  *                              writes out last incomplete buffer.    *
  41.  *                              Incorporated all AIFF routines which  *
  42.  *                              are also compatible with SUN.         *
  43.  *                              Incorporated user interface for       *
  44.  *                              specifying sound file names.          *
  45.  *                              Also incorporated user interface for  *
  46.  *                              writing AIFF compatible sound files.  *
  47.  * 27jun91  dpwe (Aware)        Added musicout and &sample_frames as  *
  48.  *                              args to out_fifo (were glob refs).    *
  49.  *                              Used new 'frame_params' struct.       *
  50.  *                              Clean,simplify, track clipped output  *
  51.  *                              and total bits/frame received.        *
  52.  * 7/10/91  Earle Jennings      changed to floats to FLOAT            *
  53.  *10/ 1/91  S.I. Sudharsanan,   Ported to IBM AIX platform.           *
  54.  *          Don H. Lee,                                               *
  55.  *          Peter W. Farrett                                          *
  56.  *10/ 3/91  Don H. Lee          implemented CRC-16 error protection   *
  57.  *                              newly introduced functions are        *
  58.  *                              buffer_CRC and recover_CRC_error      *
  59.  *                              Additions and revisions are marked    *
  60.  *                              with "dhl" for clarity                *
  61.  * 2/11/92  W. Joseph Carter    Ported new code to Macintosh.  Most   *
  62.  *                              important fixes involved changing     *
  63.  *                              16-bit ints to long or unsigned in    *
  64.  *                              bit alloc routines for quant of 65535 *
  65.  *                              and passing proper function args.     *
  66.  *                              Removed "Other Joint Stereo" option   *
  67.  *                              and made bitrate be total channel     *
  68.  *                              bitrate, irrespective of the mode.    *
  69.  *                              Fixed many small bugs & reorganized.  *
  70.  **********************************************************************
  71.  *                                                                    *
  72.  *                                                                    *
  73.  *  MPEG/audio Phase 2 coding/decoding multichannel                   *
  74.  *                                                                    *
  75.  *  Version 1.0                                                       *
  76.  *                                                                    *
  77.  *  7/27/93        Susanne Ritscher,  IRT Munich                      *
  78.  *                                                                    *
  79.  *                  thanks to                                         *
  80.  *                  Ralf Schwalbe,    Telekom FTZ Berlin              *
  81.  *                  Heiko Purnhagen,  Uni Hannover                    *
  82.  *                                                                    *
  83.  *  Version 2.0                                                       *
  84.  *                                                                    *
  85.  *  8/27/93        Susanne Ritscher, IRT Munich                       *
  86.  *                 Channel-Switching is working                       *
  87.  *                                                                    *
  88.  *  Version 2.1                                                       *
  89.  *                                                                    *
  90.  *  9/1/93         Susanne Ritscher,  IRT Munich                      *
  91.  *                 all channels normalized                            *
  92.  *                                                                    *
  93.  *  Version 3.0                                                       *
  94.  *                                                                    *
  95.  *  06/16/94       Ralf Schwalbe, Telekom FTZ Berlin                  *
  96.  *                 all sources and variables adapted due to MPEG-2 -  *
  97.  *                 DIS from March 1994                                *
  98.  *                  - dematrix and denormalize procedure              *
  99.  *                  - new tc - allocation (0-7)                       *
  100.  *                  - some new structures and variables as a basis    *
  101.  *                    for further decoding modes                      *
  102.  **********************************************************************
  103.  *       *
  104.  *  Version 1.0                                                       *
  105.  *                                                                    *
  106.  *  11/04/94       Ralf Schwalbe,  Telekom FTZ Berlin                 *
  107.  *                  - decoding tc-allocation                          *
  108.  *                  - some new subroutines, globale variables and     *
  109.  *                    structures (important to handle the ext. bitst.)*
  110.  *                  - changed all functions to ANSI-C funktion header *
  111.  *     - corrected some bugs to decode bitstreams > 512kB*
  112.  *       *
  113.  *  Version 1.1                                                       *
  114.  *                                                                    *
  115.  *  12/07/94       Ralf Schwalbe,  Telekom FTZ Berlin                 *
  116.  *                  - decoding extension bitstream                    *
  117.  *                                                                    *
  118.  *  Version 1.1.1                                                     *
  119.  *                 Ralf Schwalbe, Telekom FTZ Berlin                  *
  120.  *                  - fixed some bugs                                 *
  121.  *                                                                    *
  122.  *  Version 1.2                                                       *
  123.  *                                                                    *
  124.  *  6/21/95       Ralf Schwalbe, Deutsche Telekom FTZ Berlin          *
  125.  *                 - decoding dynamic crosstalk                      *
  126.  *                  - decoding phantom center                         * 
  127.  *                  - decoding MPEG1 compatible part only (stereo)    *
  128.  *                  - corrected some settings and bugs                *
  129.  *                                                                    *   
  130.  *  7/12/95   Ralf Schwalbe, Deutsche Telekom FTZ Berlin          *
  131.  *     - corrected dynamic crosstalk        *
  132.  *     - 3/2,3/1,3/0,2/1, channel configurations         *
  133.  *                    are working                                     *
  134.  *          *
  135.  * 10/31/95   Ralf Schwalbe, Deutsche Telekom FTZ Berlin       *
  136.  *     - decoding of LFE-channel is working         *
  137.  *     - corrected any settings and bugs       *
  138.  *     - corrected table-switch for channel mode < 3/2   *
  139.  *       and tc-allocation / dyn-crosstalk       *
  140.  *     - still a problem with compl. bitstream 18/19     *
  141.  *       *
  142.  * 01/12/96   Ralf Schwalbe, Deutsche Telekom TZ Darmstadt       *
  143.  *     - decoder prediction installed       *
  144.  *     - problem with compl. bitstream 19 solved,        *
  145.  *          *
  146.  *  Version 2.0                                                       *
  147.  *                                                                    *
  148.  * 01/28/97       Frans de Bont, Philips Sound & Vision, Eindhoven    *
  149.  *     - simultaneous use of tc allocation and dynamic   *
  150.  *       crosstalk working for all configurations       *
  151.  *     - prediction working for all configurations       *
  152.  *     - layer 1 MC working       *
  153.  *     - variable bit rate and extension bitstreams      *
  154.  *     - fully compliant to 13818-3.2                    *
  155.  *                                                                    *       *     
  156.  **********************************************************************/
  157. /**********************************************************************
  158.  *                                                                    *
  159.  *  06/06/95       Yeon Bae Thomas Kim,  Samsung AIT                  *
  160.  *    ancillary data is working       *
  161.  *       *
  162.  **********************************************************************/
  163. /***********************************************************************
  164. *
  165. *  Decoder Include Files
  166. *
  167. ***********************************************************************/
  168. /***********************************************************************
  169. *
  170. *  Decoder Definitions
  171. *
  172. ***********************************************************************/
  173. #define  DFLT_IPEXT_MPG    ".mpg"  /* default input for base file */
  174. #define  DFLT_IPEXT_EXT    ".ext"  /* default input for extension file */
  175. #define  DFLT_OPEXT_DEC    ".dec"   /* default output file name extension */
  176. #define  DFLT_OPEXT_LFE    "_lfe.dec"  /* 10/31/95 R.S. output for lfe pcm-file */
  177. #define  DFLT_OPEXT_ML    ".ml"  /* default MultiLingual output file name extension */
  178. #define  FILTYP_DEC_AIFF   "AIFF" /* '-> " . 7/13/92. sr */
  179. #define  FILTYP_DEC_BNRY   "TEXT" /* '-> " . 7/13/92. sr */
  180. #define  CREATR_DEC_AIFF   "Sd2a" /* '-> " . 7/13/92. sr */
  181. #define  CREATR_DEC_BNRY   "????" /* '-> " . 7/13/92. sr */
  182. #define   SYNC_WORD         (long) 0xfff
  183. #define   SYNC_WORD_LNGTH   12
  184. #define   MUTE              0
  185. #define   STEP     0.03125  /* 13.10.93 R.S. step for prediction */
  186. #define   PREDDEL           (2+7)        /* max. delay in prediction, HP 08-nov-94 */
  187. #define   EXTENSION_CRC_CHECK
  188. /***********************************************************************
  189. *
  190. *  Decoder Type Definitions
  191. *
  192. ***********************************************************************/
  193. /***********************************************************************
  194. *
  195. *  Decoder Variable External Declarations
  196. *
  197. ***********************************************************************/
  198.  
  199. /***********************************************************************
  200. *
  201. *  Decoder Function Prototype Declarations
  202. *
  203. ***********************************************************************/
  204. /* The following functions are in the file "musicout.c" */
  205. #ifdef   PROTO_ARGS
  206. extern void   usage(void);
  207. #else
  208. extern void   usage();
  209. #endif
  210. /* The following functions are in the file "decode.c" */
  211. #ifdef   PROTO_ARGS
  212. extern void   decode_info(Bit_stream*, frame_params*);
  213. extern void   mc_header(Bit_stream*, frame_params*);
  214. extern void   mc_composite_status_info(Bit_stream*, frame_params*, int, int);
  215. #ifdef Augmentation_7ch
  216. extern void   mc_aug_composite_status_info(Bit_stream*, frame_params*, int, int);
  217. #endif
  218. extern void   I_decode_bitalloc(Bit_stream*, frame_params*, unsigned int[7][SBLIMIT], int);
  219. extern void   II_decode_bitalloc(Bit_stream*, frame_params*, unsigned int[7][SBLIMIT], int);
  220. extern void   II_decode_bitalloc_mc(Bit_stream*, frame_params*, unsigned int[7][SBLIMIT], int*, int*, int);
  221. #ifdef Augmentation_7ch
  222. extern void   II_decode_bitalloc_aug(Bit_stream*, frame_params*, unsigned int[7][SBLIMIT], int*, int*, int);
  223. #endif
  224. extern void   II_decode_bitalloc_ml(Bit_stream*, frame_params*, unsigned int[7][SBLIMIT], int*);
  225. extern void   I_decode_scale(Bit_stream*, frame_params*, unsigned int[7][SBLIMIT],
  226.    unsigned int[7][3][SBLIMIT],
  227.    int, int);
  228. extern void   II_decode_scale(Bit_stream*, frame_params*, unsigned int[7][SBLIMIT],
  229.    unsigned int[7][SBLIMIT], unsigned int[7][3][SBLIMIT],
  230.    int*, int*, int);
  231. extern void   II_decode_scale_ml(Bit_stream*, frame_params*, unsigned int[7][SBLIMIT],
  232.    unsigned int[7][SBLIMIT], unsigned int[7][3][SBLIMIT],
  233.    int*);
  234. extern void   I_buffer_sample(Bit_stream*, frame_params*, unsigned int[7][3][SBLIMIT],
  235.    unsigned int[7][SBLIMIT]);
  236. extern void   II_buffer_sample(Bit_stream*, frame_params*, unsigned int[7][3][SBLIMIT],
  237.    unsigned int[7][SBLIMIT]);
  238. extern void   II_buffer_sample_mc(Bit_stream*, frame_params*, unsigned int[7][3][SBLIMIT],
  239.    unsigned int[7][SBLIMIT], int, int, int);
  240. #ifdef Augmentation_7ch
  241. extern void   II_buffer_sample_aug(Bit_stream*, frame_params*, unsigned int[7][3][SBLIMIT],
  242.    unsigned int[7][SBLIMIT], int);
  243. #endif
  244. extern void   II_buffer_sample_ml(Bit_stream*, frame_params*, unsigned int[7][3][SBLIMIT],
  245.    unsigned int[7][SBLIMIT], int*);
  246. extern void   I_dequantize_sample(unsigned int[7][3][SBLIMIT], int,
  247.    unsigned int[7][SBLIMIT], double[7][SBLIMIT][3][12],
  248.    frame_params*, int*);
  249. extern void   II_dequantize_sample(unsigned int[7][3][SBLIMIT],
  250.    unsigned int[7][SBLIMIT], double[7][SBLIMIT][3][12],
  251.    frame_params*, int*);
  252. extern void   II_dequantize_sample_mc(unsigned int[7][3][SBLIMIT],
  253.    unsigned int[7][SBLIMIT], double[7][SBLIMIT][3][12],
  254.    frame_params*, int, int, int*);
  255. #ifdef Augmentation_7ch
  256. extern void   II_dequantize_sample_aug(unsigned int[7][3][SBLIMIT],
  257.    unsigned int[7][SBLIMIT], double[7][SBLIMIT][3][12],
  258.    frame_params*, int*);
  259. #endif
  260. extern void   II_dequantize_sample_ml(unsigned int[7][3][SBLIMIT],
  261.    unsigned int[7][SBLIMIT], double[7][SBLIMIT][3][12],
  262.    frame_params*, int*, int*);
  263. extern void   II_lfe_calc(frame_params*);
  264. extern void   I_denormalize_sample(double[7][SBLIMIT][3][12],
  265.    unsigned int[7][3][SBLIMIT], int, frame_params*, int*);
  266. extern void   II_denormalize_sample(double[7][SBLIMIT][3][12],
  267.    unsigned int[7][3][SBLIMIT], frame_params*, int, int*);
  268. extern void   II_denormalize_sample_mc(double[7][SBLIMIT][3][12],
  269.    unsigned int[7][3][SBLIMIT], frame_params*, int, int, int, int*);
  270. #ifdef Augmentation_7ch
  271. extern void   II_denormalize_sample_aug(double[7][SBLIMIT][3][12],
  272.    unsigned int[7][3][SBLIMIT], frame_params*, int, int*);
  273. #endif
  274. extern void   II_denormalize_sample_ml(double[7][SBLIMIT][3][12],
  275.    unsigned int[7][3][SBLIMIT], frame_params*, int, int*, int*);
  276. extern int    SubBandSynthesis(double*, int, long*);
  277. extern int    SubBandSynthesis_ml(double*, int, long*);
  278. extern void   out_fifo(long[7][3][SBLIMIT], int, frame_params*, int, FILE*, unsigned long*,int);
  279. extern void   out_fifo_ml(long[7][3][SBLIMIT], int, frame_params*, int, FILE*, unsigned long*);
  280. extern void   buffer_CRC(Bit_stream*, unsigned int*);
  281. extern void   recover_CRC_error(long[7][3][SBLIMIT], int, frame_params*,FILE*,unsigned long*,int);
  282. extern void   dematricing_mc(double[7][SBLIMIT][3][12], frame_params*, double[2][8][36+PREDDEL]);
  283. #ifdef Augmentation_7ch
  284. extern void   dematricing_aug(double[7][SBLIMIT][3][12], frame_params*);
  285. #endif
  286. extern void   denormalizing_mc(double[7][SBLIMIT][3][12], frame_params*, int); 
  287. #ifdef Augmentation_7ch
  288. extern void   denormalizing_aug(double[7][SBLIMIT][3][12], frame_params*); 
  289. #endif
  290. #else
  291. extern void   decode_info();
  292. extern void   mc_header();
  293. extern void   mc_composite_status_info();
  294. #ifdef Augmentation_7ch
  295. extern void   mc_aug_composite_status_info();
  296. #endif
  297. extern void   I_decode_bitalloc();
  298. extern void   II_decode_bitalloc();
  299. extern void   II_decode_bitalloc_mc();
  300. #ifdef Augmentation_7ch
  301. extern void   II_decode_bitalloc_aug();
  302. #endif
  303. extern void   II_decode_bitalloc_ml();
  304. extern void   I_decode_scale();
  305. extern void   II_decode_scale();
  306. extern void   II_decode_scale_ml();
  307. extern void   I_buffer_sample();
  308. extern void   II_buffer_sample();
  309. extern void   II_buffer_sample_mc();
  310. #ifdef Augmentation_7ch
  311. extern void   II_buffer_sample_aug();
  312. #endif
  313. extern void   II_buffer_sample_ml();
  314. extern void   I_dequantize_sample();
  315. extern void   II_dequantize_sample();
  316. extern void   II_dequantize_sample_mc();
  317. #ifdef Augmentation_7ch
  318. extern void   II_dequantize_sample_aug();
  319. #endif
  320. extern void   II_dequantize_sample_ml();
  321. extern void   II_lfe_calc();
  322. extern void   I_denormalize_sample();
  323. extern void   II_denormalize_sample();
  324. extern void   II_denormalize_sample_mc();
  325. #ifdef Augmentation_7ch
  326. extern void   II_denormalize_sample_aug();
  327. #endif
  328. extern void   II_denormalize_sample_ml();
  329. extern int    SubBandSynthesis();
  330. extern int    SubBandSynthesis_ml();
  331. extern void   out_fifo();
  332. extern void   out_fifo_ml();
  333. extern void   buffer_CRC();
  334. extern void   recover_CRC_error();
  335. extern void   dematricing_mc();
  336. #ifdef Augmentation_7ch
  337. extern void   dematricing_aug();
  338. #endif
  339. extern void   denormalizing_mc(); 
  340. #ifdef Augmentation_7ch
  341. extern void   denormalizing_aug(); 
  342. #endif
  343. #endif