diff options
author | jstebbins <[email protected]> | 2010-04-25 01:10:25 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2010-04-25 01:10:25 +0000 |
commit | a2d5e1faded703c38a45dd72e87ba61e564f54e0 (patch) | |
tree | 723634d9c99f29f065bb6aed7614a004b80b3d7f | |
parent | 0e567e5e3f054ddc416bc9238b045ca24aa214a4 (diff) |
fix qdm2 audio decoding
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://svn.handbrake.fr/HandBrake/trunk@3264 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r-- | libhb/decavcodec.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/libhb/decavcodec.c b/libhb/decavcodec.c index 91949fb40..a506154db 100644 --- a/libhb/decavcodec.c +++ b/libhb/decavcodec.c @@ -1172,6 +1172,7 @@ static void decodeAudio( hb_audio_t * audio, hb_work_private_t *pv, uint8_t *dat { AVCodecContext *context = pv->context; int pos = 0; + int loop_limit = 256; while ( pos < size ) { @@ -1190,10 +1191,18 @@ static void decodeAudio( hb_audio_t * audio, hb_work_private_t *pv, uint8_t *dat 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 ) { |