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

Unified Diff: media/filters/ffmpeg_video_decoder.cc

Issue 464113003: Add delay in FFmpegVideoDecoder::Decode(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Less frequent but longer decode delay. Created 6 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_video_decoder.h ('k') | media/filters/video_renderer_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/ffmpeg_video_decoder.cc
diff --git a/media/filters/ffmpeg_video_decoder.cc b/media/filters/ffmpeg_video_decoder.cc
index b7da7f7a462d17f15fe57d6e2e7e193b46dfef98..073fb57a92ea30f672414343faec367c19fc6a25 100644
--- a/media/filters/ffmpeg_video_decoder.cc
+++ b/media/filters/ffmpeg_video_decoder.cc
@@ -75,7 +75,7 @@ static size_t RoundUp(size_t value, size_t alignment) {
FFmpegVideoDecoder::FFmpegVideoDecoder(
const scoped_refptr<base::SingleThreadTaskRunner>& task_runner)
: task_runner_(task_runner), state_(kUninitialized),
- decode_nalus_(false) {}
+ decode_nalus_(false), weak_factory_(this) {}
int FFmpegVideoDecoder::GetVideoBuffer(struct AVCodecContext* codec_context,
AVFrame* frame,
@@ -153,6 +153,7 @@ void FFmpegVideoDecoder::Initialize(const VideoDecoderConfig& config,
bool low_delay,
const PipelineStatusCB& status_cb,
const OutputCB& output_cb) {
+ DVLOG(2) << __FUNCTION__;
DCHECK(task_runner_->BelongsToCurrentThread());
DCHECK(!config.is_encrypted());
DCHECK(!output_cb.is_null());
@@ -176,6 +177,29 @@ void FFmpegVideoDecoder::Initialize(const VideoDecoderConfig& config,
void FFmpegVideoDecoder::Decode(const scoped_refptr<DecoderBuffer>& buffer,
const DecodeCB& decode_cb) {
+ DVLOG(2) << __FUNCTION__;
+ DCHECK(task_runner_->BelongsToCurrentThread());
+
+ static int count = 1;
+ count++;
+ int delay = 1;
+ if (count % 100 == 0)
+ delay = 2000;
+
+ //base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(delay));
+ //DecodeInternal(buffer, decode_cb);
+
+ task_runner_->PostDelayedTask(FROM_HERE,
+ base::Bind(&FFmpegVideoDecoder::DecodeInternal,
+ weak_factory_.GetWeakPtr(),
+ buffer,
+ decode_cb),
+ base::TimeDelta::FromMilliseconds(delay));
+}
+
+void FFmpegVideoDecoder::DecodeInternal(const scoped_refptr<DecoderBuffer>& buffer,
+ const DecodeCB& decode_cb) {
+ DVLOG(2) << __FUNCTION__;
DCHECK(task_runner_->BelongsToCurrentThread());
DCHECK(buffer);
DCHECK(!decode_cb.is_null());
@@ -193,6 +217,8 @@ void FFmpegVideoDecoder::Decode(const scoped_refptr<DecoderBuffer>& buffer,
return;
}
+ //base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(40));
+
DCHECK_EQ(state_, kNormal);
// During decode, because reads are issued asynchronously, it is possible to
@@ -308,6 +334,7 @@ bool FFmpegVideoDecoder::FFmpegDecode(
frame->set_timestamp(
base::TimeDelta::FromMicroseconds(av_frame_->reordered_opaque));
*has_produced_frame = true;
+
output_cb_.Run(frame);
av_frame_unref(av_frame_.get());
« no previous file with comments | « media/filters/ffmpeg_video_decoder.h ('k') | media/filters/video_renderer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698