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

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

Issue 3002933002: Reland of Turn off error resilience for VP9 if no spatial or temporal layers are configured and NACK is enabl… (Closed)
Patch Set: Created 3 years, 4 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 | « no previous file | webrtc/video/video_stream_encoder_unittest.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) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 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/modules/video_coding/include/video_codec_initializer.h" 11 #include "webrtc/modules/video_coding/include/video_codec_initializer.h"
12 12
13 #include "webrtc/common_types.h" 13 #include "webrtc/common_types.h"
14 #include "webrtc/common_video/include/video_bitrate_allocator.h" 14 #include "webrtc/common_video/include/video_bitrate_allocator.h"
15 #include "webrtc/modules/video_coding/codecs/vp8/screenshare_layers.h" 15 #include "webrtc/modules/video_coding/codecs/vp8/screenshare_layers.h"
16 #include "webrtc/modules/video_coding/codecs/vp8/simulcast_rate_allocator.h" 16 #include "webrtc/modules/video_coding/codecs/vp8/simulcast_rate_allocator.h"
17 #include "webrtc/modules/video_coding/codecs/vp8/temporal_layers.h" 17 #include "webrtc/modules/video_coding/codecs/vp8/temporal_layers.h"
18 #include "webrtc/modules/video_coding/include/video_coding_defines.h" 18 #include "webrtc/modules/video_coding/include/video_coding_defines.h"
19 #include "webrtc/modules/video_coding/utility/default_video_bitrate_allocator.h" 19 #include "webrtc/modules/video_coding/utility/default_video_bitrate_allocator.h"
20 #include "webrtc/rtc_base/basictypes.h" 20 #include "webrtc/rtc_base/basictypes.h"
21 #include "webrtc/rtc_base/logging.h" 21 #include "webrtc/rtc_base/logging.h"
22 #include "webrtc/system_wrappers/include/clock.h" 22 #include "webrtc/system_wrappers/include/clock.h"
23 23
24 namespace webrtc { 24 namespace webrtc {
25 namespace {
26 bool TemporalLayersConfigured(const std::vector<VideoStream>& streams) {
27 for (const VideoStream& stream : streams) {
28 if (stream.temporal_layer_thresholds_bps.size() > 0)
29 return true;
30 }
31 return false;
32 }
33 } // namespace
25 34
26 bool VideoCodecInitializer::SetupCodec( 35 bool VideoCodecInitializer::SetupCodec(
27 const VideoEncoderConfig& config, 36 const VideoEncoderConfig& config,
28 const VideoSendStream::Config::EncoderSettings settings, 37 const VideoSendStream::Config::EncoderSettings settings,
29 const std::vector<VideoStream>& streams, 38 const std::vector<VideoStream>& streams,
30 bool nack_enabled, 39 bool nack_enabled,
31 VideoCodec* codec, 40 VideoCodec* codec,
32 std::unique_ptr<VideoBitrateAllocator>* bitrate_allocator) { 41 std::unique_ptr<VideoBitrateAllocator>* bitrate_allocator) {
33 *codec = 42 *codec =
34 VideoEncoderConfigToVideoCodec(config, streams, settings.payload_name, 43 VideoEncoderConfigToVideoCodec(config, streams, settings.payload_name,
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 123
115 if (config.encoder_specific_settings) 124 if (config.encoder_specific_settings)
116 config.encoder_specific_settings->FillEncoderSpecificSettings(&video_codec); 125 config.encoder_specific_settings->FillEncoderSpecificSettings(&video_codec);
117 126
118 switch (video_codec.codecType) { 127 switch (video_codec.codecType) {
119 case kVideoCodecVP8: { 128 case kVideoCodecVP8: {
120 if (!config.encoder_specific_settings) 129 if (!config.encoder_specific_settings)
121 *video_codec.VP8() = VideoEncoder::GetDefaultVp8Settings(); 130 *video_codec.VP8() = VideoEncoder::GetDefaultVp8Settings();
122 video_codec.VP8()->numberOfTemporalLayers = static_cast<unsigned char>( 131 video_codec.VP8()->numberOfTemporalLayers = static_cast<unsigned char>(
123 streams.back().temporal_layer_thresholds_bps.size() + 1); 132 streams.back().temporal_layer_thresholds_bps.size() + 1);
124 bool temporal_layers_configured = false; 133
125 for (const VideoStream& stream : streams) { 134 if (nack_enabled && !TemporalLayersConfigured(streams)) {
126 if (stream.temporal_layer_thresholds_bps.size() > 0)
127 temporal_layers_configured = true;
128 }
129 if (nack_enabled && !temporal_layers_configured) {
130 LOG(LS_INFO) << "No temporal layers and nack enabled -> resilience off"; 135 LOG(LS_INFO) << "No temporal layers and nack enabled -> resilience off";
131 video_codec.VP8()->resilience = kResilienceOff; 136 video_codec.VP8()->resilience = kResilienceOff;
132 } 137 }
133 break; 138 break;
134 } 139 }
135 case kVideoCodecVP9: { 140 case kVideoCodecVP9: {
136 if (!config.encoder_specific_settings) 141 if (!config.encoder_specific_settings)
137 *video_codec.VP9() = VideoEncoder::GetDefaultVp9Settings(); 142 *video_codec.VP9() = VideoEncoder::GetDefaultVp9Settings();
138 if (video_codec.mode == kScreensharing && 143 if (video_codec.mode == kScreensharing &&
139 config.encoder_specific_settings) { 144 config.encoder_specific_settings) {
140 video_codec.VP9()->flexibleMode = true; 145 video_codec.VP9()->flexibleMode = true;
141 // For now VP9 screensharing use 1 temporal and 2 spatial layers. 146 // For now VP9 screensharing use 1 temporal and 2 spatial layers.
142 RTC_DCHECK_EQ(1, video_codec.VP9()->numberOfTemporalLayers); 147 RTC_DCHECK_EQ(1, video_codec.VP9()->numberOfTemporalLayers);
143 RTC_DCHECK_EQ(2, video_codec.VP9()->numberOfSpatialLayers); 148 RTC_DCHECK_EQ(2, video_codec.VP9()->numberOfSpatialLayers);
144 } 149 }
145 video_codec.VP9()->numberOfTemporalLayers = static_cast<unsigned char>( 150 video_codec.VP9()->numberOfTemporalLayers = static_cast<unsigned char>(
146 streams.back().temporal_layer_thresholds_bps.size() + 1); 151 streams.back().temporal_layer_thresholds_bps.size() + 1);
152
153 if (nack_enabled && !TemporalLayersConfigured(streams) &&
154 video_codec.VP9()->numberOfSpatialLayers == 1) {
155 LOG(LS_INFO) << "No temporal or spatial layers and nack enabled -> "
156 << "resilience off";
157 video_codec.VP9()->resilienceOn = false;
158 }
147 break; 159 break;
148 } 160 }
149 case kVideoCodecH264: { 161 case kVideoCodecH264: {
150 if (!config.encoder_specific_settings) 162 if (!config.encoder_specific_settings)
151 *video_codec.H264() = VideoEncoder::GetDefaultH264Settings(); 163 *video_codec.H264() = VideoEncoder::GetDefaultH264Settings();
152 break; 164 break;
153 } 165 }
154 default: 166 default:
155 // TODO(pbos): Support encoder_settings codec-agnostically. 167 // TODO(pbos): Support encoder_settings codec-agnostically.
156 RTC_DCHECK(!config.encoder_specific_settings) 168 RTC_DCHECK(!config.encoder_specific_settings)
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 } 236 }
225 if (video_codec.maxBitrate < kEncoderMinBitrateKbps) 237 if (video_codec.maxBitrate < kEncoderMinBitrateKbps)
226 video_codec.maxBitrate = kEncoderMinBitrateKbps; 238 video_codec.maxBitrate = kEncoderMinBitrateKbps;
227 239
228 RTC_DCHECK_GT(streams[0].max_framerate, 0); 240 RTC_DCHECK_GT(streams[0].max_framerate, 0);
229 video_codec.maxFramerate = streams[0].max_framerate; 241 video_codec.maxFramerate = streams[0].max_framerate;
230 return video_codec; 242 return video_codec;
231 } 243 }
232 244
233 } // namespace webrtc 245 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/video/video_stream_encoder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698