This commit is contained in:
Romain Vimont 2021-07-04 17:19:47 +02:00
parent 40721126e2
commit e17e8077d2
3 changed files with 36 additions and 2 deletions

View file

@ -308,7 +308,7 @@ screen_init(struct screen *screen, const struct screen_params *params) {
.on_new_frame = sc_video_buffer_on_new_frame,
};
bool ok = sc_video_buffer_init(&screen->vb, 0, &cbs, screen);
bool ok = sc_video_buffer_init(&screen->vb, 1000, &cbs, screen);
if (!ok) {
LOGE("Could not initialize video buffer");
return false;

View file

@ -159,7 +159,7 @@ sc_v4l2_sink_open(struct sc_v4l2_sink *vs) {
.on_new_frame = sc_video_buffer_on_new_frame,
};
bool ok = sc_video_buffer_init(&vs->vb, 0, &cbs, vs);
bool ok = sc_video_buffer_init(&vs->vb, 1, &cbs, vs);
if (!ok) {
LOGE("Could not initialize video buffer");
return false;

View file

@ -6,6 +6,40 @@
#include "util/log.h"
struct sc_clock {
double coeff;
sc_tick offset;
unsigned range;
struct {
sc_tick system;
sc_tick stream;
} last;
};
static void
sc_clock_init(struct sc_clock *clock) {
clock->coeff = 1;
clock->offset = 0;
clock->range = 0;
clock->last.system = 0;
clock->last.stream = 0;
}
static void
sc_clock_update(struct sc_clock *clock, sc_tick now, sc_tick stream_ts) {
sc_tick system_delta = now - clock->last.system;
sc_tick stream_delta = stream_ts - clock->last.stream;
double instant_coeff = (double) system_delta / stream_delta;
}
static sc_tick
sc_clock_get_system_ts(struct sc_clock *clock, sc_tick stream_ts) {
return (sc_tick) (stream_ts * clock->coeff) + clock->offset;
}
static struct sc_video_buffer_frame *
sc_video_buffer_frame_new(const AVFrame *frame) {
struct sc_video_buffer_frame *vb_frame = malloc(sizeof(*vb_frame));