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