Add some more test cases for RTCCVPixelBuffer.
Also fix rendering of certain i420 buffers in debug quicklook.
Bug: None
Change-Id: I793915c3a5a1fcb4cd7b24383d1579655e9a7c28
Reviewed-on: https://webrtc-review.googlesource.com/72080
Reviewed-by: Kári Helgason <kthelgason@webrtc.org>
Commit-Queue: Anders Carlsson <andersc@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23005}
diff --git a/sdk/objc/Framework/Classes/Video/RTCI420Buffer.mm b/sdk/objc/Framework/Classes/Video/RTCI420Buffer.mm
index 3d0538e..ae40926 100644
--- a/sdk/objc/Framework/Classes/Video/RTCI420Buffer.mm
+++ b/sdk/objc/Framework/Classes/Video/RTCI420Buffer.mm
@@ -127,9 +127,9 @@
_i420Buffer->DataV(),
_i420Buffer->StrideV(),
ctxData,
- _i420Buffer->width() * 4,
- _i420Buffer->width(),
- _i420Buffer->height());
+ CGBitmapContextGetBytesPerRow(c),
+ CGBitmapContextGetWidth(c),
+ CGBitmapContextGetHeight(c));
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
diff --git a/sdk/objc/Framework/UnitTests/RTCCVPixelBuffer_xctest.mm b/sdk/objc/Framework/UnitTests/RTCCVPixelBuffer_xctest.mm
index c807af3..a6200dc 100644
--- a/sdk/objc/Framework/UnitTests/RTCCVPixelBuffer_xctest.mm
+++ b/sdk/objc/Framework/UnitTests/RTCCVPixelBuffer_xctest.mm
@@ -133,6 +133,18 @@
outputSize:CGSizeMake(0, 0)];
}
+- (void)testCropAndScaleToSmallFormat_NV12 {
+ [self cropAndScaleTestWithNV12InputFormat:kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange
+ outputFormat:kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange
+ outputSize:CGSizeMake(148, 320)];
+}
+
+- (void)testCropAndScaleToOddFormat_NV12 {
+ [self cropAndScaleTestWithNV12InputFormat:kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange
+ outputFormat:kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange
+ outputSize:CGSizeMake(361, 640)];
+}
+
- (void)testCropAndScale_32BGRA {
[self cropAndScaleTestWithRGBPixelFormat:kCVPixelFormatType_32BGRA];
}