[Libav-user] infinite loop in avcodec_encode_audio when encoding AAC

avcoder ffmpeg at gmail.com
Sun Aug 7 12:41:32 CEST 2011


It's the bug of aacenc encoder in FFmpeg, try the following patch

--- aacenc.c	Thu Jan 15 17:14:12 1970
+++ aacenc.c	Thu Jan 15 17:14:12 1970
@@ -573,6 +573,8 @@
         }
         start_ch += chans;
     }
+
+    s->last_frame_bits = 0;
     do {
         int frame_bits;
         init_put_bits(&s->pb, frame, buf_size*8);
@@ -639,6 +641,10 @@
             s->psy.bitres.bits = frame_bits / avctx->channels;
             break;
         }
+        //it seems that lambda is broken
+        if (s->last_frame_bits == frame_bits)
+            break;
+        s->last_frame_bits = frame_bits;

         s->lambda *= avctx->bit_rate * 1024.0f / avctx->sample_rate /
frame_bits;

--- aacenc.h	Thu Jan 15 17:14:12 1970
+++ aacenc.h	Thu Jan 15 17:14:12 1970
@@ -72,6 +72,7 @@
     float lambda;
     DECLARE_ALIGNED(16, int,   qcoefs)[96];      ///< quantized coefficients
     DECLARE_ALIGNED(32, float, scoefs)[1024];    ///< scaled coefficients
+    int last_frame_bits;
 } AACEncContext;

 #endif /* AVCODEC_AACENC_H */


On Sat, Aug 6, 2011 at 1:26 PM, Josh Gargus <josh at schwa.ca> wrote:
> I'm running into a problem that seems essentially the same as:
> http://stackoverflow.com/questions/2410459/encode-audio-to-aac-with-libavcodec
> … except that I'm already encoding at a far lower bitrate than the threshold
> that started to cause him problems (I encode at 64000bits/sec, and he was OK
> below 386000bits/sec).
> Has anyone else seen anything else like this?  I'll be happy to provide more
> details if anyone is interested.
> Thanks,
> Josh
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user
>
>



-- 
-----------------------------------------------------------------------------------------
My key fingerprint: d1:03:f5:32:26:ff:d7:3c:e4:42:e3:51:ec:92:78:b2


More information about the Libav-user mailing list