Update Lame encoder to v3.99 Alpha-10 + implement simple MP3 encoding

This commit is contained in:
LoRd_MuldeR 2010-11-15 21:07:58 +01:00
parent c543451f67
commit e76fcafb8d
7 changed files with 124 additions and 10 deletions

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 21
#define VER_LAMEXP_BUILD 26
#define VER_LAMEXP_SUFFIX TechPreview
/*

View File

@ -49,8 +49,8 @@
#include <QSysInfo>
#include <QDragEnterEvent>
#include <QWindowsMime>
#include <QResource>
#include <QTextStream>
#include <QProcess>
#include <QRegExp>
//Win32 includes
#include <Windows.h>
@ -440,13 +440,122 @@ void MainWindow::aboutButtonClicked(void)
LAMEXP_DELETE(aboutBox);
}
#define IF_UNICODE(STR) if(_stricmp(STR.toUtf8().constData(),QString::fromLocal8Bit(STR.toLocal8Bit()).toUtf8().constData()))
/*
* Encode button
*/
void MainWindow::encodeButtonClicked(void)
{
ABORT_IF_BUSY;
QMessageBox::warning(this, "LameXP", "Not implemented yet, please try again with a later version!");
if(m_settings->compressionEncoder() != SettingsModel::MP3Encoder)
{
QMessageBox::warning(this, "LameXP", "Sorry, only Lame MP3 is supported at the moment!");
tabWidget->setCurrentIndex(3);
return;
}
QProcess process;
process.setProcessChannelMode(QProcess::MergedChannels);
process.setReadChannel(QProcess::StandardOutput);
m_banner->show("Encoding files, please wait...");
for(int i = 0; i < m_fileListModel->rowCount(); i++)
{
AudioFileModel file = m_fileListModel->getFile(m_fileListModel->index(i,0));
QString outFolder = m_fileSystemModel->filePath(this->outputFolderView->currentIndex());
QString baseName = QFileInfo(file.filePath()).fileName();
int pos = baseName.lastIndexOf(".");
if(pos >= 1) baseName = baseName.left(pos);
QStringList args = QStringList() << "--nohist" << "-h";
switch(m_settings->compressionRCMode())
{
case SettingsModel::VBRMode:
args << "-V" << QString::number(9 - m_settings->compressionBitrate());
break;
case SettingsModel::ABRMode:
args << "--abr" << QString::number(SettingsModel::mp3Bitrates[m_settings->compressionBitrate()]);
break;
case SettingsModel::CBRMode:
args << "--cbr";
args << "-b" << QString::number(SettingsModel::mp3Bitrates[m_settings->compressionBitrate()]);
break;
}
int n = 1;
QString outFileName = QString(outFolder).append("/").append(baseName).append(".mp3");
while(QFileInfo(outFileName).exists())
{
outFileName = QString(outFolder).append("/").append(baseName).append(" (").append(QString::number(++n)).append(").mp3");
}
IF_UNICODE(file.fileName())
{
args << "--uTitle" << file.fileName();
}
else
{
args << "--lTitle" << file.fileName();
}
args << QDir::toNativeSeparators(file.filePath());
args << QDir::toNativeSeparators(outFileName);
m_banner->setText(QString("Encoding: %1").arg(QFileInfo(file.filePath()).fileName()));
process.start(lamexp_lookup_tool("lame.exe"), args);
if(!process.waitForStarted())
{
QMessageBox::warning(this, "LAME", "Failed to create process!");
m_banner->close();
return;
}
QRegExp regExp("\\(.*(\\d+)%\\)\\|");
while(process.state() != QProcess::NotRunning)
{
process.waitForReadyRead();
QByteArray line = process.readLine();
if(line.isEmpty())
{
break;
}
while(line.size() > 0)
{
qDebug("%s", line.constData());
QString text = QString::fromLocal8Bit(line.constData()).simplified();
if(regExp.lastIndexIn(line) >= 0)
{
m_banner->setText(QString("Encoding: %1 (%2%)").arg(QFileInfo(file.filePath()).fileName(),regExp.cap(1)));
}
line = process.readLine();
QApplication::processEvents();
}
}
process.waitForFinished();
if(process.state() != QProcess::NotRunning)
{
process.kill();
process.waitForFinished(-1);
}
if(process.exitStatus() != QProcess::NormalExit)
{
QMessageBox::critical(this, "Error", QString("Ahrg, encoding has failed with error code %1.").arg(QString::number(process.exitCode())));
}
}
m_banner->close();
QMessageBox::information(this, "Done", "Encoding process completed.");
}
/*
@ -882,8 +991,8 @@ void MainWindow::updateRCMode(int id)
sliderBitrate->setMaximum(9);
break;
default:
sliderBitrate->setMinimum(2);
sliderBitrate->setMaximum(20);
sliderBitrate->setMinimum(0);
sliderBitrate->setMaximum(13);
break;
}
break;
@ -967,7 +1076,7 @@ void MainWindow::updateBitrate(int value)
switch(m_settings->compressionEncoder())
{
case SettingsModel::MP3Encoder:
labelBitrate->setText(QString("&asymp; %1 kbps").arg(value * 16));
labelBitrate->setText(QString("&asymp; %1 kbps").arg(SettingsModel::mp3Bitrates[value]));
break;
case SettingsModel::FLACEncoder:
labelBitrate->setText(QString("Compression %1").arg(value));
@ -984,7 +1093,7 @@ void MainWindow::updateBitrate(int value)
switch(m_settings->compressionEncoder())
{
case SettingsModel::MP3Encoder:
labelBitrate->setText(QString("%1 kbps").arg(value * 16));
labelBitrate->setText(QString("%1 kbps").arg(SettingsModel::mp3Bitrates[value]));
break;
case SettingsModel::FLACEncoder:
labelBitrate->setText(QString("Compression %1").arg(value));

View File

@ -90,7 +90,7 @@ SIZE_T lamexp_dbg_private_bytes(void);
#define LAMEXP_BOOL(X) (X ? "1" : "0")
//Check for debug build
#if defined(_DEBUG) || defined(QT_DEBUG) || !defined(NDEBUG) || !defined(QT_NODEBUG)
#if defined(_DEBUG) || defined(QT_DEBUG) || !defined(NDEBUG) || !defined(QT_NO_DEBUG)
#define LAMEXP_DEBUG 1
#define LAMEXP_CHECK_DEBUG_BUILD \
qWarning("---------------------------------------------------------"); \

View File

@ -37,6 +37,8 @@ static const char *g_settingsId_compressionBitrate = "Compression/Bitrate";
#define MAKE_GETTER(OPT,DEF) int SettingsModel::OPT(void) { return m_settings->value(g_settingsId_##OPT, DEF).toInt(); }
#define MAKE_SETTER(OPT) void SettingsModel::OPT(int value) { m_settings->setValue(g_settingsId_##OPT, value); }
const int SettingsModel::mp3Bitrates[15] = {32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, -1};
////////////////////////////////////////////////////////////
// Constructor
////////////////////////////////////////////////////////////

View File

@ -48,6 +48,9 @@ public:
CBRMode = 2
};
//Consts
static const int mp3Bitrates[15];
//Getters
MAKE_GETTER_DEC(licenseAccepted);
MAKE_GETTER_DEC(interfaceStyle);

View File

@ -44,7 +44,7 @@ static const struct lamexp_tool_t g_lamexp_tools[] =
{"09e5a07555a24b8c9d6af880b81eb8ed75be16fd", "faad.exe"},
{"070bf98f78e572a97e4703ef5720c682567a6a56", "flac.exe"},
{"cf379081035ae6bfb6f7bc22f13bfb7ac6302ac5", "gpgv.exe"},
{"e613a1b56a2187edb4cdf3628a5a3e60de2e8cbc", "lame.exe"},
{"143fc001a2f6c56fe1b9e6f8a2eb2b53b9e1e504", "lame.exe"},
{"775b260b3f64101beaeb317b74746f9bccdab842", "MAC.exe"},
{"e770eaa5f2449d0fd6b3f3c02a1f574fc4370b5e", "mediainfo_icl11.exe"},
{"55c293a80475f7aeccf449ac9487a4626e5139cb", "mpcdec.exe"},