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

Side by Side Diff: webrtc/media/engine/webrtcvideoengine2.cc

Issue 1810973002: Add support for configuring the number of spatial/temporal layers for VP9 through a field trial. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 9 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
11 #include "webrtc/media/engine/webrtcvideoengine2.h" 11 #include "webrtc/media/engine/webrtcvideoengine2.h"
12 12
13 #include <stdio.h>
13 #include <algorithm> 14 #include <algorithm>
14 #include <set> 15 #include <set>
15 #include <string> 16 #include <string>
16 17
17 #include "webrtc/base/buffer.h" 18 #include "webrtc/base/buffer.h"
18 #include "webrtc/base/logging.h" 19 #include "webrtc/base/logging.h"
19 #include "webrtc/base/stringutils.h" 20 #include "webrtc/base/stringutils.h"
20 #include "webrtc/base/timeutils.h" 21 #include "webrtc/base/timeutils.h"
21 #include "webrtc/base/trace_event.h" 22 #include "webrtc/base/trace_event.h"
22 #include "webrtc/call.h" 23 #include "webrtc/call.h"
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 return 600; 309 return 600;
309 } else if (width * height <= 640 * 480) { 310 } else if (width * height <= 640 * 480) {
310 return 1700; 311 return 1700;
311 } else if (width * height <= 960 * 540) { 312 } else if (width * height <= 960 * 540) {
312 return 2000; 313 return 2000;
313 } else { 314 } else {
314 return 2500; 315 return 2500;
315 } 316 }
316 } 317 }
317 318
319 bool GetVp9LayersFromFieldTrialGroup(int* num_spatial_layers,
320 int* num_temporal_layers) {
321 std::string group = webrtc::field_trial::FindFullName("WebRTC-SupportVP9SVC");
322 if (group.empty())
323 return false;
324
325 if (sscanf(group.c_str(), "EnabledByFlag_%dSL%dTL", num_spatial_layers,
326 num_temporal_layers) != 2) {
327 return false;
328 }
329 const int kMaxSpatialLayers = 3;
330 if (*num_spatial_layers > kMaxSpatialLayers || *num_spatial_layers < 1)
331 return false;
332
333 const int kMaxTemporalLayers = 3;
334 if (*num_temporal_layers > kMaxTemporalLayers || *num_temporal_layers < 1)
335 return false;
336
337 return true;
338 }
339
340 int GetDefaultVp9SpatialLayers() {
341 int num_sl;
342 int num_tl;
343 if (GetVp9LayersFromFieldTrialGroup(&num_sl, &num_tl)) {
344 return num_sl;
345 }
346 return 1;
347 }
348
349 int GetDefaultVp9TemporalLayers() {
350 int num_sl;
351 int num_tl;
352 if (GetVp9LayersFromFieldTrialGroup(&num_sl, &num_tl)) {
353 return num_tl;
354 }
355 return 1;
356 }
318 } // namespace 357 } // namespace
319 358
320 // Constants defined in webrtc/media/engine/constants.h 359 // Constants defined in webrtc/media/engine/constants.h
321 // TODO(pbos): Move these to a separate constants.cc file. 360 // TODO(pbos): Move these to a separate constants.cc file.
322 const int kMinVideoBitrate = 30; 361 const int kMinVideoBitrate = 30;
323 const int kStartVideoBitrate = 300; 362 const int kStartVideoBitrate = 300;
324 363
325 const int kVideoMtu = 1200; 364 const int kVideoMtu = 1200;
326 const int kVideoRtpBufferSize = 65536; 365 const int kVideoRtpBufferSize = 65536;
327 366
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 encoder_settings_.vp8 = webrtc::VideoEncoder::GetDefaultVp8Settings(); 475 encoder_settings_.vp8 = webrtc::VideoEncoder::GetDefaultVp8Settings();
437 encoder_settings_.vp8.automaticResizeOn = automatic_resize; 476 encoder_settings_.vp8.automaticResizeOn = automatic_resize;
438 // VP8 denoising is enabled by default. 477 // VP8 denoising is enabled by default.
439 encoder_settings_.vp8.denoisingOn = 478 encoder_settings_.vp8.denoisingOn =
440 codec_default_denoising ? true : denoising; 479 codec_default_denoising ? true : denoising;
441 encoder_settings_.vp8.frameDroppingOn = frame_dropping; 480 encoder_settings_.vp8.frameDroppingOn = frame_dropping;
442 return &encoder_settings_.vp8; 481 return &encoder_settings_.vp8;
443 } 482 }
444 if (CodecNamesEq(codec.name, kVp9CodecName)) { 483 if (CodecNamesEq(codec.name, kVp9CodecName)) {
445 encoder_settings_.vp9 = webrtc::VideoEncoder::GetDefaultVp9Settings(); 484 encoder_settings_.vp9 = webrtc::VideoEncoder::GetDefaultVp9Settings();
485 encoder_settings_.vp9.numberOfSpatialLayers = GetDefaultVp9SpatialLayers();
pbos-webrtc 2016/03/17 14:34:38 I don't think this should apply to screenshare, sh
åsapersson 2016/03/17 16:57:34 Ok, changed so it is not set for screenshare for n
446 // VP9 denoising is disabled by default. 486 // VP9 denoising is disabled by default.
447 encoder_settings_.vp9.denoisingOn = 487 encoder_settings_.vp9.denoisingOn =
448 codec_default_denoising ? false : denoising; 488 codec_default_denoising ? false : denoising;
449 encoder_settings_.vp9.frameDroppingOn = frame_dropping; 489 encoder_settings_.vp9.frameDroppingOn = frame_dropping;
450 return &encoder_settings_.vp9; 490 return &encoder_settings_.vp9;
451 } 491 }
452 return NULL; 492 return NULL;
453 } 493 }
454 494
455 DefaultUnsignalledSsrcHandler::DefaultUnsignalledSsrcHandler() 495 DefaultUnsignalledSsrcHandler::DefaultUnsignalledSsrcHandler()
(...skipping 1407 matching lines...) Expand 10 before | Expand all | Expand 10 after
1863 // For screenshare in conference mode, tl0 and tl1 bitrates are piggybacked 1903 // For screenshare in conference mode, tl0 and tl1 bitrates are piggybacked
1864 // on the VideoCodec struct as target and max bitrates, respectively. 1904 // on the VideoCodec struct as target and max bitrates, respectively.
1865 // See eg. webrtc::VP8EncoderImpl::SetRates(). 1905 // See eg. webrtc::VP8EncoderImpl::SetRates().
1866 encoder_config.streams[0].target_bitrate_bps = 1906 encoder_config.streams[0].target_bitrate_bps =
1867 config.tl0_bitrate_kbps * 1000; 1907 config.tl0_bitrate_kbps * 1000;
1868 encoder_config.streams[0].max_bitrate_bps = config.tl1_bitrate_kbps * 1000; 1908 encoder_config.streams[0].max_bitrate_bps = config.tl1_bitrate_kbps * 1000;
1869 encoder_config.streams[0].temporal_layer_thresholds_bps.clear(); 1909 encoder_config.streams[0].temporal_layer_thresholds_bps.clear();
1870 encoder_config.streams[0].temporal_layer_thresholds_bps.push_back( 1910 encoder_config.streams[0].temporal_layer_thresholds_bps.push_back(
1871 config.tl0_bitrate_kbps * 1000); 1911 config.tl0_bitrate_kbps * 1000);
1872 } 1912 }
1913 if (CodecNamesEq(codec.name, kVp9CodecName) &&
1914 encoder_config.streams.size() == 1) {
1915 encoder_config.streams[0].temporal_layer_thresholds_bps.resize(
1916 GetDefaultVp9TemporalLayers() - 1);
1917 }
1873 return encoder_config; 1918 return encoder_config;
1874 } 1919 }
1875 1920
1876 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetDimensions( 1921 void WebRtcVideoChannel2::WebRtcVideoSendStream::SetDimensions(
1877 int width, 1922 int width,
1878 int height) { 1923 int height) {
1879 if (last_dimensions_.width == width && last_dimensions_.height == height && 1924 if (last_dimensions_.width == width && last_dimensions_.height == height &&
1880 !pending_encoder_reconfiguration_) { 1925 !pending_encoder_reconfiguration_) {
1881 // Configured using the same parameters, do not reconfigure. 1926 // Configured using the same parameters, do not reconfigure.
1882 return; 1927 return;
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
2531 rtx_mapping[video_codecs[i].codec.id] != 2576 rtx_mapping[video_codecs[i].codec.id] !=
2532 fec_settings.red_payload_type) { 2577 fec_settings.red_payload_type) {
2533 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; 2578 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id];
2534 } 2579 }
2535 } 2580 }
2536 2581
2537 return video_codecs; 2582 return video_codecs;
2538 } 2583 }
2539 2584
2540 } // namespace cricket 2585 } // namespace cricket
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698