80
89
/* max output power to 96 dB per spec */
83
/* Psychoacoustic Model 2 Definitions */
92
/***************************************************************************************
93
Psychoacoustic Model 2/4 Definitions
94
****************************************************************************************/
99
/***************************************************************************************
101
****************************************************************************************/
103
typedef struct psycho_0_mem_struct {
104
FLOAT ath_min[SBLIMIT];
109
/***************************************************************************************
111
****************************************************************************************/
124
typedef struct psycho_1_mem_struct {
126
FLOAT fft_buf[2][1408];
132
FLOAT dbtable[DBTAB];
137
/***************************************************************************************
138
Psycho3 memory structure
139
****************************************************************************************/
143
typedef struct psycho_3_mem_struct{
145
int freq_subset[SUBSIZE];
146
FLOAT bark[HBLKSIZE];
148
FLOAT fft_buf[2][1408];
149
#define CRITBANDMAX 32 /* this is much higher than it needs to be. really only about 24 */
150
int cbands; /* How many critical bands there really are */
151
int cbandindex[CRITBANDMAX]; /* The spectral line index of the start of
152
each critical band */
153
FLOAT dbtable[DBTAB];
158
/***************************************************************************************
159
Psycho2 & 4 memory structure
160
****************************************************************************************/
162
#define LOGBLKSIZE 10
166
#define TRIGTABLESIZE 6284
167
#define TRIGTABLESCALE 2000.0
168
typedef int ICB[CBANDS];
169
typedef int IHBLK[HBLKSIZE];
170
typedef FLOAT F32[32];
171
typedef FLOAT F2_32[2][32];
172
typedef FLOAT FCB[CBANDS];
173
typedef FLOAT FCBCB[CBANDS][CBANDS];
174
typedef FLOAT FBLK[BLKSIZE];
175
typedef FLOAT FHBLK[HBLKSIZE];
176
typedef FLOAT F2HBLK[2][HBLKSIZE];
177
typedef FLOAT F22HBLK[2][2][HBLKSIZE];
178
typedef FLOAT DCB[CBANDS];
180
typedef struct psycho_4_mem_struct {
189
FLOAT grouped_c[CBANDS];
190
FLOAT grouped_e[CBANDS];
198
FLOAT wsamp_r[BLKSIZE], phi[BLKSIZE], energy[BLKSIZE], window[BLKSIZE];
199
FLOAT ath[HBLKSIZE], thr[HBLKSIZE], c[HBLKSIZE];
200
FLOAT fthr[HBLKSIZE], absthr[HBLKSIZE]; // psy2 only
201
int numlines[CBANDS];
202
int partition[HBLKSIZE];
208
FLOAT cos_table[TRIGTABLESIZE];
209
} psycho_4_mem, psycho_2_mem;
212
/***************************************************************************************
213
Subband utility structures
214
****************************************************************************************/
216
typedef struct subband_mem_struct {
225
/***************************************************************************************
226
Header and frame information
227
****************************************************************************************/
229
/* Raw Header Information Structure */
233
int error_protection;
245
/* Parent Structure Interpreting some Frame Parameters in Header */
247
int actual_mode; /* when writing IS, may forget if 0 chs */
248
int nch; /* num channels in output bitstream: 1 for mono, 2 for stereo */
249
int jsbound; /* first band of joint stereo coding */
250
int sblimit; /* total number of sub bands */
254
typedef unsigned int subband_t[2][3][SCALE_BLOCK][SBLIMIT];
255
typedef FLOAT jsb_sample_t[3][SCALE_BLOCK][SBLIMIT];
256
typedef FLOAT sb_sample_t[2][3][SCALE_BLOCK][SBLIMIT];
260
/***************************************************************************************
261
twolame Global Options structure.
263
++ means it is an advanced option. Only use it if you know what you're doing.
264
****************************************************************************************/
265
struct twolame_options_struct
267
// Input PCM audio File Information
268
int samplerate_in; // mpeg1: 32000 [44100] 48000
269
// mpeg2: 16000 22050 24000
271
int num_channels; // Number of channels on the input stream
273
// Output MP2 File Information
274
TWOLAME_MPEG_version version; // 0 mpeg2 [1] mpeg1
275
int bitrate; // for mpeg1:32, 48, 56, 64, 80, 96,112,128,160,[192], 224, 256, 320, 384
276
// for mpeg2: 8, 16, 24, 32, 40, 48, 56, 64, 80, [96], 112, 128, 144, 160
277
TWOLAME_MPEG_mode mode;
278
TWOLAME_Padding padding; // [PAD_NO]
279
int do_energy_levels; // Write energy level information into the end of the frame [FALSE]
280
int num_ancillary_bits; // Number of reserved ancillary bits [0] (Currently only available for non-VBR modes)
282
// Psychoacoustic Model options
283
int psymodel; // -1, 0, 1, 2, [3], 4 Psy model number
284
FLOAT athlevel; // Adjust the Absolute Threshold of Hearing curve by [0] dB
285
int quickmode; // Only calculate psy model ever X frames [FALSE]
286
int quickcount; // Only calculate psy model every [10] frames
289
int vbr; // turn on VBR mode TRUE [FALSE]
290
int vbr_upper_index; // ++ [0] means no upper bitrate set for VBR mode. valid 1-15 depending on mode
292
FLOAT vbrlevel; // Set VBR quality. [0.0] (sensible range -10.0 -> 10.0)
294
// Miscellaneous Options That Nobody Ever Uses
295
TWOLAME_Emphasis emphasis; // [n]one, 5(50/15 microseconds), c(ccitt j.17)
296
int copyright; // [FALSE]
297
int original; // [FALSE]
298
int private_bit; // [0] Your very own bit in the header.
299
int error_protection; // [FALSE]
301
// Digital Audio Broadcasting Extensions
302
unsigned int do_dab; // Allocate space for the DigitalAudioBroadcasting info [FALSE]
303
unsigned int dab_crc_len; // Number of CRC bytes for DAB [2], 4
304
unsigned int dab_crc[4]; // DAB CRC bytes are inserted here. User must insert them in frame
305
unsigned int dab_xpad_len; // Number of bytes in the XPAD
307
// Processing Options
308
int verbosity; // Verbosity of output 0(never output a thing) [2] 100(output everything)
318
// Bit allocation stuff
321
int bitrateindextobits[15];
322
int vbr_frame_count; // Used for debugging VBR
325
// Used by twolame_encode_frame
327
short int buffer[2][1152]; // Sample buffer
328
unsigned int samples_in_buffer; // Number of samples currently in buffer
329
unsigned int psycount;
332
unsigned int bit_alloc[2][SBLIMIT];
333
unsigned int scfsi[2][SBLIMIT];
334
unsigned int scalar[2][3][SBLIMIT];
335
unsigned int j_scale[3][SBLIMIT];
337
FLOAT smr[2][SBLIMIT];
338
FLOAT max_sc[2][SBLIMIT];
341
jsb_sample_t *j_sample;
342
sb_sample_t *sb_sample;
346
/* Resampling stuff */
347
FLOAT resample_ratio;
348
void* resample_handle[2];
351
// memory for psycho models
359
// memory for subband