From bb6165342db0ba60fefa97afe770b393fd6cb463 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 7 Dec 2013 19:32:44 +0100 Subject: video: create a separate context for video filter chain This adds vf_chain, which unlike vf_instance refers to the filter chain as a whole. This makes the filter API less awkward, and will allow handling format negotiation better. --- mpvcore/player/command.c | 12 ++++++------ mpvcore/player/playloop.c | 3 ++- mpvcore/player/screenshot.c | 6 ++---- mpvcore/player/video.c | 24 ++++++++++++------------ 4 files changed, 22 insertions(+), 23 deletions(-) (limited to 'mpvcore/player') diff --git a/mpvcore/player/command.c b/mpvcore/player/command.c index 05742e0da6..728e01c636 100644 --- a/mpvcore/player/command.c +++ b/mpvcore/player/command.c @@ -1189,13 +1189,13 @@ static int probe_deint_filters(struct MPContext *mpctx, const char *cmd) static int get_deinterlacing(struct MPContext *mpctx) { - vf_instance_t *vf = mpctx->d_video->vfilter; + struct vf_chain *c = mpctx->d_video->vfilter; int enabled = 0; - if (vf->control(vf, VFCTRL_GET_DEINTERLACE, &enabled) != CONTROL_OK) + if (vf_control_any(c, VFCTRL_GET_DEINTERLACE, &enabled) != CONTROL_OK) enabled = -1; if (enabled < 0) { // vf_lavfi doesn't support VFCTRL_GET_DEINTERLACE - if (vf_find_by_label(vf, VF_DEINTERLACE_LABEL)) + if (vf_find_by_label(c, VF_DEINTERLACE_LABEL)) enabled = 1; } return enabled; @@ -1203,14 +1203,14 @@ static int get_deinterlacing(struct MPContext *mpctx) static void set_deinterlacing(struct MPContext *mpctx, bool enable) { - vf_instance_t *vf = mpctx->d_video->vfilter; - if (vf_find_by_label(vf, VF_DEINTERLACE_LABEL)) { + struct vf_chain *c = mpctx->d_video->vfilter; + if (vf_find_by_label(c, VF_DEINTERLACE_LABEL)) { if (!enable) edit_filters(mpctx, STREAM_VIDEO, "del", "@" VF_DEINTERLACE_LABEL); } else { if ((get_deinterlacing(mpctx) > 0) != enable) { int arg = enable; - if (vf->control(vf, VFCTRL_SET_DEINTERLACE, &arg) != CONTROL_OK) + if (vf_control_any(c, VFCTRL_SET_DEINTERLACE, &arg) != CONTROL_OK) probe_deint_filters(mpctx, "pre"); } } diff --git a/mpvcore/player/playloop.c b/mpvcore/player/playloop.c index b069e5c3f7..b87231c709 100644 --- a/mpvcore/player/playloop.c +++ b/mpvcore/player/playloop.c @@ -994,7 +994,8 @@ void run_playloop(struct MPContext *mpctx) if (!vo->frame_loaded && (!mpctx->paused || mpctx->restart_playback)) { double frame_time = update_video(mpctx, endpts); mp_dbg(MSGT_AVSYNC, MSGL_DBG2, "*** ftime=%5.3f ***\n", frame_time); - if (mpctx->d_video->vf_initialized < 0) { + if (mpctx->d_video->vfilter && mpctx->d_video->vfilter->initialized < 0) + { MP_FATAL(mpctx, "\nFATAL: Could not initialize video filters " "(-vf) or video output (-vo).\n"); int uninit = INITIALIZED_VCODEC; diff --git a/mpvcore/player/screenshot.c b/mpvcore/player/screenshot.c index 6a3c258094..bf7a0ce9ee 100644 --- a/mpvcore/player/screenshot.c +++ b/mpvcore/player/screenshot.c @@ -314,10 +314,8 @@ static struct mp_image *screenshot_get(struct MPContext *mpctx, int mode) struct voctrl_screenshot_args args = { .full_window = (mode == MODE_FULL_WINDOW) }; - if (mpctx->d_video && mpctx->d_video->vfilter) { - struct vf_instance *vfilter = mpctx->d_video->vfilter; - vfilter->control(vfilter, VFCTRL_SCREENSHOT, &args); - } + if (mpctx->d_video && mpctx->d_video->vfilter) + vf_control_any(mpctx->d_video->vfilter, VFCTRL_SCREENSHOT, &args); if (!args.out_image) vo_control(mpctx->video_out, VOCTRL_SCREENSHOT, &args); diff --git a/mpvcore/player/video.c b/mpvcore/player/video.c index 6560192fb4..1b88422593 100644 --- a/mpvcore/player/video.c +++ b/mpvcore/player/video.c @@ -58,18 +58,19 @@ static void recreate_video_filters(struct MPContext *mpctx) struct dec_video *d_video = mpctx->d_video; assert(d_video); - vf_uninit_filter_chain(d_video->vfilter); + vf_destroy(d_video->vfilter); + d_video->vfilter = vf_new(opts); + d_video->vfilter->hwdec = &d_video->hwdec_info; - d_video->vfilter = vf_open_filter(opts, NULL, "vo", NULL); - if (!d_video->vfilter) - abort(); - d_video->vfilter->control(d_video->vfilter, VFCTRL_SET_VO, mpctx->video_out); + vf_append_filter(d_video->vfilter, "vo", NULL); + vf_control_any(d_video->vfilter, VFCTRL_SET_VO, mpctx->video_out); - d_video->vfilter = append_filters(d_video->vfilter, opts->vf_settings); + vf_append_filter_list(d_video->vfilter, opts->vf_settings); - struct vf_instance *vf = d_video->vfilter; + // for vf_sub + vf_control_any(d_video->vfilter, VFCTRL_SET_OSD_OBJ, mpctx->osd); mpctx->osd->render_subs_in_filter - = vf->control(vf, VFCTRL_INIT_OSD, NULL) == VO_TRUE; + = vf_control_any(d_video->vfilter, VFCTRL_INIT_OSD, NULL) == CONTROL_OK; } int reinit_video_filters(struct MPContext *mpctx) @@ -82,7 +83,7 @@ int reinit_video_filters(struct MPContext *mpctx) recreate_video_filters(mpctx); video_reinit_vo(d_video); - return d_video->vf_initialized > 0 ? 0 : -1; + return d_video->vfilter && d_video->vfilter->initialized > 0 ? 0 : -1; } int reinit_video_chain(struct MPContext *mpctx) @@ -189,7 +190,7 @@ static bool filter_output_queued_frame(struct MPContext *mpctx) struct dec_video *d_video = mpctx->d_video; struct vo *video_out = mpctx->video_out; - struct mp_image *img = vf_chain_output_queued_frame(d_video->vfilter); + struct mp_image *img = vf_output_queued_frame(d_video->vfilter); if (img) vo_queue_image(video_out, img); talloc_free(img); @@ -215,7 +216,7 @@ static void init_filter_params(struct MPContext *mpctx) // might recreate the chain a second time, which is not very elegant, but // allows us to test whether enabling deinterlacing works with the current // video format and other filters. - if (d_video->vf_initialized != 1) + if (!d_video->vfilter || d_video->vfilter->initialized != 1) return; if (d_video->vf_reconfig_count <= mpctx->last_vf_reconfig_count) { @@ -286,7 +287,6 @@ double update_video(struct MPContext *mpctx, double endpts) { struct dec_video *d_video = mpctx->d_video; struct vo *video_out = mpctx->video_out; - vf_control(d_video->vfilter, VFCTRL_SET_OSD_OBJ, mpctx->osd); // for vf_sub if (d_video->header->attached_picture) return update_video_attached_pic(mpctx); -- cgit v1.2.3