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

  1. /**********************************************************************
  2. Copyright (c) 1991 MPEG/audio software simulation group, All Rights Reserved
  3. common.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 4.0                                                        *
  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 additional type definitions for *
  20.  *                              AIFF, double/SANE and "bitstream.c".  *
  21.  *                              Added function prototypes for more    *
  22.  *                              rigorous type checking.               *
  23.  * 27jun91  dpwe (Aware)        Added "alloc_*" defs & prototypes     *
  24.  *                              Defined new struct 'frame_params'.    *
  25.  *                              Changed info.stereo to info.mode_ext  *
  26.  *                              #define constants for mode types      *
  27.  *                              Prototype arguments if PROTO_ARGS     *
  28.  * 5/28/91  Earle Jennings      added MS_DOS definition               *
  29.  *                              MsDos function prototype declarations *
  30.  * 7/10/91  Earle Jennings      added FLOAT definition as double      *
  31.  *10/ 3/91  Don H. Lee          implemented CRC-16 error protection   *
  32.  * 2/11/92  W. Joseph Carter    Ported new code to Macintosh.  Most   *
  33.  *                              important fixes involved changing     *
  34.  *                              16-bit ints to long or unsigned in    *
  35.  *                              bit alloc routines for quant of 65535 *
  36.  *                              and passing proper function args.     *
  37.  *                              Removed "Other Joint Stereo" option   *
  38.  *                              and made bitrate be total channel     *
  39.  *                              bitrate, irrespective of the mode.    *
  40.  *                              Fixed many small bugs & reorganized.  *
  41.  *                              Modified some function prototypes.    *
  42.  *                              Changed BUFFER_SIZE back to 4096.     *
  43.  * 7/27/92  Michael Li          (re-)Ported to MS-DOS                 *
  44.  * 7/27/92  Masahiro Iwadare    Ported to Convex                      *
  45.  * 8/07/92  mc@tv.tek.com                                             *
  46.  * 8/10/92  Amit Gulati         Ported to the AIX Platform (RS6000)   *
  47.  *                              AIFF string constants redefined       *
  48.  * 8/27/93 Seymour Shlien,      Fixes in Unix and MSDOS ports,        *
  49.  *         Daniel Lauzon, and                                         *
  50.  *         Bill Truerniet                                             *
  51.  **********************************************************************/
  52.  
  53. /***********************************************************************
  54. *
  55. *  Global Conditional Compile Switches
  56. *
  57. ***********************************************************************/
  58.  
  59. #define      UNIX            /* Unix conditional compile switch */
  60. /* #define      MACINTOSH       /* Macintosh conditional compile switch */
  61. /* #define      MS_DOS          /* IBM PC conditional compile switch */
  62. /* #define      MSC60           /* Compiled for MS_DOS with MSC v6.0 */
  63. /* #define      AIX             /* AIX conditional compile switch    */
  64. /* #define      CONVEX          /* CONVEX conditional compile switch */
  65.  
  66. #if defined(MSC60) 
  67. #ifndef MS_DOS
  68. #define MS_DOS
  69. #endif
  70. #ifndef PROTO_ARGS
  71. #define PROTO_ARGS
  72. #endif
  73. #endif
  74.  
  75. #ifdef  UNIX
  76. #define         TABLES_PATH     "tables"  /* to find data files */
  77. /* name of environment variable holding path of table files */
  78. #define         MPEGTABENV      "MPEGTABLES"
  79. #define         PATH_SEPARATOR  "/"        /* how to build paths */
  80. #endif  /* UNIX */
  81.  
  82. #ifdef  MACINTOSH
  83. /* #define      TABLES_PATH ":tables:"  /* where to find data files */
  84. #endif  /* MACINTOSH */
  85.  
  86. /* 
  87.  * Don't define FAR to far unless you're willing to clean up the 
  88.  * prototypes
  89.  */
  90. #define FAR /*far*/
  91.  
  92. #ifdef __STDC__
  93. #ifndef PROTO_ARGS
  94. #define PROTO_ARGS
  95. #endif
  96. #endif
  97.  
  98. #ifdef CONVEX
  99. #define SEEK_SET        0
  100. #define SEEK_CUR        1
  101. #define SEEK_END        2
  102. #endif
  103.  
  104. /* MS_DOS and VMS do not define TABLES_PATH, so OpenTableFile will default
  105.    to finding the data files in the default directory */
  106.  
  107. /***********************************************************************
  108. *
  109. *  Global Include Files
  110. *
  111. ***********************************************************************/
  112.  
  113. #include        <stdio.h>
  114. #include        <string.h>
  115. #include        <math.h>
  116.  
  117. #ifdef  UNIX
  118. #include        <unistd.h>
  119. #endif  /* UNIX */
  120.  
  121. #ifdef  MACINTOSH
  122. #include        <stdlib.h>
  123. #include        <console.h>
  124. #endif  /* MACINTOSH */
  125.  
  126. #ifdef  MS_DOS
  127. #include        <stdlib.h>
  128. #ifdef MSC60
  129. #include        <memory.h>
  130. #else
  131. #include        <alloc.h>
  132. #include        <mem.h>
  133. #endif  /* MSC60 */
  134. #endif  /* MS_DOS */
  135.  
  136. #ifdef AMIGA
  137. #include        <stdlib.h>
  138. #ifdef M68881
  139. #include <m68881.h>
  140. #endif
  141. #endif
  142.  
  143. /***********************************************************************
  144. *
  145. *  Global Definitions
  146. *
  147. ***********************************************************************/
  148.  
  149. /* General Definitions */
  150.  
  151. #ifdef  MS_DOS
  152. #define         FLOAT                   double
  153. #else
  154. #define         FLOAT                   float
  155. #endif
  156.  
  157. #define         FALSE                   0
  158. #define         TRUE                    1
  159. #define         NULL_CHAR               '\0'
  160.  
  161. #define         MAX_U_32_NUM            0xFFFFFFFF
  162. #ifndef PI
  163. #define         PI                      3.14159265358979
  164. #endif
  165. #define         PI4                     PI/4
  166. #define         PI64                    PI/64
  167. #define         LN_TO_LOG10             0.2302585093
  168.  
  169. #define         VOL_REF_NUM             0
  170. #define         MPEG_AUDIO_ID           1
  171. #define         MAC_WINDOW_SIZE         24
  172.  
  173. #define         MONO                    1
  174. #define         STEREO                  2
  175. #define         BITS_IN_A_BYTE          8
  176. #define         WORD                    16
  177. #define         MAX_NAME_SIZE           81
  178. #define         SBLIMIT                 32
  179. #define         FFT_SIZE                1024
  180. #define         HAN_SIZE                512
  181. #define         SCALE_BLOCK             12
  182. #define         SCALE_RANGE             64
  183. #define         SCALE                   32768
  184. #define         CRC16_POLYNOMIAL        0x8005
  185.  
  186. /* MPEG Header Definitions - Mode Values */
  187.  
  188. #define         MPG_MD_STEREO           0
  189. #define         MPG_MD_JOINT_STEREO     1
  190. #define         MPG_MD_DUAL_CHANNEL     2
  191. #define         MPG_MD_MONO             3
  192.  
  193. /* AIFF Definitions */
  194.  
  195. /* 
  196.  * Note:  The value of a multi-character constant
  197.  *        is implementation-defined.
  198.  */
  199. #if !defined(MS_DOS) && !defined(AIX)  
  200. #define         IFF_LONG
  201. #define         IFF_ID_FORM             'FORM'
  202. #define         IFF_ID_AIFF             'AIFF'
  203. #define         IFF_ID_COMM             'COMM'
  204. #define         IFF_ID_SSND             'SSND'
  205. #define         IFF_ID_MPEG             'MPEG'
  206. #else
  207. #define         IFF_ID_FORM             "FORM"
  208. #define         IFF_ID_AIFF             "AIFF"
  209. #define         IFF_ID_COMM             "COMM"
  210. #define         IFF_ID_SSND             "SSND"
  211. #define         IFF_ID_MPEG             "MPEG"
  212. #endif
  213.  
  214. /* "bit_stream.h" Definitions */
  215.  
  216. #define         MINIMUM         4    /* Minimum size of the buffer in by