From 9b8d85a96fa0b1650b52ab914b2c70fc745e8f3a Mon Sep 17 00:00:00 2001 From: wrapper Date: Mon, 18 Aug 2025 15:49:02 +0700 Subject: [PATCH] check profiles --- libavcodec/libaac_nextenc.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/libavcodec/libaac_nextenc.c b/libavcodec/libaac_nextenc.c index c5b21f2095..8bc7fccb0f 100755 --- a/libavcodec/libaac_nextenc.c +++ b/libavcodec/libaac_nextenc.c @@ -26,13 +26,14 @@ #include -#include "libavcodec/defs.h" #include "libavutil/channel_layout.h" +#include "libavutil/internal.h" #include "libavutil/intreadwrite.h" #include "libavutil/log.h" #include "libavutil/opt.h" #include "libavutil/mem.h" #include "avcodec.h" +#include "defs.h" #include "audio_frame_queue.h" #include "codec_internal.h" #include "encode.h" @@ -116,6 +117,10 @@ static av_cold int libaac_encode_init(AVCodecContext *avctx) case AV_PROFILE_AAC_ELD: cfg.profile = AAC_ELD; break; + + default: + av_log(avctx, AV_LOG_ERROR, "unsupported profile, supported profiles are LC, HE, HEv2, LD and ELD\n"); + return AVERROR(EINVAL); } cfg.tns = s->tns; cfg.frameSize = s->frame_length; @@ -168,10 +173,9 @@ static int libaac_encode_frame(AVCodecContext *avctx, AVPacket *pkt, if (!frame) { - int isFlush = s->encoder->in_buf_offset <= 0; - av_log(avctx, AV_LOG_TRACE, "frame_queue_count: %d, frame_queue_size: %d, in_buf: %d, is_flush: %d, flush_delay: %d\n", s->afq.frame_count, s->afq.remaining_samples, s->encoder->in_buf_offset, isFlush, s->flush_delay); + av_log(avctx, AV_LOG_TRACE, "flush_delay: %d\n", s->flush_delay); - if (isFlush && s->flush_delay <= 0) + if (s->flush_delay <= 0) return 0; /* Flushing */ @@ -180,8 +184,7 @@ static int libaac_encode_frame(AVCodecContext *avctx, AVPacket *pkt, return AVERROR(EINVAL); } - if (isFlush) - s->flush_delay -= avctx->frame_size; + s->flush_delay -= avctx->frame_size; } else { @@ -189,7 +192,7 @@ static int libaac_encode_frame(AVCodecContext *avctx, AVPacket *pkt, if ((ret = ff_af_queue_add(&s->afq, frame)) < 0) return ret; - int encodeSize = (avctx->sample_fmt == AV_SAMPLE_FMT_FLT ? 4 : 2) * avctx->ch_layout.nb_channels * frame->nb_samples; + int encodeSize = av_get_bytes_per_sample(avctx->sample_fmt) * avctx->ch_layout.nb_channels * frame->nb_samples; av_log(avctx, AV_LOG_TRACE, "encode size: %d\n", encodeSize); if ((ret = aac_encode(s->encoder, frame->data[0], encodeSize, pkt->data, (unsigned int *)&pkt->size)) < 0)