OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "media/filters/ffmpeg_audio_decoder.h" | 5 #include "media/filters/ffmpeg_audio_decoder.h" |
6 | 6 |
7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
8 #include "base/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
9 #include "media/base/audio_buffer.h" | 9 #include "media/base/audio_buffer.h" |
10 #include "media/base/audio_bus.h" | 10 #include "media/base/audio_bus.h" |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 // Any time Reset() is called. | 242 // Any time Reset() is called. |
243 | 243 |
244 // Make sure we are notified if http://crbug.com/49709 returns. Issue also | 244 // Make sure we are notified if http://crbug.com/49709 returns. Issue also |
245 // occurs with some damaged files. | 245 // occurs with some damaged files. |
246 if (!buffer->end_of_stream() && buffer->timestamp() == kNoTimestamp()) { | 246 if (!buffer->end_of_stream() && buffer->timestamp() == kNoTimestamp()) { |
247 DVLOG(1) << "Received a buffer without timestamps!"; | 247 DVLOG(1) << "Received a buffer without timestamps!"; |
248 decode_cb.Run(kDecodeError); | 248 decode_cb.Run(kDecodeError); |
249 return; | 249 return; |
250 } | 250 } |
251 | 251 |
| 252 if (!buffer->end_of_stream() && !discard_helper_->initialized() && |
| 253 codec_context_->codec_id == AV_CODEC_ID_VORBIS && |
| 254 buffer->timestamp() < base::TimeDelta()) { |
| 255 // Dropping frames for negative timestamps as outlined in section A.2 |
| 256 // in the Vorbis spec. http://xiph.org/vorbis/doc/Vorbis_I_spec.html |
| 257 const int discard_frames = |
| 258 discard_helper_->TimeDeltaToFrames(-buffer->timestamp()); |
| 259 discard_helper_->Reset(discard_frames); |
| 260 } |
| 261 |
252 if (!FFmpegDecode(buffer)) { | 262 if (!FFmpegDecode(buffer)) { |
253 state_ = kError; | 263 state_ = kError; |
254 decode_cb.Run(kDecodeError); | 264 decode_cb.Run(kDecodeError); |
255 return; | 265 return; |
256 } | 266 } |
257 | 267 |
258 if (buffer->end_of_stream()) { | 268 if (buffer->end_of_stream()) { |
259 state_ = kDecodeFinished; | 269 state_ = kDecodeFinished; |
260 output_cb_.Run(AudioBuffer::CreateEOSBuffer()); | 270 output_cb_.Run(AudioBuffer::CreateEOSBuffer()); |
261 } | 271 } |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 | 425 |
416 ResetTimestampState(); | 426 ResetTimestampState(); |
417 return true; | 427 return true; |
418 } | 428 } |
419 | 429 |
420 void FFmpegAudioDecoder::ResetTimestampState() { | 430 void FFmpegAudioDecoder::ResetTimestampState() { |
421 discard_helper_->Reset(config_.codec_delay()); | 431 discard_helper_->Reset(config_.codec_delay()); |
422 } | 432 } |
423 | 433 |
424 } // namespace media | 434 } // namespace media |
OLD | NEW |