From d658b115a0fcb9b313b2eb77ed860649f83257b0 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 7 Dec 2013 19:35:55 +0100 Subject: 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. --- video/filter/vf_rotate.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'video/filter/vf_rotate.c') diff --git a/video/filter/vf_rotate.c b/video/filter/vf_rotate.c index 0a23071cdc..0105cb2c1d 100644 --- a/video/filter/vf_rotate.c +++ b/video/filter/vf_rotate.c @@ -66,24 +66,26 @@ static void rotate(unsigned char* dst,unsigned char* src,int dststride,int srcst } } -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) { + *out = *in; if (vf->priv->direction & 4) { - if (p->w < p->h) + if (in->w < in->h) vf->priv->direction &= 3; } if (vf->priv->direction & 4) - return vf_next_reconfig(vf, p, flags); - struct mp_imgfmt_desc desc = mp_imgfmt_get_desc(p->imgfmt); - int a_w = MP_ALIGN_DOWN(p->w, desc.align_x); - int a_h = MP_ALIGN_DOWN(p->h, desc.align_y); - vf_rescale_dsize(&p->d_w, &p->d_h, p->w, p->h, a_w, a_h); - p->w = a_h; - p->h = a_w; - int t = p->d_w; - p->d_w = p->d_h; - p->d_h = t; - return vf_next_reconfig(vf, p, flags); + return 0; + struct mp_imgfmt_desc desc = mp_imgfmt_get_desc(in->imgfmt); + int a_w = MP_ALIGN_DOWN(in->w, desc.align_x); + int a_h = MP_ALIGN_DOWN(in->h, desc.align_y); + vf_rescale_dsize(&out->d_w, &out->d_h, in->w, in->h, a_w, a_h); + out->w = a_h; + out->h = a_w; + int t = out->d_w; + out->d_w = out->d_h; + out->d_h = t; + return 0; } static struct mp_image *filter(struct vf_instance *vf, struct mp_image *mpi) -- cgit v1.2.3