-
Notifications
You must be signed in to change notification settings - Fork 5k
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
bcm2835-camera: Fix timestamp calculation problem #2214
Conversation
Use div_s64_rem() to convert usec timestamp to timeval to avoid integer signedness bug.
Looks highly plausible. Actually that code ought to be reworked as the actual I'm a little bemused as to how come you're getting a frame timestamped 135ms before we made the request. You're using yuv420 planar, but what resolution are you asking for? It's possibly another issue that needs investigating. |
(Sorry for the typo above, should be using I found the bug while trying to figure out why this was happening. I noticed that start_pts turn positive every time I change the frame rate.
I reformatted the output in table form for clarity. Do you see the pattern?
This is what I see when I execute ffmpeg without the fix.
|
A big thank you for the second update - my comment was more for my own benefit than a request to change the PR, but the update is very welcome. Looks fine to me. |
Sure, no problem. Let me know if you want me to make any other changes. |
I'm good. |
Thanks! |
kernel: brcmfmac: Avoid possible out-of-bounds read kernel: brcmfmac: Delete redundant length check kernel: brcmfmac: Add check for short event packets kernel: bcm2835-camera: Fix timestamp calculation problem See: raspberrypi/linux#2214 kernel: amba_pl011: Add cts-event-workaround DT property See: raspberrypi/linux#1280 kernel: amba_pl011: Insert mb() for correct FIFO handling kernel: brcmfmac: add CLM download support kernel: brcmfmac: request_firmware_direct is quieter
kernel: brcmfmac: Avoid possible out-of-bounds read kernel: brcmfmac: Delete redundant length check kernel: brcmfmac: Add check for short event packets kernel: bcm2835-camera: Fix timestamp calculation problem See: raspberrypi/linux#2214 kernel: amba_pl011: Add cts-event-workaround DT property See: raspberrypi/linux#1280 kernel: amba_pl011: Insert mb() for correct FIFO handling kernel: brcmfmac: add CLM download support kernel: brcmfmac: request_firmware_direct is quieter firmware: arm_loader: Add mbox call to query RSTS register See: arm_loader: Add mbox call to query RSTS register firmware: IL Camera: Add manual analog and digital gain controls firmware: video_decode: Allow stride to be >= min required firmware: IL ISP: Add white balance and digital gain to ISP component firmware: variants: drop [read|write]_[media|still] and image_[read|write]
* bcm2835-camera: Fix timestamp calculation problem Use div_s64_rem() to convert usec timestamp to timeval to avoid integer signedness bug. * bcm2835-camera: Store kernel start time in NSEC instead of USEC * bcm2835-camera: Reword debug message for clarity
* bcm2835-camera: Fix timestamp calculation problem Use div_s64_rem() to convert usec timestamp to timeval to avoid integer signedness bug. * bcm2835-camera: Store kernel start time in NSEC instead of USEC * bcm2835-camera: Reword debug message for clarity
* bcm2835-camera: Fix timestamp calculation problem Use div_s64_rem() to convert usec timestamp to timeval to avoid integer signedness bug. * bcm2835-camera: Store kernel start time in NSEC instead of USEC * bcm2835-camera: Reword debug message for clarity
* bcm2835-camera: Fix timestamp calculation problem Use div_s64_rem() to convert usec timestamp to timeval to avoid integer signedness bug. * bcm2835-camera: Store kernel start time in NSEC instead of USEC * bcm2835-camera: Reword debug message for clarity
* bcm2835-camera: Fix timestamp calculation problem Use div_s64_rem() to convert usec timestamp to timeval to avoid integer signedness bug. * bcm2835-camera: Store kernel start time in NSEC instead of USEC * bcm2835-camera: Reword debug message for clarity
* bcm2835-camera: Fix timestamp calculation problem Use div_s64_rem() to convert usec timestamp to timeval to avoid integer signedness bug. * bcm2835-camera: Store kernel start time in NSEC instead of USEC * bcm2835-camera: Reword debug message for clarity
* bcm2835-camera: Fix timestamp calculation problem Use div_s64_rem() to convert usec timestamp to timeval to avoid integer signedness bug. * bcm2835-camera: Store kernel start time in NSEC instead of USEC * bcm2835-camera: Reword debug message for clarity
* bcm2835-camera: Fix timestamp calculation problem Use div_s64_rem() to convert usec timestamp to timeval to avoid integer signedness bug. * bcm2835-camera: Store kernel start time in NSEC instead of USEC * bcm2835-camera: Reword debug message for clarity
* bcm2835-camera: Fix timestamp calculation problem Use div_s64_rem() to convert usec timestamp to timeval to avoid integer signedness bug. * bcm2835-camera: Store kernel start time in NSEC instead of USEC * bcm2835-camera: Reword debug message for clarity
* bcm2835-camera: Fix timestamp calculation problem Use div_s64_rem() to convert usec timestamp to timeval to avoid integer signedness bug. * bcm2835-camera: Store kernel start time in NSEC instead of USEC * bcm2835-camera: Reword debug message for clarity
* bcm2835-camera: Fix timestamp calculation problem Use div_s64_rem() to convert usec timestamp to timeval to avoid integer signedness bug. * bcm2835-camera: Store kernel start time in NSEC instead of USEC * bcm2835-camera: Reword debug message for clarity
* bcm2835-camera: Fix timestamp calculation problem Use div_s64_rem() to convert usec timestamp to timeval to avoid integer signedness bug. * bcm2835-camera: Store kernel start time in NSEC instead of USEC * bcm2835-camera: Reword debug message for clarity
* bcm2835-camera: Fix timestamp calculation problem Use div_s64_rem() to convert usec timestamp to timeval to avoid integer signedness bug. * bcm2835-camera: Store kernel start time in NSEC instead of USEC * bcm2835-camera: Reword debug message for clarity
* bcm2835-camera: Fix timestamp calculation problem Use div_s64_rem() to convert usec timestamp to timeval to avoid integer signedness bug. * bcm2835-camera: Store kernel start time in NSEC instead of USEC * bcm2835-camera: Reword debug message for clarity
* bcm2835-camera: Fix timestamp calculation problem Use div_s64_rem() to convert usec timestamp to timeval to avoid integer signedness bug. * bcm2835-camera: Store kernel start time in NSEC instead of USEC * bcm2835-camera: Reword debug message for clarity
* bcm2835-camera: Fix timestamp calculation problem Use div_s64_rem() to convert usec timestamp to timeval to avoid integer signedness bug. * bcm2835-camera: Store kernel start time in NSEC instead of USEC * bcm2835-camera: Reword debug message for clarity
* bcm2835-camera: Fix timestamp calculation problem Use div_s64_rem() to convert usec timestamp to timeval to avoid integer signedness bug. * bcm2835-camera: Store kernel start time in NSEC instead of USEC * bcm2835-camera: Reword debug message for clarity
* bcm2835-camera: Fix timestamp calculation problem Use div_s64_rem() to convert usec timestamp to timeval to avoid integer signedness bug. * bcm2835-camera: Store kernel start time in NSEC instead of USEC * bcm2835-camera: Reword debug message for clarity
* bcm2835-camera: Fix timestamp calculation problem Use div_s64_rem() to convert usec timestamp to timeval to avoid integer signedness bug. * bcm2835-camera: Store kernel start time in NSEC instead of USEC * bcm2835-camera: Reword debug message for clarity
* bcm2835-camera: Fix timestamp calculation problem Use div_s64_rem() to convert usec timestamp to timeval to avoid integer signedness bug. * bcm2835-camera: Store kernel start time in NSEC instead of USEC * bcm2835-camera: Reword debug message for clarity
* bcm2835-camera: Fix timestamp calculation problem Use div_s64_rem() to convert usec timestamp to timeval to avoid integer signedness bug. * bcm2835-camera: Store kernel start time in NSEC instead of USEC * bcm2835-camera: Reword debug message for clarity
* bcm2835-camera: Fix timestamp calculation problem Use div_s64_rem() to convert usec timestamp to timeval to avoid integer signedness bug. * bcm2835-camera: Store kernel start time in NSEC instead of USEC * bcm2835-camera: Reword debug message for clarity
* bcm2835-camera: Fix timestamp calculation problem Use div_s64_rem() to convert usec timestamp to timeval to avoid integer signedness bug. * bcm2835-camera: Store kernel start time in NSEC instead of USEC * bcm2835-camera: Reword debug message for clarity
* bcm2835-camera: Fix timestamp calculation problem Use div_s64_rem() to convert usec timestamp to timeval to avoid integer signedness bug. * bcm2835-camera: Store kernel start time in NSEC instead of USEC * bcm2835-camera: Reword debug message for clarity
This reverts commit 90ac037. This has been fixed in an alternate format upstream, so adopt that. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
Use div_s64_rem() to convert usec timestamp to timeval to avoid integer signedness bug.
While capturing uncompressed frames with ffmpeg, I notice the
bcm2835-v4l2
module generates very large negative timestamp values (e.g., -140448221.376697). These large negative values trigger a bunch of issues (e.g., DTS/PTS "invalid dropping" warnings) during capture.By turning on module's debug flag, I see this in system log:
Reading the
bcm2835-camera.c
carefully, I noticed the use ofdiv_u64_rem(...)
causes an integer signedness bug. For the conversion, it should be14389.825081
Instead of-140448221.376697
.