Skip to content
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

video/out/gpu/video: fix chroma offset rotation matrix calculation #15293

Merged
merged 2 commits into from
Nov 11, 2024

Conversation

na-na-hi
Copy link
Contributor

82231fd mentioned that for the "rot" transform flip=true must be set, which "makes no sense at all".

The reason this is happening is that the rotation matrix calculation is only valid for the 2D coordinate system where y axis is 90 degrees counterclockwise from x axis, but the coordinate system of chroma offset has its origin at top-left so it is the opposite, which results in the rotation going to the opposite way. Setting flip=true fixes the rotation direction, but results in a flipped y coordinate.

Fix this by reversing the rotation angle for chroma offset rotation matrix calculation. This also allows removing some duplicated code.

Fixes: #15288

82231fd mentioned that for the "rot"
transform flip=true must be set, which "makes no sense at all".

The reason this is happening is that the rotation matrix calculation
is only valid for the 2D coordinate system where y axis is 90 degrees
counterclockwise from x axis, but the coordinate system of chroma
offset has its origin at top-left so it is the opposite, which results
in the rotation going to the opposite way. Setting flip=true fixes the
rotation direction, but results in a flipped y coordinate.

Fix this by reversing the rotation angle for chroma offset rotation
matrix calculation. This also allows removing some duplicated code.
@kasper93
Copy link
Contributor

Thanks @na-na-hi, I didn't have time to commit the change today. But indeed it was not correct in this part of code.

Copy link

Download the artifacts for this pull request:

Windows
macOS

Copy link
Contributor

@kasper93 kasper93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you again. I'm really surprised this went unnoticed for all this time. This chroma offset flip produces really nasty artifacts and is worse that doing no correction at all...

Before:
image
After:
image

@kasper93 kasper93 merged commit ca7aeb7 into mpv-player:master Nov 11, 2024
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect chroma location handling with vo=gpu
2 participants