~ubuntu-branches/ubuntu/feisty/avidemux/feisty

« back to all changes in this revision

Viewing changes to avidemux/libtoolame/common.h

  • Committer: Bazaar Package Importer
  • Author(s): Daniel T Chen
  • Date: 2006-12-15 17:13:20 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20061215171320-w79pvpehxx2fr217
Tags: 1:2.3.0-0.0ubuntu1
* Merge from debian-multimedia.org, remaining Ubuntu change:
  - desktop file,
  - no support for ccache and make -j.
* Closes Ubuntu: #69614.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 *  tooLAME: an optimized mpeg 1/2 layer 2 audio encoder
 
2
 *  TwoLAME: an optimized MPEG Audio Layer Two encoder
3
3
 *
4
4
 *  Copyright (C) 2001-2004 Michael Cheng
 
5
 *  Copyright (C) 2004-2005 The TwoLAME Project
5
6
 *
6
7
 *  This library is free software; you can redistribute it and/or
7
8
 *  modify it under the terms of the GNU Lesser General Public
20
21
 */
21
22
 
22
23
 
23
 
#ifndef _COMMON_H
24
 
#define _COMMON_H
25
 
 
 
24
#ifndef _COMMON_H
 
25
#define _COMMON_H
 
26
 
 
27
 
 
28
/***************************************************************************************
 
29
 Common Definitions
 
30
****************************************************************************************/
 
31
 
 
32
#ifndef FLOAT
 
33
#define         FLOAT                   double
 
34
#endif
26
35
 
27
36
#define         NULL_CHAR               '\0'
28
37
 
49
58
#define         SBLIMIT                 32
50
59
#define         SSLIMIT                 18
51
60
#define         FFT_SIZE                1024
52
 
#define                 SPF                                             1152
 
61
#define         SPF                     1152
53
62
#define         HAN_SIZE                512
54
63
#define         SCALE_BLOCK             12
55
64
#define         SCALE_RANGE             64
67
76
#define NOISY_MIN_MNR   0.0
68
77
 
69
78
 
70
 
/* Psychacoustic Model 1 Definitions */
 
79
/***************************************************************************************
 
80
  Psychacoustic Model 1/3 Definitions
 
81
****************************************************************************************/
71
82
 
72
 
#define CB_FRACTION     0.33
73
 
#define MAX_SNR         1000
74
83
#define NOISE           10
75
84
#define TONE            20
76
85
#define DBMIN           -200.0
80
89
/* max output power to 96 dB per spec */
81
90
 
82
91
 
83
 
/* Psychoacoustic Model 2 Definitions */
84
 
 
 
92
/***************************************************************************************
 
93
  Psychoacoustic Model 2/4 Definitions
 
94
****************************************************************************************/
85
95
#define LXMIN           32.0
86
96
 
87
97
 
88
 
#endif
89
 
 
 
98
 
 
99
/***************************************************************************************
 
100
psycho 0 mem struct
 
101
****************************************************************************************/
 
102
 
 
103
typedef struct psycho_0_mem_struct {
 
104
        FLOAT ath_min[SBLIMIT];
 
105
} psycho_0_mem;
 
106
 
 
107
 
 
108
 
 
109
/***************************************************************************************
 
110
psycho 1 mem struct
 
111
****************************************************************************************/
 
112
#define DBTAB 1000
 
113
 
 
114
typedef struct {
 
115
        int line;
 
116
        FLOAT bark, hear, x;
 
117
} g_thres, *g_ptr;
 
118
 
 
119
typedef struct {
 
120
        FLOAT x;
 
121
        int type, next, map;
 
122
} mask, *mask_ptr;
 
123
 
 
124
typedef struct psycho_1_mem_struct {
 
125
        int off[2];
 
126
        FLOAT fft_buf[2][1408];
 
127
        int *cbound;
 
128
        int crit_band;
 
129
        int sub_size;
 
130
        mask_ptr power;
 
131
        g_ptr ltg;
 
132
        FLOAT dbtable[DBTAB];
 
133
} psycho_1_mem;
 
134
 
 
135
 
 
136
 
 
137
/***************************************************************************************
 
138
Psycho3 memory structure
 
139
****************************************************************************************/
 
140
#define HBLKSIZE 513
 
141
 
 
142
#define SUBSIZE 136
 
143
typedef struct psycho_3_mem_struct{
 
144
        int off[2];
 
145
        int freq_subset[SUBSIZE];
 
146
        FLOAT bark[HBLKSIZE];
 
147
        FLOAT ath[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];
 
154
} psycho_3_mem;
 
155
 
 
156
 
 
157
 
 
158
/***************************************************************************************
 
159
Psycho2 & 4 memory structure
 
160
****************************************************************************************/
 
161
 
 
162
#define LOGBLKSIZE      10
 
163
#define BLKSIZE         1024
 
164
#define HBLKSIZE        513
 
165
#define CBANDS          64
 
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];
 
