BradLarson/GPUImage — pull request #1473 by Petrakeas (2014-03-21 11:30:48+00:00)
Title: Proper YCbCr to RGB conversion

GPUImage uses 3 different pixel formats:
* kCVPixelFormatType_420YpCbCr8BiPlanarFullRange
* kCVPixelFormatType_420YpCbCr8BiPlanarFullRange
* kCVPixelFormatType_32BGRA

Each format requires different treatment, depending on the YUV range (video range, full range) and the color standard (BT.601, BT.709). The previous implementation did not take this into account. So different pixel formats resulted in different output and inconsistent color output.

This pull request, uses 2 different shaders (full range, video range) and the proper YCbCr to RGB conversion matrix according to the pixel format used. This affects the color output of the following sources: GPUImageVideoCamera, GPUImageMovie, GPUImageStillcamera.

Added proper color conversion in the following sources: VideoCamera, Movie:
* corrected the YUVVideoRange shader, so that it subtracts “16” from the “Y” component
* added a YUVFullRange shader
* added “isFullYUVRange” variable so that the proper shader and conversion matrix are selected
* moved the initialization of “yuvConversionProgram” after checking if FullYUVRange is supported (so that the appropriate shader is loaded)

MovieWriter tags the resulting video file as BT.601:
* 3 attachments are added on the “renderTarget” buffer so that AVAssetWriter can use them