-
Notifications
You must be signed in to change notification settings - Fork 211
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
Check that the gain map max is >= gain map min. #2580
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
#include <cstdint> | ||
#include <cstdlib> | ||
#include <limits> | ||
#include <utility> | ||
#include <vector> | ||
|
||
#include "avif/avif.h" | ||
|
@@ -167,13 +168,31 @@ inline auto ArbitraryAvifAnim() { | |
return fuzztest::OneOf(ArbitraryAvifAnim8b(), ArbitraryAvifAnim16b()); | ||
} | ||
|
||
// TODO: Try StructOf<Metadata>(StructOf<uint32_t[3]>())? | ||
// Generates two signed fractions where the first one is smaller than the second | ||
// one. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the first one is smaller than or equal to the second one, right? |
||
inline auto ArbitraryMinMaxSignedFraction() { | ||
return fuzztest::FlatMap( | ||
[](int32_t max_n, uint32_t max_d) { | ||
return fuzztest::Map( | ||
[max_n, max_d](int32_t min_n) { | ||
// For simplicity, use the same denominator for both fractions. | ||
// This does not cover all possible fractions but makes it easy | ||
// to gurantee that the fraction is smaller. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: gurantee => guarantee Add "first" before "fraction". |
||
return std::pair<avifSignedFraction, avifSignedFraction>( | ||
{min_n, max_d}, {max_n, max_d}); | ||
}, | ||
fuzztest::InRange<int32_t>(std::numeric_limits<int32_t>::min(), | ||
max_n)); | ||
}, | ||
fuzztest::Arbitrary<int32_t>(), | ||
fuzztest::InRange<uint32_t>(1, std::numeric_limits<uint32_t>::max())); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Optional: Use If this change is correct, make the same change to the other instances below. Or you can make these change in a separate pull request. |
||
} | ||
|
||
ImagePtr AddGainMapToImage( | ||
ImagePtr image, ImagePtr gain_map, int32_t gain_map_min_n0, | ||
int32_t gain_map_min_n1, int32_t gain_map_min_n2, uint32_t gain_map_min_d0, | ||
uint32_t gain_map_min_d1, uint32_t gain_map_min_d2, int32_t gain_map_max_n0, | ||
int32_t gain_map_max_n1, int32_t gain_map_max_n2, uint32_t gain_map_max_d0, | ||
uint32_t gain_map_max_d1, uint32_t gain_map_max_d2, | ||
ImagePtr image, ImagePtr gain_map, | ||
const std::pair<avifSignedFraction, avifSignedFraction>& gain_map_min_max0, | ||
const std::pair<avifSignedFraction, avifSignedFraction>& gain_map_min_max1, | ||
const std::pair<avifSignedFraction, avifSignedFraction>& gain_map_min_max2, | ||
uint32_t gain_map_gamma_n0, uint32_t gain_map_gamma_n1, | ||
uint32_t gain_map_gamma_n2, uint32_t gain_map_gamma_d0, | ||
uint32_t gain_map_gamma_d1, uint32_t gain_map_gamma_d2, | ||
|
@@ -189,16 +208,8 @@ ImagePtr AddGainMapToImage( | |
inline auto ArbitraryAvifImageWithGainMap() { | ||
return fuzztest::Map( | ||
AddGainMapToImage, ArbitraryAvifImage(), ArbitraryAvifImage(), | ||
fuzztest::Arbitrary<int32_t>(), fuzztest::Arbitrary<int32_t>(), | ||
fuzztest::Arbitrary<int32_t>(), | ||
fuzztest::InRange<uint32_t>(1, std::numeric_limits<uint32_t>::max()), | ||
fuzztest::InRange<uint32_t>(1, std::numeric_limits<uint32_t>::max()), | ||
fuzztest::InRange<uint32_t>(1, std::numeric_limits<uint32_t>::max()), | ||
fuzztest::Arbitrary<int32_t>(), fuzztest::Arbitrary<int32_t>(), | ||
fuzztest::Arbitrary<int32_t>(), | ||
fuzztest::InRange<uint32_t>(1, std::numeric_limits<uint32_t>::max()), | ||
fuzztest::InRange<uint32_t>(1, std::numeric_limits<uint32_t>::max()), | ||
fuzztest::InRange<uint32_t>(1, std::numeric_limits<uint32_t>::max()), | ||
ArbitraryMinMaxSignedFraction(), ArbitraryMinMaxSignedFraction(), | ||
ArbitraryMinMaxSignedFraction(), | ||
fuzztest::InRange<uint32_t>(1, std::numeric_limits<uint32_t>::max()), | ||
fuzztest::InRange<uint32_t>(1, std::numeric_limits<uint32_t>::max()), | ||
fuzztest::InRange<uint32_t>(1, std::numeric_limits<uint32_t>::max()), | ||
|
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.
Nit: change
" "
to": "
so that the output looks likeERROR_CODE: error message
.Also in line 57.