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

Unified Diff: ppapi/examples/video_encode/video_encode.cc

Issue 1187193006: ppapi: VideoEncoder: improve accuracy of encoding tick (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 | « native_client_sdk/src/examples/api/video_encode/video_encode.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/examples/video_encode/video_encode.cc
diff --git a/ppapi/examples/video_encode/video_encode.cc b/ppapi/examples/video_encode/video_encode.cc
index c6a09211a8c50fc0fb3811ab35a778cc9dd7cb77..7a55df294cfa2e89ce2ea21f64d974761d554871 100644
--- a/ppapi/examples/video_encode/video_encode.cc
+++ b/ppapi/examples/video_encode/video_encode.cc
@@ -6,6 +6,7 @@
#include <stdio.h>
#include <string.h>
+#include <algorithm>
#include <iostream>
#include <map>
#include <sstream>
@@ -176,6 +177,8 @@ class VideoEncoderInstance : public pp::Instance {
pp::VideoFrame current_track_frame_;
IVFWriter ivf_writer_;
+
+ PP_Time last_encode_tick_;
};
VideoEncoderInstance::VideoEncoderInstance(PP_Instance instance,
@@ -189,7 +192,8 @@ VideoEncoderInstance::VideoEncoderInstance(PP_Instance instance,
video_profile_(PP_VIDEOPROFILE_H264MAIN),
#endif
frame_format_(PP_VIDEOFRAME_FORMAT_I420),
- encoded_frames_(0) {
+ encoded_frames_(0),
+ last_encode_tick_(0) {
InitializeVideoProfiles();
ProbeEncoder();
}
@@ -339,10 +343,12 @@ void VideoEncoderInstance::OnInitializedEncoder(int32_t result) {
}
void VideoEncoderInstance::ScheduleNextEncode() {
+ PP_Time now = pp::Module::Get()->core()->GetTime();
pp::Module::Get()->core()->CallOnMainThread(
- 1000 / 30,
+ std::min(std::max(now - last_encode_tick_, 0.0), 1000.0 / 30),
callback_factory_.NewCallback(&VideoEncoderInstance::GetEncoderFrameTick),
0);
+ last_encode_tick_ = now;
}
void VideoEncoderInstance::GetEncoderFrameTick(int32_t result) {
« no previous file with comments | « native_client_sdk/src/examples/api/video_encode/video_encode.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698