mirror of https://git.ffmpeg.org/ffmpeg.git
aacenc: Fix issues with huge values of bit_rate.
Do not pointlessly call ff_alloc_packet2 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>
This commit is contained in:
parent
76e8b336cd
commit
ecd7455e96
|
@ -721,6 +721,9 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx,
|
||||||
int allz = 0;
|
int allz = 0;
|
||||||
float minthr = INFINITY;
|
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
|
//XXX: some heuristic to determine initial quantizers will reduce search time
|
||||||
//determine zero bands and upper limits
|
//determine zero bands and upper limits
|
||||||
for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
|
for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
|
||||||
|
|
|
@ -571,11 +571,11 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
|
||||||
}
|
}
|
||||||
start_ch += chans;
|
start_ch += chans;
|
||||||
}
|
}
|
||||||
|
if ((ret = ff_alloc_packet2(avctx, avpkt, 768 * s->channels)))
|
||||||
|
return ret;
|
||||||
do {
|
do {
|
||||||
int frame_bits;
|
int frame_bits;
|
||||||
|
|
||||||
if ((ret = ff_alloc_packet2(avctx, avpkt, 768 * s->channels)))
|
|
||||||
return ret;
|
|
||||||
init_put_bits(&s->pb, avpkt->data, avpkt->size);
|
init_put_bits(&s->pb, avpkt->data, avpkt->size);
|
||||||
|
|
||||||
if ((avctx->frame_number & 0xFF)==1 && !(avctx->flags & CODEC_FLAG_BITEXACT))
|
if ((avctx->frame_number & 0xFF)==1 && !(avctx->flags & CODEC_FLAG_BITEXACT))
|
||||||
|
|
Loading…
Reference in New Issue