From 0f96f0d9968a767ead3aec823fcdfb78f26f7be7 Mon Sep 17 00:00:00 2001 From: Reimar Döffinger Date: Fri, 6 Apr 2012 15:25:05 +0200 Subject: aacenc: Fix issues with huge values of bit_rate. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Do not pointlessly call ff_alloc_packet multiple times, and fix an infinite loop by clamping the maximum number of bits to target in the algorithm that does not use lambda. Signed-off-by: Reimar Döffinger Signed-off-by: Derek Buitenhuis --- libavcodec/aacenc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'libavcodec/aacenc.c') diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c index 503a4a5f40..6021c375bb 100644 --- a/libavcodec/aacenc.c +++ b/libavcodec/aacenc.c @@ -571,13 +571,14 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, } start_ch += chans; } + if ((ret = ff_alloc_packet(avpkt, 768 * s->channels))) { + av_log(avctx, AV_LOG_ERROR, "Error getting output packet\n"); + return ret; + } + do { int frame_bits; - if ((ret = ff_alloc_packet(avpkt, 768 * s->channels))) { - av_log(avctx, AV_LOG_ERROR, "Error getting output packet\n"); - return ret; - } init_put_bits(&s->pb, avpkt->data, avpkt->size); if ((avctx->frame_number & 0xFF)==1 && !(avctx->flags & CODEC_FLAG_BITEXACT)) -- cgit v1.2.3