179
 
 
180
typedef struct psycho_4_mem_struct {
 
181
        int new;
 
182
        int old;
 
183
        int oldest;
 
184
        
 
185
        int flush;
 
186
        int sync_flush;
 
187
        int syncsize;
 
188
        
 
189
        FLOAT grouped_c[CBANDS];
 
190
        FLOAT grouped_e[CBANDS];
 
191
        FLOAT nb[CBANDS];
 
192
        FLOAT cb[CBANDS];
 
193
        FLOAT tb[CBANDS];
 
194
        FLOAT ecb[CBANDS];
 
195
        FLOAT bc[CBANDS];
 
196
        FLOAT cbval[CBANDS];
 
197
        FLOAT rnorm[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];
 
203
        FLOAT *tmn;
 
204
        FCB *s;
 
205
        FHBLK *lthr;
 
206
        F2HBLK *r, *phi_sav;
 
207
        FLOAT snrtmp[2][32];
 
208
        FLOAT cos_table[TRIGTABLESIZE];
 
209
} psycho_4_mem, psycho_2_mem;
 
210
 
 
211
 
 
212
/***************************************************************************************
 
213
 Subband utility structures
 
214
****************************************************************************************/
 
215
 
 
216
typedef struct subband_mem_struct {
 
217
        FLOAT x[2][512];
 
218
        FLOAT m[16][32];
 
219
        int off[2];
 
220
        int half[2];
 
221
} subband_mem;
 
222
 
 
223
 
 
224
 
 
225
/***************************************************************************************
 
226
 Header and frame information
 
227
****************************************************************************************/
 
228
 
 
229
/* Raw Header Information Structure */
 
230
typedef struct {
 
231
        int version;
 
232
        int lay;
 
233
        int error_protection;
 
234
        int bitrate_index;
 
235
        int samplerate_idx;
 
236
        int padding;
 
237
        int private_bit;
 
238
        int mode;
 
239
        int mode_ext;
 
240
        int copyright;
 
241
        int original;
 
242
        int emphasis;
 
243
} frame_header;
 
244
 
 
245
/* Parent Structure Interpreting some Frame Parameters in Header */
 
246
typedef struct {
 
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 */
 
251
} frame_info;
 
252
 
 
253
 
 
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];
 
257
 
 
258
 
 
259
 
 
260
/***************************************************************************************
 
261
 twolame Global Options structure.
 
262
 Defaults shown in []
 
263
 ++ means it is an advanced option. Only use it if you know what you're doing.    
 
264
****************************************************************************************/
 
265
struct twolame_options_struct
 
266
{
 
267
        // Input PCM audio File Information
 
268
        int samplerate_in;      // mpeg1: 32000 [44100] 48000 
 
269
                                                // mpeg2: 16000  22050  24000 
 
270
        int samplerate_out;
 
271
        int num_channels;               // Number of channels on the input stream
 
272
        
 
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)
 
281
        
 
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
 
287
        
 
288
        // VBR Options
 
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
 
291
        int vbr_max_bitrate;
 
292
        FLOAT vbrlevel;          // Set VBR quality. [0.0] (sensible range -10.0 -> 10.0)
 
293
        
 
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] 
 
300
        
 
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
 
306
        
 
307
        // Processing Options
 
308
        int verbosity;           // Verbosity of output 0(never output a thing) [2] 100(output everything)
 
309
        
 
310
        
 
311
        // Scaling
 
312
        FLOAT scale;
 
313
        FLOAT scale_left;
 
314
        FLOAT scale_right;
 
315
        
 
316
        
 
317
        
 
318
        // Bit allocation stuff
 
319
        int lower_index;
 
320
        int upper_index;
 
321
        int bitrateindextobits[15];
 
322
        int vbr_frame_count;                    // Used for debugging VBR
 
323
        
 
324
        
 
325
        // Used by twolame_encode_frame
 
326
        int twolame_init;
 
327
        short int buffer[2][1152];      // Sample buffer
 
328
        unsigned int samples_in_buffer;         // Number of samples currently in buffer
 
329
        unsigned int psycount;
 
330
        unsigned int crc;
 
331
        
 
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];
 
336
        FLOAT smrdef[2][32];
 
337
        FLOAT smr[2][SBLIMIT];
 
338
        FLOAT max_sc[2][SBLIMIT];
 
339
        
 
340
        subband_t *subband;
 
341
        jsb_sample_t *j_sample;
 
342
        sb_sample_t *sb_sample;
 
343
        
 
344
        
 
345
        
 
346
        /* Resampling stuff */
 
347
        FLOAT resample_ratio;
 
348
        void* resample_handle[2];
 
349
        
 
350
        
 
351
        // memory for psycho models
 
352
        psycho_0_mem *p0mem;
 
353
        psycho_1_mem *p1mem;
 
354
        psycho_2_mem *p2mem;
 
355
        psycho_3_mem *p3mem;
 
356
        psycho_4_mem *p4mem;
 
357
        
 
358
        
 
359
        // memory for subband
 
360
        subband_mem smem;
 
361
        
 
362
        // Frame info
 
363
        frame_info frame;
 
364
        frame_header header;
 
365
        
 
366
        int vbrstats[15];
 
367
        int tablenum;
 
368
};
 
369
 
 
370
#endif // _COMMON_H