libobs: Implement and use better scaling function for 64-bit integers
As os_gettime_ns() gets large the current scaling methods, mostly by casting to uint64_t, may lead to numerical overflows. Sweep the code and use util_mul_div64() where applicable. Signed-off-by: Hans Petter Selasky <hps@selasky.org>
This commit is contained in:
parent
47058d9b69
commit
0e4ea14ba1
22 changed files with 97 additions and 57 deletions
|
|
@ -2,6 +2,7 @@
|
|||
#include <util/bmem.h>
|
||||
#include <util/threading.h>
|
||||
#include <util/platform.h>
|
||||
#include <util/util_uint64.h>
|
||||
#include <obs.h>
|
||||
|
||||
struct sync_pair_aud {
|
||||
|
|
@ -54,7 +55,8 @@ static void *sync_pair_aud_thread(void *pdata)
|
|||
|
||||
for (uint64_t i = 0; i < frames; i++) {
|
||||
uint64_t ts =
|
||||
last_time + i * 1000000000ULL / sample_rate;
|
||||
last_time +
|
||||
util_mul_div64(i, 1000000000ULL, sample_rate);
|
||||
|
||||
if (whitelist_time(ts, interval, fps_num, fps_den)) {
|
||||
cos_val += rate * M_PI_X2;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue