History

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.

Reimar Döffinger committed 14 years ago

Commit 0f96f0d1 parent db6e26d2 files · +8 −4Browse files

Unified · Split

2 files
  1. libavcodec/aaccoder.c +3 −0
  2. libavcodec/aacenc.c +5 −4
libavcodec/aaccoder.c+3−0
@@ -721,6 +721,9 @@ static void search_for_quantizers_twoloop(AVCodecContext *avctx, · 720 unmodified lines
721721 int allz = 0;
722722 float minthr = INFINITY;
723723
724+ // for values above this the decoder might end up in an endless loop
725+ // due to always having more bits than what can be encoded.
726+ destbits = FFMIN(destbits, 5800);
724727 //XXX: some heuristic to determine initial quantizers will reduce search time
725728 //determine zero bands and upper limits
726729 for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
libavcodec/aacenc.c+5−4
@@ -571,13 +571,14 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, · 570 unmodified lines
571571 }
572572 start_ch += chans;
573573 }
574+ if ((ret = ff_alloc_packet(avpkt, 768 * s->channels))) {
575+ av_log(avctx, AV_LOG_ERROR, "Error getting output packet\n");
576+ return ret;
577+ }
578+
574579 do {
575580 int frame_bits;
576581
577− if ((ret = ff_alloc_packet(avpkt, 768 * s->channels))) {
578− av_log(avctx, AV_LOG_ERROR, "Error getting output packet\n");
579− return ret;
580− }
581582 init_put_bits(&s->pb, avpkt->data, avpkt->size);
582583
583584 if ((avctx->frame_number & 0xFF)==1 && !(avctx->flags & CODEC_FLAG_BITEXACT))

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t