home *** CD-ROM | disk | FTP | other *** search
/ modiromppu / modiromppu.iso / PROGRAMS / ORGPACKS / MPG12304.ZIP / MPG123.H < prev    next >
C/C++ Source or Header  |  1997-05-06  |  7KB  |  270 lines

  1. /*
  2.  * mpg123 defines 
  3.  * used source: musicout.h from mpegaudio package
  4.  */
  5.  
  6. #include        <stdio.h>
  7. #include        <string.h>
  8. #include        <math.h>
  9.  
  10. #include        <unistd.h>
  11.  
  12. #ifdef SGI
  13. #include <audio.h>
  14. #endif
  15.  
  16. #ifdef SUNOS
  17. #define memmove bcopy
  18. #endif
  19.  
  20. #ifdef REAL_IS_FLOAT
  21. #  define real float
  22. #elif defined(REAL_IS_LONG_DOUBLE)
  23. #  define real long double
  24. #else
  25. #  define real double
  26. #endif
  27.  
  28. #ifdef __GNUC__
  29. #define INLINE inline
  30. #else
  31. #define INLINE
  32. #endif
  33.  
  34. #if defined(LINUX) || defined(__FreeBSD__)
  35. #define VOXWARE
  36. #endif
  37.  
  38. /* AUDIOBUFSIZE = n*64 with n=1,2,3 ...  */
  39. #define   AUDIOBUFSIZE    1024
  40.  
  41. #define         FALSE                   0
  42. #define         TRUE                    1
  43.  
  44. #define         MAX_NAME_SIZE           81
  45. #define         SBLIMIT                 32
  46. #define         SCALE_BLOCK             12
  47. #define         SSLIMIT                 18
  48.  
  49. #define         MPG_MD_STEREO           0
  50. #define         MPG_MD_JOINT_STEREO     1
  51. #define         MPG_MD_DUAL_CHANNEL     2
  52. #define         MPG_MD_MONO             3
  53.  
  54. #define         M_PI                    3.14159265359
  55. #define         M_SQRT2                 1.41421356237
  56.  
  57. enum { AUDIO_OUT_HEADPHONES,AUDIO_OUT_INTERNAL_SPEAKER,AUDIO_OUT_LINE_OUT };
  58. enum { DECODE_TEST, DECODE_AUDIO, DECODE_STDOUT, DECODE_BUFFER };
  59.  
  60. struct al_table 
  61. {
  62.   short bits;
  63.   short d;
  64. };
  65.  
  66. struct frame {
  67.     struct al_table *alloc;
  68.     int (*synth)(real *,int,short *);
  69.     int stereo;
  70.     int jsbound;
  71.     int single;
  72.     int II_sblimit;
  73.     int version;
  74.     int lay;
  75.     int error_protection;
  76.     int bitrate_index;
  77.     int sampling_frequency;
  78.     int padding;
  79.     int extension;
  80.     int mode;
  81.     int mode_ext;
  82.     int copyright;
  83.     int original;
  84.     int emphasis;
  85. };
  86.  
  87. #if defined(HPUX) || defined(SUNOS) || defined(SOLARIS) || defined(VOXWARE)
  88. #define AUDIO_USES_FD
  89. #endif
  90.  
  91. struct audio_info_struct
  92. {
  93. #ifdef AUDIO_USES_FD
  94.   int fn; /* filenumber */
  95. #endif
  96. #ifdef SGI
  97.   ALconfig config;
  98.   ALport port;
  99. #endif
  100.   long rate;
  101.   int gain;
  102.   int output;
  103.   char *device;
  104.   int channels;
  105. };
  106.  
  107. extern int outmode;  
  108. extern int tryresync;
  109. extern int quiet;
  110. extern int halfspeed;
  111. extern int usebuffer;
  112. extern int buffer_fd[2];
  113. extern char *prgName, *prgVersion;
  114.  
  115. extern int audio_play_samples(struct audio_info_struct *,short *,int);
  116. extern void buffer_loop(struct audio_info_struct *ai);
  117.  
  118. /* ------ Declarations from "httpget.c" ------ */
  119.  
  120. extern char *proxyurl;
  121. extern unsigned long proxyip;
  122. extern FILE *http_open (char *url);
  123.  
  124. /* ------ Declarations from "common.c" ------ */
  125.  
  126. extern void audio_flush(int, struct audio_info_struct *);
  127. extern void (*catchsignal(int signum, void(*handler)()))();
  128. extern unsigned int   get1bit(void);
  129. extern unsigned int   getbits(int);
  130. extern unsigned int   getbits_fast(int);
  131.  
  132. extern short pcm_sample[AUDIOBUFSIZE];
  133. extern int pcm_point;
  134. extern int audiobufsize;
  135.  
  136. #ifdef VARMODESUPPORT
  137. extern int varmode;
  138. extern int playlimit;
  139. #endif
  140.  
  141. struct III_sideinfo
  142. {
  143.   unsigned main_data_begin;
  144.   unsigned private_bits;
  145.   struct {
  146.     struct gr_info_s {
  147.       int scfsi;
  148.       unsigned part2_3_length;
  149.       unsigned big_values;
  150.       unsigned scalefac_compress;
  151.       unsigned block_type;
  152.       unsigned mixed_block_flag;
  153.       unsigned table_select[3];
  154.       unsigned subblock_gain[3];
  155.       unsigned maxband[3];
  156.       unsigned maxbandl;
  157.       unsigned region1start;
  158.       unsigned region2start;
  159.       unsigned preflag;
  160.       unsigned scalefac_scale;
  161.       unsigned count1table_select;
  162.       real *full_gain[3];
  163.       real *pow2gain;
  164.     } gr[2];
  165.   } ch[2];
  166. };
  167.  
  168. extern void open_stream(char *);
  169. extern void close_stream(char *);
  170. extern int read_frame(struct frame *fr);
  171. extern int do_layer3(struct frame *fr,int,struct audio_info_struct *);
  172. extern int do_layer2(struct frame *fr,int,struct audio_info_struct *);
  173. extern int do_layer1(struct frame *fr,int,struct audio_info_struct *);
  174. extern void print_header(struct frame *);
  175. extern void set_pointer(long);
  176. extern int synth_1to1 (real *,int,short *);
  177. extern int synth_2to1 (real *,int,short *);
  178. extern int synth_4to1 (real *,int,short *);
  179. extern void rewindNbits(int bits);
  180. extern int  hsstell(void);
  181. extern void set_pointer(long);
  182. extern void huffman_decoder(int ,int *);
  183. extern void huffman_count1(int,int *);
  184.  
  185. extern void init_layer3(void);
  186. extern void init_layer2(void);
  187. extern void make_decode_tables(long scale);
  188.  
  189. extern int audio_open(struct audio_info_struct *);
  190. extern int audio_set_rate(struct audio_info_struct *);
  191. extern int audio_set_channels(struct audio_info_struct *);
  192. extern int audio_write_sample(struct audio_info_struct *,short *,int);
  193. extern int audio_close(struct audio_info_struct *);
  194.  
  195. extern long freqs[4];
  196. extern real muls[27][64];
  197. extern real decwin[512+32];
  198. extern real *pnts[5];
  199.  
  200. #ifdef I386_ASSEM
  201.  
  202. extern unsigned char *wordpointer;
  203. extern int bitindex,tellcnt;
  204.  
  205. unsigned int   get1bit(void);
  206. #pragma aux getbits=\
  207.         "cmp ebx,0"\
  208.         "jne L1"\
  209.         "xor eax,eax"\
  210.         "jmp l2"\
  211.         "L1:"\
  212.         "mov    ecx,offset wordpointer"\
  213.         "movzx   eax,byte ptr[ecx]"\
  214.         "shl    eax,16"\
  215.         "mov     ah,byte ptr[ecx]+1"\
  216.         "mov     al,byte ptr[ecx]+2"\
  217.         "mov     ecx,bitindex"\
  218.         "shl    eax,8"\
  219.         "shl    eax,cl"\
  220.         "mov    ecx,ebx"\
  221.         "add    bitindex,ecx"\
  222.         "add    tellcnt,ecx"\
  223.         "neg    ecx"\
  224.         "add    ecx,032h"\
  225.         "shr    eax,cl"\
  226.         "mov    ecx,bitindex"\
  227.         "sar    ecx,03h"\
  228.         "add    [wordpointer],ecx"\
  229.         "and    bitindex,07h"\
  230.         "l2:"\
  231.         parm [ebx] value [eax] modify [ecx];
  232.  
  233. unsigned int   getbits(int);
  234. #pragma aux getbits_fast=\
  235.         "mov    ecx,offset wordpointer"\
  236.         "movzx  eax,byte ptr[ecx+1]"\
  237.         "mov    ah,[ecx]"\
  238.         "mov    ecx,bitindex"\
  239.         "shl    ax,cl"\
  240.         "mov    ecx,ebx"\
  241.         "add    bitindex,ecx"\
  242.         "add    tellcnt,ecx"\
  243.         "neg    ecx"\
  244.         "add    ecx,016h"\
  245.         "shr    eax,cl"\
  246.         "mov    ecx,bitindex"\
  247.         "sar    ecx,03h"\
  248.         "add    [wordpointer],ecx"\
  249.         "and    bitindex,07h"\
  250.         parm [ebx] value [eax] modify [ecx];
  251.  
  252. unsigned int   getbits_fast(int);
  253. #pragma aux get1bit=\
  254.         "mov    ecx,offset wordpointer"\
  255.         "movzx  eax,byte ptr[ecx]"\
  256.         "inc    tellcnt"\
  257.         "mov    ecx,bitindex"\
  258.         "inc    ecx"\
  259.         "rol    al,cl"\
  260.         "and    al,1"\
  261.         "mov    bitindex,ecx"\
  262.         "and    bitindex,07h"\
  263.         "sar    ecx,3"\
  264.         "add    [wordpointer],ecx"\
  265.         parm [ebx] value [eax] modify [ecx];
  266.  
  267. #endif
  268.  
  269. extern int verbose;
  270.