Implement filter framework + currently only the "downmix" filter is implemented, so we can support multichannel to MP3 encoding from now on.

This commit is contained in:
LoRd_MuldeR 2010-12-19 00:50:22 +01:00
parent 800c94abd3
commit fc148e5e65
23 changed files with 505 additions and 5 deletions

View File

@ -310,6 +310,10 @@
RelativePath=".\src\Decoder_Vorbis.cpp"
>
</File>
<File
RelativePath=".\src\Decoder_Wave.cpp"
>
</File>
<File
RelativePath=".\src\Decoder_WMA.cpp"
>
@ -370,6 +374,14 @@
RelativePath=".\src\Encoder_Wave.cpp"
>
</File>
<File
RelativePath=".\src\Filter_Abstract.cpp"
>
</File>
<File
RelativePath=".\src\Filter_Downmix.cpp"
>
</File>
<File
RelativePath=".\src\Genres.cpp"
>
@ -502,6 +514,10 @@
RelativePath=".\src\Decoder_Vorbis.h"
>
</File>
<File
RelativePath=".\src\Decoder_Wave.h"
>
</File>
<File
RelativePath=".\src\Decoder_WMA.h"
>
@ -951,6 +967,40 @@
<File
RelativePath=".\src\Encoder_Wave.h"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="MOC &quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot;"
CommandLine="&quot;$(QTDIR)\bin\moc.exe&quot; -o &quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot; &quot;$(InputPath)&quot;&#x0D;&#x0A;"
Outputs="&quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot;"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="MOC &quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot;"
CommandLine="&quot;$(QTDIR)\bin\moc.exe&quot; -o &quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot; &quot;$(InputPath)&quot;&#x0D;&#x0A;"
Outputs="&quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot;"
/>
</FileConfiguration>
<FileConfiguration
Name="Release_Static|Win32"
>
<Tool
Name="VCCustomBuildTool"
Description="MOC &quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot;"
CommandLine="&quot;$(QTDIR)\bin\moc.exe&quot; -o &quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot; &quot;$(InputPath)&quot;&#x0D;&#x0A;"
Outputs="&quot;$(SolutionDir)tmp\MOC_$(SafeInputName).cpp&quot;"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\src\Filter_Abstract.h"
>
<FileConfiguration
Name="Debug|Win32"
>
@ -982,6 +1032,10 @@
/>
</FileConfiguration>
</File>
<File
RelativePath=".\src\Filter_Downmix.h"
>
</File>
<File
RelativePath=".\src\Genres.h"
>
@ -1394,6 +1448,10 @@
RelativePath=".\tmp\MOC_Encoder_Wave.cpp"
>
</File>
<File
RelativePath=".\tmp\MOC_Filter_Abstract.cpp"
>
</File>
<File
RelativePath=".\tmp\MOC_Model_FileList.cpp"
>

View File

