Skip to content

Commit

Permalink
Fall back to HE/ELD-SBR when trying to encode non-stereo material in …
Browse files Browse the repository at this point in the history
…HEv2 or ELDv2.
  • Loading branch information
enzo1982 committed Feb 19, 2024
1 parent 4e11c49 commit b40d247
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 4 deletions.
7 changes: 6 additions & 1 deletion components/encoder/coreaudio/coreaudio.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* BoCA - BonkEnc Component Architecture
* Copyright (C) 2007-2022 Robert Kausch <[email protected]>
* Copyright (C) 2007-2024 Robert Kausch <[email protected]>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
Expand Down Expand Up @@ -159,6 +159,11 @@ Bool BoCA::EncoderCoreAudio::Activate()
Int kbps = config->GetIntValue(ConfigureCoreAudio::ConfigID, "Bitrate", 64);
Bool mp4Container = config->GetIntValue(ConfigureCoreAudio::ConfigID, "MP4Container", True);

/* Fall back to HE/ELD-SBR if HEv2/ELDv2 is selected for non-stereo input.
*/
if (codec == CA::kAudioFormatMPEG4AAC_HE_V2 && format.channels != 2) codec = CA::kAudioFormatMPEG4AAC_HE;
if (codec == CA::kOptionalAudioFormatMPEG4AAC_ELD_V2 && format.channels != 2) codec = CA::kOptionalAudioFormatMPEG4AAC_ELD_SBR;

/* Fill out source format description.
*/
CA::AudioStreamBasicDescription sourceFormat = { 0 };
Expand Down
7 changes: 6 additions & 1 deletion components/encoder/coreaudio/worker.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* BoCA - BonkEnc Component Architecture
* Copyright (C) 2007-2021 Robert Kausch <[email protected]>
* Copyright (C) 2007-2024 Robert Kausch <[email protected]>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
Expand Down Expand Up @@ -38,6 +38,11 @@ BoCA::SuperWorker::SuperWorker(const Config *config, const Format &iFormat) : pr
CA::UInt32 codec = config->GetIntValue(ConfigureCoreAudio::ConfigID, "Codec", CA::kAudioFormatMPEG4AAC);
Int kbps = config->GetIntValue(ConfigureCoreAudio::ConfigID, "Bitrate", 64);

/* Fall back to HE/ELD-SBR if HEv2/ELDv2 is selected for non-stereo input.
*/
if (codec == CA::kAudioFormatMPEG4AAC_HE_V2 && format.channels != 2) codec = CA::kAudioFormatMPEG4AAC_HE;
if (codec == CA::kOptionalAudioFormatMPEG4AAC_ELD_V2 && format.channels != 2) codec = CA::kOptionalAudioFormatMPEG4AAC_ELD_SBR;

/* Fill out source format description.
*/
CA::AudioStreamBasicDescription sourceFormat = { 0 };
Expand Down
7 changes: 6 additions & 1 deletion components/encoder/coreaudioconnect/coreaudioconnect.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* BoCA - BonkEnc Component Architecture
* Copyright (C) 2007-2022 Robert Kausch <[email protected]>
* Copyright (C) 2007-2024 Robert Kausch <[email protected]>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
Expand Down Expand Up @@ -171,6 +171,11 @@ Bool BoCA::EncoderCoreAudioConnect::Activate()
Int kbps = config->GetIntValue(ConfigureCoreAudio::ConfigID, "Bitrate", 64);
Bool mp4Container = config->GetIntValue(ConfigureCoreAudio::ConfigID, "MP4Container", True);

/* Fall back to HE/ELD-SBR if HEv2/ELDv2 is selected for non-stereo input.
*/
if (codec == CA::kAudioFormatMPEG4AAC_HE_V2 && format.channels != 2) codec = CA::kAudioFormatMPEG4AAC_HE;
if (codec == CA::kAudioFormatMPEG4AAC_ELD_V2 && format.channels != 2) codec = CA::kAudioFormatMPEG4AAC_ELD_SBR;

/* Get file type of output file.
*/
fileType = mp4Container ? CA::kAudioFileM4AType : CA::kAudioFileAAC_ADTSType;
Expand Down
4 changes: 4 additions & 0 deletions components/encoder/fdkaac/fdkaac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ Bool BoCA::EncoderFDKAAC::Activate()
Int bitrate = config->GetIntValue(ConfigureFDKAAC::ConfigID, "Bitrate", 64);
Int quality = config->GetIntValue(ConfigureFDKAAC::ConfigID, "Quality", 4);

/* Fall back to HE if HEv2 is selected for non-stereo input.
*/
if (aacType == AOT_PS && format.channels != 2) aacType = AOT_SBR;

/* Create and configure FDK AAC encoder.
*/
HANDLE_AACENCODER handle = NIL;
Expand Down
6 changes: 5 additions & 1 deletion components/encoder/fdkaac/worker.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* BoCA - BonkEnc Component Architecture
* Copyright (C) 2007-2021 Robert Kausch <[email protected]>
* Copyright (C) 2007-2024 Robert Kausch <[email protected]>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
Expand Down Expand Up @@ -36,6 +36,10 @@ BoCA::SuperWorker::SuperWorker(const Config *config, const Format &iFormat) : pr
Int quality = config->GetIntValue(ConfigureFDKAAC::ConfigID, "Quality", 4);
Int bandwidth = config->GetIntValue(ConfigureFDKAAC::ConfigID, "Bandwidth", 0);

/* Fall back to HE if HEv2 is selected for non-stereo input.
*/
if (aacType == AOT_PS && format.channels != 2) aacType = AOT_SBR;

/* Create and configure FDK AAC encoder.
*/
ex_aacEncOpen(&handle, 0x07, format.channels);
Expand Down

0 comments on commit b40d247

Please sign in to comment.