MythTV  master
lameencoder.h
Go to the documentation of this file.
1 /*
2  MP3 encoding support using liblame for MythMusic
3 
4  (c) 2003 Stefan Frank
5 
6  Please send an e-mail to sfr@gmx.net if you have
7  questions or comments.
8 
9  Project Website: http://www.mythtv.org/
10 
11  This program is free software; you can redistribute it and/or modify
12  it under the terms of the GNU General Public License as published by
13  the Free Software Foundation; either version 2 of the License, or
14  (at your option) any later version.
15 
16  This program is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  GNU General Public License for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with this program; if not, write to the Free Software
23  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25 
26 #ifndef LAMEENCODER_H_
27 #define LAMEENCODER_H_
28 
29 class QString;
30 class MusicMetadata;
31 class Encoder;
32 
33 #ifdef MMX
34 #define LAME_WORKAROUND 1
35 #undef MMX
36 #endif
37 
38 #include <lame/lame.h>
39 
40 #ifdef LAME_WORKAROUND
41 #define MMX 1
42 #endif
43 
44 #include "encoder.h"
45 
46 class LameEncoder : public Encoder
47 {
48  public:
49  LameEncoder(const QString &outfile, int qualitylevel, MusicMetadata *metadata,
50  bool vbr = false);
51  ~LameEncoder() override;
52  int addSamples(int16_t *bytes, unsigned int len) override; // Encoder
53 
54  private:
55  int init_encoder(lame_global_flags *gf, int quality, bool vbr);
56  static void init_id3tags(lame_global_flags *gf);
57 
58  int m_bits {16};
59  int m_channels {2};
62 
63  // worst-case estimate
64  int m_mp3BufSize {(int)(1.25 * 16384 + 7200)};
65  char *m_mp3Buf {nullptr};
66 
67  lame_global_flags *m_gf {nullptr};
68 };
69 
70 #endif
71 
LameEncoder(const QString &outfile, int qualitylevel, MusicMetadata *metadata, bool vbr=false)
lame_global_flags * m_gf
Definition: lameencoder.h:67
int m_channels
Definition: lameencoder.h:59
int m_samplesPerChannel
Definition: lameencoder.h:61
char * m_mp3Buf
Definition: lameencoder.h:65
static void init_id3tags(lame_global_flags *gf)
Definition: lameencoder.cpp:48
int m_bytesPerSample
Definition: lameencoder.h:60
int init_encoder(lame_global_flags *gf, int quality, bool vbr)
Definition: lameencoder.cpp:62
int m_mp3BufSize
Definition: lameencoder.h:64
int addSamples(int16_t *bytes, unsigned int len) override
~LameEncoder() override