From 525a539b7e694f99d6b9db60cb409234803ab4cd Mon Sep 17 00:00:00 2001 From: Timon Wong Date: Fri, 24 May 2013 16:15:07 +0800 Subject: [PATCH] FFmpeg: Fix potential crash on some codecs (speex for example) --- ffmpegaudio.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ffmpegaudio.cc b/ffmpegaudio.cc index 4ab56d42..ca0bb195 100644 --- a/ffmpegaudio.cc +++ b/ffmpegaudio.cc @@ -351,7 +351,7 @@ bool DecoderContext::play( QString & errorString ) av_free_packet( &packet ); } - if ( codecContext_->codec->capabilities & CODEC_CAP_DELAY ) + if ( !isCancelled_ && codecContext_->codec->capabilities & CODEC_CAP_DELAY ) { av_init_packet( &packet ); int gotFrame = 0; @@ -396,7 +396,7 @@ bool DecoderContext::normalizeAudio( AVFrame * frame, vector & samples ) case AV_SAMPLE_FMT_S32: { samples.resize( dataSize ); - memcpy( &samples.front(), frame->extended_data[0], lineSize ); + memcpy( &samples.front(), frame->data[0], lineSize ); } break; case AV_SAMPLE_FMT_FLT: @@ -406,7 +406,7 @@ bool DecoderContext::normalizeAudio( AVFrame * frame, vector & samples ) int32_t * out = ( int32_t * )&samples.front(); for ( int i = 0; i < dataSize; i += sizeof( float ) ) { - *out++ = toInt32( *( float * )frame->extended_data[i] ); + *out++ = toInt32( *( float * )frame->data[i] ); } } break; @@ -417,7 +417,7 @@ bool DecoderContext::normalizeAudio( AVFrame * frame, vector & samples ) int32_t * out = ( int32_t * )&samples.front(); for ( int i = 0; i < dataSize; i += sizeof( double ) ) { - *out++ = toInt32( *( double * )frame->extended_data[i] ); + *out++ = toInt32( *( double * )frame->data[i] ); } } break;