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

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

Issue 1886113003: Add rotation to EncodedImage and make sure it is passed through encoders. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fix merge mistake. Created 4 years, 8 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) 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 VCMGenericEncoder::VCMGenericEncoder( 94 VCMGenericEncoder::VCMGenericEncoder(
95 VideoEncoder* encoder, 95 VideoEncoder* encoder,
96 VideoEncoderRateObserver* rate_observer, 96 VideoEncoderRateObserver* rate_observer,
97 VCMEncodedFrameCallback* encoded_frame_callback, 97 VCMEncodedFrameCallback* encoded_frame_callback,
98 bool internal_source) 98 bool internal_source)
99 : encoder_(encoder), 99 : encoder_(encoder),
100 rate_observer_(rate_observer), 100 rate_observer_(rate_observer),
101 vcm_encoded_frame_callback_(encoded_frame_callback), 101 vcm_encoded_frame_callback_(encoded_frame_callback),
102 internal_source_(internal_source), 102 internal_source_(internal_source),
103 encoder_params_({0, 0, 0, 0}), 103 encoder_params_({0, 0, 0, 0}),
104 rotation_(kVideoRotation_0),
105 is_screenshare_(false) {} 104 is_screenshare_(false) {}
106 105
107 VCMGenericEncoder::~VCMGenericEncoder() {} 106 VCMGenericEncoder::~VCMGenericEncoder() {}
108 107
109 int32_t VCMGenericEncoder::Release() { 108 int32_t VCMGenericEncoder::Release() {
110 TRACE_EVENT0("webrtc", "VCMGenericEncoder::Release"); 109 TRACE_EVENT0("webrtc", "VCMGenericEncoder::Release");
111 return encoder_->Release(); 110 return encoder_->Release();
112 } 111 }
113 112
114 int32_t VCMGenericEncoder::InitEncode(const VideoCodec* settings, 113 int32_t VCMGenericEncoder::InitEncode(const VideoCodec* settings,
(...skipping 19 matching lines...) Expand all
134 133
135 int32_t VCMGenericEncoder::Encode(const VideoFrame& frame, 134 int32_t VCMGenericEncoder::Encode(const VideoFrame& frame,
136 const CodecSpecificInfo* codec_specific, 135 const CodecSpecificInfo* codec_specific,
137 const std::vector<FrameType>& frame_types) { 136 const std::vector<FrameType>& frame_types) {
138 TRACE_EVENT1("webrtc", "VCMGenericEncoder::Encode", "timestamp", 137 TRACE_EVENT1("webrtc", "VCMGenericEncoder::Encode", "timestamp",
139 frame.timestamp()); 138 frame.timestamp());
140 139
141 for (FrameType frame_type : frame_types) 140 for (FrameType frame_type : frame_types)
142 RTC_DCHECK(frame_type == kVideoFrameKey || frame_type == kVideoFrameDelta); 141 RTC_DCHECK(frame_type == kVideoFrameKey || frame_type == kVideoFrameDelta);
143 142
144 rotation_ = frame.rotation();
145
146 // Keep track of the current frame rotation and apply to the output of the
147 // encoder. There might not be exact as the encoder could have one frame delay
148 // but it should be close enough.
149 // TODO(pbos): Map from timestamp, this is racy (even if rotation_ is locked
150 // properly, which it isn't). More than one frame may be in the pipeline.
151 vcm_encoded_frame_callback_->SetRotation(rotation_);
152
153 int32_t result = encoder_->Encode(frame, codec_specific, &frame_types); 143 int32_t result = encoder_->Encode(frame, codec_specific, &frame_types);
154 144
155 if (vcm_encoded_frame_callback_) { 145 if (vcm_encoded_frame_callback_) {
156 vcm_encoded_frame_callback_->SignalLastEncoderImplementationUsed( 146 vcm_encoded_frame_callback_->SignalLastEncoderImplementationUsed(
157 encoder_->ImplementationName()); 147 encoder_->ImplementationName());
158 } 148 }
159 149
160 if (is_screenshare_ && 150 if (is_screenshare_ &&
161 result == WEBRTC_VIDEO_CODEC_TARGET_BITRATE_OVERSHOOT) { 151 result == WEBRTC_VIDEO_CODEC_TARGET_BITRATE_OVERSHOOT) {
162 // Target bitrate exceeded, encoder state has been reset - try again. 152 // Target bitrate exceeded, encoder state has been reset - try again.
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 int VCMGenericEncoder::GetTargetFramerate() { 211 int VCMGenericEncoder::GetTargetFramerate() {
222 return encoder_->GetTargetFramerate(); 212 return encoder_->GetTargetFramerate();
223 } 213 }
224 214
225 VCMEncodedFrameCallback::VCMEncodedFrameCallback( 215 VCMEncodedFrameCallback::VCMEncodedFrameCallback(
226 EncodedImageCallback* post_encode_callback) 216 EncodedImageCallback* post_encode_callback)
227 : send_callback_(), 217 : send_callback_(),
228 media_opt_(nullptr), 218 media_opt_(nullptr),
229 payload_type_(0), 219 payload_type_(0),
230 internal_source_(false), 220 internal_source_(false),
231 rotation_(kVideoRotation_0),
232 post_encode_callback_(post_encode_callback) {} 221 post_encode_callback_(post_encode_callback) {}
233 222
234 VCMEncodedFrameCallback::~VCMEncodedFrameCallback() {} 223 VCMEncodedFrameCallback::~VCMEncodedFrameCallback() {}
235 224
236 int32_t VCMEncodedFrameCallback::SetTransportCallback( 225 int32_t VCMEncodedFrameCallback::SetTransportCallback(
237 VCMPacketizationCallback* transport) { 226 VCMPacketizationCallback* transport) {
238 send_callback_ = transport; 227 send_callback_ = transport;
239 return VCM_OK; 228 return VCM_OK;
240 } 229 }
241 230
242 int32_t VCMEncodedFrameCallback::Encoded( 231 int32_t VCMEncodedFrameCallback::Encoded(
243 const EncodedImage& encoded_image, 232 const EncodedImage& encoded_image,
244 const CodecSpecificInfo* codec_specific, 233 const CodecSpecificInfo* codec_specific,
245 const RTPFragmentationHeader* fragmentation_header) { 234 const RTPFragmentationHeader* fragmentation_header) {
246 TRACE_EVENT_INSTANT1("webrtc", "VCMEncodedFrameCallback::Encoded", 235 TRACE_EVENT_INSTANT1("webrtc", "VCMEncodedFrameCallback::Encoded",
247 "timestamp", encoded_image._timeStamp); 236 "timestamp", encoded_image._timeStamp);
248 post_encode_callback_->Encoded(encoded_image, nullptr, nullptr); 237 post_encode_callback_->Encoded(encoded_image, nullptr, nullptr);
249 238
250 if (send_callback_ == nullptr) 239 if (send_callback_ == nullptr)
251 return VCM_UNINITIALIZED; 240 return VCM_UNINITIALIZED;
252 241
253 RTPVideoHeader rtp_video_header; 242 RTPVideoHeader rtp_video_header;
254 memset(&rtp_video_header, 0, sizeof(RTPVideoHeader)); 243 memset(&rtp_video_header, 0, sizeof(RTPVideoHeader));
255 if (codec_specific) 244 if (codec_specific)
256 CopyCodecSpecific(codec_specific, &rtp_video_header); 245 CopyCodecSpecific(codec_specific, &rtp_video_header);
257 rtp_video_header.rotation = rotation_; 246 rtp_video_header.rotation = encoded_image.rotation_;
258 247
259 int32_t ret_val = send_callback_->SendData( 248 int32_t ret_val = send_callback_->SendData(
260 payload_type_, encoded_image, fragmentation_header, &rtp_video_header); 249 payload_type_, encoded_image, fragmentation_header, &rtp_video_header);
261 if (ret_val < 0) 250 if (ret_val < 0)
262 return ret_val; 251 return ret_val;
263 252
264 if (media_opt_) { 253 if (media_opt_) {
265 media_opt_->UpdateWithEncodedData(encoded_image); 254 media_opt_->UpdateWithEncodedData(encoded_image);
266 if (internal_source_) 255 if (internal_source_)
267 return media_opt_->DropFrame(); // Signal to encoder to drop next frame. 256 return media_opt_->DropFrame(); // Signal to encoder to drop next frame.
268 } 257 }
269 return VCM_OK; 258 return VCM_OK;
270 } 259 }
271 260
272 void VCMEncodedFrameCallback::SetMediaOpt( 261 void VCMEncodedFrameCallback::SetMediaOpt(
273 media_optimization::MediaOptimization* mediaOpt) { 262 media_optimization::MediaOptimization* mediaOpt) {
274 media_opt_ = mediaOpt; 263 media_opt_ = mediaOpt;
275 } 264 }
276 265
277 void VCMEncodedFrameCallback::SignalLastEncoderImplementationUsed( 266 void VCMEncodedFrameCallback::SignalLastEncoderImplementationUsed(
278 const char* implementation_name) { 267 const char* implementation_name) {
279 if (send_callback_) 268 if (send_callback_)
280 send_callback_->OnEncoderImplementationName(implementation_name); 269 send_callback_->OnEncoderImplementationName(implementation_name);
281 } 270 }
282 } // namespace webrtc 271 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/video_coding/generic_encoder.h ('k') | webrtc/modules/video_coding/utility/quality_scaler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698