home *** CD-ROM | disk | FTP | other *** search
/ Da Capo / da_capo_vol1.bin / programs / amiga / misc / mpegaudio / encoder.h < prev    next >
C/C++ Source or Header  |  1994-03-21  |  15KB  |  330 lines

  1. /**********************************************************************
  2. Copyright (c) 1991 MPEG/audio software simulation group, All Rights Reserved
  3. encoder.h
  4. **********************************************************************/
  5. /**********************************************************************
  6.  * MPEG/audio coding/decoding software, work in progress              *
  7.  *   NOT for public distribution until verified and approved by the   *
  8.  *   MPEG/audio committee.  For further information, please contact   *
  9.  *   Davis Pan, 508-493-2241, e-mail: pan@gauss.enet.dec.com          *
  10.  *                                                                    *
  11.  * VERSION 3.5                                                       *
  12.  *   changes made since last update:                                  *
  13.  *   date   programmers         comment                               *
  14.  * 2/25/91  Doulas Wong,        start of version 1.0 records          *
  15.  *          Davis Pan                                                 *
  16.  * 5/10/91  W. Joseph Carter    Reorganized & renamed all ".h" files  *
  17.  *                              into "common.h" and "encoder.h".      *
  18.  *                              Ported to Macintosh and Unix.         *
  19.  *                              Added function prototypes for more    *
  20.  *                              rigorous type checking.               *
  21.  * 27jun91  dpwe (Aware)        moved "alloc_*" types, pros to common *
  22.  *                              Use ifdef PROTO_ARGS for prototypes   *
  23.  *                              prototypes reflect frame_params struct*
  24.  * 7/10/91  Earle Jennings      Conversion of all floats to FLOAT     *
  25.  * 10/3/91  Don H. Lee          implemented CRC-16 error protection   *
  26.  *                              Additions and revisions are marked    *
  27.  *                              with "dhl" for clarity                *
  28.  * 2/11/92  W. Joseph Carter    Ported new code to Macintosh.  Most   *
  29.  *                              important fixes involved changing     *
  30.  *                              16-bit ints to long or unsigned in    *
  31.  *                              bit alloc routines for quant of 65535 *
  32.  *                              and passing proper function args.     *
  33.  *                              Removed "Other Joint Stereo" option   *
  34.  *                              and made bitrate be total channel     *
  35.  *                              bitrate, irrespective of the mode.    *
  36.  *                              Fixed many small bugs & reorganized.  *
  37.  *                              Modified some function prototypes.    *
  38.  * 7/27/92  Masahiro Iwadare    FFT modifications for Layer 3         *
  39.  * 8/3/92   Mike Li             removed declaration _stklen for DOS.  *
  40.  * 9/22/92  jddevine@aware.com  Fix protos for _scale_factor_calc()   *
  41.  **********************************************************************/
  42.  
  43. /***********************************************************************
  44. *
  45. *  Encoder Include Files
  46. *
  47. ***********************************************************************/
  48.  
  49. /***********************************************************************
  50. *
  51. *  Encoder Definitions
  52. *
  53. ***********************************************************************/
  54.  
  55. /* General Definitions */
  56.  
  57. /* Default Input Arguments (for command line control) */
  58.  
  59. #define DFLT_LAY        2      /* default encoding layer is II */
  60. #define DFLT_MOD        's'    /* default mode is stereo */
  61. #define DFLT_PSY        2      /* default psych model is 2 */
  62. #define DFLT_SFQ        44.1   /* default input sampling rate is 44.1 kHz */
  63. #define DFLT_BRT        384    /* default total output bitrate is 384 kbps */
  64. #define DFLT_EMP        'n'    /* default de-emphasis is none */
  65. #define DFLT_EXT        ".mpg" /* default output file extension */
  66.  
  67. #define FILETYPE_ENCODE 'TEXT'
  68. #define CREATOR_ENCODE  'MpgD'
  69.  
  70. /* This is the smallest MNR a subband can have before it is counted
  71.    as 'noisy' by the logic which chooses the number of JS subbands */
  72.  
  73. #define NOISY_MIN_MNR   0.0
  74.  
  75. /* Psychacoustic Model 1 Definitions */
  76.  
  77. #define CB_FRACTION     0.33
  78. #define MAX_SNR         1000
  79. #define NOISE           10
  80. #define TONE            20
  81. #define DBMIN           -200.0
  82. #define LAST            -1
  83. #define STOP            -100
  84. #define POWERNORM       90.3090 /* = 20 * log10(32768) to normalize */
  85.                                 /* max output power to 96 dB per spec */
  86.  
  87. /* Psychoacoustic Model 2 Definitions */
  88.  
  89. #define LOGBLKSIZE      10
  90. #define BLKSIZE         1024
  91. #define HBLKSIZE        513
  92. #define CBANDS          63
  93. #define LXMIN           32.0
  94.  
  95. /***********************************************************************
  96. *
  97. *  Encoder Type Definitions
  98. *
  99. ***********************************************************************/
  100.  
  101. /* Psychoacoustic Model 1 Type Definitions */
  102.  
  103. typedef int        IFFT2[FFT_SIZE/2];
  104. typedef int        IFFT[FFT_SIZE];
  105. typedef double     D9[9];
  106. typedef double     D10[10];
  107. typedef double     D640[640];
  108. typedef double     D1408[1408];
  109. typedef double     DFFT2[FFT_SIZE/2];
  110. typedef double     DFFT[FFT_SIZE];
  111. typedef double     DSBL[SBLIMIT];
  112. typedef double     D2SBL[2][SBLIMIT];
  113.  
  114. typedef struct {
  115.         int        line;
  116.         double     bark, hear, x;
  117. } g_thres, *g_ptr;
  118.  
  119. typedef struct {
  120.         double     x;
  121.         int        type, next, map;
  122. } mask, *mask_ptr;
  123.  
  124. /* Psychoacoustic Model 2 Type Definitions */
  125.  
  126. typedef int        ICB[CBANDS];
  127. typedef int        IHBLK[HBLKSIZE];
  128. typedef FLOAT      F32[32];
  129. typedef FLOAT      F2_32[2][32];
  130. typedef FLOAT      FCB[CBANDS];
  131. typedef FLOAT      FCBCB[CBANDS][CBANDS];
  132. typedef FLOAT      FBLK[BLKSIZE];
  133. typedef FLOAT      FHBLK[HBLKSIZE];
  134. typedef FLOAT      F2HBLK[2][HBLKSIZE];
  135. typedef FLOAT      F22HBLK[2][2][HBLKSIZE];
  136. typedef double     DCB[CBANDS];
  137.  
  138. /***********************************************************************
  139. *
  140. *  Encoder Function Prototype Declarations
  141. *
  142. ***********************************************************************/
  143.  
  144. /* The following functions are in the file "musicin.c" */
  145.  
  146. #ifdef        PROTO_ARGS
  147. extern void   obtain_parameters(frame_params*, int*, unsigned long*,
  148.                            char[MAX_NAME_SIZE], char[MAX_NAME_SIZE]);
  149. extern void   parse_args(int, char**, frame_params*, int*, unsigned long*,
  150.                            char[MAX_NAME_SIZE], char[MAX_NAME_SIZE]);
  151. extern void   print_config(frame_params*, int*, unsigned long*,
  152.                            char[MAX_NAME_SIZE], char[MAX_NAME_SIZE]);
  153. void   usage(void);
  154. extern void   aiff_check(char*, IFF_AIFF*);
  155. #else
  156. extern void   obtain_parameters();
  157. extern void   parse_args();
  158. extern void   print_config();
  159. void   usage();
  160. extern void   aiff_check();
  161. #endif
  162.  
  163. /* The following functions are in the file "encode.c" */
  164.  
  165. #ifdef        PROTO_ARGS
  166. extern unsigned long    read_samples(FILE*, short[2304], unsigned long,
  167.                            unsigned long);
  168. extern unsigned long    get_audio(FILE*, short[2][1152], unsigned long,
  169.                            int, int);
  170. extern void   read_ana_window(double[HAN_SIZE]);
  171. extern void   window_subband(short**, double[HAN_SIZE], int);
  172. extern void   create_ana_filter(double[SBLIMIT][64]);
  173. extern void   filter_subband(double[HAN_SIZE], double[SBLIMIT]);
  174. extern void   encode_info(frame_params*, Bit_stream_struc*);
  175. extern double mod(double);
  176. extern void   I_combine_LR(double[2][3][SCALE_BLOCK][SBLIMIT],
  177.                            double[3][SCALE_BLOCK][SBLIMIT]);
  178. extern void   II_combine_LR(double[2][3][SCALE_BLOCK][SBLIMIT],
  179.                            double[3][SCALE_BLOCK][SBLIMIT], int);
  180. extern void   I_scale_factor_calc(double[][3][SCALE_BLOCK][SBLIMIT],
  181.                            unsigned int[][3][SBLIMIT], int);
  182. extern void   II_scale_factor_calc(double[][3][SCALE_BLOCK][SBLIMIT],
  183.                            unsigned int[][3][SBLIMIT], int, int);
  184. extern void   pick_scale(unsigned int[2][3][SBLIMIT], frame_params*,
  185.                            double[2][SBLIMIT]);
  186. extern void   put_scale(unsigned int[2][3][SBLIMIT], frame_params*,
  187.                            double[2][SBLIMIT]);
  188. extern void   II_transmission_pattern(unsigned int[2][3][SBLIMIT],
  189.                            unsigned int[