-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Vertically scaled dispmanx elements cause image corruption #277
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
Comments
I haven't run the testcode yet, but can you try:
in config.txt? |
Activating dispmanx_offline does not improve the behaviour. Actually activating it introduces additional distortion in the checkerboard pattern itself when omxplayer is running in parallel. |
Have you been able to reproduce the issue? |
I can reproduce the issue. We are running out of context memory in the HVS. My understanding is that with dispmanx_offline=0, this behaviour is (probably) expected. If you don't require the framebuffer, it is always worth removing it (even when obscured it is still using normal memory, HVS context memory, and memory/HVS bandwidth). One way of removing the framebuffer is:
and you can restore it with
The amount of HVS context memory required if proportional to the number of layers on screen, with scaled layers requiring more context memory. The size of layers doesn't (I believe) affect it. I'll talk to HVS expert about what's happening tomorrow and see why the offline case is failing, and whether there are any other solutions. |
Thanks for the details. Using dispmanx_offline, even if it wouldn't suffer this problem, doesn't seem to be a solution for us, as the video rendering performance breaks almost completely when enabling offline compositing. Is there an option to increase HVS context memory size? What stands HVS for, btw? |
HVS is hardware video scaler. The context memory is fixed in hardware (and 48K). Perhaps the resize has a significant effect, or perhaps there is something else which is using context memory. I'll try to get some more answers tomorrow. |
What I find especially confusing is that only vertical scaling seems to have such a high impact. Using only horizontal scaling I am unable to reproduce the problem... |
I think the issue is you can horizontally scale in hardware with just a few pixels of context. |
Merging subtitles into a single region in software turns out to be more complicated than I had hoped due to VLC architecture... So finding any workaround to increase the number of scalable elements to 5 or 6 would be really a major help for us... |
I've spoken to the expert. HVS context memory requires 16 bytes * min(src_width, dst_width) when vertically resizing (plus some much smaller contributions). If alpha is not used that reduces to 12 bytes * min(src_width, dst_width). Now it turns out that if the layers don't intersect vertically (as in your example code), then the context memory could in theory be reused. There is no code to support this special case, but the HVS guy said he'd think about adding that. No promises, but a possibility for the future. He also pointed me at a commit that fixes the offline case. It also seems to avoid the corruption displayed in the non-offline case (elements just vanish when memory is exhausted). That will be in the next firmware update. |
Thanks for the update. The optimisation idea sounds promising as it would actually fit our real-world scenario. Then another thought: Is it somehow possible to do manual offline composition of some elements into another one? The idea would be to offline composite all subtitle elements into one which can then be rendered without offline compositing onto the video. |
Yes, offline composition is supported. Look at:
|
Ah thanks, this is really interesting. I will try to port my hackish merge code to use that. |
I'm not 100% sure if this will work automatically (dispmanx_offline=1 allocates spare framebuffers in case offline composition is required, and I'm not sure if they are required for this case). What you can do is create two offscreen dispmanx resources. and repeat this as needed to build up any complexity. |
kernel: V4L2 padding removal, and support for H264_I_PERIOD See: raspberrypi/linux#598 firmware: dispmanx: Limit LBM usage on any channel See: #277 firmware: MMAL: vc_image: Fix some of the combinations for vc_image_pack firmware: MMAL: Don't ask for YUVUV when tearing down an opaque tunnel See: http://www.raspberrypi.org/forums/viewtopic.php?f=43&t=62364&start=300#p552913 firmware: gencmd: Add display_power command for controlling power to hdmi phy firmware: config: Add hdmi_force_mode option to force only one mode See: http://openelec.tv/forum/124-raspberry-pi/71222-display-issues#108236 firmware: hdmi: Make configured mode have high score, so it is respected after power on preferred firmware: hdmi: Call the callback with current hdmi mode, not preferred See: http://forum.stmlabs.com/showthread.php?tid=11003&pid=102973#pid102973 firmware: dispmanx: Move the offline/rotated buffer allocation into attach function. See: raspberrypi/linux#463
kernel: V4L2 padding removal, and support for H264_I_PERIOD See: raspberrypi/linux#598 firmware: dispmanx: Limit LBM usage on any channel See: raspberrypi/firmware#277 firmware: MMAL: vc_image: Fix some of the combinations for vc_image_pack firmware: MMAL: Don't ask for YUVUV when tearing down an opaque tunnel See: http://www.raspberrypi.org/forums/viewtopic.php?f=43&t=62364&start=300#p552913 firmware: gencmd: Add display_power command for controlling power to hdmi phy firmware: config: Add hdmi_force_mode option to force only one mode See: http://openelec.tv/forum/124-raspberry-pi/71222-display-issues#108236 firmware: hdmi: Make configured mode have high score, so it is respected after power on preferred firmware: hdmi: Call the callback with current hdmi mode, not preferred See: http://forum.stmlabs.com/showthread.php?tid=11003&pid=102973#pid102973 firmware: dispmanx: Move the offline/rotated buffer allocation into attach function. See: raspberrypi/linux#463
I've just pushed updated firmware. It should avoid the corruption problem, and improve offline case, but you will still get missing elements in non-offline case when context memory is full. |
Perfect, thank you. I'll go ahead with implementing offscreen compositing of layers, so that we will only have to scale one layer afterwards. |
Things seem to be sufficiently handled now. Thanks for the support, I'm closing the bug. |
kernel: V4L2 padding removal, and support for H264_I_PERIOD See: raspberrypi/linux#598 firmware: dispmanx: Limit LBM usage on any channel See: raspberrypi#277 firmware: MMAL: vc_image: Fix some of the combinations for vc_image_pack firmware: MMAL: Don't ask for YUVUV when tearing down an opaque tunnel See: http://www.raspberrypi.org/forums/viewtopic.php?f=43&t=62364&start=300#p552913 firmware: gencmd: Add display_power command for controlling power to hdmi phy firmware: config: Add hdmi_force_mode option to force only one mode See: http://openelec.tv/forum/124-raspberry-pi/71222-display-issues#108236 firmware: hdmi: Make configured mode have high score, so it is respected after power on preferred firmware: hdmi: Call the callback with current hdmi mode, not preferred See: http://forum.stmlabs.com/showthread.php?tid=11003&pid=102973#pid102973 firmware: dispmanx: Move the offline/rotated buffer allocation into attach function. See: raspberrypi/linux#463
We ran into a quite odd issue using scaled dispmanx resources:
When we display more than 3 resources which are vertically scaled we get image distortions on the left half of the screen.
We can reproduce it with a clean raspbian which is just booted and shows the login prompt.
For demonstration we prepared a little tool, which draws a 4 "line" checkerboard, where each line is a dispmanx element. So when the fourth line appears the issue is triggered. To show the relation to scaling vertically the tool runs in 4 test modes:
Test 3 and 4 trigger the issue while 1 and 2 run without problems. Interestingly when running omxplayer the issue does either not occur or (what I think is more likely) the garbled content is covered by the video output. Unfortunaltely with our VLC mmal and omx plugins the video output does not cover the garbled content. We played around with the dispmanx layers but found no way to work around it.
You can find the code here: https://gist.github.com/julianscheel/96682459fcd6edb09ac5
And a precompiled binary here: http://jusst.de/files/dispman-test
And a picture showing the problem on stock raspian:
This issue is especially painful when using VLC+mmal+DVB subtitles where frequently more than 3 layers are required and where we use dispmanx scaling capabilities.
The text was updated successfully, but these errors were encountered: