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

Unified Diff: media/filters/ffmpeg_audio_decoder.cc

Issue 165270: Updated decode logic to estimate timestamps if the demuxer has not assigned o... (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/filters/ffmpeg_audio_decoder.h ('k') | no next file » | 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 22918)
+++ media/filters/ffmpeg_audio_decoder.cc (working copy)
@@ -2,8 +2,9 @@
// source code is governed by a BSD-style license that can be found in the
// LICENSE file.
+#include "media/filters/ffmpeg_audio_decoder.h"
+
#include "media/base/data_buffer.h"
-#include "media/filters/ffmpeg_audio_decoder.h"
#include "media/filters/ffmpeg_common.h"
#include "media/filters/ffmpeg_demuxer.h"
@@ -73,16 +74,15 @@
return true;
}
+void FFmpegAudioDecoder::OnSeek(base::TimeDelta time) {
+ avcodec_flush_buffers(codec_context_);
+ estimated_next_timestamp_ = base::TimeDelta();
+}
+
void FFmpegAudioDecoder::OnStop() {
}
void FFmpegAudioDecoder::OnDecode(Buffer* input) {
- // Check for discontinuous buffer. If we receive a discontinuous buffer here,
- // flush the internal buffer of FFmpeg.
- if (input->IsDiscontinuous()) {
- avcodec_flush_buffers(codec_context_);
- }
-
// Due to FFmpeg API changes we no longer have const read-only pointers.
AVPacket packet;
av_init_packet(&packet);
@@ -120,9 +120,18 @@
result_buffer->SetDuration(input->GetDuration());
}
- // Copy over the timestamp.
- result_buffer->SetTimestamp(input->GetTimestamp());
+ // Use our estimate for the timestamp if |input| does not have one.
+ // Otherwise, copy over the timestamp.
+ if (input->GetTimestamp().InMicroseconds() == 0) {
+ result_buffer->SetTimestamp(estimated_next_timestamp_);
+ } else {
+ result_buffer->SetTimestamp(input->GetTimestamp());
+ }
+ // Update our estimated timestamp for the next packet.
+ estimated_next_timestamp_ = result_buffer->GetTimestamp() +
+ result_buffer->GetDuration();
+
EnqueueResult(result_buffer);
return;
}
« no previous file with comments | « media/filters/ffmpeg_audio_decoder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698