OLD | NEW |
1 /* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 1 /* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
2 * | 2 * |
3 * Use of this source code is governed by a BSD-style license | 3 * Use of this source code is governed by a BSD-style license |
4 * that can be found in the LICENSE file in the root of the source | 4 * that can be found in the LICENSE file in the root of the source |
5 * tree. An additional intellectual property rights grant can be found | 5 * tree. An additional intellectual property rights grant can be found |
6 * in the file PATENTS. All contributing project authors may | 6 * in the file PATENTS. All contributing project authors may |
7 * be found in the AUTHORS file in the root of the source tree. | 7 * be found in the AUTHORS file in the root of the source tree. |
8 */ | 8 */ |
9 | 9 |
10 #include <stdlib.h> | 10 #include <stdlib.h> |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 bitrates.push_back(static_cast<uint32_t>(layer_bitrate + 0.5)); | 172 bitrates.push_back(static_cast<uint32_t>(layer_bitrate + 0.5)); |
173 } | 173 } |
174 new_bitrates_kbps_ = rtc::Optional<std::vector<uint32_t>>(bitrates); | 174 new_bitrates_kbps_ = rtc::Optional<std::vector<uint32_t>>(bitrates); |
175 | 175 |
176 // Allocation table is of aggregates, transform to individual rates. | 176 // Allocation table is of aggregates, transform to individual rates. |
177 uint32_t sum = 0; | 177 uint32_t sum = 0; |
178 for (int i = 0; i < num_layers; ++i) { | 178 for (int i = 0; i < num_layers; ++i) { |
179 uint32_t layer_bitrate = bitrates[i]; | 179 uint32_t layer_bitrate = bitrates[i]; |
180 RTC_DCHECK_LE(sum, bitrates[i]); | 180 RTC_DCHECK_LE(sum, bitrates[i]); |
181 bitrates[i] -= sum; | 181 bitrates[i] -= sum; |
182 sum += layer_bitrate; | 182 sum = layer_bitrate; |
183 | 183 |
184 if (sum == static_cast<uint32_t>(bitrate_kbps)) { | 184 if (sum >= static_cast<uint32_t>(bitrate_kbps)) { |
185 // Sum adds up; any subsequent layers will be 0. | 185 // Sum adds up; any subsequent layers will be 0. |
186 bitrates.resize(i); | 186 bitrates.resize(i + 1); |
187 break; | 187 break; |
188 } | 188 } |
189 } | 189 } |
190 | 190 |
191 return bitrates; | 191 return bitrates; |
192 } | 192 } |
193 | 193 |
194 bool UpdateConfiguration(vpx_codec_enc_cfg_t* cfg) override { | 194 bool UpdateConfiguration(vpx_codec_enc_cfg_t* cfg) override { |
195 if (!new_bitrates_kbps_) | 195 if (!new_bitrates_kbps_) |
196 return false; | 196 return false; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 int simulcast_id, | 302 int simulcast_id, |
303 int max_temporal_layers, | 303 int max_temporal_layers, |
304 uint8_t initial_tl0_pic_idx) const { | 304 uint8_t initial_tl0_pic_idx) const { |
305 TemporalLayers* tl = | 305 TemporalLayers* tl = |
306 new RealTimeTemporalLayers(max_temporal_layers, initial_tl0_pic_idx); | 306 new RealTimeTemporalLayers(max_temporal_layers, initial_tl0_pic_idx); |
307 if (listener_) | 307 if (listener_) |
308 listener_->OnTemporalLayersCreated(simulcast_id, tl); | 308 listener_->OnTemporalLayersCreated(simulcast_id, tl); |
309 return tl; | 309 return tl; |
310 } | 310 } |
311 } // namespace webrtc | 311 } // namespace webrtc |
OLD | NEW |