@ -54,6 +54,7 @@
;--------------------------------
!include `MUI2.nsh`
!include `WinVer.nsh`
!include `UAC.nsh`
!include `parameters.nsh`
@ -223,6 +224,7 @@ LangString LAMEXP_LANG_LOCKEDLIST_NOPROG ${LANG_ENGLISH} "No programs that hav
LangString LAMEXP_LANG_LOCKEDLIST_SEARCH ${LANG_ENGLISH} "Searching, please wait..."
LangString LAMEXP_LANG_LOCKEDLIST_COLHDR1 ${LANG_ENGLISH} "Application"
LangString LAMEXP_LANG_LOCKEDLIST_COLHDR2 ${LANG_ENGLISH} "Process"
LangString LAMEXP_LANG_UNINST_PERSONAL ${LANG_ENGLISH} "Do you want your personal settings to be deleted too?"
;German
LangString LAMEXP_LANG_STATUS_CLOSING ${LANG_GERMAN} "Schließe laufende Instanz, bitte warten..."
@ -238,6 +240,7 @@ LangString LAMEXP_LANG_LOCKEDLIST_NOPROG ${LANG_GERMAN} "Es m
LangString LAMEXP_LANG_LOCKEDLIST_SEARCH ${LANG_GERMAN} "Suche, bitte warten..."
LangString LAMEXP_LANG_LOCKEDLIST_COLHDR1 ${LANG_GERMAN} "Anwendung"
LangString LAMEXP_LANG_LOCKEDLIST_COLHDR2 ${LANG_GERMAN} "Prozess"
LangString LAMEXP_LANG_UNINST_PERSONAL ${LANG_GERMAN} "Sollen Ihre persönlichen Einstellungen ebenfalls gelöscht werden?"
;--------------------------------
@ -254,6 +257,19 @@ Function .onInit
MessageBox MB_ICONSTOP|MB_TOPMOST "Sorry, the installer is already running!"
Quit
${EndIf}
${If} ${IsNT}
Goto OS_Windows_NT
${Else}
MessageBox MB_TOPMOST|MB_ICONSTOP "Sorry, the Windows 9x series (including ME) is not supported by this application!"
Quit
${EndIf}
OS_Windows_NT:
${If} ${AtMostWinNT4}
MessageBox MB_TOPMOST|MB_ICONSTOP "Sorry, Windows NT 4.0 (and older) is not supported by this application!"
Quit
${EndIf}
FunctionEnd
Function un.onInit
@ -430,6 +446,9 @@ Section "Uninstall"
DeleteRegValue HKLM "${MyRegPath}" "StartmenuFolder"
DeleteRegValue HKLM "${MyRegPath}" "SetupLanguage"
MessageBox MB_YESNO|MB_TOPMOST "$(LAMEXP_LANG_UNINST_PERSONAL)" IDNO +2
Delete "$LOCALAPPDATA\LoRd_MuldeR\LameXP - Audio Encoder Front-End\config.ini"
!insertmacro PrintProgress "$(MUI_UNTEXT_FINISH_TITLE)."
SectionEnd

View File

@ -19,6 +19,7 @@
<file>tools/oggenc2_x64.exe</file>
<file>tools/selfdelete.exe</file>
<file>tools/shorten.exe</file>
<file>tools/sox.exe</file>
<file>tools/speexdec.exe</file>
<file>tools/takc.exe</file>
<file>tools/ttaenc.exe</file>

BIN
res/tools/sox.exe Normal file

Binary file not shown.

View File

@ -25,7 +25,7 @@
#define VER_LAMEXP_MAJOR 4
#define VER_LAMEXP_MINOR_HI 0
#define VER_LAMEXP_MINOR_LO 0
#define VER_LAMEXP_BUILD 163
#define VER_LAMEXP_BUILD 167
#define VER_LAMEXP_SUFFIX TechPreview
/*

88
src/Decoder_Wave.cpp Normal file
View File

@ -0,0 +1,88 @@
///////////////////////////////////////////////////////////////////////////////
// LameXP - Audio Encoder Front-End
// Copyright (C) 2004-2010 LoRd_MuldeR <MuldeR2@GMX.de>
//
// 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
// (at your option) any later version.
//
// 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 "Decoder_Wave.h"
#include "Global.h"
#include <QDir>
#include <QProcess>
#include <QRegExp>
#include <Shellapi.h>
#define FIX_SEPARATORS(STR) for(int i = 0; STR[i]; i++) { if(STR[i] == L'/') STR[i] = L'\\'; }
WaveDecoder::WaveDecoder(void)
{
}
WaveDecoder::~WaveDecoder(void)
{
}
bool WaveDecoder::decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag)
{
emit messageLogged(QString("Copy file \"%1\" to \"%2\"").arg(sourceFile, outputFile));
SHFILEOPSTRUCTW fileOperation;
memset(&fileOperation, 0, sizeof(SHFILEOPSTRUCTW));
fileOperation.wFunc = FO_COPY;
fileOperation.fFlags = FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR | FOF_NOERRORUI | FOF_FILESONLY;
size_t srcLen = wcslen(reinterpret_cast<const wchar_t*>(sourceFile.utf16())) + 3;
wchar_t *srcBuffer = new wchar_t[srcLen];
memset(srcBuffer, 0, srcLen * sizeof(wchar_t));
wcscpy_s(srcBuffer, srcLen, reinterpret_cast<const wchar_t*>(sourceFile.utf16()));
FIX_SEPARATORS (srcBuffer);
fileOperation.pFrom = srcBuffer;
size_t outLen = wcslen(reinterpret_cast<const wchar_t*>(outputFile.utf16())) + 3;
wchar_t *outBuffer = new wchar_t[outLen];
memset(outBuffer, 0, outLen * sizeof(wchar_t));
wcscpy_s(outBuffer, outLen, reinterpret_cast<const wchar_t*>(outputFile.utf16()));
FIX_SEPARATORS (outBuffer);
fileOperation.pTo = outBuffer;
emit statusUpdated(0);
int result = SHFileOperation(&fileOperation);
emit statusUpdated(100);
emit messageLogged(QString().sprintf("\nExited with code: 0x%04X", result));
delete [] srcBuffer;
delete [] outBuffer;
return (result == 0 && fileOperation.fAnyOperationsAborted == false);
}
bool WaveDecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
{
if(containerType.compare("Wave", Qt::CaseInsensitive) == 0)
{
if(formatType.compare("PCM", Qt::CaseInsensitive) == 0)
{
return true;
}
}
return false;
}

34
src/Decoder_Wave.h Normal file
View File

@ -0,0 +1,34 @@
///////////////////////////////////////////////////////////////////////////////
// LameXP - Audio Encoder Front-End
// Copyright (C) 2004-2010 LoRd_MuldeR <MuldeR2@GMX.de>
//
// 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
// (at your option) any later version.
//
// 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
///////////////////////////////////////////////////////////////////////////////
#pragma once
#include "Decoder_Abstract.h"
class WaveDecoder : public AbstractDecoder
{
public:
WaveDecoder(void);
~WaveDecoder(void);
virtual bool decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag);
static bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
};

View File

@ -244,11 +244,16 @@ void AboutDialog::showMoreAbout(void)
moreAboutText += LINK("http://flac.sourceforge.net/");
moreAboutText += "<br>";
moreAboutText += VSTR("<li><b>MediaInfo - Media File Analysis Tool (%1)</b><br>", "mediainfo_i386.exe", "v?.?.??");
moreAboutText += VSTR("<li><b>MediaInfo - Media File Analysis Tool (%1)</b><br>", "mediainfo_i386.exe", "v?.?.?");
moreAboutText += "Released under the terms of the GNU Leser General Public License.<br>";
moreAboutText += LINK("http://mediainfo.sourceforge.net/");
moreAboutText += "<br>";
moreAboutText += VSTR("<li><b>SoX - Sound eXchange (%1)</b><br>", "sox.exe", "v??.?.?");
moreAboutText += "Released under the terms of the GNU Leser General Public License.<br>";
moreAboutText += LINK("http://sox.sourceforge.net/");
moreAboutText += "<br>";
moreAboutText += "<li><b>Silk Icons - Over 700 icons in PNG format (v1.3)</b><br>";
moreAboutText += "<nobr>By Mark James, released under the Creative Commons 'by' License.</nobr><br>";
moreAboutText += LINK("http://www.famfamfam.com/lab/icons/silk/");

View File

@ -584,6 +584,9 @@ void MainWindow::aboutButtonClicked(void)
*/
void MainWindow::encodeButtonClicked(void)
{
static const __int64 oneGigabyte = 1073741824;
static const __int64 minimumFreeDiskspaceMultiplier = 222;
ABORT_IF_BUSY;
if(m_fileListModel->rowCount() < 1)
@ -593,6 +596,16 @@ void MainWindow::encodeButtonClicked(void)
return;
}
if(lamexp_free_diskspace(lamexp_temp_folder()) < (oneGigabyte * minimumFreeDiskspaceMultiplier))
{
QDir tempFolder(lamexp_temp_folder());
tempFolder.cdUp();
if(QMessageBox::warning(this, "Low Diskspace Warning", QString("<nobr>Warning: There are less than %1 GB of free diskspace available on your system's TEMP folder!</nobr><br><br>Your TEMP folder is located at:<br><i>%2</i>").arg(QString::number(minimumFreeDiskspaceMultiplier), tempFolder.path()), "Abort Process (Recommended)", "Ignore") != 1)
{
return;
}
}
switch(m_settings->compressionEncoder())
{
case SettingsModel::MP3Encoder:

View File

@ -339,7 +339,7 @@ void ProcessingDialog::doneEncoding(void)
}
else
{
CHANGE_BACKGROUND_COLOR(frame_header, QColor("#D1FFD5"));
CHANGE_BACKGROUND_COLOR(frame_header, QColor("#E0FFE2"));
WinSevenTaskbar::setTaskbarState(this, WinSevenTaskbar::WinSevenTaskbarNormalState);
WinSevenTaskbar::setOverlayIcon(this, &QIcon(":/icons/accept.png"));
SET_PROGRESS_TEXT("Alle files completed successfully.");

View File

@ -39,3 +39,11 @@ AbstractEncoder::~AbstractEncoder(void)
void AbstractEncoder::setBitrate(int bitrate) { m_configBitrate = max(0, bitrate); }
void AbstractEncoder::setRCMode(int mode) { m_configRCMode = max(0, mode); }
/*
* Default implementation
*/
bool AbstractEncoder::requiresDownmix(void)
{
return false;
}

View File

@ -40,6 +40,7 @@ public:
virtual bool encode(const QString &sourceFile, const AudioFileModel &metaInfo, const QString &outputFile, volatile bool *abortFlag) = 0;
virtual bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion) = 0;
virtual QString extension(void) = 0;
virtual bool requiresDownmix(void);
//Common setter methods
void setBitrate(int bitrate);

