2 (c) Copyright 1998-2000 - Tord Jansson
3 ======================================
5 This file is part of the BladeEnc MP3 Encoder, based on
6 ISO's reference code for MPEG Layer 3 compression, and might
7 contain smaller or larger sections that are directly taken
8 from ISO's reference code.
10 All changes to the ISO reference code herein are either
11 copyrighted by Tord Jansson (tord.jansson@swipnet.se)
12 or sublicensed to Tord Jansson by a third party.
14 BladeEnc is free software; you can redistribute this file
15 and/or modify it under the terms of the GNU Lesser General Public
16 License as published by the Free Software Foundation; either
17 version 2.1 of the License, or (at your option) any later version.
21 ------------ Changes ------------
23 2000-02-07 Andre Piotrowski
35 /***********************************************************************
37 * Global Include Files
39 ***********************************************************************/
51 #define MIN(A, B) ((A) < (B) ? (A) : (B))
52 #define MAX(A, B) ((A) > (B) ? (A) : (B))
59 #define EXIT_SUCCESS 0
63 #define EXIT_FAILURE 1
70 /***********************************************************************
74 ***********************************************************************/
76 /* General Definitions */
87 #define NULL_CHAR '\0'
89 #define MAX_U_32_NUM 0xFFFFFFFF
92 #define PI 3.14159265358979
97 #define LN_TO_LOG10 0.2302585093
100 #define MPEG_AUDIO_ID 1
101 #define MPEG_PHASE2_LSF 0 /* 1995-07-11 SHN */
108 #define BITS_IN_A_BYTE 8
110 #define MAX_NAME_SIZE 81
113 #define FFT_SIZE 1024
115 #define SCALE_BLOCK 12
116 #define SCALE_RANGE 64
118 #define CRC16_POLYNOMIAL 0x8005
121 /* MPEG Header Definitions - Mode Values */
123 #define MPG_MD_STEREO 0
124 #define MPG_MD_DUAL_CHANNEL 2
125 #define MPG_MD_MONO 3
130 #define MPG_MD_LR_LR 0
131 #define MPG_MD_LR_I 1
132 #define MPG_MD_MS_LR 2
133 #define MPG_MD_MS_I 3
136 /* "bit_stream.h" Definitions */
138 #define MINIMUM 4 /* Minimum size of the buffer in bytes */
139 #define MAX_LENGTH 32 /* Maximum length of word written or
140 read from bit stream */
148 #define BUFFER_SIZE 4096
154 /***********************************************************************
156 * Global Type Definitions
158 ***********************************************************************/
161 /* Structure for Reading Layer II Allocation Tables from File */
169 } sb_alloc, *alloc_ptr;
171 typedef sb_alloc al_table[SBLIMIT][16];
174 /* Header Information Structure */
179 int error_protection;
181 int sampling_frequency;
193 /* Parent Structure Interpreting some Frame Parameters in Header */
197 layer *header; /* raw header information */
198 int actual_mode; /* when writing IS, may forget if 0 chs */
199 al_table *alloc; /* bit allocation table read in */
200 int tab_num; /* number of table as loaded */
201 int stereo; /* 1 for mono, 2 for stereo */
202 int jsbound; /* first band of joint stereo coding */
203 int sblimit; /* total number of sub bands */
208 enum byte_order { order_unknown, order_bigEndian, order_littleEndian };
209 extern enum byte_order NativeByteOrder;
212 /* "bit_stream.h" Type Definitions */
214 typedef struct bit_stream_struc
216 FILE *pt; /* pointer to bit stream device */
217 unsigned char *buf; /* bit stream buffer */
218 int buf_size; /* size of buffer (in number of bytes) */
219 int totbit; /* bit counter of bit stream */
220 int buf_byte_idx; /* pointer to top byte in buffer */
221 int buf_bit_idx; /* pointer to top bit of top byte in buffer */
222 int mode; /* bit stream open in read or write mode */
223 int eob; /* end of buffer index */
224 int eobs; /* end of bit stream flag */
225 char format; /* format of file in rd mode (BINARY/ASCII) */
234 /***********************************************************************
236 * Global Variable External Declarations
238 ***********************************************************************/
241 extern char *mode_names[4];
242 extern char *layer_names[3];
243 extern char *version_names[2];
245 extern double s_freq[2][4];
246 extern int bitratex[2][15];
252 /***********************************************************************
254 * Global Function Prototype Declarations
256 ***********************************************************************/
258 /* The following functions are in the file "common.c" */
260 extern void *mem_alloc (unsigned int block, char *item);
261 extern void mem_free (void **ptr_addr);
267 #endif /* __COMMON__ */