it seems ffmpeg wants to be passed the same buffer repeatedly
while decoding this audio type. we were exiting if ffmpeg said it
consumed 0 bytes. Now we continue to feed the same buffer when
this happens. I added a loop limit to protect against an hypothetical
ffmpeg bug that would never consume anything. I wonder if any other
codecs behave this way *scratches head in bewilderment*
git-svn-id: svn://localhost/HandBrake/trunk@3264
b64f7644-9d1e-0410-96f1-
a4d463321fa5
{
AVCodecContext *context = pv->context;
int pos = 0;
+ int loop_limit = 256;
while ( pos < size )
{
int out_size = AVCODEC_MAX_AUDIO_FRAME_SIZE;
int nsamples;
int len = avcodec_decode_audio3( context, buffer, &out_size, &avp );
- if ( len <= 0 )
+ if ( len < 0 )
{
return;
}
+ if ( len == 0 )
+ {
+ if ( !(loop_limit--) )
+ return;
+ }
+ else
+ loop_limit = 256;
+
pos += len;
if( out_size > 0 )
{