diff options
author | Reimar Döffinger <Reimar.Doeffinger@gmx.de> | 2012-04-06 15:25:05 +0200 |
---|---|---|
committer | Derek Buitenhuis <derek.buitenhuis@gmail.com> | 2012-04-17 10:25:28 -0400 |
commit | 0f96f0d9968a767ead3aec823fcdfb78f26f7be7 (patch) | |
tree | c068dc23c136f519ddd319a929fc9d1079f57856 /libavcodec | |
parent | db6e26d70c371f069075d11f40d38924f3a45b65 (diff) | |
download | ffmpeg-0f96f0d9968a767ead3aec823fcdfb78f26f7be7.tar.gz |
aacenc: Fix issues with huge values of bit_rate.
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 <Reimar.Doeffinger@gmx.de>
Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/aaccoder.c | 3 | ||||
-rw-r--r-- | libavcodec/aacenc.c | 9 |
2 files changed, 8 insertions, 4 deletions
diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c index 36a49a7538..c2b0e241a9 100644 --- a/libavcodec/aaccoder.c +++ b/libavcodec/aaccoder.c @@ -721,6 +721,9 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx, int allz = 0; float minthr = INFINITY; + // for values above this the decoder might end up in an endless loop + // due to always having more bits than what can be encoded. + destbits = FFMIN(destbits, 5800); //XXX: some heuristic to determine initial quantizers will reduce search time //determine zero bands and upper limits for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) { 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)) |