-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed the color attachment comparison bug #1449
Conversation
+1! |
Fixed the color attachment comparison bug
Thanks, appreciate it. Sorry I took so long to work on this, but as you can see I had a few other things going on. |
This actually introduced a crash on iOS 7, because when taking a photo, apparently the colorAttachments variable here is sometimes NULL. This causes the string comparison to fail. I default to the second colorspace, but you might need to check that I've selected the right one in the latest code in the repository. |
Oh, snap. I will look into it and I will let you know :) Good catch 👍 |
After some extensive tests, it seems that the proper solution for this is to handle differently the luminance levels in the shader for photo and video. I will make some fixes and issue a new pull request when it's ready 😄 |
In the still picture mode, the YCbCr data is in different ranges than in video mode (Y in video is [16...235] while in picture it's [0...255]), so a different conversion matrix is required (reference here). After comparing GPUImage photo output with the one of the default Camera app, we concluded that we will need the full range RGB to YCbCr (ITU-R BT.601) conversion matrix.
I will issue a pull request about that as soon as possible. We also noticed that there is a problem with the conversion matrices in video (BT.601 and BT.709). As seen in the sample Apple app and in the reference article, we need to subtract 16 from the luminance component (Y). But applying the subtraction, still does not match the default Camera app's video output. This one needs some more thorough investigation, though 😄 |
Fixes the bug of using the wrong YUV to RGB conversion table while displaying the video from the camera (GPUImageVideoCamera) or playing back a video using the GPUImageMovie class.
In shorts the comparison between two CFStringRef variables was the cause of the problem.
Instead of using CFStringCompare, there was a == comparison which didn't return the correct result.
What is troubling me the most though is that the exact same bug exists in Apple's sample code of 'Real-time Video Processing Using AVPlayerItemVideoOutput' as well, so be advised :)
The bug caused the red color to be displayed as orange (due to the fact that it was using the 709 conversion table instead of the 601 a.k.a. wrong YUV to RGB conversion), as seen from the screenshot below:
This bug also affected any rendered movie file from GPUImage that used GPUImageVideoCamera as source.