| Index: webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_encoder.cc
|
| diff --git a/webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_encoder.cc b/webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_encoder.cc
|
| index bbf3f0f8f62ce90f4375770db4361a6b833e9707..4cbe2cd0bff1df04eef1ee04190311fd6fbc7541 100644
|
| --- a/webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_encoder.cc
|
| +++ b/webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_encoder.cc
|
| @@ -28,6 +28,11 @@
|
|
|
| namespace internal {
|
|
|
| +// The ratio between kVTCompressionPropertyKey_DataRateLimits and
|
| +// kVTCompressionPropertyKey_AverageBitRate. The data rate limit is set higher
|
| +// than the average bit rate to avoid undershooting the target.
|
| +const float kLimitToAverageBitRateFactor = 1.5f;
|
| +
|
| // Convenience function for creating a dictionary.
|
| inline CFDictionaryRef CreateCFDictionary(CFTypeRef* keys,
|
| CFTypeRef* values,
|
| @@ -519,11 +524,12 @@ void H264VideoToolboxEncoder::SetEncoderBitrateBps(uint32_t bitrate_bps) {
|
| bitrate_bps);
|
|
|
| // TODO(tkchin): Add a helper method to set array value.
|
| - int64_t bytes_per_second_value = bitrate_bps / 8;
|
| + int64_t data_limit_bytes_per_second_value = static_cast<int64_t>(
|
| + bitrate_bps * internal::kLimitToAverageBitRateFactor / 8);
|
| CFNumberRef bytes_per_second =
|
| CFNumberCreate(kCFAllocatorDefault,
|
| kCFNumberSInt64Type,
|
| - &bytes_per_second_value);
|
| + &data_limit_bytes_per_second_value);
|
| int64_t one_second_value = 1;
|
| CFNumberRef one_second =
|
| CFNumberCreate(kCFAllocatorDefault,
|
|
|