Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(733)

Unified Diff: media/filters/ffmpeg_audio_decoder.cc

Issue 239423005: Wire up codec_delay() to MP3StreamParser and FFmpegAudioDecoder. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ResetTimestampState() on config change. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/filters/decrypting_demuxer_stream.cc ('k') | media/filters/opus_audio_decoder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/ffmpeg_audio_decoder.cc
diff --git a/media/filters/ffmpeg_audio_decoder.cc b/media/filters/ffmpeg_audio_decoder.cc
index 45f8dd4863d6da11db8b4792ee5dba86c4551948..02af059ac2db969f48ae0b7b9426b1c8f0732b78 100644
--- a/media/filters/ffmpeg_audio_decoder.cc
+++ b/media/filters/ffmpeg_audio_decoder.cc
@@ -262,22 +262,30 @@ void FFmpegAudioDecoder::DecodeBuffer(
}
if (!buffer->end_of_stream()) {
- if (last_input_timestamp_ == kNoTimestamp() &&
- codec_context_->codec_id == AV_CODEC_ID_VORBIS &&
+ DCHECK(buffer->timestamp() != kNoTimestamp());
+ const bool first_buffer =
+ last_input_timestamp_ == kNoTimestamp() &&
+ output_timestamp_helper_->base_timestamp() == kNoTimestamp();
+ if (first_buffer && codec_context_->codec_id == AV_CODEC_ID_VORBIS &&
buffer->timestamp() < base::TimeDelta()) {
// Dropping frames for negative timestamps as outlined in section A.2
// in the Vorbis spec. http://xiph.org/vorbis/doc/Vorbis_I_spec.html
- output_frames_to_drop_ = floor(0.5 + -buffer->timestamp().InSecondsF() *
- config_.samples_per_second());
+ DCHECK_EQ(output_frames_to_drop_, 0);
+ output_frames_to_drop_ =
+ 0.5 +
+ -buffer->timestamp().InSecondsF() * config_.samples_per_second();
+
+ // If we are dropping samples for Vorbis, the timeline always starts at 0.
+ output_timestamp_helper_->SetBaseTimestamp(base::TimeDelta());
} else {
- if (last_input_timestamp_ != kNoTimestamp() &&
- buffer->timestamp() < last_input_timestamp_) {
+ if (first_buffer) {
+ output_timestamp_helper_->SetBaseTimestamp(buffer->timestamp());
+ } else if (buffer->timestamp() < last_input_timestamp_) {
const base::TimeDelta diff =
buffer->timestamp() - last_input_timestamp_;
- DLOG(WARNING)
- << "Input timestamps are not monotonically increasing! "
- << " ts " << buffer->timestamp().InMicroseconds() << " us"
- << " diff " << diff.InMicroseconds() << " us";
+ DLOG(WARNING) << "Input timestamps are not monotonically increasing! "
+ << " ts " << buffer->timestamp().InMicroseconds() << " us"
+ << " diff " << diff.InMicroseconds() << " us";
}
last_input_timestamp_ = buffer->timestamp();
@@ -355,19 +363,6 @@ bool FFmpegAudioDecoder::FFmpegDecode(
packet.size -= result;
packet.data += result;
- if (output_timestamp_helper_->base_timestamp() == kNoTimestamp() &&
- !buffer->end_of_stream()) {
- DCHECK(buffer->timestamp() != kNoTimestamp());
- if (output_frames_to_drop_ > 0) {
- // Currently Vorbis is the only codec that causes us to drop samples.
- // If we have to drop samples it always means the timeline starts at 0.
- DCHECK_EQ(codec_context_->codec_id, AV_CODEC_ID_VORBIS);
- output_timestamp_helper_->SetBaseTimestamp(base::TimeDelta());
- } else {
- output_timestamp_helper_->SetBaseTimestamp(buffer->timestamp());
- }
- }
-
scoped_refptr<AudioBuffer> output;
int decoded_frames = 0;
int original_frames = 0;
@@ -483,6 +478,7 @@ bool FFmpegAudioDecoder::ConfigureDecoder() {
av_frame_.reset(av_frame_alloc());
output_timestamp_helper_.reset(
new AudioTimestampHelper(config_.samples_per_second()));
+ ResetTimestampState();
av_sample_format_ = codec_context_->sample_fmt;
@@ -496,6 +492,8 @@ bool FFmpegAudioDecoder::ConfigureDecoder() {
state_ = kUninitialized;
return false;
}
+
+ output_frames_to_drop_ = config_.codec_delay();
return true;
}
« no previous file with comments | « media/filters/decrypting_demuxer_stream.cc ('k') | media/filters/opus_audio_decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698