From 2026be82ddcd9e2f15f919c868904d2cbc19c60e Mon Sep 17 00:00:00 2001 From: LoRd_MuldeR Date: Sat, 12 Nov 2016 16:06:04 +0100 Subject: [PATCH] Don't apply "downmix" filter on Mono or Stereo sources. Always apply when channel count is undetermined. --- etc/Translation/Blank.ts | 40 ++++++------ etc/Translation/LameXP_DE.ts | 40 ++++++------ etc/Translation/LameXP_ES.ts | 40 ++++++------ etc/Translation/LameXP_FR.ts | 40 ++++++------ etc/Translation/LameXP_HU.ts | 40 ++++++------ etc/Translation/LameXP_IT.ts | 40 ++++++------ etc/Translation/LameXP_KR.ts | 40 ++++++------ etc/Translation/LameXP_PL.ts | 40 ++++++------ etc/Translation/LameXP_RU.ts | 40 ++++++------ etc/Translation/LameXP_SV.ts | 40 ++++++------ etc/Translation/LameXP_TW.ts | 40 ++++++------ etc/Translation/LameXP_UK.ts | 40 ++++++------ etc/Translation/LameXP_ZH.ts | 40 ++++++------ src/Config.h | 4 +- src/Filter_Abstract.h | 2 +- src/Filter_Downmix.cpp | 10 ++- src/Filter_Downmix.h | 2 +- src/Filter_Normalize.cpp | 2 +- src/Filter_Normalize.h | 2 +- src/Filter_Resample.cpp | 2 +- src/Filter_Resample.h | 2 +- src/Filter_ToneAdjust.cpp | 2 +- src/Filter_ToneAdjust.h | 2 +- src/Thread_Process.cpp | 145 ++++++++++++++++++++++--------------------- src/Thread_Process.h | 4 +- 25 files changed, 351 insertions(+), 348 deletions(-) diff --git a/etc/Translation/Blank.ts b/etc/Translation/Blank.ts index 6ece24e0..72e5515f 100644 --- a/etc/Translation/Blank.ts +++ b/etc/Translation/Blank.ts @@ -3017,102 +3017,102 @@ - + Aborted! - + Done. - + Failed! - + Encoding - + Analyzing - + Filtering - + Decoding - + The source audio file could not be found: - + The source audio file could not be opened for reading: - + The target output directory doesn't exist and could NOT be created: - + The target output directory is NOT writable: - + Unknown File Name - + Unknown Title - + Unknown Artist - + Unknown Album - + Unknown Comment - + Target output file already exists, going to skip this file: - + If you don't want existing files to be skipped, please change the overwrite mode! - + Target output file already exists, going to delete existing file: - + Failed to delete existing target file, will save to another file name! diff --git a/etc/Translation/LameXP_DE.ts b/etc/Translation/LameXP_DE.ts index b4d0abe3..ab78c4aa 100644 --- a/etc/Translation/LameXP_DE.ts +++ b/etc/Translation/LameXP_DE.ts @@ -3015,82 +3015,82 @@ Nicht unterstützt! - + Done. Fertig. - + Aborted! Abgebrochen! - + Failed! Fehler! - + Encoding Kodiere - + Filtering Filtere - + Decoding Dekodiere - + The source audio file could not be found: Die Quell-Audiodatei konnte nicht gefunden werden: - + The source audio file could not be opened for reading: Die Quell-Audiodatei konnte nicht zum Lesen geöffnet werden: - + The target output directory doesn't exist and could NOT be created: Das Zielverzeichnis existiert nicht und konnte nicht erstellt werden: - + The target output directory is NOT writable: In das Zielverzeichnis kann nicht geschrieben werden: - + Unknown File Name Unbekannter Dateiname - + Unknown Title Unbekannter Titel - + Unknown Artist Unbekannter Künstler - + Unknown Album Unbekanntes Album - + Unknown Comment Unbekannter Kommentar - + Analyzing Prüfe @@ -3106,22 +3106,22 @@ Übersprungen. - + Target output file already exists, going to skip this file: Zieldatei existiert bereits, die Datei wird übersprungen: - + If you don't want existing files to be skipped, please change the overwrite mode! Wenn existierende Dateien nicht übersprungen werden sollen, ändern Sie bitte den Überschreiben-Modus! - + Target output file already exists, going to delete existing file: Zieldatei existiert bereits, die Datei wird gelöscht und überschrieben: - + Failed to delete existing target file, will save to another file name! Die existierende Datei konnte nicht gelöscht werden, ein anderer Dateiname wird gewählt! diff --git a/etc/Translation/LameXP_ES.ts b/etc/Translation/LameXP_ES.ts index 5e896bf8..02a6ab52 100644 --- a/etc/Translation/LameXP_ES.ts +++ b/etc/Translation/LameXP_ES.ts @@ -3015,82 +3015,82 @@ ¡No soportado! - + Done. Finalizado. - + Aborted! ¡Abortado! - + Failed! ¡Error! - + Encoding Codificando - + Filtering Filtrando - + Decoding Decodificando - + The source audio file could not be found: No se encuentra el archivo de entrada: - + The source audio file could not be opened for reading: No se puede abrir el archivo de entrada para su lectura: - + The target output directory doesn't exist and could NOT be created: La carpeta de salida no existe y NO puede ser creada: - + The target output directory is NOT writable: NO se puede escribir en la carpeta de salida: - + Unknown File Name Nombre de archivo desconocido - + Unknown Title Título desconocido - + Unknown Artist Artista desconocido - + Unknown Album Álbum desconocido - + Unknown Comment Comentario desconocido - + Analyzing Analizando @@ -3106,22 +3106,22 @@ Omitidos. - + Target output file already exists, going to skip this file: El archivo de destino ya existe, se omitirá este archivo: - + If you don't want existing files to be skipped, please change the overwrite mode! ¡Si no quiere sobreescribir los archivos existentes, cambie el modo sobreescritura por favor! - + Target output file already exists, going to delete existing file: El archivo de destino ya existe, se eliminará este archivo: - + Failed to delete existing target file, will save to another file name! ¡Error al eliminar el archivo de destino existente, se guardará con otro nombre! diff --git a/etc/Translation/LameXP_FR.ts b/etc/Translation/LameXP_FR.ts index 93b60831..098bfa3f 100644 --- a/etc/Translation/LameXP_FR.ts +++ b/etc/Translation/LameXP_FR.ts @@ -3022,82 +3022,82 @@ Sélection automatique (par défaut) Non supporté! - + Done. Terminé. - + Aborted! Arrêté! - + Failed! Échec! - + Encoding Encodage - + Filtering Filtrage - + Decoding Décodage - + The source audio file could not be found: Le fichier audio source n'a pas pu être trouvé: - + The source audio file could not be opened for reading: Le fichier audio source n'a pas pu être ouvert pour la lecture: - + The target output directory doesn't exist and could NOT be created: Le répertoire de sortie cible n'existe pas et ne peut PAS être créé: - + The target output directory is NOT writable: Le répertoire de sortie cible n'est pas accessible en écriture: - + Unknown File Name Nom de fichier inconnu - + Unknown Title Titre inconnu - + Unknown Artist Artiste inconnu - + Unknown Album Album inconnu - + Unknown Comment Commentaire inconnu - + Analyzing Analyse @@ -3114,22 +3114,22 @@ Sélection automatique (par défaut) Ignoré. - + Target output file already exists, going to skip this file: Le fichier de sortie existe déjà, il sera ignoré : - + If you don't want existing files to be skipped, please change the overwrite mode! Si vous ne voulez pas ignorer les fichiers existants, veuillez changer le mode de remplacement ! - + Target output file already exists, going to delete existing file: Le fichier de sortie existe déjà, il sera supprimé : - + Failed to delete existing target file, will save to another file name! Impossible de supprimer le fichier cible existant, il sera enregistré sous un autre nom ! diff --git a/etc/Translation/LameXP_HU.ts b/etc/Translation/LameXP_HU.ts index 7bd3c598..2f355476 100644 --- a/etc/Translation/LameXP_HU.ts +++ b/etc/Translation/LameXP_HU.ts @@ -3017,102 +3017,102 @@ Nem támogatott! - + Aborted! Megszakítva! - + Done. Kész. - + Failed! Sikertelen! - + Encoding Kódolás - + Analyzing Elemzés - + Filtering Szűrés - + Decoding Dekódolás - + The source audio file could not be found: A forrás hangfájl nem található: - + The source audio file could not be opened for reading: A forrás hangfájl nem nyitható meg olvasásra: - + The target output directory doesn't exist and could NOT be created: A cél kimeneti könyvtár nem létezik, és NEM hozható létre: - + The target output directory is NOT writable: A cél kimeneti könyvtár NEM írható: - + Unknown File Name Ismeretlen fájlnév - + Unknown Title Ismeretlen cím - + Unknown Artist Ismeretlen előadó - + Unknown Album Ismeretlen album - + Unknown Comment Ismeretlen hozzászólás - + Target output file already exists, going to skip this file: A cél kimeneti fájl már létezik, ez a fájl ki lesz hagyva: - + If you don't want existing files to be skipped, please change the overwrite mode! Ha nem szeretné a meglévő fájlokat kihagyni, kérjük, változtassa meg a felülírási módot! - + Target output file already exists, going to delete existing file: A cél kimeneti fájl már létezik, a meglévő fájl törlésre kerül: - + Failed to delete existing target file, will save to another file name! Nem sikerült törölni a meglévő cél fájlt. Az állomány másik fájlnéven lesz elmentve! diff --git a/etc/Translation/LameXP_IT.ts b/etc/Translation/LameXP_IT.ts index 90ca1ecc..c04a868f 100644 --- a/etc/Translation/LameXP_IT.ts +++ b/etc/Translation/LameXP_IT.ts @@ -3082,83 +3082,83 @@ Non Supportato! - + Done. Fatto. - + Aborted! Processo Annullato! - + Failed! Fallito! - + Encoding Codifica in corso - + Filtering Filtraggio in corso - + Decoding Decodifica in corso - + The source audio file could not be found: Il file audio sorgente non può essere trovato: - + The source audio file could not be opened for reading: Il file audio sorgente non può essere aperto per la lettura: - + The target output directory doesn't exist and could NOT be created: La cartella di destinazione assegnata non esiste e NON può essere creata: - + The target output directory is NOT writable: La directory di destinazione assegnata è di SOLA LETTURA: La directory di destinazione assegnata NON è scrivibile: - + Unknown File Name Nome File Sconosciuto - + Unknown Title Titolo Sconosciuto - + Unknown Artist Artista Sconosciuto - + Unknown Album Album Sconosciuto - + Unknown Comment Commento Sconosciuto - + Analyzing Analisi in corso @@ -3174,22 +3174,22 @@ Saltato. - + Target output file already exists, going to skip this file: Il file di destinazione esiste già, questo file verrà saltato: - + If you don't want existing files to be skipped, please change the overwrite mode! Se non vuoi saltare i file esistenti, cambia la modalità di sovrascrittura! - + Target output file already exists, going to delete existing file: Il file di destinazione esiste già, il file esistente verrà eliminato: - + Failed to delete existing target file, will save to another file name! Impossibile eliminare il file di destinazione esistente, il file verrà salvato con un altro nome! diff --git a/etc/Translation/LameXP_KR.ts b/etc/Translation/LameXP_KR.ts index a7e7e877..4d85cbbb 100644 --- a/etc/Translation/LameXP_KR.ts +++ b/etc/Translation/LameXP_KR.ts @@ -3006,82 +3006,82 @@ 지원하지 않습니다! - + Done. 완료. - + Aborted! 취소됨! - + Failed! 실패됨! - + Encoding 인코딩 - + Filtering 필터링 - + Decoding 디코딩 - + The source audio file could not be found: 원본 오디오 파일을 찾을 수 없음: - + The source audio file could not be opened for reading: 원본 오디오 파일을 열 수 없음: - + The target output directory doesn't exist and could NOT be created: 대상 출력 디렉터리가 존재하지 않으며, 만들 수 없습니다: - + The target output directory is NOT writable: 대상 출력 디렉터리에 쓰기 불가: - + Unknown File Name 알수 없는 파일명 - + Unknown Title 알수 없는 제목 - + Unknown Artist 알수 없는 가수 - + Unknown Album 알수 없는 앨범 - + Unknown Comment 알수 없는 설명 - + Analyzing 검토 중 @@ -3097,22 +3097,22 @@ 건너뜀. - + Target output file already exists, going to skip this file: 대상 출력 파일이 이미 존재합니다. 건너뛰기할 파일: - + If you don't want existing files to be skipped, please change the overwrite mode! 기존 파일을 건너뛰기하지 않으려면, 덮어쓰기 방식을 변경하시기 바랍니다! - + Target output file already exists, going to delete existing file: 대상 출력 파일이 이미 존재합니다. 건너뛰기할 파일: - + Failed to delete existing target file, will save to another file name! 기존 대상 파일 삭제 실패. 다른 파일명으로 저장됩니다! diff --git a/etc/Translation/LameXP_PL.ts b/etc/Translation/LameXP_PL.ts index 33908378..db6a5cb3 100644 --- a/etc/Translation/LameXP_PL.ts +++ b/etc/Translation/LameXP_PL.ts @@ -3034,102 +3034,102 @@ Nieobsługiwany! - + Done. Zrobione. - + Aborted! Przerwano! - + Failed! Niepowodzenie! - + Encoding Kompresowanie - + Analyzing Analizowanie - + Filtering Filtrowanie - + Decoding Dekodowanie - + The source audio file could not be found: Źródłowy plik dźwiękowy nie został odnaleziony: - + The source audio file could not be opened for reading: Źródłowy plik dźwiękowy nie mógł zostać otworzony: - + The target output directory doesn't exist and could NOT be created: Lokalizacja docelowa nie istnieje lu NIE mogła zostać utworzona: - + The target output directory is NOT writable: Nie można zapisać do lokalizacji docelowej: - + Unknown File Name Nieznana nazwa pliku - + Unknown Title Nieznany Tytuł - + Unknown Artist Nieznany Artysta - + Unknown Album Nieznany Album - + Unknown Comment Nieznany Komentarz - + Target output file already exists, going to skip this file: Plik wynikowy już istnieje, zostanie pominięty plik: - + If you don't want existing files to be skipped, please change the overwrite mode! Jeśli nie chcesz aby istniejące pliki były pomijane, zmień tryb nadpisywania! - + Target output file already exists, going to delete existing file: Plik wynikowy już istnieje, zostanie usunięty plik: - + Failed to delete existing target file, will save to another file name! Usuwanie istniejącego pliku zakończone niepowodzeniem, nowy plik zostanie zapisany pod inną nazwą! diff --git a/etc/Translation/LameXP_RU.ts b/etc/Translation/LameXP_RU.ts index b6e94179..8cce8461 100644 --- a/etc/Translation/LameXP_RU.ts +++ b/etc/Translation/LameXP_RU.ts @@ -3030,82 +3030,82 @@ Неподдерживается! - + Done. Готово. - + Aborted! Прервано! - + Failed! Ошибка! - + Encoding Кодирование - + Filtering Фильтрация - + Decoding Декодирование - + The source audio file could not be found: Исходный аудио файл не найден: - + The source audio file could not be opened for reading: Исходный аудио файл не может быть открыт: - + The target output directory doesn't exist and could NOT be created: Папка для выходных файлов не существует и не может быть создана: - + The target output directory is NOT writable: Папка для выходных файлов недоступна для записи: - + Unknown File Name Неизвестное имя файла - + Unknown Title Неизвестное Название - + Unknown Artist Неизвестный Артист - + Unknown Album Неизвестный Альбом - + Unknown Comment Неизвестный Комментарий - + Analyzing Анализ @@ -3121,22 +3121,22 @@ Пропущен. - + Target output file already exists, going to skip this file: Файл уже существует, будет пропущен: - + If you don't want existing files to be skipped, please change the overwrite mode! Если Вы не хотите пропускать уже существующие файлы, пожалуйста, измените режим перезаписи! - + Target output file already exists, going to delete existing file: Файл уже существует, будет удалён: - + Failed to delete existing target file, will save to another file name! Ошибка удаления существующего файла, будет сохранение с другим именем! diff --git a/etc/Translation/LameXP_SV.ts b/etc/Translation/LameXP_SV.ts index bf0cd2d6..fffd09ea 100644 --- a/etc/Translation/LameXP_SV.ts +++ b/etc/Translation/LameXP_SV.ts @@ -3027,102 +3027,102 @@ Stöd saknas! - + Aborted! Avbruten! - + Done. Klar. - + Failed! Misslyckades! - + Encoding Kodar - + Analyzing Analyserar - + Filtering Filtrerar - + Decoding Avkodar - + The source audio file could not be found: Källfilen kan inte hittas: - + The source audio file could not be opened for reading: Källfilen kan inte öppnas för läsning: - + The target output directory doesn't exist and could NOT be created: Målmappen finns inte och kan inte skapas: - + The target output directory is NOT writable: Målmappen är INTE skrivbar: - + Unknown File Name Okänt filnamn - + Unknown Title Okänd titel - + Unknown Artist Okänd artist - + Unknown Album Okänt album - + Unknown Comment Okänd kommentar - + Target output file already exists, going to skip this file: Målfilen finns redan! Den här filen hoppas över: - + If you don't want existing files to be skipped, please change the overwrite mode! Om du inte vill att befintliga filer hoppas över, måste du ändra överskrivningsläge! - + Target output file already exists, going to delete existing file: Målfilen finns redan! Befintlig fil kommer att tas bort: - + Failed to delete existing target file, will save to another file name! Kunde inte ta bort befintlig målfil. Sparar med annat filnamn! diff --git a/etc/Translation/LameXP_TW.ts b/etc/Translation/LameXP_TW.ts index 30b11114..873e5ca4 100644 --- a/etc/Translation/LameXP_TW.ts +++ b/etc/Translation/LameXP_TW.ts @@ -3006,82 +3006,82 @@ 不受支持! - + Done. 完成. - + Aborted! 中止! - + Failed! 失敗! - + Encoding 編碼 - + Filtering 過濾 - + Decoding 解碼 - + The source audio file could not be found: 找不到源音頻文件: - + The source audio file could not be opened for reading: 無法打開源音頻文件進行讀取: - + The target output directory doesn't exist and could NOT be created: 目標輸出目錄不存在,無法創建: - + The target output directory is NOT writable: 目標輸出目錄不是可寫: - + Unknown File Name 未知文件名稱 - + Unknown Title 未知標題 - + Unknown Artist 未知藝術家 - + Unknown Album 未知專輯 - + Unknown Comment 未知評論 - + Analyzing 分析 @@ -3097,22 +3097,22 @@ 跳過. - + Target output file already exists, going to skip this file: 目標輸出文件已經存在, 將跳過此文件: - + If you don't want existing files to be skipped, please change the overwrite mode! 如果你不希望被跳過已存在的文件, 請更改覆蓋模式! - + Target output file already exists, going to delete existing file: 目標輸出文件已經存在, 要刪除現有的文件: - + Failed to delete existing target file, will save to another file name! 無法刪除現有目標文件, 將保存到另一個文件名! diff --git a/etc/Translation/LameXP_UK.ts b/etc/Translation/LameXP_UK.ts index b519276d..988857c3 100644 --- a/etc/Translation/LameXP_UK.ts +++ b/etc/Translation/LameXP_UK.ts @@ -3023,82 +3023,82 @@ Не підтримується! - + Done. Виконано. - + Aborted! Перервано! - + Failed! Збій! - + Encoding Кодування - + Filtering Фільтрування - + Decoding Декодування - + The source audio file could not be found: Неможливо знайти вхідний файл аудіо: - + The source audio file could not be opened for reading: Неможливо відкрити для читання вхідний файл аудіо: - + The target output directory doesn't exist and could NOT be created: Вихідної теки не існує і її неможливо створити: - + The target output directory is NOT writable: До вихідної теки неможливо проводити запис: - + Unknown File Name Невідома назва файла - + Unknown Title Невідомий заголовок - + Unknown Artist Невідомий виконавець - + Unknown Album Невідомий альбом - + Unknown Comment Невідомий коментар - + Analyzing Аналізування @@ -3114,22 +3114,22 @@ Пропущено. - + Target output file already exists, going to skip this file: Вихідний цільовий файл вже існує, спроба пропустити цей файл: - + If you don't want existing files to be skipped, please change the overwrite mode! Якщо ви не хочете, щоб існуючі файли були пропущені, будь ласка, змініть режим перезапису! - + Target output file already exists, going to delete existing file: Вихідний цільовий файл вже існує, спроба видалити існуючий файл: - + Failed to delete existing target file, will save to another file name! Неможливо видалити існуючий файл, збереження буде проведено до файла з іншою назвою! diff --git a/etc/Translation/LameXP_ZH.ts b/etc/Translation/LameXP_ZH.ts index d7ce2e62..944bf17a 100644 --- a/etc/Translation/LameXP_ZH.ts +++ b/etc/Translation/LameXP_ZH.ts @@ -3006,82 +3006,82 @@ 不支持! - + Done. 完成。 - + Aborted! 中止! - + Failed! 失败! - + Encoding 编码 - + Filtering 过滤 - + Decoding 解码 - + The source audio file could not be found: 找不到源音频文件: - + The source audio file could not be opened for reading: 无法打开源音频文件进行读取: - + The target output directory doesn't exist and could NOT be created: 目标输出目录不存在且无法创建: - + The target output directory is NOT writable: 目标输出目录不可写: - + Unknown File Name 未知文件名称 - + Unknown Title 未知标题 - + Unknown Artist 未知艺术家 - + Unknown Album 未知专辑 - + Unknown Comment 未知注释 - + Analyzing 分析 @@ -3097,22 +3097,22 @@ 跳过。 - + Target output file already exists, going to skip this file: 目标输出文件已经存在, 将跳过此文件: - + If you don't want existing files to be skipped, please change the overwrite mode! 如果你不希望跳过已存在的文件, 请更改覆盖模式! - + Target output file already exists, going to delete existing file: 目标输出文件已经存在, 将删除现有的文件: - + Failed to delete existing target file, will save to another file name! 无法删除现有目标文件, 将保存为另一个文件名! diff --git a/src/Config.h b/src/Config.h index fb8ff117..9c94b4f1 100644 --- a/src/Config.h +++ b/src/Config.h @@ -34,8 +34,8 @@ #define VER_LAMEXP_MINOR_HI 1 #define VER_LAMEXP_MINOR_LO 4 #define VER_LAMEXP_TYPE RC -#define VER_LAMEXP_PATCH 5 -#define VER_LAMEXP_BUILD 1927 +#define VER_LAMEXP_PATCH 6 +#define VER_LAMEXP_BUILD 1928 #define VER_LAMEXP_CONFG 1818 /////////////////////////////////////////////////////////////////////////////// diff --git a/src/Filter_Abstract.h b/src/Filter_Abstract.h index 28f864e8..8872bef9 100644 --- a/src/Filter_Abstract.h +++ b/src/Filter_Abstract.h @@ -35,6 +35,6 @@ public: ~AbstractFilter(void); //Internal decoder API - virtual bool apply(const QString &sourceFile, const QString &outputFile, AudioFileModel_TechInfo *formatInfo, volatile bool *abortFlag) = 0; + virtual bool apply(const QString &sourceFile, const QString &outputFile, AudioFileModel_TechInfo *const formatInfo, volatile bool *abortFlag) = 0; }; diff --git a/src/Filter_Downmix.cpp b/src/Filter_Downmix.cpp index 29325e8b..6488e0d3 100644 --- a/src/Filter_Downmix.cpp +++ b/src/Filter_Downmix.cpp @@ -49,15 +49,15 @@ DownmixFilter::~DownmixFilter(void) { } -bool DownmixFilter::apply(const QString &sourceFile, const QString &outputFile, AudioFileModel_TechInfo *formatInfo, volatile bool *abortFlag) +bool DownmixFilter::apply(const QString &sourceFile, const QString &outputFile, AudioFileModel_TechInfo *const formatInfo, volatile bool *abortFlag) { unsigned int channels = formatInfo->audioChannels(); //detectChannels(sourceFile, abortFlag); emit messageLogged(QString().sprintf("--> Number of channels is: %d\n", channels)); - if(channels == 2) + if((channels != 0) && (channels <= 2)) { messageLogged("Skipping downmix!"); - qDebug("Dowmmix not required for Stereo input, skipping!"); + qDebug("Dowmmix not required/possible for Mono or Stereo input, skipping!"); return true; } @@ -71,8 +71,6 @@ bool DownmixFilter::apply(const QString &sourceFile, const QString &outputFile, switch(channels) { - case 2: //Unknown - qWarning("Downmixer: Nothing to do!"); case 3: //3.0 (L/R/C) args << "remix" << "1v0.66,3v0.34" << "2v0.66,3v0.34"; break; @@ -96,7 +94,7 @@ bool DownmixFilter::apply(const QString &sourceFile, const QString &outputFile, break; default: //Unknown qWarning("Downmixer: Unknown channel configuration!"); - args << "channels" << "2"; + args << "channels" << QString::number(2); break; } diff --git a/src/Filter_Downmix.h b/src/Filter_Downmix.h index a24739ed..6f269d79 100644 --- a/src/Filter_Downmix.h +++ b/src/Filter_Downmix.h @@ -32,7 +32,7 @@ public: DownmixFilter(void); ~DownmixFilter(void); - virtual bool apply(const QString &sourceFile, const QString &outputFile, AudioFileModel_TechInfo *formatInfo, volatile bool *abortFlag); + virtual bool apply(const QString &sourceFile, const QString &outputFile, AudioFileModel_TechInfo *const formatInfo, volatile bool *abortFlag); private: const QString m_binary; diff --git a/src/Filter_Normalize.cpp b/src/Filter_Normalize.cpp index 21c310a8..3c5e5635 100644 --- a/src/Filter_Normalize.cpp +++ b/src/Filter_Normalize.cpp @@ -57,7 +57,7 @@ NormalizeFilter::~NormalizeFilter(void) { } -bool NormalizeFilter::apply(const QString &sourceFile, const QString &outputFile, AudioFileModel_TechInfo *formatInfo, volatile bool *abortFlag) +bool NormalizeFilter::apply(const QString &sourceFile, const QString &outputFile, AudioFileModel_TechInfo *const formatInfo, volatile bool *abortFlag) { QProcess process; QStringList args; diff --git a/src/Filter_Normalize.h b/src/Filter_Normalize.h index b3156143..fc7eac42 100644 --- a/src/Filter_Normalize.h +++ b/src/Filter_Normalize.h @@ -30,7 +30,7 @@ public: NormalizeFilter(const int &peakVolume = -50, const bool &dnyAudNorm = false, const bool &channelsCoupled = true, const int &filterSize = 31); ~NormalizeFilter(void); - virtual bool apply(const QString &sourceFile, const QString &outputFile, AudioFileModel_TechInfo *formatInfo, volatile bool *abortFlag); + virtual bool apply(const QString &sourceFile, const QString &outputFile, AudioFileModel_TechInfo *const formatInfo, volatile bool *abortFlag); private: const QString m_binary; diff --git a/src/Filter_Resample.cpp b/src/Filter_Resample.cpp index 6547ec96..aae080cb 100644 --- a/src/Filter_Resample.cpp +++ b/src/Filter_Resample.cpp @@ -61,7 +61,7 @@ ResampleFilter::~ResampleFilter(void) { } -bool ResampleFilter::apply(const QString &sourceFile, const QString &outputFile, AudioFileModel_TechInfo *formatInfo, volatile bool *abortFlag) +bool ResampleFilter::apply(const QString &sourceFile, const QString &outputFile, AudioFileModel_TechInfo *const formatInfo, volatile bool *abortFlag) { QProcess process; QStringList args; diff --git a/src/Filter_Resample.h b/src/Filter_Resample.h index 5e408d24..7c68ab37 100644 --- a/src/Filter_Resample.h +++ b/src/Filter_Resample.h @@ -30,7 +30,7 @@ public: ResampleFilter(int samplingRate = 0, int bitDepth = 0); ~ResampleFilter(void); - virtual bool apply(const QString &sourceFile, const QString &outputFile, AudioFileModel_TechInfo *formatInfo, volatile bool *abortFlag); + virtual bool apply(const QString &sourceFile, const QString &outputFile, AudioFileModel_TechInfo *const formatInfo, volatile bool *abortFlag); private: const QString m_binary; diff --git a/src/Filter_ToneAdjust.cpp b/src/Filter_ToneAdjust.cpp index 99a1cfbd..16161f73 100644 --- a/src/Filter_ToneAdjust.cpp +++ b/src/Filter_ToneAdjust.cpp @@ -51,7 +51,7 @@ ToneAdjustFilter::~ToneAdjustFilter(void) { } -bool ToneAdjustFilter::apply(const QString &sourceFile, const QString &outputFile, AudioFileModel_TechInfo *formatInfo, volatile bool *abortFlag) +bool ToneAdjustFilter::apply(const QString &sourceFile, const QString &outputFile, AudioFileModel_TechInfo *const formatInfo, volatile bool *abortFlag) { QProcess process; QStringList args; diff --git a/src/Filter_ToneAdjust.h b/src/Filter_ToneAdjust.h index eaca82ee..03d2a300 100644 --- a/src/Filter_ToneAdjust.h +++ b/src/Filter_ToneAdjust.h @@ -30,7 +30,7 @@ public: ToneAdjustFilter(int bass = 0, int treble = 0); ~ToneAdjustFilter(void); - virtual bool apply(const QString &sourceFile, const QString &outputFile, AudioFileModel_TechInfo *formatInfo, volatile bool *abortFlag); + virtual bool apply(const QString &sourceFile, const QString &outputFile, AudioFileModel_TechInfo *const formatInfo, volatile bool *abortFlag); private: const QString m_binary; diff --git a/src/Thread_Process.cpp b/src/Thread_Process.cpp index eb59d96d..53664637 100644 --- a/src/Thread_Process.cpp +++ b/src/Thread_Process.cpp @@ -271,15 +271,18 @@ void ProcessThread::processFile() handleMessage("\n-------------------------------\n"); //Do we need to take care if Stereo downmix? - if(m_encoder->supportedChannelCount()) + const unsigned int *const supportedChannelCount = m_encoder->supportedChannelCount(); + if(supportedChannelCount && supportedChannelCount[0]) { - insertDownmixFilter(); + insertDownmixFilter(supportedChannelCount); } //Do we need to take care of downsampling the input? - if(m_encoder->supportedSamplerates() || m_encoder->supportedBitdepths()) + const unsigned int *const supportedSamplerates = m_encoder->supportedSamplerates(); + const unsigned int *const supportedBitdepths = m_encoder->supportedBitdepths(); + if((supportedSamplerates && supportedSamplerates[0]) || (supportedBitdepths && supportedBitdepths[0])) { - insertDownsampleFilter(); + insertDownsampleFilter(supportedSamplerates, supportedBitdepths); } } } @@ -548,65 +551,44 @@ QString ProcessThread::generateTempFileName(void) return tempFileName; } -void ProcessThread::insertDownsampleFilter(void) +bool ProcessThread::insertDownsampleFilter(const unsigned int *const supportedSamplerates, const unsigned int *const supportedBitdepths) { - int targetSampleRate = 0; - int targetBitDepth = 0; + int targetSampleRate = 0, targetBitDepth = 0; /* Adjust sample rate */ - if(m_encoder->supportedSamplerates() && m_audioFile.techInfo().audioSamplerate()) + if(supportedSamplerates && m_audioFile.techInfo().audioSamplerate()) { - bool applyDownsampling = true; - - //Check if downsampling filter is already in the chain - for(int i = 0; i < m_filters.count(); i++) + const unsigned int inputRate = m_audioFile.techInfo().audioSamplerate(); + unsigned int currentDiff = UINT_MAX, minimumDiff = UINT_MAX, bestRate = UINT_MAX; + + //Find the most suitable supported sampling rate + for(int i = 0; supportedSamplerates[i]; i++) { - if(dynamic_cast(m_filters.at(i))) + currentDiff = DIFF(inputRate, supportedSamplerates[i]); + if((currentDiff < minimumDiff) || ((currentDiff == minimumDiff) && (bestRate < supportedSamplerates[i]))) { - qWarning("Encoder requires downsampling, but user has already set resamling filter!"); - handleMessage("WARNING: Encoder may need resampling, but already using resample filter. Encoding *may* fail!\n"); - applyDownsampling = false; + bestRate = supportedSamplerates[i]; + minimumDiff = currentDiff; + if(!(minimumDiff > 0)) break; } } - //Now determine the target sample rate, if required - if(applyDownsampling) + if(bestRate != inputRate) { - const unsigned int *supportedRates = m_encoder->supportedSamplerates(); - const unsigned int inputRate = m_audioFile.techInfo().audioSamplerate(); - unsigned int currentDiff = UINT_MAX, minimumDiff = UINT_MAX, bestRate = UINT_MAX; - - //Find the most suitable supported sampling rate - for(int i = 0; supportedRates[i]; i++) - { - currentDiff = DIFF(inputRate, supportedRates[i]); - if((currentDiff < minimumDiff) || ((currentDiff == minimumDiff) && (bestRate < supportedRates[i]))) - { - bestRate = supportedRates[i]; - minimumDiff = currentDiff; - if(!(minimumDiff > 0)) break; - } - } - - if(bestRate != inputRate) - { - targetSampleRate = (bestRate != UINT_MAX) ? bestRate : supportedRates[0]; - } + targetSampleRate = (bestRate != UINT_MAX) ? bestRate : supportedSamplerates[0]; } } /* Adjust bit depth (word size) */ - if(m_encoder->supportedBitdepths() && m_audioFile.techInfo().audioBitdepth()) + if(supportedBitdepths && m_audioFile.techInfo().audioBitdepth()) { const unsigned int inputBPS = m_audioFile.techInfo().audioBitdepth(); - const unsigned int *supportedBPS = m_encoder->supportedBitdepths(); - bool bAdjustBitdepth = true; //Is the input bit depth supported exactly? (including IEEE Float) - for(int i = 0; supportedBPS[i]; i++) + for(int i = 0; supportedBitdepths[i]; i++) { - if(supportedBPS[i] == inputBPS) bAdjustBitdepth = false; + if(supportedBitdepths[i] == inputBPS) bAdjustBitdepth = false; } if(bAdjustBitdepth) @@ -615,14 +597,14 @@ void ProcessThread::insertDownsampleFilter(void) 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++) + for(int i = 0; supportedBitdepths[i]; i++) { - if(supportedBPS[i] == AudioFileModel::BITDEPTH_IEEE_FLOAT32) continue; + if(supportedBitdepths[i] == AudioFileModel::BITDEPTH_IEEE_FLOAT32) continue; - currentDiff = DIFF(originalBPS, supportedBPS[i]); - if((currentDiff < minimumDiff) || ((currentDiff == minimumDiff) && (bestBPS < supportedBPS[i]))) + currentDiff = DIFF(originalBPS, supportedBitdepths[i]); + if((currentDiff < minimumDiff) || ((currentDiff == minimumDiff) && (bestBPS < supportedBitdepths[i]))) { - bestBPS = supportedBPS[i]; + bestBPS = supportedBitdepths[i]; minimumDiff = currentDiff; if(!(minimumDiff > 0)) break; } @@ -630,7 +612,21 @@ void ProcessThread::insertDownsampleFilter(void) if(bestBPS != originalBPS) { - targetBitDepth = (bestBPS != UINT_MAX) ? bestBPS : supportedBPS[0]; + targetBitDepth = (bestBPS != UINT_MAX) ? bestBPS : supportedBitdepths[0]; + } + } + } + + //Check if downsampling filter is already in the chain + if (targetSampleRate || targetBitDepth) + { + for (int i = 0; i < m_filters.count(); i++) + { + if (dynamic_cast(m_filters.at(i))) + { + qWarning("Encoder requires downsampling, but user has already set resamling filter!"); + handleMessage("WARNING: Encoder may need resampling, but already using resample filter. Encoding *may* fail!\n"); + targetSampleRate = targetBitDepth = 0; } } } @@ -639,45 +635,54 @@ void ProcessThread::insertDownsampleFilter(void) if(targetSampleRate || targetBitDepth) { m_filters.append(new ResampleFilter(targetSampleRate, targetBitDepth)); + return true; } + + return false; /*did not insert the resample filter */ } -void ProcessThread::insertDownmixFilter(void) +bool ProcessThread::insertDownmixFilter(const unsigned int *const supportedChannels) { - bool applyDownmixing = true; - - //Check if downmixing filter is already in the chain - for(int i = 0; i < m_filters.count(); i++) + //Determine number of channels in source + const unsigned int channels = m_audioFile.techInfo().audioChannels(); + bool requiresDownmix = (channels > 0); + + //Check whether encoder requires downmixing + if(requiresDownmix) { - if(dynamic_cast(m_filters.at(i))) + for (int i = 0; supportedChannels[i]; i++) { - qWarning("Encoder requires Stereo downmix, but user has already forced downmix!"); - handleMessage("WARNING: Encoder may need downmixning, but already using downmixning filter. Encoding *may* fail!\n"); - applyDownmixing = false; + if (supportedChannels[i] == channels) + { + requiresDownmix = false; + break; + } } } - //Now add the downmixing filter, if needed - if(applyDownmixing) + //Check if downmixing filter is already in the chain + if (requiresDownmix) { - bool requiresDownmix = true; - const unsigned int *supportedChannels = m_encoder->supportedChannelCount(); - unsigned int channels = m_audioFile.techInfo().audioChannels(); - - for(int i = 0; supportedChannels[i]; i++) + for (int i = 0; i < m_filters.count(); i++) { - if(supportedChannels[i] == channels) + if (dynamic_cast(m_filters.at(i))) { + qWarning("Encoder requires Stereo downmix, but user has already forced downmix!"); + handleMessage("WARNING: Encoder may need downmixning, but already using downmixning filter. Encoding *may* fail!\n"); requiresDownmix = false; break; } } + } - if(requiresDownmix) - { - m_filters.append(new DownmixFilter()); - } + //Now add the downmixing filter, if needed + if(requiresDownmix) + { + m_filters.append(new DownmixFilter()); + return true; } + + return false; /*did not insert the downmix filter*/ } bool ProcessThread::updateFileTime(const QString &originalFile, const QString &modifiedFile) diff --git a/src/Thread_Process.h b/src/Thread_Process.h index 9609ab7d..77c76037 100644 --- a/src/Thread_Process.h +++ b/src/Thread_Process.h @@ -92,8 +92,8 @@ private: QString applyRenamePattern(const QString &baseName, const AudioFileModel_MetaInfo &metaInfo); QString applyRegularExpression(const QString &fileName); QString generateTempFileName(void); - void insertDownmixFilter(void); - void insertDownsampleFilter(void); + bool insertDownmixFilter(const unsigned int *const supportedChannels); + bool insertDownsampleFilter(const unsigned int *const supportedSamplerates, const unsigned int *const supportedBitdepths); bool updateFileTime(const QString &originalFile, const QString &modifiedFile); volatile bool m_aborted; -- 2.11.4.GIT