iOS HW encoder: Increase data rate limit
The iOS H264 video toolbox encoder is currently undershooting the intended bitrate. This seems to be caused by the data rate limit property. This CL increases the data rate limit to a set percentage above the intended bitrate to avoid undershooting. The AverageBitRate property is still set to the intended bitrate, which keeps it from overshooting the intended bitrate. BUG=b/28713684 Review-Url: https://codereview.webrtc.org/2177873003 Cr-Commit-Position: refs/heads/master@{#13526}
This commit is contained in:
@ -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,
|
||||
|
||||
Reference in New Issue
Block a user