1 Reply
      Latest reply on Aug 21, 2016 7:46 PM by thomas.pintaric
      thomas.pintaric Level 2 Level 2 (55 points)

        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;


        Appears correct.


        previewPhotoSampleBuffer = kCVPixelFormatType_420YpCbCr8BiPlanarFullRange;


        Green artifacts along the right/bottom edge!


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