-
Notifications
You must be signed in to change notification settings - Fork 208
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
Convert color conversion internals to matrices stored as 1D array #1932
Conversation
src/colrconvert.c
Outdated
coeffs[1][2] = coeffsTmp[5]; | ||
coeffs[2][0] = coeffsTmp[6]; | ||
coeffs[2][1] = coeffsTmp[7]; | ||
coeffs[2][2] = coeffsTmp[8]; |
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.
This kind of conversion is not ideal.
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.
Done
This is to prevent passing M[3][3] and make sure they are const, cf https://c-faq.com/ansi/constmismatch.html
Thank you for writing this pull request. The new code is not as readable as the original code, so I think we should ask in the C/C++ discussion group at Google about this problem. The two dimensional array is not exactly the same as https://c-faq.com/ansi/constmismatch.html. Hopefully there is a better solution. I am also wondering why none of the compilers we use regularly warn about this. Is it because we do not enable a certain warning option? |
I found a Stack Overflow question about this issue: |
{{ | ||
0.4360747, 0.3850649, 0.1430804, // row 0 | ||
0.2225045, 0.7168786, 0.0606169, // row 1 | ||
0.0139322, 0.0971045, 0.7141733 // row 2 |
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.
If the original still works, the original code seems to be a better initializer for std::array<std::array<double, 3>, 3>
(see line 19).
This comment also applies to the second arguments for the ExpectMatrixNear()
calls below.
I tried to play with clang options like '-Wincompatible-pointer-types-discards-qualifiers' to no avail. Ditto for gcc. |
Vincent: Removing the const from the function prorotypes is fine by me. My suggestion was to wrap the two-dimensional array in a struct, e.g.,
But this requires more changes to the code, because |
Right, but the problem would be the same: a const avifMat offers no const guarantee on the data in |
Closing in favor of #1946 |
Are you sure? I guess you may be thinking of a struct like
then the following is allowed:
On the other hand, if we have a struct like the following:
then the following is not allowed:
|
I thought the same issue would pop with 2d but it indeed works. |
This is to prevent passing M[3][3] and make sure they are const, cf https://c-faq.com/ansi/constmismatch.html