Added support for Microsoft ADPCM, Apple/SGI AIFF and Sun/NeXT Au files.

This commit is contained in:
LoRd_MuldeR 2011-01-09 22:36:52 +01:00
parent bb09b5da7c
commit 15df253e52
7 changed files with 193 additions and 2 deletions

View File

@ -302,6 +302,10 @@
RelativePath=".\src\Decoder_AC3.cpp"
>
</File>
<File
RelativePath=".\src\Decoder_ADPCM.cpp"
>
</File>
<File
RelativePath=".\src\Decoder_FLAC.cpp"
>
@ -514,6 +518,10 @@
RelativePath=".\src\Decoder_AC3.h"
>
</File>
<File
RelativePath=".\src\Decoder_ADPCM.h"
>
</File>
<File
RelativePath=".\src\Decoder_FLAC.h"
>

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 224
#define VER_LAMEXP_BUILD 226
#define VER_LAMEXP_SUFFIX TechPreview
/*

142
src/Decoder_ADPCM.cpp Normal file
View File

@ -0,0 +1,142 @@
///////////////////////////////////////////////////////////////////////////////
// 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_ADPCM.h"
#include "Global.h"
#include <QDir>
#include <QProcess>
#include <QRegExp>
ADPCMDecoder::ADPCMDecoder(void)
:
m_binary(lamexp_lookup_tool("sox.exe"))
{
if(m_binary.isEmpty())
{
throw "Error initializing Vorbis decoder. Tool 'sox.exe' is not registred!";
}
}
ADPCMDecoder::~ADPCMDecoder(void)
{
}
bool ADPCMDecoder::decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag)
{
QProcess process;
QStringList args;
process.setWorkingDirectory(lamexp_temp_folder());
args << "-V3" << "-S" << "--temp" << ".";
args << QDir::toNativeSeparators(sourceFile);
args << "-e" << "signed-integer";
args << QDir::toNativeSeparators(outputFile);
if(!startProcess(process, m_binary, args))
{
return false;
}
bool bTimeout = false;
bool bAborted = false;
QRegExp regExp("In:(\\d+)(\\.\\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("Sox 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 ADPCMDecoder::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("ADPCM", Qt::CaseInsensitive) == 0)
{
return true;
}
}
if(containerType.compare("AIFF", Qt::CaseInsensitive) == 0 || containerType.compare("AU", Qt::CaseInsensitive) == 0)
{
if(formatType.compare("PCM", Qt::CaseInsensitive) == 0 || formatType.compare("ADPCM", Qt::CaseInsensitive) == 0)
{
return true;
}
}
return false;
}
QStringList ADPCMDecoder::supportedTypes(void)
{
return QStringList() << "Microsoft ADPCM (*.wav)" << "Apple/SGI AIFF (*.aif *.aiff)" << "Sun/NeXT Au (*.au *.snd)";
}

38
src/Decoder_ADPCM.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 ADPCMDecoder : public AbstractDecoder
{
public:
ADPCMDecoder(void);
~ADPCMDecoder(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

@ -22,6 +22,7 @@
#include "Registry_Decoder.h"
#include "Decoder_AAC.h"
#include "Decoder_ADPCM.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(AC3Decoder);
PROBE_DECODER(FLACDecoder);
PROBE_DECODER(WMADecoder);
PROBE_DECODER(ADPCMDecoder);
PROBE_DECODER(WaveDecoder);
return NULL;
}
@ -59,6 +61,7 @@ QStringList DecoderRegistry::getSupportedTypes(void)
types << GET_FILETYPES(AC3Decoder);
types << GET_FILETYPES(FLACDecoder);
types << GET_FILETYPES(WMADecoder);
types << GET_FILETYPES(ADPCMDecoder);
QStringList extensions;
QRegExp regExp("\\((.+)\\)", Qt::CaseInsensitive);

View File

@ -65,7 +65,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},
{"1a1fa403094736bffcbbc30aa59b10f43e81ceed", "sox.exe", 1431},
{"2d08c3586f9cf99f2e4c89ac54eeb595f63aef61", "sox.exe", 1431},
{"346ce516281c97e92e1b8957ddeca52edcf2d056", "speexdec.exe", UINT_MAX},
{"8a74b767cfe88bf88c068fdae0de02d65589d25e", "takc.exe", UINT_MAX},
{"1c5cedb56358a0e8c4590a863a97c94d7d7e98b2", "ttaenc.exe", UINT_MAX},