2010-11-17 19:35:50 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// LameXP - Audio Encoder Front-End
|
2015-01-01 18:06:21 +01:00
|
|
|
// Copyright (C) 2004-2015 LoRd_MuldeR <MuldeR2@GMX.de>
|
2010-11-17 19:35:50 +01:00
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation; either version 2 of the License, or
|
2013-10-23 20:56:57 +02:00
|
|
|
// (at your option) any later version, but always including the *additional*
|
|
|
|
// restrictions defined in the "License.txt" file.
|
2010-11-17 19:35:50 +01:00
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License along
|
|
|
|
// with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
//
|
|
|
|
// http://www.gnu.org/licenses/gpl-2.0.txt
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "Encoder_Abstract.h"
|
|
|
|
|
2014-11-25 02:14:42 +01:00
|
|
|
//Internal
|
2011-02-20 16:28:28 +01:00
|
|
|
#include "Global.h"
|
2010-11-22 21:45:00 +01:00
|
|
|
|
2014-11-25 02:14:42 +01:00
|
|
|
//MUtils
|
|
|
|
#include <MUtils/Global.h>
|
|
|
|
|
2010-11-17 19:35:50 +01:00
|
|
|
AbstractEncoder::AbstractEncoder(void)
|
|
|
|
{
|
|
|
|
m_configBitrate = 0;
|
|
|
|
m_configRCMode = 0;
|
2011-02-09 23:36:17 +01:00
|
|
|
m_configCustomParams.clear();
|
2010-11-17 19:35:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
AbstractEncoder::~AbstractEncoder(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-11-24 21:00:59 +01:00
|
|
|
/*
|
|
|
|
* Setters
|
|
|
|
*/
|
|
|
|
|
2011-11-08 15:12:31 +01:00
|
|
|
void AbstractEncoder::setBitrate(int bitrate) { m_configBitrate = qMax(0, bitrate); }
|
|
|
|
void AbstractEncoder::setRCMode(int mode) { m_configRCMode = qMax(0, mode); }
|
2013-10-03 17:01:37 +02:00
|
|
|
void AbstractEncoder::setCustomParams(const QString &customParams) { m_configCustomParams = customParams.trimmed(); }
|
2010-12-19 00:50:22 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Default implementation
|
|
|
|
*/
|
2011-05-06 17:51:49 +02:00
|
|
|
|
|
|
|
// Does encoder require the input to be downmixed to stereo?
|
2011-12-23 00:43:11 +01:00
|
|
|
const unsigned int *AbstractEncoder::supportedChannelCount(void)
|
2010-12-19 00:50:22 +01:00
|
|
|
{
|
2011-12-23 00:43:11 +01:00
|
|
|
return NULL;
|
2010-12-19 00:50:22 +01:00
|
|
|
}
|
2011-02-20 16:28:28 +01:00
|
|
|
|
2011-05-06 17:51:49 +02:00
|
|
|
// Does encoder require the input to be downsampled? (NULL-terminated array of supported sampling rates)
|
2011-12-21 01:23:21 +01:00
|
|
|
const unsigned int *AbstractEncoder::supportedSamplerates(void)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// What bitdepths does the encoder support as input? (NULL-terminated array of supported bits per sample)
|
|
|
|
const unsigned int *AbstractEncoder::supportedBitdepths(void)
|
2011-05-06 17:51:49 +02:00
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-07-21 19:16:12 +02:00
|
|
|
//Does the encoder need the exact duration of the source?
|
|
|
|
const bool AbstractEncoder::needsTimingInfo(void)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-02-20 16:28:28 +01:00
|
|
|
/*
|
|
|
|
* Helper functions
|
|
|
|
*/
|
2012-12-02 22:55:22 +01:00
|
|
|
|
|
|
|
//Does this text contain Non-ASCII characters?
|
2011-02-20 16:28:28 +01:00
|
|
|
bool AbstractEncoder::isUnicode(const QString &original)
|
|
|
|
{
|
|
|
|
QString asLatin1 = QString::fromLatin1(original.toLatin1().constData());
|
2014-11-25 02:14:42 +01:00
|
|
|
return (wcscmp(MUTILS_WCHR(original), MUTILS_WCHR(asLatin1)) != 0);
|
2011-02-20 16:28:28 +01:00
|
|
|
}
|
2012-12-02 22:55:22 +01:00
|
|
|
|
|
|
|
//Remove "problematic" characters from tag
|
|
|
|
QString AbstractEncoder::cleanTag(const QString &text)
|
|
|
|
{
|
|
|
|
QString result(text);
|
|
|
|
result.replace(QChar('"'), "'");
|
|
|
|
result.replace(QChar('\\'), "/");
|
|
|
|
return result;
|
|
|
|
}
|