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

Side by Side 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, 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 * 9 *
10 */ 10 */
(...skipping 11 matching lines...) Expand all
22 #include "vpx/vp8dx.h" 22 #include "vpx/vp8dx.h"
23 23
24 #include "webrtc/base/checks.h" 24 #include "webrtc/base/checks.h"
25 #include "webrtc/base/keep_ref_until_done.h" 25 #include "webrtc/base/keep_ref_until_done.h"
26 #include "webrtc/base/logging.h" 26 #include "webrtc/base/logging.h"
27 #include "webrtc/base/random.h" 27 #include "webrtc/base/random.h"
28 #include "webrtc/base/timeutils.h" 28 #include "webrtc/base/timeutils.h"
29 #include "webrtc/base/trace_event.h" 29 #include "webrtc/base/trace_event.h"
30 #include "webrtc/common_video/include/video_frame_buffer.h" 30 #include "webrtc/common_video/include/video_frame_buffer.h"
31 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" 31 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
32 #include "webrtc/modules/include/module_common_types.h"
33 #include "webrtc/modules/video_coding/codecs/vp9/screenshare_layers.h" 32 #include "webrtc/modules/video_coding/codecs/vp9/screenshare_layers.h"
34 33
35 namespace webrtc { 34 namespace webrtc {
36 35
37 // Only positive speeds, range for real-time coding currently is: 5 - 8. 36 // Only positive speeds, range for real-time coding currently is: 5 - 8.
38 // Lower means slower/better quality, higher means fastest/lower quality. 37 // Lower means slower/better quality, higher means fastest/lower quality.
39 int GetCpuSpeed(int width, int height) { 38 int GetCpuSpeed(int width, int height) {
40 #if defined(WEBRTC_ARCH_ARM) || defined(WEBRTC_ARCH_ARM64) || defined(ANDROID) 39 #if defined(WEBRTC_ARCH_ARM) || defined(WEBRTC_ARCH_ARM64) || defined(ANDROID)
41 return 8; 40 return 8;
42 #else 41 #else
(...skipping 30 matching lines...) Expand all
73 encoder_(NULL), 72 encoder_(NULL),
74 config_(NULL), 73 config_(NULL),
75 raw_(NULL), 74 raw_(NULL),
76 input_image_(NULL), 75 input_image_(NULL),
77 frames_since_kf_(0), 76 frames_since_kf_(0),
78 num_temporal_layers_(0), 77 num_temporal_layers_(0),
79 num_spatial_layers_(0), 78 num_spatial_layers_(0),
80 is_flexible_mode_(false), 79 is_flexible_mode_(false),
81 frames_encoded_(0), 80 frames_encoded_(0),
82 // Use two spatial when screensharing with flexible mode. 81 // Use two spatial when screensharing with flexible mode.
83 spatial_layer_(new ScreenshareLayersVP9(2)) { 82 spatial_layer_(new ScreenshareLayersVP9(2)),
83 last_timing_frame_time_ms_(0),
84 encode_time_start_ms_(0) {
84 memset(&codec_, 0, sizeof(codec_)); 85 memset(&codec_, 0, sizeof(codec_));
85 memset(&svc_params_, 0, sizeof(vpx_svc_extra_cfg_t)); 86 memset(&svc_params_, 0, sizeof(vpx_svc_extra_cfg_t));
86 87
87 Random random(rtc::TimeMicros()); 88 Random random(rtc::TimeMicros());
88 picture_id_ = random.Rand<uint16_t>() & 0x7FFF; 89 picture_id_ = random.Rand<uint16_t>() & 0x7FFF;
89 tl0_pic_idx_ = random.Rand<uint8_t>(); 90 tl0_pic_idx_ = random.Rand<uint8_t>();
90 } 91 }
91 92
92 VP9EncoderImpl::~VP9EncoderImpl() { 93 VP9EncoderImpl::~VP9EncoderImpl() {
93 Release(); 94 Release();
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 485
485 int VP9EncoderImpl::Encode(const VideoFrame& input_image, 486 int VP9EncoderImpl::Encode(const VideoFrame& input_image,
486 const CodecSpecificInfo* codec_specific_info, 487 const CodecSpecificInfo* codec_specific_info,
487 const std::vector<FrameType>* frame_types) { 488 const std::vector<FrameType>* frame_types) {
488 if (!inited_) { 489 if (!inited_) {
489 return WEBRTC_VIDEO_CODEC_UNINITIALIZED; 490 return WEBRTC_VIDEO_CODEC_UNINITIALIZED;
490 } 491 }
491 if (encoded_complete_callback_ == NULL) { 492 if (encoded_complete_callback_ == NULL) {
492 return WEBRTC_VIDEO_CODEC_UNINITIALIZED; 493 return WEBRTC_VIDEO_CODEC_UNINITIALIZED;
493 } 494 }
495
496 encode_time_start_ms_ = rtc::TimeMillis();
497 if (input_image.render_time_ms() - last_timing_frame_time_ms_ >=
498 codec_.timingFramesDelayMs) {
499 last_timing_frame_time_ms_ = input_image.render_time_ms();
500 }
501
494 FrameType frame_type = kVideoFrameDelta; 502 FrameType frame_type = kVideoFrameDelta;
495 // We only support one stream at the moment. 503 // We only support one stream at the moment.
496 if (frame_types && frame_types->size() > 0) { 504 if (frame_types && frame_types->size() > 0) {
497 frame_type = (*frame_types)[0]; 505 frame_type = (*frame_types)[0];
498 } 506 }
499 RTC_DCHECK_EQ(input_image.width(), raw_->d_w); 507 RTC_DCHECK_EQ(input_image.width(), raw_->d_w);
500 RTC_DCHECK_EQ(input_image.height(), raw_->d_h); 508 RTC_DCHECK_EQ(input_image.height(), raw_->d_h);
501 509
502 // Set input image for use in the callback. 510 // Set input image for use in the callback.
503 // This was necessary since you need some information from input_image. 511 // This was necessary since you need some information from input_image.
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 encoded_image_.capture_time_ms_ = input_image_->render_time_ms(); 713 encoded_image_.capture_time_ms_ = input_image_->render_time_ms();
706 encoded_image_.rotation_ = input_image_->rotation(); 714 encoded_image_.rotation_ = input_image_->rotation();
707 encoded_image_.content_type_ = (codec_.mode == kScreensharing) 715 encoded_image_.content_type_ = (codec_.mode == kScreensharing)
708 ? VideoContentType::SCREENSHARE 716 ? VideoContentType::SCREENSHARE
709 : VideoContentType::UNSPECIFIED; 717 : VideoContentType::UNSPECIFIED;
710 encoded_image_._encodedHeight = raw_->d_h; 718 encoded_image_._encodedHeight = raw_->d_h;
711 encoded_image_._encodedWidth = raw_->d_w; 719 encoded_image_._encodedWidth = raw_->d_w;
712 int qp = -1; 720 int qp = -1;
713 vpx_codec_control(encoder_, VP8E_GET_LAST_QUANTIZER, &qp); 721 vpx_codec_control(encoder_, VP8E_GET_LAST_QUANTIZER, &qp);
714 encoded_image_.qp_ = qp; 722 encoded_image_.qp_ = qp;
723
724 if (last_timing_frame_time_ms_ == input_image_->render_time_ms() ||
725 encoded_image_._length >= codec_.minFrameSizeToForceTimingFrameBytes) {
726 encoded_image_.timing_.is_timing_frame = true;
727 encoded_image_.timing_.encode_start_ms = encode_time_start_ms_;
728 encoded_image_.timing_.encode_finish_ms = rtc::TimeMillis();
729 } else {
730 encoded_image_.timing_.is_timing_frame = false;
731 }
732
715 encoded_complete_callback_->OnEncodedImage(encoded_image_, &codec_specific, 733 encoded_complete_callback_->OnEncodedImage(encoded_image_, &codec_specific,
716 &frag_info); 734 &frag_info);
717 } 735 }
718 return WEBRTC_VIDEO_CODEC_OK; 736 return WEBRTC_VIDEO_CODEC_OK;
719 } 737 }
720 738
721 vpx_svc_ref_frame_config VP9EncoderImpl::GenerateRefsAndFlags( 739 vpx_svc_ref_frame_config VP9EncoderImpl::GenerateRefsAndFlags(
722 const SuperFrameRefSettings& settings) { 740 const SuperFrameRefSettings& settings) {
723 static const vpx_enc_frame_flags_t kAllFlags = 741 static const vpx_enc_frame_flags_t kAllFlags =
724 VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_LAST | 742 VP8_EFLAG_NO_REF_ARF | VP8_EFLAG_NO_REF_GF | VP8_EFLAG_NO_REF_LAST |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
1006 frame_buffer_pool_.ClearPool(); 1024 frame_buffer_pool_.ClearPool();
1007 inited_ = false; 1025 inited_ = false;
1008 return WEBRTC_VIDEO_CODEC_OK; 1026 return WEBRTC_VIDEO_CODEC_OK;
1009 } 1027 }
1010 1028
1011 const char* VP9DecoderImpl::ImplementationName() const { 1029 const char* VP9DecoderImpl::ImplementationName() const {
1012 return "libvpx"; 1030 return "libvpx";
1013 } 1031 }
1014 1032
1015 } // namespace webrtc 1033 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698