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

Unified Diff: trunk/src/media/filters/ffmpeg_audio_decoder.cc

Issue 242203006: Revert 264763 "Wire up codec_delay() to MP3StreamParser and FFmp..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: 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 | « trunk/src/media/filters/decrypting_demuxer_stream.cc ('k') | trunk/src/media/filters/opus_audio_decoder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trunk/src/media/filters/ffmpeg_audio_decoder.cc
===================================================================
--- trunk/src/media/filters/ffmpeg_audio_decoder.cc (revision 264802)
+++ trunk/src/media/filters/ffmpeg_audio_decoder.cc (working copy)
@@ -262,30 +262,22 @@
}
if (!buffer->end_of_stream()) {
- 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 &&
+ if (last_input_timestamp_ == kNoTimestamp() &&
+ 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
- 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());
+ output_frames_to_drop_ = floor(0.5 + -buffer->timestamp().InSecondsF() *
+ config_.samples_per_second());
} else {
- if (first_buffer) {
- output_timestamp_helper_->SetBaseTimestamp(buffer->timestamp());
- } else if (buffer->timestamp() < last_input_timestamp_) {
+ if (last_input_timestamp_ != kNoTimestamp() &&
+ 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();
@@ -363,6 +355,19 @@
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;
@@ -478,7 +483,6 @@
av_frame_.reset(av_frame_alloc());
output_timestamp_helper_.reset(
new AudioTimestampHelper(config_.samples_per_second()));
- ResetTimestampState();
av_sample_format_ = codec_context_->sample_fmt;
@@ -492,8 +496,6 @@
state_ = kUninitialized;
return false;
}
-
- output_frames_to_drop_ = config_.codec_delay();
return true;
}
« no previous file with comments | « trunk/src/media/filters/decrypting_demuxer_stream.cc ('k') | trunk/src/media/filters/opus_audio_decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698