Skip to content

Commit b40d247

Browse files
committed
Fall back to HE/ELD-SBR when trying to encode non-stereo material in HEv2 or ELDv2.
1 parent 4e11c49 commit b40d247

File tree

5 files changed

+27
-4
lines changed

5 files changed

+27
-4
lines changed

components/encoder/coreaudio/coreaudio.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* BoCA - BonkEnc Component Architecture
2-
* Copyright (C) 2007-2022 Robert Kausch <robert.kausch@freac.org>
2+
* Copyright (C) 2007-2024 Robert Kausch <robert.kausch@freac.org>
33
*
44
* This program is free software; you can redistribute it and/or
55
* modify it under the terms of the GNU General Public License as
@@ -159,6 +159,11 @@ Bool BoCA::EncoderCoreAudio::Activate()
159159
Int kbps = config->GetIntValue(ConfigureCoreAudio::ConfigID, "Bitrate", 64);
160160
Bool mp4Container = config->GetIntValue(ConfigureCoreAudio::ConfigID, "MP4Container", True);
161161

162+
/* Fall back to HE/ELD-SBR if HEv2/ELDv2 is selected for non-stereo input.
163+
*/
164+
if (codec == CA::kAudioFormatMPEG4AAC_HE_V2 && format.channels != 2) codec = CA::kAudioFormatMPEG4AAC_HE;
165+
if (codec == CA::kOptionalAudioFormatMPEG4AAC_ELD_V2 && format.channels != 2) codec = CA::kOptionalAudioFormatMPEG4AAC_ELD_SBR;
166+
162167
/* Fill out source format description.
163168
*/
164169
CA::AudioStreamBasicDescription sourceFormat = { 0 };

components/encoder/coreaudio/worker.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* BoCA - BonkEnc Component Architecture
2-
* Copyright (C) 2007-2021 Robert Kausch <robert.kausch@freac.org>
2+
* Copyright (C) 2007-2024 Robert Kausch <robert.kausch@freac.org>
33
*
44
* This program is free software; you can redistribute it and/or
55
* modify it under the terms of the GNU General Public License as
@@ -38,6 +38,11 @@ BoCA::SuperWorker::SuperWorker(const Config *config, const Format &iFormat) : pr
3838
CA::UInt32 codec = config->GetIntValue(ConfigureCoreAudio::ConfigID, "Codec", CA::kAudioFormatMPEG4AAC);
3939
Int kbps = config->GetIntValue(ConfigureCoreAudio::ConfigID, "Bitrate", 64);
4040

41+
/* Fall back to HE/ELD-SBR if HEv2/ELDv2 is selected for non-stereo input.
42+
*/
43+
if (codec == CA::kAudioFormatMPEG4AAC_HE_V2 && format.channels != 2) codec = CA::kAudioFormatMPEG4AAC_HE;
44+
if (codec == CA::kOptionalAudioFormatMPEG4AAC_ELD_V2 && format.channels != 2) codec = CA::kOptionalAudioFormatMPEG4AAC_ELD_SBR;
45+
4146
/* Fill out source format description.
4247
*/
4348
CA::AudioStreamBasicDescription sourceFormat = { 0 };

components/encoder/coreaudioconnect/coreaudioconnect.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* BoCA - BonkEnc Component Architecture
2-
* Copyright (C) 2007-2022 Robert Kausch <robert.kausch@freac.org>
2+
* Copyright (C) 2007-2024 Robert Kausch <robert.kausch@freac.org>
33
*
44
* This program is free software; you can redistribute it and/or
55
* modify it under the terms of the GNU General Public License as
@@ -171,6 +171,11 @@ Bool BoCA::EncoderCoreAudioConnect::Activate()
171171
Int kbps = config->GetIntValue(ConfigureCoreAudio::ConfigID, "Bitrate", 64);
172172
Bool mp4Container = config->GetIntValue(ConfigureCoreAudio::ConfigID, "MP4Container", True);
173173

174+
/* Fall back to HE/ELD-SBR if HEv2/ELDv2 is selected for non-stereo input.
175+
*/
176+
if (codec == CA::kAudioFormatMPEG4AAC_HE_V2 && format.channels != 2) codec = CA::kAudioFormatMPEG4AAC_HE;
177+
if (codec == CA::kAudioFormatMPEG4AAC_ELD_V2 && format.channels != 2) codec = CA::kAudioFormatMPEG4AAC_ELD_SBR;
178+
174179
/* Get file type of output file.
175180
*/
176181
fileType = mp4Container ? CA::kAudioFileM4AType : CA::kAudioFileAAC_ADTSType;

components/encoder/fdkaac/fdkaac.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,10 @@ Bool BoCA::EncoderFDKAAC::Activate()
207207
Int bitrate = config->GetIntValue(ConfigureFDKAAC::ConfigID, "Bitrate", 64);
208208
Int quality = config->GetIntValue(ConfigureFDKAAC::ConfigID, "Quality", 4);
209209

210+
/* Fall back to HE if HEv2 is selected for non-stereo input.
211+
*/
212+
if (aacType == AOT_PS && format.channels != 2) aacType = AOT_SBR;
213+
210214
/* Create and configure FDK AAC encoder.
211215
*/
212216
HANDLE_AACENCODER handle = NIL;

components/encoder/fdkaac/worker.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* BoCA - BonkEnc Component Architecture
2-
* Copyright (C) 2007-2021 Robert Kausch <robert.kausch@freac.org>
2+
* Copyright (C) 2007-2024 Robert Kausch <robert.kausch@freac.org>
33
*
44
* This program is free software; you can redistribute it and/or
55
* modify it under the terms of the GNU General Public License as
@@ -36,6 +36,10 @@ BoCA::SuperWorker::SuperWorker(const Config *config, const Format &iFormat) : pr
3636
Int quality = config->GetIntValue(ConfigureFDKAAC::ConfigID, "Quality", 4);
3737
Int bandwidth = config->GetIntValue(ConfigureFDKAAC::ConfigID, "Bandwidth", 0);
3838

39+
/* Fall back to HE if HEv2 is selected for non-stereo input.
40+
*/
41+
if (aacType == AOT_PS && format.channels != 2) aacType = AOT_SBR;
42+
3943
/* Create and configure FDK AAC encoder.
4044
*/
4145
ex_aacEncOpen(&handle, 0x07, format.channels);

0 commit comments

Comments
 (0)