Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions player/video.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ void reset_video_state(struct MPContext *mpctx)
if (t && t->dec)
mp_decoder_wrapper_set_play_dir(t->dec, mpctx->play_dir);
}
if (mpctx->video_out)
vo_forget_frames(mpctx->video_out);

for (int n = 0; n < mpctx->num_next_frames; n++)
mp_image_unrefp(&mpctx->next_frames[n]);
Expand Down
10 changes: 10 additions & 0 deletions video/out/vo.c
Original file line number Diff line number Diff line change
Expand Up @@ -1537,3 +1537,13 @@ struct mp_image_params vo_get_target_params(struct vo *vo)
mp_mutex_unlock(&vo->params_mutex);
return p;
}

void vo_forget_frames(struct vo *vo)
{
struct vo_internal *in = vo->in;
mp_mutex_lock(&in->lock);
forget_frames(vo);
TA_FREEP(&in->frame_queued);
TA_FREEP(&in->current_frame);
mp_mutex_unlock(&in->lock);
}
2 changes: 2 additions & 0 deletions video/out/vo.h
Original file line number Diff line number Diff line change
Expand Up @@ -579,4 +579,6 @@ struct vo_frame *vo_frame_ref(struct vo_frame *frame);
struct mp_image_params vo_get_current_params(struct vo *vo);
struct mp_image_params vo_get_target_params(struct vo *vo);

void vo_forget_frames(struct vo *vo);

#endif /* MPLAYER_VIDEO_OUT_H */
21 changes: 12 additions & 9 deletions video/out/vo_gpu_next.c
Original file line number Diff line number Diff line change
Expand Up @@ -1002,6 +1002,15 @@ static enum pl_color_primaries get_best_prim_container(const struct pl_raw_prima
static void update_hook_opts_dynamic(struct priv *p, const struct pl_hook *hook,
const struct mp_image *mpi);

static void reset(struct priv *p)
{
pl_renderer_flush_cache(p->rr);
pl_queue_reset(p->queue);
p->last_pts = 0.0;
p->last_id = 0;
p->want_reset = false;
}

static bool draw_frame(struct vo *vo, struct vo_frame *frame)
{
struct priv *p = vo->priv;
Expand Down Expand Up @@ -1056,13 +1065,8 @@ static bool draw_frame(struct vo *vo, struct vo_frame *frame)
for (int n = 0; n < frame->num_frames; n++) {
int id = frame->frame_id + n;

if (p->want_reset) {
pl_renderer_flush_cache(p->rr);
pl_queue_reset(p->queue);
p->last_pts = 0.0;
p->last_id = 0;
p->want_reset = false;
}
if (p->want_reset)
reset(p);

if (id <= p->last_id)
continue; // ignore already seen frames
Expand Down Expand Up @@ -1831,8 +1835,7 @@ static int control(struct vo *vo, uint32_t request, void *data)
}

case VOCTRL_RESET:
// Defer until the first new frame (unique ID) actually arrives
p->want_reset = true;
reset(p);
return VO_TRUE;

case VOCTRL_PERFORMANCE_DATA: {
Expand Down