3 /***********************************************************************
5 * Encoder Include Files
7 ***********************************************************************/
9 /***********************************************************************
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
42 #define POWERNORM 90.3090 /* = 20 * log10(32768) to normalize */
43 /* max output power to 96 dB per spec */
45 /* Psychoacoustic Model 2 Definitions */
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
];
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
];
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,
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
]);
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,
127 extern unsigned long get_audio (FILE *, short[2][1152], unsigned long,
130 extern unsigned long get_audio (FILE *, FILE *, short[2][1152], unsigned long,
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
*,
144 extern void put_scale (unsigned int[2][3][SBLIMIT
], frame_params
*,
146 extern void transmission_pattern (unsigned int[2][3][SBLIMIT
],
147 unsigned int[2][SBLIMIT
],
149 extern void encode_scale (unsigned int[2][SBLIMIT
],
150 unsigned int[2][SBLIMIT
],
151 unsigned int[2][3][SBLIMIT
], frame_params
*,
153 extern int bits_for_nonoise (double[2][SBLIMIT
], unsigned int[2][SBLIMIT
],
155 extern void main_bit_allocation (double[2][SBLIMIT
],
156 unsigned int[2][SBLIMIT
],
157 unsigned int[2][SBLIMIT
], int *,
159 extern int a_bit_allocation (double[2][SBLIMIT
], unsigned int[2][SBLIMIT
],
160 unsigned int[2][SBLIMIT
], int *,
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
],
169 extern void encode_bit_alloc (unsigned int[2][SBLIMIT
], frame_params
*,
171 extern void sample_encoding (unsigned int[2][3][SCALE_BLOCK
][SBLIMIT
],
172 unsigned int[2][SBLIMIT
], frame_params
*,
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,
202 /* The following functions are in the file "subs.c" */
204 extern void fft (FLOAT
[BLKSIZE
], FLOAT
[BLKSIZE
], FLOAT
[BLKSIZE
],
205 FLOAT
[BLKSIZE
], int);