1 /*****************************************************************************
2 * vout_subpictures.c : subpicture management functions
3 *****************************************************************************
4 * Copyright (C) 2000-2007 the VideoLAN team
7 * Authors: Vincent Seguin <seguin@via.ecp.fr>
8 * Samuel Hocevar <sam@zoy.org>
9 * Gildas Bazin <gbazin@videolan.org>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24 *****************************************************************************/
26 /*****************************************************************************
28 *****************************************************************************/
33 #include <vlc_common.h>
35 #include <vlc_block.h>
36 #include <vlc_filter.h>
38 #include "../libvlc.h"
40 /*****************************************************************************
42 *****************************************************************************/
43 static void UpdateSPU ( spu_t *, vlc_object_t * );
44 static int CropCallback( vlc_object_t *, char const *,
45 vlc_value_t, vlc_value_t, void * );
47 static int spu_vaControlDefault( spu_t *, int, va_list );
49 static subpicture_t *sub_new_buffer( filter_t * );
50 static void sub_del_buffer( filter_t *, subpicture_t * );
51 static subpicture_t *spu_new_buffer( filter_t * );
52 static void spu_del_buffer( filter_t *, subpicture_t * );
53 static picture_t *spu_new_video_buffer( filter_t * );
54 static void spu_del_video_buffer( filter_t *, picture_t * );
56 static int spu_ParseChain( spu_t * );
57 static void spu_DeleteChain( spu_t * );
58 static int SubFilterCallback( vlc_object_t *, char const *,
59 vlc_value_t, vlc_value_t, void * );
61 struct filter_owner_sys_t
73 * Creates the subpicture unit
75 * \param p_this the parent object which creates the subpicture unit
77 spu_t *__spu_Create( vlc_object_t *p_this )
80 spu_t *p_spu = vlc_custom_create( p_this, sizeof( spu_t ),
81 VLC_OBJECT_GENERIC, "subpicture" );
83 for( i_index = 0; i_index < VOUT_MAX_SUBPICTURES; i_index++)
85 p_spu->p_subpicture[i_index].i_status = FREE_SUBPICTURE;
88 p_spu->p_blend = NULL;
90 p_spu->p_scale = NULL;
92 p_spu->pf_control = spu_vaControlDefault;
94 /* Register the default subpicture channel */
97 vlc_mutex_init( &p_spu->subpicture_lock );
99 vlc_object_attach( p_spu, p_this );
105 * Initialise the subpicture unit
107 * \param p_spu the subpicture unit object
109 int spu_Init( spu_t *p_spu )
113 /* If the user requested a sub margin, we force the position. */
114 var_Create( p_spu, "sub-margin", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
115 var_Get( p_spu, "sub-margin", &val );
116 p_spu->i_margin = val.i_int;
118 var_Create( p_spu, "sub-filter", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
119 var_AddCallback( p_spu, "sub-filter", SubFilterCallback, p_spu );
121 spu_ParseChain( p_spu );
126 int spu_ParseChain( spu_t *p_spu )
130 var_Get( p_spu, "sub-filter", &val );
131 psz_parser = val.psz_string;
133 while( psz_parser && *psz_parser )
135 config_chain_t *p_cfg;
138 psz_parser = config_ChainCreate( &psz_name, &p_cfg, psz_parser );
140 msg_Dbg( p_spu, "adding sub-filter: %s", psz_name );
142 p_spu->pp_filter[p_spu->i_filter] =
143 vlc_object_create( p_spu, VLC_OBJECT_FILTER );
144 vlc_object_attach( p_spu->pp_filter[p_spu->i_filter], p_spu );
145 p_spu->pp_filter[p_spu->i_filter]->pf_sub_buffer_new = sub_new_buffer;
146 p_spu->pp_filter[p_spu->i_filter]->pf_sub_buffer_del = sub_del_buffer;
147 p_spu->pp_filter[p_spu->i_filter]->p_cfg = p_cfg;
148 p_spu->pp_filter[p_spu->i_filter]->p_module =
149 module_Need( p_spu->pp_filter[p_spu->i_filter],
150 "sub filter", psz_name, true );
153 if( p_spu->pp_filter[p_spu->i_filter]->p_module )
155 filter_owner_sys_t *p_sys = malloc( sizeof(filter_owner_sys_t) );
158 p_spu->pp_filter[p_spu->i_filter]->p_owner = p_sys;
159 spu_Control( p_spu, SPU_CHANNEL_REGISTER, &p_sys->i_channel );
160 p_sys->p_spu = p_spu;
166 msg_Dbg( p_spu, "no sub filter found" );
167 config_ChainDestroy( p_spu->pp_filter[p_spu->i_filter]->p_cfg );
168 vlc_object_detach( p_spu->pp_filter[p_spu->i_filter] );
169 vlc_object_release( p_spu->pp_filter[p_spu->i_filter] );
172 if( p_spu->i_filter >= 10 )
174 msg_Dbg( p_spu, "can't add anymore filters" );
179 free( val.psz_string );
185 * Destroy the subpicture unit
187 * \param p_this the parent object which destroys the subpicture unit
189 void spu_Destroy( spu_t *p_spu )
193 vlc_object_detach( p_spu );
195 /* Destroy all remaining subpictures */
196 for( i_index = 0; i_index < VOUT_MAX_SUBPICTURES; i_index++ )
198 if( p_spu->p_subpicture[i_index].i_status != FREE_SUBPICTURE )
200 spu_DestroySubpicture( p_spu, &p_spu->p_subpicture[i_index] );
206 if( p_spu->p_blend->p_module )
207 module_Unneed( p_spu->p_blend, p_spu->p_blend->p_module );
209 vlc_object_detach( p_spu->p_blend );
210 vlc_object_release( p_spu->p_blend );
215 if( p_spu->p_text->p_module )
216 module_Unneed( p_spu->p_text, p_spu->p_text->p_module );
218 vlc_object_detach( p_spu->p_text );
219 vlc_object_release( p_spu->p_text );
224 if( p_spu->p_scale->p_module )
225 module_Unneed( p_spu->p_scale, p_spu->p_scale->p_module );
227 vlc_object_detach( p_spu->p_scale );
228 vlc_object_release( p_spu->p_scale );
231 spu_DeleteChain( p_spu );
233 vlc_mutex_destroy( &p_spu->subpicture_lock );
234 vlc_object_release( p_spu );
237 static void spu_DeleteChain( spu_t *p_spu )
239 if( p_spu->i_filter )
240 while( p_spu->i_filter )
243 module_Unneed( p_spu->pp_filter[p_spu->i_filter],
244 p_spu->pp_filter[p_spu->i_filter]->p_module );
245 free( p_spu->pp_filter[p_spu->i_filter]->p_owner );
246 config_ChainDestroy( p_spu->pp_filter[p_spu->i_filter]->p_cfg );
247 vlc_object_detach( p_spu->pp_filter[p_spu->i_filter] );
248 vlc_object_release( p_spu->pp_filter[p_spu->i_filter] );
253 * Attach/Detach the SPU from any input
255 * \param p_this the object in which to destroy the subpicture unit
256 * \param b_attach to select attach or detach
258 void spu_Attach( spu_t *p_spu, vlc_object_t *p_this, bool b_attach )
260 vlc_object_t *p_input;
262 p_input = vlc_object_find( p_this, VLC_OBJECT_INPUT, FIND_PARENT );
263 if( !p_input ) return;
267 UpdateSPU( p_spu, VLC_OBJECT(p_input) );
268 var_AddCallback( p_input, "highlight", CropCallback, p_spu );
269 vlc_object_release( p_input );
273 /* Delete callback */
274 var_DelCallback( p_input, "highlight", CropCallback, p_spu );
275 vlc_object_release( p_input );
280 * Create a subpicture region
282 * \param p_this vlc_object_t
283 * \param p_fmt the format that this subpicture region should have
285 static void RegionPictureRelease( picture_t *p_pic )
287 free( p_pic->p_data_orig );
289 subpicture_region_t *__spu_CreateRegion( vlc_object_t *p_this,
290 video_format_t *p_fmt )
292 subpicture_region_t *p_region = malloc( sizeof(subpicture_region_t) );
293 if( !p_region ) return NULL;
295 memset( p_region, 0, sizeof(subpicture_region_t) );
296 p_region->i_alpha = 0xff;
297 p_region->p_next = NULL;
298 p_region->p_cache = NULL;
299 p_region->fmt = *p_fmt;
300 p_region->psz_text = NULL;
301 p_region->p_style = NULL;
303 if( p_fmt->i_chroma == VLC_FOURCC('Y','U','V','P') )
304 p_fmt->p_palette = p_region->fmt.p_palette =
305 malloc( sizeof(video_palette_t) );
306 else p_fmt->p_palette = p_region->fmt.p_palette = NULL;
308 p_region->picture.p_data_orig = NULL;
310 if( p_fmt->i_chroma == VLC_FOURCC('T','E','X','T') ) return p_region;
312 vout_AllocatePicture( p_this, &p_region->picture, p_fmt->i_chroma,
313 p_fmt->i_width, p_fmt->i_height, p_fmt->i_aspect );
315 if( !p_region->picture.i_planes )
318 free( p_fmt->p_palette );
322 p_region->picture.pf_release = RegionPictureRelease;
328 * Make a subpicture region from an existing picture_t
330 * \param p_this vlc_object_t
331 * \param p_fmt the format that this subpicture region should have
332 * \param p_pic a pointer to the picture creating the region (not freed)
334 subpicture_region_t *__spu_MakeRegion( vlc_object_t *p_this,
335 video_format_t *p_fmt,
338 subpicture_region_t *p_region = malloc( sizeof(subpicture_region_t) );
340 if( !p_region ) return NULL;
341 memset( p_region, 0, sizeof(subpicture_region_t) );
342 p_region->i_alpha = 0xff;
343 p_region->p_next = 0;
344 p_region->p_cache = 0;
345 p_region->fmt = *p_fmt;
346 p_region->psz_text = 0;
347 p_region->p_style = NULL;
349 if( p_fmt->i_chroma == VLC_FOURCC('Y','U','V','P') )
350 p_fmt->p_palette = p_region->fmt.p_palette =
351 malloc( sizeof(video_palette_t) );
352 else p_fmt->p_palette = p_region->fmt.p_palette = NULL;
354 memcpy( &p_region->picture, p_pic, sizeof(picture_t) );
355 p_region->picture.pf_release = RegionPictureRelease;
361 * Destroy a subpicture region
363 * \param p_this vlc_object_t
364 * \param p_region the subpicture region to destroy
366 void __spu_DestroyRegion( vlc_object_t *p_this, subpicture_region_t *p_region )
368 if( !p_region ) return;
369 if( p_region->picture.pf_release )
370 p_region->picture.pf_release( &p_region->picture );
371 free( p_region->fmt.p_palette );
372 if( p_region->p_cache ) __spu_DestroyRegion( p_this, p_region->p_cache );
374 free( p_region->psz_text );
375 free( p_region->psz_html );
376 //free( p_region->p_style ); FIXME --fenrir plugin does not allocate the memory for it. I think it might lead to segfault, video renderer can live longer than the decoder
381 * Display a subpicture
383 * Remove the reservation flag of a subpicture, which will cause it to be
385 * \param p_spu the subpicture unit object
386 * \param p_subpic the subpicture to display
388 void spu_DisplaySubpicture( spu_t *p_spu, subpicture_t *p_subpic )
390 /* Check if status is valid */
391 if( p_subpic->i_status != RESERVED_SUBPICTURE )
393 msg_Err( p_spu, "subpicture %p has invalid status #%d",
394 p_subpic, p_subpic->i_status );
397 /* Remove reservation flag */
398 p_subpic->i_status = READY_SUBPICTURE;
400 if( p_subpic->i_channel == DEFAULT_CHAN )
402 p_subpic->i_channel = 0xFFFF;
403 spu_Control( p_spu, SPU_CHANNEL_CLEAR, DEFAULT_CHAN );
404 p_subpic->i_channel = DEFAULT_CHAN;
409 * Allocate a subpicture in the spu heap.
411 * This function create a reserved subpicture in the spu heap.
412 * A null pointer is returned if the function fails. This method provides an
413 * already allocated zone of memory in the spu data fields. It needs locking
414 * since several pictures can be created by several producers threads.
415 * \param p_spu the subpicture unit in which to create the subpicture
416 * \return NULL on error, a reserved subpicture otherwise
418 subpicture_t *spu_CreateSubpicture( spu_t *p_spu )
420 int i_subpic; /* subpicture index */
421 subpicture_t * p_subpic = NULL; /* first free subpicture */
424 vlc_mutex_lock( &p_spu->subpicture_lock );
427 * Look for an empty place
430 for( i_subpic = 0; i_subpic < VOUT_MAX_SUBPICTURES; i_subpic++ )
432 if( p_spu->p_subpicture[i_subpic].i_status == FREE_SUBPICTURE )
434 /* Subpicture is empty and ready for allocation */
435 p_subpic = &p_spu->p_subpicture[i_subpic];
436 p_spu->p_subpicture[i_subpic].i_status = RESERVED_SUBPICTURE;
441 /* If no free subpicture could be found */
442 if( p_subpic == NULL )
444 msg_Err( p_spu, "subpicture heap is full" );
445 vlc_mutex_unlock( &p_spu->subpicture_lock );
449 /* Copy subpicture information, set some default values */
450 memset( p_subpic, 0, sizeof(subpicture_t) );
451 p_subpic->i_status = RESERVED_SUBPICTURE;
452 p_subpic->b_absolute = true;
453 p_subpic->b_pausable = false;
454 p_subpic->b_fade = false;
455 p_subpic->i_alpha = 0xFF;
456 p_subpic->p_region = NULL;
457 p_subpic->pf_render = NULL;
458 p_subpic->pf_destroy = NULL;
459 p_subpic->p_sys = NULL;
460 vlc_mutex_unlock( &p_spu->subpicture_lock );
462 p_subpic->pf_create_region = __spu_CreateRegion;
463 p_subpic->pf_make_region = __spu_MakeRegion;
464 p_subpic->pf_destroy_region = __spu_DestroyRegion;
470 * Remove a subpicture from the heap
472 * This function frees a previously reserved subpicture.
473 * It is meant to be used when the construction of a picture aborted.
474 * This function does not need locking since reserved subpictures are ignored
477 void spu_DestroySubpicture( spu_t *p_spu, subpicture_t *p_subpic )
480 vlc_mutex_lock( &p_spu->subpicture_lock );
482 /* There can be race conditions so we need to check the status */
483 if( p_subpic->i_status == FREE_SUBPICTURE )
485 vlc_mutex_unlock( &p_spu->subpicture_lock );
489 /* Check if status is valid */
490 if( ( p_subpic->i_status != RESERVED_SUBPICTURE )
491 && ( p_subpic->i_status != READY_SUBPICTURE ) )
493 msg_Err( p_spu, "subpicture %p has invalid status %d",
494 p_subpic, p_subpic->i_status );
497 while( p_subpic->p_region )
499 subpicture_region_t *p_region = p_subpic->p_region;
500 p_subpic->p_region = p_region->p_next;
501 spu_DestroyRegion( p_spu, p_region );
504 if( p_subpic->pf_destroy )
506 p_subpic->pf_destroy( p_subpic );
509 p_subpic->i_status = FREE_SUBPICTURE;
511 vlc_mutex_unlock( &p_spu->subpicture_lock );
514 /*****************************************************************************
515 * spu_RenderSubpictures: render a subpicture list
516 *****************************************************************************
517 * This function renders all sub picture units in the list.
518 *****************************************************************************/
519 void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt,
520 picture_t *p_pic_dst, picture_t *p_pic_src,
521 subpicture_t *p_subpic,
522 int i_scale_width_orig, int i_scale_height_orig )
524 int i_source_video_width;
525 int i_source_video_height;
526 subpicture_t *p_subpic_v = p_subpic;
529 vlc_mutex_lock( &p_spu->subpicture_lock );
531 for( p_subpic_v = p_subpic;
532 p_subpic_v != NULL && p_subpic_v->i_status != FREE_SUBPICTURE;
533 p_subpic_v = p_subpic_v->p_next )
535 if( p_subpic_v->pf_pre_render )
537 p_subpic_v->pf_pre_render( p_fmt, p_spu, p_subpic_v, mdate() );
541 if( i_scale_width_orig <= 0 )
542 i_scale_width_orig = 1;
543 if( i_scale_height_orig <= 0 )
544 i_scale_height_orig = 1;
546 i_source_video_width = p_fmt->i_width * 1000 / i_scale_width_orig;
547 i_source_video_height = p_fmt->i_height * 1000 / i_scale_height_orig;
549 /* Check i_status again to make sure spudec hasn't destroyed the subpic */
550 while( ( p_subpic != NULL ) && ( p_subpic->i_status != FREE_SUBPICTURE ) )
552 subpicture_region_t *p_region;
553 int pi_scale_width[ SCALE_SIZE ];
554 int pi_scale_height[ SCALE_SIZE ];
555 int pi_subpic_x[ SCALE_SIZE ];
558 /* If the source video and subtitles stream agree on the size of
559 * the video then disregard all further references to the subtitle
562 if( ( i_source_video_height == p_subpic->i_original_picture_height ) &&
563 ( i_source_video_width == p_subpic->i_original_picture_width ) )
565 p_subpic->i_original_picture_height = 0;
566 p_subpic->i_original_picture_width = 0;
569 for( k = 0; k < SCALE_SIZE ; k++ )
570 pi_subpic_x[ k ] = p_subpic->i_x;
572 if( p_subpic->pf_update_regions )
574 if ( p_subpic->p_region ) {
575 spu_DestroyRegion( p_spu, p_subpic->p_region );
577 p_subpic->p_region = p_region = p_subpic->pf_update_regions( p_fmt, p_spu, p_subpic, mdate() );
581 p_region = p_subpic->p_region;
584 /* Load the blending module */
585 if( !p_spu->p_blend && p_region )
587 p_spu->p_blend = vlc_object_create( p_spu, VLC_OBJECT_FILTER );
588 vlc_object_attach( p_spu->p_blend, p_spu );
589 p_spu->p_blend->fmt_out.video.i_x_offset =
590 p_spu->p_blend->fmt_out.video.i_y_offset = 0;
591 p_spu->p_blend->fmt_out.video.i_aspect = p_fmt->i_aspect;
592 p_spu->p_blend->fmt_out.video.i_chroma = p_fmt->i_chroma;
594 /* The blend module will be loaded when needed with the real
596 memset( &p_spu->p_blend->fmt_in, 0, sizeof(p_spu->p_blend->fmt_in) );
597 p_spu->p_blend->p_module = NULL;
600 /* Load the text rendering module; it is possible there is a
601 * text region somewhere in the subpicture other than the first
602 * element in the region list, so just load it anyway as we'll
603 * probably want it sooner or later. */
604 if( !p_spu->p_text && p_region )
606 char *psz_modulename = NULL;
608 p_spu->p_text = vlc_object_create( p_spu, VLC_OBJECT_FILTER );
609 vlc_object_attach( p_spu->p_text, p_spu );
611 p_spu->p_text->fmt_out.video.i_width =
612 p_spu->p_text->fmt_out.video.i_visible_width =
614 p_spu->p_text->fmt_out.video.i_height =
615 p_spu->p_text->fmt_out.video.i_visible_height =
618 p_spu->p_text->pf_sub_buffer_new = spu_new_buffer;
619 p_spu->p_text->pf_sub_buffer_del = spu_del_buffer;
621 psz_modulename = var_CreateGetString( p_spu, "text-renderer" );
622 if( psz_modulename && *psz_modulename )
624 p_spu->p_text->p_module =
625 module_Need( p_spu->p_text, "text renderer",
626 psz_modulename, true );
628 if( !p_spu->p_text->p_module )
630 p_spu->p_text->p_module =
631 module_Need( p_spu->p_text, "text renderer", 0, 0 );
633 free( psz_modulename );
638 subpicture_region_t *p_text_region = p_subpic->p_region;
640 /* Only overwrite the size fields if the region is still in
641 * pre-rendered TEXT format. We have to traverse the subregion
642 * list because if more than one subregion is present, the text
643 * region isn't guarentteed to be the first in the list, and
644 * only text regions use this flag. All of this effort assists
645 * with the rescaling of text that has been rendered at native
646 * resolution, rather than video resolution.
648 while( p_text_region &&
649 ( p_text_region->fmt.i_chroma != VLC_FOURCC('T','E','X','T') ) )
651 p_text_region = p_text_region->p_next;
655 ( ( p_text_region->i_align & SUBPICTURE_RENDERED ) == 0 ) )
657 if( (p_subpic->i_original_picture_height > 0) &&
658 (p_subpic->i_original_picture_width > 0) )
660 p_spu->p_text->fmt_out.video.i_width =
661 p_spu->p_text->fmt_out.video.i_visible_width =
662 p_subpic->i_original_picture_width;
663 p_spu->p_text->fmt_out.video.i_height =
664 p_spu->p_text->fmt_out.video.i_visible_height =
665 p_subpic->i_original_picture_height;
669 p_spu->p_text->fmt_out.video.i_width =
670 p_spu->p_text->fmt_out.video.i_visible_width =
672 p_spu->p_text->fmt_out.video.i_height =
673 p_spu->p_text->fmt_out.video.i_visible_height =
679 pi_scale_width[ SCALE_DEFAULT ] = i_scale_width_orig;
680 pi_scale_height[ SCALE_DEFAULT ] = i_scale_height_orig;
684 pi_scale_width[ SCALE_TEXT ] = ( p_fmt->i_width * 1000 ) /
685 p_spu->p_text->fmt_out.video.i_width;
686 pi_scale_height[ SCALE_TEXT ] = ( p_fmt->i_height * 1000 ) /
687 p_spu->p_text->fmt_out.video.i_height;
689 /* If we have an explicit size plane to render to, then turn off
690 * the fontsize rescaling.
692 if( (p_subpic->i_original_picture_height > 0) &&
693 (p_subpic->i_original_picture_width > 0) )
695 i_scale_width_orig = 1000;
696 i_scale_height_orig = 1000;
699 for( k = 0; k < SCALE_SIZE ; k++ )
701 /* Case of both width and height being specified has been dealt
702 * with above by instead rendering to an output pane of the
703 * explicit dimensions specified - we don't need to scale it.
705 if( (p_subpic->i_original_picture_height > 0) &&
706 (p_subpic->i_original_picture_width <= 0) )
708 pi_scale_height[ k ] = pi_scale_height[ k ] * i_source_video_height /
709 p_subpic->i_original_picture_height;
710 pi_scale_width[ k ] = pi_scale_width[ k ] * i_source_video_height /
711 p_subpic->i_original_picture_height;
715 /* Set default subpicture aspect ratio */
716 if( p_region && p_region->fmt.i_aspect &&
717 ( !p_region->fmt.i_sar_num || !p_region->fmt.i_sar_den ) )
719 p_region->fmt.i_sar_den = p_region->fmt.i_aspect;
720 p_region->fmt.i_sar_num = VOUT_ASPECT_FACTOR;
723 ( !p_region->fmt.i_sar_num || !p_region->fmt.i_sar_den ) )
725 p_region->fmt.i_sar_den = p_fmt->i_sar_den;
726 p_region->fmt.i_sar_num = p_fmt->i_sar_num;
729 /* Take care of the aspect ratio */
731 ( ( p_region->fmt.i_sar_num * p_fmt->i_sar_den ) !=
732 ( p_region->fmt.i_sar_den * p_fmt->i_sar_num ) ) )
734 for( k = 0; k < SCALE_SIZE ; k++ )
736 pi_scale_width[ k ] = pi_scale_width[ k ] *
737 (int64_t)p_region->fmt.i_sar_num * p_fmt->i_sar_den /
738 p_region->fmt.i_sar_den / p_fmt->i_sar_num;
739 pi_subpic_x[ k ] = p_subpic->i_x * pi_scale_width[ k ] / 1000;
743 /* Load the scaling module */
744 if( !p_spu->p_scale &&
745 ((((pi_scale_width[ SCALE_TEXT ] > 0) || (pi_scale_height[ SCALE_TEXT ] > 0)) &&
746 ((pi_scale_width[ SCALE_TEXT ] != 1000) || (pi_scale_height[ SCALE_TEXT ] != 1000))) ||
747 (((pi_scale_width[ SCALE_DEFAULT ] > 0) || (pi_scale_height[ SCALE_DEFAULT ] > 0)) &&
748 ((pi_scale_width[ SCALE_DEFAULT ] != 1000) || (pi_scale_height[ SCALE_DEFAULT ] != 1000)))) )
750 p_spu->p_scale = vlc_object_create( p_spu, VLC_OBJECT_FILTER );
751 vlc_object_attach( p_spu->p_scale, p_spu );
752 p_spu->p_scale->fmt_out.video.i_chroma =
753 p_spu->p_scale->fmt_in.video.i_chroma =
754 VLC_FOURCC('Y','U','V','P');
755 /* FIXME: We'll also be using it for YUVA and RGBA blending ... */
757 p_spu->p_scale->fmt_in.video.i_width =
758 p_spu->p_scale->fmt_in.video.i_height = 32;
759 p_spu->p_scale->fmt_out.video.i_width =
760 p_spu->p_scale->fmt_out.video.i_height = 16;
762 p_spu->p_scale->pf_vout_buffer_new = spu_new_video_buffer;
763 p_spu->p_scale->pf_vout_buffer_del = spu_del_video_buffer;
764 p_spu->p_scale->p_module =
765 module_Need( p_spu->p_scale, "video filter2", 0, 0 );
770 video_format_t orig_fmt = p_region->fmt;
771 bool b_rerender_text = false;
772 int i_fade_alpha = 255;
775 int i_scale_idx = SCALE_DEFAULT;
776 int i_inv_scale_x = 1000;
777 int i_inv_scale_y = 1000;
779 if( p_region->fmt.i_chroma == VLC_FOURCC('T','E','X','T') )
781 if( p_spu->p_text && p_spu->p_text->p_module )
785 /* Setup 3 variables which can be used to render
786 * time-dependent text (and effects). The first indicates
787 * the total amount of time the text will be on screen,
788 * the second the amount of time it has already been on
789 * screen (can be a negative value as text is layed out
790 * before it is rendered) and the third is a feedback
791 * variable from the renderer - if the renderer sets it
792 * then this particular text is time-dependent, eg. the
793 * visual progress bar inside the text in karaoke and the
794 * text needs to be rendered multiple times in order for
795 * the effect to work - we therefore need to return the
796 * region to its original state at the end of the loop,
797 * instead of leaving it in YUVA or YUVP.
798 * Any renderer which is unaware of how to render
799 * time-dependent text can happily ignore the variables
800 * and render the text the same as usual - it should at
801 * least show up on screen, but the effect won't change
802 * the text over time.
805 var_Create( p_spu->p_text, "spu-duration", VLC_VAR_TIME );
806 val.i_time = p_subpic->i_stop - p_subpic->i_start;
807 var_Set( p_spu->p_text, "spu-duration", val );
809 var_Create( p_spu->p_text, "spu-elapsed", VLC_VAR_TIME );
810 val.i_time = mdate() - p_subpic->i_start;
811 var_Set( p_spu->p_text, "spu-elapsed", val );
813 var_Create( p_spu->p_text, "text-rerender", VLC_VAR_BOOL );
814 var_SetBool( p_spu->p_text, "text-rerender", false );
816 var_Create( p_spu->p_text, "scale", VLC_VAR_INTEGER );
817 var_SetInteger( p_spu->p_text, "scale",
818 __MIN(i_scale_width_orig, i_scale_height_orig) );
820 if( p_spu->p_text->pf_render_html && p_region->psz_html )
822 p_spu->p_text->pf_render_html( p_spu->p_text,
823 p_region, p_region );
825 else if( p_spu->p_text->pf_render_text )
827 p_spu->p_text->pf_render_text( p_spu->p_text,
828 p_region, p_region );
830 b_rerender_text = var_GetBool( p_spu->p_text, "text-rerender" );
832 var_Destroy( p_spu->p_text, "spu-duration" );
833 var_Destroy( p_spu->p_text, "spu-elapsed" );
834 var_Destroy( p_spu->p_text, "text-rerender" );
835 var_Destroy( p_spu->p_text, "scale" );
837 p_region->i_align |= SUBPICTURE_RENDERED;
840 if( p_region->i_align & SUBPICTURE_RENDERED )
842 i_scale_idx = SCALE_TEXT;
843 i_inv_scale_x = i_scale_width_orig;
844 i_inv_scale_y = i_scale_height_orig;
847 i_x_offset = (p_region->i_x + pi_subpic_x[ i_scale_idx ]) * i_inv_scale_x / 1000;
848 i_y_offset = (p_region->i_y + p_subpic->i_y) * i_inv_scale_y / 1000;
850 /* Force palette if requested */
851 if( p_spu->b_force_palette &&
852 ( VLC_FOURCC('Y','U','V','P') == p_region->fmt.i_chroma ) )
854 memcpy( p_region->fmt.p_palette->palette,
855 p_spu->palette, 16 );
858 /* Scale SPU if necessary */
859 if( p_region->p_cache &&
860 ( p_region->fmt.i_chroma != VLC_FOURCC('T','E','X','T') ) )
862 if( pi_scale_width[ i_scale_idx ] * p_region->fmt.i_width / 1000 !=
863 p_region->p_cache->fmt.i_width ||
864 pi_scale_height[ i_scale_idx ] * p_region->fmt.i_height / 1000 !=
865 p_region->p_cache->fmt.i_height )
867 p_subpic->pf_destroy_region( VLC_OBJECT(p_spu),
869 p_region->p_cache = 0;
873 if( ( ( pi_scale_width[ i_scale_idx ] != 1000 ) ||
874 ( pi_scale_height[ i_scale_idx ] != 1000 ) ) &&
875 ( ( pi_scale_width[ i_scale_idx ] > 0 ) ||
876 ( pi_scale_height[ i_scale_idx ] > 0 ) ) &&
877 p_spu->p_scale && !p_region->p_cache &&
878 ( p_region->fmt.i_chroma != VLC_FOURCC('T','E','X','T') ) )
882 p_spu->p_scale->fmt_in.video = p_region->fmt;
883 p_spu->p_scale->fmt_out.video = p_region->fmt;
886 p_subpic->pf_create_region( VLC_OBJECT(p_spu),
887 &p_spu->p_scale->fmt_out.video );
888 if( p_spu->p_scale->fmt_out.video.p_palette )
889 *p_spu->p_scale->fmt_out.video.p_palette =
890 *p_region->fmt.p_palette;
891 p_region->p_cache->p_next = p_region->p_next;
893 vout_CopyPicture( p_spu, &p_region->p_cache->picture,
894 &p_region->picture );
896 p_spu->p_scale->fmt_out.video.i_width =
897 p_region->fmt.i_width * pi_scale_width[ i_scale_idx ] / 1000;
898 p_spu->p_scale->fmt_out.video.i_visible_width =
899 p_region->fmt.i_visible_width * pi_scale_width[ i_scale_idx ] / 1000;
900 p_spu->p_scale->fmt_out.video.i_height =
901 p_region->fmt.i_height * pi_scale_height[ i_scale_idx ] / 1000;
902 p_spu->p_scale->fmt_out.video.i_visible_height =
903 p_region->fmt.i_visible_height * pi_scale_height[ i_scale_idx ] / 1000;
904 p_region->p_cache->fmt = p_spu->p_scale->fmt_out.video;
905 p_region->p_cache->i_x = p_region->i_x * pi_scale_width[ i_scale_idx ] / 1000;
906 p_region->p_cache->i_y = p_region->i_y * pi_scale_height[ i_scale_idx ] / 1000;
907 p_region->p_cache->i_align = p_region->i_align;
908 p_region->p_cache->i_alpha = p_region->i_alpha;
910 p_pic = p_spu->p_scale->pf_video_filter(
911 p_spu->p_scale, &p_region->p_cache->picture );
914 picture_t p_pic_tmp = p_region->p_cache->picture;
915 p_region->p_cache->picture = *p_pic;
921 if( ( ( pi_scale_width[ i_scale_idx ] != 1000 ) ||
922 ( pi_scale_height[ i_scale_idx ] != 1000 ) ) &&
923 ( ( pi_scale_width[ i_scale_idx ] > 0 ) ||
924 ( pi_scale_height[ i_scale_idx ] > 0 ) ) &&
925 p_spu->p_scale && p_region->p_cache &&
926 ( p_region->fmt.i_chroma != VLC_FOURCC('T','E','X','T') ) )
928 p_region = p_region->p_cache;
931 if( p_region->i_align & SUBPICTURE_ALIGN_BOTTOM )
933 i_y_offset = p_fmt->i_height - p_region->fmt.i_height -
934 (p_subpic->i_y + p_region->i_y) * i_inv_scale_y / 1000;
936 else if ( !(p_region->i_align & SUBPICTURE_ALIGN_TOP) )
938 i_y_offset = p_fmt->i_height / 2 - p_region->fmt.i_height / 2;
941 if( p_region->i_align & SUBPICTURE_ALIGN_RIGHT )
943 i_x_offset = p_fmt->i_width - p_region->fmt.i_width -
944 (pi_subpic_x[ i_scale_idx ] + p_region->i_x)
945 * i_inv_scale_x / 1000;
947 else if ( !(p_region->i_align & SUBPICTURE_ALIGN_LEFT) )
949 i_x_offset = p_fmt->i_width / 2 - p_region->fmt.i_width / 2;
952 if( p_subpic->b_absolute )
954 i_x_offset = (p_region->i_x +
955 pi_subpic_x[ i_scale_idx ] *
956 pi_scale_width[ i_scale_idx ] / 1000)
957 * i_inv_scale_x / 1000;
958 i_y_offset = (p_region->i_y +
959 p_subpic->i_y * pi_scale_height[ i_scale_idx ] / 1000)
960 * i_inv_scale_y / 1000;
964 i_x_offset = __MAX( i_x_offset, 0 );
965 i_y_offset = __MAX( i_y_offset, 0 );
967 if( ( p_spu->i_margin != 0 ) &&
968 ( p_spu->b_force_crop == false ) )
971 int i_low = (i_y_offset - p_spu->i_margin) * i_inv_scale_y / 1000;
972 int i_high = i_low + p_region->fmt.i_height;
974 /* crop extra margin to keep within bounds */
977 if( i_high > (int)p_fmt->i_height )
978 i_diff = i_high - p_fmt->i_height;
979 i_y_offset -= ( p_spu->i_margin * i_inv_scale_y / 1000 + i_diff );
982 if( p_subpic->b_fade )
984 mtime_t i_fade_start = ( p_subpic->i_stop +
985 p_subpic->i_start ) / 2;
986 mtime_t i_now = mdate();
987 if( i_now >= i_fade_start && p_subpic->i_stop > i_fade_start )
989 i_fade_alpha = 255 * ( p_subpic->i_stop - i_now ) /
990 ( p_subpic->i_stop - i_fade_start );
994 if( p_region->fmt.i_chroma != VLC_FOURCC('T','E','X','T') )
996 if( p_spu->p_blend->fmt_in.video.i_chroma != p_region->fmt.i_chroma )
998 /* The chroma is not the same, we need to reload the blend module
999 * XXX to match the old behaviour just test !p_spu->p_blend->fmt_in.video.i_chroma */
1000 if( p_spu->p_blend->p_module )
1001 module_Unneed( p_spu->p_blend, p_spu->p_blend->p_module );
1003 p_spu->p_blend->fmt_in.video = p_region->fmt;
1004 p_spu->p_blend->p_module = module_Need( p_spu->p_blend, "video blending", 0, 0 );
1008 p_spu->p_blend->fmt_in.video = p_region->fmt;
1011 /* Force cropping if requested */
1012 if( p_spu->b_force_crop )
1014 video_format_t *p_fmt = &p_spu->p_blend->fmt_in.video;
1015 int i_crop_x = p_spu->i_crop_x * pi_scale_width[ i_scale_idx ] / 1000
1016 * i_inv_scale_x / 1000;
1017 int i_crop_y = p_spu->i_crop_y * pi_scale_height[ i_scale_idx ] / 1000
1018 * i_inv_scale_y / 1000;
1019 int i_crop_width = p_spu->i_crop_width * pi_scale_width[ i_scale_idx ] / 1000
1020 * i_inv_scale_x / 1000;
1021 int i_crop_height = p_spu->i_crop_height * pi_scale_height[ i_scale_idx ] / 1000
1022 * i_inv_scale_y / 1000;
1024 /* Find the intersection */
1025 if( i_crop_x + i_crop_width <= i_x_offset ||
1026 i_x_offset + (int)p_fmt->i_visible_width < i_crop_x ||
1027 i_crop_y + i_crop_height <= i_y_offset ||
1028 i_y_offset + (int)p_fmt->i_visible_height < i_crop_y )
1030 /* No intersection */
1031 p_fmt->i_visible_width = p_fmt->i_visible_height = 0;
1035 int i_x, i_y, i_x_end, i_y_end;
1036 i_x = __MAX( i_crop_x, i_x_offset );
1037 i_y = __MAX( i_crop_y, i_y_offset );
1038 i_x_end = __MIN( i_crop_x + i_crop_width,
1039 i_x_offset + (int)p_fmt->i_visible_width );
1040 i_y_end = __MIN( i_crop_y + i_crop_height,
1041 i_y_offset + (int)p_fmt->i_visible_height );
1043 p_fmt->i_x_offset = i_x - i_x_offset;
1044 p_fmt->i_y_offset = i_y - i_y_offset;
1045 p_fmt->i_visible_width = i_x_end - i_x;
1046 p_fmt->i_visible_height = i_y_end - i_y;
1053 i_x_offset = __MAX( i_x_offset, 0 );
1054 i_y_offset = __MAX( i_y_offset, 0 );
1056 /* Update the output picture size */
1057 p_spu->p_blend->fmt_out.video.i_width =
1058 p_spu->p_blend->fmt_out.video.i_visible_width =
1060 p_spu->p_blend->fmt_out.video.i_height =
1061 p_spu->p_blend->fmt_out.video.i_visible_height =
1064 if( p_spu->p_blend->p_module )
1066 p_spu->p_blend->pf_video_blend( p_spu->p_blend, p_pic_dst,
1067 p_pic_src, &p_region->picture, i_x_offset, i_y_offset,
1068 i_fade_alpha * p_subpic->i_alpha * p_region->i_alpha / 65025 );
1072 msg_Err( p_spu, "blending %4.4s to %4.4s failed",
1073 (char *)&p_spu->p_blend->fmt_out.video.i_chroma,
1074 (char *)&p_spu->p_blend->fmt_out.video.i_chroma );
1078 if( b_rerender_text )
1080 /* Some forms of subtitles need to be re-rendered more than
1081 * once, eg. karaoke. We therefore restore the region to its
1082 * pre-rendered state, so the next time through everything is
1085 p_region->picture.pf_release( &p_region->picture );
1086 memset( &p_region->picture, 0, sizeof( picture_t ) );
1087 p_region->fmt = orig_fmt;
1088 p_region->i_align &= ~SUBPICTURE_RENDERED;
1090 p_region = p_region->p_next;
1093 p_subpic = p_subpic->p_next;
1096 vlc_mutex_unlock( &p_spu->subpicture_lock );
1099 /*****************************************************************************
1100 * spu_SortSubpictures: find the subpictures to display
1101 *****************************************************************************
1102 * This function parses all subpictures and decides which ones need to be
1103 * displayed. This operation does not need lock, since only READY_SUBPICTURE
1104 * are handled. If no picture has been selected, display_date will depend on
1106 * We also check for ephemer DVD subpictures (subpictures that have
1107 * to be removed if a newer one is available), which makes it a lot
1108 * more difficult to guess if a subpicture has to be rendered or not.
1109 *****************************************************************************/
1110 subpicture_t *spu_SortSubpictures( spu_t *p_spu, mtime_t display_date,
1113 int i_index, i_channel;
1114 subpicture_t *p_subpic = NULL;
1115 subpicture_t *p_ephemer;
1116 mtime_t ephemer_date;
1118 /* Run subpicture filters */
1119 for( i_index = 0; i_index < p_spu->i_filter; i_index++ )
1121 subpicture_t *p_subpic_filter;
1122 p_subpic_filter = p_spu->pp_filter[i_index]->
1123 pf_sub_filter( p_spu->pp_filter[i_index], display_date );
1124 if( p_subpic_filter )
1126 spu_DisplaySubpicture( p_spu, p_subpic_filter );
1130 /* We get an easily parsable chained list of subpictures which
1131 * ends with NULL since p_subpic was initialized to NULL. */
1132 for( i_channel = 0; i_channel < p_spu->i_channel; i_channel++ )
1137 for( i_index = 0; i_index < VOUT_MAX_SUBPICTURES; i_index++ )
1139 if( p_spu->p_subpicture[i_index].i_channel != i_channel ||
1140 p_spu->p_subpicture[i_index].i_status != READY_SUBPICTURE )
1145 display_date < p_spu->p_subpicture[i_index].i_start )
1147 /* Too early, come back next monday */
1151 if( p_spu->p_subpicture[i_index].i_start > ephemer_date )
1152 ephemer_date = p_spu->p_subpicture[i_index].i_start;
1154 if( display_date > p_spu->p_subpicture[i_index].i_stop &&
1155 ( !p_spu->p_subpicture[i_index].b_ephemer ||
1156 p_spu->p_subpicture[i_index].i_stop >
1157 p_spu->p_subpicture[i_index].i_start ) &&
1158 !( p_spu->p_subpicture[i_index].b_pausable &&
1161 /* Too late, destroy the subpic */
1162 spu_DestroySubpicture( p_spu, &p_spu->p_subpicture[i_index] );
1166 /* If this is an ephemer subpic, add it to our list */
1167 if( p_spu->p_subpicture[i_index].b_ephemer )
1169 p_spu->p_subpicture[i_index].p_next = p_ephemer;
1170 p_ephemer = &p_spu->p_subpicture[i_index];
1175 p_spu->p_subpicture[i_index].p_next = p_subpic;
1176 p_subpic = &p_spu->p_subpicture[i_index];
1179 /* If we found ephemer subpictures, check if they have to be
1180 * displayed or destroyed */
1181 while( p_ephemer != NULL )
1183 subpicture_t *p_tmp = p_ephemer;
1184 p_ephemer = p_ephemer->p_next;
1186 if( p_tmp->i_start < ephemer_date )
1188 /* Ephemer subpicture has lived too long */
1189 spu_DestroySubpicture( p_spu, p_tmp );
1193 /* Ephemer subpicture can still live a bit */
1194 p_tmp->p_next = p_subpic;
1203 /*****************************************************************************
1204 * SpuClearChannel: clear an spu channel
1205 *****************************************************************************
1206 * This function destroys the subpictures which belong to the spu channel
1207 * corresponding to i_channel_id.
1208 *****************************************************************************/
1209 static void SpuClearChannel( spu_t *p_spu, int i_channel )
1211 int i_subpic; /* subpicture index */
1212 subpicture_t *p_subpic = NULL; /* first free subpicture */
1214 vlc_mutex_lock( &p_spu->subpicture_lock );
1216 for( i_subpic = 0; i_subpic < VOUT_MAX_SUBPICTURES; i_subpic++ )
1218 p_subpic = &p_spu->p_subpicture[i_subpic];
1219 if( p_subpic->i_status == FREE_SUBPICTURE
1220 || ( p_subpic->i_status != RESERVED_SUBPICTURE
1221 && p_subpic->i_status != READY_SUBPICTURE ) )
1226 if( p_subpic->i_channel == i_channel )
1228 while( p_subpic->p_region )
1230 subpicture_region_t *p_region = p_subpic->p_region;
1231 p_subpic->p_region = p_region->p_next;
1232 spu_DestroyRegion( p_spu, p_region );
1235 if( p_subpic->pf_destroy ) p_subpic->pf_destroy( p_subpic );
1236 p_subpic->i_status = FREE_SUBPICTURE;
1240 vlc_mutex_unlock( &p_spu->subpicture_lock );
1243 /*****************************************************************************
1244 * spu_ControlDefault: default methods for the subpicture unit control.
1245 *****************************************************************************/
1246 static int spu_vaControlDefault( spu_t *p_spu, int i_query, va_list args )
1252 case SPU_CHANNEL_REGISTER:
1253 pi = (int *)va_arg( args, int * );
1254 if( pi ) *pi = p_spu->i_channel++;
1257 case SPU_CHANNEL_CLEAR:
1258 i = (int)va_arg( args, int );
1259 SpuClearChannel( p_spu, i );
1263 msg_Dbg( p_spu, "control query not supported" );
1264 return VLC_EGENERIC;
1270 /*****************************************************************************
1271 * Object variables callbacks
1272 *****************************************************************************/
1274 /*****************************************************************************
1275 * UpdateSPU: update subpicture settings
1276 *****************************************************************************
1277 * This function is called from CropCallback and at initialization time, to
1278 * retrieve crop information from the input.
1279 *****************************************************************************/
1280 static void UpdateSPU( spu_t *p_spu, vlc_object_t *p_object )
1284 p_spu->b_force_palette = false;
1285 p_spu->b_force_crop = false;
1287 if( var_Get( p_object, "highlight", &val ) || !val.b_bool ) return;
1289 p_spu->b_force_crop = true;
1290 var_Get( p_object, "x-start", &val );
1291 p_spu->i_crop_x = val.i_int;
1292 var_Get( p_object, "y-start", &val );
1293 p_spu->i_crop_y = val.i_int;
1294 var_Get( p_object, "x-end", &val );
1295 p_spu->i_crop_width = val.i_int - p_spu->i_crop_x;
1296 var_Get( p_object, "y-end", &val );
1297 p_spu->i_crop_height = val.i_int - p_spu->i_crop_y;
1299 if( var_Get( p_object, "menu-palette", &val ) == VLC_SUCCESS )
1301 memcpy( p_spu->palette, val.p_address, 16 );
1302 p_spu->b_force_palette = true;
1305 msg_Dbg( p_object, "crop: %i,%i,%i,%i, palette forced: %i",
1306 p_spu->i_crop_x, p_spu->i_crop_y,
1307 p_spu->i_crop_width, p_spu->i_crop_height,
1308 p_spu->b_force_palette );
1311 /*****************************************************************************
1312 * CropCallback: called when the highlight properties are changed
1313 *****************************************************************************
1314 * This callback is called from the input thread when we need cropping
1315 *****************************************************************************/
1316 static int CropCallback( vlc_object_t *p_object, char const *psz_var,
1317 vlc_value_t oldval, vlc_value_t newval, void *p_data )
1319 (void)psz_var; (void)oldval; (void)newval;
1320 UpdateSPU( (spu_t *)p_data, p_object );
1324 /*****************************************************************************
1325 * Buffers allocation callbacks for the filters
1326 *****************************************************************************/
1327 static subpicture_t *sub_new_buffer( filter_t *p_filter )
1329 filter_owner_sys_t *p_sys = p_filter->p_owner;
1330 subpicture_t *p_subpicture = spu_CreateSubpicture( p_sys->p_spu );
1331 if( p_subpicture ) p_subpicture->i_channel = p_sys->i_channel;
1332 return p_subpicture;
1335 static void sub_del_buffer( filter_t *p_filter, subpicture_t *p_subpic )
1337 filter_owner_sys_t *p_sys = p_filter->p_owner;
1338 spu_DestroySubpicture( p_sys->p_spu, p_subpic );
1341 static subpicture_t *spu_new_buffer( filter_t *p_filter )
1344 subpicture_t *p_subpic = (subpicture_t *)malloc(sizeof(subpicture_t));
1345 if( !p_subpic ) return NULL;
1346 memset( p_subpic, 0, sizeof(subpicture_t) );
1347 p_subpic->b_absolute = true;
1349 p_subpic->pf_create_region = __spu_CreateRegion;
1350 p_subpic->pf_make_region = __spu_MakeRegion;
1351 p_subpic->pf_destroy_region = __spu_DestroyRegion;
1356 static void spu_del_buffer( filter_t *p_filter, subpicture_t *p_subpic )
1358 while( p_subpic->p_region )
1360 subpicture_region_t *p_region = p_subpic->p_region;
1361 p_subpic->p_region = p_region->p_next;
1362 p_subpic->pf_destroy_region( VLC_OBJECT(p_filter), p_region );
1368 static picture_t *spu_new_video_buffer( filter_t *p_filter )
1370 picture_t *p_picture = malloc( sizeof(picture_t) );
1371 if( !p_picture ) return NULL;
1372 if( vout_AllocatePicture( p_filter, p_picture,
1373 p_filter->fmt_out.video.i_chroma,
1374 p_filter->fmt_out.video.i_width,
1375 p_filter->fmt_out.video.i_height,
1376 p_filter->fmt_out.video.i_aspect )
1383 p_picture->pf_release = RegionPictureRelease;
1388 static void spu_del_video_buffer( filter_t *p_filter, picture_t *p_pic )
1393 free( p_pic->p_data_orig );
1398 static int SubFilterCallback( vlc_object_t *p_object, char const *psz_var,
1399 vlc_value_t oldval, vlc_value_t newval, void *p_data )
1401 VLC_UNUSED(p_object); VLC_UNUSED(oldval);
1402 VLC_UNUSED(newval); VLC_UNUSED(psz_var);
1404 spu_t *p_spu = (spu_t *)p_data;
1405 vlc_mutex_lock( &p_spu->subpicture_lock );
1406 spu_DeleteChain( p_spu );
1407 spu_ParseChain( p_spu );
1408 vlc_mutex_unlock( &p_spu->subpicture_lock );