0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 12:02:23 +02:00

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.
This commit is contained in:
wm4 2015-12-20 09:46:15 +01:00
parent 127da1613f
commit 2da533bec3

View File

@ -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 *img)
{ {
struct mp_image_params *params = &img->params; struct mp_image_params *params = &img->params;
if (params->d_w > 0 && params->d_h > 0) { p->vsapi->propSetInt(map, "_SARNum", params->p_w, 0);
AVRational dar = {params->d_w, params->d_h}; p->vsapi->propSetInt(map, "_SARDen", params->p_h, 0);
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);
}
if (params->colorlevels) { if (params->colorlevels) {
p->vsapi->propSetInt(map, "_ColorRange", p->vsapi->propSetInt(map, "_ColorRange",
params->colorlevels == MP_CSP_LEVELS_TV, 0); 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)) if (p->vsapi->propSetNode(vars, "video_in", p->in_node, 0))
goto error; goto error;
p->vsapi->propSetInt(vars, "video_in_dw", p->fmt_in.d_w, 0); int d_w, d_h;
p->vsapi->propSetInt(vars, "video_in_dh", p->fmt_in.d_h, 0); 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, "container_fps", vf->chain->container_fps, 0);
p->vsapi->propSetFloat(vars, "display_fps", vf->chain->display_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; struct vf_priv_s *p = vf->priv;
*out = *in;
p->fmt_in = *in; p->fmt_in = *in;
if (reinit_vs(vf) < 0) if (reinit_vs(vf) < 0)
return -1; return -1;
const VSVideoInfo *vi = p->vsapi->getVideoInfo(p->out_node); const VSVideoInfo *vi = p->vsapi->getVideoInfo(p->out_node);
fmt = mp_from_vs(vi->format->id); out->w = vi->width;
if (!fmt) { out->h = vi->height;
out->imgfmt = mp_from_vs(vi->format->id);
if (!out->imgfmt) {
MP_FATAL(vf, "Unsupported output format.\n"); MP_FATAL(vf, "Unsupported output format.\n");
destroy_vs(vf); destroy_vs(vf);
return -1; return -1;
@ -673,9 +673,6 @@ static int reconfig(struct vf_instance *vf, struct mp_image_params *in,
return -1; return -1;
} }
*out = *in;
out->w = vi->width;
out->h = vi->height;
return 0; return 0;
} }
@ -720,8 +717,7 @@ static int vf_open(vf_instance_t *vf)
pthread_mutex_init(&p->lock, NULL); pthread_mutex_init(&p->lock, NULL);
pthread_cond_init(&p->wakeup, NULL); pthread_cond_init(&p->wakeup, NULL);
vf->reconfig = NULL; vf->reconfig = reconfig;
vf->config = config;
vf->filter_ext = filter_ext; vf->filter_ext = filter_ext;
vf->filter_out = filter_out; vf->filter_out = filter_out;
vf->needs_input = needs_input; vf->needs_input = needs_input;