Adjust for initial cropping when adapting frame.
When adapting a frame, any initial cropping coordinate was replaced
by the coordinate calculated for adapting. Offset initial coordinate
instead.
BUG=webrtc:7880
Review-Url: https://codereview.webrtc.org/2975613002
Cr-Original-Commit-Position: refs/heads/master@{#19509}
Cr-Mirrored-From: https://chromium.googlesource.com/external/webrtc
Cr-Mirrored-Commit: 151aa6b3f7b00c9be05ffda848bc42748af19f04
diff --git a/sdk/objc/Framework/Classes/Video/RTCCVPixelBuffer.mm b/sdk/objc/Framework/Classes/Video/RTCCVPixelBuffer.mm
index 72c9a26..7d3669f 100644
--- a/sdk/objc/Framework/Classes/Video/RTCCVPixelBuffer.mm
+++ b/sdk/objc/Framework/Classes/Video/RTCCVPixelBuffer.mm
@@ -21,11 +21,11 @@
int _bufferHeight;
int _cropWidth;
int _cropHeight;
- int _cropX;
- int _cropY;
}
@synthesize pixelBuffer = _pixelBuffer;
+@synthesize cropX = _cropX;
+@synthesize cropY = _cropY;
- (instancetype)initWithPixelBuffer:(CVPixelBufferRef)pixelBuffer {
return [self initWithPixelBuffer:pixelBuffer
diff --git a/sdk/objc/Framework/Classes/Video/objcvideotracksource.mm b/sdk/objc/Framework/Classes/Video/objcvideotracksource.mm
index 4200cbc..d3ec3bd 100644
--- a/sdk/objc/Framework/Classes/Video/objcvideotracksource.mm
+++ b/sdk/objc/Framework/Classes/Video/objcvideotracksource.mm
@@ -54,8 +54,8 @@
adaptedHeight:adapted_height
cropWidth:crop_width
cropHeight:crop_height
- cropX:crop_x
- cropY:crop_y]);
+ cropX:crop_x + rtcPixelBuffer.cropX
+ cropY:crop_y + rtcPixelBuffer.cropY]);
} else {
// Adapted I420 frame.
// TODO(magjed): Optimize this I420 path.
diff --git a/sdk/objc/Framework/Headers/WebRTC/RTCVideoFrameBuffer.h b/sdk/objc/Framework/Headers/WebRTC/RTCVideoFrameBuffer.h
index 63505ab..ffcdf26 100644
--- a/sdk/objc/Framework/Headers/WebRTC/RTCVideoFrameBuffer.h
+++ b/sdk/objc/Framework/Headers/WebRTC/RTCVideoFrameBuffer.h
@@ -69,6 +69,8 @@
@interface RTCCVPixelBuffer : NSObject <RTCVideoFrameBuffer>
@property(nonatomic, readonly) CVPixelBufferRef pixelBuffer;
+@property(nonatomic, readonly) int cropX;
+@property(nonatomic, readonly) int cropY;
- (instancetype)initWithPixelBuffer:(CVPixelBufferRef)pixelBuffer;
- (instancetype)initWithPixelBuffer:(CVPixelBufferRef)pixelBuffer