-
-
Notifications
You must be signed in to change notification settings - Fork 134
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
Fix yuv420p to p01x unscaled conversion #453
Fix yuv420p to p01x unscaled conversion #453
Conversation
Signed-off-by: nyanmisaka <nst799610810@gmail.com>
Is this reported to ffmpeg upstream yet? |
My email configuration has been broken for a while so it's not very convenient to send patches. Perhaps you can do it? Or send it to https://github.com/intel-media-ci/ffmpeg/pulls |
This makes md5 the same as it was before FFmpeg/FFmpeg@e3fd185 Are you sure this is not just another bug fixed with accurate_rnd? Try -sws_flags accurate_rnd. |
Why the md5 has to change in the first place? Shouldn't they look exactly the same for the same grayscale input?
I'm very sure it is not. It is so wrong that you can identify that with your bare eyes. And yes, I've tested with |
So Intel defined P010 differently from nvidia (see ffmpeg -h encoder=hevc_nvenc, there is P010 support), https://trac.ffmpeg.org/ticket/7199#comment:16 FFmpeg/FFmpeg@e3fd185 is correct for Nvidia, but incorrect for Intel. This is the issue. There is a sample here that shows it https://trac.ffmpeg.org/ticket/8055 There is also an issue that capture cards that signal P010 also have a special flag to signal whether it is Nvidia or Intel flavour of P010 (mxfFrameInfo::Shift). |
I don't know how that is related to hardware formats if at all honestly. We are using ffmpeg's internal software filter to generate grayscale image, using ffmpeg internal software scale to convert colorspace, and ffmpeg's software scale produces inconsistent results. No hardware specific things are involved and it is just ffmpeg implemented its color conversion wrong. |
P010 is actually 10 bit color space, but 420, so for Y plane 10 bit and for Cb, Cr together 2 times less data 5 bits are used, so together 15 bits... Only -vf format=yuv420p10,format=p010le is probably correct. Then there is no issue, right? I cannot use YUView to see what is being produced, alas, but I can see it is 126, 126, 126 RGB with ffplay. What you are not accounting for is that 420 has chroma siting. That means it may be a mismatch somewhere there. But again unscaled and scaled is how Intel and Nvidia define it, I doubt it can be changed. |
What you're not seeing is just the code that implements this conversion. The function directly takes 8-bit 420p inputs and outputs p010 frames without any intermediary steps. If you're implying that FFmpeg is producing yuv420p frames incorrectly at the start, that would be a much larger issue, as it would break most decoder usages that everyone uses.
But again it is not related to current issue in any way.
It is using a completely different conversion function, that one is correct means nothing.
If you can use ffplay then you will notice that they are different. It is so subtle that you don't need a color meter at all. |
yuv420p (fully-planar) => p010le (semi-planar) Without the fast path:
With the fast path:
The purpose of the fast path |
If you still insist upstream did it correctly and that is due to hardware vendor stuff, let me make things clear for you as it seems like you don't familiar with those functions and how frames format differs. What you are keep talking about the P010 difference, is the difference whether to store the 10bits in the high 10 bits of the 16bits, or the low 10 bits of the 16bits, and it has nothing to do with this color conversion function, as it always store in the high 10 bits. What was incorrect was that the low 12 bits would contain garbage, especially the low 2 bits of the 10 bit color and it makes a subtle difference on grayscale images. You have to pick your poison: all other 8 to 10 bit conversion functions are wrong, or this specific conversion is wrong. |
You are right. Y plane only format (which is what gray is) is not affected by chroma siting. So clearly must be a bug. And you are right that 10 bit is using different code path. P.S. Patch applied upstream FFmpeg/FFmpeg@0bb5394 |
Changes
Issues
(Originally reported in HandBrake/HandBrake#5011)