diff options
Diffstat (limited to 'libmpcodecs/vf.c')
-rw-r--r-- | libmpcodecs/vf.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/libmpcodecs/vf.c b/libmpcodecs/vf.c index 0bebfcc49e..e510d99e31 100644 --- a/libmpcodecs/vf.c +++ b/libmpcodecs/vf.c @@ -541,6 +541,37 @@ void vf_clone_mpi_attributes(mp_image_t* dst, mp_image_t* src){ dst->qscale= src->qscale; } } +/** + * \brief Video config() function wrapper + * + * Blocks config() calls with different size or format for filters + * with VFCAP_CONSTANT + * + * First call is redirected to vf->config. + * + * In following calls, it verifies that the configuration parameters + * are unchanged, and returns either success or error. + * +*/ +int vf_config_wrapper(struct vf_instance_s* vf, + int width, int height, int d_width, int d_height, + unsigned int flags, unsigned int outfmt) +{ + if ((vf->default_caps&VFCAP_CONSTANT) && vf->fmt.have_configured) { + if ((vf->fmt.orig_width != width) + || (vf->fmt.orig_height != height) + || (vf->fmt.orig_fmt != outfmt)) { + mp_msg(MSGT_VFILTER,MSGL_FATAL,MSGTR_ResolutionDoesntMatch); + return 0; + } + return 1; + } + vf->fmt.have_configured = 1; + vf->fmt.orig_height = height; + vf->fmt.orig_width = width; + vf->fmt.orig_fmt = outfmt; + vf->config(vf, width, height, d_width, d_height, flags, outfmt); +} int vf_next_config(struct vf_instance_s* vf, int width, int height, int d_width, int d_height, @@ -571,7 +602,7 @@ int vf_next_config(struct vf_instance_s* vf, vf->next=vf2; } vf->next->w = width; vf->next->h = height; - return vf->next->config(vf->next,width,height,d_width,d_height,voflags,outfmt); + return vf_config_wrapper(vf->next,width,height,d_width,d_height,voflags,outfmt); } int vf_next_control(struct vf_instance_s* vf, int request, void* data){ |