View File

@ -173,3 +173,8 @@ bool MP3Encoder::isFormatSupported(const QString &containerType, const QString &
return false;
}
bool MP3Encoder::requiresDownmix(void)
{
return true;
}

View File

@ -36,6 +36,7 @@ public:
virtual bool encode(const QString &sourceFile, const AudioFileModel &metaInfo, const QString &outputFile, volatile bool *abortFlag);
virtual bool isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion);
virtual QString extension(void);
virtual bool requiresDownmix(void);
private:
const QString m_binary;

30
src/Filter_Abstract.cpp Normal file
View File

@ -0,0 +1,30 @@
///////////////////////////////////////////////////////////////////////////////
// LameXP - Audio Encoder Front-End
// Copyright (C) 2004-2010 LoRd_MuldeR <MuldeR2@GMX.de>
//
// 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
// (at your option) any later version.
//
// 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 "Filter_Abstract.h"
AbstractFilter::AbstractFilter(void)
{
}
AbstractFilter::~AbstractFilter(void)
{
}

37
src/Filter_Abstract.h Normal file
View File

@ -0,0 +1,37 @@
///////////////////////////////////////////////////////////////////////////////
// LameXP - Audio Encoder Front-End
// Copyright (C) 2004-2010 LoRd_MuldeR <MuldeR2@GMX.de>
//
// 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
// (at your option) any later version.
//
// 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
///////////////////////////////////////////////////////////////////////////////
#pragma once
#include "Tool_Abstract.h"
class AbstractFilter : public AbstractTool
{
Q_OBJECT
public:
AbstractFilter(void);
~AbstractFilter(void);
//Internal decoder API
virtual bool apply(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag) = 0;
};

106
src/Filter_Downmix.cpp Normal file
View File

