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
Clipping incorrect when rotating an omx render component while having its dest outside of the visible screen #844
Comments
Can you confirm. With |
For The summary would probably be: If I render a video partially offscreen, the output should make sense regardless of the rotation setting. Right now |
I'm talking about destination pixels. |
I'm not sure I understand, but the image with the red border is what I'm expecting when rendering a 180 degree rotated video outside of the screen. Instead I get the result in the screenshot before that. I would expect when I set a destination rect to some coordinates, that the video is fully rendered into that area. Regardless of whether that rect is outside the screen or the video is rotated. The screenshot with the red area shows how it's supposed to look like. This works perfectly when the video isn't rotated. |
Is it clear what I'm expecting vs what actually happens? If not, I might try to create a GIF that shows the problem. |
Here's a GIF showing the problem in an animated form: I'm playing a video and adjusting it's target with
Does that help? |
I think I understand. We have a clamp function in dispmanx that checks for out-of-range dest rectangle coordinates and clamps them to screen edges (adjusting source coordinates to compensate). I believe that function does the right thing for orientation=0 but not for other orientations. |
Thanks a lot! I'm happy to test any future firmware that fixes this. Oh. And if you need any easy way to test all this, I can put up info-beamer code that runs the above test. Would that be helpful? |
How to reproduce the above GIF output: Put the following code in -- save as node.lua
gl.setup(NATIVE_WIDTH, NATIVE_HEIGHT)
local vid = resource.load_video{
file = "test.mp4",
raw = true,
}
-- local font = resource.load_font "font.ttf"
vid:layer(-1)
local s = 2
local r = {0, 90, 180, 270}
function node.render()
local rotation = r[math.floor(sys.now()/4) % 4 + 1]
vid:rotate(rotation)
gl.clear(0,0,0,0)
-- font:write(0, 0, "Rotation " .. tostring(rotation), 100, 1,1,1,1)
local x = math.sin(sys.now() * 5) * 500 + WIDTH/2
local y = math.cos(sys.now() * 5) * 300 + HEIGHT/2
vid:target(x - 1920/s, y-1080/s, x+1920/s, y+1080/s)
end Then run this code with info-beamer like this:
If you want the overlay that informs you about the current rotation, put any truetype font as |
Thinking a day over what you said:
For some reason I didn't expect it to work like this internally. But that makes perfect sense. So I guess it's also possible to fix this completely in "user space" by adjusting source/dest/rotation accordingly. I'll look into that. That might also have the added benefit of making it easier to check if the transformed video is completely off-screen and avoid those greenish artifacts that sometimes result from that. |
It works. With the help of a transformation matrix I now project the video into screen space, clamp there and transform back into video space. Then I set the dest/source/rotation values. Works pretty well. I guess I no longer need a firmware based fix for this. Feel free to close depending on what you think the firmware should do. |
Closing this issue as questions answered/issue resolved. |
Let me try to describe what happens. I took a FullHD video and am rendering it to a FullHD output. I manually place the
render
component of the omx pipeline to be outside of the visible screen. This can be done with omxplayer like this:The result is the following and looks correct:
But if I rotate the
render
component by 90, 180 or 270 degree the following happens. The example image is create when running omxplayer like this:It seems that when using any rotation other than 0, the video is somehow clipped into the visible area. In the above image I would expect the output to look like the red area in this manually put together screenshot:
The same thing happens then the video is vertically outside of the screen. In that case 0 and 90 degree rotation works while 180 and 270 don't. Each screenshot is generated while running
Expected result when rotated by 0 degree:

Expected result when rotated by 90 degree:

Weird result when rotated by 180 degree:

Weird result when rotated by 270 degree:

I'm running
Can this be fixed?
The text was updated successfully, but these errors were encountered: