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

Side by Side Diff: webrtc/modules/video_coding/main/source/generic_encoder.cc

Issue 1193513006: In screenshare mode, suppress VP8 bitrate overshoot and increase quality (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebase 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 unified diff | Download patch
« no previous file with comments | « webrtc/modules/video_coding/main/source/generic_encoder.h ('k') | webrtc/video/full_stack.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 53
54 VCMGenericEncoder::VCMGenericEncoder(VideoEncoder* encoder, 54 VCMGenericEncoder::VCMGenericEncoder(VideoEncoder* encoder,
55 VideoEncoderRateObserver* rate_observer, 55 VideoEncoderRateObserver* rate_observer,
56 bool internalSource) 56 bool internalSource)
57 : encoder_(encoder), 57 : encoder_(encoder),
58 rate_observer_(rate_observer), 58 rate_observer_(rate_observer),
59 vcm_encoded_frame_callback_(nullptr), 59 vcm_encoded_frame_callback_(nullptr),
60 bit_rate_(0), 60 bit_rate_(0),
61 frame_rate_(0), 61 frame_rate_(0),
62 internal_source_(internalSource), 62 internal_source_(internalSource),
63 rotation_(kVideoRotation_0) { 63 rotation_(kVideoRotation_0),
64 is_screenshare_(false) {
64 } 65 }
65 66
66 VCMGenericEncoder::~VCMGenericEncoder() 67 VCMGenericEncoder::~VCMGenericEncoder()
67 { 68 {
68 } 69 }
69 70
70 int32_t VCMGenericEncoder::Release() 71 int32_t VCMGenericEncoder::Release()
71 { 72 {
72 { 73 {
73 rtc::CritScope lock(&rates_lock_); 74 rtc::CritScope lock(&rates_lock_);
74 bit_rate_ = 0; 75 bit_rate_ = 0;
75 frame_rate_ = 0; 76 frame_rate_ = 0;
76 vcm_encoded_frame_callback_ = nullptr; 77 vcm_encoded_frame_callback_ = nullptr;
77 } 78 }
78 79
79 return encoder_->Release(); 80 return encoder_->Release();
80 } 81 }
81 82
82 int32_t 83 int32_t
83 VCMGenericEncoder::InitEncode(const VideoCodec* settings, 84 VCMGenericEncoder::InitEncode(const VideoCodec* settings,
84 int32_t numberOfCores, 85 int32_t numberOfCores,
85 size_t maxPayloadSize) 86 size_t maxPayloadSize)
86 { 87 {
87 { 88 {
88 rtc::CritScope lock(&rates_lock_); 89 rtc::CritScope lock(&rates_lock_);
89 bit_rate_ = settings->startBitrate * 1000; 90 bit_rate_ = settings->startBitrate * 1000;
90 frame_rate_ = settings->maxFramerate; 91 frame_rate_ = settings->maxFramerate;
91 } 92 }
92 93
94 is_screenshare_ = settings->mode == VideoCodecMode::kScreensharing;
93 if (encoder_->InitEncode(settings, numberOfCores, maxPayloadSize) != 0) { 95 if (encoder_->InitEncode(settings, numberOfCores, maxPayloadSize) != 0) {
94 LOG(LS_ERROR) << "Failed to initialize the encoder associated with " 96 LOG(LS_ERROR) << "Failed to initialize the encoder associated with "
95 "payload name: " << settings->plName; 97 "payload name: " << settings->plName;
96 return -1; 98 return -1;
97 } 99 }
98 return 0; 100 return 0;
99 } 101 }
100 102
101 int32_t VCMGenericEncoder::Encode(const VideoFrame& inputFrame, 103 int32_t VCMGenericEncoder::Encode(const VideoFrame& inputFrame,
102 const CodecSpecificInfo* codecSpecificInfo, 104 const CodecSpecificInfo* codecSpecificInfo,
103 const std::vector<FrameType>& frameTypes) { 105 const std::vector<FrameType>& frameTypes) {
104 std::vector<VideoFrameType> video_frame_types(frameTypes.size(), 106 std::vector<VideoFrameType> video_frame_types(frameTypes.size(),
105 kDeltaFrame); 107 kDeltaFrame);
106 VCMEncodedFrame::ConvertFrameTypes(frameTypes, &video_frame_types); 108 VCMEncodedFrame::ConvertFrameTypes(frameTypes, &video_frame_types);
107 109
108 rotation_ = inputFrame.rotation(); 110 rotation_ = inputFrame.rotation();
109 111
110 if (vcm_encoded_frame_callback_) { 112 if (vcm_encoded_frame_callback_) {
111 // Keep track of the current frame rotation and apply to the output of the 113 // Keep track of the current frame rotation and apply to the output of the
112 // encoder. There might not be exact as the encoder could have one frame 114 // encoder. There might not be exact as the encoder could have one frame
113 // delay but it should be close enough. 115 // delay but it should be close enough.
114 vcm_encoded_frame_callback_->SetRotation(rotation_); 116 vcm_encoded_frame_callback_->SetRotation(rotation_);
115 } 117 }
116 118
117 return encoder_->Encode(inputFrame, codecSpecificInfo, &video_frame_types); 119 int32_t result =
120 encoder_->Encode(inputFrame, codecSpecificInfo, &video_frame_types);
121 if (is_screenshare_ &&
122 result == WEBRTC_VIDEO_CODEC_TARGET_BITRATE_OVERSHOOT) {
123 // Target bitrate exceeded, encoder state has been reset - try again.
124 return encoder_->Encode(inputFrame, codecSpecificInfo, &video_frame_types);
125 }
126
127 return result;
118 } 128 }
119 129
120 int32_t 130 int32_t
121 VCMGenericEncoder::SetChannelParameters(int32_t packetLoss, int64_t rtt) 131 VCMGenericEncoder::SetChannelParameters(int32_t packetLoss, int64_t rtt)
122 { 132 {
123 return encoder_->SetChannelParameters(packetLoss, rtt); 133 return encoder_->SetChannelParameters(packetLoss, rtt);
124 } 134 }
125 135
126 int32_t 136 int32_t
127 VCMGenericEncoder::SetRates(uint32_t newBitRate, uint32_t frameRate) 137 VCMGenericEncoder::SetRates(uint32_t newBitRate, uint32_t frameRate)
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 } 289 }
280 290
281 void 291 void
282 VCMEncodedFrameCallback::SetMediaOpt( 292 VCMEncodedFrameCallback::SetMediaOpt(
283 media_optimization::MediaOptimization *mediaOpt) 293 media_optimization::MediaOptimization *mediaOpt)
284 { 294 {
285 _mediaOpt = mediaOpt; 295 _mediaOpt = mediaOpt;
286 } 296 }
287 297
288 } // namespace webrtc 298 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/video_coding/main/source/generic_encoder.h ('k') | webrtc/video/full_stack.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698