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

Unified Diff: webrtc/modules/video_coding/codecs/vp9/vp9_impl.cc

Issue 2911193002: Implement timing frames. (Closed)
Patch Set: Fix uninitialized variables memcheck errors Created 3 years, 7 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
Index: webrtc/modules/video_coding/codecs/vp9/vp9_impl.cc
diff --git a/webrtc/modules/video_coding/codecs/vp9/vp9_impl.cc b/webrtc/modules/video_coding/codecs/vp9/vp9_impl.cc
index 65d1a155d52275edbfb1e81ea773545ed5157e21..b3fb1640b3b7493deaa8b0e24759d086ebc4f3b9 100644
--- a/webrtc/modules/video_coding/codecs/vp9/vp9_impl.cc
+++ b/webrtc/modules/video_coding/codecs/vp9/vp9_impl.cc
@@ -29,7 +29,6 @@
#include "webrtc/base/trace_event.h"
#include "webrtc/common_video/include/video_frame_buffer.h"
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
-#include "webrtc/modules/include/module_common_types.h"
#include "webrtc/modules/video_coding/codecs/vp9/screenshare_layers.h"
namespace webrtc {
@@ -80,7 +79,9 @@ VP9EncoderImpl::VP9EncoderImpl()
is_flexible_mode_(false),
frames_encoded_(0),
// Use two spatial when screensharing with flexible mode.
- spatial_layer_(new ScreenshareLayersVP9(2)) {
+ spatial_layer_(new ScreenshareLayersVP9(2)),
+ last_timing_frame_time_ms_(0),
+ encode_time_start_ms_(0) {
memset(&codec_, 0, sizeof(codec_));
memset(&svc_params_, 0, sizeof(vpx_svc_extra_cfg_t));
@@ -491,6 +492,13 @@ int VP9EncoderImpl::Encode(const VideoFrame& input_image,
if (encoded_complete_callback_ == NULL) {
return WEBRTC_VIDEO_CODEC_UNINITIALIZED;
}
+
+ encode_time_start_ms_ = rtc::TimeMillis();
+ if (input_image.render_time_ms() - last_timing_frame_time_ms_ >=
+ codec_.timingFramesDelayMs) {
+ last_timing_frame_time_ms_ = input_image.render_time_ms();
+ }
+
FrameType frame_type = kVideoFrameDelta;
// We only support one stream at the moment.
if (frame_types && frame_types->size() > 0) {
@@ -712,6 +720,16 @@ int VP9EncoderImpl::GetEncodedLayerFrame(const vpx_codec_cx_pkt* pkt) {
int qp = -1;
vpx_codec_control(encoder_, VP8E_GET_LAST_QUANTIZER, &qp);
encoded_image_.qp_ = qp;
+
+ if (last_timing_frame_time_ms_ == input_image_->render_time_ms() ||
+ encoded_image_._length >= codec_.minFrameSizeToForceTimingFrameBytes) {
+ encoded_image_.timing_.is_timing_frame = true;
+ encoded_image_.timing_.encode_start_ms = encode_time_start_ms_;
+ encoded_image_.timing_.encode_finish_ms = rtc::TimeMillis();
+ } else {
+ encoded_image_.timing_.is_timing_frame = false;
+ }
+
encoded_complete_callback_->OnEncodedImage(encoded_image_, &codec_specific,
&frag_info);
}

Powered by Google App Engine
This is Rietveld 408576698