OLD | NEW |
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 24 matching lines...) Expand all Loading... |
35 #include "webrtc/rtc_base/trace_event.h" | 35 #include "webrtc/rtc_base/trace_event.h" |
36 #include "webrtc/system_wrappers/include/clock.h" | 36 #include "webrtc/system_wrappers/include/clock.h" |
37 #include "webrtc/system_wrappers/include/field_trial.h" | 37 #include "webrtc/system_wrappers/include/field_trial.h" |
38 #include "webrtc/system_wrappers/include/metrics.h" | 38 #include "webrtc/system_wrappers/include/metrics.h" |
39 | 39 |
40 namespace webrtc { | 40 namespace webrtc { |
41 namespace { | 41 namespace { |
42 | 42 |
43 const char kVp8PostProcArmFieldTrial[] = "WebRTC-VP8-Postproc-Arm"; | 43 const char kVp8PostProcArmFieldTrial[] = "WebRTC-VP8-Postproc-Arm"; |
44 const char kVp8GfBoostFieldTrial[] = "WebRTC-VP8-GfBoost"; | 44 const char kVp8GfBoostFieldTrial[] = "WebRTC-VP8-GfBoost"; |
| 45 const char kVp8ForceFallbackEncoderFieldTrial[] = |
| 46 "WebRTC-VP8-Forced-Fallback-Encoder"; |
45 | 47 |
46 const int kTokenPartitions = VP8_ONE_TOKENPARTITION; | 48 const int kTokenPartitions = VP8_ONE_TOKENPARTITION; |
47 enum { kVp8ErrorPropagationTh = 30 }; | 49 enum { kVp8ErrorPropagationTh = 30 }; |
48 enum { kVp832ByteAlign = 32 }; | 50 enum { kVp832ByteAlign = 32 }; |
49 | 51 |
50 // VP8 denoiser states. | 52 // VP8 denoiser states. |
51 enum denoiserState { | 53 enum denoiserState { |
52 kDenoiserOff, | 54 kDenoiserOff, |
53 kDenoiserOnYOnly, | 55 kDenoiserOnYOnly, |
54 kDenoiserOnYUV, | 56 kDenoiserOnYUV, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 | 105 |
104 int NumStreamsDisabled(const std::vector<bool>& streams) { | 106 int NumStreamsDisabled(const std::vector<bool>& streams) { |
105 int num_disabled = 0; | 107 int num_disabled = 0; |
106 for (bool stream : streams) { | 108 for (bool stream : streams) { |
107 if (!stream) | 109 if (!stream) |
108 ++num_disabled; | 110 ++num_disabled; |
109 } | 111 } |
110 return num_disabled; | 112 return num_disabled; |
111 } | 113 } |
112 | 114 |
| 115 rtc::Optional<int> GetForcedFallbackMinPixelsFromFieldTrialGroup() { |
| 116 if (!webrtc::field_trial::IsEnabled(kVp8ForceFallbackEncoderFieldTrial)) |
| 117 return rtc::Optional<int>(); |
| 118 |
| 119 std::string group = |
| 120 webrtc::field_trial::FindFullName(kVp8ForceFallbackEncoderFieldTrial); |
| 121 if (group.empty()) |
| 122 return rtc::Optional<int>(); |
| 123 |
| 124 int low_kbps; |
| 125 int high_kbps; |
| 126 int min_low_ms; |
| 127 int min_pixels; |
| 128 if (sscanf(group.c_str(), "Enabled-%d,%d,%d,%d", &low_kbps, &high_kbps, |
| 129 &min_low_ms, &min_pixels) != 4) { |
| 130 return rtc::Optional<int>(); |
| 131 } |
| 132 |
| 133 if (min_low_ms <= 0 || min_pixels <= 0 || low_kbps <= 0 || |
| 134 high_kbps <= low_kbps) { |
| 135 return rtc::Optional<int>(); |
| 136 } |
| 137 return rtc::Optional<int>(min_pixels); |
| 138 } |
| 139 |
113 bool GetGfBoostPercentageFromFieldTrialGroup(int* boost_percentage) { | 140 bool GetGfBoostPercentageFromFieldTrialGroup(int* boost_percentage) { |
114 std::string group = webrtc::field_trial::FindFullName(kVp8GfBoostFieldTrial); | 141 std::string group = webrtc::field_trial::FindFullName(kVp8GfBoostFieldTrial); |
115 if (group.empty()) | 142 if (group.empty()) |
116 return false; | 143 return false; |
117 | 144 |
118 if (sscanf(group.c_str(), "Enabled-%d", boost_percentage) != 1) | 145 if (sscanf(group.c_str(), "Enabled-%d", boost_percentage) != 1) |
119 return false; | 146 return false; |
120 | 147 |
121 if (*boost_percentage < 0 || *boost_percentage > 100) | 148 if (*boost_percentage < 0 || *boost_percentage > 100) |
122 return false; | 149 return false; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 if ((references.arf_buffer_flags & TemporalLayers::kUpdate) == 0) | 201 if ((references.arf_buffer_flags & TemporalLayers::kUpdate) == 0) |
175 flags |= VP8_EFLAG_NO_UPD_ARF; | 202 flags |= VP8_EFLAG_NO_UPD_ARF; |
176 if (references.freeze_entropy) | 203 if (references.freeze_entropy) |
177 flags |= VP8_EFLAG_NO_UPD_ENTROPY; | 204 flags |= VP8_EFLAG_NO_UPD_ENTROPY; |
178 | 205 |
179 return flags; | 206 return flags; |
180 } | 207 } |
181 | 208 |
182 VP8EncoderImpl::VP8EncoderImpl() | 209 VP8EncoderImpl::VP8EncoderImpl() |
183 : use_gf_boost_(webrtc::field_trial::IsEnabled(kVp8GfBoostFieldTrial)), | 210 : use_gf_boost_(webrtc::field_trial::IsEnabled(kVp8GfBoostFieldTrial)), |
| 211 min_pixels_per_frame_(GetForcedFallbackMinPixelsFromFieldTrialGroup()), |
184 encoded_complete_callback_(nullptr), | 212 encoded_complete_callback_(nullptr), |
185 inited_(false), | 213 inited_(false), |
186 timestamp_(0), | 214 timestamp_(0), |
187 qp_max_(56), // Setting for max quantizer. | 215 qp_max_(56), // Setting for max quantizer. |
188 cpu_speed_default_(-6), | 216 cpu_speed_default_(-6), |
189 number_of_cores_(0), | 217 number_of_cores_(0), |
190 rc_max_intra_target_(0), | 218 rc_max_intra_target_(0), |
191 key_frame_request_(kMaxSimulcastStreams, false) { | 219 key_frame_request_(kMaxSimulcastStreams, false) { |
192 Random random(rtc::TimeMicros()); | 220 Random random(rtc::TimeMicros()); |
193 picture_id_.reserve(kMaxSimulcastStreams); | 221 picture_id_.reserve(kMaxSimulcastStreams); |
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
928 } | 956 } |
929 } | 957 } |
930 } | 958 } |
931 return result; | 959 return result; |
932 } | 960 } |
933 | 961 |
934 VideoEncoder::ScalingSettings VP8EncoderImpl::GetScalingSettings() const { | 962 VideoEncoder::ScalingSettings VP8EncoderImpl::GetScalingSettings() const { |
935 const bool enable_scaling = encoders_.size() == 1 && | 963 const bool enable_scaling = encoders_.size() == 1 && |
936 configurations_[0].rc_dropframe_thresh > 0 && | 964 configurations_[0].rc_dropframe_thresh > 0 && |
937 codec_.VP8().automaticResizeOn; | 965 codec_.VP8().automaticResizeOn; |
| 966 if (enable_scaling && min_pixels_per_frame_) { |
| 967 return VideoEncoder::ScalingSettings(enable_scaling, |
| 968 *min_pixels_per_frame_); |
| 969 } |
938 return VideoEncoder::ScalingSettings(enable_scaling); | 970 return VideoEncoder::ScalingSettings(enable_scaling); |
939 } | 971 } |
940 | 972 |
941 int VP8EncoderImpl::SetChannelParameters(uint32_t packetLoss, int64_t rtt) { | 973 int VP8EncoderImpl::SetChannelParameters(uint32_t packetLoss, int64_t rtt) { |
942 return WEBRTC_VIDEO_CODEC_OK; | 974 return WEBRTC_VIDEO_CODEC_OK; |
943 } | 975 } |
944 | 976 |
945 int VP8EncoderImpl::RegisterEncodeCompleteCallback( | 977 int VP8EncoderImpl::RegisterEncodeCompleteCallback( |
946 EncodedImageCallback* callback) { | 978 EncodedImageCallback* callback) { |
947 encoded_complete_callback_ = callback; | 979 encoded_complete_callback_ = callback; |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1218 buffer_pool_.Release(); | 1250 buffer_pool_.Release(); |
1219 inited_ = false; | 1251 inited_ = false; |
1220 return WEBRTC_VIDEO_CODEC_OK; | 1252 return WEBRTC_VIDEO_CODEC_OK; |
1221 } | 1253 } |
1222 | 1254 |
1223 const char* VP8DecoderImpl::ImplementationName() const { | 1255 const char* VP8DecoderImpl::ImplementationName() const { |
1224 return "libvpx"; | 1256 return "libvpx"; |
1225 } | 1257 } |
1226 | 1258 |
1227 } // namespace webrtc | 1259 } // namespace webrtc |
OLD | NEW |