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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 sampleBuffer:(CMSampleBufferRef)sampleBuffer | 42 sampleBuffer:(CMSampleBufferRef)sampleBuffer |
43 codecSpecificInfo:(id<RTCCodecSpecificInfo>)codecSpecificInfo | 43 codecSpecificInfo:(id<RTCCodecSpecificInfo>)codecSpecificInfo |
44 width:(int32_t)width | 44 width:(int32_t)width |
45 height:(int32_t)height | 45 height:(int32_t)height |
46 renderTimeMs:(int64_t)renderTimeMs | 46 renderTimeMs:(int64_t)renderTimeMs |
47 timestamp:(uint32_t)timestamp | 47 timestamp:(uint32_t)timestamp |
48 rotation:(RTCVideoRotation)rotation; | 48 rotation:(RTCVideoRotation)rotation; |
49 | 49 |
50 @end | 50 @end |
51 | 51 |
| 52 namespace { // anonymous namespace |
| 53 |
52 // The ratio between kVTCompressionPropertyKey_DataRateLimits and | 54 // The ratio between kVTCompressionPropertyKey_DataRateLimits and |
53 // kVTCompressionPropertyKey_AverageBitRate. The data rate limit is set higher | 55 // kVTCompressionPropertyKey_AverageBitRate. The data rate limit is set higher |
54 // than the average bit rate to avoid undershooting the target. | 56 // than the average bit rate to avoid undershooting the target. |
55 const float kLimitToAverageBitRateFactor = 1.5f; | 57 const float kLimitToAverageBitRateFactor = 1.5f; |
56 // These thresholds deviate from the default h264 QP thresholds, as they | 58 // These thresholds deviate from the default h264 QP thresholds, as they |
57 // have been found to work better on devices that support VideoToolbox | 59 // have been found to work better on devices that support VideoToolbox |
58 const int kLowH264QpThreshold = 28; | 60 const int kLowH264QpThreshold = 28; |
59 const int kHighH264QpThreshold = 39; | 61 const int kHighH264QpThreshold = 39; |
60 | 62 |
61 // Struct that we pass to the encoder per frame to encode. We receive it again | 63 // Struct that we pass to the encoder per frame to encode. We receive it again |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 case webrtc::H264::kLevel1_1: | 263 case webrtc::H264::kLevel1_1: |
262 case webrtc::H264::kLevel1_2: | 264 case webrtc::H264::kLevel1_2: |
263 case webrtc::H264::kLevel1_3: | 265 case webrtc::H264::kLevel1_3: |
264 case webrtc::H264::kLevel2: | 266 case webrtc::H264::kLevel2: |
265 case webrtc::H264::kLevel2_1: | 267 case webrtc::H264::kLevel2_1: |
266 case webrtc::H264::kLevel2_2: | 268 case webrtc::H264::kLevel2_2: |
267 return kVTProfileLevel_H264_High_AutoLevel; | 269 return kVTProfileLevel_H264_High_AutoLevel; |
268 } | 270 } |
269 } | 271 } |
270 } | 272 } |
| 273 } // namespace |
271 | 274 |
272 @implementation RTCVideoEncoderH264 { | 275 @implementation RTCVideoEncoderH264 { |
273 RTCVideoCodecInfo *_codecInfo; | 276 RTCVideoCodecInfo *_codecInfo; |
274 webrtc::BitrateAdjuster *_bitrateAdjuster; | 277 webrtc::BitrateAdjuster *_bitrateAdjuster; |
275 uint32_t _targetBitrateBps; | 278 uint32_t _targetBitrateBps; |
276 uint32_t _encoderBitrateBps; | 279 uint32_t _encoderBitrateBps; |
277 RTCH264PacketizationMode _packetizationMode; | 280 RTCH264PacketizationMode _packetizationMode; |
278 CFStringRef _profile; | 281 CFStringRef _profile; |
279 RTCVideoEncoderCallback _callback; | 282 RTCVideoEncoderCallback _callback; |
280 int32_t _width; | 283 int32_t _width; |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
704 } | 707 } |
705 _bitrateAdjuster->Update(frame.buffer.length); | 708 _bitrateAdjuster->Update(frame.buffer.length); |
706 } | 709 } |
707 | 710 |
708 - (RTCVideoEncoderQpThresholds *)scalingSettings { | 711 - (RTCVideoEncoderQpThresholds *)scalingSettings { |
709 return [[RTCVideoEncoderQpThresholds alloc] initWithThresholdsLow:kLowH264QpTh
reshold | 712 return [[RTCVideoEncoderQpThresholds alloc] initWithThresholdsLow:kLowH264QpTh
reshold |
710 high:kHighH264QpT
hreshold]; | 713 high:kHighH264QpT
hreshold]; |
711 } | 714 } |
712 | 715 |
713 @end | 716 @end |
OLD | NEW |