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