OLD | NEW |
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 15 matching lines...) Expand all Loading... |
26 #include "webrtc/base/logging.h" | 26 #include "webrtc/base/logging.h" |
27 #include "webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_nalu.h" | 27 #include "webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_nalu.h" |
28 #include "webrtc/system_wrappers/include/clock.h" | 28 #include "webrtc/system_wrappers/include/clock.h" |
29 | 29 |
30 namespace internal { | 30 namespace internal { |
31 | 31 |
32 // The ratio between kVTCompressionPropertyKey_DataRateLimits and | 32 // The ratio between kVTCompressionPropertyKey_DataRateLimits and |
33 // kVTCompressionPropertyKey_AverageBitRate. The data rate limit is set higher | 33 // kVTCompressionPropertyKey_AverageBitRate. The data rate limit is set higher |
34 // than the average bit rate to avoid undershooting the target. | 34 // than the average bit rate to avoid undershooting the target. |
35 const float kLimitToAverageBitRateFactor = 1.5f; | 35 const float kLimitToAverageBitRateFactor = 1.5f; |
| 36 const int kLowH264QpThreshold = 28; |
| 37 const int kHighH264QpThreshold = 39; |
36 | 38 |
37 // Convenience function for creating a dictionary. | 39 // Convenience function for creating a dictionary. |
38 inline CFDictionaryRef CreateCFDictionary(CFTypeRef* keys, | 40 inline CFDictionaryRef CreateCFDictionary(CFTypeRef* keys, |
39 CFTypeRef* values, | 41 CFTypeRef* values, |
40 size_t size) { | 42 size_t size) { |
41 return CFDictionaryCreate(kCFAllocatorDefault, keys, values, size, | 43 return CFDictionaryCreate(kCFAllocatorDefault, keys, values, size, |
42 &kCFTypeDictionaryKeyCallBacks, | 44 &kCFTypeDictionaryKeyCallBacks, |
43 &kCFTypeDictionaryValueCallBacks); | 45 &kCFTypeDictionaryValueCallBacks); |
44 } | 46 } |
45 | 47 |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 DestroyCompressionSession(); | 227 DestroyCompressionSession(); |
226 } | 228 } |
227 | 229 |
228 int H264VideoToolboxEncoder::InitEncode(const VideoCodec* codec_settings, | 230 int H264VideoToolboxEncoder::InitEncode(const VideoCodec* codec_settings, |
229 int number_of_cores, | 231 int number_of_cores, |
230 size_t max_payload_size) { | 232 size_t max_payload_size) { |
231 RTC_DCHECK(codec_settings); | 233 RTC_DCHECK(codec_settings); |
232 RTC_DCHECK_EQ(codec_settings->codecType, kVideoCodecH264); | 234 RTC_DCHECK_EQ(codec_settings->codecType, kVideoCodecH264); |
233 { | 235 { |
234 rtc::CritScope lock(&quality_scaler_crit_); | 236 rtc::CritScope lock(&quality_scaler_crit_); |
235 quality_scaler_.Init(QualityScaler::kLowH264QpThreshold, | 237 quality_scaler_.Init(kLowH264QpThreshold, |
236 QualityScaler::kBadH264QpThreshold, | 238 kHighH264QpThreshold, |
237 codec_settings->startBitrate, codec_settings->width, | 239 codec_settings->startBitrate, codec_settings->width, |
238 codec_settings->height, codec_settings->maxFramerate); | 240 codec_settings->height, codec_settings->maxFramerate); |
239 QualityScaler::Resolution res = quality_scaler_.GetScaledResolution(); | 241 QualityScaler::Resolution res = quality_scaler_.GetScaledResolution(); |
240 // TODO(tkchin): We may need to enforce width/height dimension restrictions | 242 // TODO(tkchin): We may need to enforce width/height dimension restrictions |
241 // to match what the encoder supports. | 243 // to match what the encoder supports. |
242 width_ = res.width; | 244 width_ = res.width; |
243 height_ = res.height; | 245 height_ = res.height; |
244 } | 246 } |
245 // We can only set average bitrate on the HW encoder. | 247 // We can only set average bitrate on the HW encoder. |
246 target_bitrate_bps_ = codec_settings->startBitrate; | 248 target_bitrate_bps_ = codec_settings->startBitrate; |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
627 if (result != 0) { | 629 if (result != 0) { |
628 LOG(LS_ERROR) << "Encode callback failed: " << result; | 630 LOG(LS_ERROR) << "Encode callback failed: " << result; |
629 return; | 631 return; |
630 } | 632 } |
631 bitrate_adjuster_.Update(frame._size); | 633 bitrate_adjuster_.Update(frame._size); |
632 } | 634 } |
633 | 635 |
634 } // namespace webrtc | 636 } // namespace webrtc |
635 | 637 |
636 #endif // defined(WEBRTC_VIDEO_TOOLBOX_SUPPORTED) | 638 #endif // defined(WEBRTC_VIDEO_TOOLBOX_SUPPORTED) |
OLD | NEW |