FLAC decoding support.
This commit is contained in:
parent
2e97f2474c
commit
6644b38816
@ -298,6 +298,10 @@
|
||||
RelativePath=".\src\Decoder_Abstract.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\Decoder_FLAC.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\Decoder_MP3.cpp"
|
||||
>
|
||||
@ -482,6 +486,10 @@
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\Decoder_FLAC.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\Decoder_MP3.h"
|
||||
>
|
||||
@ -843,7 +851,7 @@
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description="MOC "$(SolutionDir)tmp\MOC_$(SafeInputName).cpp""
|
||||
CommandLine=""$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\MOC_$(SafeInputName).cpp" "$(InputPath)""
|
||||
CommandLine=""$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\MOC_$(SafeInputName).cpp" "$(InputPath)"
"
|
||||
Outputs=""$(SolutionDir)tmp\MOC_$(SafeInputName).cpp""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
@ -853,7 +861,7 @@
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description="MOC "$(SolutionDir)tmp\MOC_$(SafeInputName).cpp""
|
||||
CommandLine=""$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\MOC_$(SafeInputName).cpp" "$(InputPath)""
|
||||
CommandLine=""$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\MOC_$(SafeInputName).cpp" "$(InputPath)"
"
|
||||
Outputs=""$(SolutionDir)tmp\MOC_$(SafeInputName).cpp""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
@ -863,7 +871,7 @@
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
Description="MOC "$(SolutionDir)tmp\MOC_$(SafeInputName).cpp""
|
||||
CommandLine=""$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\MOC_$(SafeInputName).cpp" "$(InputPath)""
|
||||
CommandLine=""$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\MOC_$(SafeInputName).cpp" "$(InputPath)"
"
|
||||
Outputs=""$(SolutionDir)tmp\MOC_$(SafeInputName).cpp""
|
||||
/>
|
||||
</FileConfiguration>
|
||||
|
@ -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 155
|
||||
#define VER_LAMEXP_BUILD 156
|
||||
#define VER_LAMEXP_SUFFIX TechPreview
|
||||
|
||||
/*
|
||||
|
127
src/Decoder_FLAC.cpp
Normal file
127
src/Decoder_FLAC.cpp
Normal file
@ -0,0 +1,127 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// 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_FLAC.h"
|
||||
|
||||
#include "Global.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QProcess>
|
||||
#include <QRegExp>
|
||||
|
||||
FLACDecoder::FLACDecoder(void)
|
||||
:
|
||||
m_binary(lamexp_lookup_tool("flac.exe"))
|
||||
{
|
||||
if(m_binary.isEmpty())
|
||||
{
|
||||
throw "Error initializing Vorbis decoder. Tool 'flac.exe' is not registred!";
|
||||
}
|
||||
}
|
||||
|
||||
FLACDecoder::~FLACDecoder(void)
|
||||
{
|
||||
}
|
||||
|
||||
bool FLACDecoder::decode(const QString &sourceFile, const QString &outputFile, volatile bool *abortFlag)
|
||||
{
|
||||
QProcess process;
|
||||
QStringList args;
|
||||
|
||||
args << "-d" << "-F" << "-f";
|
||||
args << "-o" << QDir::toNativeSeparators(outputFile);
|
||||
args << QDir::toNativeSeparators(sourceFile);
|
||||
|
||||
if(!startProcess(process, m_binary, args))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool bTimeout = false;
|
||||
bool bAborted = false;
|
||||
|
||||
QRegExp regExp("\\s(\\d+)% complete");
|
||||
|
||||
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("FLAC 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 FLACDecoder::isFormatSupported(const QString &containerType, const QString &containerProfile, const QString &formatType, const QString &formatProfile, const QString &formatVersion)
|
||||
{
|
||||
if(containerType.compare("FLAC", Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
if(formatType.compare("FLAC", Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
37
src/Decoder_FLAC.h
Normal file
37
src/Decoder_FLAC.h
Normal 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 "Decoder_Abstract.h"
|
||||
|
||||
class FLACDecoder : public AbstractDecoder
|
||||
{
|
||||
public:
|
||||
FLACDecoder(void);
|
||||
~FLACDecoder(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);
|
||||
|
||||
private:
|
||||
const QString m_binary;
|
||||
};
|
@ -225,9 +225,13 @@ void AboutDialog::showMoreAbout(void)
|
||||
moreAboutText += "<br>";
|
||||
moreAboutText += "<li><b>Nero AAC reference MPEG-4 Encoder</b><br>";
|
||||
moreAboutText += "Freeware state-of-the-art HE-AAC encoder with 2-Pass support.<br>";
|
||||
moreAboutText += "(Available from vendor web-site as free download)<br>";
|
||||
moreAboutText += "<i>Available from vendor web-site as free download:</i><br>";
|
||||
moreAboutText += LINK(neroAacUrl);
|
||||
moreAboutText += "<br>";
|
||||
moreAboutText += "<li><b>FLAC - Free Lossless Audio Codec</b>";
|
||||
moreAboutText += "<br>Open and patent-free lossless audio compression.<br>";
|
||||
moreAboutText += LINK("http://flac.sourceforge.net/");
|
||||
moreAboutText += "<br>";
|
||||
moreAboutText += "<li><b>MediaInfo - Media File Analysis Tool</b><br>";
|
||||
moreAboutText += "Released under the terms of the GNU Leser General Public License.<br>";
|
||||
moreAboutText += LINK("http://mediainfo.sourceforge.net/");
|
||||
|
@ -831,14 +831,15 @@ QString lamexp_known_folder(lamexp_known_folder_t folder_id)
|
||||
static const GUID GUID_LOCAL_APPDATA_LOW = {0xA520A1A4,0x1780,0x4FF6,{0xBD,0x18,0x16,0x73,0x43,0xC5,0xAF,0x16}};
|
||||
static const GUID GUID_PROGRAM_FILES = {0x905e63b6,0xc1bf,0x494e,{0xb2,0x9c,0x65,0xb7,0x32,0xd3,0xd2,0x1a}};
|
||||
|
||||
static QLibrary *Kernel32Lib = NULL;
|
||||
static SHGetKnownFolderPathFun SHGetKnownFolderPathPtr = NULL;
|
||||
static SHGetFolderPathFun SHGetFolderPathPtr = NULL;
|
||||
|
||||
if((!SHGetKnownFolderPathPtr) && (!SHGetFolderPathPtr))
|
||||
{
|
||||
QLibrary Kernel32Lib("shell32.dll");
|
||||
SHGetKnownFolderPathPtr = (SHGetKnownFolderPathFun) Kernel32Lib.resolve("SHGetKnownFolderPath");
|
||||
SHGetFolderPathPtr = (SHGetFolderPathFun) Kernel32Lib.resolve("SHGetFolderPathW");
|
||||
if(!Kernel32Lib) Kernel32Lib = new QLibrary("shell32.dll");
|
||||
SHGetKnownFolderPathPtr = (SHGetKnownFolderPathFun) Kernel32Lib->resolve("SHGetKnownFolderPath");
|
||||
SHGetFolderPathPtr = (SHGetFolderPathFun) Kernel32Lib->resolve("SHGetFolderPathW");
|
||||
}
|
||||
|
||||
int folderCSIDL = -1;
|
||||
@ -866,7 +867,7 @@ QString lamexp_known_folder(lamexp_known_folder_t folder_id)
|
||||
WCHAR *path = NULL;
|
||||
if(SHGetKnownFolderPathPtr(folderGUID, 0x00008000, NULL, &path) == S_OK)
|
||||
{
|
||||
MessageBoxW(0, path, L"SHGetKnownFolderPathPtr", MB_TOPMOST);
|
||||
//MessageBoxW(0, path, L"SHGetKnownFolderPath", MB_TOPMOST);
|
||||
QDir folderTemp = QDir(QDir::fromNativeSeparators(QString::fromUtf16(reinterpret_cast<const unsigned short*>(path))));
|
||||
if(!folderTemp.exists())
|
||||
{
|
||||
@ -884,7 +885,7 @@ QString lamexp_known_folder(lamexp_known_folder_t folder_id)
|
||||
WCHAR *path = new WCHAR[4096];
|
||||
if(SHGetFolderPathPtr(NULL, folderCSIDL, NULL, NULL, path) == S_OK)
|
||||
{
|
||||
MessageBoxW(0, path, L"SHGetFolderPathPtr", MB_TOPMOST);
|
||||
//MessageBoxW(0, path, L"SHGetFolderPathW", MB_TOPMOST);
|
||||
QDir folderTemp = QDir(QDir::fromNativeSeparators(QString::fromUtf16(reinterpret_cast<const unsigned short*>(path))));
|
||||
if(!folderTemp.exists())
|
||||
{
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "Decoder_AAC.h"
|
||||
#include "Decoder_MP3.h"
|
||||
#include "Decoder_Vorbis.h"
|
||||
#include "Decoder_FLAC.h"
|
||||
#include "Decoder_WMA.h"
|
||||
|
||||
#include <QString>
|
||||
@ -35,6 +36,7 @@ AbstractDecoder *DecoderRegistry::lookup(const QString &containerType, const QSt
|
||||
PROBE_DECODER(MP3Decoder);
|
||||
PROBE_DECODER(VorbisDecoder);
|
||||
PROBE_DECODER(AACDecoder);
|
||||
PROBE_DECODER(FLACDecoder);
|
||||
PROBE_DECODER(WMADecoder);
|
||||
return NULL;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user