r123: Merged HEAD and TEST. New stuff shall be committed to HEAD from now on.
[cinelerra_cv/mob.git] / plugins / toolame / encoder.h
bloba126ffc86e772440b601381e164b09821d089150
1 #ifndef ENCODER_DOT_H
2 #define ENCODER_DOT_H
3 /***********************************************************************
5 * Encoder Include Files
7 ***********************************************************************/
9 /***********************************************************************
11 * Encoder Definitions
13 ***********************************************************************/
15 /* General Definitions */
17 /* Default Input Arguments (for command line control) */
19 #define DFLT_MOD 's' /* default mode is stereo */
20 #define DFLT_PSY 1 /* default psych model is 1 */
21 #define DFLT_SFQ 44.1 /* default input sampling rate is 44.1 kHz */
22 #define DFLT_EMP 'n' /* default de-emphasis is none */
23 #define DFLT_EXT ".mp2" /* default output file extension */
25 #define FILETYPE_ENCODE 'TEXT'
26 #define CREATOR_ENCODE 'MpgD'
28 /* This is the smallest MNR a subband can have before it is counted
29 as 'noisy' by the logic which chooses the number of JS subbands */
31 #define NOISY_MIN_MNR 0.0
33 /* Psychacoustic Model 1 Definitions */
35 #define CB_FRACTION 0.33
36 #define MAX_SNR 1000
37 #define NOISE 10
38 #define TONE 20
39 #define DBMIN -200.0
40 #define LAST -1
41 #define STOP -100
42 #define POWERNORM 90.3090 /* = 20 * log10(32768) to normalize */
43 /* max output power to 96 dB per spec */
45 /* Psychoacoustic Model 2 Definitions */
47 #define LOGBLKSIZE 10
48 #define BLKSIZE 1024
49 #define HBLKSIZE 513
50 #define CRITBANDS 63
51 #define LXMIN 32.0
53 /***********************************************************************
55 * Encoder Type Definitions
57 ***********************************************************************/
59 /* Psychoacoustic Model 1 Type Definitions */
61 typedef int IFFT2[FFT_SIZE / 2];
62 typedef int IFFT[FFT_SIZE];
63 typedef double D9[9];
64 typedef double D10[10];
65 typedef double D640[640];
66 typedef double D1408[1408];
67 typedef double DFFT2[FFT_SIZE / 2];
68 typedef double DFFT[FFT_SIZE];
69 typedef double DSBL[SBLIMIT];
70 typedef double D2SBL[2][SBLIMIT];
72 typedef struct
74 int line;
75 double bark, hear, x;
77 g_thres, *g_ptr;
79 typedef struct
81 double x;
82 int type, next, map;
84 mask, *mask_ptr;
86 /* Psychoacoustic Model 2 Type Definitions */
88 typedef int ICB[CRITBANDS];
89 typedef int IHBLK[HBLKSIZE];
90 typedef FLOAT F32[32];
91 typedef FLOAT F2_32[2][32];
92 typedef FLOAT FCB[CRITBANDS];
93 typedef FLOAT FCBCB[CRITBANDS][CRITBANDS];
94 typedef FLOAT FBLK[BLKSIZE];
95 typedef FLOAT FHBLK[HBLKSIZE];
96 typedef FLOAT F2HBLK[2][HBLKSIZE];
97 typedef FLOAT F22HBLK[2][2][HBLKSIZE];
98 typedef double DCB[CRITBANDS];
100 /***********************************************************************
102 * Encoder Function Prototype Declarations
104 ***********************************************************************/
106 /* The following functions are in the file "musicin.c" */
108 extern void obtain_parameters (frame_params *, int *, unsigned long *,
109 char[MAX_NAME_SIZE], char[MAX_NAME_SIZE]);
110 extern void parse_args (int,
111 char **,
112 frame_params *,
113 int *,
114 unsigned long *,
115 int *,
116 char[MAX_NAME_SIZE], char[MAX_NAME_SIZE]);
117 extern void print_config (frame_params *, int *,
118 char[MAX_NAME_SIZE], char[MAX_NAME_SIZE]);
119 void usage (void);
120 extern void aiff_check (char *, IFF_AIFF *, int *);
122 /* The following functions are in the file "encode.c" */
124 extern unsigned long read_samples (FILE *, short[2304], unsigned long,
125 unsigned long);
126 #if 0
127 extern unsigned long get_audio (FILE *, short[2][1152], unsigned long,
128 int, int);
129 #else
130 extern unsigned long get_audio (FILE *, FILE *, short[2][1152], unsigned long,
131 int, layer * info);
132 #endif
133 extern void window_subband (short **, double[HAN_SIZE], int);
134 extern void create_ana_filter (double[SBLIMIT][64]);
135 extern void filter_subband (double[HAN_SIZE], double[SBLIMIT]);
136 extern void encode_info (frame_params *, Bit_stream_struc *);
137 extern double mod (double);
138 extern void combine_LR (double[2][3][SCALE_BLOCK][SBLIMIT],
139 double[3][SCALE_BLOCK][SBLIMIT], int);
140 extern void scale_factor_calc (double[][3][SCALE_BLOCK][SBLIMIT],
141 unsigned int[][3][SBLIMIT], int, int);
142 extern void pick_scale (unsigned int[2][3][SBLIMIT], frame_params *,
143 double[2][SBLIMIT]);
144 extern void put_scale (unsigned int[2][3][SBLIMIT], frame_params *,
145 double[2][SBLIMIT]);
146 extern void transmission_pattern (unsigned int[2][3][SBLIMIT],
147 unsigned int[2][SBLIMIT],
148 frame_params *);
149 extern void encode_scale (unsigned int[2][SBLIMIT],
150 unsigned int[2][SBLIMIT],
151 unsigned int[2][3][SBLIMIT], frame_params *,
152 Bit_stream_struc *);
153 extern int bits_for_nonoise (double[2][SBLIMIT], unsigned int[2][SBLIMIT],
154 frame_params *);
155 extern void main_bit_allocation (double[2][SBLIMIT],
156 unsigned int[2][SBLIMIT],
157 unsigned int[2][SBLIMIT], int *,
158 frame_params *);
159 extern int a_bit_allocation (double[2][SBLIMIT], unsigned int[2][SBLIMIT],
160 unsigned int[2][SBLIMIT], int *,
161 frame_params *);
162 extern void subband_quantization (unsigned int[2][3][SBLIMIT],
163 double[2][3][SCALE_BLOCK][SBLIMIT],
164 unsigned int[3][SBLIMIT],
165 double[3][SCALE_BLOCK][SBLIMIT],
166 unsigned int[2][SBLIMIT],
167 unsigned int[2][3][SCALE_BLOCK][SBLIMIT],
168 frame_params *);
169 extern void encode_bit_alloc (unsigned int[2][SBLIMIT], frame_params *,
170 Bit_stream_struc *);
171 extern void sample_encoding (unsigned int[2][3][SCALE_BLOCK][SBLIMIT],
172 unsigned int[2][SBLIMIT], frame_params *,
173 Bit_stream_struc *);
174 extern void encode_CRC (unsigned int, Bit_stream_struc *);
176 /* The following functions are in the file "tonal.c" */
178 extern void read_cbound (int);
179 extern void read_freq_band (g_ptr *, int);
180 extern void make_map (mask[HAN_SIZE], g_thres *);
181 extern INLINE double add_db (double, double);
182 extern void f_f_t (double[FFT_SIZE], mask[HAN_SIZE]);
183 extern void hann_win (double[FFT_SIZE]);
184 extern void pick_max (mask[HAN_SIZE], double[SBLIMIT]);
185 extern void tonal_label (mask[HAN_SIZE], int *);
186 extern void noise_label (mask *, int *, g_thres *);
187 extern void subsampling (mask[HAN_SIZE], g_thres *, int *, int *);
188 extern void threshold (mask[HAN_SIZE], g_thres *, int *, int *, int);
189 extern void minimum_mask (g_thres *, double[SBLIMIT], int);
190 extern void smr (double[SBLIMIT], double[SBLIMIT], double[SBLIMIT], int);
191 extern void psycho_one (short[2][1152], double[2][SBLIMIT],
192 double[2][SBLIMIT], frame_params *);
195 /* The following functions are in the file "psy.c" */
197 extern void cleanup_psycho_two(void);
198 extern void init_psycho_two(double sfreq);
199 extern void psycho_two (short int *, short int[1056], int,
200 FLOAT[32], double);
202 /* The following functions are in the file "subs.c" */
204 extern void fft (FLOAT[BLKSIZE], FLOAT[BLKSIZE], FLOAT[BLKSIZE],
205 FLOAT[BLKSIZE], int);
206 #endif