fix frame delays being 1000x too long — from_millis should be from_micros
- SHA
609a151c62900df0a0f55aefbeb006bc106ccd00- Parents
-
1578a8c - Tree
37db125
609a151
609a151c62900df0a0f55aefbeb006bc106ccd001578a8c
37db125| Status | File | + | - |
|---|---|---|---|
| M |
garbg/src/media/apng.rs
|
1 | 1 |
| M |
garbg/src/media/gif.rs
|
3 | 1 |
| M |
garbg/src/media/webp.rs
|
1 | 1 |
garbg/src/media/apng.rsmodified@@ -162,7 +162,7 @@ fn frame_delay_to_duration(frame: &Frame) -> Duration { | |||
| 162 | if denominator == 0 { | 162 | if denominator == 0 { |
| 163 | Duration::ZERO | 163 | Duration::ZERO |
| 164 | } else { | 164 | } else { |
| 165 | - Duration::from_millis((numerator as u64 * 1000) / denominator as u64) | 165 | + Duration::from_micros((numerator as u64 * 1000) / denominator as u64) |
| 166 | } | 166 | } |
| 167 | } | 167 | } |
| 168 | 168 | ||
garbg/src/media/gif.rsmodified@@ -162,12 +162,14 @@ impl AnimatedGif { | |||
| 162 | } | 162 | } |
| 163 | 163 | ||
| 164 | /// Convert frame delay ratio to Duration | 164 | /// Convert frame delay ratio to Duration |
| 165 | +/// numer_denom_ms() returns (numerator, denominator) where numerator/denominator = delay in ms | ||
| 165 | fn frame_delay_to_duration(frame: &Frame) -> Duration { | 166 | fn frame_delay_to_duration(frame: &Frame) -> Duration { |
| 166 | let (numerator, denominator) = frame.delay().numer_denom_ms(); | 167 | let (numerator, denominator) = frame.delay().numer_denom_ms(); |
| 167 | if denominator == 0 { | 168 | if denominator == 0 { |
| 168 | Duration::ZERO | 169 | Duration::ZERO |
| 169 | } else { | 170 | } else { |
| 170 | - Duration::from_millis((numerator as u64 * 1000) / denominator as u64) | 171 | + // Convert ms ratio to microseconds for sub-ms precision |
| 172 | + Duration::from_micros((numerator as u64 * 1000) / denominator as u64) | ||
| 171 | } | 173 | } |
| 172 | } | 174 | } |
| 173 | 175 | ||
garbg/src/media/webp.rsmodified@@ -159,7 +159,7 @@ fn frame_delay_to_duration(frame: &Frame) -> Duration { | |||
| 159 | if denominator == 0 { | 159 | if denominator == 0 { |
| 160 | Duration::ZERO | 160 | Duration::ZERO |
| 161 | } else { | 161 | } else { |
| 162 | - Duration::from_millis((numerator as u64 * 1000) / denominator as u64) | 162 | + Duration::from_micros((numerator as u64 * 1000) / denominator as u64) |
| 163 | } | 163 | } |
| 164 | } | 164 | } |
| 165 | 165 | ||