-
Notifications
You must be signed in to change notification settings - Fork 621
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
Encapsulate the delay ratio #1128
Conversation
Two major reasons: * This avoids the public dependency on `num_ratio`. * The internal representation can be changed. This already proved necessary once (from u16 rational) and in this manner we are free to do it again by adding an inner enum representation. Note that we already have rounding semantics for the meaning of Delay as gif rounds to the nearest 10ms when writing frames. Any more or less precise representation can be made to round to the closest u32 ratio.
After this PR the only remaining public dependency will be |
Could we avoid adding a new type here, and either use a f32 / u32 with an associated base unit or just a Duration? GIF images can only have delays in multiples of 10ms so it won't impact accuracy for any current uses, and we are probably going to want to redesign this area of the API again anyway |
Good point, an interaction with
I'll add the rounding, and best effort conversion from |
With the original available as a millisecond ratio this can easily be done to the accuracy of nanoseconds, which is the finest available.
Given the prior usage, it does not make much sense to provide an exact conversion. However, it should be clear that precision is not finite and the representation is not exactly that of a Duration. The implementation turned out to be fairly involved as the num-fraction crate does not provide approximation algorithms for fractions. No fear, we code them ourselves with extensive testing to cover much more than the required accuracy tests.
@fintelia With conversion from |
Note: we can reuse the implementation of |
I'd feel much better about this if we had multiple different image formats that used the animation API, rather than just extrapolating from GIF. Especially since a bunch of the bounded fraction stuff is really only relevant to formats that don't encode frame delays as an integer number of milliseconds. Because of that, I'd lead towards a minimum viable option of just exposing the GIF frame delay, and planning to make a minor breaking change (to add the rest of this proposal) if/when more formats are added |
That is already a sufficiently complex amount of conventions to warrant an opaque representation in my opinion, although we might as well switch to an inner enum representation right now instead of later. But let's just get the interface correct and not worry about implementation too much.
A change can't be both minor and breaking, and lib.rs shows the version churn results, many outdated dependencies that are stuck without security and stability updates. |
I'll take it 👍 means that this is fine? Then I'd merge this and prepare release notes for |
Sounds good. If you're confident that the design will work for all those other formats as well then I think we should be fine |
Two major reasons:
num_ratio
.necessary once (from u16 rational) and in this manner we are free to
do it again by adding an inner enum representation.
Note that we already have rounding semantics for the meaning of Delay as
gif rounds to the nearest 10ms when writing frames. Any more or less
precise representation can be made to round to the closest u32 ratio.