twolame 0.3.13 MPEGAudioLayer2encoder

# twolame.h

Go to the documentation of this file.

    00001 /*
    00002  *  TwoLAME: an optimized MPEG Audio Layer Two encoder
    00003  *
    00004  *  Copyright (C) 2001-2004 Michael Cheng
    00005  *  Copyright (C) 2004-2006 The TwoLAME Project
    00006  *
    00007  *  This library is free software; you can redistribute it and/or
    00008  *  modify it under the terms of the GNU Lesser General Public
    00009  *  License as published by the Free Software Foundation; either
    00010  *  version 2.1 of the License, or (at your option) any later version.
    00011  *
    00012  *  This library is distributed in the hope that it will be useful,
    00013  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    00014  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00015  *  Lesser General Public License for more details.
    00016  *
    00017  *  You should have received a copy of the GNU Lesser General Public
    00018  *  License along with this library; if not, write to the Free Software
    00019  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    00020  *
    00021  *  $Id$
    00022  *
    00023  */
    00024
    00025 #ifndef __TWOLAME_H__
    00026 #define __TWOLAME_H__
    00027
    00028 #ifdef __cplusplus
    00029 extern "C" {
    00030 #endif
    00031
    00034 /*
    00035  * ATTENTION WIN32 USERS!
    00036  *
    00037  * By default, when you use this header file, it is configured to use
    00038  * symbols from the "twolame.dll" file. If you use the static version of
    00039  * the library, define LIBTWOLAME_STATIC prior to including this header.
    00040  */
    00041
    00042 #ifdef _WIN32
    00043 #ifdef LIBTWOLAME_STATIC
    00044 #define DLL_EXPORT
    00045 #else
    00046 #ifdef LIBTWOLAME_DLL_EXPORTS
    00047 #define DLL_EXPORT __declspec(dllexport)
    00048 #else
    00049 #define DLL_EXPORT __declspec(dllimport)
    00050 #endif
    00051 #endif
    00052 #else
    00053 #define DLL_EXPORT
    00054 #endif
    00055
    00056
    00057 #ifndef TRUE
    00058 #define TRUE    (1)
    00059 #endif
    00060
    00061 #ifndef FALSE
    00062 #define FALSE   (0)
    00063 #endif
    00064
    00065
    00067     typedef enum {
    00068         TWOLAME_AUTO_MODE = -1,
    00070         TWOLAME_STEREO = 0,
    00071         TWOLAME_JOINT_STEREO,
    00073         TWOLAME_DUAL_CHANNEL,
    00075         TWOLAME_MONO,
    00076         TWOLAME_NOT_SET
    00077     } TWOLAME_MPEG_mode;
    00078
    00079
    00084     typedef enum {
    00085         TWOLAME_MPEG2 = 0,
    00087         TWOLAME_MPEG1
    00088     } TWOLAME_MPEG_version;
    00089
    00090
    00092     typedef enum {
    00093         TWOLAME_PAD_NO = 0,
    00094         TWOLAME_PAD_ALL
    00095 //  TWOLAME_PAD_ADJUST      // unsupported by twolame
    00096     } TWOLAME_Padding;
    00097
    00099     typedef enum {
    00100         TWOLAME_EMPHASIS_N = 0,
    00102         TWOLAME_EMPHASIS_5 = 1,
    00104         // reserved
    00105         TWOLAME_EMPHASIS_C = 3
    00107     } TWOLAME_Emphasis;
    00108
    00109
    00111 #define TWOLAME_SAMPLES_PER_FRAME       (1152)
    00112
    00113
    00115     struct twolame_options_struct;
    00116
    00118     typedef struct twolame_options_struct twolame_options;
    00119
    00120
    00121
    00122
    00123
    00129     DLL_EXPORT const char *get_twolame_version(void);
    00130
    00131
    00137     DLL_EXPORT const char *get_twolame_url(void);
    00138
    00139
    00150     DLL_EXPORT void twolame_print_config(twolame_options * glopts);
    00151
    00152
    00162     DLL_EXPORT twolame_options *twolame_init(void);
    00163
    00164
    00176     DLL_EXPORT int twolame_init_params(twolame_options * glopts);
    00177
    00178
    00193     DLL_EXPORT int twolame_encode_buffer(twolame_options * glopts,
    00194                                          const short int leftpcm[],
    00195                                          const short int rightpcm[],
    00196                                          int num_samples,
    00197                                          unsigned char *mp2buffer, int mp2buffer_size);
    00198
    00199
    00213     DLL_EXPORT int twolame_encode_buffer_interleaved(twolame_options * glopts,
    00214                                                      const short int pcm[],
    00215                                                      int num_samples,
    00216                                                      unsigned char *mp2buffer, int mp2buffer_size);
    00217
    00218
    00236     DLL_EXPORT int twolame_encode_buffer_float32(twolame_options * glopts,
    00237                                                  const float leftpcm[],
    00238                                                  const float rightpcm[],
    00239                                                  int num_samples,
    00240                                                  unsigned char *mp2buffer, int mp2buffer_size);
    00241
    00242
    00256     int twolame_encode_buffer_float32_interleaved(twolame_options * glopts,
    00257                                                   const float pcm[],
    00258                                                   int num_samples,
    00259                                                   unsigned char *mp2buffer, int mp2buffer_size);
    00260
    00261
    00274     DLL_EXPORT int twolame_encode_flush(twolame_options * glopts,
    00275                                         unsigned char *mp2buffer, int mp2buffer_size);
    00276
    00277
    00287     DLL_EXPORT void twolame_close(twolame_options ** glopts);
    00288
    00289
    00290
    00306     DLL_EXPORT int twolame_set_verbosity(twolame_options * glopts, int verbosity);
    00307
    00308
    00314     DLL_EXPORT int twolame_get_verbosity(twolame_options * glopts);
    00315
    00316
    00327     DLL_EXPORT int twolame_set_mode(twolame_options * glopts, TWOLAME_MPEG_mode mode);
    00328
    00329
    00335     DLL_EXPORT TWOLAME_MPEG_mode twolame_get_mode(twolame_options * glopts);
    00336
    00337
    00343     DLL_EXPORT const char *twolame_get_mode_name(twolame_options * glopts);
    00344
    00345
    00355     DLL_EXPORT int twolame_set_version(twolame_options * glopts, TWOLAME_MPEG_version version);
    00356
    00357
    00363     DLL_EXPORT TWOLAME_MPEG_version twolame_get_version(twolame_options * glopts);
    00364
    00365
    00371     DLL_EXPORT const char *twolame_get_version_name(twolame_options * glopts);
    00372
    00373
    00380     DLL_EXPORT int twolame_get_framelength(twolame_options * glopts);
    00381
    00382
    00392     DLL_EXPORT int twolame_set_psymodel(twolame_options * glopts, int psymodel);
    00393
    00394
    00400     DLL_EXPORT int twolame_get_psymodel(twolame_options * glopts);
    00401
    00402
    00416     DLL_EXPORT int twolame_set_num_channels(twolame_options * glopts, int num_channels);
    00417
    00418
    00424     DLL_EXPORT int twolame_get_num_channels(twolame_options * glopts);
    00425
    00426
    00438     DLL_EXPORT int twolame_set_scale(twolame_options * glopts, float scale);
    00439
    00440
    00446     DLL_EXPORT float twolame_get_scale(twolame_options * glopts);
    00447
    00459     DLL_EXPORT int twolame_set_scale_left(twolame_options * glopts, float scale);
    00460
    00461
    00467     DLL_EXPORT float twolame_get_scale_left(twolame_options * glopts);
    00468
    00469
    00481     DLL_EXPORT int twolame_set_scale_right(twolame_options * glopts, float scale);
    00482
    00483
    00489     DLL_EXPORT float twolame_get_scale_right(twolame_options * glopts);
    00490
    00491
    00501     DLL_EXPORT int twolame_set_in_samplerate(twolame_options * glopts, int samplerate);
    00502
    00503
    00509     DLL_EXPORT int twolame_get_in_samplerate(twolame_options * glopts);
    00510
    00511
    00521     DLL_EXPORT int twolame_set_out_samplerate(twolame_options * glopts, int samplerate);
    00522
    00523
    00529     DLL_EXPORT int twolame_get_out_samplerate(twolame_options * glopts);
    00530
    00531
    00541     DLL_EXPORT int twolame_set_bitrate(twolame_options * glopts, int bitrate);
    00542
    00543
    00549     DLL_EXPORT int twolame_get_bitrate(twolame_options * glopts);
    00550
    00551
    00556     DLL_EXPORT int twolame_set_brate(twolame_options * glopts, int bitrate);
    00557
    00558
    00563     DLL_EXPORT int twolame_get_brate(twolame_options * glopts);
    00564
    00565
    00577     DLL_EXPORT int twolame_set_padding(twolame_options * glopts, TWOLAME_Padding padding);
    00578
    00584     DLL_EXPORT TWOLAME_Padding twolame_get_padding(twolame_options * glopts);
    00585
    00586
    00604     DLL_EXPORT int twolame_set_energy_levels(twolame_options * glopts, int energylevels);
    00605
    00606
    00612     DLL_EXPORT int twolame_get_energy_levels(twolame_options * glopts);
    00613
    00614
    00624     DLL_EXPORT int twolame_set_num_ancillary_bits(twolame_options * glopts, int num);
    00625
    00626
    00632     DLL_EXPORT int twolame_get_num_ancillary_bits(twolame_options * glopts);
    00633
    00634
    00635
    00645     DLL_EXPORT int twolame_set_emphasis(twolame_options * glopts, TWOLAME_Emphasis emphasis);
    00646
    00647
    00653     DLL_EXPORT TWOLAME_Emphasis twolame_get_emphasis(twolame_options * glopts);
    00654
    00655
    00665     DLL_EXPORT int twolame_set_error_protection(twolame_options * glopts, int err_protection);
    00666
    00667
    00673     DLL_EXPORT int twolame_get_error_protection(twolame_options * glopts);
    00674
    00675
    00687     DLL_EXPORT int twolame_set_copyright(twolame_options * glopts, int copyright);
    00688
    00689
    00695     DLL_EXPORT int twolame_get_copyright(twolame_options * glopts);
    00696
    00697
    00707     DLL_EXPORT int twolame_set_original(twolame_options * glopts, int original);
    00708
    00709
    00715     DLL_EXPORT int twolame_get_original(twolame_options * glopts);
    00716
    00717
    00727     DLL_EXPORT int twolame_set_VBR(twolame_options * glopts, int vbr);
    00728
    00729
    00735     DLL_EXPORT int twolame_get_VBR(twolame_options * glopts);
    00736
    00737
    00750     DLL_EXPORT int twolame_set_VBR_level(twolame_options * glopts, float level);
    00751
    00752
    00758     DLL_EXPORT float twolame_get_VBR_level(twolame_options * glopts);
    00759
    00760
    00761
    00762 /*
    00763    Using the twolame_set_VBR_q()/twolame_get_VBR_q functions
    00764    are deprecated, please use twolame_set_VBR_level() instead.
    00765 */
    00766     DLL_EXPORT int twolame_set_VBR_q(twolame_options * glopts, float level);
    00767     DLL_EXPORT float twolame_get_VBR_q(twolame_options * glopts);
    00768
    00769
    00770
    00780     DLL_EXPORT int twolame_set_ATH_level(twolame_options * glopts, float level);
    00781
    00782
    00788     DLL_EXPORT float twolame_get_ATH_level(twolame_options * glopts);
    00789
    00790
    00800     DLL_EXPORT int twolame_set_VBR_max_bitrate_kbps(twolame_options * glopts, int bitrate);
    00801
    00807     DLL_EXPORT int twolame_get_VBR_max_bitrate_kbps(twolame_options * glopts);
    00808
    00809
    00819     DLL_EXPORT int twolame_set_quick_mode(twolame_options * glopts, int quickmode);
    00820
    00826     DLL_EXPORT int twolame_get_quick_mode(twolame_options * glopts);
    00827
    00828
    00838     DLL_EXPORT int twolame_set_quick_count(twolame_options * glopts, int quickcount);
    00839
    00845     DLL_EXPORT int twolame_get_quick_count(twolame_options * glopts);
    00846
    00847
    00848
    00849
    00850
    00851
    00852
    00853 /* WARNING: DAB support is currently broken */
    00854
    00855
    00856
    00857
    00858
    00868     DLL_EXPORT int twolame_set_DAB(twolame_options * glopts, int dab);
    00869
    00875     DLL_EXPORT int twolame_get_DAB(twolame_options * glopts);
    00876
    00877
    00887     DLL_EXPORT int twolame_set_DAB_xpad_length(twolame_options * glopts, int length);
    00888
    00889
    00895     DLL_EXPORT int twolame_get_DAB_xpad_length(twolame_options * glopts);
    00896
    00897
    00907     DLL_EXPORT int twolame_set_DAB_crc_length(twolame_options * glopts, int length);
    00908
    00909
    00915     DLL_EXPORT int twolame_get_DAB_crc_length(twolame_options * glopts);
    00916
    00917
    00918
    00919 #ifdef __cplusplus
    00920 }
    00921 #endif
    00922 #endif                          /* _TWOLAME_H_ */
    00923 // vim:ts=4:sw=4:nowrap: