mirror of
https://github.com/mpv-player/mpv.git
synced 2025-12-28 05:33:14 +00:00
video: don't drop last frame when deinterlacing with yadif
Or in other words, add support for properly draining remaining frames from video filters. vf_yadif is buffering at least one frame, and the buffered frame was not retrieved on EOF. For most filters, ignore this for now, and just adjust them to the changed semantics of filter_ext. But for vf_lavfi (used by vf_yadif), real support is implemented. libavfilter handles this simply by passing a NULL frame to av_buffersrc_add_frame(), so we just have to make mp_to_av() handle NULL arguments. In load_next_vo_frame(), we first try to output a frame buffered in the VO, then the filter, and then (if EOF is reached and there's still no new frame) the VO again, with draining enabled. I guess this was implemented slightly incorrectly before, because the filter chain still could have had remaining output frames.
This commit is contained in:
@@ -301,12 +301,12 @@ void mp_force_video_refresh(struct MPContext *mpctx)
|
||||
queue_seek(mpctx, MPSEEK_ABSOLUTE, mpctx->last_vo_pts, 1, true);
|
||||
}
|
||||
|
||||
static bool filter_output_queued_frame(struct MPContext *mpctx)
|
||||
static bool filter_output_queued_frame(struct MPContext *mpctx, bool eof)
|
||||
{
|
||||
struct dec_video *d_video = mpctx->d_video;
|
||||
struct vo *video_out = mpctx->video_out;
|
||||
|
||||
struct mp_image *img = vf_output_queued_frame(d_video->vfilter);
|
||||
struct mp_image *img = vf_output_queued_frame(d_video->vfilter, eof);
|
||||
if (img)
|
||||
vo_queue_image(video_out, img);
|
||||
talloc_free(img);
|
||||
@@ -316,9 +316,11 @@ static bool filter_output_queued_frame(struct MPContext *mpctx)
|
||||
|
||||
static bool load_next_vo_frame(struct MPContext *mpctx, bool eof)
|
||||
{
|
||||
if (vo_get_buffered_frame(mpctx->video_out, eof) >= 0)
|
||||
if (vo_get_buffered_frame(mpctx->video_out, false) >= 0)
|
||||
return true;
|
||||
if (filter_output_queued_frame(mpctx))
|
||||
if (filter_output_queued_frame(mpctx, eof))
|
||||
return true;
|
||||
if (eof && vo_get_buffered_frame(mpctx->video_out, true) >= 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
@@ -366,7 +368,7 @@ static void filter_video(struct MPContext *mpctx, struct mp_image *frame,
|
||||
|
||||
mp_image_set_params(frame, &d_video->vf_input); // force csp/aspect overrides
|
||||
vf_filter_frame(d_video->vfilter, frame);
|
||||
filter_output_queued_frame(mpctx);
|
||||
filter_output_queued_frame(mpctx, false);
|
||||
}
|
||||
|
||||
// Reconfigure the video chain and the VO on a format change. This is separate,
|
||||
|
||||
Reference in New Issue
Block a user