@ -0,0 +1,106 @@
///////////////////////////////////////////////////////////////////////////////
// LameXP - Audio Encoder Front-End
// Copyright (C) 2004-2010 LoRd_MuldeR <MuldeR2@GMX.de>
//
// 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
// (at your option) any later version.
//
// 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 "Filter_Downmix.h"
#include "Global.h"
#include <QDir>
#include <QProcess>
#include <QRegExp>
DownmixFilter::DownmixFilter(void)
:
m_binary(lamexp_lookup_tool("sox.exe"))
{
if(m_binary.isEmpty())
{
throw "Error initializing SoX filter. Tool 'sox.exe' is not registred!";
}
}
DownmixFilter::~DownmixFilter(void)
{
}
bool DownmixFilter::apply(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag)
{
QProcess process;
QStringList args;
args << "-V3";
args << QDir::toNativeSeparators(sourceFile);
args << "-c2";
args << QDir::toNativeSeparators(outputFile);
if(!startProcess(process, m_binary, args))
{
return false;
}
bool bTimeout = false;
bool bAborted = false;
while(process.state() != QProcess::NotRunning)
{
if(*abortFlag)
{
process.kill();
bAborted = true;
emit messageLogged("\nABORTED BY USER !!!");
break;
}
process.waitForReadyRead();
if(!process.bytesAvailable() && process.state() == QProcess::Running)
{
process.kill();
qWarning("SoX process timed out <-- killing!");
bTimeout = true;
break;
}
while(process.bytesAvailable() > 0)
{
QByteArray line = process.readLine();
QString text = QString::fromUtf8(line.constData()).simplified();
if(!text.isEmpty())
{
emit messageLogged(text);
}
}
}
process.waitForFinished();
if(process.state() != QProcess::NotRunning)
{
process.kill();
process.waitForFinished(-1);
}
emit statusUpdated(100);
emit messageLogged(QString().sprintf("\nExited with code: 0x%04X", process.exitCode()));
if(bTimeout || bAborted || process.exitStatus() != QProcess::NormalExit || QFileInfo(outputFile).size() == 0)
{
return false;
}
return true;
}

36
src/Filter_Downmix.h Normal file
View File

@ -0,0 +1,36 @@
///////////////////////////////////////////////////////////////////////////////
// LameXP - Audio Encoder Front-End
// Copyright (C) 2004-2010 LoRd_MuldeR <MuldeR2@GMX.de>
//
// 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
// (at your option) any later version.
//
// 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
///////////////////////////////////////////////////////////////////////////////
#pragma once
#include "Filter_Abstract.h"
class DownmixFilter : public AbstractFilter
{
public:
DownmixFilter(void);
~DownmixFilter(void);
virtual bool apply(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag);
private:
const QString m_binary;
};

View File

@ -907,6 +907,23 @@ QString lamexp_known_folder(lamexp_known_folder_t folder_id)
return folder;
}
/*
* Get number private bytes [debug only]
*/
__int64 lamexp_free_diskspace(const QString &path)
{
ULARGE_INTEGER freeBytesAvailable, totalNumberOfBytes, totalNumberOfFreeBytes;
if(GetDiskFreeSpaceExW(reinterpret_cast<const wchar_t*>(QDir::toNativeSeparators(path).utf16()), &freeBytesAvailable, &totalNumberOfBytes, &totalNumberOfFreeBytes))
{
return freeBytesAvailable.QuadPart;
}
else
{
return 0;
}
}
/*
* Get number private bytes [debug only]
*/

View File

@ -94,6 +94,7 @@ lamexp_cpu_t lamexp_detect_cpu_features(void);
bool lamexp_clean_folder(const QString folderPath);
const QString lamexp_version2string(const QString &pattern, unsigned int version);
QString lamexp_known_folder(lamexp_known_folder_t folder_id);
__int64 lamexp_free_diskspace(const QString &path);
//Debug-only functions
SIZE_T lamexp_dbg_private_bytes(void);

View File

@ -26,6 +26,7 @@
#include "Decoder_Vorbis.h"
#include "Decoder_FLAC.h"
#include "Decoder_WMA.h"
#include "Decoder_Wave.h"
#include <QString>
@ -38,6 +39,7 @@ AbstractDecoder *DecoderRegistry::lookup(const QString &containerType, const QSt
PROBE_DECODER(AACDecoder);
PROBE_DECODER(FLACDecoder);
PROBE_DECODER(WMADecoder);
PROBE_DECODER(WaveDecoder);
return NULL;
}

View File

