Fix capture frame interval handling#50
Open
grawis wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix the mismatch between the frame interval reported through
VIDIOC_G_PARMand the actual capture timing.The previous implementation calculated:
For the default 1001/30000 time-per-frame value, this produces about
29.97, which represents frames per second, but was treated as milliseconds.
The new implementation calculates:
It then subtracts the frame processing time before sleeping, so the actual
capture period follows the configured V4L2 time-per-frame value.
Other changes:
Rename
output_fpstoframe_intervalbecause it stores seconds perframe, not frames per second.
Clamp
VIDIOC_S_PARMvalues to the range advertised byVIDIOC_ENUM_FRAMEINTERVALS.Reuse the same interval definitions for enumeration, initialization,
setting, reporting, and frame pacing.
Test results
Before:
Frame interval: reported=33.367 ms measured=29.989 ms
error=10.1% [FAIL]
After:
Frame interval: reported=33.367 ms measured=33.997 ms
error=1.9% [PASS]
Additional tests:
25 FPS: reported=40.000 ms measured=41.008 ms error=2.5% [PASS]
YUYV: reported=33.367 ms measured=34.012 ms error=1.9% [PASS]
Fixes #49
Summary by cubic
Fixes incorrect frame pacing by computing and applying the V4L2 time-per-frame correctly. Reported and actual intervals now align, reducing timing error from ~10% to ~2%.
output_fpstoframe_interval(seconds per frame).VIDIOC_S_PARMto the range fromVIDIOC_ENUM_FRAMEINTERVALS.Written for commit ef4fd9e. Summary will update on new commits.