| 11 | } |
| 12 | |
| 13 | void FrameTracker::get_interval_frames(fl::u32 now, fl::u32 *frameNumber, |
| 14 | fl::u32 *nextFrameNumber, |
| 15 | u8 *amountOfNextFrame) const { |
| 16 | // Account for any pause time |
| 17 | fl::u32 effectiveTime = now; |
| 18 | |
| 19 | // Convert milliseconds to microseconds for precise calculation |
| 20 | fl::u64 microseconds = static_cast<fl::u64>(effectiveTime) * 1000ULL; |
| 21 | |
| 22 | // Calculate frame number with proper rounding |
| 23 | *frameNumber = microseconds / mMicrosSecondsPerInterval; |
| 24 | *nextFrameNumber = *frameNumber + 1; |
| 25 | |
| 26 | // Calculate interpolation amount if requested |
| 27 | if (amountOfNextFrame != nullptr) { |
| 28 | fl::u64 frame1_start = (*frameNumber * mMicrosSecondsPerInterval); |
| 29 | fl::u64 frame2_start = (*nextFrameNumber * mMicrosSecondsPerInterval); |
| 30 | fl::u32 rel_time = microseconds - frame1_start; |
| 31 | fl::u32 frame_duration = frame2_start - frame1_start; |
| 32 | u8 progress = map_range<fl::u32, u8>(rel_time, 0, frame_duration, 0, 255); |
| 33 | *amountOfNextFrame = progress; |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | fl::u32 FrameTracker::get_exact_timestamp_ms(fl::u32 frameNumber) const { |
| 38 | fl::u64 microseconds = frameNumber * mMicrosSecondsPerInterval; |
no outgoing calls
no test coverage detected