http://bugs.winehq.org/show_bug.cgi?id=58425
Bug ID: 58425 Summary: video/x-h264 alignment=au caps causes artifacts and crashes with nal-aligned streams Product: Wine Version: 10.11 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: winegstreamer Assignee: wine-bugs@winehq.org Reporter: mkrsym1@gmail.com Distribution: ---
Multiple applications try to playback nal-aligned streams, but Wine always sets the alignment caps to au. This causes h264parse to work incorrectly, which in turn leads to various unpleasant effects, depending on the decoder used.
Some examples: - libav's avdec_h264 is the most tolerant one, and only displays brief image artifacts when au-alignment is broken. - OpenH264 displays major image and temporal artifacts on au-alignment break, sometimes hangs. - NVIDIA's nvh264dec immediately crashes the entire application on au-alignment break.
This issue is completely fixed by not setting the alignment caps at all and letting h264parse do it's job, as done in this commit: https://github.com/ValveSoftware/wine/commit/0304a42
Not sure why it's set in the first place. Maybe that patch can be merged into Wine master, or is there something that I'm missing?
http://bugs.winehq.org/show_bug.cgi?id=58425
mkrsym1@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |mkrsym1@gmail.com
http://bugs.winehq.org/show_bug.cgi?id=58425
--- Comment #1 from Ken Sharp imwellcushtymelike@gmail.com ---
Multiple applications
Which ones? It's helpful if there is a download available to test against. It also helps to attach the bug to the relevant entries in the AppDB.
http://bugs.winehq.org/show_bug.cgi?id=58425
--- Comment #2 from mkrsym1@gmail.com --- Mostly CRIWare under Unity. Can't find anything that is both free and public, but there probably is. I'll try to make a test application to show the issue.
http://bugs.winehq.org/show_bug.cgi?id=58425
--- Comment #3 from mkrsym1@gmail.com --- Upon further investigation, the underlying problem appears to be different from what I first described. Most buffers submitted by CRIWare are actually au-aligned, but sometimes the last nal is incomplete, and it's continuation is submitted in the next buffer, after which following buffers are correctly au-aligned again. Windows can somehow handle this nightmare, but as of now, Wine cannot. Letting h264parse align the buffers by not setting alignment=au makes the behavior match Windows.
http://bugs.winehq.org/show_bug.cgi?id=58425
mkrsym1@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Summary|video/x-h264 alignment=au |video/x-h264 alignment=au |caps causes artifacts and |caps causes artifacts and |crashes with nal-aligned |crashes with |streams |"almost-aligned" streams
http://bugs.winehq.org/show_bug.cgi?id=58425
--- Comment #4 from mkrsym1@gmail.com --- Created attachment 78875 --> http://bugs.winehq.org/attachment.cgi?id=78875 Test program
Here is a test program that demonstrates the problem in a very exaggerated way, by splitting the last NALU in every AU in half. Test steps: 1. Recode a video to Annex B with e.g. `ffmpeg -i input_video -c:v libx264 -x264-params 'annexb=1:aud=1' -f h264 test.h264`. 2. Try decoding the video with `test_align.exe test.h264 out.bin` on Wine 10.11. If using avdec_h264, you will get lots of buffer overread errors. Verify artifacts with `ffplay -f rawvideo -video_size WxH out.bin`. 3. Try decoding the video on Windows in the same way. Verify that there aren't any artifacts with ffplay. 4. Try decoding the video on Wine again, but with the abovementioned patch. Verify that the characteristic artifacts are not there anymore.
Sidenote: when decoding on Wine, there often appears a green strip at the bottom of the video. That does not depend on whether the video was "preprocessed", so it's a different bug.
http://bugs.winehq.org/show_bug.cgi?id=58425
mkrsym1@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |rbernon@codeweavers.com
http://bugs.winehq.org/show_bug.cgi?id=58425
mkrsym1@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |bmcgrath@codeweavers.com
http://bugs.winehq.org/show_bug.cgi?id=58425
--- Comment #5 from mkrsym1@gmail.com --- CC Rémi Bernon per git blame, Brendan McGrath as commit author.
http://bugs.winehq.org/show_bug.cgi?id=58425
mkrsym1@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |testcase
http://bugs.winehq.org/show_bug.cgi?id=58425
--- Comment #6 from Brendan McGrath bmcgrath@codeweavers.com --- One of the reasons I felt this was safe for Proton but not for upstream was because I know 'h264parse' is always available with Proton. For upstream wine however, it will require the user to install `gst-plugins-bad`.
Without 'h264parse' available, removing the 'au' alignment could make things worse (I'll need to double check). But even so, there is probably a way to check if 'h264parse' is missing and then fallback to 'au' alignment in that scenario.
I'll look in to it.
http://bugs.winehq.org/show_bug.cgi?id=58425
Zeb Figura z.figura12@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- CC| |z.figura12@gmail.com
--- Comment #7 from Zeb Figura z.figura12@gmail.com --- (In reply to Brendan McGrath from comment #6)
One of the reasons I felt this was safe for Proton but not for upstream was because I know 'h264parse' is always available with Proton. For upstream wine however, it will require the user to install `gst-plugins-bad`.
Without 'h264parse' available, removing the 'au' alignment could make things worse (I'll need to double check). But even so, there is probably a way to check if 'h264parse' is missing and then fallback to 'au' alignment in that scenario.
I'll look in to it.
I think depending on h264parse is fine. We need it anyway for other reasons; cf. 5988.