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

Side by Side Diff: webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.cc

Issue 2001533003: Refactoring: Hide VideoCodec.codecSpecific as "private" (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: More zeroes Created 4 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 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 if (inst->maxFramerate < 1) { 74 if (inst->maxFramerate < 1) {
75 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; 75 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
76 } 76 }
77 // allow zero to represent an unspecified maxBitRate 77 // allow zero to represent an unspecified maxBitRate
78 if (inst->maxBitrate > 0 && inst->startBitrate > inst->maxBitrate) { 78 if (inst->maxBitrate > 0 && inst->startBitrate > inst->maxBitrate) {
79 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; 79 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
80 } 80 }
81 if (inst->width <= 1 || inst->height <= 1) { 81 if (inst->width <= 1 || inst->height <= 1) {
82 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; 82 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
83 } 83 }
84 if (inst->codecSpecific.VP8.feedbackModeOn && 84 if (inst->VP8().feedbackModeOn && inst->numberOfSimulcastStreams > 1) {
85 inst->numberOfSimulcastStreams > 1) {
86 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; 85 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
87 } 86 }
88 if (inst->codecSpecific.VP8.automaticResizeOn && 87 if (inst->VP8().automaticResizeOn && inst->numberOfSimulcastStreams > 1) {
89 inst->numberOfSimulcastStreams > 1) {
90 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; 88 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
91 } 89 }
92 return WEBRTC_VIDEO_CODEC_OK; 90 return WEBRTC_VIDEO_CODEC_OK;
93 } 91 }
94 92
95 // TL1 FrameDropper's max time to drop frames. 93 // TL1 FrameDropper's max time to drop frames.
96 const float kTl1MaxTimeToDropFrames = 20.0f; 94 const float kTl1MaxTimeToDropFrames = 20.0f;
97 95
98 struct ScreenshareTemporalLayersFactory : webrtc::TemporalLayersFactory { 96 struct ScreenshareTemporalLayersFactory : webrtc::TemporalLayersFactory {
99 ScreenshareTemporalLayersFactory() 97 ScreenshareTemporalLayersFactory()
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 184
187 if (doing_simulcast && !ValidSimulcastResolutions(*inst, number_of_streams)) { 185 if (doing_simulcast && !ValidSimulcastResolutions(*inst, number_of_streams)) {
188 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; 186 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
189 } 187 }
190 188
191 codec_ = *inst; 189 codec_ = *inst;
192 190
193 // Special mode when screensharing on a single stream. 191 // Special mode when screensharing on a single stream.
194 if (number_of_streams == 1 && inst->mode == kScreensharing) { 192 if (number_of_streams == 1 && inst->mode == kScreensharing) {
195 screensharing_tl_factory_.reset(new ScreenshareTemporalLayersFactory()); 193 screensharing_tl_factory_.reset(new ScreenshareTemporalLayersFactory());
196 codec_.codecSpecific.VP8.tl_factory = screensharing_tl_factory_.get(); 194 codec_.VP8()->tl_factory = screensharing_tl_factory_.get();
197 } 195 }
198 196
199 std::string implementation_name; 197 std::string implementation_name;
200 // Create |number_of_streams| of encoder instances and init them. 198 // Create |number_of_streams| of encoder instances and init them.
201 for (int i = 0; i < number_of_streams; ++i) { 199 for (int i = 0; i < number_of_streams; ++i) {
202 VideoCodec stream_codec; 200 VideoCodec stream_codec;
203 bool send_stream = true; 201 bool send_stream = true;
204 if (!doing_simulcast) { 202 if (!doing_simulcast) {
205 stream_codec = codec_; 203 stream_codec = codec_;
206 stream_codec.numberOfSimulcastStreams = 1; 204 stream_codec.numberOfSimulcastStreams = 1;
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 streaminfos_[stream_idx].key_frame_request = true; 368 streaminfos_[stream_idx].key_frame_request = true;
371 } 369 }
372 streaminfos_[stream_idx].send_stream = send_stream; 370 streaminfos_[stream_idx].send_stream = send_stream;
373 371
374 // TODO(holmer): This is a temporary hack for screensharing, where we 372 // TODO(holmer): This is a temporary hack for screensharing, where we
375 // interpret the startBitrate as the encoder target bitrate. This is 373 // interpret the startBitrate as the encoder target bitrate. This is
376 // to allow for a different max bitrate, so if the codec can't meet 374 // to allow for a different max bitrate, so if the codec can't meet
377 // the target we still allow it to overshoot up to the max before dropping 375 // the target we still allow it to overshoot up to the max before dropping
378 // frames. This hack should be improved. 376 // frames. This hack should be improved.
379 if (codec_.targetBitrate > 0 && 377 if (codec_.targetBitrate > 0 &&
380 (codec_.codecSpecific.VP8.numberOfTemporalLayers == 2 || 378 (codec_.VP8()->numberOfTemporalLayers == 2 ||
381 codec_.simulcastStream[0].numberOfTemporalLayers == 2)) { 379 codec_.simulcastStream[0].numberOfTemporalLayers == 2)) {
382 stream_bitrate = std::min(codec_.maxBitrate, stream_bitrate); 380 stream_bitrate = std::min(codec_.maxBitrate, stream_bitrate);
383 // TODO(ronghuawu): Can't change max bitrate via the VideoEncoder 381 // TODO(ronghuawu): Can't change max bitrate via the VideoEncoder
384 // interface. And VP8EncoderImpl doesn't take negative framerate. 382 // interface. And VP8EncoderImpl doesn't take negative framerate.
385 // max_bitrate = std::min(codec_.maxBitrate, stream_bitrate); 383 // max_bitrate = std::min(codec_.maxBitrate, stream_bitrate);
386 // new_framerate = -1; 384 // new_framerate = -1;
387 } 385 }
388 386
389 streaminfos_[stream_idx].encoder->SetRates(stream_bitrate, new_framerate); 387 streaminfos_[stream_idx].encoder->SetRates(stream_bitrate, new_framerate);
390 } 388 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 void SimulcastEncoderAdapter::PopulateStreamCodec( 454 void SimulcastEncoderAdapter::PopulateStreamCodec(
457 const webrtc::VideoCodec* inst, 455 const webrtc::VideoCodec* inst,
458 int stream_index, 456 int stream_index,
459 size_t total_number_of_streams, 457 size_t total_number_of_streams,
460 bool highest_resolution_stream, 458 bool highest_resolution_stream,
461 webrtc::VideoCodec* stream_codec, 459 webrtc::VideoCodec* stream_codec,
462 bool* send_stream) { 460 bool* send_stream) {
463 *stream_codec = *inst; 461 *stream_codec = *inst;
464 462
465 // Stream specific settings. 463 // Stream specific settings.
466 stream_codec->codecSpecific.VP8.numberOfTemporalLayers = 464 stream_codec->VP8()->numberOfTemporalLayers =
467 inst->simulcastStream[stream_index].numberOfTemporalLayers; 465 inst->simulcastStream[stream_index].numberOfTemporalLayers;
468 stream_codec->numberOfSimulcastStreams = 0; 466 stream_codec->numberOfSimulcastStreams = 0;
469 stream_codec->width = inst->simulcastStream[stream_index].width; 467 stream_codec->width = inst->simulcastStream[stream_index].width;
470 stream_codec->height = inst->simulcastStream[stream_index].height; 468 stream_codec->height = inst->simulcastStream[stream_index].height;
471 stream_codec->maxBitrate = inst->simulcastStream[stream_index].maxBitrate; 469 stream_codec->maxBitrate = inst->simulcastStream[stream_index].maxBitrate;
472 stream_codec->minBitrate = inst->simulcastStream[stream_index].minBitrate; 470 stream_codec->minBitrate = inst->simulcastStream[stream_index].minBitrate;
473 stream_codec->qpMax = inst->simulcastStream[stream_index].qpMax; 471 stream_codec->qpMax = inst->simulcastStream[stream_index].qpMax;
474 // Settings that are based on stream/resolution. 472 // Settings that are based on stream/resolution.
475 if (stream_index == 0) { 473 if (stream_index == 0) {
476 // Settings for lowest spatial resolutions. 474 // Settings for lowest spatial resolutions.
477 stream_codec->qpMax = kLowestResMaxQp; 475 stream_codec->qpMax = kLowestResMaxQp;
478 } 476 }
479 if (!highest_resolution_stream) { 477 if (!highest_resolution_stream) {
480 // For resolutions below CIF, set the codec |complexity| parameter to 478 // For resolutions below CIF, set the codec |complexity| parameter to
481 // kComplexityHigher, which maps to cpu_used = -4. 479 // kComplexityHigher, which maps to cpu_used = -4.
482 int pixels_per_frame = stream_codec->width * stream_codec->height; 480 int pixels_per_frame = stream_codec->width * stream_codec->height;
483 if (pixels_per_frame < 352 * 288) { 481 if (pixels_per_frame < 352 * 288) {
484 stream_codec->codecSpecific.VP8.complexity = webrtc::kComplexityHigher; 482 stream_codec->VP8()->complexity = webrtc::kComplexityHigher;
485 } 483 }
486 // Turn off denoising for all streams but the highest resolution. 484 // Turn off denoising for all streams but the highest resolution.
487 stream_codec->codecSpecific.VP8.denoisingOn = false; 485 stream_codec->VP8()->denoisingOn = false;
488 } 486 }
489 // TODO(ronghuawu): what to do with targetBitrate. 487 // TODO(ronghuawu): what to do with targetBitrate.
490 488
491 int stream_bitrate = GetStreamBitrate(stream_index, total_number_of_streams, 489 int stream_bitrate = GetStreamBitrate(stream_index, total_number_of_streams,
492 inst->startBitrate, send_stream); 490 inst->startBitrate, send_stream);
493 stream_codec->startBitrate = stream_bitrate; 491 stream_codec->startBitrate = stream_bitrate;
494 } 492 }
495 493
496 bool SimulcastEncoderAdapter::Initialized() const { 494 bool SimulcastEncoderAdapter::Initialized() const {
497 return !streaminfos_.empty(); 495 return !streaminfos_.empty();
(...skipping 10 matching lines...) Expand all
508 if (streaminfos_.size() != 1) 506 if (streaminfos_.size() != 1)
509 return false; 507 return false;
510 return streaminfos_[0].encoder->SupportsNativeHandle(); 508 return streaminfos_[0].encoder->SupportsNativeHandle();
511 } 509 }
512 510
513 const char* SimulcastEncoderAdapter::ImplementationName() const { 511 const char* SimulcastEncoderAdapter::ImplementationName() const {
514 return implementation_name_.c_str(); 512 return implementation_name_.c_str();
515 } 513 }
516 514
517 } // namespace webrtc 515 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698