@ -64,6 +64,7 @@ static const struct lamexp_tool_t g_lamexp_tools[] =
{"a8c50872e544a55495a824426e9378984f2ae01d", "oggenc2_x64.exe", 287},
{"cd95369051f96b9ca3a997658771c5ea52bc874d", "selfdelete.exe", UINT_MAX},
{"ffeaa70bd6321185eafcb067ab2dc441650038bf", "shorten.exe", UINT_MAX},
{"831f898daaba8d9787c5c02b5f4f8ace9e77de99", "sox.exe", 1431},
{"346ce516281c97e92e1b8957ddeca52edcf2d056", "speexdec.exe", UINT_MAX},
{"8a74b767cfe88bf88c068fdae0de02d65589d25e", "takc.exe", UINT_MAX},
{"1c5cedb56358a0e8c4590a863a97c94d7d7e98b2", "ttaenc.exe", UINT_MAX},

View File

@ -26,6 +26,8 @@
#include "Model_Progress.h"
#include "Encoder_Abstract.h"
#include "Decoder_Abstract.h"
#include "Filter_Abstract.h"
#include "Filter_Downmix.h"
#include "Registry_Decoder.h"
#include "Model_Settings.h"
@ -94,7 +96,7 @@ void ProcessThread::processFile()
{
m_aborted = false;
bool bSuccess = true;
qDebug("Process thread %s has started.", m_jobId.toString().toLatin1().constData());
emit processStateInitialized(m_jobId, QFileInfo(m_audioFile.filePath()).fileName(), "Starting...", ProgressModel::JobRunning);
@ -107,10 +109,18 @@ void ProcessThread::processFile()
return;
}
QList<AbstractFilter*> filters;
//Do we need Stereo downmix?
if(m_audioFile.formatAudioChannels() > 2 && m_encoder->requiresDownmix())
{
filters.prepend(new DownmixFilter());
}
QString sourceFile = m_audioFile.filePath();
//Decode source file
if(!m_encoder->isFormatSupported(m_audioFile.formatContainerType(), m_audioFile.formatContainerProfile(), m_audioFile.formatAudioType(), m_audioFile.formatAudioProfile(), m_audioFile.formatAudioVersion()))
if(!filters.isEmpty() || !m_encoder->isFormatSupported(m_audioFile.formatContainerType(), m_audioFile.formatContainerProfile(), m_audioFile.formatAudioType(), m_audioFile.formatAudioProfile(), m_audioFile.formatAudioVersion()))
{
m_currentStep = DecodingStep;
AbstractDecoder *decoder = DecoderRegistry::lookup(m_audioFile.formatContainerType(), m_audioFile.formatContainerProfile(), m_audioFile.formatAudioType(), m_audioFile.formatAudioProfile(), m_audioFile.formatAudioVersion());
@ -139,6 +149,30 @@ void ProcessThread::processFile()
}
}
//Apply all filters
while(!filters.isEmpty())
{
QString tempFile = generateTempFileName();
AbstractFilter *poFilter = filters.takeFirst();
if(bSuccess)
{
connect(poFilter, SIGNAL(statusUpdated(int)), this, SLOT(handleUpdate(int)), Qt::DirectConnection);
connect(poFilter, SIGNAL(messageLogged(QString)), this, SLOT(handleMessage(QString)), Qt::DirectConnection);
m_currentStep = FilteringStep;
bSuccess = poFilter->apply(sourceFile, tempFile, &m_aborted);
if(bSuccess)
{
sourceFile = tempFile;
handleMessage("\n-------------------------------\n");
}
}
delete poFilter;
}
//Encode audio file
if(bSuccess)
{
@ -171,6 +205,9 @@ void ProcessThread::handleUpdate(int progress)
case EncodingStep:
emit processStateChanged(m_jobId, QString("Encoding (%1%)").arg(QString::number(progress)), ProgressModel::JobRunning);
break;
case FilteringStep:
emit processStateChanged(m_jobId, QString("Filtering (%1%)").arg(QString::number(progress)), ProgressModel::JobRunning);
break;
case DecodingStep:
emit processStateChanged(m_jobId, QString("Decoding (%1%)").arg(QString::number(progress)), ProgressModel::JobRunning);
break;