OLD | NEW |
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 */ |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 cpu_speed_(3), | 70 cpu_speed_(3), |
71 rc_max_intra_target_(0), | 71 rc_max_intra_target_(0), |
72 encoder_(NULL), | 72 encoder_(NULL), |
73 config_(NULL), | 73 config_(NULL), |
74 raw_(NULL), | 74 raw_(NULL), |
75 input_image_(NULL), | 75 input_image_(NULL), |
76 tl0_pic_idx_(0), | 76 tl0_pic_idx_(0), |
77 frames_since_kf_(0), | 77 frames_since_kf_(0), |
78 num_temporal_layers_(0), | 78 num_temporal_layers_(0), |
79 num_spatial_layers_(0), | 79 num_spatial_layers_(0), |
80 is_flexible_mode_(false), | |
81 frames_encoded_(0), | 80 frames_encoded_(0), |
82 // Use two spatial when screensharing with flexible mode. | 81 // Use two spatial when screensharing with flexible mode. |
83 spatial_layer_(new ScreenshareLayersVP9(2)) { | 82 spatial_layer_(new ScreenshareLayersVP9(2)) { |
84 memset(&codec_, 0, sizeof(codec_)); | 83 memset(&codec_, 0, sizeof(codec_)); |
85 memset(&svc_internal_.svc_params, 0, sizeof(vpx_svc_extra_cfg_t)); | 84 memset(&svc_internal_.svc_params, 0, sizeof(vpx_svc_extra_cfg_t)); |
86 uint32_t seed = rtc::Time32(); | 85 uint32_t seed = rtc::Time32(); |
87 srand(seed); | 86 srand(seed); |
88 } | 87 } |
89 | 88 |
90 VP9EncoderImpl::~VP9EncoderImpl() { | 89 VP9EncoderImpl::~VP9EncoderImpl() { |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 // For now, temporal layers only supported when having one spatial layer. | 186 // For now, temporal layers only supported when having one spatial layer. |
188 if (num_spatial_layers_ == 1) { | 187 if (num_spatial_layers_ == 1) { |
189 for (i = 0; i < num_temporal_layers_; ++i) { | 188 for (i = 0; i < num_temporal_layers_; ++i) { |
190 config_->ts_target_bitrate[i] = config_->layer_target_bitrate[i]; | 189 config_->ts_target_bitrate[i] = config_->layer_target_bitrate[i]; |
191 } | 190 } |
192 } | 191 } |
193 | 192 |
194 return true; | 193 return true; |
195 } | 194 } |
196 | 195 |
197 int VP9EncoderImpl::SetRateAllocation( | 196 int VP9EncoderImpl::SetRates(uint32_t new_bitrate_kbit, |
198 const BitrateAllocation& bitrate_allocation, | 197 uint32_t new_framerate) { |
199 uint32_t frame_rate) { | |
200 if (!inited_) { | 198 if (!inited_) { |
201 return WEBRTC_VIDEO_CODEC_UNINITIALIZED; | 199 return WEBRTC_VIDEO_CODEC_UNINITIALIZED; |
202 } | 200 } |
203 if (encoder_->err) { | 201 if (encoder_->err) { |
204 return WEBRTC_VIDEO_CODEC_ERROR; | 202 return WEBRTC_VIDEO_CODEC_ERROR; |
205 } | 203 } |
206 if (frame_rate < 1) { | 204 if (new_framerate < 1) { |
207 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; | 205 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; |
208 } | 206 } |
209 // Update bit rate | 207 // Update bit rate |
210 if (codec_.maxBitrate > 0 && | 208 if (codec_.maxBitrate > 0 && new_bitrate_kbit > codec_.maxBitrate) { |
211 bitrate_allocation.get_sum_kbps() > codec_.maxBitrate) { | 209 new_bitrate_kbit = codec_.maxBitrate; |
212 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; | |
213 } | 210 } |
214 | 211 config_->rc_target_bitrate = new_bitrate_kbit; |
215 // TODO(sprang): Actually use BitrateAllocation layer info. | 212 codec_.maxFramerate = new_framerate; |
216 config_->rc_target_bitrate = bitrate_allocation.get_sum_kbps(); | 213 spatial_layer_->ConfigureBitrate(new_bitrate_kbit, 0); |
217 codec_.maxFramerate = frame_rate; | |
218 spatial_layer_->ConfigureBitrate(bitrate_allocation.get_sum_kbps(), 0); | |
219 | 214 |
220 if (!SetSvcRates()) { | 215 if (!SetSvcRates()) { |
221 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; | 216 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; |
222 } | 217 } |
223 | 218 |
224 // Update encoder context | 219 // Update encoder context |
225 if (vpx_codec_enc_config_set(encoder_, config_)) { | 220 if (vpx_codec_enc_config_set(encoder_, config_)) { |
226 return WEBRTC_VIDEO_CODEC_ERROR; | 221 return WEBRTC_VIDEO_CODEC_ERROR; |
227 } | 222 } |
228 return WEBRTC_VIDEO_CODEC_OK; | 223 return WEBRTC_VIDEO_CODEC_OK; |
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
999 frame_buffer_pool_.ClearPool(); | 994 frame_buffer_pool_.ClearPool(); |
1000 inited_ = false; | 995 inited_ = false; |
1001 return WEBRTC_VIDEO_CODEC_OK; | 996 return WEBRTC_VIDEO_CODEC_OK; |
1002 } | 997 } |
1003 | 998 |
1004 const char* VP9DecoderImpl::ImplementationName() const { | 999 const char* VP9DecoderImpl::ImplementationName() const { |
1005 return "libvpx"; | 1000 return "libvpx"; |
1006 } | 1001 } |
1007 | 1002 |
1008 } // namespace webrtc | 1003 } // namespace webrtc |
OLD | NEW |