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

Side by Side Diff: webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.cc

Issue 2489843002: Revert of Extract bitrate allocation of spatial/temporal layers out of codec impl. (Closed)
Patch Set: Created 4 years, 1 month 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 // Copy the entire layer's data (including start codes). 145 // Copy the entire layer's data (including start codes).
146 memcpy(encoded_image->_buffer + encoded_image->_length, 146 memcpy(encoded_image->_buffer + encoded_image->_length,
147 layerInfo.pBsBuf, 147 layerInfo.pBsBuf,
148 layer_len); 148 layer_len);
149 encoded_image->_length += layer_len; 149 encoded_image->_length += layer_len;
150 } 150 }
151 } 151 }
152 152
153 H264EncoderImpl::H264EncoderImpl() 153 H264EncoderImpl::H264EncoderImpl()
154 : openh264_encoder_(nullptr), 154 : openh264_encoder_(nullptr),
155 width_(0),
156 height_(0),
157 max_frame_rate_(0.0f),
158 target_bps_(0),
159 max_bps_(0),
160 mode_(kRealtimeVideo),
161 frame_dropping_on_(false),
162 key_frame_interval_(0),
163 number_of_cores_(0), 155 number_of_cores_(0),
164 encoded_image_callback_(nullptr), 156 encoded_image_callback_(nullptr),
165 has_reported_init_(false), 157 has_reported_init_(false),
166 has_reported_error_(false) {} 158 has_reported_error_(false) {}
167 159
168 H264EncoderImpl::~H264EncoderImpl() { 160 H264EncoderImpl::~H264EncoderImpl() {
169 Release(); 161 Release();
170 } 162 }
171 163
172 int32_t H264EncoderImpl::InitEncode(const VideoCodec* codec_settings, 164 int32_t H264EncoderImpl::InitEncode(const VideoCodec* codec_settings,
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 encoded_image_buffer_.reset(); 256 encoded_image_buffer_.reset();
265 return WEBRTC_VIDEO_CODEC_OK; 257 return WEBRTC_VIDEO_CODEC_OK;
266 } 258 }
267 259
268 int32_t H264EncoderImpl::RegisterEncodeCompleteCallback( 260 int32_t H264EncoderImpl::RegisterEncodeCompleteCallback(
269 EncodedImageCallback* callback) { 261 EncodedImageCallback* callback) {
270 encoded_image_callback_ = callback; 262 encoded_image_callback_ = callback;
271 return WEBRTC_VIDEO_CODEC_OK; 263 return WEBRTC_VIDEO_CODEC_OK;
272 } 264 }
273 265
274 int32_t H264EncoderImpl::SetRateAllocation( 266 int32_t H264EncoderImpl::SetRates(uint32_t bitrate, uint32_t framerate) {
275 const BitrateAllocation& bitrate_allocation, 267 if (bitrate <= 0 || framerate <= 0) {
276 uint32_t framerate) {
277 if (bitrate_allocation.get_sum_bps() <= 0 || framerate <= 0)
278 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; 268 return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
279 269 }
280 target_bps_ = bitrate_allocation.get_sum_bps(); 270 target_bps_ = bitrate * 1000;
281 max_frame_rate_ = static_cast<float>(framerate); 271 max_frame_rate_ = static_cast<float>(framerate);
282 quality_scaler_.ReportFramerate(framerate); 272 quality_scaler_.ReportFramerate(framerate);
283 273
284 SBitrateInfo target_bitrate; 274 SBitrateInfo target_bitrate;
285 memset(&target_bitrate, 0, sizeof(SBitrateInfo)); 275 memset(&target_bitrate, 0, sizeof(SBitrateInfo));
286 target_bitrate.iLayer = SPATIAL_LAYER_ALL, 276 target_bitrate.iLayer = SPATIAL_LAYER_ALL,
287 target_bitrate.iBitrate = target_bps_; 277 target_bitrate.iBitrate = target_bps_;
288 openh264_encoder_->SetOption(ENCODER_OPTION_BITRATE, 278 openh264_encoder_->SetOption(ENCODER_OPTION_BITRATE,
289 &target_bitrate); 279 &target_bitrate);
290 openh264_encoder_->SetOption(ENCODER_OPTION_FRAME_RATE, &max_frame_rate_); 280 openh264_encoder_->SetOption(ENCODER_OPTION_FRAME_RATE, &max_frame_rate_);
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 486
497 int32_t H264EncoderImpl::SetPeriodicKeyFrames(bool enable) { 487 int32_t H264EncoderImpl::SetPeriodicKeyFrames(bool enable) {
498 return WEBRTC_VIDEO_CODEC_OK; 488 return WEBRTC_VIDEO_CODEC_OK;
499 } 489 }
500 490
501 void H264EncoderImpl::OnDroppedFrame() { 491 void H264EncoderImpl::OnDroppedFrame() {
502 quality_scaler_.ReportDroppedFrame(); 492 quality_scaler_.ReportDroppedFrame();
503 } 493 }
504 494
505 } // namespace webrtc 495 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.h ('k') | webrtc/modules/video_coding/codecs/i420/include/i420.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698