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

Josh Gargus josh at schwa.ca
Mon Aug 8 19:23:56 CEST 2011


Have you had any response from the relevant libav developers about positively identifying and fixing the root cause of the problem?  Maybe this patch is the right solution as-is, or maybe an underlying problem should be fixed, but either way the evidence points toward a real problem in a specific part of the code.

Cheers,
Josh


On Aug 8, 2011, at 12:42 AM, avcoder wrote:

> The patch is my hack. I also face the same issue as yours, so I
> patched FFmpeg to fix this bug
> 
> On Mon, Aug 8, 2011 at 3:09 PM, Josh Gargus <josh at schwa.ca> wrote:
>> Unfortunately I'm on Windows, and setting up a build environment for both libav and it's prerequisite libraries is a bit of a hassle.
>> 
>> Do you consider this patch to be The Right Thing?  A hacky workaround?  The reason I ask is that if I can just wait a few days or weeks for it to show up in a nightly build, then I'll wait.  But, if there's no chance of having the patch accepted as-is, then I'll have to think about other options.
>> 
>> Cheers,
>> Josh
>> 
>> 
>> 
>> On Aug 7, 2011, at 3:41 AM, avcoder wrote:
>> 
>>> 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
>>> _______________________________________________
>>> Libav-user mailing list
>>> Libav-user at ffmpeg.org
>>> http://ffmpeg.org/mailman/listinfo/libav-user
>> 
>> _______________________________________________
>> 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
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user



More information about the Libav-user mailing list