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

Color profile check YUV2RGB matrix #7384

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

akallabeth
Copy link
Member

@akallabeth akallabeth commented Oct 20, 2021

thanks to @alexandru-bagu for doing such intensive testing :)

@akallabeth akallabeth added this to the next milestone Oct 20, 2021
@freerdp-bot
Copy link

Refer to this link for build results (access rights to CI server needed):
https://ci.freerdp.com//job/PullRequestTester/6619/

@freerdp-bot
Copy link

Refer to this link for build results (access rights to CI server needed):
https://ci.freerdp.com//job/PullRequestTester/6624/

@freerdp-bot
Copy link

Refer to this link for build results (access rights to CI server needed):
https://ci.freerdp.com//job/PullRequestTester/6625/

@akallabeth
Copy link
Member Author

@alexandru-bagu looks like the sse and neon implementations still are buggy, the comparison tests to generic fail.

@alexandru-bagu
Copy link
Contributor

@alexandru-bagu looks like the sse and neon implementations still are buggy, the comparison tests to generic fail.

Will check them today. I know my ssse tests didnt fail but I did run them on osx. Will setup a docker env for ubuntu.

@alexandru-bagu
Copy link
Contributor

alexandru-bagu commented Oct 22, 2021

It seems to be an intermittent issue. Sometimes I get a test failure for TestSynchCritical. Sometimes I get a failure for TestPrimitivesYUV. Sometimes I get neither failure... I think I know where the issue is though.

@alexandru-bagu
Copy link
Contributor

alexandru-bagu commented Oct 23, 2021

I've spent 11 hours I think today working on this.... and it's annoying!
I've figured out most of the SSE stuff and after updating to the correct formula as in Wikipedia some tests still fail in some cases. The commits can be seen here: alexandru-bagu@387996e and alexandru-bagu@9e497cf .

The tests that still fail are TestPrimitiveRgbToLumaChroma when the RGBA values are random. This appears to be because of how _mm_maddubs_epi16 (https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm_maddubs_epi16&ig_expand=4454) is implemented. It uses at most 15 bits from the multiplications, because of this fact and the fact that the generic implementation does not have such a limitation (one could be implemented like the Saturate16). If we were to set the same limitation for the generic implementation then I believe we would have the same results (however I don't believe that to be wanted).

I will need someone to review the SSE changes I made, more specifically the usage of _mm_packus_epi16 instead of _mm_packs_epi16. I had to replace the calls to _mm_packs_epi16 with _mm_packus_epi16 because data was being lost due to the same behaviour seen in _mm_maddubs_epi16. Though since the tests don't fail I guess I did a good enough job there.

I have not touched the neon implementation and I don't plan to, I've wrecked my brains today working on this.

@akallabeth
Copy link
Member Author

@alexandru-bagu yes, intrinsics are annoying, specifically if you are operating at the limit of the datatypes involved. (that is the reason for the conversion matrix in the spec, it is optimized for 8/16 bit data types).
Will have a look when back, I'm not available next week.

@alexandru-bagu
Copy link
Contributor

I figured out the SSE issues that were left in alexandru-bagu@3885e20 . Reverted the test to use rand() and it's all good. Due to the limitations of SSE I had to do 3 additional operations so there's no rounding done anymore.

@alexandru-bagu
Copy link
Contributor

Squashed some commits and created a PR in your branch. akallabeth#3

@freerdp-bot
Copy link

Refer to this link for build results (access rights to CI server needed):
https://ci.freerdp.com//job/PullRequestTester/6637/

@freerdp-bot
Copy link

Refer to this link for build results (access rights to CI server needed):
https://ci.freerdp.com//job/PullRequestTester/6638/

@akallabeth
Copy link
Member Author

@alexandru-bagu damn, looks like the different implementations need some more attention, the unit test fails (generic and sse produce differing results)

@alexandru-bagu
Copy link
Contributor

alexandru-bagu commented Nov 2, 2021

Ok, I will have another look and will let you know.

@alexandru-bagu
Copy link
Contributor

alexandru-bagu commented Nov 2, 2021

You are missing my last 3 commits. Seems after you merge my pull-request you overwritten your branch with a force push.
https://github.com/alexandru-bagu/FreeRDP/commits/color_profile_check

@akallabeth
Copy link
Member Author

@alexandru-bagu ok, strange, I've merged your pr. well, cherry-picked them now, lets see if that works out.

@freerdp-bot
Copy link

Refer to this link for build results (access rights to CI server needed):
https://ci.freerdp.com//job/PullRequestTester/6640/

@freerdp-bot
Copy link

Refer to this link for build results (access rights to CI server needed):
https://ci.freerdp.com//job/PullRequestTester/6642/

@freerdp-bot
Copy link

Refer to this link for build results (access rights to CI server needed):
https://ci.freerdp.com//job/PullRequestTester/6644/

@akallabeth akallabeth requested a review from llyzs November 3, 2021 10:39
@akallabeth
Copy link
Member Author

@llyzs maybe you can have a look at this too?

@llyzs
Copy link
Member

llyzs commented Nov 4, 2021

@akallabeth I don't know what was the original issue that the PR is trying to solve, but we should not use different color matrix than specified in the MS spec. The problem could be elsewhere.

@akallabeth
Copy link
Member Author

@llyzs the issue is only visible with [RDPEVOR] video redirection.
When the h264 data is sent, then the colors do not match the background.
To test, play a video on youtube and wait until the video redirection kicks in.
When that happens, the white area surrounding the video will have a slightly different color from what it previously was. (the redirection does usually contain a few lines around the video as well)

@alexandru-bagu
Copy link
Contributor

Maybe it would be worth considering whether we can have the matrix change only for decoding when we know we are connected to a Windows terminal server implementation, since that's when the issue presents itself.

@akallabeth
Copy link
Member Author

@alexandru-bagu you don´t know that, there is no way to (properly) identify the remote os

The YUV to RGB conversion matric in
[MS-RDPEGFX] 3.3.8.3.1 Color Conversion seems to produce color that
is not consistent for AVC420 streams. Using a modified matrix now.
@freerdp-bot
Copy link

Refer to this link for build results (access rights to CI server needed):
https://ci.freerdp.com//job/PullRequestTester/6661/

@akallabeth akallabeth modified the milestones: 3.0.0-beta1, next-3.0 Jul 25, 2023
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.

None yet

4 participants