OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 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 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
733 // TODO(magjed): Avoid converting to I420. | 733 // TODO(magjed): Avoid converting to I420. |
734 rtc::scoped_refptr<webrtc::I420Buffer> scaled_buffer( | 734 rtc::scoped_refptr<webrtc::I420Buffer> scaled_buffer( |
735 _buffer_pool.CreateBuffer(adapted_width, adapted_height)); | 735 _buffer_pool.CreateBuffer(adapted_width, adapted_height)); |
736 scaled_buffer->CropAndScaleFrom(buffer->NativeToI420Buffer(), crop_x, | 736 scaled_buffer->CropAndScaleFrom(buffer->NativeToI420Buffer(), crop_x, |
737 crop_y, crop_width, crop_height); | 737 crop_y, crop_width, crop_height); |
738 if (!apply_rotation() || rotation == webrtc::kVideoRotation_0) { | 738 if (!apply_rotation() || rotation == webrtc::kVideoRotation_0) { |
739 buffer = scaled_buffer; | 739 buffer = scaled_buffer; |
740 } else { | 740 } else { |
741 // Applying rotation is only supported for legacy reasons and performance | 741 // Applying rotation is only supported for legacy reasons and performance |
742 // is not critical here. | 742 // is not critical here. |
743 buffer = (rotation == webrtc::kVideoRotation_180) | 743 rtc::scoped_refptr<webrtc::I420Buffer> rotated_buffer( |
744 ? I420Buffer::Create(adapted_width, adapted_height) | 744 (rotation == webrtc::kVideoRotation_180) |
745 : I420Buffer::Create(adapted_height, adapted_width); | 745 ? I420Buffer::Create(adapted_width, adapted_height) |
746 libyuv::I420Rotate(scaled_buffer->DataY(), scaled_buffer->StrideY(), | 746 : I420Buffer::Create(adapted_height, adapted_width)); |
747 scaled_buffer->DataU(), scaled_buffer->StrideU(), | 747 libyuv::I420Rotate( |
748 scaled_buffer->DataV(), scaled_buffer->StrideV(), | 748 scaled_buffer->DataY(), scaled_buffer->StrideY(), |
749 buffer->MutableDataY(), buffer->StrideY(), | 749 scaled_buffer->DataU(), scaled_buffer->StrideU(), |
750 buffer->MutableDataU(), buffer->StrideU(), | 750 scaled_buffer->DataV(), scaled_buffer->StrideV(), |
751 buffer->MutableDataV(), buffer->StrideV(), | 751 rotated_buffer->MutableDataY(), rotated_buffer->StrideY(), |
752 crop_width, crop_height, | 752 rotated_buffer->MutableDataU(), rotated_buffer->StrideU(), |
753 static_cast<libyuv::RotationMode>(rotation)); | 753 rotated_buffer->MutableDataV(), rotated_buffer->StrideV(), |
| 754 crop_width, crop_height, |
| 755 static_cast<libyuv::RotationMode>(rotation)); |
| 756 buffer = rotated_buffer; |
754 } | 757 } |
755 } | 758 } |
756 | 759 |
757 OnFrame(cricket::WebRtcVideoFrame(buffer, rotation, | 760 OnFrame(cricket::WebRtcVideoFrame(buffer, rotation, |
758 translated_camera_time_us, 0), | 761 translated_camera_time_us, 0), |
759 captured_width, captured_height); | 762 captured_width, captured_height); |
760 } | 763 } |
761 | 764 |
762 } // namespace webrtc | 765 } // namespace webrtc |
OLD | NEW |