OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2017 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 buffer = frame.videoBuffer; | 46 buffer = frame.videoBuffer; |
47 } else if (frame.nativeHandle) { | 47 } else if (frame.nativeHandle) { |
48 // Adapted CVPixelBuffer frame. | 48 // Adapted CVPixelBuffer frame. |
49 buffer = new rtc::RefCountedObject<CoreVideoFrameBuffer>( | 49 buffer = new rtc::RefCountedObject<CoreVideoFrameBuffer>( |
50 static_cast<CVPixelBufferRef>(frame.nativeHandle), adapted_width, adapte
d_height, | 50 static_cast<CVPixelBufferRef>(frame.nativeHandle), adapted_width, adapte
d_height, |
51 crop_width, crop_height, crop_x, crop_y); | 51 crop_width, crop_height, crop_x, crop_y); |
52 } else { | 52 } else { |
53 // Adapted I420 frame. | 53 // Adapted I420 frame. |
54 // TODO(magjed): Optimize this I420 path. | 54 // TODO(magjed): Optimize this I420 path. |
55 rtc::scoped_refptr<I420Buffer> i420_buffer = I420Buffer::Create(adapted_widt
h, adapted_height); | 55 rtc::scoped_refptr<I420Buffer> i420_buffer = I420Buffer::Create(adapted_widt
h, adapted_height); |
56 i420_buffer->CropAndScaleFrom(*frame.videoBuffer, crop_x, crop_y, crop_width
, crop_height); | 56 i420_buffer->CropAndScaleFrom( |
| 57 *frame.videoBuffer->ToI420(), crop_x, crop_y, crop_width, crop_height); |
57 buffer = i420_buffer; | 58 buffer = i420_buffer; |
58 } | 59 } |
59 | 60 |
60 // Applying rotation is only supported for legacy reasons and performance is | 61 // Applying rotation is only supported for legacy reasons and performance is |
61 // not critical here. | 62 // not critical here. |
62 webrtc::VideoRotation rotation = static_cast<webrtc::VideoRotation>(frame.rota
tion); | 63 webrtc::VideoRotation rotation = static_cast<webrtc::VideoRotation>(frame.rota
tion); |
63 if (apply_rotation() && rotation != kVideoRotation_0) { | 64 if (apply_rotation() && rotation != kVideoRotation_0) { |
64 buffer = I420Buffer::Rotate(*buffer->NativeToI420Buffer(), rotation); | 65 buffer = I420Buffer::Rotate(*buffer->ToI420(), rotation); |
65 rotation = kVideoRotation_0; | 66 rotation = kVideoRotation_0; |
66 } | 67 } |
67 | 68 |
68 OnFrame(webrtc::VideoFrame(buffer, rotation, translated_timestamp_us)); | 69 OnFrame(webrtc::VideoFrame(buffer, rotation, translated_timestamp_us)); |
69 } | 70 } |
70 | 71 |
71 } // namespace webrtc | 72 } // namespace webrtc |
OLD | NEW |