-
Notifications
You must be signed in to change notification settings - Fork 214
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
Do not allow for monochrome + identity matrix #2667
base: main
Are you sure you want to change the base?
Conversation
908cbfe
to
6bf6a07
Compare
tests/gtest/aviflosslesstest.cc
Outdated
// Convert to a temporary PNG and read back, to have default matrix | ||
// coefficients. | ||
const std::string tmp_path = testing::TempDir() + "decoded_default.png"; | ||
ASSERT_TRUE(testutil::WriteImage(decoded.get(), tmp_path.c_str())); | ||
const ImagePtr decoded_lossless = | ||
ReadImageLossless(tmp_path, pixel_format, ignore_icc); | ||
|
||
// Verify that the ground truth and decoded images are the same. | ||
const ImagePtr ground_truth_lossless = | ||
ReadImageLossless(file_path, pixel_format, ignore_icc); | ||
const bool are_images_equal = | ||
testutil::AreImagesEqual(*ground_truth_lossless, *decoded_lossless); | ||
|
||
if (matrix_coefficients == AVIF_MATRIX_COEFFICIENTS_YCGCO) { | ||
// AVIF_MATRIX_COEFFICIENTS_YCGCO is not a lossless transform. | ||
ASSERT_FALSE(are_images_equal); | ||
} else if (pixel_format == AVIF_PIXEL_FORMAT_YUV400) { | ||
// For gray images, information is lost. | ||
ASSERT_FALSE(are_images_equal); | ||
} else { | ||
ASSERT_TRUE(are_images_equal); |
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 looks unrelated to the test above because ASSERT_TRUE(testutil::AreImagesEqual(*image, *decoded));
. Split into two units?
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.
Also add a CHANGELOG entry please
avifPixelFormat requested_format, | ||
avifBool ignore_icc) { | ||
ImagePtr image(avifImageCreateEmpty()); | ||
image->matrixCoefficients = AVIF_MATRIX_COEFFICIENTS_IDENTITY; |
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.
You check !image
after this line.
@@ -115,11 +115,11 @@ avifBool avifGetYUVColorSpaceInfo(const avifImage * image, avifYUVColorSpaceInfo | |||
return AVIF_FALSE; | |||
} | |||
|
|||
// Removing 400 here would break backward behavior but would respect the spec. |
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.
But this is checked for later? What path does this break?
return image; | ||
} | ||
|
||
class LosslessTest |
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.
Add a comment about what the parameters are. Tuples are convenient in tests, but aren't self documenting like structs.
TEST_P(LosslessTest, EncodeDecodeMatrixCoefficients) { | ||
const std::string& file_name = std::get<0>(GetParam()); | ||
const avifMatrixCoefficients matrix_coefficients = | ||
static_cast<avifMatrixCoefficients>(std::get<1>(GetParam())); |
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 the test just take the enum types as params to avoid all the casting?
This fixes #2639