-
-
Notifications
You must be signed in to change notification settings - Fork 852
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
Fix Vp8Residual costs calculation #2432
Conversation
/// Initializes a new instance of the <see cref="Vp8BandProbas"/> class. | ||
/// Only used for unit tests. | ||
/// </summary> | ||
[JsonConstructor] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably use a custom JSON converter in the tests rather than adding attributes to the source.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry @brianpopow I've given you the runaround here. I didn't realize you'd introduced the constructors.
Let's go with your original plan but wrap the namespace imports and constructor code in the following conditional.
#if SIXLABORS_TESTING || SIXLABORS_TESTING_PREVIEW
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's go with your original plan but wrap the namespace imports and constructor code in the following conditional.
#if SIXLABORS_TESTING || SIXLABORS_TESTING_PREVIEW
I dont think that's a good idea. If someone does a fresh clone of the repo and tries to run the tests, those webp tests will fail without any obvious reason. I dont think test should behave different when a environment is set. Unfortunately I dont have a better idea so far.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we avoid the json and populate the test instance with equivalent data generated in a class using string builder or similar?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we avoid the json and populate the test instance with equivalent data generated in a class using string builder or similar?
Usually I would create a test instance in the unittest and populate it with data, but for Vp8Residual
that does not seem feasible. There are so many nested arrays, that I dont know how this can be populated manually. Thats why I have chosen to go for json serialization.
Also I dont understand your suggestion with the string builder.
I now tried to use the binary serialization and this was looking promising. We would not need the additional constructors.
But now I noticed its marked as obsolete 😢
See: https://learn.microsoft.com/de-de/dotnet/standard/serialization/binaryformatter-security-guide
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed serialization now to use BinaryWriter/BinaryReader, according to https://learn.microsoft.com/de-de/dotnet/standard/serialization/binaryformatter-security-guide this should be fine.
No additional constructors required now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah that’s fantastic! We’ll done finding a solution!
Prerequisites
Description
This PR fixes an issue with the AVX2 version of the residual costs calculation. In some rare cases it does not match the scalar version. I have switch back to the SSE2 variant, which matches the original libwebp implementation.
AVX version was
SSE version:
The problem was that
Avx2.PackSignedSaturate(e0, e0);
is not the same asSse2.PackSignedSaturate(e0, e1);
Related to #2414