2013-09-30 21:39:56 +02:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// LameXP - Audio Encoder Front-End
|
2016-01-03 15:53:42 +01:00
|
|
|
// Copyright (C) 2004-2016 LoRd_MuldeR <MuldeR2@GMX.de>
|
2013-09-30 21:39:56 +02: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.
|
2013-09-30 21:39:56 +02: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 "Registry_Encoder.h"
|
|
|
|
|
2013-10-02 19:17:33 +02:00
|
|
|
#include "Global.h"
|
2013-09-30 21:39:56 +02:00
|
|
|
#include "Model_Settings.h"
|
|
|
|
#include "Encoder_AAC.h"
|
|
|
|
#include "Encoder_AAC_FHG.h"
|
2015-04-24 20:36:05 +02:00
|
|
|
#include "Encoder_AAC_FDK.h"
|
2013-09-30 21:39:56 +02:00
|
|
|
#include "Encoder_AAC_QAAC.h"
|
|
|
|
#include "Encoder_AC3.h"
|
|
|
|
#include "Encoder_DCA.h"
|
|
|
|
#include "Encoder_FLAC.h"
|
|
|
|
#include "Encoder_MP3.h"
|
|
|
|
#include "Encoder_Vorbis.h"
|
|
|
|
#include "Encoder_Opus.h"
|
2013-12-04 22:36:19 +01:00
|
|
|
#include "Encoder_MAC.h"
|
2013-09-30 21:39:56 +02:00
|
|
|
#include "Encoder_Wave.h"
|
|
|
|
|
|
|
|
#define IS_VBR(RC_MODE) ((RC_MODE) == SettingsModel::VBRMode)
|
2013-10-03 15:56:10 +02:00
|
|
|
#define IS_ABR(RC_MODE) ((RC_MODE) == SettingsModel::ABRMode)
|
|
|
|
#define IS_CBR(RC_MODE) ((RC_MODE) == SettingsModel::CBRMode)
|
2013-09-30 21:39:56 +02:00
|
|
|
|
2013-10-02 16:39:26 +02:00
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
// Create encoder instance
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
|
2016-01-30 17:51:10 +01:00
|
|
|
AbstractEncoder *EncoderRegistry::createInstance(const int encoderId, const SettingsModel *settings)
|
2013-09-30 21:39:56 +02:00
|
|
|
{
|
|
|
|
int rcMode = -1;
|
|
|
|
AbstractEncoder *encoder = NULL;
|
|
|
|
|
2013-10-03 17:01:37 +02:00
|
|
|
//Create new encoder instance and apply encoder-specific settings
|
2013-09-30 21:39:56 +02:00
|
|
|
switch(encoderId)
|
|
|
|
{
|
|
|
|
/*-------- MP3Encoder /*--------*/
|
|
|
|
case SettingsModel::MP3Encoder:
|
|
|
|
{
|
2016-01-30 17:51:10 +01:00
|
|
|
MP3Encoder *const mp3Encoder = new MP3Encoder();
|
2013-09-30 21:39:56 +02:00
|
|
|
mp3Encoder->setAlgoQuality(settings->lameAlgoQuality());
|
|
|
|
if(settings->bitrateManagementEnabled())
|
|
|
|
{
|
|
|
|
mp3Encoder->setBitrateLimits(settings->bitrateManagementMinRate(), settings->bitrateManagementMaxRate());
|
|
|
|
}
|
|
|
|
mp3Encoder->setChannelMode(settings->lameChannelMode());
|
|
|
|
encoder = mp3Encoder;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
/*-------- VorbisEncoder /*--------*/
|
|
|
|
case SettingsModel::VorbisEncoder:
|
|
|
|
{
|
2016-01-30 17:51:10 +01:00
|
|
|
VorbisEncoder *const vorbisEncoder = new VorbisEncoder();
|
2013-09-30 21:39:56 +02:00
|
|
|
if(settings->bitrateManagementEnabled())
|
|
|
|
{
|
|
|
|
vorbisEncoder->setBitrateLimits(settings->bitrateManagementMinRate(), settings->bitrateManagementMaxRate());
|
|
|
|
}
|
|
|
|
encoder = vorbisEncoder;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
/*-------- AACEncoder /*--------*/
|
|
|
|
case SettingsModel::AACEncoder:
|
|
|
|
{
|
2013-10-02 19:17:33 +02:00
|
|
|
switch(getAacEncoder())
|
2013-09-30 21:39:56 +02:00
|
|
|
{
|
|
|
|
case SettingsModel::AAC_ENCODER_QAAC:
|
|
|
|
{
|
2016-01-30 17:51:10 +01:00
|
|
|
QAACEncoder *const aacEncoder = new QAACEncoder();
|
2013-09-30 21:39:56 +02:00
|
|
|
aacEncoder->setProfile(settings->aacEncProfile());
|
2016-02-01 20:20:14 +01:00
|
|
|
aacEncoder->setAlgoQuality(settings->lameAlgoQuality());
|
2013-09-30 21:39:56 +02:00
|
|
|
encoder = aacEncoder;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SettingsModel::AAC_ENCODER_FHG:
|
|
|
|
{
|
2016-01-30 17:51:10 +01:00
|
|
|
FHGAACEncoder *const aacEncoder = new FHGAACEncoder();
|
2013-09-30 21:39:56 +02:00
|
|
|
aacEncoder->setProfile(settings->aacEncProfile());
|
|
|
|
encoder = aacEncoder;
|
|
|
|
}
|
|
|
|
break;
|
2015-04-24 20:36:05 +02:00
|
|
|
case SettingsModel::AAC_ENCODER_FDK:
|
|
|
|
{
|
2016-01-30 17:51:10 +01:00
|
|
|
FDKAACEncoder *const aacEncoder = new FDKAACEncoder();
|
2015-04-24 20:36:05 +02:00
|
|
|
aacEncoder->setProfile(settings->aacEncProfile());
|
|
|
|
encoder = aacEncoder;
|
|
|
|
}
|
|
|
|
break;
|
2013-09-30 21:39:56 +02:00
|
|
|
case SettingsModel::AAC_ENCODER_NERO:
|
|
|
|
{
|
2016-01-30 17:51:10 +01:00
|
|
|
AACEncoder *const aacEncoder = new AACEncoder();
|
2013-09-30 21:39:56 +02:00
|
|
|
aacEncoder->setEnable2Pass(settings->neroAACEnable2Pass());
|
|
|
|
aacEncoder->setProfile(settings->aacEncProfile());
|
|
|
|
encoder = aacEncoder;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2014-11-30 21:32:23 +01:00
|
|
|
MUTILS_THROW("makeEncoder(): Unknown AAC encoder specified!");
|
2013-09-30 21:39:56 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
/*-------- AC3Encoder /*--------*/
|
|
|
|
case SettingsModel::AC3Encoder:
|
|
|
|
{
|
2016-01-30 17:51:10 +01:00
|
|
|
AC3Encoder *const ac3Encoder = new AC3Encoder();
|
2013-09-30 21:39:56 +02:00
|
|
|
ac3Encoder->setAudioCodingMode(settings->aftenAudioCodingMode());
|
|
|
|
ac3Encoder->setDynamicRangeCompression(settings->aftenDynamicRangeCompression());
|
|
|
|
ac3Encoder->setExponentSearchSize(settings->aftenExponentSearchSize());
|
|
|
|
ac3Encoder->setFastBitAllocation(settings->aftenFastBitAllocation());
|
|
|
|
encoder = ac3Encoder;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
/*-------- FLACEncoder /*--------*/
|
|
|
|
case SettingsModel::FLACEncoder:
|
|
|
|
{
|
2016-01-30 17:51:10 +01:00
|
|
|
FLACEncoder *const flacEncoder = new FLACEncoder();
|
2013-09-30 21:39:56 +02:00
|
|
|
encoder = flacEncoder;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
/*-------- OpusEncoder --------*/
|
|
|
|
case SettingsModel::OpusEncoder:
|
|
|
|
{
|
2016-01-30 17:51:10 +01:00
|
|
|
OpusEncoder *const opusEncoder = new OpusEncoder();
|
2013-09-30 21:39:56 +02:00
|
|
|
opusEncoder->setOptimizeFor(settings->opusOptimizeFor());
|
|
|
|
opusEncoder->setEncodeComplexity(settings->opusComplexity());
|
|
|
|
opusEncoder->setFrameSize(settings->opusFramesize());
|
|
|
|
encoder = opusEncoder;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
/*-------- DCAEncoder --------*/
|
|
|
|
case SettingsModel::DCAEncoder:
|
|
|
|
{
|
2016-01-30 17:51:10 +01:00
|
|
|
DCAEncoder *const dcaEncoder = new DCAEncoder();
|
2013-09-30 21:39:56 +02:00
|
|
|
encoder = dcaEncoder;
|
|
|
|
}
|
|
|
|
break;
|
2013-12-04 22:36:19 +01:00
|
|
|
/*-------- MACEncoder --------*/
|
|
|
|
case SettingsModel::MACEncoder:
|
|
|
|
{
|
2016-01-30 17:51:10 +01:00
|
|
|
MACEncoder *const macEncoder = new MACEncoder();
|
2013-12-04 22:36:19 +01:00
|
|
|
encoder = macEncoder;
|
|
|
|
}
|
|
|
|
break;
|
2013-09-30 21:39:56 +02:00
|
|
|
/*-------- PCMEncoder --------*/
|
|
|
|
case SettingsModel::PCMEncoder:
|
|
|
|
{
|
2016-01-30 17:51:10 +01:00
|
|
|
WaveEncoder *const waveEncoder = new WaveEncoder();
|
2013-09-30 21:39:56 +02:00
|
|
|
encoder = waveEncoder;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
/*-------- default --------*/
|
|
|
|
default:
|
2014-11-30 21:32:23 +01:00
|
|
|
MUTILS_THROW("Unsupported encoder!");
|
2013-09-30 21:39:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//Sanity checking
|
|
|
|
if(!encoder)
|
|
|
|
{
|
2014-11-30 21:32:23 +01:00
|
|
|
MUTILS_THROW("No encoder instance has been assigend!");
|
2013-09-30 21:39:56 +02:00
|
|
|
}
|
|
|
|
|
2013-10-03 17:01:37 +02:00
|
|
|
//Apply common settings
|
|
|
|
encoder->setRCMode(rcMode = loadEncoderMode(settings, encoderId));
|
|
|
|
encoder->setCustomParams(loadEncoderCustomParams(settings, encoderId));
|
|
|
|
encoder->setBitrate(loadEncoderValue(settings, encoderId, rcMode));
|
|
|
|
|
2013-09-30 21:39:56 +02:00
|
|
|
return encoder;
|
|
|
|
}
|
|
|
|
|
2013-10-02 16:39:26 +02:00
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
// Get encoder info
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
|
2013-09-30 21:39:56 +02:00
|
|
|
const AbstractEncoderInfo *EncoderRegistry::getEncoderInfo(const int encoderId)
|
|
|
|
{
|
|
|
|
const AbstractEncoderInfo *info = NULL;
|
|
|
|
|
|
|
|
switch(encoderId)
|
|
|
|
{
|
2015-04-24 20:36:05 +02:00
|
|
|
case SettingsModel::MP3Encoder: info = MP3Encoder ::getEncoderInfo(); break;
|
2013-10-02 19:17:33 +02:00
|
|
|
case SettingsModel::VorbisEncoder: info = VorbisEncoder::getEncoderInfo(); break;
|
2015-04-24 20:36:05 +02:00
|
|
|
case SettingsModel::AC3Encoder: info = AC3Encoder ::getEncoderInfo(); break;
|
|
|
|
case SettingsModel::FLACEncoder: info = FLACEncoder ::getEncoderInfo(); break;
|
|
|
|
case SettingsModel::OpusEncoder: info = OpusEncoder ::getEncoderInfo(); break;
|
|
|
|
case SettingsModel::DCAEncoder: info = DCAEncoder ::getEncoderInfo(); break;
|
|
|
|
case SettingsModel::MACEncoder: info = MACEncoder ::getEncoderInfo(); break;
|
|
|
|
case SettingsModel::PCMEncoder: info = WaveEncoder ::getEncoderInfo(); break;
|
2013-10-02 19:17:33 +02:00
|
|
|
case SettingsModel::AACEncoder:
|
|
|
|
switch(getAacEncoder())
|
2013-09-30 21:39:56 +02:00
|
|
|
{
|
2015-04-24 20:36:05 +02:00
|
|
|
case SettingsModel::AAC_ENCODER_QAAC: info = QAACEncoder ::getEncoderInfo(); break;
|
2013-10-02 19:17:33 +02:00
|
|
|
case SettingsModel::AAC_ENCODER_FHG: info = FHGAACEncoder::getEncoderInfo(); break;
|
2015-04-24 20:36:05 +02:00
|
|
|
case SettingsModel::AAC_ENCODER_FDK: info = FDKAACEncoder::getEncoderInfo(); break;
|
|
|
|
case SettingsModel::AAC_ENCODER_NERO: info = AACEncoder ::getEncoderInfo(); break;
|
2014-11-30 21:32:23 +01:00
|
|
|
default: MUTILS_THROW("Unknown AAC encoder specified!");
|
2013-09-30 21:39:56 +02:00
|
|
|
}
|
2013-10-02 19:17:33 +02:00
|
|
|
break;
|
2014-11-30 21:32:23 +01:00
|
|
|
default: MUTILS_THROW("Unsupported encoder!");
|
2013-09-30 21:39:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//Sanity checking
|
|
|
|
if(!info)
|
|
|
|
{
|
2014-11-30 21:32:23 +01:00
|
|
|
MUTILS_THROW("No encoder instance has been assigend!");
|
2013-09-30 21:39:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return info;
|
|
|
|
}
|
2013-10-02 16:39:26 +02:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
// Load/store encoder RC mode
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#define STORE_MODE(ENCODER_ID, RC_MODE) do \
|
|
|
|
{ \
|
|
|
|
settings->compressionRCMode##ENCODER_ID(RC_MODE); \
|
|
|
|
} \
|
|
|
|
while(0)
|
|
|
|
|
|
|
|
#define LOAD_MODE(RC_MODE, ENCODER_ID) do \
|
|
|
|
{ \
|
|
|
|
(RC_MODE) = settings->compressionRCMode##ENCODER_ID(); \
|
|
|
|
} \
|
|
|
|
while(0)
|
|
|
|
|
|
|
|
void EncoderRegistry::saveEncoderMode(SettingsModel *settings, const int encoderId, const int rcMode)
|
|
|
|
{
|
|
|
|
//Sanity checking
|
|
|
|
if((rcMode < SettingsModel::VBRMode) || (rcMode > SettingsModel::CBRMode))
|
|
|
|
{
|
2014-11-30 21:32:23 +01:00
|
|
|
MUTILS_THROW("Unknown rate-control mode!");
|
2013-10-02 16:39:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//Store the encoder bitrate/quality value
|
|
|
|
switch(encoderId)
|
|
|
|
{
|
|
|
|
case SettingsModel::MP3Encoder: STORE_MODE(LAME, rcMode); break;
|
|
|
|
case SettingsModel::VorbisEncoder: STORE_MODE(OggEnc, rcMode); break;
|
|
|
|
case SettingsModel::AACEncoder: STORE_MODE(AacEnc, rcMode); break;
|
|
|
|
case SettingsModel::AC3Encoder: STORE_MODE(Aften, rcMode); break;
|
|
|
|
case SettingsModel::FLACEncoder: STORE_MODE(FLAC, rcMode); break;
|
|
|
|
case SettingsModel::OpusEncoder: STORE_MODE(OpusEnc, rcMode); break;
|
|
|
|
case SettingsModel::DCAEncoder: STORE_MODE(DcaEnc, rcMode); break;
|
2013-12-04 22:36:19 +01:00
|
|
|
case SettingsModel::MACEncoder: STORE_MODE(MacEnc, rcMode); break;
|
2013-10-02 16:39:26 +02:00
|
|
|
case SettingsModel::PCMEncoder: STORE_MODE(Wave, rcMode); break;
|
2014-11-30 21:32:23 +01:00
|
|
|
default: MUTILS_THROW("Unsupported encoder!");
|
2013-10-02 16:39:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-03 17:01:37 +02:00
|
|
|
int EncoderRegistry::loadEncoderMode(const SettingsModel *settings, const int encoderId)
|
2013-10-02 16:39:26 +02:00
|
|
|
{
|
|
|
|
int rcMode = -1;
|
|
|
|
|
|
|
|
//Store the encoder bitrate/quality value
|
|
|
|
switch(encoderId)
|
|
|
|
{
|
|
|
|
case SettingsModel::MP3Encoder: LOAD_MODE(rcMode, LAME); break;
|
|
|
|
case SettingsModel::VorbisEncoder: LOAD_MODE(rcMode, OggEnc); break;
|
|
|
|
case SettingsModel::AACEncoder: LOAD_MODE(rcMode, AacEnc); break;
|
|
|
|
case SettingsModel::AC3Encoder: LOAD_MODE(rcMode, Aften); break;
|
|
|
|
case SettingsModel::FLACEncoder: LOAD_MODE(rcMode, FLAC); break;
|
|
|
|
case SettingsModel::OpusEncoder: LOAD_MODE(rcMode, OpusEnc); break;
|
|
|
|
case SettingsModel::DCAEncoder: LOAD_MODE(rcMode, DcaEnc); break;
|
2013-12-04 22:36:19 +01:00
|
|
|
case SettingsModel::MACEncoder: LOAD_MODE(rcMode, MacEnc); break;
|
2013-10-02 16:39:26 +02:00
|
|
|
case SettingsModel::PCMEncoder: LOAD_MODE(rcMode, Wave); break;
|
2014-11-30 21:32:23 +01:00
|
|
|
default: MUTILS_THROW("Unsupported encoder!");
|
2013-10-02 16:39:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return rcMode;
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
// Load/store encoder bitrate/quality value
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#define STORE_VALUE(ENCODER_ID, RC_MODE, VALUE) do \
|
|
|
|
{ \
|
2013-10-03 15:56:10 +02:00
|
|
|
if(IS_VBR(RC_MODE)) settings->compressionVbrQuality##ENCODER_ID(VALUE); \
|
|
|
|
if(IS_ABR(RC_MODE)) settings->compressionAbrBitrate##ENCODER_ID(VALUE); \
|
|
|
|
if(IS_CBR(RC_MODE)) settings->compressionCbrBitrate##ENCODER_ID(VALUE); \
|
2013-10-02 16:39:26 +02:00
|
|
|
} \
|
|
|
|
while(0)
|
|
|
|
|
|
|
|
#define LOAD_VALUE(VALUE, ENCODER_ID, RC_MODE) do \
|
|
|
|
{ \
|
2013-10-03 15:56:10 +02:00
|
|
|
if(IS_VBR(RC_MODE)) (VALUE) = settings->compressionVbrQuality##ENCODER_ID(); \
|
|
|
|
if(IS_ABR(RC_MODE)) (VALUE) = settings->compressionAbrBitrate##ENCODER_ID(); \
|
|
|
|
if(IS_CBR(RC_MODE)) (VALUE) = settings->compressionCbrBitrate##ENCODER_ID(); \
|
2013-10-02 16:39:26 +02:00
|
|
|
} \
|
|
|
|
while(0)
|
|
|
|
|
|
|
|
void EncoderRegistry::saveEncoderValue(SettingsModel *settings, const int encoderId, const int rcMode, const int value)
|
|
|
|
{
|
|
|
|
//Sanity checking
|
|
|
|
if((rcMode < SettingsModel::VBRMode) || (rcMode > SettingsModel::CBRMode))
|
|
|
|
{
|
2014-11-30 21:32:23 +01:00
|
|
|
MUTILS_THROW("Unknown rate-control mode!");
|
2013-10-02 16:39:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//Store the encoder bitrate/quality value
|
|
|
|
switch(encoderId)
|
|
|
|
{
|
|
|
|
case SettingsModel::MP3Encoder: STORE_VALUE(LAME, rcMode, value); break;
|
|
|
|
case SettingsModel::VorbisEncoder: STORE_VALUE(OggEnc, rcMode, value); break;
|
|
|
|
case SettingsModel::AACEncoder: STORE_VALUE(AacEnc, rcMode, value); break;
|
|
|
|
case SettingsModel::AC3Encoder: STORE_VALUE(Aften, rcMode, value); break;
|
|
|
|
case SettingsModel::FLACEncoder: STORE_VALUE(FLAC, rcMode, value); break;
|
|
|
|
case SettingsModel::OpusEncoder: STORE_VALUE(OpusEnc, rcMode, value); break;
|
|
|
|
case SettingsModel::DCAEncoder: STORE_VALUE(DcaEnc, rcMode, value); break;
|
2013-12-04 22:36:19 +01:00
|
|
|
case SettingsModel::MACEncoder: STORE_VALUE(MacEnc, rcMode, value); break;
|
2013-10-02 16:39:26 +02:00
|
|
|
case SettingsModel::PCMEncoder: STORE_VALUE(Wave, rcMode, value); break;
|
2014-11-30 21:32:23 +01:00
|
|
|
default: MUTILS_THROW("Unsupported encoder!");
|
2013-10-02 16:39:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int EncoderRegistry::loadEncoderValue(const SettingsModel *settings, const int encoderId, const int rcMode)
|
|
|
|
{
|
|
|
|
int value = INT_MAX;
|
|
|
|
|
|
|
|
//Sanity checking
|
|
|
|
if((rcMode < SettingsModel::VBRMode) || (rcMode > SettingsModel::CBRMode))
|
|
|
|
{
|
2014-11-30 21:32:23 +01:00
|
|
|
MUTILS_THROW("Unknown rate-control mode!");
|
2013-10-02 16:39:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//Load the encoder bitrate/quality value
|
|
|
|
switch(encoderId)
|
|
|
|
{
|
|
|
|
case SettingsModel::MP3Encoder: LOAD_VALUE(value, LAME, rcMode); break;
|
|
|
|
case SettingsModel::VorbisEncoder: LOAD_VALUE(value, OggEnc, rcMode); break;
|
|
|
|
case SettingsModel::AACEncoder: LOAD_VALUE(value, AacEnc, rcMode); break;
|
|
|
|
case SettingsModel::AC3Encoder: LOAD_VALUE(value, Aften, rcMode); break;
|
|
|
|
case SettingsModel::FLACEncoder: LOAD_VALUE(value, FLAC, rcMode); break;
|
|
|
|
case SettingsModel::OpusEncoder: LOAD_VALUE(value, OpusEnc, rcMode); break;
|
|
|
|
case SettingsModel::DCAEncoder: LOAD_VALUE(value, DcaEnc, rcMode); break;
|
2013-12-04 22:36:19 +01:00
|
|
|
case SettingsModel::MACEncoder: LOAD_VALUE(value, MacEnc, rcMode); break;
|
2013-10-02 16:39:26 +02:00
|
|
|
case SettingsModel::PCMEncoder: LOAD_VALUE(value, Wave, rcMode); break;
|
2014-11-30 21:32:23 +01:00
|
|
|
default: MUTILS_THROW("Unsupported encoder!");
|
2013-10-02 16:39:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
2013-10-02 19:17:33 +02:00
|
|
|
|
2013-10-03 17:01:37 +02:00
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
// Load/store encoder custom parameters
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#define STORE_PARAMS(ENCODER_ID, PARAMS) do \
|
|
|
|
{ \
|
|
|
|
settings->customParameters##ENCODER_ID(PARAMS); \
|
|
|
|
} \
|
|
|
|
while(0)
|
|
|
|
|
|
|
|
#define LOAD_PARAMS(PARAMS, ENCODER_ID) do \
|
|
|
|
{ \
|
|
|
|
(PARAMS) = settings->customParameters##ENCODER_ID(); \
|
|
|
|
} \
|
|
|
|
while(0)
|
|
|
|
|
2015-04-09 18:40:32 +02:00
|
|
|
void EncoderRegistry::saveEncoderCustomParams(SettingsModel *settings, const int encoderId, const QString ¶ms)
|
2013-10-03 17:01:37 +02:00
|
|
|
{
|
|
|
|
//Store the encoder bitrate/quality value
|
|
|
|
switch(encoderId)
|
|
|
|
{
|
|
|
|
case SettingsModel::MP3Encoder: STORE_PARAMS(LAME, params.trimmed()); break;
|
|
|
|
case SettingsModel::VorbisEncoder: STORE_PARAMS(OggEnc, params.trimmed()); break;
|
|
|
|
case SettingsModel::AACEncoder: STORE_PARAMS(AacEnc, params.trimmed()); break;
|
|
|
|
case SettingsModel::AC3Encoder: STORE_PARAMS(Aften, params.trimmed()); break;
|
|
|
|
case SettingsModel::FLACEncoder: STORE_PARAMS(FLAC, params.trimmed()); break;
|
|
|
|
case SettingsModel::OpusEncoder: STORE_PARAMS(OpusEnc, params.trimmed()); break;
|
|
|
|
case SettingsModel::DCAEncoder: STORE_PARAMS(DcaEnc, params.trimmed()); break;
|
2013-12-04 22:36:19 +01:00
|
|
|
case SettingsModel::MACEncoder: STORE_PARAMS(MacEnc, params.trimmed()); break;
|
2013-10-03 17:01:37 +02:00
|
|
|
case SettingsModel::PCMEncoder: STORE_PARAMS(Wave, params.trimmed()); break;
|
2014-11-30 21:32:23 +01:00
|
|
|
default: MUTILS_THROW("Unsupported encoder!");
|
2013-10-03 17:01:37 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QString EncoderRegistry::loadEncoderCustomParams(const SettingsModel *settings, const int encoderId)
|
|
|
|
{
|
|
|
|
QString params;
|
|
|
|
|
|
|
|
//Load the encoder bitrate/quality value
|
|
|
|
switch(encoderId)
|
|
|
|
{
|
|
|
|
case SettingsModel::MP3Encoder: LOAD_PARAMS(params, LAME); break;
|
|
|
|
case SettingsModel::VorbisEncoder: LOAD_PARAMS(params, OggEnc); break;
|
|
|
|
case SettingsModel::AACEncoder: LOAD_PARAMS(params, AacEnc); break;
|
|
|
|
case SettingsModel::AC3Encoder: LOAD_PARAMS(params, Aften); break;
|
|
|
|
case SettingsModel::FLACEncoder: LOAD_PARAMS(params, FLAC); break;
|
|
|
|
case SettingsModel::OpusEncoder: LOAD_PARAMS(params, OpusEnc); break;
|
|
|
|
case SettingsModel::DCAEncoder: LOAD_PARAMS(params, DcaEnc); break;
|
2013-12-04 22:36:19 +01:00
|
|
|
case SettingsModel::MACEncoder: LOAD_PARAMS(params, MacEnc); break;
|
2013-10-03 17:01:37 +02:00
|
|
|
case SettingsModel::PCMEncoder: LOAD_PARAMS(params, Wave); break;
|
2014-11-30 21:32:23 +01:00
|
|
|
default: MUTILS_THROW("Unsupported encoder!");
|
2013-10-03 17:01:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return params;
|
|
|
|
}
|
|
|
|
|
2013-10-03 15:56:10 +02:00
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
// Reset encoder settings
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#define RESET_SETTING(OBJ,NAME) do \
|
|
|
|
{ \
|
|
|
|
(OBJ)->NAME((OBJ)->NAME##Default()); \
|
|
|
|
} \
|
|
|
|
while(0)
|
|
|
|
|
|
|
|
void EncoderRegistry::resetAllEncoders(SettingsModel *settings)
|
|
|
|
{
|
|
|
|
RESET_SETTING(settings, compressionAbrBitrateAacEnc);
|
|
|
|
RESET_SETTING(settings, compressionAbrBitrateAften);
|
|
|
|
RESET_SETTING(settings, compressionAbrBitrateDcaEnc);
|
|
|
|
RESET_SETTING(settings, compressionAbrBitrateFLAC);
|
|
|
|
RESET_SETTING(settings, compressionAbrBitrateLAME);
|
2013-12-04 22:36:19 +01:00
|
|
|
RESET_SETTING(settings, compressionAbrBitrateMacEnc);
|
2013-10-03 15:56:10 +02:00
|
|
|
RESET_SETTING(settings, compressionAbrBitrateOggEnc);
|
|
|
|
RESET_SETTING(settings, compressionAbrBitrateOpusEnc);
|
|
|
|
RESET_SETTING(settings, compressionAbrBitrateWave);
|
|
|
|
|
|
|
|
RESET_SETTING(settings, compressionCbrBitrateAacEnc);
|
|
|
|
RESET_SETTING(settings, compressionCbrBitrateAften);
|
|
|
|
RESET_SETTING(settings, compressionCbrBitrateDcaEnc);
|
|
|
|
RESET_SETTING(settings, compressionCbrBitrateFLAC);
|
|
|
|
RESET_SETTING(settings, compressionCbrBitrateLAME);
|
2013-12-04 22:36:19 +01:00
|
|
|
RESET_SETTING(settings, compressionCbrBitrateMacEnc);
|
2013-10-03 15:56:10 +02:00
|
|
|
RESET_SETTING(settings, compressionCbrBitrateOggEnc);
|
|
|
|
RESET_SETTING(settings, compressionCbrBitrateOpusEnc);
|
|
|
|
RESET_SETTING(settings, compressionCbrBitrateWave);
|
|
|
|
|
|
|
|
RESET_SETTING(settings, compressionRCModeAacEnc);
|
|
|
|
RESET_SETTING(settings, compressionRCModeAften);
|
|
|
|
RESET_SETTING(settings, compressionRCModeDcaEnc);
|
|
|
|
RESET_SETTING(settings, compressionRCModeFLAC);
|
|
|
|
RESET_SETTING(settings, compressionRCModeLAME);
|
2013-12-04 22:36:19 +01:00
|
|
|
RESET_SETTING(settings, compressionRCModeMacEnc);
|
2013-10-03 15:56:10 +02:00
|
|
|
RESET_SETTING(settings, compressionRCModeOggEnc);
|
|
|
|
RESET_SETTING(settings, compressionRCModeOpusEnc);
|
|
|
|
RESET_SETTING(settings, compressionRCModeWave);
|
|
|
|
|
|
|
|
RESET_SETTING(settings, compressionVbrQualityAacEnc);
|
|
|
|
RESET_SETTING(settings, compressionVbrQualityAften);
|
|
|
|
RESET_SETTING(settings, compressionVbrQualityDcaEnc);
|
|
|
|
RESET_SETTING(settings, compressionVbrQualityFLAC);
|
|
|
|
RESET_SETTING(settings, compressionVbrQualityLAME);
|
2013-12-04 22:36:19 +01:00
|
|
|
RESET_SETTING(settings, compressionVbrQualityMacEnc);
|
2013-10-03 15:56:10 +02:00
|
|
|
RESET_SETTING(settings, compressionVbrQualityOggEnc);
|
|
|
|
RESET_SETTING(settings, compressionVbrQualityOpusEnc);
|
|
|
|
RESET_SETTING(settings, compressionVbrQualityWave);
|
|
|
|
}
|
|
|
|
|
2015-05-10 16:34:07 +02:00
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
// Get File Extensions
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
QStringList EncoderRegistry::getOutputFileExtensions(void)
|
|
|
|
{
|
|
|
|
QStringList list;
|
|
|
|
for(int encoderId = SettingsModel::MP3Encoder; encoderId < SettingsModel::ENCODER_COUNT; encoderId++)
|
|
|
|
{
|
|
|
|
if((encoderId == SettingsModel::AACEncoder) && (getAacEncoder() == SettingsModel::AAC_ENCODER_NONE))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
list << QString::fromLatin1(getEncoderInfo(encoderId)->extension());
|
|
|
|
}
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
2013-10-02 19:17:33 +02:00
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
// Static Functions
|
|
|
|
////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
int EncoderRegistry::getAacEncoder(void)
|
|
|
|
{
|
2014-12-20 23:44:43 +01:00
|
|
|
if(lamexp_tools_check("qaac.exe") && lamexp_tools_check("libsoxr.dll") && lamexp_tools_check("libsoxconvolver.dll"))
|
2013-10-02 19:17:33 +02:00
|
|
|
{
|
|
|
|
return SettingsModel::AAC_ENCODER_QAAC;
|
|
|
|
}
|
2015-05-12 00:29:17 +02:00
|
|
|
else if(lamexp_tools_check("qaac64.exe") && lamexp_tools_check("libsoxr64.dll") && lamexp_tools_check("libsoxconvolver64.dll"))
|
|
|
|
{
|
|
|
|
return SettingsModel::AAC_ENCODER_QAAC;
|
|
|
|
}
|
2015-04-24 20:36:05 +02:00
|
|
|
else if(lamexp_tools_check("fdkaac.exe"))
|
|
|
|
{
|
|
|
|
return SettingsModel::AAC_ENCODER_FDK;
|
|
|
|
}
|
2014-12-20 23:44:43 +01:00
|
|
|
else if(lamexp_tools_check("fhgaacenc.exe") && lamexp_tools_check("enc_fhgaac.dll") && lamexp_tools_check("nsutil.dll") && lamexp_tools_check("libmp4v2.dll"))
|
2013-10-02 19:17:33 +02:00
|
|
|
{
|
|
|
|
return SettingsModel::AAC_ENCODER_FHG;
|
|
|
|
}
|
2014-12-20 23:44:43 +01:00
|
|
|
else if(lamexp_tools_check("neroAacEnc.exe") && lamexp_tools_check("neroAacDec.exe") && lamexp_tools_check("neroAacTag.exe"))
|
2013-10-02 19:17:33 +02:00
|
|
|
{
|
|
|
|
return SettingsModel::AAC_ENCODER_NERO;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return SettingsModel::AAC_ENCODER_NONE;
|
|
|
|
}
|
|
|
|
}
|