From d62be1bee3aad35c5cc601d6c595db7e4e0cf437 Mon Sep 17 00:00:00 2001 From: SuRuoyan Date: Wed, 27 Nov 2024 15:23:25 +0800 Subject: [PATCH] fix codecheck Signed-off-by: SuRuoyan --- .../audio/encoder/audio_ffmpeg_encoder_plugin.cpp | 3 +++ .../plugins/ffmpeg_adapter/common/ffmpeg_utils.cpp | 10 +++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/services/engine/codec/audio/encoder/audio_ffmpeg_encoder_plugin.cpp b/services/engine/codec/audio/encoder/audio_ffmpeg_encoder_plugin.cpp index da7752cbb..17ef088d3 100644 --- a/services/engine/codec/audio/encoder/audio_ffmpeg_encoder_plugin.cpp +++ b/services/engine/codec/audio/encoder/audio_ffmpeg_encoder_plugin.cpp @@ -288,6 +288,9 @@ int32_t AudioFfmpegEncoderPlugin::ReAllocateContext() } }); + CHECK_AND_RETURN_RET_LOG(tmpContext != nullptr, AVCodecServiceErrCode::AVCS_ERR_NO_MEMORY, + "Allocate tmpContext failed."); + tmpContext->channels = avCodecContext_->channels; tmpContext->sample_rate = avCodecContext_->sample_rate; tmpContext->bit_rate = avCodecContext_->bit_rate; 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 fb2490dc2..0cd49364a 100644 --- a/services/media_engine/plugins/ffmpeg_adapter/common/ffmpeg_utils.cpp +++ b/services/media_engine/plugins/ffmpeg_adapter/common/ffmpeg_utils.cpp @@ -327,19 +327,19 @@ std::vector GenerateAACCodecConfig(int32_t profile, int32_t sampleRate, {AAC_PROFILE_LD, 22}, {AAC_PROFILE_MAIN, 0}, }; - const std::unordered_map sampleRates = { + const std::unordered_map sampleRates = { {96000, 0}, {88200, 1}, {64000, 2}, {48000, 3}, {44100, 4}, {32000, 5}, {24000, 6}, {22050, 7}, {16000, 8}, {12000, 9}, {11025, 10}, {8000, 11}, {7350, 12}, }; - int32_t profileVal = FF_PROFILE_AAC_LOW; + uint32_t profileVal = FF_PROFILE_AAC_LOW; auto it1 = profiles.find(static_cast(profile)); if (it1 != profiles.end()) { profileVal = it1->second; } - int32_t sampleRateIndex = 0x10; - int32_t baseIndex = 0xF; + uint32_t sampleRateIndex = 0x10; + uint32_t baseIndex = 0xF; auto it2 = sampleRates.find(sampleRate); if (it2 != sampleRates.end()) { sampleRateIndex = it2->second; @@ -351,7 +351,7 @@ 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; + uint32_t realCh = (profile == AAC_PROFILE_HE_V2) ? 1 : static_cast(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); -- Gitee