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

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

Issue 2995173002: Revert 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
34 25
35 bool VideoCodecInitializer::SetupCodec( 26 bool VideoCodecInitializer::SetupCodec(
36 const VideoEncoderConfig& config, 27 const VideoEncoderConfig& config,
37 const VideoSendStream::Config::EncoderSettings settings, 28 const VideoSendStream::Config::EncoderSettings settings,
38 const std::vector<VideoStream>& streams, 29 const std::vector<VideoStream>& streams,
39 bool nack_enabled, 30 bool nack_enabled,
40 VideoCodec* codec, 31 VideoCodec* codec,
41 std::unique_ptr<VideoBitrateAllocator>* bitrate_allocator) { 32 std::unique_ptr<VideoBitrateAllocator>* bitrate_allocator) {
42 *codec = 33 *codec =
43 VideoEncoderConfigToVideoCodec(config, streams, settings.payload_name, 34 VideoEncoderConfigToVideoCodec(config, streams, settings.payload_name,
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 114
124 if (config.encoder_specific_settings) 115 if (config.encoder_specific_settings)
125 config.encoder_specific_settings->FillEncoderSpecificSettings(&video_codec); 116 config.encoder_specific_settings->FillEncoderSpecificSettings(&video_codec);
126 117
127 switch (video_codec.codecType) { 118 switch (video_codec.codecType) {
128 case kVideoCodecVP8: { 119 case kVideoCodecVP8: {
129 if (!config.encoder_specific_settings) 120 if (!config.encoder_specific_settings)
130 *video_codec.VP8() = VideoEncoder::GetDefaultVp8Settings(); 121 *video_codec.VP8() = VideoEncoder::GetDefaultVp8Settings();
131 video_codec.VP8()->numberOfTemporalLayers = static_cast<unsigned char>( 122 video_codec.VP8()->numberOfTemporalLayers = static_cast<unsigned char>(
132 streams.back().temporal_layer_thresholds_bps.size() + 1); 123 streams.back().temporal_layer_thresholds_bps.size() + 1);
133 124 bool temporal_layers_configured = false;
134 if (nack_enabled && !TemporalLayersConfigured(streams)) { 125 for (const VideoStream& stream : streams) {
126 if (stream.temporal_layer_thresholds_bps.size() > 0)
127 temporal_layers_configured = true;
128 }
129 if (nack_enabled && !temporal_layers_configured) {
135 LOG(LS_INFO) << "No temporal layers and nack enabled -> resilience off"; 130 LOG(LS_INFO) << "No temporal layers and nack enabled -> resilience off";
136 video_codec.VP8()->resilience = kResilienceOff; 131 video_codec.VP8()->resilience = kResilienceOff;
137 } 132 }
138 break; 133 break;
139 } 134 }
140 case kVideoCodecVP9: { 135 case kVideoCodecVP9: {
141 if (!config.encoder_specific_settings) 136 if (!config.encoder_specific_settings)
142 *video_codec.VP9() = VideoEncoder::GetDefaultVp9Settings(); 137 *video_codec.VP9() = VideoEncoder::GetDefaultVp9Settings();
143 if (video_codec.mode == kScreensharing && 138 if (video_codec.mode == kScreensharing &&
144 config.encoder_specific_settings) { 139 config.encoder_specific_settings) {
145 video_codec.VP9()->flexibleMode = true; 140 video_codec.VP9()->flexibleMode = true;
146 // For now VP9 screensharing use 1 temporal and 2 spatial layers. 141 // For now VP9 screensharing use 1 temporal and 2 spatial layers.
147 RTC_DCHECK_EQ(1, video_codec.VP9()->numberOfTemporalLayers); 142 RTC_DCHECK_EQ(1, video_codec.VP9()->numberOfTemporalLayers);
148 RTC_DCHECK_EQ(2, video_codec.VP9()->numberOfSpatialLayers); 143 RTC_DCHECK_EQ(2, video_codec.VP9()->numberOfSpatialLayers);
149 } 144 }
150 video_codec.VP9()->numberOfTemporalLayers = static_cast<unsigned char>( 145 video_codec.VP9()->numberOfTemporalLayers = static_cast<unsigned char>(
151 streams.back().temporal_layer_thresholds_bps.size() + 1); 146 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 }
159 break; 147 break;
160 } 148 }
161 case kVideoCodecH264: { 149 case kVideoCodecH264: {
162 if (!config.encoder_specific_settings) 150 if (!config.encoder_specific_settings)
163 *video_codec.H264() = VideoEncoder::GetDefaultH264Settings(); 151 *video_codec.H264() = VideoEncoder::GetDefaultH264Settings();
164 break; 152 break;
165 } 153 }
166 default: 154 default:
167 // TODO(pbos): Support encoder_settings codec-agnostically. 155 // TODO(pbos): Support encoder_settings codec-agnostically.
168 RTC_DCHECK(!config.encoder_specific_settings) 156 RTC_DCHECK(!config.encoder_specific_settings)
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 } 224 }
237 if (video_codec.maxBitrate < kEncoderMinBitrateKbps) 225 if (video_codec.maxBitrate < kEncoderMinBitrateKbps)
238 video_codec.maxBitrate = kEncoderMinBitrateKbps; 226 video_codec.maxBitrate = kEncoderMinBitrateKbps;
239 227
240 RTC_DCHECK_GT(streams[0].max_framerate, 0); 228 RTC_DCHECK_GT(streams[0].max_framerate, 0);
241 video_codec.maxFramerate = streams[0].max_framerate; 229 video_codec.maxFramerate = streams[0].max_framerate;
242 return video_codec; 230 return video_codec;
243 } 231 }
244 232
245 } // namespace webrtc 233 } // 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