+/**
+ * Filter an image with a psz_module filter
+ *
+ */
+
+static picture_t *ImageFilter( image_handler_t *p_image, picture_t *p_pic,
+ video_format_t *p_fmt, const char *psz_module )
+{
+ void (*pf_release)( picture_t * );
+ picture_t *p_pif;
+
+ /* Start a filter */
+ if( !p_image->p_filter )
+ {
+ es_format_t fmt;
+ es_format_Init( &fmt, VIDEO_ES, p_fmt->i_chroma );
+ fmt.video = *p_fmt;
+
+ p_image->p_filter =
+ CreateFilter( p_image->p_parent, &fmt, &fmt.video, psz_module );
+
+ if( !p_image->p_filter )
+ {
+ return NULL;
+ }
+ }
+ else
+ {
+ /* Filters should handle on-the-fly size changes */
+ p_image->p_filter->fmt_in.video = *p_fmt;
+ p_image->p_filter->fmt_out.video = *p_fmt;
+ }
+
+ pf_release = p_pic->pf_release;
+ p_pic->pf_release = PicRelease; /* Small hack */
+ p_pif = p_image->p_filter->pf_video_filter( p_image->p_filter, p_pic );
+ p_pic->pf_release = pf_release;
+
+ return p_pif;
+}
+