OSDN Git Service

Switched the method of how the Designer UI file is used in the DropBox class to ...
[lamexp/LameXP.git] / src / Encoder_AAC_FHG.cpp
index 11415ae..728d760 100644 (file)
@@ -1,6 +1,6 @@
 ///////////////////////////////////////////////////////////////////////////////
 // LameXP - Audio Encoder Front-End
-// Copyright (C) 2004-2011 LoRd_MuldeR <MuldeR2@GMX.de>
+// Copyright (C) 2004-2012 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
 #include "Global.h"
 #include "Model_Settings.h"
 
+#include <math.h>
 #include <QProcess>
 #include <QDir>
 
-#define max(a,b) (((a) > (b)) ? (a) : (b))
-#define min(a,b) (((a) < (b)) ? (a) : (b))
-
-inline int round(double x) { return static_cast<int>(floor((x < 0.0) ? x - 0.5 : x + 0.5)); }
-
 FHGAACEncoder::FHGAACEncoder(void)
 :
        m_binary_enc(lamexp_lookup_tool("fhgaacenc.exe")),
@@ -77,10 +73,10 @@ bool FHGAACEncoder::encode(const QString &sourceFile, const AudioFileModel &meta
        switch(m_configRCMode)
        {
        case SettingsModel::CBRMode:
-               args << "--cbr" << QString::number(max(32, min(maxBitrate, (m_configBitrate * 8))));
+               args << "--cbr" << QString::number(qMax(32, qMin(maxBitrate, (m_configBitrate * 8))));
                break;
        case SettingsModel::VBRMode:
-               args << "--vbr" << QString::number(round(static_cast<double>(m_configBitrate) / 5.0) + 1);
+               args << "--vbr" << QString::number(qRound(static_cast<double>(m_configBitrate) / 5.0) + 1);
                break;
        default:
                throw "Bad rate-control mode!";
@@ -89,6 +85,8 @@ bool FHGAACEncoder::encode(const QString &sourceFile, const AudioFileModel &meta
 
        args << "--dll" << m_binary_dll;
 
+       if(!m_configCustomParams.isEmpty()) args << m_configCustomParams.split(" ", QString::SkipEmptyParts);
+
        args << QDir::toNativeSeparators(sourceFile);
        args << QDir::toNativeSeparators(outputFile);
 
@@ -99,6 +97,7 @@ bool FHGAACEncoder::encode(const QString &sourceFile, const AudioFileModel &meta
 
        bool bTimeout = false;
        bool bAborted = false;
+       int prevProgress = -1;
 
        QRegExp regExp("Progress:\\s*(\\d+)%");
 
@@ -128,7 +127,11 @@ bool FHGAACEncoder::encode(const QString &sourceFile, const AudioFileModel &meta
                        {
                                bool ok = false;
                                int progress = regExp.cap(1).toInt(&ok);
-                               if(ok) emit statusUpdated(progress);
+                               if(ok && (progress > prevProgress))
+                               {
+                                       emit statusUpdated(progress);
+                                       prevProgress = qMin(progress + 2, 99);
+                               }
                        }
                        else if(!text.isEmpty())
                        {
@@ -147,7 +150,7 @@ bool FHGAACEncoder::encode(const QString &sourceFile, const AudioFileModel &meta
        emit statusUpdated(100);
        emit messageLogged(QString().sprintf("\nExited with code: 0x%04X", process.exitCode()));
 
-       if(bTimeout || bAborted || process.exitStatus() != QProcess::NormalExit)
+       if(bTimeout || bAborted || process.exitCode() != EXIT_SUCCESS)
        {
                return false;
        }
@@ -173,6 +176,23 @@ bool FHGAACEncoder::isFormatSupported(const QString &containerType, const QStrin
        return false;
 }
 
+const unsigned int *FHGAACEncoder::supportedChannelCount(void)
+{
+       static const unsigned int supportedChannels[] = {1, 2, 4, 5, 6, NULL};
+       return supportedChannels;
+}
+
+const unsigned int *FHGAACEncoder::supportedSamplerates(void)
+{
+       static const unsigned int supportedRates[] = {192000, 96000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000, 6000, NULL};
+       return supportedRates;
+}
+
+const unsigned int *FHGAACEncoder::supportedBitdepths(void)
+{
+       static const unsigned int supportedBPS[] = {16, 24, NULL};
+       return supportedBPS;
+}
 
 void FHGAACEncoder::setProfile(int profile)
 {