diff --git a/sdk/objc/Framework/Classes/Video/RTCI420Buffer.mm b/sdk/objc/Framework/Classes/Video/RTCI420Buffer.mm index 3d0538e572..ae4092689f 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 c807af3b47..a6200dca5a 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]; }