Skip to content

Commit bfd68f7

Browse files
Rahi374naushir
authored andcommitted
libcamera: clock_recovery: Use nanoseconds in addSample()
FrameWallClock was recently changed to nanoseconds, and all users of ClockRecovery use SensorTimestamp directly, which is also in nanoseconds. Thus addSample() should also use nanoseconds. Fix this. Signed-off-by: Paul Elder <[email protected]> Reviewed-by: Barnabás Pőcze <[email protected]> Reviewed-by: Naushir Patuck <[email protected]> Tested-by: Naushir Patuck <[email protected]>
1 parent bd124d8 commit bfd68f7

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/libcamera/clock_recovery.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,10 @@ void ClockRecovery::addSample()
118118
clock_gettime(CLOCK_BOOTTIME, &bootTime1);
119119
clock_gettime(CLOCK_REALTIME, &wallTime);
120120
clock_gettime(CLOCK_BOOTTIME, &bootTime2);
121-
uint64_t boot1 = bootTime1.tv_sec * 1000000ULL + bootTime1.tv_nsec / 1000;
122-
uint64_t boot2 = bootTime2.tv_sec * 1000000ULL + bootTime2.tv_nsec / 1000;
121+
uint64_t boot1 = bootTime1.tv_sec * 1000000000ULL + bootTime1.tv_nsec;
122+
uint64_t boot2 = bootTime2.tv_sec * 1000000000ULL + bootTime2.tv_nsec;
123123
uint64_t boot = (boot1 + boot2) / 2;
124-
uint64_t wall = wallTime.tv_sec * 1000000ULL + wallTime.tv_nsec / 1000;
124+
uint64_t wall = wallTime.tv_sec * 1000000000ULL + wallTime.tv_nsec;
125125

126126
addSample(boot, wall);
127127
}

0 commit comments

Comments
 (0)