OSDN Git Service

Set creation/modified time of the encoded file the same value as the original file...
[lamexp/LameXP.git] / src / Encoder_Abstract.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // LameXP - Audio Encoder Front-End
3 // Copyright (C) 2004-2015 LoRd_MuldeR <MuldeR2@GMX.de>
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version, but always including the *additional*
9 // restrictions defined in the "License.txt" file.
10 //
11 // This program 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
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License along
17 // with this program; if not, write to the Free Software Foundation, Inc.,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 //
20 // http://www.gnu.org/licenses/gpl-2.0.txt
21 ///////////////////////////////////////////////////////////////////////////////
22
23 #include "Encoder_Abstract.h"
24
25 //Internal
26 #include "Global.h"
27
28 //MUtils
29 #include <MUtils/Global.h>
30
31 AbstractEncoder::AbstractEncoder(void)
32 {
33         m_configBitrate = 0;
34         m_configRCMode = 0;
35         m_configCustomParams.clear();
36 }
37
38 AbstractEncoder::~AbstractEncoder(void)
39 {
40 }
41
42 /*
43  * Setters
44  */
45
46 void AbstractEncoder::setBitrate(int bitrate) { m_configBitrate = qMax(0, bitrate); }
47 void AbstractEncoder::setRCMode(int mode) { m_configRCMode = qMax(0, mode); }
48 void AbstractEncoder::setCustomParams(const QString &customParams) { m_configCustomParams = customParams.trimmed(); }
49
50 /*
51  * Default implementation
52  */
53
54 // Does encoder require the input to be downmixed to stereo?
55 const unsigned int *AbstractEncoder::supportedChannelCount(void)
56 {
57         return NULL;
58 }
59
60 // Does encoder require the input to be downsampled? (NULL-terminated array of supported sampling rates)
61 const unsigned int *AbstractEncoder::supportedSamplerates(void)
62 {
63         return NULL;
64 }
65
66 // What bitdepths does the encoder support as input? (NULL-terminated array of supported bits per sample)
67 const unsigned int *AbstractEncoder::supportedBitdepths(void)
68 {
69         return NULL;
70 }
71
72 //Does the encoder need the exact duration of the source?
73 const bool AbstractEncoder::needsTimingInfo(void)
74 {
75         return false;
76 }
77
78 /*
79  * Helper functions
80  */
81
82 //Does this text contain Non-ASCII characters?
83 bool AbstractEncoder::isUnicode(const QString &original)
84 {
85         if(!original.isEmpty())
86         {
87                 QString asLatin1 = QString::fromLatin1(original.toLatin1().constData());
88                 return (wcscmp(MUTILS_WCHR(original), MUTILS_WCHR(asLatin1)) != 0);
89         }
90         return false;
91 }
92
93 //Remove "problematic" characters from tag
94 QString AbstractEncoder::cleanTag(const QString &text)
95 {
96         QString result(text);
97         result.replace(QChar('"'), "'");
98         result.replace(QChar('\\'), "/");
99         return result;
100 }