[AVCapturePhotoOutput] Certain preview-sized photo sample buffers introduce green border artifacts.

I noticed that certain preview-sized photo sample buffers will exhibit green border artifacts (along the right/bottom edge), if the preview image dimensions are not chosen to be a multiple of N (where N = probably 4, but I'm not entirely sure). This only applies to YCbCr (kCVPixelFormatType_420YpCbCr8BiPlanarFullRange or kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange) formats, not RGB.


As a test, I chose 253x189 as preview image dimensions:

(I ran this test on an iPhone 6s with iOS 10 beta 7).


AVCapturePhotoOutput* capturePhotoOutput = [...assume this is initialized...]
OSType rawPixelFormatType = [capturePhotoOutput.availableRawPhotoPixelFormatTypes.firstObject unsignedIntValue];
AVCapturePhotoSettings* photoSettings = [AVCapturePhotoSettings photoSettingsWithRawPixelFormatType:rawPixelFormatType];
OSType previewPixelBufferFormat = [... see below...]
photoSettings.previewPhotoFormat = @{ (__bridge NSString*)kCVPixelBufferPixelFormatTypeKey : @(previewPixelBufferFormat), (__bridge NSString*)kCVPixelBufferWidthKey : @(253), (__bridge NSString*)kCVPixelBufferHeightKey : @(189) };

Here are the results (with 400% enlargement):

previewPhotoSampleBuffer = kCVPixelFormatType_32BGRA;

http://imgur.com/adXKKoH

Appears correct.


previewPhotoSampleBuffer = kCVPixelFormatType_420YpCbCr8BiPlanarFullRange;

http://imgur.com/5hvI3l1

Green artifacts along the right/bottom edge!


So, my question is: Which dimensions are safe to chose for YCbCr preview sample buffers?

Replies

Filed as Bug #27942047 under https://bugreport.apple.com