1 | /*
|
---|
2 | * Interface to MP3 LAME encoding engine
|
---|
3 | *
|
---|
4 | * Copyright (c) 1999 Mark Taylor
|
---|
5 | *
|
---|
6 | * This program is free software; you can redistribute it and/or modify
|
---|
7 | * it under the terms of the GNU General Public License as published by
|
---|
8 | * the Free Software Foundation; either version 2, or (at your option)
|
---|
9 | * any later version.
|
---|
10 | *
|
---|
11 | * This program is distributed in the hope that it will be useful,
|
---|
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
14 | * GNU General Public License for more details.
|
---|
15 | *
|
---|
16 | * You should have received a copy of the GNU General Public License
|
---|
17 | * along with this program; see the file COPYING. If not, write to
|
---|
18 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
19 | */
|
---|
20 |
|
---|
21 | /* $Id: lame.h,v 1.154 2004/04/11 15:39:53 glessard Exp $ */
|
---|
22 |
|
---|
23 | #ifndef LAME_LAME_H
|
---|
24 | #define LAME_LAME_H
|
---|
25 |
|
---|
26 | #include <stdio.h>
|
---|
27 | #include <stdarg.h>
|
---|
28 |
|
---|
29 | #if defined(__cplusplus)
|
---|
30 | extern "C" {
|
---|
31 | #endif
|
---|
32 |
|
---|
33 | #if defined(WIN32)
|
---|
34 | #undef CDECL
|
---|
35 | #define CDECL _cdecl
|
---|
36 | #else
|
---|
37 | #define CDECL
|
---|
38 | #endif
|
---|
39 |
|
---|
40 |
|
---|
41 | typedef enum vbr_mode_e {
|
---|
42 | vbr_off=0,
|
---|
43 | vbr_mt, /* obsolete, same as vbr_mtrh */
|
---|
44 | vbr_rh,
|
---|
45 | vbr_abr,
|
---|
46 | vbr_mtrh,
|
---|
47 | vbr_max_indicator, /* Don't use this! It's used for sanity checks. */
|
---|
48 | vbr_default=vbr_rh /* change this to change the default VBR mode of LAME */
|
---|
49 | } vbr_mode;
|
---|
50 |
|
---|
51 |
|
---|
52 | /* MPEG modes */
|
---|
53 | typedef enum MPEG_mode_e {
|
---|
54 | STEREO = 0,
|
---|
55 | JOINT_STEREO,
|
---|
56 | DUAL_CHANNEL, /* LAME doesn't supports this! */
|
---|
57 | MONO,
|
---|
58 | NOT_SET,
|
---|
59 | MAX_INDICATOR /* Don't use this! It's used for sanity checks. */
|
---|
60 | } MPEG_mode;
|
---|
61 |
|
---|
62 | /* Padding types */
|
---|
63 | typedef enum Padding_type_e {
|
---|
64 | PAD_NO = 0,
|
---|
65 | PAD_ALL,
|
---|
66 | PAD_ADJUST,
|
---|
67 | PAD_MAX_INDICATOR /* Don't use this! It's used for sanity checks. */
|
---|
68 | } Padding_type;
|
---|
69 |
|
---|
70 |
|
---|
71 |
|
---|
72 | /*presets*/
|
---|
73 | typedef enum preset_mode_e {
|
---|
74 | /*values from 8 to 320 should be reserved for abr bitrates*/
|
---|
75 | /*for abr I'd suggest to directly use the targeted bitrate as a value*/
|
---|
76 | ABR_8 = 8,
|
---|
77 | ABR_320 = 320,
|
---|
78 |
|
---|
79 | V9 = 410, /*Vx to match Lame and VBR_xx to match FhG*/
|
---|
80 | VBR_10 = 410,
|
---|
81 | V8 = 420,
|
---|
82 | VBR_20 = 420,
|
---|
83 | V7 = 430,
|
---|
84 | VBR_30 = 430,
|
---|
85 | V6 = 440,
|
---|
86 | VBR_40 = 440,
|
---|
87 | V5 = 450,
|
---|
88 | VBR_50 = 450,
|
---|
89 | V4 = 460,
|
---|
90 | VBR_60 = 460,
|
---|
91 | V3 = 470,
|
---|
92 | VBR_70 = 470,
|
---|
93 | V2 = 480,
|
---|
94 | VBR_80 = 480,
|
---|
95 | V1 = 490,
|
---|
96 | VBR_90 = 490,
|
---|
97 | V0 = 500,
|
---|
98 | VBR_100 = 500,
|
---|
99 |
|
---|
100 |
|
---|
101 |
|
---|
102 | /*still there for compatibility*/
|
---|
103 | R3MIX = 1000,
|
---|
104 | STANDARD = 1001,
|
---|
105 | EXTREME = 1002,
|
---|
106 | INSANE = 1003,
|
---|
107 | STANDARD_FAST = 1004,
|
---|
108 | EXTREME_FAST = 1005,
|
---|
109 | MEDIUM = 1006,
|
---|
110 | MEDIUM_FAST = 1007
|
---|
111 | } preset_mode;
|
---|
112 |
|
---|
113 |
|
---|
114 | /*asm optimizations*/
|
---|
115 | typedef enum asm_optimizations_e {
|
---|
116 | MMX = 1,
|
---|
117 | AMD_3DNOW = 2,
|
---|
118 | SSE = 3
|
---|
119 | } asm_optimizations;
|
---|
120 |
|
---|
121 |
|
---|
122 | /* psychoacoustic model */
|
---|
123 | typedef enum Psy_model_e {
|
---|
124 | PSY_GPSYCHO = 1,
|
---|
125 | PSY_NSPSYTUNE = 2
|
---|
126 | } Psy_model;
|
---|
127 |
|
---|
128 |
|
---|
129 | struct lame_global_struct;
|
---|
130 | typedef struct lame_global_struct lame_global_flags;
|
---|
131 | typedef lame_global_flags *lame_t;
|
---|
132 |
|
---|
133 |
|
---|
134 |
|
---|
135 |
|
---|
136 | /***********************************************************************
|
---|
137 | *
|
---|
138 | * The LAME API
|
---|
139 | * These functions should be called, in this order, for each
|
---|
140 | * MP3 file to be encoded. See the file "API" for more documentation
|
---|
141 | *
|
---|
142 | ***********************************************************************/
|
---|
143 |
|
---|
144 |
|
---|
145 | /*
|
---|
146 | * REQUIRED:
|
---|
147 | * initialize the encoder. sets default for all encoder parameters,
|
---|
148 | * returns NULL if some malloc()'s failed
|
---|
149 | * otherwise returns pointer to structure needed for all future
|
---|
150 | * API calls.
|
---|
151 | */
|
---|
152 | lame_global_flags * CDECL lame_init(void);
|
---|
153 | /* obsolete version */
|
---|
154 | int CDECL lame_init_old(lame_global_flags *);
|
---|
155 |
|
---|
156 |
|
---|
157 | /*
|
---|
158 | * OPTIONAL:
|
---|
159 | * set as needed to override defaults
|
---|
160 | */
|
---|
161 |
|
---|
162 | /********************************************************************
|
---|
163 | * input stream description
|
---|
164 | ***********************************************************************/
|
---|
165 | /* number of samples. default = 2^32-1 */
|
---|
166 | int CDECL lame_set_num_samples(lame_global_flags *, unsigned long);
|
---|
167 | unsigned long CDECL lame_get_num_samples(const lame_global_flags *);
|
---|
168 |
|
---|
169 | /* input sample rate in Hz. default = 44100hz */
|
---|
170 | int CDECL lame_set_in_samplerate(lame_global_flags *, int);
|
---|
171 | int CDECL lame_get_in_samplerate(const lame_global_flags *);
|
---|
172 |
|
---|
173 | /* number of channels in input stream. default=2 */
|
---|
174 | int CDECL lame_set_num_channels(lame_global_flags *, int);
|
---|
175 | int CDECL lame_get_num_channels(const lame_global_flags *);
|
---|
176 |
|
---|
177 | /*
|
---|
178 | scale the input by this amount before encoding. default=0 (disabled)
|
---|
179 | (not used by decoding routines)
|
---|
180 | */
|
---|
181 | int CDECL lame_set_scale(lame_global_flags *, float);
|
---|
182 | float CDECL lame_get_scale(const lame_global_flags *);
|
---|
183 |
|
---|
184 | /*
|
---|
185 | scale the channel 0 (left) input by this amount before encoding.
|
---|
186 | default=0 (disabled)
|
---|
187 | (not used by decoding routines)
|
---|
188 | */
|
---|
189 | int CDECL lame_set_scale_left(lame_global_flags *, float);
|
---|
190 | float CDECL lame_get_scale_left(const lame_global_flags *);
|
---|
191 |
|
---|
192 | /*
|
---|
193 | scale the channel 1 (right) input by this amount before encoding.
|
---|
194 | default=0 (disabled)
|
---|
195 | (not used by decoding routines)
|
---|
196 | */
|
---|
197 | int CDECL lame_set_scale_right(lame_global_flags *, float);
|
---|
198 | float CDECL lame_get_scale_right(const lame_global_flags *);
|
---|
199 |
|
---|
200 | /*
|
---|
201 | output sample rate in Hz. default = 0, which means LAME picks best value
|
---|
202 | based on the amount of compression. MPEG only allows:
|
---|
203 | MPEG1 32, 44.1, 48khz
|
---|
204 | MPEG2 16, 22.05, 24
|
---|
205 | MPEG2.5 8, 11.025, 12
|
---|
206 | (not used by decoding routines)
|
---|
207 | */
|
---|
208 | int CDECL lame_set_out_samplerate(lame_global_flags *, int);
|
---|
209 | int CDECL lame_get_out_samplerate(const lame_global_flags *);
|
---|
210 |
|
---|
211 |
|
---|
212 | /********************************************************************
|
---|
213 | * general control parameters
|
---|
214 | ***********************************************************************/
|
---|
215 | /* 1=cause LAME to collect data for an MP3 frame analyzer. default=0 */
|
---|
216 | int CDECL lame_set_analysis(lame_global_flags *, int);
|
---|
217 | int CDECL lame_get_analysis(const lame_global_flags *);
|
---|
218 |
|
---|
219 | /*
|
---|
220 | 1 = write a Xing VBR header frame.
|
---|
221 | default = 1
|
---|
222 | this variable must have been added by a Hungarian notation Windows programmer :-)
|
---|
223 | */
|
---|
224 | int CDECL lame_set_bWriteVbrTag(lame_global_flags *, int);
|
---|
225 | int CDECL lame_get_bWriteVbrTag(const lame_global_flags *);
|
---|
226 |
|
---|
227 | /* 1=decode only. use lame/mpglib to convert mp3/ogg to wav. default=0 */
|
---|
228 | int CDECL lame_set_decode_only(lame_global_flags *, int);
|
---|
229 | int CDECL lame_get_decode_only(const lame_global_flags *);
|
---|
230 |
|
---|
231 | /* 1=encode a Vorbis .ogg file. default=0 */
|
---|
232 | /* DEPRECATED */
|
---|
233 | int CDECL lame_set_ogg(lame_global_flags *, int);
|
---|
234 | int CDECL lame_get_ogg(const lame_global_flags *);
|
---|
235 |
|
---|
236 | /*
|
---|
237 | internal algorithm selection. True quality is determined by the bitrate
|
---|
238 | but this variable will effect quality by selecting expensive or cheap algorithms.
|
---|
239 | quality=0..9. 0=best (very slow). 9=worst.
|
---|
240 | recommended: 2 near-best quality, not too slow
|
---|
241 | 5 good quality, fast
|
---|
242 | 7 ok quality, really fast
|
---|
243 | */
|
---|
244 | int CDECL lame_set_quality(lame_global_flags *, int);
|
---|
245 | int CDECL lame_get_quality(const lame_global_flags *);
|
---|
246 |
|
---|
247 | /*
|
---|
248 | mode = 0,1,2,3 = stereo, jstereo, dual channel (not supported), mono
|
---|
249 | default: lame picks based on compression ration and input channels
|
---|
250 | */
|
---|
251 | int CDECL lame_set_mode(lame_global_flags *, MPEG_mode);
|
---|
252 | MPEG_mode CDECL lame_get_mode(const lame_global_flags *);
|
---|
253 |
|
---|
254 | /*
|
---|
255 | mode_automs. Use a M/S mode with a switching threshold based on
|
---|
256 | compression ratio
|
---|
257 | DEPRECATED
|
---|
258 | */
|
---|
259 | int CDECL lame_set_mode_automs(lame_global_flags *, int);
|
---|
260 | int CDECL lame_get_mode_automs(const lame_global_flags *);
|
---|
261 |
|
---|
262 | /*
|
---|
263 | force_ms. Force M/S for all frames. For testing only.
|
---|
264 | default = 0 (disabled)
|
---|
265 | */
|
---|
266 | int CDECL lame_set_force_ms(lame_global_flags *, int);
|
---|
267 | int CDECL lame_get_force_ms(const lame_global_flags *);
|
---|
268 |
|
---|
269 | /* use free_format? default = 0 (disabled) */
|
---|
270 | int CDECL lame_set_free_format(lame_global_flags *, int);
|
---|
271 | int CDECL lame_get_free_format(const lame_global_flags *);
|
---|
272 |
|
---|
273 | /* perform ReplayGain analysis? default = 0 (disabled) */
|
---|
274 | int CDECL lame_set_findReplayGain(lame_global_flags *, int);
|
---|
275 | int CDECL lame_get_findReplayGain(const lame_global_flags *);
|
---|
276 |
|
---|
277 | /* decode on the fly. Search for the peak sample. If the ReplayGain
|
---|
278 | * analysis is enabled then perform the analysis on the decoded data
|
---|
279 | * stream. default = 0 (disabled)
|
---|
280 | * NOTE: if this option is set the build-in decoder should not be used */
|
---|
281 | int CDECL lame_set_decode_on_the_fly(lame_global_flags *, int);
|
---|
282 | int CDECL lame_get_decode_on_the_fly(const lame_global_flags *);
|
---|
283 |
|
---|
284 | /* DEPRECATED: now does the same as lame_set_findReplayGain()
|
---|
285 | default = 0 (disabled) */
|
---|
286 | int CDECL lame_set_ReplayGain_input(lame_global_flags *, int);
|
---|
287 | int CDECL lame_get_ReplayGain_input(const lame_global_flags *);
|
---|
288 |
|
---|
289 | /* DEPRECATED: now does the same as
|
---|
290 | lame_set_decode_on_the_fly() && lame_set_findReplayGain()
|
---|
291 | default = 0 (disabled) */
|
---|
292 | int CDECL lame_set_ReplayGain_decode(lame_global_flags *, int);
|
---|
293 | int CDECL lame_get_ReplayGain_decode(const lame_global_flags *);
|
---|
294 |
|
---|
295 | /* DEPRECATED: now does the same as lame_set_decode_on_the_fly()
|
---|
296 | default = 0 (disabled) */
|
---|
297 | int CDECL lame_set_findPeakSample(lame_global_flags *, int);
|
---|
298 | int CDECL lame_get_findPeakSample(const lame_global_flags *);
|
---|
299 |
|
---|
300 | /* counters for gapless encoding */
|
---|
301 | int CDECL lame_set_nogap_total(lame_global_flags*, int);
|
---|
302 | int CDECL lame_get_nogap_total(const lame_global_flags*);
|
---|
303 |
|
---|
304 | int CDECL lame_set_nogap_currentindex(lame_global_flags* , int);
|
---|
305 | int CDECL lame_get_nogap_currentindex(const lame_global_flags*);
|
---|
306 |
|
---|
307 |
|
---|
308 | /*
|
---|
309 | * OPTIONAL:
|
---|
310 | * Set printf like error/debug/message reporting functions.
|
---|
311 | * The second argument has to be a pointer to a function which looks like
|
---|
312 | * void my_debugf(const char *format, va_list ap)
|
---|
313 | * {
|
---|
314 | * (void) vfprintf(stdout, format, ap);
|
---|
315 | * }
|
---|
316 | * If you use NULL as the value of the pointer in the set function, the
|
---|
317 | * lame buildin function will be used (prints to stderr).
|
---|
318 | * To quiet any output you have to replace the body of the example function
|
---|
319 | * with just "return;" and use it in the set function.
|
---|
320 | */
|
---|
321 | int CDECL lame_set_errorf(lame_global_flags *,
|
---|
322 | void (*func)(const char *, va_list));
|
---|
323 | int CDECL lame_set_debugf(lame_global_flags *,
|
---|
324 | void (*func)(const char *, va_list));
|
---|
325 | int CDECL lame_set_msgf (lame_global_flags *,
|
---|
326 | void (*func)(const char *, va_list));
|
---|
327 |
|
---|
328 |
|
---|
329 |
|
---|
330 | /* set one of brate compression ratio. default is compression ratio of 11. */
|
---|
331 | int CDECL lame_set_brate(lame_global_flags *, int);
|
---|
332 | int CDECL lame_get_brate(const lame_global_flags *);
|
---|
333 | int CDECL lame_set_compression_ratio(lame_global_flags *, float);
|
---|
334 | float CDECL lame_get_compression_ratio(const lame_global_flags *);
|
---|
335 |
|
---|
336 |
|
---|
337 | int CDECL lame_set_preset( lame_global_flags* gfp, int );
|
---|
338 | int CDECL lame_set_asm_optimizations( lame_global_flags* gfp, int, int );
|
---|
339 |
|
---|
340 |
|
---|
341 |
|
---|
342 | /********************************************************************
|
---|
343 | * frame params
|
---|
344 | ***********************************************************************/
|
---|
345 | /* mark as copyright. default=0 */
|
---|
346 | int CDECL lame_set_copyright(lame_global_flags *, int);
|
---|
347 | int CDECL lame_get_copyright(const lame_global_flags *);
|
---|
348 |
|
---|
349 | /* mark as original. default=1 */
|
---|
350 | int CDECL lame_set_original(lame_global_flags *, int);
|
---|
351 | int CDECL lame_get_original(const lame_global_flags *);
|
---|
352 |
|
---|
353 | /* error_protection. Use 2 bytes from each frame for CRC checksum. default=0 */
|
---|
354 | int CDECL lame_set_error_protection(lame_global_flags *, int);
|
---|
355 | int CDECL lame_get_error_protection(const lame_global_flags *);
|
---|
356 |
|
---|
357 | /* padding_type. 0=pad no frames 1=pad all frames 2=adjust padding(default) */
|
---|
358 | int CDECL lame_set_padding_type(lame_global_flags *, Padding_type);
|
---|
359 | Padding_type CDECL lame_get_padding_type(const lame_global_flags *);
|
---|
360 |
|
---|
361 | /* MP3 'private extension' bit Meaningless. default=0 */
|
---|
362 | int CDECL lame_set_extension(lame_global_flags *, int);
|
---|
363 | int CDECL lame_get_extension(const lame_global_flags *);
|
---|
364 |
|
---|
365 | /* enforce strict ISO compliance. default=0 */
|
---|
366 | int CDECL lame_set_strict_ISO(lame_global_flags *, int);
|
---|
367 | int CDECL lame_get_strict_ISO(const lame_global_flags *);
|
---|
368 |
|
---|
369 |
|
---|
370 | /********************************************************************
|
---|
371 | * quantization/noise shaping
|
---|
372 | ***********************************************************************/
|
---|
373 |
|
---|
374 | /* disable the bit reservoir. For testing only. default=0 */
|
---|
375 | int CDECL lame_set_disable_reservoir(lame_global_flags *, int);
|
---|
376 | int CDECL lame_get_disable_reservoir(const lame_global_flags *);
|
---|
377 |
|
---|
378 | /* select a different "best quantization" function. default=0 */
|
---|
379 | int CDECL lame_set_quant_comp(lame_global_flags *, int);
|
---|
380 | int CDECL lame_get_quant_comp(const lame_global_flags *);
|
---|
381 | int CDECL lame_set_quant_comp_short(lame_global_flags *, int);
|
---|
382 | int CDECL lame_get_quant_comp_short(const lame_global_flags *);
|
---|
383 |
|
---|
384 | int CDECL lame_set_experimentalX(lame_global_flags *, int); /* compatibility*/
|
---|
385 | int CDECL lame_get_experimentalX(const lame_global_flags *);
|
---|
386 |
|
---|
387 | /* another experimental option. for testing only */
|
---|
388 | int CDECL lame_set_experimentalY(lame_global_flags *, int);
|
---|
389 | int CDECL lame_get_experimentalY(const lame_global_flags *);
|
---|
390 |
|
---|
391 | /* another experimental option. for testing only */
|
---|
392 | int CDECL lame_set_experimentalZ(lame_global_flags *, int);
|
---|
393 | int CDECL lame_get_experimentalZ(const lame_global_flags *);
|
---|
394 |
|
---|
395 | /* Naoki's psycho acoustic model. default=0 */
|
---|
396 | int CDECL lame_set_exp_nspsytune(lame_global_flags *, int);
|
---|
397 | int CDECL lame_get_exp_nspsytune(const lame_global_flags *);
|
---|
398 |
|
---|
399 | void CDECL lame_set_msfix(lame_global_flags *, double);
|
---|
400 | float CDECL lame_get_msfix(const lame_global_flags *);
|
---|
401 |
|
---|
402 | int lame_set_exp_nspsytune2_int( lame_global_flags*, int, int);
|
---|
403 | float lame_set_exp_nspsytune2_real( lame_global_flags*, int, float);
|
---|
404 | void * lame_set_exp_nspsytune2_pointer( lame_global_flags*, int, void *);
|
---|
405 |
|
---|
406 | /********************************************************************
|
---|
407 | * VBR control
|
---|
408 | ***********************************************************************/
|
---|
409 | /* Types of VBR. default = vbr_off = CBR */
|
---|
410 | int CDECL lame_set_VBR(lame_global_flags *, vbr_mode);
|
---|
411 | vbr_mode CDECL lame_get_VBR(const lame_global_flags *);
|
---|
412 |
|
---|
413 | /* VBR quality level. 0=highest 9=lowest */
|
---|
414 | int CDECL lame_set_VBR_q(lame_global_flags *, int);
|
---|
415 | int CDECL lame_get_VBR_q(const lame_global_flags *);
|
---|
416 |
|
---|
417 | /* Ignored except for VBR=vbr_abr (ABR mode) */
|
---|
418 | int CDECL lame_set_VBR_mean_bitrate_kbps(lame_global_flags *, int);
|
---|
419 | int CDECL lame_get_VBR_mean_bitrate_kbps(const lame_global_flags *);
|
---|
420 |
|
---|
421 | int CDECL lame_set_VBR_min_bitrate_kbps(lame_global_flags *, int);
|
---|
422 | int CDECL lame_get_VBR_min_bitrate_kbps(const lame_global_flags *);
|
---|
423 |
|
---|
424 | int CDECL lame_set_VBR_max_bitrate_kbps(lame_global_flags *, int);
|
---|
425 | int CDECL lame_get_VBR_max_bitrate_kbps(const lame_global_flags *);
|
---|
426 |
|
---|
427 | /*
|
---|
428 | 1=strictly enforce VBR_min_bitrate. Normally it will be violated for
|
---|
429 | analog silence
|
---|
430 | */
|
---|
431 | int CDECL lame_set_VBR_hard_min(lame_global_flags *, int);
|
---|
432 | int CDECL lame_get_VBR_hard_min(const lame_global_flags *);
|
---|
433 |
|
---|
434 | /* for preset */
|
---|
435 | int CDECL lame_set_preset_expopts(lame_global_flags *, int);
|
---|
436 |
|
---|
437 |
|
---|
438 | /********************************************************************
|
---|
439 | * Filtering control
|
---|
440 | ***********************************************************************/
|
---|
441 | /* freq in Hz to apply lowpass. Default = 0 = lame chooses. -1 = disabled */
|
---|
442 | int CDECL lame_set_lowpassfreq(lame_global_flags *, int);
|
---|
443 | int CDECL lame_get_lowpassfreq(const lame_global_flags *);
|
---|
444 | /* width of transition band, in Hz. Default = one polyphase filter band */
|
---|
445 | int CDECL lame_set_lowpasswidth(lame_global_flags *, int);
|
---|
446 | int CDECL lame_get_lowpasswidth(const lame_global_flags *);
|
---|
447 |
|
---|
448 | /* freq in Hz to apply highpass. Default = 0 = lame chooses. -1 = disabled */
|
---|
449 | int CDECL lame_set_highpassfreq(lame_global_flags *, int);
|
---|
450 | int CDECL lame_get_highpassfreq(const lame_global_flags *);
|
---|
451 | /* width of transition band, in Hz. Default = one polyphase filter band */
|
---|
452 | int CDECL lame_set_highpasswidth(lame_global_flags *, int);
|
---|
453 | int CDECL lame_get_highpasswidth(const lame_global_flags *);
|
---|
454 |
|
---|
455 |
|
---|
456 | /********************************************************************
|
---|
457 | * psycho acoustics and other arguments which you should not change
|
---|
458 | * unless you know what you are doing
|
---|
459 | ***********************************************************************/
|
---|
460 |
|
---|
461 | /* only use ATH for masking */
|
---|
462 | int CDECL lame_set_ATHonly(lame_global_flags *, int);
|
---|
463 | int CDECL lame_get_ATHonly(const lame_global_flags *);
|
---|
464 |
|
---|
465 | /* only use ATH for short blocks */
|
---|
466 | int CDECL lame_set_ATHshort(lame_global_flags *, int);
|
---|
467 | int CDECL lame_get_ATHshort(const lame_global_flags *);
|
---|
468 |
|
---|
469 | /* disable ATH */
|
---|
470 | int CDECL lame_set_noATH(lame_global_flags *, int);
|
---|
471 | int CDECL lame_get_noATH(const lame_global_flags *);
|
---|
472 |
|
---|
473 | /* select ATH formula */
|
---|
474 | int CDECL lame_set_ATHtype(lame_global_flags *, int);
|
---|
475 | int CDECL lame_get_ATHtype(const lame_global_flags *);
|
---|
476 |
|
---|
477 | /* lower ATH by this many db */
|
---|
478 | int CDECL lame_set_ATHlower(lame_global_flags *, float);
|
---|
479 | float CDECL lame_get_ATHlower(const lame_global_flags *);
|
---|
480 |
|
---|
481 | /* select ATH adaptive adjustment type */
|
---|
482 | int CDECL lame_set_athaa_type( lame_global_flags *, int);
|
---|
483 | int CDECL lame_get_athaa_type( const lame_global_flags *);
|
---|
484 |
|
---|
485 | /* select the loudness approximation used by the ATH adaptive auto-leveling */
|
---|
486 | int CDECL lame_set_athaa_loudapprox( lame_global_flags *, int);
|
---|
487 | int CDECL lame_get_athaa_loudapprox( const lame_global_flags *);
|
---|
488 |
|
---|
489 | /* adjust (in dB) the point below which adaptive ATH level adjustment occurs */
|
---|
490 | int CDECL lame_set_athaa_sensitivity( lame_global_flags *, float);
|
---|
491 | float CDECL lame_get_athaa_sensitivity( const lame_global_flags* );
|
---|
492 |
|
---|
493 | /* predictability limit (ISO tonality formula) */
|
---|
494 | int CDECL lame_set_cwlimit(lame_global_flags *, int);
|
---|
495 | int CDECL lame_get_cwlimit(const lame_global_flags *);
|
---|
496 |
|
---|
497 | /*
|
---|
498 | allow blocktypes to differ between channels?
|
---|
499 | default: 0 for jstereo, 1 for stereo
|
---|
500 | */
|
---|
501 | int CDECL lame_set_allow_diff_short(lame_global_flags *, int);
|
---|
502 | int CDECL lame_get_allow_diff_short(const lame_global_flags *);
|
---|
503 |
|
---|
504 | /* use temporal masking effect (default = 1) */
|
---|
505 | int CDECL lame_set_useTemporal(lame_global_flags *, int);
|
---|
506 | int CDECL lame_get_useTemporal(const lame_global_flags *);
|
---|
507 |
|
---|
508 | /* use temporal masking effect (default = 1) */
|
---|
509 | int CDECL lame_set_interChRatio(lame_global_flags *, float);
|
---|
510 | float CDECL lame_get_interChRatio(const lame_global_flags *);
|
---|
511 |
|
---|
512 | /* disable short blocks */
|
---|
513 | int CDECL lame_set_no_short_blocks(lame_global_flags *, int);
|
---|
514 | int CDECL lame_get_no_short_blocks(const lame_global_flags *);
|
---|
515 |
|
---|
516 | /* force short blocks */
|
---|
517 | int CDECL lame_set_force_short_blocks(lame_global_flags *, int);
|
---|
518 | int CDECL lame_get_force_short_blocks(const lame_global_flags *);
|
---|
519 |
|
---|
520 | /* Input PCM is emphased PCM (for instance from one of the rarely
|
---|
521 | emphased CDs), it is STRONGLY not recommended to use this, because
|
---|
522 | psycho does not take it into account, and last but not least many decoders
|
---|
523 | ignore these bits */
|
---|
524 | int CDECL lame_set_emphasis(lame_global_flags *, int);
|
---|
525 | int CDECL lame_get_emphasis(const lame_global_flags *);
|
---|
526 |
|
---|
527 |
|
---|
528 |
|
---|
529 | /************************************************************************/
|
---|
530 | /* internal variables, cannot be set... */
|
---|
531 | /* provided because they may be of use to calling application */
|
---|
532 | /************************************************************************/
|
---|
533 | /* version 0=MPEG-2 1=MPEG-1 (2=MPEG-2.5) */
|
---|
534 | int CDECL lame_get_version(const lame_global_flags *);
|
---|
535 |
|
---|
536 | /* encoder delay */
|
---|
537 | int CDECL lame_get_encoder_delay(const lame_global_flags *);
|
---|
538 |
|
---|
539 | /*
|
---|
540 | padding appended to the input to make sure decoder can fully decode
|
---|
541 | all input. Note that this value can only be calculated during the
|
---|
542 | call to lame_encoder_flush(). Before lame_encoder_flush() has
|
---|
543 | been called, the value of encoder_padding = 0.
|
---|
544 | */
|
---|
545 | int CDECL lame_get_encoder_padding(const lame_global_flags *);
|
---|
546 |
|
---|
547 | /* size of MPEG frame */
|
---|
548 | int CDECL lame_get_framesize(const lame_global_flags *);
|
---|
549 |
|
---|
550 | /* number of PCM samples buffered, but not yet encoded to mp3 data. */
|
---|
551 | int CDECL lame_get_mf_samples_to_encode( const lame_global_flags* gfp );
|
---|
552 |
|
---|
553 | /*
|
---|
554 | size (bytes) of mp3 data buffered, but not yet encoded.
|
---|
555 | this is the number of bytes which would be output by a call to
|
---|
556 | lame_encode_flush_nogap. NOTE: lame_encode_flush() will return
|
---|
557 | more bytes than this because it will encode the reamining buffered
|
---|
558 | PCM samples before flushing the mp3 buffers.
|
---|
559 | */
|
---|
560 | int CDECL lame_get_size_mp3buffer( const lame_global_flags* gfp );
|
---|
561 |
|
---|
562 | /* number of frames encoded so far */
|
---|
563 | int CDECL lame_get_frameNum(const lame_global_flags *);
|
---|
564 |
|
---|
565 | /*
|
---|
566 | lame's estimate of the total number of frames to be encoded
|
---|
567 | only valid if calling program set num_samples
|
---|
568 | */
|
---|
569 | int CDECL lame_get_totalframes(const lame_global_flags *);
|
---|
570 |
|
---|
571 | /* RadioGain value. Multiplied by 10 and rounded to the nearest. */
|
---|
572 | int CDECL lame_get_RadioGain(const lame_global_flags *);
|
---|
573 |
|
---|
574 | /* AudiophileGain value. Multipled by 10 and rounded to the nearest. */
|
---|
575 | int CDECL lame_get_AudiophileGain(const lame_global_flags *);
|
---|
576 |
|
---|
577 | /* the peak sample */
|
---|
578 | float CDECL lame_get_PeakSample(const lame_global_flags *);
|
---|
579 |
|
---|
580 | /* is decoding on the fly performed */
|
---|
581 | int CDECL lame_get_decode_on_the_fly(const lame_global_flags *);
|
---|
582 |
|
---|
583 | /* is ReplayGain analysis performed */
|
---|
584 | int CDECL lame_get_findReplayGain(const lame_global_flags *);
|
---|
585 |
|
---|
586 | /* Gain change required for preventing clipping. The value is correct only if
|
---|
587 | peak sample searching was enabled. If negative then the waveform
|
---|
588 | already does not clip. The value is multiplied by 10 and rounded up. */
|
---|
589 | int CDECL lame_get_noclipGainChange(const lame_global_flags *);
|
---|
590 |
|
---|
591 | /* user-specified scale factor required for preventing clipping. Value is
|
---|
592 | correct only if peak sample searching was enabled and no user-specified
|
---|
593 | scaling was performed. If negative then either the waveform already does
|
---|
594 | not clip or the value cannot be determined */
|
---|
595 | float CDECL lame_get_noclipScale(const lame_global_flags *);
|
---|
596 |
|
---|
597 |
|
---|
598 |
|
---|
599 |
|
---|
600 |
|
---|
601 |
|
---|
602 |
|
---|
603 | /*
|
---|
604 | * REQUIRED:
|
---|
605 | * sets more internal configuration based on data provided above.
|
---|
606 | * returns -1 if something failed.
|
---|
607 | */
|
---|
608 | int CDECL lame_init_params(lame_global_flags * const );
|
---|
609 |
|
---|
610 |
|
---|
611 | /*
|
---|
612 | * OPTIONAL:
|
---|
613 | * get the version number, in a string. of the form:
|
---|
614 | * "3.63 (beta)" or just "3.63".
|
---|
615 | */
|
---|
616 | const char* CDECL get_lame_version ( void );
|
---|
617 | const char* CDECL get_lame_short_version ( void );
|
---|
618 | const char* CDECL get_lame_very_short_version ( void );
|
---|
619 | const char* CDECL get_psy_version ( void );
|
---|
620 | const char* CDECL get_lame_url ( void );
|
---|
621 |
|
---|
622 | /*
|
---|
623 | * OPTIONAL:
|
---|
624 | * get the version numbers in numerical form.
|
---|
625 | */
|
---|
626 | typedef struct {
|
---|
627 | /* generic LAME version */
|
---|
628 | int major;
|
---|
629 | int minor;
|
---|
630 | int alpha; /* 0 if not an alpha version */
|
---|
631 | int beta; /* 0 if not a beta version */
|
---|
632 |
|
---|
633 | /* version of the psy model */
|
---|
634 | int psy_major;
|
---|
635 | int psy_minor;
|
---|
636 | int psy_alpha; /* 0 if not an alpha version */
|
---|
637 | int psy_beta; /* 0 if not a beta version */
|
---|
638 |
|
---|
639 | /* compile time features */
|
---|
640 | const char *features; /* Don't make assumptions about the contents! */
|
---|
641 | } lame_version_t;
|
---|
642 | void CDECL get_lame_version_numerical ( lame_version_t *const );
|
---|
643 |
|
---|
644 |
|
---|
645 | /*
|
---|
646 | * OPTIONAL:
|
---|
647 | * print internal lame configuration to message handler
|
---|
648 | */
|
---|
649 | void CDECL lame_print_config(const lame_global_flags* gfp);
|
---|
650 |
|
---|
651 | void CDECL lame_print_internals( const lame_global_flags *gfp);
|
---|
652 |
|
---|
653 |
|
---|
654 | /*
|
---|
655 | * input pcm data, output (maybe) mp3 frames.
|
---|
656 | * This routine handles all buffering, resampling and filtering for you.
|
---|
657 | *
|
---|
658 | * return code number of bytes output in mp3buf. Can be 0
|
---|
659 | * -1: mp3buf was too small
|
---|
660 | * -2: malloc() problem
|
---|
661 | * -3: lame_init_params() not called
|
---|
662 | * -4: psycho acoustic problems
|
---|
663 | *
|
---|
664 | * The required mp3buf_size can be computed from num_samples,
|
---|
665 | * samplerate and encoding rate, but here is a worst case estimate:
|
---|
666 | *
|
---|
667 | * mp3buf_size in bytes = 1.25*num_samples + 7200
|
---|
668 | *
|
---|
669 | * I think a tighter bound could be: (mt, March 2000)
|
---|
670 | * MPEG1:
|
---|
671 | * num_samples*(bitrate/8)/samplerate + 4*1152*(bitrate/8)/samplerate + 512
|
---|
672 | * MPEG2:
|
---|
673 | * num_samples*(bitrate/8)/samplerate + 4*576*(bitrate/8)/samplerate + 256
|
---|
674 | *
|
---|
675 | * but test first if you use that!
|
---|
676 | *
|
---|
677 | * set mp3buf_size = 0 and LAME will not check if mp3buf_size is
|
---|
678 | * large enough.
|
---|
679 | *
|
---|
680 | * NOTE:
|
---|
681 | * if gfp->num_channels=2, but gfp->mode = 3 (mono), the L & R channels
|
---|
682 | * will be averaged into the L channel before encoding only the L channel
|
---|
683 | * This will overwrite the data in buffer_l[] and buffer_r[].
|
---|
684 | *
|
---|
685 | */
|
---|
686 | int CDECL lame_encode_buffer (
|
---|
687 | lame_global_flags* gfp, /* global context handle */
|
---|
688 | const short int buffer_l [], /* PCM data for left channel */
|
---|
689 | const short int buffer_r [], /* PCM data for right channel */
|
---|
690 | const int nsamples, /* number of samples per channel */
|
---|
691 | unsigned char* mp3buf, /* pointer to encoded MP3 stream */
|
---|
692 | const int mp3buf_size ); /* number of valid octets in this
|
---|
693 | stream */
|
---|
694 |
|
---|
695 | /*
|
---|
696 | * as above, but input has L & R channel data interleaved.
|
---|
697 | * NOTE:
|
---|
698 | * num_samples = number of samples in the L (or R)
|
---|
699 | * channel, not the total number of samples in pcm[]
|
---|
700 | */
|
---|
701 | int CDECL lame_encode_buffer_interleaved(
|
---|
702 | lame_global_flags* gfp, /* global context handlei */
|
---|
703 | short int pcm[], /* PCM data for left and right
|
---|
704 | channel, interleaved */
|
---|
705 | int num_samples, /* number of samples per channel,
|
---|
706 | _not_ number of samples in
|
---|
707 | pcm[] */
|
---|
708 | unsigned char* mp3buf, /* pointer to encoded MP3 stream */
|
---|
709 | int mp3buf_size ); /* number of valid octets in this
|
---|
710 | stream */
|
---|
711 |
|
---|
712 |
|
---|
713 | /* as lame_encode_buffer, but for 'float's.
|
---|
714 | * !! NOTE: !! data must still be scaled to be in the same range as
|
---|
715 | * short int, +/- 32768
|
---|
716 | */
|
---|
717 | int CDECL lame_encode_buffer_float(
|
---|
718 | lame_global_flags* gfp, /* global context handle */
|
---|
719 | const float buffer_l [], /* PCM data for left channel */
|
---|
720 | const float buffer_r [], /* PCM data for right channel */
|
---|
721 | const int nsamples, /* number of samples per channel */
|
---|
722 | unsigned char* mp3buf, /* pointer to encoded MP3 stream */
|
---|
723 | const int mp3buf_size ); /* number of valid octets in this
|
---|
724 | stream */
|
---|
725 |
|
---|
726 |
|
---|
727 | /* as lame_encode_buffer, but for long's
|
---|
728 | * !! NOTE: !! data must still be scaled to be in the same range as
|
---|
729 | * short int, +/- 32768
|
---|
730 | *
|
---|
731 | * This scaling was a mistake (doesn't allow one to exploit full
|
---|
732 | * precision of type 'long'. Use lame_encode_buffer_long2() instead.
|
---|
733 | *
|
---|
734 | */
|
---|
735 | int CDECL lame_encode_buffer_long(
|
---|
736 | lame_global_flags* gfp, /* global context handle */
|
---|
737 | const long buffer_l [], /* PCM data for left channel */
|
---|
738 | const long buffer_r [], /* PCM data for right channel */
|
---|
739 | const int nsamples, /* number of samples per channel */
|
---|
740 | unsigned char* mp3buf, /* pointer to encoded MP3 stream */
|
---|
741 | const int mp3buf_size ); /* number of valid octets in this
|
---|
742 | stream */
|
---|
743 |
|
---|
744 | /* Same as lame_encode_buffer_long(), but with correct scaling.
|
---|
745 | * !! NOTE: !! data must still be scaled to be in the same range as
|
---|
746 | * type 'long'. Data should be in the range: +/- 2^(8*size(long)-1)
|
---|
747 | *
|
---|
748 | */
|
---|
749 | int CDECL lame_encode_buffer_long2(
|
---|
750 | lame_global_flags* gfp, /* global context handle */
|
---|
751 | const long buffer_l [], /* PCM data for left channel */
|
---|
752 | const long buffer_r [], /* PCM data for right channel */
|
---|
753 | const int nsamples, /* number of samples per channel */
|
---|
754 | unsigned char* mp3buf, /* pointer to encoded MP3 stream */
|
---|
755 | const int mp3buf_size ); /* number of valid octets in this
|
---|
756 | stream */
|
---|
757 |
|
---|
758 | /* as lame_encode_buffer, but for int's
|
---|
759 | * !! NOTE: !! input should be scaled to the maximum range of 'int'
|
---|
760 | * If int is 4 bytes, then the values should range from
|
---|
761 | * +/- 2147483648.
|
---|
762 | *
|
---|
763 | * This routine does not (and cannot, without loosing precision) use
|
---|
764 | * the same scaling as the rest of the lame_encode_buffer() routines.
|
---|
765 | *
|
---|
766 | */
|
---|
767 | int CDECL lame_encode_buffer_int(
|
---|
768 | lame_global_flags* gfp, /* global context handle */
|
---|
769 | const int buffer_l [], /* PCM data for left channel */
|
---|
770 | const int buffer_r [], /* PCM data for right channel */
|
---|
771 | const int nsamples, /* number of samples per channel */
|
---|
772 | unsigned char* mp3buf, /* pointer to encoded MP3 stream */
|
---|
773 | const int mp3buf_size ); /* number of valid octets in this
|
---|
774 | stream */
|
---|
775 |
|
---|
776 |
|
---|
777 |
|
---|
778 |
|
---|
779 |
|
---|
780 | /*
|
---|
781 | * REQUIRED:
|
---|
782 | * lame_encode_flush will flush the intenal PCM buffers, padding with
|
---|
783 | * 0's to make sure the final frame is complete, and then flush
|
---|
784 | * the internal MP3 buffers, and thus may return a
|
---|
785 | * final few mp3 frames. 'mp3buf' should be at least 7200 bytes long
|
---|
786 | * to hold all possible emitted data.
|
---|
787 | *
|
---|
788 | * will also write id3v1 tags (if any) into the bitstream
|
---|
789 | *
|
---|
790 | * return code = number of bytes output to mp3buf. Can be 0
|
---|
791 | */
|
---|
792 | int CDECL lame_encode_flush(
|
---|
793 | lame_global_flags * gfp, /* global context handle */
|
---|
794 | unsigned char* mp3buf, /* pointer to encoded MP3 stream */
|
---|
795 | int size); /* number of valid octets in this stream */
|
---|
796 |
|
---|
797 | /*
|
---|
798 | * OPTIONAL:
|
---|
799 | * lame_encode_flush_nogap will flush the internal mp3 buffers and pad
|
---|
800 | * the last frame with ancillary data so it is a complete mp3 frame.
|
---|
801 | *
|
---|
802 | * 'mp3buf' should be at least 7200 bytes long
|
---|
803 | * to hold all possible emitted data.
|
---|
804 | *
|
---|
805 | * After a call to this routine, the outputed mp3 data is complete, but
|
---|
806 | * you may continue to encode new PCM samples and write future mp3 data
|
---|
807 | * to a different file. The two mp3 files will play back with no gaps
|
---|
808 | * if they are concatenated together.
|
---|
809 | *
|
---|
810 | * This routine will NOT write id3v1 tags into the bitstream.
|
---|
811 | *
|
---|
812 | * return code = number of bytes output to mp3buf. Can be 0
|
---|
813 | */
|
---|
814 | int CDECL lame_encode_flush_nogap(
|
---|
815 | lame_global_flags * gfp, /* global context handle */
|
---|
816 | unsigned char* mp3buf, /* pointer to encoded MP3 stream */
|
---|
817 | int size); /* number of valid octets in this stream */
|
---|
818 |
|
---|
819 | /*
|
---|
820 | * OPTIONAL:
|
---|
821 | * Normally, this is called by lame_init_params(). It writes id3v2 and
|
---|
822 | * Xing headers into the front of the bitstream, and sets frame counters
|
---|
823 | * and bitrate histogram data to 0. You can also call this after
|
---|
824 | * lame_encode_flush_nogap().
|
---|
825 | */
|
---|
826 | int CDECL lame_init_bitstream(
|
---|
827 | lame_global_flags * gfp); /* global context handle */
|
---|
828 |
|
---|
829 |
|
---|
830 |
|
---|
831 | /*
|
---|
832 | * OPTIONAL: some simple statistics
|
---|
833 | * a bitrate histogram to visualize the distribution of used frame sizes
|
---|
834 | * a stereo mode histogram to visualize the distribution of used stereo
|
---|
835 | * modes, useful in joint-stereo mode only
|
---|
836 | * 0: LR left-right encoded
|
---|
837 | * 1: LR-I left-right and intensity encoded (currently not supported)
|
---|
838 | * 2: MS mid-side encoded
|
---|
839 | * 3: MS-I mid-side and intensity encoded (currently not supported)
|
---|
840 | *
|
---|
841 | * attention: don't call them after lame_encode_finish
|
---|
842 | * suggested: lame_encode_flush -> lame_*_hist -> lame_close
|
---|
843 | */
|
---|
844 |
|
---|
845 | void CDECL lame_bitrate_hist(
|
---|
846 | const lame_global_flags *const gfp,
|
---|
847 | int bitrate_count[14] );
|
---|
848 | void CDECL lame_bitrate_kbps(
|
---|
849 | const lame_global_flags *const gfp,
|
---|
850 | int bitrate_kbps [14] );
|
---|
851 | void CDECL lame_stereo_mode_hist(
|
---|
852 | const lame_global_flags *const gfp,
|
---|
853 | int stereo_mode_count[4] );
|
---|
854 |
|
---|
855 | void CDECL lame_bitrate_stereo_mode_hist (
|
---|
856 | const lame_global_flags * const gfp,
|
---|
857 | int bitrate_stmode_count [14] [4] );
|
---|
858 |
|
---|
859 | void CDECL lame_block_type_hist (
|
---|
860 | const lame_global_flags * const gfp,
|
---|
861 | int btype_count[6] );
|
---|
862 |
|
---|
863 | void CDECL lame_bitrate_block_type_hist (
|
---|
864 | const lame_global_flags * const gfp,
|
---|
865 | int bitrate_btype_count[14][6] );
|
---|
866 |
|
---|
867 |
|
---|
868 | /*
|
---|
869 | * OPTIONAL:
|
---|
870 | * lame_mp3_tags_fid will append a Xing VBR tag to the mp3 file with file
|
---|
871 | * pointer fid. These calls perform forward and backwards seeks, so make
|
---|
872 | * sure fid is a real file. Make sure lame_encode_flush has been called,
|
---|
873 | * and all mp3 data has been written to the file before calling this
|
---|
874 | * function.
|
---|
875 | * NOTE:
|
---|
876 | * if VBR tags are turned off by the user, or turned off by LAME because
|
---|
877 | * the output is not a regular file, this call does nothing
|
---|
878 | */
|
---|
879 | void CDECL lame_mp3_tags_fid(lame_global_flags *,FILE* fid);
|
---|
880 |
|
---|
881 |
|
---|
882 | /*
|
---|
883 | * REQUIRED:
|
---|
884 | * final call to free all remaining buffers
|
---|
885 | */
|
---|
886 | int CDECL lame_close (lame_global_flags *);
|
---|
887 |
|
---|
888 | /*
|
---|
889 | * OBSOLETE:
|
---|
890 | * lame_encode_finish combines lame_encode_flush() and lame_close() in
|
---|
891 | * one call. However, once this call is made, the statistics routines
|
---|
892 | * will no longer work because the data will have been cleared, and
|
---|
893 | * lame_mp3_tags_fid() cannot be called to add data to the VBR header
|
---|
894 | */
|
---|
895 | int CDECL lame_encode_finish(
|
---|
896 | lame_global_flags* gfp,
|
---|
897 | unsigned char* mp3buf,
|
---|
898 | int size );
|
---|
899 |
|
---|
900 |
|
---|
901 |
|
---|
902 |
|
---|
903 |
|
---|
904 |
|
---|
905 |
|
---|
906 | /*********************************************************************
|
---|
907 | *
|
---|
908 | * decoding
|
---|
909 | *
|
---|
910 | * a simple interface to mpglib, part of mpg123, is also included if
|
---|
911 | * libmp3lame is compiled with HAVE_MPGLIB
|
---|
912 | *
|
---|
913 | *********************************************************************/
|
---|
914 | typedef struct {
|
---|
915 | int header_parsed; /* 1 if header was parsed and following data was
|
---|
916 | computed */
|
---|
917 | int stereo; /* number of channels */
|
---|
918 | int samplerate; /* sample rate */
|
---|
919 | int bitrate; /* bitrate */
|
---|
920 | int mode; /* mp3 frame type */
|
---|
921 | int mode_ext; /* mp3 frame type */
|
---|
922 | int framesize; /* number of samples per mp3 frame */
|
---|
923 |
|
---|
924 | /* this data is only computed if mpglib detects a Xing VBR header */
|
---|
925 | unsigned long nsamp; /* number of samples in mp3 file. */
|
---|
926 | int totalframes; /* total number of frames in mp3 file */
|
---|
927 |
|
---|
928 | /* this data is not currently computed by the mpglib routines */
|
---|
929 | int framenum; /* frames decoded counter */
|
---|
930 | } mp3data_struct;
|
---|
931 |
|
---|
932 |
|
---|
933 | /* required call to initialize decoder
|
---|
934 | * NOTE: the decoder should not be used when encoding is performed
|
---|
935 | * with decoding on the fly */
|
---|
936 | int CDECL lame_decode_init(void);
|
---|
937 |
|
---|
938 | /*********************************************************************
|
---|
939 | * input 1 mp3 frame, output (maybe) pcm data.
|
---|
940 | *
|
---|
941 | * nout = lame_decode(mp3buf,len,pcm_l,pcm_r);
|
---|
942 | *
|
---|
943 | * input:
|
---|
944 | * len : number of bytes of mp3 data in mp3buf
|
---|
945 | * mp3buf[len] : mp3 data to be decoded
|
---|
946 | *
|
---|
947 | * output:
|
---|
948 | * nout: -1 : decoding error
|
---|
949 | * 0 : need more data before we can complete the decode
|
---|
950 | * >0 : returned 'nout' samples worth of data in pcm_l,pcm_r
|
---|
951 | * pcm_l[nout] : left channel data
|
---|
952 | * pcm_r[nout] : right channel data
|
---|
953 | *
|
---|
954 | *********************************************************************/
|
---|
955 | int CDECL lame_decode(
|
---|
956 | unsigned char * mp3buf,
|
---|
957 | int len,
|
---|
958 | short pcm_l[],
|
---|
959 | short pcm_r[] );
|
---|
960 |
|
---|
961 | /* same as lame_decode, and also returns mp3 header data */
|
---|
962 | int CDECL lame_decode_headers(
|
---|
963 | unsigned char* mp3buf,
|
---|
964 | int len,
|
---|
965 | short pcm_l[],
|
---|
966 | short pcm_r[],
|
---|
967 | mp3data_struct* mp3data );
|
---|
968 |
|
---|
969 | /* same as lame_decode, but returns at most one frame */
|
---|
970 | int CDECL lame_decode1(
|
---|
971 | unsigned char* mp3buf,
|
---|
972 | int len,
|
---|
973 | short pcm_l[],
|
---|
974 | short pcm_r[] );
|
---|
975 |
|
---|
976 | /* same as lame_decode1, but returns at most one frame and mp3 header data */
|
---|
977 | int CDECL lame_decode1_headers(
|
---|
978 | unsigned char* mp3buf,
|
---|
979 | int len,
|
---|
980 | short pcm_l[],
|
---|
981 | short pcm_r[],
|
---|
982 | mp3data_struct* mp3data );
|
---|
983 |
|
---|
984 | /* same as lame_decode1_headers, but also returns enc_delay and enc_padding
|
---|
985 | from VBR Info tag, (-1 if no info tag was found) */
|
---|
986 | int CDECL lame_decode1_headersB(
|
---|
987 | unsigned char* mp3buf,
|
---|
988 | int len,
|
---|
989 | short pcm_l[],
|
---|
990 | short pcm_r[],
|
---|
991 | mp3data_struct* mp3data,
|
---|
992 | int *enc_delay,
|
---|
993 | int *enc_padding );
|
---|
994 |
|
---|
995 |
|
---|
996 | /* cleanup call to exit decoder */
|
---|
997 | int CDECL lame_decode_exit(void);
|
---|
998 |
|
---|
999 |
|
---|
1000 |
|
---|
1001 | /*********************************************************************
|
---|
1002 | *
|
---|
1003 | * id3tag stuff
|
---|
1004 | *
|
---|
1005 | *********************************************************************/
|
---|
1006 |
|
---|
1007 | /*
|
---|
1008 | * id3tag.h -- Interface to write ID3 version 1 and 2 tags.
|
---|
1009 | *
|
---|
1010 | * Copyright (C) 2000 Don Melton.
|
---|
1011 | *
|
---|
1012 | * This library is free software; you can redistribute it and/or
|
---|
1013 | * modify it under the terms of the GNU Library General Public
|
---|
1014 | * License as published by the Free Software Foundation; either
|
---|
1015 | * version 2 of the License, or (at your option) any later version.
|
---|
1016 | *
|
---|
1017 | * This library is distributed in the hope that it will be useful,
|
---|
1018 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
1019 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
1020 | * Library General Public License for more details.
|
---|
1021 | *
|
---|
1022 | * You should have received a copy of the GNU Library General Public
|
---|
1023 | * License along with this library; if not, write to the Free Software
|
---|
1024 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
---|
1025 | */
|
---|
1026 |
|
---|
1027 | /* utility to obtain alphabetically sorted list of genre names with numbers */
|
---|
1028 | extern void id3tag_genre_list(
|
---|
1029 | void (*handler)(int, const char *, void *),
|
---|
1030 | void* cookie);
|
---|
1031 |
|
---|
1032 | extern void id3tag_init (lame_global_flags *gfp);
|
---|
1033 |
|
---|
1034 | /* force addition of version 2 tag */
|
---|
1035 | extern void id3tag_add_v2 (lame_global_flags *gfp);
|
---|
1036 |
|
---|
1037 | /* add only a version 1 tag */
|
---|
1038 | extern void id3tag_v1_only (lame_global_flags *gfp);
|
---|
1039 |
|
---|
1040 | /* add only a version 2 tag */
|
---|
1041 | extern void id3tag_v2_only (lame_global_flags *gfp);
|
---|
1042 |
|
---|
1043 | /* pad version 1 tag with spaces instead of nulls */
|
---|
1044 | extern void id3tag_space_v1 (lame_global_flags *gfp);
|
---|
1045 |
|
---|
1046 | /* pad version 2 tag with extra 128 bytes */
|
---|
1047 | extern void id3tag_pad_v2 (lame_global_flags *gfp);
|
---|
1048 |
|
---|
1049 | extern void id3tag_set_title(
|
---|
1050 | lame_global_flags* gfp,
|
---|
1051 | const char* title );
|
---|
1052 | extern void id3tag_set_artist(
|
---|
1053 | lame_global_flags* gfp,
|
---|
1054 | const char* artist );
|
---|
1055 | extern void id3tag_set_album(
|
---|
1056 | lame_global_flags* gfp,
|
---|
1057 | const char* album );
|
---|
1058 | extern void id3tag_set_year(
|
---|
1059 | lame_global_flags* gfp,
|
---|
1060 | const char* year );
|
---|
1061 | extern void id3tag_set_comment(
|
---|
1062 | lame_global_flags* gfp,
|
---|
1063 | const char* comment );
|
---|
1064 | extern void id3tag_set_track(
|
---|
1065 | lame_global_flags* gfp,
|
---|
1066 | const char* track );
|
---|
1067 |
|
---|
1068 | /* return non-zero result if genre name or number is invalid */
|
---|
1069 | extern int id3tag_set_genre(
|
---|
1070 | lame_global_flags* gfp,
|
---|
1071 | const char* genre );
|
---|
1072 |
|
---|
1073 | /***********************************************************************
|
---|
1074 | *
|
---|
1075 | * list of valid bitrates [kbps] & sample frequencies [Hz].
|
---|
1076 | * first index: 0: MPEG-2 values (sample frequencies 16...24 kHz)
|
---|
1077 | * 1: MPEG-1 values (sample frequencies 32...48 kHz)
|
---|
1078 | * 2: MPEG-2.5 values (sample frequencies 8...12 kHz)
|
---|
1079 | ***********************************************************************/
|
---|
1080 | extern const int bitrate_table [3] [16];
|
---|
1081 | extern const int samplerate_table [3] [ 4];
|
---|
1082 |
|
---|
1083 |
|
---|
1084 |
|
---|
1085 | /* maximum size of mp3buffer needed if you encode at most 1152 samples for
|
---|
1086 | each call to lame_encode_buffer. see lame_encode_buffer() below
|
---|
1087 | (LAME_MAXMP3BUFFER is now obsolete) */
|
---|
1088 | #define LAME_MAXMP3BUFFER 16384
|
---|
1089 |
|
---|
1090 |
|
---|
1091 | typedef enum {
|
---|
1092 | LAME_OKAY = 0,
|
---|
1093 | LAME_NOERROR = 0,
|
---|
1094 | LAME_GENERICERROR = -1,
|
---|
1095 | LAME_NOMEM = -10,
|
---|
1096 | LAME_BADBITRATE = -11,
|
---|
1097 | LAME_BADSAMPFREQ = -12,
|
---|
1098 | LAME_INTERNALERROR = -13,
|
---|
1099 |
|
---|
1100 | FRONTEND_READERROR = -80,
|
---|
1101 | FRONTEND_WRITEERROR = -81,
|
---|
1102 | FRONTEND_FILETOOLARGE = -82
|
---|
1103 |
|
---|
1104 | } lame_errorcodes_t;
|
---|
1105 |
|
---|
1106 | #if defined(__cplusplus)
|
---|
1107 | }
|
---|
1108 | #endif
|
---|
1109 | #endif /* LAME_LAME_H */
|
---|
1110 |
|
---|