diff --git a/LameXP_VS2010.vcxproj b/LameXP_VS2010.vcxproj index ab96eeba..02e56db3 100644 --- a/LameXP_VS2010.vcxproj +++ b/LameXP_VS2010.vcxproj @@ -131,11 +131,13 @@ copy "$(QTDIR)\plugins\imageformats\q????d4.dll" "$(TargetDir)imageformats\" Fast NotUsing Level3 - - false true false + + + true + false "/MANIFESTDEPENDENCY:type=%27win32%27 name=%27Microsoft.Windows.Common-Controls%27 version=%276.0.0.0%27 publicKeyToken=%276595b64144ccf1df%27 language=%27*%27 processorArchitecture=%27*%27" %(AdditionalOptions) @@ -157,6 +159,11 @@ copy "$(QTDIR)\plugins\imageformats\q????d4.dll" "$(TargetDir)imageformats\" MachineX86 5.0 lamexp_crt_startup + + + true + + Copy plugin DLL%27s @@ -196,11 +203,12 @@ del "$(TargetDir)imageformats\q???d4.dll" Fast NotUsing Level3 - - + ProgramDatabase false true false + false + true "/MANIFESTDEPENDENCY:type=%27win32%27 name=%27Microsoft.Windows.Common-Controls%27 version=%276.0.0.0%27 publicKeyToken=%276595b64144ccf1df%27 language=%27*%27 processorArchitecture=%27*%27" %(AdditionalOptions) @@ -208,10 +216,10 @@ del "$(TargetDir)imageformats\q???d4.dll" LinkVerboseLib $(SolutionDir)\etc\Prerequisites\qt4_static\lib;$(SolutionDir)\etc\Prerequisites\qt4_static\plugins\imageformats;$(SolutionDir)\etc\Prerequisites\EncodePointer\lib;%(AdditionalLibraryDirectories) %(IgnoreSpecificDefaultLibraries) - false + true - false + true Windows true true @@ -220,6 +228,10 @@ del "$(TargetDir)imageformats\q???d4.dll" MachineX86 5.0 lamexp_crt_startup + true + + + true @@ -258,6 +270,7 @@ del "$(TargetDir)imageformats\q???d4.dll" + @@ -305,6 +318,7 @@ del "$(TargetDir)imageformats\q???d4.dll" + @@ -382,6 +396,17 @@ del "$(TargetDir)imageformats\q???d4.dll" $(SolutionDir)tmp\MOC_%(Filename).cpp;%(Outputs) + + "$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\MOC_%(Filename).cpp" "%(FullPath)" + "$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\MOC_%(Filename).cpp" "%(FullPath)" + "$(QTDIR)\bin\moc.exe" -o "$(SolutionDir)tmp\MOC_%(Filename).cpp" "%(FullPath)" + MOC "$(SolutionDir)tmp\MOC_%(Filename).cpp" + MOC "$(SolutionDir)tmp\MOC_%(Filename).cpp" + MOC "$(SolutionDir)tmp\MOC_%(Filename).cpp" + $(SolutionDir)tmp\MOC_%(Filename).cpp;%(Outputs) + $(SolutionDir)tmp\MOC_%(Filename).cpp;%(Outputs) + $(SolutionDir)tmp\MOC_%(Filename).cpp;%(Outputs) + diff --git a/LameXP_VS2010.vcxproj.filters b/LameXP_VS2010.vcxproj.filters index 17533262..35009bbc 100644 --- a/LameXP_VS2010.vcxproj.filters +++ b/LameXP_VS2010.vcxproj.filters @@ -310,6 +310,12 @@ Source Files\Decoders + + Source Files\Encoders + + + Generated Files\MOC + @@ -584,6 +590,9 @@ Header Files\Threads + + Header Files\Encoders + diff --git a/etc/Translation/Blank.ts b/etc/Translation/Blank.ts index 7cc57589..f3115f00 100644 --- a/etc/Translation/Blank.ts +++ b/etc/Translation/Blank.ts @@ -704,7 +704,7 @@ - + Show Details @@ -1331,9 +1331,9 @@ - - - + + + Check for Updates @@ -1374,13 +1374,13 @@ - + Disable Update Reminder - + Disable Sound Effects @@ -1455,671 +1455,671 @@ - + Adding file(s), please wait... - - + + Access Denied - + %1 file(s) have been rejected, because read access was not granted! - + This usually means the file is locked by another process. - + CDDA Files - + %1 file(s) have been rejected, because they are dummy CDDA files! - + Sorry, LameXP cannot extract audio tracks from an Audio&minus;CD at present. - + We recommend using %1 for that purpose. - + Cue Sheet - + %1 file(s) have been rejected, because they appear to be Cue Sheet images! - + Please use LameXP's Cue Sheet wizard for importing Cue Sheet files. - + Files Rejected - + %1 file(s) have been rejected, because the file format could not be recognized! - + This usually means the file is damaged or the file format is not supported. - + Scanning folder(s) for files, please wait... - + DEMO VERSION - + You can drop in audio files here! - + Open File in External Application - + Browse File Location - + Browse Selected Folder - + Bookmark Current Output Folder - + License Declined - + You have declined the license. Consequently the application will exit now! - + Goodbye! - + LameXP - Expired - + This demo (pre-release) version of LameXP has expired at %1. - + LameXP is free software and release versions won't expire. - - + + Exit Program - + It seems that a bogus anti-virus software is slowing down the startup of LameXP. - + Please refer to the %1 document for details and solutions! - + Slow Startup - - - - + + + + Discard - - + + Don't Show Again - + Urgent Update - + Your version of LameXP is more than a year old. Time for an update! - - - + + + Update Reminder - + Your last update check was more than 14 days ago. Check for updates now? - + Your did not check for LameXP updates yet. Check for updates now? - + Postpone - + LameXP detected that your version of the Nero AAC encoder is outdated! - + The current version available is %1 (or later), but you still have version %2 installed. - + n/a - + You can download the latest version of the Nero AAC encoder from the Nero website at: - + AAC Encoder Outdated - + The Nero AAC encoder could not be found. AAC encoding support will be disabled. - + Please put 'neroAacEnc.exe', 'neroAacDec.exe' and 'neroAacTag.exe' into the LameXP directory! - + Your LameXP directory is located here: - + You can download the Nero AAC encoder for free from the official Nero website at: - + AAC Support Disabled - - - + + + LameXP - + You must add at least one file to the list before proceeding! - + Not Found - + Your currently selected TEMP folder does not exist anymore: - + Restore Default - + Cancel - + Low Diskspace Warning - + There are less than %1 GB of free diskspace available on your system's TEMP folder. - + It is highly recommend to free up more diskspace before proceeding with the encode! - + Your TEMP folder is located at: - + Abort Encoding Process - + Clean Disk Now - + Ignore - + Low Diskspace - + You are proceeding with low diskspace. Problems might occur! - + Sorry, an unsupported encoder has been chosen! - + Cannot write to the selected output directory. - + Please choose a different directory! - + Load Translation - + Translation Files - + Do you really want to disable the update reminder? - - - - - - + + + + + + Yes - - - - - - + + + + + + No - + The update reminder has been disabled. - + Please remember to check for updates at regular intervals! - + The update reminder has been re-enabled. - + Do you really want to disable all sound effects? - - + + Sound Effects - + All sound effects have been disabled. - + The sound effects have been re-enabled. - - - + + + Nero AAC Notifications - + Do you really want to disable all Nero AAC Encoder notifications? - + All Nero AAC Encoder notifications have been disabled. - + The Nero AAC Encoder notifications have been re-enabled. - - - + + + Slow Startup Notifications - + Do you really want to disable the slow startup notifications? - + The slow startup notifications have been disabled. - + The slow startup notifications have been re-enabled. - + Open Cue Sheet - + Cue Sheet File - - - + + + Beta Updates - + Do you really want LameXP to check for Beta (pre-release) updates? - + LameXP will check for Beta (pre-release) updates from now on. - + Check Now - + LameXP will <i>not</i> check for Beta (pre-release) updates from now on. - - - + + + Shell Integration - + Do you really want to disable the LameXP shell integration? - + The LameXP shell integration has been disabled. - + The LameXP shell integration has been re-enabled. - - + + Add file(s) - - + + Add Folder - - + + New Folder - + Enter the name of the new folder: - + Failed to create folder - + The new folder could not be created: - + Drive is read-only or insufficient access rights! - - - - + + + + Quality Level %1 - - - + + + Compression %1 - - - + + + Uncompressed - + Best Quality (Very Slow) - + High Quality (Recommended) - + Average Quality (Default) - + Low Quality (Fast) - + Poor Quality (Very Fast) - + File name without extension - + Track number with leading zero - + Track title - + Artist name - + Album name - + Year with (at least) four digits - + Comment - + Characters forbidden in file names: - + Rename Macros - + %1 Instance(s) - + Cannot write to the selected directory. Please choose another directory! - + Already Running - + LameXP is already running, please use the running instance! @@ -2541,114 +2541,114 @@ - + Show details for selected job - + Browse Output File Location - + Encoding Files - + Your files are being encoded, please be patient... - + Encoding files, please wait... - + Multi-threading enabled: Running %1 instances in parallel! - + Aborted! Waiting for running jobs to terminate... - + Encoding: %1 files of %2 completed so far, please wait... - + Creating the playlist file, please wait... - + Process was aborted by the user after %1 file(s)! - + Process was aborted prematurely by the user! - + LameXP - Aborted - + Process was aborted by the user. - + Error: %1 of %2 files failed. Double-click failed items for detailed information! - + LameXP - Error - + At least one file has failed! - + All files completed successfully. - + LameXP - Done - + Playlist creation failed - + The playlist file could not be created: - + Warning: Computer will shutdown in %1 seconds... - - + + Cancel Shutdown diff --git a/src/Config.h b/src/Config.h index 91219640..713aa80b 100644 --- a/src/Config.h +++ b/src/Config.h @@ -29,8 +29,8 @@ #define VER_LAMEXP_MINOR_HI 0 #define VER_LAMEXP_MINOR_LO 3 #define VER_LAMEXP_TYPE Alpha -#define VER_LAMEXP_PATCH 12 -#define VER_LAMEXP_BUILD 648 +#define VER_LAMEXP_PATCH 13 +#define VER_LAMEXP_BUILD 652 /////////////////////////////////////////////////////////////////////////////// // Tools versions diff --git a/src/Dialog_MainWindow.cpp b/src/Dialog_MainWindow.cpp index 4f56120e..9f52edb3 100644 --- a/src/Dialog_MainWindow.cpp +++ b/src/Dialog_MainWindow.cpp @@ -86,6 +86,7 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel *metaInfo, S m_metaData(metaInfo), m_settings(settingsModel), m_neroEncoderAvailable(lamexp_check_tool("neroAacEnc.exe") && lamexp_check_tool("neroAacDec.exe") && lamexp_check_tool("neroAacTag.exe")), + m_fhgEncoderAvailable(lamexp_check_tool("fhgaacenc.exe") && lamexp_check_tool("enc_fhgaac.dll") && lamexp_check_tool("nsutil.dll") && lamexp_check_tool("libmp4v2.dll")), m_accepted(false), m_firstTimeShown(true), m_OutputFolderViewInitialized(false) @@ -200,10 +201,10 @@ MainWindow::MainWindow(FileListModel *fileListModel, AudioFileModel *metaInfo, S m_modeButtonGroup->addButton(radioButtonModeQuality, SettingsModel::VBRMode); m_modeButtonGroup->addButton(radioButtonModeAverageBitrate, SettingsModel::ABRMode); m_modeButtonGroup->addButton(radioButtonConstBitrate, SettingsModel::CBRMode); - radioButtonEncoderAAC->setEnabled(m_neroEncoderAvailable); + radioButtonEncoderAAC->setEnabled(m_neroEncoderAvailable || m_fhgEncoderAvailable); radioButtonEncoderMP3->setChecked(m_settings->compressionEncoder() == SettingsModel::MP3Encoder); radioButtonEncoderVorbis->setChecked(m_settings->compressionEncoder() == SettingsModel::VorbisEncoder); - radioButtonEncoderAAC->setChecked((m_settings->compressionEncoder() == SettingsModel::AACEncoder) && m_neroEncoderAvailable); + radioButtonEncoderAAC->setChecked((m_settings->compressionEncoder() == SettingsModel::AACEncoder) && (m_neroEncoderAvailable || m_fhgEncoderAvailable)); radioButtonEncoderAC3->setChecked(m_settings->compressionEncoder() == SettingsModel::AC3Encoder); radioButtonEncoderFLAC->setChecked(m_settings->compressionEncoder() == SettingsModel::FLACEncoder); radioButtonEncoderPCM->setChecked(m_settings->compressionEncoder() == SettingsModel::PCMEncoder); @@ -988,7 +989,7 @@ void MainWindow::windowShown(void) } else { - if(m_settings->neroAacNotificationsEnabled()) + if(m_settings->neroAacNotificationsEnabled() && (!m_fhgEncoderAvailable)) { QString appPath = QDir(QCoreApplication::applicationDirPath()).canonicalPath(); if(appPath.isEmpty()) appPath = QCoreApplication::applicationDirPath(); @@ -1006,32 +1007,6 @@ void MainWindow::windowShown(void) } } } - - //Check for WMA support - //if(m_settings->wmaDecoderNotificationsEnabled()) - //{ - // if(!lamexp_check_tool("wmawav.exe")) - // { - // QString messageText; - // messageText += QString("%1
").arg(tr("LameXP has detected that the WMA File Decoder component is not currently installed on your system.").replace("-", "−")); - // messageText += QString("%1

").arg(tr("You won't be able to process WMA files as input unless the WMA File Decoder component is installed!").replace("-", "−")); - // messageText += QString("%1").arg(tr("Do you want to download and install the WMA File Decoder component now?").replace("-", "−")); - // int result = QMessageBox::information(this, tr("WMA Decoder Missing"), messageText, tr("Download && Install"), tr("Don't Show Again"), tr("Postpone")); - // if(result == 0) - // { - // if(installWMADecoder()) - // { - // QApplication::quit(); - // return; - // } - // } - // else if(result == 1) - // { - // m_settings->wmaDecoderNotificationsEnabled(false); - // actionDisableWmaDecoderNotifications->setChecked(!m_settings->wmaDecoderNotificationsEnabled()); - // } - // } - //} //Add files from the command-line for(int i = 0; i < arguments.count() - 1; i++) diff --git a/src/Dialog_MainWindow.h b/src/Dialog_MainWindow.h index 7c00a664..6d96b1be 100644 --- a/src/Dialog_MainWindow.h +++ b/src/Dialog_MainWindow.h @@ -154,6 +154,7 @@ private: bool m_OutputFolderViewInitialized; const bool m_neroEncoderAvailable; + const bool m_fhgEncoderAvailable; WorkingBanner *m_banner; QStringList *m_delayedFileList; diff --git a/src/Dialog_Processing.cpp b/src/Dialog_Processing.cpp index dd0c22a6..8cbf58d0 100644 --- a/src/Dialog_Processing.cpp +++ b/src/Dialog_Processing.cpp @@ -32,6 +32,7 @@ #include "Encoder_MP3.h" #include "Encoder_Vorbis.h" #include "Encoder_AAC.h" +#include "Encoder_AAC_FHG.h" #include "Encoder_AC3.h" #include "Encoder_FLAC.h" #include "Encoder_Wave.h" @@ -595,13 +596,24 @@ void ProcessingDialog::startNextJob(void) break; case SettingsModel::AACEncoder: { - AACEncoder *aacEncoder = new AACEncoder(); - aacEncoder->setBitrate(m_settings->compressionBitrate()); - aacEncoder->setRCMode(m_settings->compressionRCMode()); - aacEncoder->setEnable2Pass(m_settings->neroAACEnable2Pass()); - aacEncoder->setProfile(m_settings->neroAACProfile()); - aacEncoder->setCustomParams(m_settings->customParametersNeroAAC()); - encoder = aacEncoder; + if(lamexp_lookup_tool("fhgaacenc.exe").isEmpty() || lamexp_lookup_tool("enc_fhgaac.dll").isEmpty()) + { + AACEncoder *aacEncoder = new AACEncoder(); + aacEncoder->setBitrate(m_settings->compressionBitrate()); + aacEncoder->setRCMode(m_settings->compressionRCMode()); + aacEncoder->setEnable2Pass(m_settings->neroAACEnable2Pass()); + aacEncoder->setProfile(m_settings->neroAACProfile()); + aacEncoder->setCustomParams(m_settings->customParametersNeroAAC()); + encoder = aacEncoder; + } + else + { + FHGAACEncoder *aacEncoder = new FHGAACEncoder(); + aacEncoder->setBitrate(m_settings->compressionBitrate()); + aacEncoder->setRCMode(m_settings->compressionRCMode()); + aacEncoder->setProfile(m_settings->neroAACProfile()); + encoder = aacEncoder; + } } break; case SettingsModel::AC3Encoder: diff --git a/src/Encoder_AAC_FHG.cpp b/src/Encoder_AAC_FHG.cpp new file mode 100644 index 00000000..7869f9c5 --- /dev/null +++ b/src/Encoder_AAC_FHG.cpp @@ -0,0 +1,176 @@ +/////////////////////////////////////////////////////////////////////////////// +// LameXP - Audio Encoder Front-End +// Copyright (C) 2004-2011 LoRd_MuldeR +// +// 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 "Encoder_AAC_FHG.h" + +#include "Global.h" +#include "Model_Settings.h" + +#include +#include + +#define max(a,b) (((a) > (b)) ? (a) : (b)) +#define min(a,b) (((a) < (b)) ? (a) : (b)) + +FHGAACEncoder::FHGAACEncoder(void) +: + m_binary_enc(lamexp_lookup_tool("fhgaacenc.exe")), + m_binary_dll(lamexp_lookup_tool("enc_fhgaac.dll")) +{ + if(m_binary_enc.isEmpty() || m_binary_dll.isEmpty()) + { + throw "Error initializing FhgAacEnc. Tool 'fhgaacenc.exe' is not registred!"; + } + + m_configProfile = 0; +} + +FHGAACEncoder::~FHGAACEncoder(void) +{ +} + +bool FHGAACEncoder::encode(const QString &sourceFile, const AudioFileModel &metaInfo, const QString &outputFile, volatile bool *abortFlag) +{ + QProcess process; + QStringList args; + + switch(m_configRCMode) + { + case SettingsModel::VBRMode: + args << "--vbr" << QString::number(max(1, min(5, m_configBitrate))); + break; + case SettingsModel::CBRMode: + args << "--cbr" << QString::number(max(32, min(500, (m_configBitrate * 8)))); + break; + case SettingsModel::ABRMode: + qWarning("FhgAacEnc does not support ABR mode -> failure!"); + emit messageLogged("\nTHIS ENCODER DOES NOT SUPPORT AN \"ABR\" MODE !!!"); + return false; + break; + default: + throw "Bad rate-control mode!"; + break; + } + + switch(m_configProfile) + { + case 1: + args << "--profile" << "lc"; //Forces use of LC AAC profile + break; + case 2: + args << "--profile" << "he"; //Forces use of HE AAC profile + break; + case 3: + args << "--profile" << "hev2"; //Forces use of HEv2 AAC profile + break; + } + + args << "--dll" << m_binary_dll; + + args << QDir::toNativeSeparators(sourceFile); + args << QDir::toNativeSeparators(outputFile); + + if(!startProcess(process, m_binary_enc, args)) + { + return false; + } + + bool bTimeout = false; + bool bAborted = false; + + QRegExp regExp("Progress:\\s*(\\d+)%"); + + while(process.state() != QProcess::NotRunning) + { + if(*abortFlag) + { + process.kill(); + bAborted = true; + emit messageLogged("\nABORTED BY USER !!!"); + break; + } + process.waitForReadyRead(m_processTimeoutInterval); + if(!process.bytesAvailable() && process.state() == QProcess::Running) + { + process.kill(); + qWarning("FhgAacEnc process timed out <-- killing!"); + emit messageLogged("\nPROCESS TIMEOUT !!!"); + 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) + { + return false; + } + + return true; +} + +QString FHGAACEncoder::extension(void) +{ + return "mp4"; +} + +bool FHGAACEncoder::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; +} + + +void FHGAACEncoder::setProfile(int profile) +{ + m_configProfile = profile; +} diff --git a/src/Encoder_AAC_FHG.h b/src/Encoder_AAC_FHG.h new file mode 100644 index 00000000..db24281d --- /dev/null +++ b/src/Encoder_AAC_FHG.h @@ -0,0 +1,47 @@ +/////////////////////////////////////////////////////////////////////////////// +// LameXP - Audio Encoder Front-End +// Copyright (C) 2004-2011 LoRd_MuldeR +// +// 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 "Encoder_Abstract.h" + +#include + +class FHGAACEncoder : public AbstractEncoder +{ + Q_OBJECT + +public: + FHGAACEncoder(void); + ~FHGAACEncoder(void); + + 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); + + //Advanced options + virtual void setProfile(int profile); + +private: + const QString m_binary_enc; + const QString m_binary_dll; + int m_configProfile; +}; diff --git a/src/Thread_Initialization.cpp b/src/Thread_Initialization.cpp index cd28a9b3..df337e31 100644 --- a/src/Thread_Initialization.cpp +++ b/src/Thread_Initialization.cpp @@ -233,9 +233,12 @@ void InitializationThread::run() //Register all translations initTranslations(); - //Look for Nero encoder + //Look for Nero AAC encoder initNeroAac(); + //Look for FHG AAC encoder + initFhgAac(); + delay(); m_bSuccess = true; } @@ -410,6 +413,105 @@ void InitializationThread::initNeroAac(void) } } +void InitializationThread::initFhgAac(void) +{ + const QString appPath = QDir(QCoreApplication::applicationDirPath()).canonicalPath(); + + QFileInfo fhgFileInfo[4]; + fhgFileInfo[0] = QFileInfo(QString("%1/fhgaacenc.exe").arg(appPath)); + fhgFileInfo[1] = QFileInfo(QString("%1/enc_fhgaac.dll").arg(appPath)); + fhgFileInfo[2] = QFileInfo(QString("%1/nsutil.dll").arg(appPath)); + fhgFileInfo[3] = QFileInfo(QString("%1/libmp4v2.dll").arg(appPath)); + + bool fhgFilesFound = true; + for(int i = 0; i < 4; i++) { if(!fhgFileInfo[i].exists()) fhgFilesFound = false; } + + //Lock the FhgAacEnc binaries + if(!fhgFilesFound) + { + qDebug("FhgAacEnc binaries not found -> FhgAacEnc support will be disabled!\n"); + return; + } + + qDebug("Found FhgAacEnc executable:\n%s\n", fhgFileInfo[0].canonicalFilePath().toUtf8().constData()); + qDebug("Found FhgAacEnc enclibrary:\n%s\n", fhgFileInfo[1].canonicalFilePath().toUtf8().constData()); + + LockedFile *fhgBin[4]; + for(int i = 0; i < 4; i++) fhgBin[i] = NULL; + + try + { + for(int i = 0; i < 4; i++) + { + fhgBin[i] = new LockedFile(fhgFileInfo[i].canonicalFilePath()); + } + } + catch(...) + { + for(int i = 0; i < 4; i++) LAMEXP_DELETE(fhgBin[i]); + qWarning("Failed to get excluive lock to FhgAacEnc binary -> FhgAacEnc support will be disabled!"); + return; + } + + QProcess process; + process.setProcessChannelMode(QProcess::MergedChannels); + process.setReadChannel(QProcess::StandardOutput); + process.start(fhgFileInfo[0].canonicalFilePath(), QStringList() << "--version"); + + if(!process.waitForStarted()) + { + qWarning("FhgAacEnc process failed to create!"); + qWarning("Error message: \"%s\"\n", process.errorString().toLatin1().constData()); + process.kill(); + process.waitForFinished(-1); + for(int i = 0; i < 4; i++) LAMEXP_DELETE(fhgBin[i]); + return; + } + + QRegExp fhgAacEncSig("fhgaacenc version (\\d+) by tmkk", Qt::CaseInsensitive); + unsigned int fhgVersion = 0; + + while(process.state() != QProcess::NotRunning) + { + process.waitForReadyRead(); + if(!process.bytesAvailable() && process.state() == QProcess::Running) + { + qWarning("FhgAacEnc process time out -> killing!"); + process.kill(); + process.waitForFinished(-1); + for(int i = 0; i < 4; i++) LAMEXP_DELETE(fhgBin[i]); + return; + } + while(process.bytesAvailable() > 0) + { + QString line = QString::fromUtf8(process.readLine().constData()).simplified(); + if(fhgAacEncSig.lastIndexIn(line) >= 0) + { + bool ok = false; + unsigned int temp = fhgAacEncSig.cap(1).toUInt(&ok); + if(ok) fhgVersion = temp; + } + } + } + + if(!(fhgVersion > 0)) + { + qWarning("FhgAacEnc version couldn't be determined -> FhgAacEnc support will be disabled!"); + for(int i = 0; i < 4; i++) LAMEXP_DELETE(fhgBin[i]); + return; + } + else if(fhgVersion < 20110819) + { + qWarning("FhgAacEnc version is too much outdated -> FhgAacEnc support will be disabled!"); + for(int i = 0; i < 4; i++) LAMEXP_DELETE(fhgBin[i]); + return; + } + + for(int i = 0; i < 4; i++) + { + lamexp_register_tool(fhgFileInfo[i].fileName(), fhgBin[i], fhgVersion); + } +} //void InitializationThread::initWmaDec(void) //{ diff --git a/src/Thread_Initialization.h b/src/Thread_Initialization.h index 569b81f0..857cd84c 100644 --- a/src/Thread_Initialization.h +++ b/src/Thread_Initialization.h @@ -42,6 +42,7 @@ private: void delay(void); void initTranslations(void); void initNeroAac(void); + void initFhgAac(void); bool m_bSuccess; lamexp_cpu_t m_cpuFeatures;