From 961cae7fa3c08f1702a64c7269f144907b8c3932 Mon Sep 17 00:00:00 2001 From: SuRuoyan Date: Thu, 14 Nov 2024 20:32:57 +0800 Subject: [PATCH] fix channel in HE-AAC v2 mux Signed-off-by: SuRuoyan --- .../plugins/ffmpeg_adapter/common/ffmpeg_utils.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/services/media_engine/plugins/ffmpeg_adapter/common/ffmpeg_utils.cpp b/services/media_engine/plugins/ffmpeg_adapter/common/ffmpeg_utils.cpp index f2c76a51e..5e38d8aac 100644 --- a/services/media_engine/plugins/ffmpeg_adapter/common/ffmpeg_utils.cpp +++ b/services/media_engine/plugins/ffmpeg_adapter/common/ffmpeg_utils.cpp @@ -350,11 +350,13 @@ std::vector GenerateAACCodecConfig(int32_t profile, int32_t sampleRate, } std::vector codecConfig; if (profile == AAC_PROFILE_HE || profile == AAC_PROFILE_HE_V2) { + // HE-AAC v2 only support stereo and only one channel exist + int32_t realCh = (profile == AAC_PROFILE_HE_V2) ? 1 : channels; codecConfig = {0, 0, 0, 0, 0}; // 5 bit AOT(0x03:left 3 bits for sample rate) + 4 bit sample rate idx(0x01: 4 - 0x03) codecConfig[0] = ((profileVal + 1) << 0x03) | ((baseIndex & 0x0F) >> 0x01); // 0x07: left 7bits for other, 4 bit channel cfg,0x03:left for other - codecConfig[1] = ((baseIndex & 0x01) << 0x07) | ((channels & 0x0F) << 0x03) | ((sampleRateIndex & 0x0F) >> 1) ; + codecConfig[1] = ((baseIndex & 0x01) << 0x07) | ((realCh & 0x0F) << 0x03) | ((sampleRateIndex & 0x0F) >> 1) ; // 4 bit ext sample rate idx(0x07: left 7 bits for other) + 4 bit aot(2: LC-AAC, 0x02: left for other) codecConfig[2] = ((sampleRateIndex & 0x01) << 0x07) | (2 << 0x02); } else { -- Gitee