| Index: media/filters/ffmpeg_audio_decoder.cc
|
| diff --git a/media/filters/ffmpeg_audio_decoder.cc b/media/filters/ffmpeg_audio_decoder.cc
|
| index cce22b784a1e9b3befbd07a474992d13e2872e0b..f922e984b0277c235e144a2db3c7cf51bca20e8e 100644
|
| --- a/media/filters/ffmpeg_audio_decoder.cc
|
| +++ b/media/filters/ffmpeg_audio_decoder.cc
|
| @@ -357,6 +357,7 @@ bool FFmpegAudioDecoder::ConfigureDecoder() {
|
|
|
| codec_context_->opaque = this;
|
| codec_context_->get_buffer2 = GetAudioBufferImpl;
|
| + codec_context_->refcounted_frames = 1;
|
|
|
| AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
|
| if (!codec || avcodec_open2(codec_context_, codec, NULL) < 0) {
|
| @@ -396,10 +397,8 @@ void FFmpegAudioDecoder::ReleaseFFmpegResources() {
|
| av_free(codec_context_);
|
| }
|
|
|
| - if (av_frame_) {
|
| - av_free(av_frame_);
|
| - av_frame_ = NULL;
|
| - }
|
| + if (av_frame_)
|
| + av_frame_free(&av_frame_);
|
| }
|
|
|
| void FFmpegAudioDecoder::ResetTimestampState() {
|
| @@ -426,9 +425,6 @@ void FFmpegAudioDecoder::RunDecodeLoop(
|
| // want to hand it to the decoder at least once, otherwise we would end up
|
| // skipping end of stream packets since they have a size of zero.
|
| do {
|
| - // Reset frame to default values.
|
| - avcodec_get_frame_defaults(av_frame_);
|
| -
|
| int frame_decoded = 0;
|
| int result = avcodec_decode_audio4(
|
| codec_context_, av_frame_, &frame_decoded, &packet);
|
| @@ -487,6 +483,7 @@ void FFmpegAudioDecoder::RunDecodeLoop(
|
| // This is an unrecoverable error, so bail out.
|
| QueuedAudioBuffer queue_entry = { kDecodeError, NULL };
|
| queued_audio_.push_back(queue_entry);
|
| + av_frame_unref(av_frame_);
|
| break;
|
| }
|
|
|
| @@ -509,8 +506,11 @@ void FFmpegAudioDecoder::RunDecodeLoop(
|
| }
|
|
|
| decoded_frames = output->frame_count();
|
| + av_frame_unref(av_frame_);
|
| }
|
|
|
| + // WARNING: |av_frame_| no longer has valid data at this point.
|
| +
|
| if (decoded_frames > 0) {
|
| // Set the timestamp/duration once all the extra frames have been
|
| // discarded.
|
|
|