]> git.sesse.net Git - vlc/blob - modules/video_filter/opencv_wrapper.c
Merge branch 'master' of git@git.videolan.org:vlc
[vlc] / modules / video_filter / opencv_wrapper.c
1 /*****************************************************************************
2  * opencv_wrapper.c : OpenCV wrapper video filter
3  *****************************************************************************
4  * Copyright (C) 2006 the VideoLAN team
5  *
6  * Authors: Dugal Harris <dugalh@protoclea.co.za>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21  *****************************************************************************/
22
23 /*****************************************************************************
24  * Preamble
25  *****************************************************************************/
26
27 #include <cxcore.h>
28 #include <cv.h>
29 #include <highgui.h>
30
31 #ifdef HAVE_CONFIG_H
32 # include "config.h"
33 #endif
34
35 #include <vlc/vlc.h>
36 #include <vlc_vout.h>
37
38 #include <math.h>
39 #include <time.h>
40
41 #include "vlc_filter.h"
42 #include "filter_common.h"
43 #include <vlc_charset.h>
44 #include "vlc_image.h"
45 #include "vlc_input.h"
46 #include "vlc_playlist.h"
47
48
49 /*****************************************************************************
50  * Local prototypes
51  *****************************************************************************/
52 static int  Create    ( vlc_object_t * );
53 static void Destroy   ( vlc_object_t * );
54
55 static int  Init      ( vout_thread_t * );
56 static void End       ( vout_thread_t * );
57 static void Render    ( vout_thread_t *, picture_t * );
58
59 static int  SendEvents( vlc_object_t *, char const *,
60                         vlc_value_t, vlc_value_t, void * );
61 static void ReleaseImages( vout_thread_t *p_vout );
62 static void VlcPictureToIplImage( vout_thread_t *p_vout, picture_t *p_in );
63
64 /*****************************************************************************
65  * Module descriptor
66  *****************************************************************************/
67
68 static char *chroma_list[] = { "input", "I420", "RGB32"};
69 static char *chroma_list_text[] = { N_("Use input chroma unaltered"),
70   N_("I420 - first plane is greyscale"), N_("RGB32")};
71
72 static char *output_list[] = { "none", "input", "processed"};
73 static char *output_list_text[] = { N_("Don't display any video"),
74   N_("Display the input video"), N_("Display the processed video")};
75
76 static char *verbosity_list[] = { "error", "warning", "debug"};
77 static char *verbosity_list_text[] = { N_("Show only errors"),
78   N_("Show errors and warnings"), N_("Show everything including debug messages")};
79
80 vlc_module_begin();
81     set_description( _("OpenCV video filter wrapper") );
82     set_shortname( _("OpenCV" ));
83     set_category( CAT_VIDEO );
84     set_subcategory( SUBCAT_VIDEO_VFILTER );
85     set_capability( "video filter", 0 );
86     add_shortcut( "opencv_wrapper" );
87     set_callbacks( Create, Destroy );
88     add_float_with_range( "opencv-scale", 1.0, 0.1, 2.0, NULL,
89                           N_("Scale factor (0.1-2.0)"),
90                           N_("Ammount by which to scale the picture before sending it to the internal OpenCV filter"),
91                           false );
92     add_string( "opencv-chroma", "input", NULL,
93                           N_("OpenCV filter chroma"),
94                           N_("Chroma to convert picture to before sending it to the internal OpenCV filter"), false);
95         change_string_list( chroma_list, chroma_list_text, 0);
96     add_string( "opencv-output", "input", NULL,
97                           N_("Wrapper filter output"),
98                           N_("Determines what (if any) video is displayed by the wrapper filter"), false);
99         change_string_list( output_list, output_list_text, 0);
100     add_string( "opencv-verbosity", "error", NULL,
101                           N_("Wrapper filter verbosity"),
102                           N_("Determines wrapper filter verbosity level"), false);
103         change_string_list( verbosity_list, verbosity_list_text, 0);
104     add_string( "opencv-filter-name", "none", NULL,
105                           N_("OpenCV internal filter name"),
106                           N_("Name of internal OpenCV plugin filter to use"), false);
107 vlc_module_end();
108
109
110 /*****************************************************************************
111  * wrapper_output_t: what video is output
112  *****************************************************************************/
113 enum wrapper_output_t
114 {
115    NONE,    //not working yet
116    VINPUT,
117    PROCESSED
118 };
119
120 /*****************************************************************************
121  * internal_chroma_t: what chroma is sent to the internal opencv filter
122  *****************************************************************************/
123 enum internal_chroma_t
124 {
125    CINPUT,
126    GREY,
127    RGB
128 };
129
130 /*****************************************************************************
131  * verbosity_t:
132  *****************************************************************************/
133 enum verbosity_t
134 {
135    VERB_ERROR,
136    VERB_WARN,
137    VERB_DEBUG
138 };
139
140 /*****************************************************************************
141  * vout_sys_t: opencv_wrapper video output method descriptor
142  *****************************************************************************
143  * This structure is part of the video output thread descriptor.
144  * It describes the opencv_wrapper specific properties of an output thread.
145  *****************************************************************************/
146 struct vout_sys_t
147 {
148     vout_thread_t *p_vout;
149
150     image_handler_t *p_image;
151
152     int i_cv_image_size;
153
154     picture_t *p_proc_image;
155     picture_t *p_to_be_freed;
156
157     float f_scale;
158
159     int i_wrapper_output;
160     int i_internal_chroma;
161     int i_verbosity;
162
163     IplImage *p_cv_image[VOUT_MAX_PLANES];
164
165     filter_t *p_opencv;
166     char* psz_inner_name;
167
168     picture_t hacked_pic;
169 };
170
171 /*****************************************************************************
172  * Control: control facility for the vout (forwards to child vout)
173  *****************************************************************************/
174 static int Control( vout_thread_t *p_vout, int i_query, va_list args )
175 {
176     return vout_vaControl( p_vout->p_sys->p_vout, i_query, args );
177 }
178
179 /*****************************************************************************
180  * Create: allocates opencv_wrapper video thread output method
181  *****************************************************************************
182  * This function allocates and initializes a opencv_wrapper vout method.
183  *****************************************************************************/
184 static int Create( vlc_object_t *p_this )
185 {
186     vout_thread_t *p_vout = (vout_thread_t *)p_this;
187     char *psz_chroma, *psz_output, *psz_verbosity;
188     int i = 0;
189
190     /* Allocate structure */
191     p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
192     if( p_vout->p_sys == NULL )
193     {
194         msg_Err( p_vout, "out of memory" );
195         return VLC_ENOMEM;
196     }
197
198     /* Init structure */
199     p_vout->p_sys->p_image = image_HandlerCreate( p_vout );
200     for (i = 0; i < VOUT_MAX_PLANES; i++)
201         p_vout->p_sys->p_cv_image[i] = NULL;
202     p_vout->p_sys->p_proc_image = NULL;
203     p_vout->p_sys->p_to_be_freed = NULL;
204     p_vout->p_sys->i_cv_image_size = 0;
205
206     p_vout->pf_init = Init;
207     p_vout->pf_end = End;
208     p_vout->pf_manage = NULL;
209     p_vout->pf_render = Render;
210     p_vout->pf_display = NULL;
211     p_vout->pf_control = Control;
212
213     /* Retrieve and apply config */
214     if( !(psz_chroma = config_GetPsz( p_vout, "opencv-chroma" )) )
215     {
216         msg_Err( p_vout, "configuration variable %s empty, using 'grey'",
217                          "opencv-chroma" );
218         p_vout->p_sys->i_internal_chroma = GREY;
219     }
220     else
221     {
222         if( !strcmp( psz_chroma, "input" ) )
223             p_vout->p_sys->i_internal_chroma = CINPUT;
224         else if( !strcmp( psz_chroma, "I420" ) )
225             p_vout->p_sys->i_internal_chroma = GREY;
226         else if( !strcmp( psz_chroma, "RGB32" ) )
227             p_vout->p_sys->i_internal_chroma = RGB;
228         else
229         {
230             msg_Err( p_vout, "no valid opencv-chroma provided, using 'grey'" );
231             p_vout->p_sys->i_internal_chroma = GREY;
232         }
233     }
234     free( psz_chroma);
235
236     if( !(psz_output = config_GetPsz( p_vout, "opencv-output" )) )
237     {
238         msg_Err( p_vout, "configuration variable %s empty, using 'input'",
239                          "opencv-output" );
240         p_vout->p_sys->i_wrapper_output = VINPUT;
241     }
242     else
243     {
244         if( !strcmp( psz_output, "none" ) )
245             p_vout->p_sys->i_wrapper_output = NONE;
246         else if( !strcmp( psz_output, "input" ) )
247             p_vout->p_sys->i_wrapper_output = VINPUT;
248         else if( !strcmp( psz_output, "processed" ) )
249             p_vout->p_sys->i_wrapper_output = PROCESSED;
250         else
251         {
252             msg_Err( p_vout, "no valid opencv-output provided, using 'input'" );
253             p_vout->p_sys->i_wrapper_output = VINPUT;
254         }
255     }
256     free( psz_output);
257
258     if( !(psz_verbosity = config_GetPsz( p_vout, "opencv-verbosity" )) )
259     {
260         msg_Err( p_vout, "configuration variable %s empty, using 'input'",
261                          "opencv-verbosity" );
262         p_vout->p_sys->i_verbosity = VERB_ERROR;
263     }
264     else
265     {
266         if( !strcmp( psz_verbosity, "error" ) )
267             p_vout->p_sys->i_verbosity = VERB_ERROR;
268         else if( !strcmp( psz_verbosity, "warning" ) )
269             p_vout->p_sys->i_verbosity = VERB_WARN;
270         else if( !strcmp( psz_verbosity, "debug" ) )
271             p_vout->p_sys->i_verbosity = VERB_DEBUG;
272         else
273         {
274             msg_Err( p_vout, "no valid opencv-verbosity provided, using 'error'" );
275             p_vout->p_sys->i_verbosity = VERB_ERROR;
276         }
277     }
278     free( psz_verbosity);
279
280     p_vout->p_sys->psz_inner_name = config_GetPsz( p_vout, "opencv-filter-name" );
281
282     p_vout->p_sys->f_scale =
283         config_GetFloat( p_vout, "opencv-scale" );
284
285     if (p_vout->p_sys->i_verbosity > VERB_WARN)
286         msg_Info(p_vout, "Configuration: opencv-scale: %f, opencv-chroma: %d, "
287             "opencv-output: %d, opencv-verbosity %d, opencv-filter %s",
288             p_vout->p_sys->f_scale,
289             p_vout->p_sys->i_internal_chroma,
290             p_vout->p_sys->i_wrapper_output,
291             p_vout->p_sys->i_verbosity,
292             p_vout->p_sys->psz_inner_name);
293
294     return VLC_SUCCESS;
295 }
296
297 /*****************************************************************************
298  * Init: initialize opencv_wrapper video thread output method
299  *****************************************************************************/
300 static int Init( vout_thread_t *p_vout )
301 {
302     int i_index;
303     picture_t *p_pic;
304     video_format_t fmt;
305     vout_sys_t *p_sys = p_vout->p_sys;
306     I_OUTPUTPICTURES = 0;
307
308     /* Initialize the output video format */
309     memset( &fmt, 0, sizeof(video_format_t) );
310     p_vout->output.i_chroma = p_vout->render.i_chroma;
311     p_vout->output.i_width  = p_vout->render.i_width;
312     p_vout->output.i_height = p_vout->render.i_height;
313     p_vout->output.i_aspect = p_vout->render.i_aspect;
314     p_vout->fmt_out = p_vout->fmt_in;           //set to input video format
315
316     fmt = p_vout->fmt_out;
317     if (p_sys->i_wrapper_output == PROCESSED)   //set to processed video format
318     {
319         fmt.i_width = fmt.i_width * p_sys->f_scale;
320         fmt.i_height = fmt.i_height * p_sys->f_scale;
321         fmt.i_visible_width = fmt.i_visible_width * p_sys->f_scale;
322         fmt.i_visible_height = fmt.i_visible_height * p_sys->f_scale;
323         fmt.i_x_offset = fmt.i_x_offset * p_sys->f_scale;
324         fmt.i_y_offset = fmt.i_y_offset * p_sys->f_scale;
325
326         if (p_sys->i_internal_chroma == GREY)
327             fmt.i_chroma = VLC_FOURCC('I','4','2','0');
328         else if (p_sys->i_internal_chroma == RGB)
329             fmt.i_chroma = VLC_FOURCC('R','V','3','2');
330     }
331
332     /* Load the internal opencv filter */
333     /* We don't need to set up video formats for this filter as it not actually using a picture_t */
334     p_sys->p_opencv = vlc_object_create( p_vout, sizeof(filter_t) );
335     vlc_object_attach( p_sys->p_opencv, p_vout );
336
337     if (p_vout->p_sys->psz_inner_name)
338         p_sys->p_opencv->p_module =
339             module_Need( p_sys->p_opencv, p_sys->psz_inner_name, 0, 0 );
340
341     if( !p_sys->p_opencv->p_module )
342     {
343         msg_Err( p_vout, "can't open internal opencv filter: %s", p_vout->p_sys->psz_inner_name );
344         p_vout->p_sys->psz_inner_name = NULL;
345         vlc_object_detach( p_sys->p_opencv );
346         vlc_object_release( p_sys->p_opencv );
347         p_sys->p_opencv = NULL;
348     }
349
350     /* Try to open the real video output */
351     if (p_sys->i_verbosity > VERB_WARN)
352         msg_Dbg( p_vout, "spawning the real video output" );
353
354     p_vout->p_sys->p_vout = vout_Create( p_vout, &fmt );
355
356     /* Everything failed */
357     if( p_vout->p_sys->p_vout == NULL )
358     {
359         msg_Err( p_vout, "can't open vout, aborting" );
360         return VLC_EGENERIC;
361     }
362
363     ALLOCATE_DIRECTBUFFERS( VOUT_MAX_PICTURES );
364
365     ADD_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
366
367     ADD_PARENT_CALLBACKS( SendEventsToChild );
368
369     return VLC_SUCCESS;
370 }
371
372 /*****************************************************************************
373  * End: terminate opencv_wrapper video thread output method
374  *****************************************************************************/
375 static void End( vout_thread_t *p_vout )
376 {
377     int i_index;
378
379     /* Free the fake output buffers we allocated */
380     for( i_index = I_OUTPUTPICTURES ; i_index ; )
381     {
382         i_index--;
383         free( PP_OUTPUTPICTURE[ i_index ]->p_data_orig );
384     }
385
386     if ( p_vout->p_sys->p_opencv )
387     {
388         //release the internal opencv filter
389         if( p_vout->p_sys->p_opencv->p_module )
390             module_Unneed( p_vout->p_sys->p_opencv, p_vout->p_sys->p_opencv->p_module );
391         vlc_object_detach( p_vout->p_sys->p_opencv );
392         vlc_object_release( p_vout->p_sys->p_opencv );
393         p_vout->p_sys->p_opencv = NULL;
394     }
395
396 }
397
398 /*****************************************************************************
399  * Destroy: destroy opencv_wrapper video thread output method
400  *****************************************************************************
401  * Terminate an output method created by opencv_wrapperCreateOutputMethod
402  *****************************************************************************/
403 static void Destroy( vlc_object_t *p_this )
404 {
405     vout_thread_t *p_vout = (vout_thread_t *)p_this;
406
407     if( p_vout->p_sys->p_vout )
408     {
409         DEL_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
410         vlc_object_detach( p_vout->p_sys->p_vout );
411         vout_Destroy( p_vout->p_sys->p_vout );
412     }
413
414     DEL_PARENT_CALLBACKS( SendEventsToChild );
415
416     ReleaseImages(p_vout);
417
418     if( p_vout->p_sys->p_image )
419         image_HandlerDelete( p_vout->p_sys->p_image );
420
421     free( p_vout->p_sys );
422 }
423
424 /*****************************************************************************
425  * ReleaseImages: Release OpenCV images in vout_sys_t.
426  *****************************************************************************/
427 static void ReleaseImages(vout_thread_t *p_vout)
428 {
429     int i = 0;
430     if (p_vout->p_sys->p_cv_image)
431     {
432         for (i = 0; i < VOUT_MAX_PLANES; i++)
433         {
434             if (p_vout->p_sys->p_cv_image[i])
435                 cvReleaseImageHeader(&(p_vout->p_sys->p_cv_image[i]));
436             p_vout->p_sys->p_cv_image[i] = NULL;
437         }
438     }
439     p_vout->p_sys->i_cv_image_size = 0;
440
441     /* Release temp picture_t if it exists */
442     if (p_vout->p_sys->p_to_be_freed)
443     {
444         p_vout->p_sys->p_to_be_freed->pf_release( p_vout->p_sys->p_to_be_freed );
445         p_vout->p_sys->p_to_be_freed = NULL;
446     }
447     if (p_vout->p_sys->i_verbosity > VERB_WARN)
448         msg_Dbg( p_vout, "images released" );
449 }
450
451 /*****************************************************************************
452  * VlcPictureToIplImage: Convert picture_t to IplImage
453  *****************************************************************************
454  * Converts given picture_t into IplImage(s) according to module config.
455  * IplImage(s) are stored in vout_sys_t.
456  *****************************************************************************/
457 static void VlcPictureToIplImage( vout_thread_t *p_vout, picture_t *p_in )
458 {
459     int planes = p_in->i_planes;    //num input video planes
460     // input video size
461     CvSize sz = cvSize(abs(p_in->format.i_width), abs(p_in->format.i_height));
462     video_format_t fmt_out;
463     clock_t start, finish;  //performance measures
464     double  duration;
465     int i = 0;
466     vout_sys_t* p_sys = p_vout->p_sys;
467
468     memset( &fmt_out, 0, sizeof(video_format_t) );
469
470     start = clock();
471
472     //do scale / color conversion according to p_sys config
473     if ((p_sys->f_scale != 1) || (p_sys->i_internal_chroma != CINPUT))
474     {
475         fmt_out = p_in->format;
476
477         //calc the scaled video size
478         fmt_out.i_width = p_in->format.i_width * p_sys->f_scale;
479         fmt_out.i_height = p_in->format.i_height * p_sys->f_scale;
480
481         if (p_sys->i_internal_chroma == RGB)
482         {
483             //rgb2 gives 3 separate planes, this gives 1 interleaved plane
484             //rv24 gives is about 20% faster but gives r&b the wrong way round
485             //and I cant think of an easy way to fix this
486             fmt_out.i_chroma = VLC_FOURCC('R','V','3','2');
487         }
488         else if (p_sys->i_internal_chroma == GREY)
489         {
490             //take the I (gray) plane (video seems to commonly be in this fmt so usually the
491             //conversion does nothing)
492             fmt_out.i_chroma = VLC_FOURCC('I','4','2','0');
493         }
494
495         //convert from the input image
496         p_sys->p_proc_image = image_Convert( p_sys->p_image, p_in,
497                                      &(p_in->format), &fmt_out );
498
499         if (!p_sys->p_proc_image)
500         {
501             msg_Err(p_vout, "can't convert (unsupported formats?), aborting...");
502             return;
503         }
504
505         p_sys->p_to_be_freed = p_sys->p_proc_image;    //remember this so we can free it later
506
507     }
508     else    //((p_sys->f_scale != 1) || (p_sys->i_internal_chroma != CINPUT))
509     {
510         //use the input image without conversion
511         p_sys->p_proc_image = p_in;
512     }
513
514     //Convert to the IplImage array that is to be processed.
515     //If there are multiple planes in p_sys->p_proc_image, then 1 IplImage
516     //is created for each plane.
517     planes = p_sys->p_proc_image->i_planes;
518     p_sys->i_cv_image_size = planes;
519     for ( i = 0; i < planes; i++ )
520     {
521         sz = cvSize(abs(p_sys->p_proc_image->p[i].i_visible_pitch /
522             p_sys->p_proc_image->p[i].i_pixel_pitch),
523             abs(p_sys->p_proc_image->p[i].i_visible_lines));
524
525         p_sys->p_cv_image[i] = cvCreateImageHeader(sz, IPL_DEPTH_8U,
526             p_sys->p_proc_image->p[i].i_pixel_pitch);
527
528         cvSetData( p_sys->p_cv_image[i],
529             (char*)(p_sys->p_proc_image->p[i].p_pixels), p_sys->p_proc_image->p[i].i_pitch );
530     }
531
532     //Hack the above opencv image array into a picture_t so that it can be sent to
533     //another video filter
534     p_sys->hacked_pic.p_data_orig = p_sys->p_cv_image;
535     p_sys->hacked_pic.i_planes = planes;
536     p_sys->hacked_pic.format.i_chroma = fmt_out.i_chroma;
537
538     //calculate duration of conversion
539     finish = clock();
540     duration = (double)(finish - start) / CLOCKS_PER_SEC;
541     if (p_sys->i_verbosity > VERB_WARN)
542         msg_Dbg( p_vout, "VlcPictureToIplImageRgb took %2.4f seconds\n", duration );
543 }
544
545 /*****************************************************************************
546  * Render: displays previously rendered output
547  *****************************************************************************
548  * This function send the currently rendered image to the internal opencv
549  * filter for processing.
550  *****************************************************************************/
551 static void Render( vout_thread_t *p_vout, picture_t *p_pic )
552 {
553     picture_t *p_outpic = NULL;
554     clock_t start, finish;
555     double  duration;
556
557     while( ( p_outpic = vout_CreatePicture( p_vout->p_sys->p_vout, 0, 0, 0 ) )
558               == NULL )
559     {
560         if( p_vout->b_die || p_vout->b_error )
561         {   return; }
562         msleep( VOUT_OUTMEM_SLEEP );
563     }
564
565     vout_LinkPicture( p_vout->p_sys->p_vout, p_outpic );
566
567     start = clock();
568
569     if (p_vout->p_sys->i_wrapper_output == VINPUT)  //output = input video
570     {
571         //This copy is a bit unfortunate but image_Convert can't write into an existing image so it is better to copy the
572         //(say) 16bit YUV image here than a 32bit RGB image somehwere else.
573         //It is also not that expensive in time.
574         vout_CopyPicture( p_vout, p_outpic, p_pic );
575         VlcPictureToIplImage( p_vout, p_pic);
576         //pass the image to the internal opencv filter for processing
577         if ((p_vout->p_sys->p_opencv) && (p_vout->p_sys->p_opencv->p_module))
578             p_vout->p_sys->p_opencv->pf_video_filter( p_vout->p_sys->p_opencv, &(p_vout->p_sys->hacked_pic));
579     }
580     else    //output = processed video (NONE option not working yet)
581     {
582         VlcPictureToIplImage( p_vout, p_pic);
583         //pass the image to the internal opencv filter for processing
584         if ((p_vout->p_sys->p_opencv) && (p_vout->p_sys->p_opencv->p_module))
585             p_vout->p_sys->p_opencv->pf_video_filter( p_vout->p_sys->p_opencv, &(p_vout->p_sys->hacked_pic));
586         //copy the processed image into the output image
587         if ((p_vout->p_sys->p_proc_image) && (p_vout->p_sys->p_proc_image->p_data))
588             vout_CopyPicture( p_vout, p_outpic, p_vout->p_sys->p_proc_image );
589     }
590
591     //calculate duration
592     finish = clock();
593     duration = (double)(finish - start) / CLOCKS_PER_SEC;
594     if (p_vout->p_sys->i_verbosity > VERB_WARN)
595         msg_Dbg( p_vout, "Render took %2.4f seconds\n", duration );
596
597     ReleaseImages(p_vout);
598     vout_DatePicture( p_vout->p_sys->p_vout, p_outpic, p_pic->date );
599     
600     vout_UnlinkPicture( p_vout->p_sys->p_vout, p_outpic );
601     vout_DisplayPicture( p_vout->p_sys->p_vout, p_outpic );
602 }
603
604 /*****************************************************************************
605  * SendEvents: forward mouse and keyboard events to the parent p_vout
606  *****************************************************************************/
607 static int SendEvents( vlc_object_t *p_this, char const *psz_var,
608                        vlc_value_t oldval, vlc_value_t newval, void *p_data )
609 {
610     var_Set( (vlc_object_t *)p_data, psz_var, newval );
611
612     return VLC_SUCCESS;
613 }
614
615 /*****************************************************************************
616  * SendEventsToChild: forward events to the child/children vout
617  *****************************************************************************/
618 static int SendEventsToChild( vlc_object_t *p_this, char const *psz_var,
619                        vlc_value_t oldval, vlc_value_t newval, void *p_data )
620 {
621     vout_thread_t *p_vout = (vout_thread_t *)p_this;
622     var_Set( p_vout->p_sys->p_vout, psz_var, newval );
623     return VLC_SUCCESS;
624 }