TwoLAME 0.4.0 MPEG Audio Layer 2 encoder

twolame.h
Go to the documentation of this file.
1 /*
2 * TwoLAME: an optimized MPEG Audio Layer Two encoder
3 *
4 * Copyright (C) 2001-2004 Michael Cheng
5 * Copyright (C) 2004-2018 The TwoLAME Project
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */
22
23 #ifndef TWOLAME_H
24 #define TWOLAME_H
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
32 /*
33 * ATTENTION WIN32 USERS!
34 *
35 * By default, when you use this header file, it is configured to use
36 * symbols from the "twolame.dll" file. If you use the static version of
37 * the library, define LIBTWOLAME_STATIC prior to including this header.
38 */
39
40 #ifdef TL_API
41 # undef TL_API
42 #endif
43
44 #ifdef _WIN32
45 # ifdef LIBTWOLAME_BUILD
46 # ifdef DLL_EXPORT
47 # define TL_API __declspec(dllexport)
48 # else
49 # define TL_API
50 # endif
51 # else
52 # ifdef LIBTWOLAME_STATIC
53 # define TL_API
54 # else
55 # define TL_API __declspec(dllimport)
56 # endif
57 # endif
58 #else
59 # ifdef GNUC
60 # if GNUC >= 4
61 # define TL_API attribute ((visibility("default")))
62 # else
63 # define TL_API
64 # endif
65 # else
66 # define TL_API
67 # endif
68 #endif
69
70
71 #ifndef TRUE
72 #define TRUE (1)
73 #endif
74
75 #ifndef FALSE
76 #define FALSE (0)
77 #endif
78
79
81 typedef enum {
82 TWOLAME_AUTO_MODE = -1,
84 TWOLAME_STEREO = 0,
85 TWOLAME_JOINT_STEREO,
87 TWOLAME_DUAL_CHANNEL,
89 TWOLAME_MONO,
90 TWOLAME_NOT_SET
91 } TWOLAME_MPEG_mode;
92
93
98 typedef enum {
99 TWOLAME_MPEG_UNKNOWN = -1,
100 TWOLAME_MPEG2 = 0,
101 TWOLAME_MPEG1 = 1
102 } TWOLAME_MPEG_version;
103
104
106 typedef enum {
107 TWOLAME_PAD_NO = 0,
108 TWOLAME_PAD_ALL
109 // TWOLAME_PAD_ADJUST // unsupported by twolame
110 } TWOLAME_Padding;
111
113 typedef enum {
114 TWOLAME_EMPHASIS_N = 0,
115 TWOLAME_EMPHASIS_5 = 1,
116 TWOLAME_EMPHASIS_C = 3
117 } TWOLAME_Emphasis;
118
119
121 #define TWOLAME_SAMPLES_PER_FRAME (1152)
122
123
125 struct twolame_options_struct;
126
128 typedef struct twolame_options_struct twolame_options;
129
130
131
132
133
139 TL_API const char *get_twolame_version(void);
140
141
147 TL_API const char *get_twolame_url(void);
148
149
160 TL_API void twolame_print_config(twolame_options * glopts);
161
162
172 TL_API twolame_options *twolame_init(void);
173
174
186 TL_API int twolame_init_params(twolame_options * glopts);
187
188
203 TL_API int twolame_encode_buffer(twolame_options * glopts,
204 const short int leftpcm[],
205 const short int rightpcm[],
206 int num_samples,
207 unsigned char *mp2buffer, int mp2buffer_size);
208
209
223 TL_API int twolame_encode_buffer_interleaved(twolame_options * glopts,
224 const short int pcm[],
225 int num_samples,
226 unsigned char *mp2buffer, int mp2buffer_size);
227
228
246 TL_API int twolame_encode_buffer_float32(twolame_options * glopts,
247 const float leftpcm[],
248 const float rightpcm[],
249 int num_samples,
250 unsigned char *mp2buffer, int mp2buffer_size);
251
252
266 int twolame_encode_buffer_float32_interleaved(twolame_options * glopts,
267 const float pcm[],
268 int num_samples,
269 unsigned char *mp2buffer, int mp2buffer_size);
270
271
284 TL_API int twolame_encode_flush(twolame_options * glopts,
285 unsigned char *mp2buffer, int mp2buffer_size);
286
287
297 TL_API void twolame_close(twolame_options ** glopts);
298
299
300
315 TL_API int twolame_set_verbosity(twolame_options * glopts, int verbosity);
316
317
323 TL_API int twolame_get_verbosity(twolame_options * glopts);
324
325
335 TL_API int twolame_set_mode(twolame_options * glopts, TWOLAME_MPEG_mode mode);
336
337
343 TL_API TWOLAME_MPEG_mode twolame_get_mode(twolame_options * glopts);
344
345
351 TL_API const char *twolame_get_mode_name(twolame_options * glopts);
352
353
362 TL_API int twolame_set_version(twolame_options * glopts, TWOLAME_MPEG_version version);
363
364
370 TL_API TWOLAME_MPEG_version twolame_get_version(twolame_options * glopts);
371
372
378 TL_API const char *twolame_get_version_name(twolame_options * glopts);
379
380
387 TL_API int twolame_set_freeformat(twolame_options * glopts, int freef);
388
389
396 TL_API int twolame_get_framelength(twolame_options * glopts);
397
398
407 TL_API int twolame_set_psymodel(twolame_options * glopts, int psymodel);
408
409
415 TL_API int twolame_get_psymodel(twolame_options * glopts);
416
417
430 TL_API int twolame_set_num_channels(twolame_options * glopts, int num_channels);
431
432
438 TL_API int twolame_get_num_channels(twolame_options * glopts);
439
440
451 TL_API int twolame_set_scale(twolame_options * glopts, float scale);
452
453
459 TL_API float twolame_get_scale(twolame_options * glopts);
460
471 TL_API int twolame_set_scale_left(twolame_options * glopts, float scale);
472
473
479 TL_API float twolame_get_scale_left(twolame_options * glopts);
480
481
492 TL_API int twolame_set_scale_right(twolame_options * glopts, float scale);
493
494
500 TL_API float twolame_get_scale_right(twolame_options * glopts);
501
502
511 TL_API int twolame_set_in_samplerate(twolame_options * glopts, int samplerate);
512
513
519 TL_API int twolame_get_in_samplerate(twolame_options * glopts);
520
521
530 TL_API int twolame_set_out_samplerate(twolame_options * glopts, int samplerate);
531
532
538 TL_API int twolame_get_out_samplerate(twolame_options * glopts);
539
540
549 TL_API int twolame_set_bitrate(twolame_options * glopts, int bitrate);
550
551
557 TL_API int twolame_get_bitrate(twolame_options * glopts);
558
559
564 TL_API int twolame_set_brate(twolame_options * glopts, int bitrate);
565
566
571 TL_API int twolame_get_brate(twolame_options * glopts);
572
573
584 TL_API int twolame_set_padding(twolame_options * glopts, TWOLAME_Padding padding);
585
591 TL_API TWOLAME_Padding twolame_get_padding(twolame_options * glopts);
592
593
610 TL_API int twolame_set_energy_levels(twolame_options * glopts, int energylevels);
611
612
618 TL_API int twolame_get_energy_levels(twolame_options * glopts);
619
620
629 TL_API int twolame_set_num_ancillary_bits(twolame_options * glopts, int num);
630
631
637 TL_API int twolame_get_num_ancillary_bits(twolame_options * glopts);
638
639
640
649 TL_API int twolame_set_emphasis(twolame_options * glopts, TWOLAME_Emphasis emphasis);
650
651
657 TL_API TWOLAME_Emphasis twolame_get_emphasis(twolame_options * glopts);
658
659
668 TL_API int twolame_set_error_protection(twolame_options * glopts, int err_protection);
669
670
676 TL_API int twolame_get_error_protection(twolame_options * glopts);
677
678
689 TL_API int twolame_set_copyright(twolame_options * glopts, int copyright);
690
691
697 TL_API int twolame_get_copyright(twolame_options * glopts);
698
699
708 TL_API int twolame_set_original(twolame_options * glopts, int original);
709
710
716 TL_API int twolame_get_original(twolame_options * glopts);
717
718
727 TL_API int twolame_set_extension(twolame_options * glopts, int extension);
728
729
735 TL_API int twolame_get_extension(twolame_options * glopts);
736
737
746 TL_API int twolame_set_VBR(twolame_options * glopts, int vbr);
747
748
754 TL_API int twolame_get_VBR(twolame_options * glopts);
755
756
768 TL_API int twolame_set_VBR_level(twolame_options * glopts, float level);
769
770
776 TL_API float twolame_get_VBR_level(twolame_options * glopts);
777
778
779
780 /*
781 Using the twolame_set_VBR_q()/twolame_get_VBR_q functions
782 are deprecated, please use twolame_set_VBR_level() instead.
783 */
784 TL_API int twolame_set_VBR_q(twolame_options * glopts, float level);
785 TL_API float twolame_get_VBR_q(twolame_options * glopts);
786
787
796 TL_API int twolame_set_ATH_level(twolame_options * glopts, float level);
797
798
804 TL_API float twolame_get_ATH_level(twolame_options * glopts);
805
806
815 TL_API int twolame_set_VBR_max_bitrate_kbps(twolame_options * glopts, int bitrate);
816
817
823 TL_API int twolame_get_VBR_max_bitrate_kbps(twolame_options * glopts);
824
825
834 TL_API int twolame_set_quick_mode(twolame_options * glopts, int quickmode);
835
836
842 TL_API int twolame_get_quick_mode(twolame_options * glopts);
843
844
853 TL_API int twolame_set_quick_count(twolame_options * glopts, int quickcount);
854
855
861 TL_API int twolame_get_quick_count(twolame_options * glopts);
862
863
872 TL_API int twolame_set_DAB(twolame_options * glopts, int dab);
873
879 TL_API int twolame_get_DAB(twolame_options * glopts);
880
881
890 TL_API int twolame_set_DAB_xpad_length(twolame_options * glopts, int length);
891
892
898 TL_API int twolame_get_DAB_xpad_length(twolame_options * glopts);
899
900
910 TL_API int twolame_set_DAB_crc_length(twolame_options * glopts, int length);
911
912
920 TL_API int twolame_set_DAB_scf_crc_length(twolame_options * glopts);
921
922
928 TL_API int twolame_get_DAB_crc_length(twolame_options * glopts);
929
930
949 TL_API int twolame_set_DAB_scf_crc(twolame_options * glopts,
950 unsigned char *mp2buffer,
951 int mp2buffer_size);
952
953
954 #ifdef __cplusplus
955 }
956 #endif
957 #endif /* TWOLAME_H */
958 // vim:ts=4:sw=4:nowrap:
twolame_set_VBR_max_bitrate_kbps
TL_API int twolame_set_VBR_max_bitrate_kbps(twolame_options *glopts, int bitrate)
TWOLAME_Padding
TWOLAME_Padding
Definition: twolame.h:106
twolame_get_original
TL_API int twolame_get_original(twolame_options *glopts)
twolame_get_version_name
TL_API const char * twolame_get_version_name(twolame_options *glopts)
TWOLAME_MPEG_version
TWOLAME_MPEG_version
Definition: twolame.h:98
TWOLAME_PAD_NO
Definition: twolame.h:107
twolame_get_out_samplerate
TL_API int twolame_get_out_samplerate(twolame_options *glopts)
twolame_set_emphasis
TL_API int twolame_set_emphasis(twolame_options *glopts, TWOLAME_Emphasis emphasis)
twolame_get_in_samplerate
TL_API int twolame_get_in_samplerate(twolame_options *glopts)
twolame_set_version
TL_API int twolame_set_version(twolame_options *glopts, TWOLAME_MPEG_version version)
twolame_get_quick_mode
TL_API int twolame_get_quick_mode(twolame_options *glopts)
twolame_set_mode
TL_API int twolame_set_mode(twolame_options *glopts, TWOLAME_MPEG_mode mode)
twolame_set_error_protection
TL_API int twolame_set_error_protection(twolame_options *glopts, int err_protection)
twolame_get_VBR_level
TL_API float twolame_get_VBR_level(twolame_options *glopts)
twolame_get_num_channels
TL_API int twolame_get_num_channels(twolame_options *glopts)
twolame_set_DAB_scf_crc_length
TL_API int twolame_set_DAB_scf_crc_length(twolame_options *glopts)
twolame_set_extension
TL_API int twolame_set_extension(twolame_options *glopts, int extension)
twolame_print_config
TL_API void twolame_print_config(twolame_options *glopts)
twolame_set_scale_left
TL_API int twolame_set_scale_left(twolame_options *glopts, float scale)
twolame_set_DAB
TL_API int twolame_set_DAB(twolame_options *glopts, int dab)
get_twolame_version
TL_API const char * get_twolame_version(void)
twolame_get_VBR
TL_API int twolame_get_VBR(twolame_options *glopts)
twolame_encode_buffer_interleaved
TL_API int twolame_encode_buffer_interleaved(twolame_options *glopts, const short int pcm[], int num_samples, unsigned char *mp2buffer, int mp2buffer_size)
TWOLAME_MPEG_mode
TWOLAME_MPEG_mode
Definition: twolame.h:81
twolame_get_scale_left
TL_API float twolame_get_scale_left(twolame_options *glopts)
TWOLAME_EMPHASIS_5
Definition: twolame.h:115
TWOLAME_EMPHASIS_C
Definition: twolame.h:116
twolame_set_ATH_level
TL_API int twolame_set_ATH_level(twolame_options *glopts, float level)
twolame_encode_flush
TL_API int twolame_encode_flush(twolame_options *glopts, unsigned char *mp2buffer, int mp2buffer_size)
twolame_set_out_samplerate
TL_API int twolame_set_out_samplerate(twolame_options *glopts, int samplerate)
twolame_set_psymodel
TL_API int twolame_set_psymodel(twolame_options *glopts, int psymodel)
twolame_get_psymodel
TL_API int twolame_get_psymodel(twolame_options *glopts)
twolame_get_brate
TL_API int twolame_get_brate(twolame_options *glopts)
twolame_get_VBR_max_bitrate_kbps
TL_API int twolame_get_VBR_max_bitrate_kbps(twolame_options *glopts)
twolame_encode_buffer
TL_API int twolame_encode_buffer(twolame_options *glopts, const short int leftpcm[], const short int rightpcm[], int num_samples, unsigned char *mp2buffer, int mp2buffer_size)
TWOLAME_MPEG2
Definition: twolame.h:100
twolame_get_framelength
TL_API int twolame_get_framelength(twolame_options *glopts)
twolame_get_ATH_level
TL_API float twolame_get_ATH_level(twolame_options *glopts)
twolame_set_copyright
TL_API int twolame_set_copyright(twolame_options *glopts, int copyright)
twolame_get_version
TL_API TWOLAME_MPEG_version twolame_get_version(twolame_options *glopts)
twolame_get_mode_name
TL_API const char * twolame_get_mode_name(twolame_options *glopts)
twolame_set_quick_mode
TL_API int twolame_set_quick_mode(twolame_options *glopts, int quickmode)
TWOLAME_EMPHASIS_N
Definition: twolame.h:114
twolame_get_padding
TL_API TWOLAME_Padding twolame_get_padding(twolame_options *glopts)
twolame_set_DAB_xpad_length
TL_API int twolame_set_DAB_xpad_length(twolame_options *glopts, int length)
TWOLAME_JOINT_STEREO
Definition: twolame.h:85
twolame_set_in_samplerate
TL_API int twolame_set_in_samplerate(twolame_options *glopts, int samplerate)
twolame_set_freeformat
TL_API int twolame_set_freeformat(twolame_options *glopts, int freef)
TWOLAME_MPEG1
Definition: twolame.h:101
TWOLAME_Emphasis
TWOLAME_Emphasis
Definition: twolame.h:113
TWOLAME_DUAL_CHANNEL
Definition: twolame.h:87
twolame_encode_buffer_float32
TL_API int twolame_encode_buffer_float32(twolame_options *glopts, const float leftpcm[], const float rightpcm[], int num_samples, unsigned char *mp2buffer, int mp2buffer_size)
twolame_init
TL_API twolame_options * twolame_init(void)
TWOLAME_PAD_ALL
Definition: twolame.h:108
twolame_set_brate
TL_API int twolame_set_brate(twolame_options *glopts, int bitrate)
twolame_get_mode
TL_API TWOLAME_MPEG_mode twolame_get_mode(twolame_options *glopts)
twolame_set_energy_levels
TL_API int twolame_set_energy_levels(twolame_options *glopts, int energylevels)
twolame_get_scale
TL_API float twolame_get_scale(twolame_options *glopts)
twolame_get_error_protection
TL_API int twolame_get_error_protection(twolame_options *glopts)
twolame_get_quick_count
TL_API int twolame_get_quick_count(twolame_options *glopts)
twolame_get_emphasis
TL_API TWOLAME_Emphasis twolame_get_emphasis(twolame_options *glopts)
twolame_get_DAB_xpad_length
TL_API int twolame_get_DAB_xpad_length(twolame_options *glopts)
twolame_get_bitrate
TL_API int twolame_get_bitrate(twolame_options *glopts)
TWOLAME_MONO
Definition: twolame.h:89
twolame_get_DAB
TL_API int twolame_get_DAB(twolame_options *glopts)
twolame_get_scale_right
TL_API float twolame_get_scale_right(twolame_options *glopts)
twolame_set_VBR
TL_API int twolame_set_VBR(twolame_options *glopts, int vbr)
twolame_set_num_channels
TL_API int twolame_set_num_channels(twolame_options *glopts, int num_channels)
twolame_set_bitrate
TL_API int twolame_set_bitrate(twolame_options *glopts, int bitrate)
twolame_get_copyright
TL_API int twolame_get_copyright(twolame_options *glopts)
twolame_set_DAB_scf_crc
TL_API int twolame_set_DAB_scf_crc(twolame_options *glopts, unsigned char *mp2buffer, int mp2buffer_size)
get_twolame_url
TL_API const char * get_twolame_url(void)
twolame_set_padding
TL_API int twolame_set_padding(twolame_options *glopts, TWOLAME_Padding padding)
twolame_close
TL_API void twolame_close(twolame_options **glopts)
twolame_init_params
TL_API int twolame_init_params(twolame_options *glopts)
twolame_set_num_ancillary_bits
TL_API int twolame_set_num_ancillary_bits(twolame_options *glopts, int num)
twolame_options
struct twolame_options_struct twolame_options
Definition: twolame.h:128
twolame_get_energy_levels
TL_API int twolame_get_energy_levels(twolame_options *glopts)
twolame_set_scale
TL_API int twolame_set_scale(twolame_options *glopts, float scale)
twolame_get_extension
TL_API int twolame_get_extension(twolame_options *glopts)
twolame_set_scale_right
TL_API int twolame_set_scale_right(twolame_options *glopts, float scale)
twolame_get_DAB_crc_length
TL_API int twolame_get_DAB_crc_length(twolame_options *glopts)
twolame_encode_buffer_float32_interleaved
int twolame_encode_buffer_float32_interleaved(twolame_options *glopts, const float pcm[], int num_samples, unsigned char *mp2buffer, int mp2buffer_size)
TWOLAME_STEREO
Definition: twolame.h:84
twolame_set_VBR_level
TL_API int twolame_set_VBR_level(twolame_options *glopts, float level)
twolame_set_original
TL_API int twolame_set_original(twolame_options *glopts, int original)
twolame_set_DAB_crc_length
TL_API int twolame_set_DAB_crc_length(twolame_options *glopts, int length)
TWOLAME_AUTO_MODE
Definition: twolame.h:82
twolame_set_quick_count
TL_API int twolame_set_quick_count(twolame_options *glopts, int quickcount)
twolame_get_num_ancillary_bits
TL_API int twolame_get_num_ancillary_bits(twolame_options *glopts)
twolame_set_verbosity
TL_API int twolame_set_verbosity(twolame_options *glopts, int verbosity)
twolame_get_verbosity
TL_API int twolame_get_verbosity(twolame_options *glopts)