diff options
author | Dudemanguy <random342@airmail.cc> | 2023-09-17 20:44:05 -0500 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2023-10-10 19:10:55 +0000 |
commit | c82c55b4b9d4015ba79fb36170defb328563cdea (patch) | |
tree | 326dfdfbe8d262d09d741945b89ccb1b111c3956 /video/out/vo.c | |
parent | 8fccd6bf91abe42a032b2c7c14bb7a0366ad19bf (diff) | |
download | mpv-c82c55b4b9d4015ba79fb36170defb328563cdea.tar.bz2 mpv-c82c55b4b9d4015ba79fb36170defb328563cdea.tar.xz |
vo: use nanoseconds for frame duration and pts
Diffstat (limited to 'video/out/vo.c')
-rw-r--r-- | video/out/vo.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/video/out/vo.c b/video/out/vo.c index 496f01f45e..7b50b90745 100644 --- a/video/out/vo.c +++ b/video/out/vo.c @@ -232,7 +232,7 @@ static void read_opts(struct vo *vo) struct vo_internal *in = vo->in; pthread_mutex_lock(&in->lock); - in->timing_offset = (uint64_t)(vo->opts->timing_offset * 1e6); + in->timing_offset = (uint64_t)(vo->opts->timing_offset * 1e9); pthread_mutex_unlock(&in->lock); } @@ -782,7 +782,7 @@ bool vo_is_ready_for_frame(struct vo *vo, int64_t next_pts) // time. next_pts -= in->timing_offset; next_pts -= in->flip_queue_offset; - int64_t now = mp_time_us(); + int64_t now = mp_time_ns(); if (next_pts > now) r = false; if (!in->wakeup_pts || next_pts < in->wakeup_pts) { @@ -830,9 +830,9 @@ void vo_wait_frame(struct vo *vo) static void wait_until(struct vo *vo, int64_t target) { struct vo_internal *in = vo->in; - struct timespec ts = mp_time_us_to_realtime(target); + struct timespec ts = mp_time_ns_to_realtime(target); pthread_mutex_lock(&in->lock); - while (target > mp_time_us()) { + while (target > mp_time_ns()) { if (in->queued_events & VO_EVENT_LIVE_RESIZING) break; if (pthread_cond_timedwait(&in->wakeup, &in->lock, &ts)) @@ -873,7 +873,7 @@ static bool render_frame(struct vo *vo) if (in->paused) frame->vsync_offset = 0; - int64_t now = mp_time_us(); + int64_t now = mp_time_ns(); int64_t pts = frame->pts; int64_t duration = frame->duration; int64_t end_time = pts + duration; @@ -889,7 +889,7 @@ static bool render_frame(struct vo *vo) in->dropped_frame &= frame->can_drop; // Even if we're hopelessly behind, rather degrade to 10 FPS playback, // instead of just freezing the display forever. - in->dropped_frame &= now - (in->prev_vsync / 1000.0) < 100 * 1000; + in->dropped_frame &= now - in->prev_vsync < 100 * 1e6; in->dropped_frame &= in->hasframe_rendered; // Setup parameters for the next time this frame is drawn. ("frame" is the @@ -907,7 +907,7 @@ static bool render_frame(struct vo *vo) bool use_vsync = in->current_frame->display_synced && !in->paused; if (use_vsync && !in->expecting_vsync) // first DS frame in a row - in->prev_vsync = now * 1000; + in->prev_vsync = now; in->expecting_vsync = use_vsync; // Store the initial value before we unlock. @@ -1230,15 +1230,15 @@ void vo_get_src_dst_rects(struct vo *vo, struct mp_rect *out_src, out_src, out_dst, out_osd); } -// flip_page[_timed] will be called offset_us microseconds too early. +// flip_page[_timed] will be called offset_us nanoseconds too early. // (For vo_vdpau, which does its own timing.) // num_req_frames set the requested number of requested vo_frame.frames. // (For vo_gpu interpolation.) -void vo_set_queue_params(struct vo *vo, int64_t offset_us, int num_req_frames) +void vo_set_queue_params(struct vo *vo, int64_t offset_ns, int num_req_frames) { struct vo_internal *in = vo->in; pthread_mutex_lock(&in->lock); - in->flip_queue_offset = offset_us; + in->flip_queue_offset = offset_ns; in->req_frames = MPCLAMP(num_req_frames, 1, VO_MAX_REQ_FRAMES); pthread_mutex_unlock(&in->lock); } |