OSDN Git Service

Updated Korean translation. Thanks to JaeHyung Lee <kolanp@gmail.com>.
[lamexp/LameXP.git] / src / Thread_Process.cpp
index ce58b2f..5d5a31f 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
@@ -158,9 +158,15 @@ void ProcessThread::processFile()
                        if(bSuccess)
                        {
                                sourceFile = tempFile;
-                               handleMessage("\n-------------------------------\n");
                                m_audioFile.setFormatContainerType(QString::fromLatin1("Wave"));
                                m_audioFile.setFormatAudioType(QString::fromLatin1("PCM"));
+
+                               if(QFileInfo(sourceFile).size() >= 4294967296i64)
+                               {
+                                       handleMessage(tr("WARNING: Decoded file size exceeds 4 GB, problems might occur!\n"));
+                               }
+
+                               handleMessage("\n-------------------------------\n");
                        }
                }
                else
@@ -175,9 +181,9 @@ void ProcessThread::processFile()
        //------------------------------------
        //Update audio properties after decode
        //------------------------------------
-       if(bSuccess && IS_WAVE(m_audioFile))
+       if(bSuccess && !m_aborted && IS_WAVE(m_audioFile))
        {
-               if(m_encoder->supportedSamplerates() || m_encoder->supportedBitdepths() || m_encoder->supportedChannelCount())
+               if(m_encoder->supportedSamplerates() || m_encoder->supportedBitdepths() || m_encoder->supportedChannelCount() || m_encoder->needsTimingInfo() || !m_filters.isEmpty())
                {
                        m_currentStep = AnalyzeStep;
                        bSuccess = m_propDetect->detect(sourceFile, &m_audioFile, &m_aborted);
@@ -206,7 +212,7 @@ void ProcessThread::processFile()
        //-----------------------
        if(bSuccess)
        {
-               while(!m_filters.isEmpty())
+               while(!m_filters.isEmpty() && !m_aborted)
                {
                        QString tempFile = generateTempFileName();
                        AbstractFilter *poFilter = m_filters.takeFirst();
@@ -215,7 +221,7 @@ void ProcessThread::processFile()
                        connect(poFilter, SIGNAL(statusUpdated(int)), this, SLOT(handleUpdate(int)), Qt::DirectConnection);
                        connect(poFilter, SIGNAL(messageLogged(QString)), this, SLOT(handleMessage(QString)), Qt::DirectConnection);
 
-                       if(poFilter->apply(sourceFile, tempFile, &m_aborted))
+                       if(poFilter->apply(sourceFile, tempFile, &m_audioFile, &m_aborted))
                        {
                                sourceFile = tempFile;
                        }
@@ -228,14 +234,14 @@ void ProcessThread::processFile()
        //-----------------
        //Encode audio file
        //-----------------
-       if(bSuccess)
+       if(bSuccess && !m_aborted)
        {
                m_currentStep = EncodingStep;
                bSuccess = m_encoder->encode(sourceFile, m_audioFile, outFileName, &m_aborted);
        }
 
        //Make sure output file exists
-       if(bSuccess)
+       if(bSuccess && !m_aborted)
        {
                QFileInfo fileInfo(outFileName);
                bSuccess = fileInfo.exists() && fileInfo.isFile() && (fileInfo.size() > 0);
@@ -244,7 +250,7 @@ void ProcessThread::processFile()
        QThread::msleep(500);
 
        //Report result
-       emit processStateChanged(m_jobId, (bSuccess ? tr("Done.") : (m_aborted ? tr("Aborted!") : tr("Failed!"))), (bSuccess ? ProgressModel::JobComplete : ProgressModel::JobFailed));
+       emit processStateChanged(m_jobId, (m_aborted ? tr("Aborted!") : (bSuccess ? tr("Done.") : tr("Failed!"))), ((bSuccess && !m_aborted) ? ProgressModel::JobComplete : ProgressModel::JobFailed));
        emit processStateFinished(m_jobId, outFileName, bSuccess);
 
        qDebug("Process thread is done.");
@@ -438,25 +444,40 @@ void ProcessThread::insertDownsampleFilter(void)
        /* Adjust bit depth (word size) */
        if(m_encoder->supportedBitdepths() && m_audioFile.formatAudioBitdepth())
        {
-               const unsigned int *supportedBPS = m_encoder->supportedBitdepths();
                const unsigned int inputBPS = m_audioFile.formatAudioBitdepth();
-               unsigned int currentDiff = UINT_MAX, minimumDiff = UINT_MAX, bestBPS = UINT_MAX;
+               const unsigned int *supportedBPS = m_encoder->supportedBitdepths();
+
+               bool bAdjustBitdepth = true;
 
-               //Find the most suitable supported bit depth
+               //Is the input bit depth supported exactly? (inclduing IEEE Float)
                for(int i = 0; supportedBPS[i]; i++)
                {
-                       currentDiff = DIFF(inputBPS, supportedBPS[i]);
-                       if((currentDiff < minimumDiff) || ((currentDiff == minimumDiff) && (bestBPS < supportedBPS[i])))
+                       if(supportedBPS[i] == inputBPS) bAdjustBitdepth = false;
+               }
+               
+               if(bAdjustBitdepth)
+               {
+                       unsigned int currentDiff = UINT_MAX, minimumDiff = UINT_MAX, bestBPS = UINT_MAX;
+                       const unsigned int originalBPS = (inputBPS == AudioFileModel::BITDEPTH_IEEE_FLOAT32) ? 32 : inputBPS;
+
+                       //Find the most suitable supported bit depth
+                       for(int i = 0; supportedBPS[i]; i++)
                        {
-                               bestBPS = supportedBPS[i];
-                               minimumDiff = currentDiff;
-                               if(!(minimumDiff > 0)) break;
+                               if(supportedBPS[i] == AudioFileModel::BITDEPTH_IEEE_FLOAT32) continue;
+                               
+                               currentDiff = DIFF(originalBPS, supportedBPS[i]);
+                               if((currentDiff < minimumDiff) || ((currentDiff == minimumDiff) && (bestBPS < supportedBPS[i])))
+                               {
+                                       bestBPS = supportedBPS[i];
+                                       minimumDiff = currentDiff;
+                                       if(!(minimumDiff > 0)) break;
+                               }
                        }
-               }
 
-               if(bestBPS != inputBPS)
-               {
-                       targetBitDepth = (bestBPS != UINT_MAX) ? bestBPS : supportedBPS[0];
+                       if(bestBPS != originalBPS)
+                       {
+                               targetBitDepth = (bestBPS != UINT_MAX) ? bestBPS : supportedBPS[0];
+                       }
                }
        }