From 2da533bec362ea97db12ffe43173e374c7592254 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 20 Dec 2015 09:46:15 +0100 Subject: vf_vapoursynth: fix everything Broken by commit 0a0bb905. The changes to this filter were accidentally simply not tested, and it was obviously broken in a bunch of ways. Fixes #2616. --- video/filter/vf_vapoursynth.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/video/filter/vf_vapoursynth.c b/video/filter/vf_vapoursynth.c index 57ffe4d535..5592e032e4 100644 --- a/video/filter/vf_vapoursynth.c +++ b/video/filter/vf_vapoursynth.c @@ -141,14 +141,8 @@ static void copy_mp_to_vs_frame_props_map(struct vf_priv_s *p, VSMap *map, struct mp_image *img) { struct mp_image_params *params = &img->params; - if (params->d_w > 0 && params->d_h > 0) { - AVRational dar = {params->d_w, params->d_h}; - AVRational asp = {params->w, params->h}; - AVRational par = av_div_q(dar, asp); - - p->vsapi->propSetInt(map, "_SARNum", par.num, 0); - p->vsapi->propSetInt(map, "_SARDen", par.den, 0); - } + p->vsapi->propSetInt(map, "_SARNum", params->p_w, 0); + p->vsapi->propSetInt(map, "_SARDen", params->p_h, 0); if (params->colorlevels) { p->vsapi->propSetInt(map, "_ColorRange", params->colorlevels == MP_CSP_LEVELS_TV, 0); @@ -614,8 +608,11 @@ static int reinit_vs(struct vf_instance *vf) if (p->vsapi->propSetNode(vars, "video_in", p->in_node, 0)) goto error; - p->vsapi->propSetInt(vars, "video_in_dw", p->fmt_in.d_w, 0); - p->vsapi->propSetInt(vars, "video_in_dh", p->fmt_in.d_h, 0); + int d_w, d_h; + mp_image_params_get_dsize(&p->fmt_in, &d_w, &d_h); + + p->vsapi->propSetInt(vars, "video_in_dw", d_w, 0); + p->vsapi->propSetInt(vars, "video_in_dh", d_h, 0); p->vsapi->propSetFloat(vars, "container_fps", vf->chain->container_fps, 0); p->vsapi->propSetFloat(vars, "display_fps", vf->chain->display_fps, 0); @@ -653,14 +650,17 @@ static int reconfig(struct vf_instance *vf, struct mp_image_params *in, { struct vf_priv_s *p = vf->priv; + *out = *in; p->fmt_in = *in; if (reinit_vs(vf) < 0) return -1; const VSVideoInfo *vi = p->vsapi->getVideoInfo(p->out_node); - fmt = mp_from_vs(vi->format->id); - if (!fmt) { + out->w = vi->width; + out->h = vi->height; + out->imgfmt = mp_from_vs(vi->format->id); + if (!out->imgfmt) { MP_FATAL(vf, "Unsupported output format.\n"); destroy_vs(vf); return -1; @@ -673,9 +673,6 @@ static int reconfig(struct vf_instance *vf, struct mp_image_params *in, return -1; } - *out = *in; - out->w = vi->width; - out->h = vi->height; return 0; } @@ -720,8 +717,7 @@ static int vf_open(vf_instance_t *vf) pthread_mutex_init(&p->lock, NULL); pthread_cond_init(&p->wakeup, NULL); - vf->reconfig = NULL; - vf->config = config; + vf->reconfig = reconfig; vf->filter_ext = filter_ext; vf->filter_out = filter_out; vf->needs_input = needs_input; -- cgit v1.2.3