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 *****************************************************************************/
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 );
151 if( p_spu->pp_filter[p_spu->i_filter]->p_module )
153 filter_owner_sys_t *p_sys = malloc( sizeof(filter_owner_sys_t) );
156 p_spu->pp_filter[p_spu->i_filter]->p_owner = p_sys;
157 spu_Control( p_spu, SPU_CHANNEL_REGISTER, &p_sys->i_channel );
158 p_sys->p_spu = p_spu;
164 msg_Dbg( p_spu, "no sub filter found" );
165 config_ChainDestroy( p_spu->pp_filter[p_spu->i_filter]->p_cfg );
166 vlc_object_detach( p_spu->pp_filter[p_spu->i_filter] );
167 vlc_object_release( p_spu->pp_filter[p_spu->i_filter] );
170 if( p_spu->i_filter >= 10 )
172 msg_Dbg( p_spu, "can't add anymore filters" );
177 free( val.psz_string );
183 * Destroy the subpicture unit
185 * \param p_this the parent object which destroys the subpicture unit
187 void spu_Destroy( spu_t *p_spu )
191 vlc_object_detach( p_spu );
193 /* Destroy all remaining subpictures */
194 for( i_index = 0; i_index < VOUT_MAX_SUBPICTURES; i_index++ )
196 if( p_spu->p_subpicture[i_index].i_status != FREE_SUBPICTURE )
198 spu_DestroySubpicture( p_spu, &p_spu->p_subpicture[i_index] );
204 if( p_spu->p_blend->p_module )
205 module_Unneed( p_spu->p_blend, p_spu->p_blend->p_module );
207 vlc_object_detach( p_spu->p_blend );
208 vlc_object_release( p_spu->p_blend );
213 if( p_spu->p_text->p_module )
214 module_Unneed( p_spu->p_text, p_spu->p_text->p_module );
216 vlc_object_detach( p_spu->p_text );
217 vlc_object_release( p_spu->p_text );
222 if( p_spu->p_scale->p_module )
223 module_Unneed( p_spu->p_scale, p_spu->p_scale->p_module );
225 vlc_object_detach( p_spu->p_scale );
226 vlc_object_release( p_spu->p_scale );
229 spu_DeleteChain( p_spu );
231 vlc_mutex_destroy( &p_spu->subpicture_lock );
232 vlc_object_release( p_spu );
235 static void spu_DeleteChain( spu_t *p_spu )
237 if( p_spu->i_filter )
238 while( p_spu->i_filter )
241 module_Unneed( p_spu->pp_filter[p_spu->i_filter],
242 p_spu->pp_filter[p_spu->i_filter]->p_module );
243 free( p_spu->pp_filter[p_spu->i_filter]->p_owner );
244 config_ChainDestroy( p_spu->pp_filter[p_spu->i_filter]->p_cfg );
245 vlc_object_detach( p_spu->pp_filter[p_spu->i_filter] );
246 vlc_object_release( p_spu->pp_filter[p_spu->i_filter] );
251 * Attach/Detach the SPU from any input
253 * \param p_this the object in which to destroy the subpicture unit
254 * \param b_attach to select attach or detach
256 void spu_Attach( spu_t *p_spu, vlc_object_t *p_this, bool b_attach )
258 vlc_object_t *p_input;
260 p_input = vlc_object_find( p_this, VLC_OBJECT_INPUT, FIND_PARENT );
261 if( !p_input ) return;
265 UpdateSPU( p_spu, VLC_OBJECT(p_input) );
266 var_AddCallback( p_input, "highlight", CropCallback, p_spu );
267 vlc_object_release( p_input );
271 /* Delete callback */
272 var_DelCallback( p_input, "highlight", CropCallback, p_spu );
273 vlc_object_release( p_input );
278 * Create a subpicture region
280 * \param p_this vlc_object_t
281 * \param p_fmt the format that this subpicture region should have
283 static void RegionPictureRelease( picture_t *p_pic )
285 free( p_pic->p_data_orig );
287 subpicture_region_t *__spu_CreateRegion( vlc_object_t *p_this,
288 video_format_t *p_fmt )
290 subpicture_region_t *p_region = malloc( sizeof(subpicture_region_t) );
291 if( !p_region ) return NULL;
293 memset( p_region, 0, sizeof(subpicture_region_t) );
294 p_region->i_alpha = 0xff;
295 p_region->p_next = NULL;
296 p_region->p_cache = NULL;
297 p_region->fmt = *p_fmt;
298 p_region->psz_text = NULL;
299 p_region->p_style = NULL;
301 if( p_fmt->i_chroma == VLC_FOURCC('Y','U','V','P') )
302 p_fmt->p_palette = p_region->fmt.p_palette =
303 malloc( sizeof(video_palette_t) );
304 else p_fmt->p_palette = p_region->fmt.p_palette = NULL;
306 p_region->picture.p_data_orig = NULL;
308 if( p_fmt->i_chroma == VLC_FOURCC('T','E','X','T') ) return p_region;
310 vout_AllocatePicture( p_this, &p_region->picture, p_fmt->i_chroma,
311 p_fmt->i_width, p_fmt->i_height, p_fmt->i_aspect );
313 if( !p_region->picture.i_planes )
316 free( p_fmt->p_palette );
320 p_region->picture.pf_release = RegionPictureRelease;
326 * Make a subpicture region from an existing picture_t
328 * \param p_this vlc_object_t
329 * \param p_fmt the format that this subpicture region should have
330 * \param p_pic a pointer to the picture creating the region (not freed)
332 subpicture_region_t *__spu_MakeRegion( vlc_object_t *p_this,
333 video_format_t *p_fmt,
336 subpicture_region_t *p_region = malloc( sizeof(subpicture_region_t) );
338 if( !p_region ) return NULL;
339 memset( p_region, 0, sizeof(subpicture_region_t) );
340 p_region->i_alpha = 0xff;
341 p_region->p_next = 0;
342 p_region->p_cache = 0;
343 p_region->fmt = *p_fmt;
344 p_region->psz_text = 0;
345 p_region->p_style = NULL;
347 if( p_fmt->i_chroma == VLC_FOURCC('Y','U','V','P') )
348 p_fmt->p_palette = p_region->fmt.p_palette =
349 malloc( sizeof(video_palette_t) );
350 else p_fmt->p_palette = p_region->fmt.p_palette = NULL;
352 memcpy( &p_region->picture, p_pic, sizeof(picture_t) );
353 p_region->picture.pf_release = RegionPictureRelease;
359 * Destroy a subpicture region
361 * \param p_this vlc_object_t
362 * \param p_region the subpicture region to destroy
364 void __spu_DestroyRegion( vlc_object_t *p_this, subpicture_region_t *p_region )
366 if( !p_region ) return;
367 if( p_region->picture.pf_release )
368 p_region->picture.pf_release( &p_region->picture );
369 free( p_region->fmt.p_palette );
370 if( p_region->p_cache ) __spu_DestroyRegion( p_this, p_region->p_cache );
372 free( p_region->psz_text );
373 free( p_region->psz_html );
374 //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
379 * Display a subpicture
381 * Remove the reservation flag of a subpicture, which will cause it to be
383 * \param p_spu the subpicture unit object
384 * \param p_subpic the subpicture to display
386 void spu_DisplaySubpicture( spu_t *p_spu, subpicture_t *p_subpic )
388 /* Check if status is valid */
389 if( p_subpic->i_status != RESERVED_SUBPICTURE )
391 msg_Err( p_spu, "subpicture %p has invalid status #%d",
392 p_subpic, p_subpic->i_status );
395 /* Remove reservation flag */
396 p_subpic->i_status = READY_SUBPICTURE;
398 if( p_subpic->i_channel == DEFAULT_CHAN )
400 p_subpic->i_channel = 0xFFFF;
401 spu_Control( p_spu, SPU_CHANNEL_CLEAR, DEFAULT_CHAN );
402 p_subpic->i_channel = DEFAULT_CHAN;
407 * Allocate a subpicture in the spu heap.
409 * This function create a reserved subpicture in the spu heap.
410 * A null pointer is returned if the function fails. This method provides an
411 * already allocated zone of memory in the spu data fields. It needs locking
412 * since several pictures can be created by several producers threads.
413 * \param p_spu the subpicture unit in which to create the subpicture
414 * \return NULL on error, a reserved subpicture otherwise
416 subpicture_t *spu_CreateSubpicture( spu_t *p_spu )
418 int i_subpic; /* subpicture index */
419 subpicture_t * p_subpic = NULL; /* first free subpicture */
422 vlc_mutex_lock( &p_spu->subpicture_lock );
425 * Look for an empty place
428 for( i_subpic = 0; i_subpic < VOUT_MAX_SUBPICTURES; i_subpic++ )
430 if( p_spu->p_subpicture[i_subpic].i_status == FREE_SUBPICTURE )
432 /* Subpicture is empty and ready for allocation */
433 p_subpic = &p_spu->p_subpicture[i_subpic];
434 p_spu->p_subpicture[i_subpic].i_status = RESERVED_SUBPICTURE;
439 /* If no free subpicture could be found */
440 if( p_subpic == NULL )
442 msg_Err( p_spu, "subpicture heap is full" );
443 vlc_mutex_unlock( &p_spu->subpicture_lock );
447 /* Copy subpicture information, set some default values */
448 memset( p_subpic, 0, sizeof(subpicture_t) );
449 p_subpic->i_status = RESERVED_SUBPICTURE;
450 p_subpic->b_absolute = true;
451 p_subpic->b_pausable = false;
452 p_subpic->b_fade = false;
453 p_subpic->i_alpha = 0xFF;
454 p_subpic->p_region = NULL;
455 p_subpic->pf_render = NULL;
456 p_subpic->pf_destroy = NULL;
457 p_subpic->p_sys = NULL;
458 vlc_mutex_unlock( &p_spu->subpicture_lock );
460 p_subpic->pf_create_region = __spu_CreateRegion;
461 p_subpic->pf_make_region = __spu_MakeRegion;
462 p_subpic->pf_destroy_region = __spu_DestroyRegion;
468 * Remove a subpicture from the heap
470 * This function frees a previously reserved subpicture.
471 * It is meant to be used when the construction of a picture aborted.
472 * This function does not need locking since reserved subpictures are ignored
475 void spu_DestroySubpicture( spu_t *p_spu, subpicture_t *p_subpic )
478 vlc_mutex_lock( &p_spu->subpicture_lock );
480 /* There can be race conditions so we need to check the status */
481 if( p_subpic->i_status == FREE_SUBPICTURE )
483 vlc_mutex_unlock( &p_spu->subpicture_lock );
487 /* Check if status is valid */
488 if( ( p_subpic->i_status != RESERVED_SUBPICTURE )
489 && ( p_subpic->i_status != READY_SUBPICTURE ) )
491 msg_Err( p_spu, "subpicture %p has invalid status %d",
492 p_subpic, p_subpic->i_status );
495 while( p_subpic->p_region )
497 subpicture_region_t *p_region = p_subpic->p_region;
498 p_subpic->p_region = p_region->p_next;
499 spu_DestroyRegion( p_spu, p_region );
502 if( p_subpic->pf_destroy )
504 p_subpic->pf_destroy( p_subpic );
507 p_subpic->i_status = FREE_SUBPICTURE;
509 vlc_mutex_unlock( &p_spu->subpicture_lock );
512 /*****************************************************************************
513 * spu_RenderSubpictures: render a subpicture list
514 *****************************************************************************
515 * This function renders all sub picture units in the list.
516 *****************************************************************************/
517 void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt,
518 picture_t *p_pic_dst, picture_t *p_pic_src,
519 subpicture_t *p_subpic,
520 int i_scale_width_orig, int i_scale_height_orig )
522 int i_source_video_width;
523 int i_source_video_height;
524 subpicture_t *p_subpic_v = p_subpic;
527 vlc_mutex_lock( &p_spu->subpicture_lock );
529 for( p_subpic_v = p_subpic;
530 p_subpic_v != NULL && p_subpic_v->i_status != FREE_SUBPICTURE;
531 p_subpic_v = p_subpic_v->p_next )
533 if( p_subpic_v->pf_pre_render )
535 p_subpic_v->pf_pre_render( p_fmt, p_spu, p_subpic_v, mdate() );
539 if( i_scale_width_orig <= 0 )
540 i_scale_width_orig = 1;
541 if( i_scale_height_orig <= 0 )
542 i_scale_height_orig = 1;
544 i_source_video_width = p_fmt->i_width * 1000 / i_scale_width_orig;
545 i_source_video_height = p_fmt->i_height * 1000 / i_scale_height_orig;
547 /* Check i_status again to make sure spudec hasn't destroyed the subpic */
548 while( ( p_subpic != NULL ) && ( p_subpic->i_status != FREE_SUBPICTURE ) )
550 subpicture_region_t *p_region;
551 int pi_scale_width[ SCALE_SIZE ];
552 int pi_scale_height[ SCALE_SIZE ];
553 int pi_subpic_x[ SCALE_SIZE ];
556 /* If the source video and subtitles stream agree on the size of
557 * the video then disregard all further references to the subtitle
560 if( ( i_source_video_height == p_subpic->i_original_picture_height ) &&
561 ( i_source_video_width == p_subpic->i_original_picture_width ) )
563 p_subpic->i_original_picture_height = 0;
564 p_subpic->i_original_picture_width = 0;
567 for( k = 0; k < SCALE_SIZE ; k++ )
568 pi_subpic_x[ k ] = p_subpic->i_x;
570 if( p_subpic->pf_update_regions )
572 if ( p_subpic->p_region ) {
573 spu_DestroyRegion( p_spu, p_subpic->p_region );
575 p_subpic->p_region = p_region = p_subpic->pf_update_regions( p_fmt, p_spu, p_subpic, mdate() );
579 p_region = p_subpic->p_region;
582 /* Load the blending module */
583 if( !p_spu->p_blend && p_region )
585 p_spu->p_blend = vlc_object_create( p_spu, VLC_OBJECT_FILTER );
586 vlc_object_attach( p_spu->p_blend, p_spu );
587 p_spu->p_blend->fmt_out.video.i_x_offset =
588 p_spu->p_blend->fmt_out.video.i_y_offset = 0;
589 p_spu->p_blend->fmt_out.video.i_aspect = p_fmt->i_aspect;
590 p_spu->p_blend->fmt_out.video.i_chroma = p_fmt->i_chroma;
592 /* The blend module will be loaded when needed with the real
594 memset( &p_spu->p_blend->fmt_in, 0, sizeof(p_spu->p_blend->fmt_in) );
595 p_spu->p_blend->p_module = NULL;
598 /* Load the text rendering module; it is possible there is a
599 * text region somewhere in the subpicture other than the first
600 * element in the region list, so just load it anyway as we'll
601 * probably want it sooner or later. */
602 if( !p_spu->p_text && p_region )
604 char *psz_modulename = NULL;
606 p_spu->p_text = vlc_object_create( p_spu, VLC_OBJECT_FILTER );
607 vlc_object_attach( p_spu->p_text, p_spu );
609 p_spu->p_text->fmt_out.video.i_width =
610 p_spu->p_text->fmt_out.video.i_visible_width =
612 p_spu->p_text->fmt_out.video.i_height =
613 p_spu->p_text->fmt_out.video.i_visible_height =
616 p_spu->p_text->pf_sub_buffer_new = spu_new_buffer;
617 p_spu->p_text->pf_sub_buffer_del = spu_del_buffer;
619 psz_modulename = var_CreateGetString( p_spu, "text-renderer" );
620 if( psz_modulename && *psz_modulename )
622 p_spu->p_text->p_module =
623 module_Need( p_spu->p_text, "text renderer",
624 psz_modulename, true );
626 if( !p_spu->p_text->p_module )
628 p_spu->p_text->p_module =
629 module_Need( p_spu->p_text, "text renderer", 0, 0 );
631 free( psz_modulename );
636 subpicture_region_t *p_text_region = p_subpic->p_region;
638 /* Only overwrite the size fields if the region is still in
639 * pre-rendered TEXT format. We have to traverse the subregion
640 * list because if more than one subregion is present, the text
641 * region isn't guarentteed to be the first in the list, and
642 * only text regions use this flag. All of this effort assists
643 * with the rescaling of text that has been rendered at native
644 * resolution, rather than video resolution.
646 while( p_text_region &&
647 ( p_text_region->fmt.i_chroma != VLC_FOURCC('T','E','X','T') ) )
649 p_text_region = p_text_region->p_next;
653 ( ( p_text_region->i_align & SUBPICTURE_RENDERED ) == 0 ) )
655 if( (p_subpic->i_original_picture_height > 0) &&
656 (p_subpic->i_original_picture_width > 0) )
658 p_spu->p_text->fmt_out.video.i_width =
659 p_spu->p_text->fmt_out.video.i_visible_width =
660 p_subpic->i_original_picture_width;
661 p_spu->p_text->fmt_out.video.i_height =
662 p_spu->p_text->fmt_out.video.i_visible_height =
663 p_subpic->i_original_picture_height;
667 p_spu->p_text->fmt_out.video.i_width =
668 p_spu->p_text->fmt_out.video.i_visible_width =
670 p_spu->p_text->fmt_out.video.i_height =
671 p_spu->p_text->fmt_out.video.i_visible_height =
677 pi_scale_width[ SCALE_DEFAULT ] = i_scale_width_orig;
678 pi_scale_height[ SCALE_DEFAULT ] = i_scale_height_orig;
682 pi_scale_width[ SCALE_TEXT ] = ( p_fmt->i_width * 1000 ) /
683 p_spu->p_text->fmt_out.video.i_width;
684 pi_scale_height[ SCALE_TEXT ] = ( p_fmt->i_height * 1000 ) /
685 p_spu->p_text->fmt_out.video.i_height;
687 /* If we have an explicit size plane to render to, then turn off
688 * the fontsize rescaling.
690 if( (p_subpic->i_original_picture_height > 0) &&
691 (p_subpic->i_original_picture_width > 0) )
693 i_scale_width_orig = 1000;
694 i_scale_height_orig = 1000;
697 for( k = 0; k < SCALE_SIZE ; k++ )
699 /* Case of both width and height being specified has been dealt
700 * with above by instead rendering to an output pane of the
701 * explicit dimensions specified - we don't need to scale it.
703 if( (p_subpic->i_original_picture_height > 0) &&
704 (p_subpic->i_original_picture_width <= 0) )
706 pi_scale_height[ k ] = pi_scale_height[ k ] * i_source_video_height /
707 p_subpic->i_original_picture_height;
708 pi_scale_width[ k ] = pi_scale_width[ k ] * i_source_video_height /
709 p_subpic->i_original_picture_height;
713 /* Set default subpicture aspect ratio */
714 if( p_region && p_region->fmt.i_aspect &&
715 ( !p_region->fmt.i_sar_num || !p_region->fmt.i_sar_den ) )
717 p_region->fmt.i_sar_den = p_region->fmt.i_aspect;
718 p_region->fmt.i_sar_num = VOUT_ASPECT_FACTOR;
721 ( !p_region->fmt.i_sar_num || !p_region->fmt.i_sar_den ) )
723 p_region->fmt.i_sar_den = p_fmt->i_sar_den;
724 p_region->fmt.i_sar_num = p_fmt->i_sar_num;
727 /* Take care of the aspect ratio */
729 ( ( p_region->fmt.i_sar_num * p_fmt->i_sar_den ) !=
730 ( p_region->fmt.i_sar_den * p_fmt->i_sar_num ) ) )
732 for( k = 0; k < SCALE_SIZE ; k++ )
734 pi_scale_width[ k ] = pi_scale_width[ k ] *
735 (int64_t)p_region->fmt.i_sar_num * p_fmt->i_sar_den /
736 p_region->fmt.i_sar_den / p_fmt->i_sar_num;
737 pi_subpic_x[ k ] = p_subpic->i_x * pi_scale_width[ k ] / 1000;
741 /* Load the scaling module */
742 if( !p_spu->p_scale &&
743 ((((pi_scale_width[ SCALE_TEXT ] > 0) || (pi_scale_height[ SCALE_TEXT ] > 0)) &&
744 ((pi_scale_width[ SCALE_TEXT ] != 1000) || (pi_scale_height[ SCALE_TEXT ] != 1000))) ||
745 (((pi_scale_width[ SCALE_DEFAULT ] > 0) || (pi_scale_height[ SCALE_DEFAULT ] > 0)) &&
746 ((pi_scale_width[ SCALE_DEFAULT ] != 1000) || (pi_scale_height[ SCALE_DEFAULT ] != 1000)))) )
748 p_spu->p_scale = vlc_object_create( p_spu, VLC_OBJECT_FILTER );
749 vlc_object_attach( p_spu->p_scale, p_spu );
750 p_spu->p_scale->fmt_out.video.i_chroma =
751 p_spu->p_scale->fmt_in.video.i_chroma =
752 VLC_FOURCC('Y','U','V','P');
753 /* FIXME: We'll also be using it for YUVA and RGBA blending ... */
755 p_spu->p_scale->fmt_in.video.i_width =
756 p_spu->p_scale->fmt_in.video.i_height = 32;
757 p_spu->p_scale->fmt_out.video.i_width =
758 p_spu->p_scale->fmt_out.video.i_height = 16;
760 p_spu->p_scale->pf_vout_buffer_new = spu_new_video_buffer;
761 p_spu->p_scale->pf_vout_buffer_del = spu_del_video_buffer;
762 p_spu->p_scale->p_module =
763 module_Need( p_spu->p_scale, "video filter2", 0, 0 );
768 video_format_t orig_fmt = p_region->fmt;
769 bool b_rerender_text = false;
770 int i_fade_alpha = 255;
773 int i_scale_idx = SCALE_DEFAULT;
774 int i_inv_scale_x = 1000;
775 int i_inv_scale_y = 1000;
777 if( p_region->fmt.i_chroma == VLC_FOURCC('T','E','X','T') )
779 if( p_spu->p_text && p_spu->p_text->p_module )
783 /* Setup 3 variables which can be used to render
784 * time-dependent text (and effects). The first indicates
785 * the total amount of time the text will be on screen,
786 * the second the amount of time it has already been on
787 * screen (can be a negative value as text is layed out
788 * before it is rendered) and the third is a feedback
789 * variable from the renderer - if the renderer sets it
790 * then this particular text is time-dependent, eg. the
791 * visual progress bar inside the text in karaoke and the
792 * text needs to be rendered multiple times in order for
793 * the effect to work - we therefore need to return the
794 * region to its original state at the end of the loop,
795 * instead of leaving it in YUVA or YUVP.
796 * Any renderer which is unaware of how to render
797 * time-dependent text can happily ignore the variables
798 * and render the text the same as usual - it should at
799 * least show up on screen, but the effect won't change
800 * the text over time.
803 var_Create( p_spu->p_text, "spu-duration", VLC_VAR_TIME );
804 val.i_time = p_subpic->i_stop - p_subpic->i_start;
805 var_Set( p_spu->p_text, "spu-duration", val );
807 var_Create( p_spu->p_text, "spu-elapsed", VLC_VAR_TIME );
808 val.i_time = mdate() - p_subpic->i_start;
809 var_Set( p_spu->p_text, "spu-elapsed", val );
811 var_Create( p_spu->p_text, "text-rerender", VLC_VAR_BOOL );
812 var_SetBool( p_spu->p_text, "text-rerender", false );
814 var_Create( p_spu->p_text, "scale", VLC_VAR_INTEGER );
815 var_SetInteger( p_spu->p_text, "scale",
816 __MIN(i_scale_width_orig, i_scale_height_orig) );
818 if( p_spu->p_text->pf_render_html && p_region->psz_html )
820 p_spu->p_text->pf_render_html( p_spu->p_text,
821 p_region, p_region );
823 else if( p_spu->p_text->pf_render_text )
825 p_spu->p_text->pf_render_text( p_spu->p_text,
826 p_region, p_region );
828 b_rerender_text = var_GetBool( p_spu->p_text, "text-rerender" );
830 var_Destroy( p_spu->p_text, "spu-duration" );
831 var_Destroy( p_spu->p_text, "spu-elapsed" );
832 var_Destroy( p_spu->p_text, "text-rerender" );
833 var_Destroy( p_spu->p_text, "scale" );
835 p_region->i_align |= SUBPICTURE_RENDERED;
838 if( p_region->i_align & SUBPICTURE_RENDERED )
840 i_scale_idx = SCALE_TEXT;
841 i_inv_scale_x = i_scale_width_orig;
842 i_inv_scale_y = i_scale_height_orig;
845 i_x_offset = (p_region->i_x + pi_subpic_x[ i_scale_idx ]) * i_inv_scale_x / 1000;
846 i_y_offset = (p_region->i_y + p_subpic->i_y) * i_inv_scale_y / 1000;
848 /* Force palette if requested */
849 if( p_spu->b_force_palette &&
850 ( VLC_FOURCC('Y','U','V','P') == p_region->fmt.i_chroma ) )
852 memcpy( p_region->fmt.p_palette->palette,
853 p_spu->palette, 16 );
856 /* Scale SPU if necessary */
857 if( p_region->p_cache &&
858 ( p_region->fmt.i_chroma != VLC_FOURCC('T','E','X','T') ) )
860 if( pi_scale_width[ i_scale_idx ] * p_region->fmt.i_width / 1000 !=
861 p_region->p_cache->fmt.i_width ||
862 pi_scale_height[ i_scale_idx ] * p_region->fmt.i_height / 1000 !=
863 p_region->p_cache->fmt.i_height )
865 p_subpic->pf_destroy_region( VLC_OBJECT(p_spu),
867 p_region->p_cache = 0;
871 if( ( ( pi_scale_width[ i_scale_idx ] != 1000 ) ||
872 ( pi_scale_height[ i_scale_idx ] != 1000 ) ) &&
873 ( ( pi_scale_width[ i_scale_idx ] > 0 ) ||
874 ( pi_scale_height[ i_scale_idx ] > 0 ) ) &&
875 p_spu->p_scale && !p_region->p_cache &&
876 ( p_region->fmt.i_chroma != VLC_FOURCC('T','E','X','T') ) )
880 p_spu->p_scale->fmt_in.video = p_region->fmt;
881 p_spu->p_scale->fmt_out.video = p_region->fmt;
884 p_subpic->pf_create_region( VLC_OBJECT(p_spu),
885 &p_spu->p_scale->fmt_out.video );
886 if( p_spu->p_scale->fmt_out.video.p_palette )
887 *p_spu->p_scale->fmt_out.video.p_palette =
888 *p_region->fmt.p_palette;
889 p_region->p_cache->p_next = p_region->p_next;
891 vout_CopyPicture( p_spu, &p_region->p_cache->picture,
892 &p_region->picture );
894 p_spu->p_scale->fmt_out.video.i_width =
895 p_region->fmt.i_width * pi_scale_width[ i_scale_idx ] / 1000;
896 p_spu->p_scale->fmt_out.video.i_visible_width =
897 p_region->fmt.i_visible_width * pi_scale_width[ i_scale_idx ] / 1000;
898 p_spu->p_scale->fmt_out.video.i_height =
899 p_region->fmt.i_height * pi_scale_height[ i_scale_idx ] / 1000;
900 p_spu->p_scale->fmt_out.video.i_visible_height =
901 p_region->fmt.i_visible_height * pi_scale_height[ i_scale_idx ] / 1000;
902 p_region->p_cache->fmt = p_spu->p_scale->fmt_out.video;
903 p_region->p_cache->i_x = p_region->i_x * pi_scale_width[ i_scale_idx ] / 1000;
904 p_region->p_cache->i_y = p_region->i_y * pi_scale_height[ i_scale_idx ] / 1000;
905 p_region->p_cache->i_align = p_region->i_align;
906 p_region->p_cache->i_alpha = p_region->i_alpha;
908 p_pic = p_spu->p_scale->pf_video_filter(
909 p_spu->p_scale, &p_region->p_cache->picture );
912 picture_t p_pic_tmp = p_region->p_cache->picture;
913 p_region->p_cache->picture = *p_pic;
919 if( ( ( pi_scale_width[ i_scale_idx ] != 1000 ) ||
920 ( pi_scale_height[ i_scale_idx ] != 1000 ) ) &&
921 ( ( pi_scale_width[ i_scale_idx ] > 0 ) ||
922 ( pi_scale_height[ i_scale_idx ] > 0 ) ) &&
923 p_spu->p_scale && p_region->p_cache &&
924 ( p_region->fmt.i_chroma != VLC_FOURCC('T','E','X','T') ) )
926 p_region = p_region->p_cache;
929 if( p_region->i_align & SUBPICTURE_ALIGN_BOTTOM )
931 i_y_offset = p_fmt->i_height - p_region->fmt.i_height -
932 (p_subpic->i_y + p_region->i_y) * i_inv_scale_y / 1000;
934 else if ( !(p_region->i_align & SUBPICTURE_ALIGN_TOP) )
936 i_y_offset = p_fmt->i_height / 2 - p_region->fmt.i_height / 2;
939 if( p_region->i_align & SUBPICTURE_ALIGN_RIGHT )
941 i_x_offset = p_fmt->i_width - p_region->fmt.i_width -
942 (pi_subpic_x[ i_scale_idx ] + p_region->i_x)
943 * i_inv_scale_x / 1000;
945 else if ( !(p_region->i_align & SUBPICTURE_ALIGN_LEFT) )
947 i_x_offset = p_fmt->i_width / 2 - p_region->fmt.i_width / 2;
950 if( p_subpic->b_absolute )
952 i_x_offset = (p_region->i_x +
953 pi_subpic_x[ i_scale_idx ] *
954 pi_scale_width[ i_scale_idx ] / 1000)
955 * i_inv_scale_x / 1000;
956 i_y_offset = (p_region->i_y +
957 p_subpic->i_y * pi_scale_height[ i_scale_idx ] / 1000)
958 * i_inv_scale_y / 1000;
962 i_x_offset = __MAX( i_x_offset, 0 );
963 i_y_offset = __MAX( i_y_offset, 0 );
965 if( ( p_spu->i_margin != 0 ) &&
966 ( p_spu->b_force_crop == false ) )
969 int i_low = (i_y_offset - p_spu->i_margin) * i_inv_scale_y / 1000;
970 int i_high = i_low + p_region->fmt.i_height;
972 /* crop extra margin to keep within bounds */
975 if( i_high > (int)p_fmt->i_height )
976 i_diff = i_high - p_fmt->i_height;
977 i_y_offset -= ( p_spu->i_margin * i_inv_scale_y / 1000 + i_diff );
980 if( p_subpic->b_fade )
982 mtime_t i_fade_start = ( p_subpic->i_stop +
983 p_subpic->i_start ) / 2;
984 mtime_t i_now = mdate();
985 if( i_now >= i_fade_start && p_subpic->i_stop > i_fade_start )
987 i_fade_alpha = 255 * ( p_subpic->i_stop - i_now ) /
988 ( p_subpic->i_stop - i_fade_start );
992 if( p_region->fmt.i_chroma != VLC_FOURCC('T','E','X','T') )
994 if( p_spu->p_blend->fmt_in.video.i_chroma != p_region->fmt.i_chroma )
996 /* The chroma is not the same, we need to reload the blend module
997 * XXX to match the old behaviour just test !p_spu->p_blend->fmt_in.video.i_chroma */
998 if( p_spu->p_blend->p_module )
999 module_Unneed( p_spu->p_blend, p_spu->p_blend->p_module );
1001 p_spu->p_blend->fmt_in.video = p_region->fmt;
1002 p_spu->p_blend->p_module = module_Need( p_spu->p_blend, "video blending", 0, 0 );
1006 p_spu->p_blend->fmt_in.video = p_region->fmt;
1009 /* Force cropping if requested */
1010 if( p_spu->b_force_crop )
1012 video_format_t *p_fmt = &p_spu->p_blend->fmt_in.video;
1013 int i_crop_x = p_spu->i_crop_x * pi_scale_width[ i_scale_idx ] / 1000
1014 * i_inv_scale_x / 1000;
1015 int i_crop_y = p_spu->i_crop_y * pi_scale_height[ i_scale_idx ] / 1000
1016 * i_inv_scale_y / 1000;
1017 int i_crop_width = p_spu->i_crop_width * pi_scale_width[ i_scale_idx ] / 1000
1018 * i_inv_scale_x / 1000;
1019 int i_crop_height = p_spu->i_crop_height * pi_scale_height[ i_scale_idx ] / 1000
1020 * i_inv_scale_y / 1000;
1022 /* Find the intersection */
1023 if( i_crop_x + i_crop_width <= i_x_offset ||
1024 i_x_offset + (int)p_fmt->i_visible_width < i_crop_x ||
1025 i_crop_y + i_crop_height <= i_y_offset ||
1026 i_y_offset + (int)p_fmt->i_visible_height < i_crop_y )
1028 /* No intersection */
1029 p_fmt->i_visible_width = p_fmt->i_visible_height = 0;
1033 int i_x, i_y, i_x_end, i_y_end;
1034 i_x = __MAX( i_crop_x, i_x_offset );
1035 i_y = __MAX( i_crop_y, i_y_offset );
1036 i_x_end = __MIN( i_crop_x + i_crop_width,
1037 i_x_offset + (int)p_fmt->i_visible_width );
1038 i_y_end = __MIN( i_crop_y + i_crop_height,
1039 i_y_offset + (int)p_fmt->i_visible_height );
1041 p_fmt->i_x_offset = i_x - i_x_offset;
1042 p_fmt->i_y_offset = i_y - i_y_offset;
1043 p_fmt->i_visible_width = i_x_end - i_x;
1044 p_fmt->i_visible_height = i_y_end - i_y;
1051 i_x_offset = __MAX( i_x_offset, 0 );
1052 i_y_offset = __MAX( i_y_offset, 0 );
1054 /* Update the output picture size */
1055 p_spu->p_blend->fmt_out.video.i_width =
1056 p_spu->p_blend->fmt_out.video.i_visible_width =
1058 p_spu->p_blend->fmt_out.video.i_height =
1059 p_spu->p_blend->fmt_out.video.i_visible_height =
1062 if( p_spu->p_blend->p_module )
1064 p_spu->p_blend->pf_video_blend( p_spu->p_blend, p_pic_dst,
1065 p_pic_src, &p_region->picture, i_x_offset, i_y_offset,
1066 i_fade_alpha * p_subpic->i_alpha * p_region->i_alpha / 65025 );
1070 msg_Err( p_spu, "blending %4.4s to %4.4s failed",
1071 (char *)&p_spu->p_blend->fmt_out.video.i_chroma,
1072 (char *)&p_spu->p_blend->fmt_out.video.i_chroma );
1076 if( b_rerender_text )
1078 /* Some forms of subtitles need to be re-rendered more than
1079 * once, eg. karaoke. We therefore restore the region to its
1080 * pre-rendered state, so the next time through everything is
1083 p_region->picture.pf_release( &p_region->picture );
1084 memset( &p_region->picture, 0, sizeof( picture_t ) );
1085 p_region->fmt = orig_fmt;
1086 p_region->i_align &= ~SUBPICTURE_RENDERED;
1088 p_region = p_region->p_next;
1091 p_subpic = p_subpic->p_next;
1094 vlc_mutex_unlock( &p_spu->subpicture_lock );
1097 /*****************************************************************************
1098 * spu_SortSubpictures: find the subpictures to display
1099 *****************************************************************************
1100 * This function parses all subpictures and decides which ones need to be
1101 * displayed. This operation does not need lock, since only READY_SUBPICTURE
1102 * are handled. If no picture has been selected, display_date will depend on
1104 * We also check for ephemer DVD subpictures (subpictures that have
1105 * to be removed if a newer one is available), which makes it a lot
1106 * more difficult to guess if a subpicture has to be rendered or not.
1107 *****************************************************************************/
1108 subpicture_t *spu_SortSubpictures( spu_t *p_spu, mtime_t display_date,
1111 int i_index, i_channel;
1112 subpicture_t *p_subpic = NULL;
1113 subpicture_t *p_ephemer;
1114 mtime_t ephemer_date;
1116 /* Run subpicture filters */
1117 for( i_index = 0; i_index < p_spu->i_filter; i_index++ )
1119 subpicture_t *p_subpic_filter;
1120 p_subpic_filter = p_spu->pp_filter[i_index]->
1121 pf_sub_filter( p_spu->pp_filter[i_index], display_date );
1122 if( p_subpic_filter )
1124 spu_DisplaySubpicture( p_spu, p_subpic_filter );
1128 /* We get an easily parsable chained list of subpictures which
1129 * ends with NULL since p_subpic was initialized to NULL. */
1130 for( i_channel = 0; i_channel < p_spu->i_channel; i_channel++ )
1135 for( i_index = 0; i_index < VOUT_MAX_SUBPICTURES; i_index++ )
1137 if( p_spu->p_subpicture[i_index].i_channel != i_channel ||
1138 p_spu->p_subpicture[i_index].i_status != READY_SUBPICTURE )
1143 display_date < p_spu->p_subpicture[i_index].i_start )
1145 /* Too early, come back next monday */
1149 if( p_spu->p_subpicture[i_index].i_start > ephemer_date )
1150 ephemer_date = p_spu->p_subpicture[i_index].i_start;
1152 if( display_date > p_spu->p_subpicture[i_index].i_stop &&
1153 ( !p_spu->p_subpicture[i_index].b_ephemer ||
1154 p_spu->p_subpicture[i_index].i_stop >
1155 p_spu->p_subpicture[i_index].i_start ) &&
1156 !( p_spu->p_subpicture[i_index].b_pausable &&
1159 /* Too late, destroy the subpic */
1160 spu_DestroySubpicture( p_spu, &p_spu->p_subpicture[i_index] );
1164 /* If this is an ephemer subpic, add it to our list */
1165 if( p_spu->p_subpicture[i_index].b_ephemer )
1167 p_spu->p_subpicture[i_index].p_next = p_ephemer;
1168 p_ephemer = &p_spu->p_subpicture[i_index];
1173 p_spu->p_subpicture[i_index].p_next = p_subpic;
1174 p_subpic = &p_spu->p_subpicture[i_index];
1177 /* If we found ephemer subpictures, check if they have to be
1178 * displayed or destroyed */
1179 while( p_ephemer != NULL )
1181 subpicture_t *p_tmp = p_ephemer;
1182 p_ephemer = p_ephemer->p_next;
1184 if( p_tmp->i_start < ephemer_date )
1186 /* Ephemer subpicture has lived too long */
1187 spu_DestroySubpicture( p_spu, p_tmp );
1191 /* Ephemer subpicture can still live a bit */
1192 p_tmp->p_next = p_subpic;
1201 /*****************************************************************************
1202 * SpuClearChannel: clear an spu channel
1203 *****************************************************************************
1204 * This function destroys the subpictures which belong to the spu channel
1205 * corresponding to i_channel_id.
1206 *****************************************************************************/
1207 static void SpuClearChannel( spu_t *p_spu, int i_channel )
1209 int i_subpic; /* subpicture index */
1210 subpicture_t *p_subpic = NULL; /* first free subpicture */
1212 vlc_mutex_lock( &p_spu->subpicture_lock );
1214 for( i_subpic = 0; i_subpic < VOUT_MAX_SUBPICTURES; i_subpic++ )
1216 p_subpic = &p_spu->p_subpicture[i_subpic];
1217 if( p_subpic->i_status == FREE_SUBPICTURE
1218 || ( p_subpic->i_status != RESERVED_SUBPICTURE
1219 && p_subpic->i_status != READY_SUBPICTURE ) )
1224 if( p_subpic->i_channel == i_channel )
1226 while( p_subpic->p_region )
1228 subpicture_region_t *p_region = p_subpic->p_region;
1229 p_subpic->p_region = p_region->p_next;
1230 spu_DestroyRegion( p_spu, p_region );
1233 if( p_subpic->pf_destroy ) p_subpic->pf_destroy( p_subpic );
1234 p_subpic->i_status = FREE_SUBPICTURE;
1238 vlc_mutex_unlock( &p_spu->subpicture_lock );
1241 /*****************************************************************************
1242 * spu_ControlDefault: default methods for the subpicture unit control.
1243 *****************************************************************************/
1244 static int spu_vaControlDefault( spu_t *p_spu, int i_query, va_list args )
1250 case SPU_CHANNEL_REGISTER:
1251 pi = (int *)va_arg( args, int * );
1252 if( pi ) *pi = p_spu->i_channel++;
1255 case SPU_CHANNEL_CLEAR:
1256 i = (int)va_arg( args, int );
1257 SpuClearChannel( p_spu, i );
1261 msg_Dbg( p_spu, "control query not supported" );
1262 return VLC_EGENERIC;
1268 /*****************************************************************************
1269 * Object variables callbacks
1270 *****************************************************************************/
1272 /*****************************************************************************
1273 * UpdateSPU: update subpicture settings
1274 *****************************************************************************
1275 * This function is called from CropCallback and at initialization time, to
1276 * retrieve crop information from the input.
1277 *****************************************************************************/
1278 static void UpdateSPU( spu_t *p_spu, vlc_object_t *p_object )
1282 p_spu->b_force_palette = false;
1283 p_spu->b_force_crop = false;
1285 if( var_Get( p_object, "highlight", &val ) || !val.b_bool ) return;
1287 p_spu->b_force_crop = true;
1288 var_Get( p_object, "x-start", &val );
1289 p_spu->i_crop_x = val.i_int;
1290 var_Get( p_object, "y-start", &val );
1291 p_spu->i_crop_y = val.i_int;
1292 var_Get( p_object, "x-end", &val );
1293 p_spu->i_crop_width = val.i_int - p_spu->i_crop_x;
1294 var_Get( p_object, "y-end", &val );
1295 p_spu->i_crop_height = val.i_int - p_spu->i_crop_y;
1297 if( var_Get( p_object, "menu-palette", &val ) == VLC_SUCCESS )
1299 memcpy( p_spu->palette, val.p_address, 16 );
1300 p_spu->b_force_palette = true;
1303 msg_Dbg( p_object, "crop: %i,%i,%i,%i, palette forced: %i",
1304 p_spu->i_crop_x, p_spu->i_crop_y,
1305 p_spu->i_crop_width, p_spu->i_crop_height,
1306 p_spu->b_force_palette );
1309 /*****************************************************************************
1310 * CropCallback: called when the highlight properties are changed
1311 *****************************************************************************
1312 * This callback is called from the input thread when we need cropping
1313 *****************************************************************************/
1314 static int CropCallback( vlc_object_t *p_object, char const *psz_var,
1315 vlc_value_t oldval, vlc_value_t newval, void *p_data )
1317 (void)psz_var; (void)oldval; (void)newval;
1318 UpdateSPU( (spu_t *)p_data, p_object );
1322 /*****************************************************************************
1323 * Buffers allocation callbacks for the filters
1324 *****************************************************************************/
1325 static subpicture_t *sub_new_buffer( filter_t *p_filter )
1327 filter_owner_sys_t *p_sys = p_filter->p_owner;
1328 subpicture_t *p_subpicture = spu_CreateSubpicture( p_sys->p_spu );
1329 if( p_subpicture ) p_subpicture->i_channel = p_sys->i_channel;
1330 return p_subpicture;
1333 static void sub_del_buffer( filter_t *p_filter, subpicture_t *p_subpic )
1335 filter_owner_sys_t *p_sys = p_filter->p_owner;
1336 spu_DestroySubpicture( p_sys->p_spu, p_subpic );
1339 static subpicture_t *spu_new_buffer( filter_t *p_filter )
1342 subpicture_t *p_subpic = (subpicture_t *)malloc(sizeof(subpicture_t));
1343 if( !p_subpic ) return NULL;
1344 memset( p_subpic, 0, sizeof(subpicture_t) );
1345 p_subpic->b_absolute = true;
1347 p_subpic->pf_create_region = __spu_CreateRegion;
1348 p_subpic->pf_make_region = __spu_MakeRegion;
1349 p_subpic->pf_destroy_region = __spu_DestroyRegion;
1354 static void spu_del_buffer( filter_t *p_filter, subpicture_t *p_subpic )
1356 while( p_subpic->p_region )
1358 subpicture_region_t *p_region = p_subpic->p_region;
1359 p_subpic->p_region = p_region->p_next;
1360 p_subpic->pf_destroy_region( VLC_OBJECT(p_filter), p_region );
1366 static picture_t *spu_new_video_buffer( filter_t *p_filter )
1368 picture_t *p_picture = malloc( sizeof(picture_t) );
1369 if( !p_picture ) return NULL;
1370 if( vout_AllocatePicture( p_filter, p_picture,
1371 p_filter->fmt_out.video.i_chroma,
1372 p_filter->fmt_out.video.i_width,
1373 p_filter->fmt_out.video.i_height,
1374 p_filter->fmt_out.video.i_aspect )
1381 p_picture->pf_release = RegionPictureRelease;
1386 static void spu_del_video_buffer( filter_t *p_filter, picture_t *p_pic )
1391 free( p_pic->p_data_orig );
1396 static int SubFilterCallback( vlc_object_t *p_object, char const *psz_var,
1397 vlc_value_t oldval, vlc_value_t newval, void *p_data )
1399 VLC_UNUSED(p_object); VLC_UNUSED(oldval);
1400 VLC_UNUSED(newval); VLC_UNUSED(psz_var);
1402 spu_t *p_spu = (spu_t *)p_data;
1403 vlc_mutex_lock( &p_spu->subpicture_lock );
1404 spu_DeleteChain( p_spu );
1405 spu_ParseChain( p_spu );
1406 vlc_mutex_unlock( &p_spu->subpicture_lock );