+ /* Video Filter2 stuff */
+ if( p_vout->b_vfilter_change == VLC_TRUE )
+ {
+ int i;
+ vlc_mutex_lock( &p_vout->vfilter_lock );
+ RemoveVideoFilters2( p_vout );
+ for( i = 0; i < p_vout->i_vfilters_cfg; i++ )
+ {
+ filter_t *p_vfilter =
+ p_vout->pp_vfilters[p_vout->i_vfilters] =
+ vlc_object_create( p_vout, VLC_OBJECT_FILTER );
+
+ vlc_object_attach( p_vfilter, p_vout );
+
+ p_vfilter->pf_vout_buffer_new = video_new_buffer_filter;
+ p_vfilter->pf_vout_buffer_del = video_del_buffer_filter;
+
+ if( !p_vout->i_vfilters )
+ {
+ p_vfilter->fmt_in.video = p_vout->fmt_render;
+ }
+ else
+ {
+ p_vfilter->fmt_in.video = (p_vfilter-1)->fmt_out.video;
+ }
+ /* TODO: one day filters in the middle of the chain might
+ * have a different fmt_out.video than fmt_render ... */
+ p_vfilter->fmt_out.video = p_vout->fmt_render;
+
+ p_vfilter->p_cfg = p_vout->p_vfilters_cfg[i];
+ p_vfilter->p_module = module_Need( p_vfilter, "video filter2",
+ p_vout->psz_vfilters[i],
+ VLC_TRUE );
+
+ if( p_vfilter->p_module )
+ {
+ p_vfilter->p_owner =
+ malloc( sizeof( filter_owner_sys_t ) );
+ p_vfilter->p_owner->p_vout = p_vout;
+ p_vout->i_vfilters++;
+ msg_Dbg( p_vout, "video filter found (%s)",
+ p_vout->psz_vfilters[i] );
+ }
+ else
+ {
+ msg_Err( p_vout, "no video filter found (%s)",
+ p_vout->psz_vfilters[i] );
+ vlc_object_detach( p_vfilter );
+ vlc_object_release( p_vfilter );
+ }
+ }
+ p_vout->b_vfilter_change = VLC_FALSE;
+ vlc_mutex_unlock( &p_vout->vfilter_lock );
+ }
+
+ if( p_picture )
+ {
+ int i;
+ for( i = 0; i < p_vout->i_vfilters; i++ )
+ {
+ picture_t *p_old = p_picture;
+ p_picture = p_vout->pp_vfilters[i]->pf_video_filter(
+ p_vout->pp_vfilters[i], p_picture );
+ if( !p_picture )
+ {
+ break;
+ }
+ /* FIXME: this is kind of wrong
+ * if you have 2 or more vfilters and the 2nd breaks,
+ * on the next loop the 1st one will be applied again */
+
+ /* if p_old and p_picture are the same (ie the filter
+ * worked on the old picture), then following code is
+ * still alright since i_status gets changed back to
+ * the right value */
+ if( p_old->i_refcount )
+ {
+ p_old->i_status = DISPLAYED_PICTURE;
+ }
+ else
+ {
+ p_old->i_status = DESTROYED_PICTURE;
+ }
+ p_picture->i_status = READY_PICTURE;
+ }
+ }
+
+ if( p_picture && p_vout->b_snapshot )
+ {
+ p_vout->b_snapshot = VLC_FALSE;
+ vout_Snapshot( p_vout, p_picture );
+ }
+