1
0
mirror of https://github.com/mpv-player/mpv synced 2025-02-21 07:16:56 +00:00

vo_gpu_next: improve PTS clamping

Originally suggested by @haasn. Instead of awkwardly using a pts from
the previous render loop, we can just peek into pl_queue and use the pts
of the first frame instead. This eliminates a lot of weird artifacts
that can happen on discontinuities like seeking. Fixes #12355.
This commit is contained in:
Dudemanguy 2023-11-07 19:03:02 -06:00
parent 9199afc405
commit 332619042f

View File

@ -966,9 +966,14 @@ static void draw_frame(struct vo *vo, struct vo_frame *frame)
);
// mpv likes to generate sporadically jumping PTS shortly after
// initialization, but pl_queue does not like these. Hard-clamp as
// a simple work-around.
qparams.pts = p->last_pts = MPMAX(qparams.pts, p->last_pts);
// initialization, but pl_queue does not like these. Hard-clamp to
// the first frame in the queue as a simple workaround.
struct pl_source_frame first;
if (pl_queue_peek(p->queue, 0, &first)) {
if (qparams.pts < first.pts)
MP_VERBOSE(vo, "Clamping first frame PTS from %f to %f\n", qparams.pts, first.pts);
qparams.pts = p->last_pts = MPMAX(qparams.pts, first.pts);
}
switch (pl_queue_update(p->queue, &mix, &qparams)) {
case PL_QUEUE_ERR: