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

Unified Diff: media/filters/ffmpeg_demuxer.cc

Issue 465044: Refactor FFmpegVideoDecoder to try and generalize code common to all video decoders. (Closed)
Patch Set: Fix SCOPED_TRACE since VS faults on %zd. Created 11 years 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_demuxer.h ('k') | media/filters/ffmpeg_video_decode_engine_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/ffmpeg_demuxer.cc
diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc
index dd08e40b3cf3f351829dea27e55aa61d23c61594..3eab9f66972727339bfe26eff3f8fe08d1455cea 100644
--- a/media/filters/ffmpeg_demuxer.cc
+++ b/media/filters/ffmpeg_demuxer.cc
@@ -7,6 +7,7 @@
#include "base/string_util.h"
#include "base/time.h"
#include "media/base/filter_host.h"
+#include "media/ffmpeg/ffmpeg_util.h"
#include "media/filters/ffmpeg_common.h"
#include "media/filters/ffmpeg_demuxer.h"
#include "media/filters/ffmpeg_glue.h"
@@ -76,7 +77,7 @@ FFmpegDemuxerStream::FFmpegDemuxerStream(FFmpegDemuxer* demuxer,
}
// Calculate the duration.
- duration_ = ConvertTimestamp(stream->duration);
+ duration_ = ConvertStreamTimestamp(stream->time_base, stream->duration);
}
FFmpegDemuxerStream::~FFmpegDemuxerStream() {
@@ -103,8 +104,10 @@ bool FFmpegDemuxerStream::HasPendingReads() {
base::TimeDelta FFmpegDemuxerStream::EnqueuePacket(AVPacket* packet) {
DCHECK_EQ(MessageLoop::current(), demuxer_->message_loop());
- base::TimeDelta timestamp = ConvertTimestamp(packet->pts);
- base::TimeDelta duration = ConvertTimestamp(packet->duration);
+ base::TimeDelta timestamp =
+ ConvertStreamTimestamp(stream_->time_base, packet->pts);
+ base::TimeDelta duration =
+ ConvertStreamTimestamp(stream_->time_base, packet->duration);
if (stopped_) {
NOTREACHED() << "Attempted to enqueue packet on a stopped stream";
return timestamp;
@@ -191,12 +194,13 @@ void FFmpegDemuxerStream::FulfillPendingRead() {
read_callback->Run(buffer);
}
-base::TimeDelta FFmpegDemuxerStream::ConvertTimestamp(int64 timestamp) {
+// static
+base::TimeDelta FFmpegDemuxerStream::ConvertStreamTimestamp(
+ const AVRational& time_base, int64 timestamp) {
if (timestamp == static_cast<int64>(AV_NOPTS_VALUE))
return StreamSample::kInvalidTimestamp;
- AVRational time_base = { 1, base::Time::kMicrosecondsPerSecond };
- int64 microseconds = av_rescale_q(timestamp, stream_->time_base, time_base);
- return base::TimeDelta::FromMicroseconds(microseconds);
+
+ return ConvertTimestamp(time_base, timestamp);
}
//
« no previous file with comments | « media/filters/ffmpeg_demuxer.h ('k') | media/filters/ffmpeg_video_decode_engine_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698