Added support for Monkey's Audio input.

This commit is contained in:
LoRd_MuldeR 2011-01-16 22:00:49 +01:00
parent cad43988b8
commit beb93e7eaa
9 changed files with 195 additions and 8 deletions

View File

@ -310,6 +310,10 @@
RelativePath=".\src\Decoder_FLAC.cpp"
>
</File>
<File
RelativePath=".\src\Decoder_MAC.cpp"
>
</File>
<File
RelativePath=".\src\Decoder_MP3.cpp"
>
@ -526,6 +530,10 @@
RelativePath=".\src\Decoder_FLAC.h"
>
</File>
<File
RelativePath=".\src\Decoder_MAC.h"
>
</File>
<File
RelativePath=".\src\Decoder_MP3.h"
>
@ -1111,7 +1119,7 @@
<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;"
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>
@ -1121,7 +1129,7 @@
<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;"
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>
@ -1131,7 +1139,7 @@
<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;"
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>

View File

@ -8,7 +8,7 @@
<file>tools/gpgv.exe</file>
<file>tools/gpgv.gpg</file>
<file>tools/lame.exe</file>
<file>tools/MAC.exe</file>
<file>tools/mac.exe</file>
<file>tools/mediainfo_i386.exe</file>
<file>tools/mediainfo_x64.exe</file>
<file>tools/mpcdec.exe</file>

BIN
res/tools/mac.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 235
#define VER_LAMEXP_BUILD 236
#define VER_LAMEXP_SUFFIX TechPreview
/*

131
src/Decoder_MAC.cpp Normal file
View File

@ -0,0 +1,131 @@
///////////////////////////////////////////////////////////////////////////////
// LameXP - Audio Encoder Front-End
// Copyright (C) 2004-2011 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_MAC.h"
#include "Global.h"
#include <QDir>
#include <QProcess>
#include <QRegExp>
MACDecoder::MACDecoder(void)
:
m_binary(lamexp_lookup_tool("mac.exe"))
{
if(m_binary.isEmpty())
{
throw "Error initializing MAC decoder. Tool 'mac.exe' is not registred!";
}
}
MACDecoder::~MACDecoder(void)
{
}
bool MACDecoder::decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag)
{
QProcess process;
QStringList args;
args << QDir::toNativeSeparators(sourceFile);
args << QDir::toNativeSeparators(outputFile);
args << "-d";
if(!startProcess(process, m_binary, args))
{
return false;
}
bool bTimeout = false;
bool bAborted = false;
QRegExp regExp("Progress: (\\d+)%");
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("MAC process timed out <-- killing!");
bTimeout = true;
break;
}
while(process.bytesAvailable() > 0)
{
QByteArray line = process.readLine();
QString text = QString::fromUtf8(line.constData()).simplified();
if(regExp.lastIndexIn(text) >= 0)
{
bool ok = false;
int progress = regExp.cap(1).toInt(&ok);
if(ok) emit statusUpdated(progress);
}
else 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;
}
bool MACDecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
{
if(containerType.compare("Monkey's Audio", Qt::CaseInsensitive) == 0)
{
if(formatType.compare("Monkey's Audio", Qt::CaseInsensitive) == 0)
{
return true;
}
}
return false;
}
QStringList MACDecoder::supportedTypes(void)
{
return QStringList() << "Monkey's Audio (*.ape)";
}

38
src/Decoder_MAC.h Normal file
View File

@ -0,0 +1,38 @@
///////////////////////////////////////////////////////////////////////////////
// LameXP - Audio Encoder Front-End
// Copyright (C) 2004-2011 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 MACDecoder : public AbstractDecoder
{
public:
MACDecoder(void);
~MACDecoder(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);
static QStringList supportedTypes(void);
private:
const QString m_binary;
};

View File

@ -282,6 +282,13 @@ void AboutDialog::showMoreAbout(void)
"http://www.ac3filter.net/projects/tools"
);
moreAboutText += makeToolText
(
tr("Monkey's Audio - Lossless Audio Compressor"),
"mac.exe", "v?.??",
tr("Freely available source code, simple SDK and non-restrictive licensing."),
"http://www.monkeysaudio.com/"
);
moreAboutText += makeToolText
(
tr("MediaInfo - Media File Analysis Tool"),
"mediainfo_i386.exe", "v?.?.??",

View File

@ -23,6 +23,7 @@
#include "Decoder_AAC.h"
#include "Decoder_ADPCM.h"
#include "Decoder_MAC.h"
#include "Decoder_MP3.h"
#include "Decoder_Vorbis.h"
#include "Decoder_FLAC.h"
@ -44,6 +45,7 @@ AbstractDecoder *DecoderRegistry::lookup(const QString &containerType, const QSt
PROBE_DECODER(AACDecoder);
PROBE_DECODER(AC3Decoder);
PROBE_DECODER(FLACDecoder);
PROBE_DECODER(MACDecoder);
PROBE_DECODER(WMADecoder);
PROBE_DECODER(ADPCMDecoder);
PROBE_DECODER(WaveDecoder);
@ -60,6 +62,7 @@ QStringList DecoderRegistry::getSupportedTypes(void)
types << GET_FILETYPES(AACDecoder);
types << GET_FILETYPES(AC3Decoder);
types << GET_FILETYPES(FLACDecoder);
types << GET_FILETYPES(MACDecoder);
types << GET_FILETYPES(WMADecoder);
types << GET_FILETYPES(ADPCMDecoder);

View File

@ -54,7 +54,7 @@ static const struct lamexp_tool_t g_lamexp_tools[] =
{"cf379081035ae6bfb6f7bc22f13bfb7ac6302ac5", "gpgv.exe", 1410},
{"d837bf6ee4dab557d8b02d46c75a24e58980fffa", "gpgv.gpg", UINT_MAX},
{"143fc001a2f6c56fe1b9e6f8a2eb2b53b9e1e504", "lame.exe", 39910},
{"775b260b3f64101beaeb317b74746f9bccdab842", "MAC.exe", UINT_MAX},
{"a4e929cfaa42fa2e61a3d0c6434c77a06d45aef3", "mac.exe", 406},
{"61d584ffaf428e9afb0ed9bd32706a954af492b0", "mediainfo_i386.exe", 739},
{"81fb728cbc6057906fa1b637738e6aefe5dccf54", "mediainfo_x64.exe", 739},
{"55c293a80475f7aeccf449ac9487a4626e5139cb", "mpcdec.exe", UINT_MAX},
@ -125,8 +125,8 @@ void InitializationThread::run()
{
try
{
qDebug("Extracting file: %s", g_lamexp_tools[i].pcName);
QString toolName = toolsList.at(i).fileName();
QString toolName = toolsList.at(i).fileName().toLower();
qDebug("Extracting file: %s", toolName.toLatin1().constData());
QByteArray toolHash = checksum.take(toolName).toLatin1();
unsigned int toolVersion = version.take(toolName);
if(toolHash.size() != 40)