Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Side by Side Diff: webrtc/sdk/objc/Framework/Classes/Video/objcvideotracksource.mm

Issue 2975613002: Adjust for initial cropping when adapting frame. (Closed)
Patch Set: Rebase Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 buffer = new rtc::RefCountedObject<ObjCFrameBuffer>(frame.buffer); 47 buffer = new rtc::RefCountedObject<ObjCFrameBuffer>(frame.buffer);
48 } else if ([frame.buffer isKindOfClass:[RTCCVPixelBuffer class]]) { 48 } else if ([frame.buffer isKindOfClass:[RTCCVPixelBuffer class]]) {
49 // Adapted CVPixelBuffer frame. 49 // Adapted CVPixelBuffer frame.
50 RTCCVPixelBuffer *rtcPixelBuffer = (RTCCVPixelBuffer *)frame.buffer; 50 RTCCVPixelBuffer *rtcPixelBuffer = (RTCCVPixelBuffer *)frame.buffer;
51 buffer = new rtc::RefCountedObject<ObjCFrameBuffer>([[RTCCVPixelBuffer alloc ] 51 buffer = new rtc::RefCountedObject<ObjCFrameBuffer>([[RTCCVPixelBuffer alloc ]
52 initWithPixelBuffer:rtcPixelBuffer.pixelBuffer 52 initWithPixelBuffer:rtcPixelBuffer.pixelBuffer
53 adaptedWidth:adapted_width 53 adaptedWidth:adapted_width
54 adaptedHeight:adapted_height 54 adaptedHeight:adapted_height
55 cropWidth:crop_width 55 cropWidth:crop_width
56 cropHeight:crop_height 56 cropHeight:crop_height
57 cropX:crop_x 57 cropX:crop_x + rtcPixelBuffer.cropX
58 cropY:crop_y]); 58 cropY:crop_y + rtcPixelBuffer.cropY]);
59 } else { 59 } else {
60 // Adapted I420 frame. 60 // Adapted I420 frame.
61 // TODO(magjed): Optimize this I420 path. 61 // TODO(magjed): Optimize this I420 path.
62 rtc::scoped_refptr<I420Buffer> i420_buffer = I420Buffer::Create(adapted_widt h, adapted_height); 62 rtc::scoped_refptr<I420Buffer> i420_buffer = I420Buffer::Create(adapted_widt h, adapted_height);
63 buffer = new rtc::RefCountedObject<ObjCFrameBuffer>(frame.buffer); 63 buffer = new rtc::RefCountedObject<ObjCFrameBuffer>(frame.buffer);
64 i420_buffer->CropAndScaleFrom(*buffer->ToI420(), crop_x, crop_y, crop_width, crop_height); 64 i420_buffer->CropAndScaleFrom(*buffer->ToI420(), crop_x, crop_y, crop_width, crop_height);
65 buffer = i420_buffer; 65 buffer = i420_buffer;
66 } 66 }
67 67
68 // Applying rotation is only supported for legacy reasons and performance is 68 // Applying rotation is only supported for legacy reasons and performance is
69 // not critical here. 69 // not critical here.
70 webrtc::VideoRotation rotation = static_cast<webrtc::VideoRotation>(frame.rota tion); 70 webrtc::VideoRotation rotation = static_cast<webrtc::VideoRotation>(frame.rota tion);
71 if (apply_rotation() && rotation != kVideoRotation_0) { 71 if (apply_rotation() && rotation != kVideoRotation_0) {
72 buffer = I420Buffer::Rotate(*buffer->ToI420(), rotation); 72 buffer = I420Buffer::Rotate(*buffer->ToI420(), rotation);
73 rotation = kVideoRotation_0; 73 rotation = kVideoRotation_0;
74 } 74 }
75 75
76 OnFrame(webrtc::VideoFrame(buffer, rotation, translated_timestamp_us)); 76 OnFrame(webrtc::VideoFrame(buffer, rotation, translated_timestamp_us));
77 } 77 }
78 78
79 } // namespace webrtc 79 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698