diff options
author | wm4 <wm4@nowhere> | 2013-12-07 19:35:55 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-12-07 19:35:55 +0100 |
commit | d658b115a0fcb9b313b2eb77ed860649f83257b0 (patch) | |
tree | 8efd883fb2d83d8b8fc3be95067d32e336e11944 /video/filter/vf_scale.c | |
parent | 37fbef2ccb3c828dd41f6e15ccf635e697e4011f (diff) | |
download | mpv-d658b115a0fcb9b313b2eb77ed860649f83257b0.tar.bz2 mpv-d658b115a0fcb9b313b2eb77ed860649f83257b0.tar.xz |
vf: redo conversion filter insertion/format negotiation
Remove the inconsistent, duplicated, and insufficient scale filter
insertion code, and do it in one place instead. This also compensates
for the earlier removal of vf_match_csp() (which was in fact duplicated
code).
The algorithm to determine where to insert a filter etc. is probably the
same, though it also comes with some changes that should make debugging
easier when trying to figure out why a chain is failing to configure.
Add an "in" pseudo filter, which makes insertion of conversion filters
easier. Also change the vf->reconfig signature. At a later point, I'll
probably change format negotiation such that the generic filter code
will choose the output format, so having separate in and out params will
be useful.
Diffstat (limited to 'video/filter/vf_scale.c')
-rw-r--r-- | video/filter/vf_scale.c | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/video/filter/vf_scale.c b/video/filter/vf_scale.c index c466c5d39a..268e65ae59 100644 --- a/video/filter/vf_scale.c +++ b/video/filter/vf_scale.c @@ -217,13 +217,13 @@ static unsigned int find_best_out(vf_instance_t *vf, int in_format) return best; } -static int reconfig(struct vf_instance *vf, struct mp_image_params *p, int flags) +static int reconfig(struct vf_instance *vf, struct mp_image_params *in, + struct mp_image_params *out) { - int width = p->w, height = p->h, d_width = p->d_w, d_height = p->d_h; - unsigned int outfmt = p->imgfmt; + int width = in->w, height = in->h, d_width = in->d_w, d_height = in->d_h; + unsigned int outfmt = in->imgfmt; unsigned int best = find_best_out(vf, outfmt); int round_w = 0, round_h = 0; - struct mp_image_params input = *p; if (!best) { mp_msg(MSGT_VFILTER, MSGL_WARN, @@ -302,30 +302,30 @@ static int reconfig(struct vf_instance *vf, struct mp_image_params *p, int flags d_height = vf->priv->w * d_height / d_width; d_width = vf->priv->w; } - //d_width=d_width*vf->priv->w/width; - //d_height=d_height*vf->priv->h/height; - p->w = vf->priv->w; - p->h = vf->priv->h; - p->d_w = d_width; - p->d_h = d_height; - p->imgfmt = best; + + *out = *in; + out->w = vf->priv->w; + out->h = vf->priv->h; + out->d_w = d_width; + out->d_h = d_height; + out->imgfmt = best; // Second-guess what libswscale is going to output and what not. // It depends what libswscale supports for in/output, and what makes sense. - struct mp_imgfmt_desc s_fmt = mp_imgfmt_get_desc(input.imgfmt); - struct mp_imgfmt_desc d_fmt = mp_imgfmt_get_desc(p->imgfmt); + struct mp_imgfmt_desc s_fmt = mp_imgfmt_get_desc(in->imgfmt); + struct mp_imgfmt_desc d_fmt = mp_imgfmt_get_desc(out->imgfmt); // keep colorspace settings if the data stays in yuv if (!(s_fmt.flags & MP_IMGFLAG_YUV) || !(d_fmt.flags & MP_IMGFLAG_YUV)) { - p->colorspace = MP_CSP_AUTO; - p->colorlevels = MP_CSP_LEVELS_AUTO; + out->colorspace = MP_CSP_AUTO; + out->colorlevels = MP_CSP_LEVELS_AUTO; } - mp_image_params_guess_csp(p); + mp_image_params_guess_csp(out); mp_sws_set_from_cmdline(vf->priv->sws); vf->priv->sws->flags |= vf->priv->v_chr_drop << SWS_SRC_V_CHR_DROP_SHIFT; vf->priv->sws->flags |= vf->priv->accurate_rnd * SWS_ACCURATE_RND; - vf->priv->sws->src = input; - vf->priv->sws->dst = *p; + vf->priv->sws->src = *in; + vf->priv->sws->dst = *out; if (mp_sws_reinit(vf->priv->sws) < 0) { // error... @@ -333,11 +333,7 @@ static int reconfig(struct vf_instance *vf, struct mp_image_params *p, int flags "Couldn't init libswscale for this setup\n"); return -1; } - - // In particular, fix up colorspace/levels if YUV<->RGB conversion is - // performed. - - return vf_next_reconfig(vf, p, flags); + return 0; } static struct mp_image *filter(struct vf_instance *vf, struct mp_image *mpi) |