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

Unified Diff: media/filters/ffmpeg_audio_decoder.cc

Issue 173072: Suppress slider thumb jumping around during seeking... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 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/base/pipeline_impl.cc ('k') | media/filters/ffmpeg_demuxer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/ffmpeg_audio_decoder.cc
===================================================================
--- media/filters/ffmpeg_audio_decoder.cc (revision 23852)
+++ media/filters/ffmpeg_audio_decoder.cc (working copy)
@@ -76,7 +76,7 @@
void FFmpegAudioDecoder::OnSeek(base::TimeDelta time) {
avcodec_flush_buffers(codec_context_);
- estimated_next_timestamp_ = base::TimeDelta();
+ estimated_next_timestamp_ = StreamSample::kInvalidTimestamp;
}
void FFmpegAudioDecoder::OnStop() {
@@ -114,26 +114,27 @@
// Determine the duration if the demuxer couldn't figure it out, otherwise
// copy it over.
- if (input->GetDuration().InMicroseconds() == 0) {
+ if (input->GetDuration().ToInternalValue() == 0) {
result_buffer->SetDuration(CalculateDuration(output_buffer_size));
} else {
+ DCHECK(input->GetDuration() != StreamSample::kInvalidTimestamp);
result_buffer->SetDuration(input->GetDuration());
}
// Use our estimate for the timestamp if |input| does not have one.
// Otherwise, copy over the timestamp.
- if (input->GetTimestamp().InMicroseconds() == 0) {
+ if (input->GetTimestamp() == StreamSample::kInvalidTimestamp) {
result_buffer->SetTimestamp(estimated_next_timestamp_);
} else {
result_buffer->SetTimestamp(input->GetTimestamp());
}
// Only use the timestamp of |result_buffer| to estimate the next timestamp
- // if it is valid (i.e. greater than 0). Otherwise the error will stack
- // together and we will get a series of incorrect timestamps. In this case,
- // this will maintain a series of zero timestamps.
- // TODO(hclam): We should use another invalid value other than 0.
- if (result_buffer->GetTimestamp().InMicroseconds() > 0) {
+ // if it is valid (i.e. != StreamSample::kInvalidTimestamp). Otherwise the
+ // error will stack together and we will get a series of incorrect
+ // timestamps. In this case, this will maintain a series of zero
+ // timestamps.
+ if (result_buffer->GetTimestamp() != StreamSample::kInvalidTimestamp) {
// Update our estimated timestamp for the next packet.
estimated_next_timestamp_ = result_buffer->GetTimestamp() +
result_buffer->GetDuration();
@@ -143,6 +144,16 @@
return;
}
+ // We can get a positive result but no decoded data. This is ok because this
+ // this can be a marker packet that only contains timestamp. In this case we
+ // save the timestamp for later use.
+ if (result && !input->IsEndOfStream() &&
+ input->GetTimestamp() != StreamSample::kInvalidTimestamp &&
+ input->GetDuration() != StreamSample::kInvalidTimestamp) {
+ estimated_next_timestamp_ = input->GetTimestamp() + input->GetDuration();
+ return;
+ }
+
// Three conditions to meet to declare end of stream for this decoder:
// 1. FFmpeg didn't read anything.
// 2. FFmpeg didn't output anything.
« no previous file with comments | « media/base/pipeline_impl.cc ('k') | media/filters/ffmpeg_demuxer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698