1 /*******************************************************************************
2  lqt_lame.c
3 
4  libquicktime - A library for reading and writing quicktime/avi/mp4 files.
5  http://libquicktime.sourceforge.net
6 
7  Copyright (C) 2002 Heroine Virtual Ltd.
8  Copyright (C) 2002-2011 Members of the libquicktime project.
9 
10  This library is free software; you can redistribute it and/or modify it under
11  the terms of the GNU Lesser General Public License as published by the Free
12  Software Foundation; either version 2.1 of the License, or (at your option)
13  any later version.
14 
15  This library is distributed in the hope that it will be useful, but WITHOUT
16  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17  FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
18  details.
19 
20  You should have received a copy of the GNU Lesser General Public License along
21  with this library; if not, write to the Free Software Foundation, Inc., 51
22  Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 *******************************************************************************/
24 
25 #include "lqt_private.h"
26 #include <quicktime/lqt_codecapi.h>
27 #include "lame_codec.h"
28 
29 static char * fourccs_mp3[]  = { QUICKTIME_MP3, (char*)0 };
30 
31 static lqt_parameter_info_static_t encode_parameters_lame[] =
32   {
33     {
34       .name =        "mp3_bitrate_mode",
35       .real_name =   TRS("Bitrate mode"),
36       .type =        LQT_PARAMETER_STRINGLIST,
37       .val_default = { .val_string = "CBR" },
38       .stringlist_options = (char*[]){ TRS("CBR"), TRS("ABR"), TRS("VBR"), (char*)0 },
39       .help_string = TRS("CBR: Constant bitrate\nVBR: Variable bitrate\n"
40                          "ABR: Average bitrate")
41     },
42     {
43       .name =        "mp3_bitrate",
44       .real_name =   TRS("Nominal Bitrate (ABR/CBR)"),
45       .type =        LQT_PARAMETER_INT,
46       .val_default = { 256000 },
47       .help_string = TRS("Bitrate in bits per second. For CBR, this must be a "
48                          "valid MP3 bitrate")
49     },
50     {
51       .name =        "mp3_bitrate_min",
52       .real_name =   TRS("Minimum Bitrate (ABR)"),
53       .type =        LQT_PARAMETER_INT,
54       .val_default = { 64000 },
55       .help_string = TRS("Minimum ABR bitrate in bits per second. This must be a "
56                          "valid MP3 bitrate")
57     },
58     {
59       .name =        "mp3_bitrate_max",
60       .real_name =   TRS("Maximum Bitrate (ABR)"),
61       .type =        LQT_PARAMETER_INT,
62       .val_default = { 320000 },
63       .help_string = TRS("Maximum ABR bitrate in bits per second. This must be a "
64                          "valid MP3 bitrate")
65     },
66     {
67       .name =        "mp3_quality",
68       .real_name =   TRS("Quality (0 = best)"),
69       .type =        LQT_PARAMETER_INT,
70       .val_default = { 0 },
71       .val_min =     { .val_int = 0 },
72       .val_max =     { .val_int = 9 },
73       .help_string = TRS("0: Slowest encoding, best quality\n"
74                          "9: Fastest encoding, worst quality")
75     },
76     {
77       .name =        "mp3_quality_vbr",
78       .real_name =   TRS("VBR Quality (0 = best)"),
79       .type =        LQT_PARAMETER_INT,
80       .val_default = { 0 },
81       .val_min =     { .val_int = 0 },
82       .val_max =     { .val_int = 9 },
83       .help_string = TRS("VBR Quality level. 0: best, 9: worst")
84     },
85     { /* End of paramaters */ }
86   };
87 
88 static lqt_codec_info_static_t codec_info_lame =
89   {
90     .name =                "lame",
91     .long_name =           TRS("Lame mp3 encoder"),
92     .description =         TRS("Lame mp3 encoder (see http://www.mp3dev.org)"),
93     .fourccs =             fourccs_mp3,
94     .wav_ids =             (int[]){ 0x55, LQT_WAV_ID_NONE },
95     .type =                LQT_CODEC_AUDIO,
96     .direction =           LQT_DIRECTION_ENCODE,
97     .encoding_parameters = encode_parameters_lame,
98     .decoding_parameters = (lqt_parameter_info_static_t*)0,
99     .compatibility_flags = LQT_FILE_QT_OLD | LQT_FILE_QT | LQT_FILE_AVI | LQT_FILE_AVI_ODML,
100     .compression_id      = LQT_COMPRESSION_MP3,
101   };
102 
get_num_codecs()103 LQT_EXTERN int get_num_codecs() { return 1; }
104 
get_codec_info(int index)105 LQT_EXTERN lqt_codec_info_static_t * get_codec_info(int index)
106   {
107   if(!index)
108     return &codec_info_lame;
109 
110   return (lqt_codec_info_static_t*)0;
111   }
112 
113 /*
114  *   Return the actual codec constructor
115  */
116 
get_codec(int index)117 LQT_EXTERN lqt_init_codec_func_t get_codec(int index)
118   {
119   if(index == 0)
120     return quicktime_init_codec_lame;
121   return (lqt_init_codec_func_t)0;
122   }
123