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>
39 /*****************************************************************************
41 *****************************************************************************/
42 static void UpdateSPU ( spu_t *, vlc_object_t * );
43 static int CropCallback( vlc_object_t *, char const *,
44 vlc_value_t, vlc_value_t, void * );
46 static int spu_vaControlDefault( spu_t *, int, va_list );
48 static subpicture_t *sub_new_buffer( filter_t * );
49 static void sub_del_buffer( filter_t *, subpicture_t * );
50 static subpicture_t *spu_new_buffer( filter_t * );
51 static void spu_del_buffer( filter_t *, subpicture_t * );
52 static picture_t *spu_new_video_buffer( filter_t * );
53 static void spu_del_video_buffer( filter_t *, picture_t * );
55 static int spu_ParseChain( spu_t * );
56 static void spu_DeleteChain( spu_t * );
57 static int SubFilterCallback( vlc_object_t *, char const *,
58 vlc_value_t, vlc_value_t, void * );
60 struct filter_owner_sys_t
72 * Creates the subpicture unit
74 * \param p_this the parent object which creates the subpicture unit
76 spu_t *__spu_Create( vlc_object_t *p_this )
79 spu_t *p_spu = vlc_object_create( p_this, VLC_OBJECT_SPU );
81 for( i_index = 0; i_index < VOUT_MAX_SUBPICTURES; i_index++)
83 p_spu->p_subpicture[i_index].i_status = FREE_SUBPICTURE;
86 p_spu->p_blend = NULL;
88 p_spu->p_scale = NULL;
90 p_spu->pf_control = spu_vaControlDefault;
92 /* Register the default subpicture channel */
95 vlc_mutex_init( p_this, &p_spu->subpicture_lock );
97 vlc_object_attach( p_spu, p_this );
103 * Initialise the subpicture unit
105 * \param p_spu the subpicture unit object
107 int spu_Init( spu_t *p_spu )
111 /* If the user requested a sub margin, we force the position. */
112 var_Create( p_spu, "sub-margin", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
113 var_Get( p_spu, "sub-margin", &val );
114 p_spu->i_margin = val.i_int;
116 var_Create( p_spu, "sub-filter", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
117 var_AddCallback( p_spu, "sub-filter", SubFilterCallback, p_spu );
119 spu_ParseChain( p_spu );
124 int spu_ParseChain( spu_t *p_spu )
128 var_Get( p_spu, "sub-filter", &val );
129 psz_parser = val.psz_string;
131 while( psz_parser && *psz_parser )
133 config_chain_t *p_cfg;
136 psz_parser = config_ChainCreate( &psz_name, &p_cfg, psz_parser );
138 msg_Dbg( p_spu, "adding sub-filter: %s", psz_name );
140 p_spu->pp_filter[p_spu->i_filter] =
141 vlc_object_create( p_spu, VLC_OBJECT_FILTER );
142 vlc_object_attach( p_spu->pp_filter[p_spu->i_filter], p_spu );
143 p_spu->pp_filter[p_spu->i_filter]->pf_sub_buffer_new = sub_new_buffer;
144 p_spu->pp_filter[p_spu->i_filter]->pf_sub_buffer_del = sub_del_buffer;
145 p_spu->pp_filter[p_spu->i_filter]->p_cfg = p_cfg;
146 p_spu->pp_filter[p_spu->i_filter]->p_module =
147 module_Need( p_spu->pp_filter[p_spu->i_filter],
148 "sub filter", psz_name, VLC_TRUE );
149 if( p_spu->pp_filter[p_spu->i_filter]->p_module )
151 filter_owner_sys_t *p_sys = malloc( sizeof(filter_owner_sys_t) );
154 p_spu->pp_filter[p_spu->i_filter]->p_owner = p_sys;
155 spu_Control( p_spu, SPU_CHANNEL_REGISTER, &p_sys->i_channel );
156 p_sys->p_spu = p_spu;
162 msg_Dbg( p_spu, "no sub filter found" );
163 config_ChainDestroy( p_spu->pp_filter[p_spu->i_filter]->p_cfg );
164 vlc_object_detach( p_spu->pp_filter[p_spu->i_filter] );
165 vlc_object_release( p_spu->pp_filter[p_spu->i_filter] );
168 if( p_spu->i_filter >= 10 )
170 msg_Dbg( p_spu, "can't add anymore filters" );
175 if( val.psz_string ) free( val.psz_string );
181 * Destroy the subpicture unit
183 * \param p_this the parent object which destroys the subpicture unit
185 void spu_Destroy( spu_t *p_spu )
189 vlc_object_detach( p_spu );
191 /* Destroy all remaining subpictures */
192 for( i_index = 0; i_index < VOUT_MAX_SUBPICTURES; i_index++ )
194 if( p_spu->p_subpicture[i_index].i_status != FREE_SUBPICTURE )
196 spu_DestroySubpicture( p_spu, &p_spu->p_subpicture[i_index] );
202 if( p_spu->p_blend->p_module )
203 module_Unneed( p_spu->p_blend, p_spu->p_blend->p_module );
205 vlc_object_detach( p_spu->p_blend );
206 vlc_object_release( p_spu->p_blend );
211 if( p_spu->p_text->p_module )
212 module_Unneed( p_spu->p_text, p_spu->p_text->p_module );
214 vlc_object_detach( p_spu->p_text );
215 vlc_object_release( p_spu->p_text );
220 if( p_spu->p_scale->p_module )
221 module_Unneed( p_spu->p_scale, p_spu->p_scale->p_module );
223 vlc_object_detach( p_spu->p_scale );
224 vlc_object_release( p_spu->p_scale );
227 spu_DeleteChain( p_spu );
229 vlc_mutex_destroy( &p_spu->subpicture_lock );
230 vlc_object_release( p_spu );
233 static void spu_DeleteChain( spu_t *p_spu )
235 if( p_spu->i_filter )
236 while( p_spu->i_filter )
239 module_Unneed( p_spu->pp_filter[p_spu->i_filter],
240 p_spu->pp_filter[p_spu->i_filter]->p_module );
241 free( p_spu->pp_filter[p_spu->i_filter]->p_owner );
242 config_ChainDestroy( p_spu->pp_filter[p_spu->i_filter]->p_cfg );
243 vlc_object_detach( p_spu->pp_filter[p_spu->i_filter] );
244 vlc_object_release( p_spu->pp_filter[p_spu->i_filter] );
249 * Attach/Detach the SPU from any input
251 * \param p_this the object in which to destroy the subpicture unit
252 * \param b_attach to select attach or detach
254 void spu_Attach( spu_t *p_spu, vlc_object_t *p_this, vlc_bool_t b_attach )
256 vlc_object_t *p_input;
258 p_input = vlc_object_find( p_this, VLC_OBJECT_INPUT, FIND_PARENT );
259 if( !p_input ) return;
263 UpdateSPU( p_spu, VLC_OBJECT(p_input) );
264 var_AddCallback( p_input, "highlight", CropCallback, p_spu );
265 vlc_object_release( p_input );
269 /* Delete callback */
270 var_DelCallback( p_input, "highlight", CropCallback, p_spu );
271 vlc_object_release( p_input );
276 * Create a subpicture region
278 * \param p_this vlc_object_t
279 * \param p_fmt the format that this subpicture region should have
281 static void RegionPictureRelease( picture_t *p_pic )
283 if( p_pic->p_data_orig ) free( p_pic->p_data_orig );
285 subpicture_region_t *__spu_CreateRegion( vlc_object_t *p_this,
286 video_format_t *p_fmt )
288 subpicture_region_t *p_region = malloc( sizeof(subpicture_region_t) );
289 if( !p_region ) return NULL;
291 memset( p_region, 0, sizeof(subpicture_region_t) );
292 p_region->p_next = NULL;
293 p_region->p_cache = NULL;
294 p_region->fmt = *p_fmt;
295 p_region->psz_text = NULL;
296 p_region->p_style = NULL;
298 if( p_fmt->i_chroma == VLC_FOURCC('Y','U','V','P') )
299 p_fmt->p_palette = p_region->fmt.p_palette =
300 malloc( sizeof(video_palette_t) );
301 else p_fmt->p_palette = p_region->fmt.p_palette = NULL;
303 p_region->picture.p_data_orig = NULL;
305 if( p_fmt->i_chroma == VLC_FOURCC('T','E','X','T') ) return p_region;
307 vout_AllocatePicture( p_this, &p_region->picture, p_fmt->i_chroma,
308 p_fmt->i_width, p_fmt->i_height, p_fmt->i_aspect );
310 if( !p_region->picture.i_planes )
313 if( p_fmt->p_palette ) free( p_fmt->p_palette );
317 p_region->picture.pf_release = RegionPictureRelease;
323 * Make a subpicture region from an existing picture_t
325 * \param p_this vlc_object_t
326 * \param p_fmt the format that this subpicture region should have
327 * \param p_pic a pointer to the picture creating the region (not freed)
329 subpicture_region_t *__spu_MakeRegion( vlc_object_t *p_this,
330 video_format_t *p_fmt,
333 subpicture_region_t *p_region = malloc( sizeof(subpicture_region_t) );
335 if( !p_region ) return NULL;
336 memset( p_region, 0, sizeof(subpicture_region_t) );
337 p_region->p_next = 0;
338 p_region->p_cache = 0;
339 p_region->fmt = *p_fmt;
340 p_region->psz_text = 0;
341 p_region->p_style = NULL;
343 if( p_fmt->i_chroma == VLC_FOURCC('Y','U','V','P') )
344 p_fmt->p_palette = p_region->fmt.p_palette =
345 malloc( sizeof(video_palette_t) );
346 else p_fmt->p_palette = p_region->fmt.p_palette = NULL;
348 memcpy( &p_region->picture, p_pic, sizeof(picture_t) );
349 p_region->picture.pf_release = RegionPictureRelease;
355 * Destroy a subpicture region
357 * \param p_this vlc_object_t
358 * \param p_region the subpicture region to destroy
360 void __spu_DestroyRegion( vlc_object_t *p_this, subpicture_region_t *p_region )
362 if( !p_region ) return;
363 if( p_region->picture.pf_release )
364 p_region->picture.pf_release( &p_region->picture );
365 if( p_region->fmt.p_palette ) free( p_region->fmt.p_palette );
366 if( p_region->p_cache ) __spu_DestroyRegion( p_this, p_region->p_cache );
368 if( p_region->psz_text )
369 free( p_region->psz_text );
370 if( p_region->psz_html )
371 free( p_region->psz_html );
372 //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
377 * Display a subpicture
379 * Remove the reservation flag of a subpicture, which will cause it to be
381 * \param p_spu the subpicture unit object
382 * \param p_subpic the subpicture to display
384 void spu_DisplaySubpicture( spu_t *p_spu, subpicture_t *p_subpic )
386 /* Check if status is valid */
387 if( p_subpic->i_status != RESERVED_SUBPICTURE )
389 msg_Err( p_spu, "subpicture %p has invalid status #%d",
390 p_subpic, p_subpic->i_status );
393 /* Remove reservation flag */
394 p_subpic->i_status = READY_SUBPICTURE;
396 if( p_subpic->i_channel == DEFAULT_CHAN )
398 p_subpic->i_channel = 0xFFFF;
399 spu_Control( p_spu, SPU_CHANNEL_CLEAR, DEFAULT_CHAN );
400 p_subpic->i_channel = DEFAULT_CHAN;
405 * Allocate a subpicture in the spu heap.
407 * This function create a reserved subpicture in the spu heap.
408 * A null pointer is returned if the function fails. This method provides an
409 * already allocated zone of memory in the spu data fields. It needs locking
410 * since several pictures can be created by several producers threads.
411 * \param p_spu the subpicture unit in which to create the subpicture
412 * \return NULL on error, a reserved subpicture otherwise
414 subpicture_t *spu_CreateSubpicture( spu_t *p_spu )
416 int i_subpic; /* subpicture index */
417 subpicture_t * p_subpic = NULL; /* first free subpicture */
420 vlc_mutex_lock( &p_spu->subpicture_lock );
423 * Look for an empty place
426 for( i_subpic = 0; i_subpic < VOUT_MAX_SUBPICTURES; i_subpic++ )
428 if( p_spu->p_subpicture[i_subpic].i_status == FREE_SUBPICTURE )
430 /* Subpicture is empty and ready for allocation */
431 p_subpic = &p_spu->p_subpicture[i_subpic];
432 p_spu->p_subpicture[i_subpic].i_status = RESERVED_SUBPICTURE;
437 /* If no free subpicture could be found */
438 if( p_subpic == NULL )
440 msg_Err( p_spu, "subpicture heap is full" );
441 vlc_mutex_unlock( &p_spu->subpicture_lock );
445 /* Copy subpicture information, set some default values */
446 memset( p_subpic, 0, sizeof(subpicture_t) );
447 p_subpic->i_status = RESERVED_SUBPICTURE;
448 p_subpic->b_absolute = VLC_TRUE;
449 p_subpic->b_pausable = VLC_FALSE;
450 p_subpic->b_fade = VLC_FALSE;
451 p_subpic->i_alpha = 0xFF;
452 p_subpic->p_region = NULL;
453 p_subpic->pf_render = NULL;
454 p_subpic->pf_destroy = NULL;
455 p_subpic->p_sys = NULL;
456 vlc_mutex_unlock( &p_spu->subpicture_lock );
458 p_subpic->pf_create_region = __spu_CreateRegion;
459 p_subpic->pf_make_region = __spu_MakeRegion;
460 p_subpic->pf_destroy_region = __spu_DestroyRegion;
466 * Remove a subpicture from the heap
468 * This function frees a previously reserved subpicture.
469 * It is meant to be used when the construction of a picture aborted.
470 * This function does not need locking since reserved subpictures are ignored
473 void spu_DestroySubpicture( spu_t *p_spu, subpicture_t *p_subpic )
476 vlc_mutex_lock( &p_spu->subpicture_lock );
478 /* There can be race conditions so we need to check the status */
479 if( p_subpic->i_status == FREE_SUBPICTURE )
481 vlc_mutex_unlock( &p_spu->subpicture_lock );
485 /* Check if status is valid */
486 if( ( p_subpic->i_status != RESERVED_SUBPICTURE )
487 && ( p_subpic->i_status != READY_SUBPICTURE ) )
489 msg_Err( p_spu, "subpicture %p has invalid status %d",
490 p_subpic, p_subpic->i_status );
493 while( p_subpic->p_region )
495 subpicture_region_t *p_region = p_subpic->p_region;
496 p_subpic->p_region = p_region->p_next;
497 spu_DestroyRegion( p_spu, p_region );
500 if( p_subpic->pf_destroy )
502 p_subpic->pf_destroy( p_subpic );
505 p_subpic->i_status = FREE_SUBPICTURE;
507 vlc_mutex_unlock( &p_spu->subpicture_lock );
510 /*****************************************************************************
511 * spu_RenderSubpictures: render a subpicture list
512 *****************************************************************************
513 * This function renders all sub picture units in the list.
514 *****************************************************************************/
515 void spu_RenderSubpictures( spu_t *p_spu, video_format_t *p_fmt,
516 picture_t *p_pic_dst, picture_t *p_pic_src,
517 subpicture_t *p_subpic,
518 int i_scale_width_orig, int i_scale_height_orig )
520 int i_source_video_width;
521 int i_source_video_height;
522 subpicture_t *p_subpic_v = p_subpic;
525 vlc_mutex_lock( &p_spu->subpicture_lock );
527 for( p_subpic_v = p_subpic;
528 p_subpic_v != NULL && p_subpic_v->i_status != FREE_SUBPICTURE;
529 p_subpic_v = p_subpic_v->p_next )
531 if( p_subpic_v->pf_pre_render )
533 p_subpic_v->pf_pre_render( p_fmt, p_spu, p_subpic_v, mdate() );
537 if( i_scale_width_orig <= 0 )
538 i_scale_width_orig = 1;
539 if( i_scale_height_orig <= 0 )
540 i_scale_height_orig = 1;
542 i_source_video_width = p_fmt->i_width * 1000 / i_scale_width_orig;
543 i_source_video_height = p_fmt->i_height * 1000 / i_scale_height_orig;
545 /* Check i_status again to make sure spudec hasn't destroyed the subpic */
546 while( ( p_subpic != NULL ) && ( p_subpic->i_status != FREE_SUBPICTURE ) )
548 subpicture_region_t *p_region;
549 int pi_scale_width[ SCALE_SIZE ];
550 int pi_scale_height[ SCALE_SIZE ];
551 int pi_subpic_x[ SCALE_SIZE ];
554 /* If the source video and subtitles stream agree on the size of
555 * the video then disregard all further references to the subtitle
558 if( ( i_source_video_height == p_subpic->i_original_picture_height ) &&
559 ( i_source_video_width == p_subpic->i_original_picture_width ) )
561 p_subpic->i_original_picture_height = 0;
562 p_subpic->i_original_picture_width = 0;
565 for( k = 0; k < SCALE_SIZE ; k++ )
566 pi_subpic_x[ k ] = p_subpic->i_x;
568 if( p_subpic->pf_update_regions )
570 if ( p_subpic->p_region ) {
571 spu_DestroyRegion( p_spu, p_subpic->p_region );
573 p_subpic->p_region = p_region = p_subpic->pf_update_regions( p_fmt, p_spu, p_subpic, mdate() );
577 p_region = p_subpic->p_region;
580 /* Load the blending module */
581 if( !p_spu->p_blend && p_region )
583 p_spu->p_blend = vlc_object_create( p_spu, VLC_OBJECT_FILTER );
584 vlc_object_attach( p_spu->p_blend, p_spu );
585 p_spu->p_blend->fmt_out.video.i_x_offset =
586 p_spu->p_blend->fmt_out.video.i_y_offset = 0;
587 p_spu->p_blend->fmt_out.video.i_aspect = p_fmt->i_aspect;
588 p_spu->p_blend->fmt_out.video.i_chroma = p_fmt->i_chroma;
590 /* The blend module will be loaded when needed with the real
592 memset( &p_spu->p_blend->fmt_in, 0, sizeof(p_spu->p_blend->fmt_in) );
593 p_spu->p_blend->p_module = NULL;
596 /* Load the text rendering module; it is possible there is a
597 * text region somewhere in the subpicture other than the first
598 * element in the region list, so just load it anyway as we'll
599 * probably want it sooner or later. */
600 if( !p_spu->p_text && p_region )
602 char *psz_modulename = NULL;
604 p_spu->p_text = vlc_object_create( p_spu, VLC_OBJECT_FILTER );
605 vlc_object_attach( p_spu->p_text, p_spu );
607 p_spu->p_text->fmt_out.video.i_width =
608 p_spu->p_text->fmt_out.video.i_visible_width =
610 p_spu->p_text->fmt_out.video.i_height =
611 p_spu->p_text->fmt_out.video.i_visible_height =
614 p_spu->p_text->pf_sub_buffer_new = spu_new_buffer;
615 p_spu->p_text->pf_sub_buffer_del = spu_del_buffer;
617 psz_modulename = var_CreateGetString( p_spu, "text-renderer" );
618 if( psz_modulename && *psz_modulename )
620 p_spu->p_text->p_module =
621 module_Need( p_spu->p_text, "text renderer",
622 psz_modulename, VLC_TRUE );
624 if( !p_spu->p_text->p_module )
626 p_spu->p_text->p_module =
627 module_Need( p_spu->p_text, "text renderer", 0, 0 );
629 if( psz_modulename ) free( psz_modulename );
634 subpicture_region_t *p_text_region = p_subpic->p_region;
636 /* Only overwrite the size fields if the region is still in
637 * pre-rendered TEXT format. We have to traverse the subregion
638 * list because if more than one subregion is present, the text
639 * region isn't guarentteed to be the first in the list, and
640 * only text regions use this flag. All of this effort assists
641 * with the rescaling of text that has been rendered at native
642 * resolution, rather than video resolution.
644 while( p_text_region &&
645 ( p_text_region->fmt.i_chroma != VLC_FOURCC('T','E','X','T') ) )
647 p_text_region = p_text_region->p_next;
651 ( ( p_text_region->i_align & SUBPICTURE_RENDERED ) == 0 ) )
653 if( (p_subpic->i_original_picture_height > 0) &&
654 (p_subpic->i_original_picture_width > 0) )
656 p_spu->p_text->fmt_out.video.i_width =
657 p_spu->p_text->fmt_out.video.i_visible_width =
658 p_subpic->i_original_picture_width;
659 p_spu->p_text->fmt_out.video.i_height =
660 p_spu->p_text->fmt_out.video.i_visible_height =
661 p_subpic->i_original_picture_height;
665 p_spu->p_text->fmt_out.video.i_width =
666 p_spu->p_text->fmt_out.video.i_visible_width =
668 p_spu->p_text->fmt_out.video.i_height =
669 p_spu->p_text->fmt_out.video.i_visible_height =
675 pi_scale_width[ SCALE_DEFAULT ] = i_scale_width_orig;
676 pi_scale_height[ SCALE_DEFAULT ] = i_scale_height_orig;
680 pi_scale_width[ SCALE_TEXT ] = ( p_fmt->i_width * 1000 ) /
681 p_spu->p_text->fmt_out.video.i_width;
682 pi_scale_height[ SCALE_TEXT ] = ( p_fmt->i_height * 1000 ) /
683 p_spu->p_text->fmt_out.video.i_height;
685 /* If we have an explicit size plane to render to, then turn off
686 * the fontsize rescaling.
688 if( (p_subpic->i_original_picture_height > 0) &&
689 (p_subpic->i_original_picture_width > 0) )
691 i_scale_width_orig = 1000;
692 i_scale_height_orig = 1000;
695 for( k = 0; k < SCALE_SIZE ; k++ )
697 /* Case of both width and height being specified has been dealt
698 * with above by instead rendering to an output pane of the
699 * explicit dimensions specified - we don't need to scale it.
701 if( (p_subpic->i_original_picture_height > 0) &&
702 (p_subpic->i_original_picture_width <= 0) )
704 pi_scale_height[ k ] = pi_scale_height[ k ] * i_source_video_height /
705 p_subpic->i_original_picture_height;
706 pi_scale_width[ k ] = pi_scale_width[ k ] * i_source_video_height /
707 p_subpic->i_original_picture_height;
711 /* Set default subpicture aspect ratio */
712 if( p_region && p_region->fmt.i_aspect &&
713 ( !p_region->fmt.i_sar_num || !p_region->fmt.i_sar_den ) )
715 p_region->fmt.i_sar_den = p_region->fmt.i_aspect;
716 p_region->fmt.i_sar_num = VOUT_ASPECT_FACTOR;
719 ( !p_region->fmt.i_sar_num || !p_region->fmt.i_sar_den ) )
721 p_region->fmt.i_sar_den = p_fmt->i_sar_den;
722 p_region->fmt.i_sar_num = p_fmt->i_sar_num;
725 /* Take care of the aspect ratio */
727 ( ( p_region->fmt.i_sar_num * p_fmt->i_sar_den ) !=
728 ( p_region->fmt.i_sar_den * p_fmt->i_sar_num ) ) )
730 for( k = 0; k < SCALE_SIZE ; k++ )
732 pi_scale_width[ k ] = pi_scale_width[ k ] *
733 (int64_t)p_region->fmt.i_sar_num * p_fmt->i_sar_den /
734 p_region->fmt.i_sar_den / p_fmt->i_sar_num;
735 pi_subpic_x[ k ] = p_subpic->i_x * pi_scale_width[ k ] / 1000;
739 /* Load the scaling module */
740 if( !p_spu->p_scale &&
741 ((((pi_scale_width[ SCALE_TEXT ] > 0) || (pi_scale_height[ SCALE_TEXT ] > 0)) &&
742 ((pi_scale_width[ SCALE_TEXT ] != 1000) || (pi_scale_height[ SCALE_TEXT ] != 1000))) ||
743 (((pi_scale_width[ SCALE_DEFAULT ] > 0) || (pi_scale_height[ SCALE_DEFAULT ] > 0)) &&
744 ((pi_scale_width[ SCALE_DEFAULT ] != 1000) || (pi_scale_height[ SCALE_DEFAULT ] != 1000)))) )
746 p_spu->p_scale = vlc_object_create( p_spu, VLC_OBJECT_FILTER );
747 vlc_object_attach( p_spu->p_scale, p_spu );
748 p_spu->p_scale->fmt_out.video.i_chroma =
749 p_spu->p_scale->fmt_in.video.i_chroma =
750 VLC_FOURCC('Y','U','V','P');
751 /* FIXME: We'll also be using it for YUVA and RGBA blending ... */
753 p_spu->p_scale->fmt_in.video.i_width =
754 p_spu->p_scale->fmt_in.video.i_height = 32;
755 p_spu->p_scale->fmt_out.video.i_width =
756 p_spu->p_scale->fmt_out.video.i_height = 16;
758 p_spu->p_scale->pf_vout_buffer_new = spu_new_video_buffer;
759 p_spu->p_scale->pf_vout_buffer_del = spu_del_video_buffer;
760 p_spu->p_scale->p_module =
761 module_Need( p_spu->p_scale, "video filter2", 0, 0 );
766 video_format_t orig_fmt = p_region->fmt;
767 vlc_bool_t b_rerender_text = VLC_FALSE;
768 int i_fade_alpha = 255;
771 int i_scale_idx = SCALE_DEFAULT;
772 int i_inv_scale_x = 1000;
773 int i_inv_scale_y = 1000;
775 if( p_region->fmt.i_chroma == VLC_FOURCC('T','E','X','T') )
777 if( p_spu->p_text && p_spu->p_text->p_module )
781 /* Setup 3 variables which can be used to render
782 * time-dependent text (and effects). The first indicates
783 * the total amount of time the text will be on screen,
784 * the second the amount of time it has already been on
785 * screen (can be a negative value as text is layed out
786 * before it is rendered) and the third is a feedback
787 * variable from the renderer - if the renderer sets it
788 * then this particular text is time-dependent, eg. the
789 * visual progress bar inside the text in karaoke and the
790 * text needs to be rendered multiple times in order for
791 * the effect to work - we therefore need to return the
792 * region to its original state at the end of the loop,
793 * instead of leaving it in YUVA or YUVP.
794 * Any renderer which is unaware of how to render
795 * time-dependent text can happily ignore the variables
796 * and render the text the same as usual - it should at
797 * least show up on screen, but the effect won't change
798 * the text over time.
801 var_Create( p_spu->p_text, "spu-duration", VLC_VAR_TIME );
802 val.i_time = p_subpic->i_stop - p_subpic->i_start;
803 var_Set( p_spu->p_text, "spu-duration", val );
805 var_Create( p_spu->p_text, "spu-elapsed", VLC_VAR_TIME );
806 val.i_time = mdate() - p_subpic->i_start;
807 var_Set( p_spu->p_text, "spu-elapsed", val );
809 var_Create( p_spu->p_text, "text-rerender", VLC_VAR_BOOL );
810 var_SetBool( p_spu->p_text, "text-rerender", VLC_FALSE );
812 var_Create( p_spu->p_text, "scale", VLC_VAR_INTEGER );
813 var_SetInteger( p_spu->p_text, "scale",
814 __MIN(i_scale_width_orig, i_scale_height_orig) );
816 if( p_spu->p_text->pf_render_html && p_region->psz_html )
818 p_spu->p_text->pf_render_html( p_spu->p_text,
819 p_region, p_region );
821 else if( p_spu->p_text->pf_render_text )
823 p_spu->p_text->pf_render_text( p_spu->p_text,
824 p_region, p_region );
826 b_rerender_text = var_GetBool( p_spu->p_text, "text-rerender" );
828 var_Destroy( p_spu->p_text, "spu-duration" );
829 var_Destroy( p_spu->p_text, "spu-elapsed" );
830 var_Destroy( p_spu->p_text, "text-rerender" );
831 var_Destroy( p_spu->p_text, "scale" );
833 p_region->i_align |= SUBPICTURE_RENDERED;
836 if( p_region->i_align & SUBPICTURE_RENDERED )
838 i_scale_idx = SCALE_TEXT;
839 i_inv_scale_x = i_scale_width_orig;
840 i_inv_scale_y = i_scale_height_orig;
843 i_x_offset = (p_region->i_x + pi_subpic_x[ i_scale_idx ]) * i_inv_scale_x / 1000;
844 i_y_offset = (p_region->i_y + p_subpic->i_y) * i_inv_scale_y / 1000;
846 /* Force palette if requested */
847 if( p_spu->b_force_palette &&
848 ( VLC_FOURCC('Y','U','V','P') == p_region->fmt.i_chroma ) )
850 memcpy( p_region->fmt.p_palette->palette,
851 p_spu->palette, 16 );
854 /* Scale SPU if necessary */
855 if( p_region->p_cache &&
856 ( p_region->fmt.i_chroma != VLC_FOURCC('T','E','X','T') ) )
858 if( pi_scale_width[ i_scale_idx ] * p_region->fmt.i_width / 1000 !=
859 p_region->p_cache->fmt.i_width ||
860 pi_scale_height[ i_scale_idx ] * p_region->fmt.i_height / 1000 !=
861 p_region->p_cache->fmt.i_height )
863 p_subpic->pf_destroy_region( VLC_OBJECT(p_spu),
865 p_region->p_cache = 0;
869 if( ( ( pi_scale_width[ i_scale_idx ] != 1000 ) ||
870 ( pi_scale_height[ i_scale_idx ] != 1000 ) ) &&
871 ( ( pi_scale_width[ i_scale_idx ] > 0 ) ||
872 ( pi_scale_height[ i_scale_idx ] > 0 ) ) &&
873 p_spu->p_scale && !p_region->p_cache &&
874 ( p_region->fmt.i_chroma != VLC_FOURCC('T','E','X','T') ) )
878 p_spu->p_scale->fmt_in.video = p_region->fmt;
879 p_spu->p_scale->fmt_out.video = p_region->fmt;
882 p_subpic->pf_create_region( VLC_OBJECT(p_spu),
883 &p_spu->p_scale->fmt_out.video );
884 if( p_spu->p_scale->fmt_out.video.p_palette )
885 *p_spu->p_scale->fmt_out.video.p_palette =
886 *p_region->fmt.p_palette;
887 p_region->p_cache->p_next = p_region->p_next;
889 vout_CopyPicture( p_spu, &p_region->p_cache->picture,
890 &p_region->picture );
892 p_spu->p_scale->fmt_out.video.i_width =
893 p_region->fmt.i_width * pi_scale_width[ i_scale_idx ] / 1000;
894 p_spu->p_scale->fmt_out.video.i_visible_width =
895 p_region->fmt.i_visible_width * pi_scale_width[ i_scale_idx ] / 1000;
896 p_spu->p_scale->fmt_out.video.i_height =
897 p_region->fmt.i_height * pi_scale_height[ i_scale_idx ] / 1000;
898 p_spu->p_scale->fmt_out.video.i_visible_height =
899 p_region->fmt.i_visible_height * pi_scale_height[ i_scale_idx ] / 1000;
900 p_region->p_cache->fmt = p_spu->p_scale->fmt_out.video;
901 p_region->p_cache->i_x = p_region->i_x * pi_scale_width[ i_scale_idx ] / 1000;
902 p_region->p_cache->i_y = p_region->i_y * pi_scale_height[ i_scale_idx ] / 1000;
903 p_region->p_cache->i_align = p_region->i_align;
905 p_pic = p_spu->p_scale->pf_video_filter(
906 p_spu->p_scale, &p_region->p_cache->picture );
909 picture_t p_pic_tmp = p_region->p_cache->picture;
910 p_region->p_cache->picture = *p_pic;
916 if( ( ( pi_scale_width[ i_scale_idx ] != 1000 ) ||
917 ( pi_scale_height[ i_scale_idx ] != 1000 ) ) &&
918 ( ( pi_scale_width[ i_scale_idx ] > 0 ) ||
919 ( pi_scale_height[ i_scale_idx ] > 0 ) ) &&
920 p_spu->p_scale && p_region->p_cache &&
921 ( p_region->fmt.i_chroma != VLC_FOURCC('T','E','X','T') ) )
923 p_region = p_region->p_cache;
926 if( p_region->i_align & SUBPICTURE_ALIGN_BOTTOM )
928 i_y_offset = p_fmt->i_height - p_region->fmt.i_height -
929 (p_subpic->i_y + p_region->i_y) * i_inv_scale_y / 1000;
931 else if ( !(p_region->i_align & SUBPICTURE_ALIGN_TOP) )
933 i_y_offset = p_fmt->i_height / 2 - p_region->fmt.i_height / 2;
936 if( p_region->i_align & SUBPICTURE_ALIGN_RIGHT )
938 i_x_offset = p_fmt->i_width - p_region->fmt.i_width -
939 (pi_subpic_x[ i_scale_idx ] + p_region->i_x)
940 * i_inv_scale_x / 1000;
942 else if ( !(p_region->i_align & SUBPICTURE_ALIGN_LEFT) )
944 i_x_offset = p_fmt->i_width / 2 - p_region->fmt.i_width / 2;
947 if( p_subpic->b_absolute )
949 i_x_offset = (p_region->i_x +
950 pi_subpic_x[ i_scale_idx ] *
951 pi_scale_width[ i_scale_idx ] / 1000)
952 * i_inv_scale_x / 1000;
953 i_y_offset = (p_region->i_y +
954 p_subpic->i_y * pi_scale_height[ i_scale_idx ] / 1000)
955 * i_inv_scale_y / 1000;
959 i_x_offset = __MAX( i_x_offset, 0 );
960 i_y_offset = __MAX( i_y_offset, 0 );
962 if( ( p_spu->i_margin != 0 ) &&
963 ( p_spu->b_force_crop == VLC_FALSE ) )
966 int i_low = (i_y_offset - p_spu->i_margin) * i_inv_scale_y / 1000;
967 int i_high = i_low + p_region->fmt.i_height;
969 /* crop extra margin to keep within bounds */
972 if( i_high > (int)p_fmt->i_height )
973 i_diff = i_high - p_fmt->i_height;
974 i_y_offset -= ( p_spu->i_margin * i_inv_scale_y / 1000 + i_diff );
977 if( p_subpic->b_fade )
979 mtime_t i_fade_start = ( p_subpic->i_stop +
980 p_subpic->i_start ) / 2;
981 mtime_t i_now = mdate();
982 if( i_now >= i_fade_start && p_subpic->i_stop > i_fade_start )
984 i_fade_alpha = 255 * ( p_subpic->i_stop - i_now ) /
985 ( p_subpic->i_stop - i_fade_start );
989 if( p_region->fmt.i_chroma != VLC_FOURCC('T','E','X','T') )
991 if( p_spu->p_blend->fmt_in.video.i_chroma != p_region->fmt.i_chroma )
993 /* The chroma is not the same, we need to reload the blend module
994 * XXX to match the old behaviour just test !p_spu->p_blend->fmt_in.video.i_chroma */
995 if( p_spu->p_blend->p_module )
996 module_Unneed( p_spu->p_blend, p_spu->p_blend->p_module );
998 p_spu->p_blend->fmt_in.video = p_region->fmt;
999 p_spu->p_blend->p_module = module_Need( p_spu->p_blend, "video blending", 0, 0 );
1003 p_spu->p_blend->fmt_in.video = p_region->fmt;
1006 /* Force cropping if requested */
1007 if( p_spu->b_force_crop )
1009 video_format_t *p_fmt = &p_spu->p_blend->fmt_in.video;
1010 int i_crop_x = p_spu->i_crop_x * pi_scale_width[ i_scale_idx ] / 1000
1011 * i_inv_scale_x / 1000;
1012 int i_crop_y = p_spu->i_crop_y * pi_scale_height[ i_scale_idx ] / 1000
1013 * i_inv_scale_y / 1000;
1014 int i_crop_width = p_spu->i_crop_width * pi_scale_width[ i_scale_idx ] / 1000
1015 * i_inv_scale_x / 1000;
1016 int i_crop_height = p_spu->i_crop_height * pi_scale_height[ i_scale_idx ] / 1000
1017 * i_inv_scale_y / 1000;
1019 /* Find the intersection */
1020 if( i_crop_x + i_crop_width <= i_x_offset ||
1021 i_x_offset + (int)p_fmt->i_visible_width < i_crop_x ||
1022 i_crop_y + i_crop_height <= i_y_offset ||
1023 i_y_offset + (int)p_fmt->i_visible_height < i_crop_y )
1025 /* No intersection */
1026 p_fmt->i_visible_width = p_fmt->i_visible_height = 0;
1030 int i_x, i_y, i_x_end, i_y_end;
1031 i_x = __MAX( i_crop_x, i_x_offset );
1032 i_y = __MAX( i_crop_y, i_y_offset );
1033 i_x_end = __MIN( i_crop_x + i_crop_width,
1034 i_x_offset + (int)p_fmt->i_visible_width );
1035 i_y_end = __MIN( i_crop_y + i_crop_height,
1036 i_y_offset + (int)p_fmt->i_visible_height );
1038 p_fmt->i_x_offset = i_x - i_x_offset;
1039 p_fmt->i_y_offset = i_y - i_y_offset;
1040 p_fmt->i_visible_width = i_x_end - i_x;
1041 p_fmt->i_visible_height = i_y_end - i_y;
1048 i_x_offset = __MAX( i_x_offset, 0 );
1049 i_y_offset = __MAX( i_y_offset, 0 );
1051 /* Update the output picture size */
1052 p_spu->p_blend->fmt_out.video.i_width =
1053 p_spu->p_blend->fmt_out.video.i_visible_width =
1055 p_spu->p_blend->fmt_out.video.i_height =
1056 p_spu->p_blend->fmt_out.video.i_visible_height =
1059 if( p_spu->p_blend->p_module )
1061 p_spu->p_blend->pf_video_blend( p_spu->p_blend, p_pic_dst,
1062 p_pic_src, &p_region->picture, i_x_offset, i_y_offset,
1063 i_fade_alpha * p_subpic->i_alpha / 255 );
1067 msg_Err( p_spu, "blending %4.4s to %4.4s failed",
1068 (char *)&p_spu->p_blend->fmt_out.video.i_chroma,
1069 (char *)&p_spu->p_blend->fmt_out.video.i_chroma );
1073 if( b_rerender_text )
1075 /* Some forms of subtitles need to be re-rendered more than
1076 * once, eg. karaoke. We therefore restore the region to its
1077 * pre-rendered state, so the next time through everything is
1080 p_region->picture.pf_release( &p_region->picture );
1081 memset( &p_region->picture, 0, sizeof( picture_t ) );
1082 p_region->fmt = orig_fmt;
1083 p_region->i_align &= ~SUBPICTURE_RENDERED;
1085 p_region = p_region->p_next;
1088 p_subpic = p_subpic->p_next;
1091 vlc_mutex_unlock( &p_spu->subpicture_lock );
1094 /*****************************************************************************
1095 * spu_SortSubpictures: find the subpictures to display
1096 *****************************************************************************
1097 * This function parses all subpictures and decides which ones need to be
1098 * displayed. This operation does not need lock, since only READY_SUBPICTURE
1099 * are handled. If no picture has been selected, display_date will depend on
1101 * We also check for ephemer DVD subpictures (subpictures that have
1102 * to be removed if a newer one is available), which makes it a lot
1103 * more difficult to guess if a subpicture has to be rendered or not.
1104 *****************************************************************************/
1105 subpicture_t *spu_SortSubpictures( spu_t *p_spu, mtime_t display_date,
1106 vlc_bool_t b_paused )
1108 int i_index, i_channel;
1109 subpicture_t *p_subpic = NULL;
1110 subpicture_t *p_ephemer;
1111 mtime_t ephemer_date;
1113 /* Run subpicture filters */
1114 for( i_index = 0; i_index < p_spu->i_filter; i_index++ )
1116 subpicture_t *p_subpic_filter;
1117 p_subpic_filter = p_spu->pp_filter[i_index]->
1118 pf_sub_filter( p_spu->pp_filter[i_index], display_date );
1119 if( p_subpic_filter )
1121 spu_DisplaySubpicture( p_spu, p_subpic_filter );
1125 /* We get an easily parsable chained list of subpictures which
1126 * ends with NULL since p_subpic was initialized to NULL. */
1127 for( i_channel = 0; i_channel < p_spu->i_channel; i_channel++ )
1132 for( i_index = 0; i_index < VOUT_MAX_SUBPICTURES; i_index++ )
1134 if( p_spu->p_subpicture[i_index].i_channel != i_channel ||
1135 p_spu->p_subpicture[i_index].i_status != READY_SUBPICTURE )
1140 display_date < p_spu->p_subpicture[i_index].i_start )
1142 /* Too early, come back next monday */
1146 if( p_spu->p_subpicture[i_index].i_start > ephemer_date )
1147 ephemer_date = p_spu->p_subpicture[i_index].i_start;
1149 if( display_date > p_spu->p_subpicture[i_index].i_stop &&
1150 ( !p_spu->p_subpicture[i_index].b_ephemer ||
1151 p_spu->p_subpicture[i_index].i_stop >
1152 p_spu->p_subpicture[i_index].i_start ) &&
1153 !( p_spu->p_subpicture[i_index].b_pausable &&
1156 /* Too late, destroy the subpic */
1157 spu_DestroySubpicture( p_spu, &p_spu->p_subpicture[i_index] );
1161 /* If this is an ephemer subpic, add it to our list */
1162 if( p_spu->p_subpicture[i_index].b_ephemer )
1164 p_spu->p_subpicture[i_index].p_next = p_ephemer;
1165 p_ephemer = &p_spu->p_subpicture[i_index];
1170 p_spu->p_subpicture[i_index].p_next = p_subpic;
1171 p_subpic = &p_spu->p_subpicture[i_index];
1174 /* If we found ephemer subpictures, check if they have to be
1175 * displayed or destroyed */
1176 while( p_ephemer != NULL )
1178 subpicture_t *p_tmp = p_ephemer;
1179 p_ephemer = p_ephemer->p_next;
1181 if( p_tmp->i_start < ephemer_date )
1183 /* Ephemer subpicture has lived too long */
1184 spu_DestroySubpicture( p_spu, p_tmp );
1188 /* Ephemer subpicture can still live a bit */
1189 p_tmp->p_next = p_subpic;
1198 /*****************************************************************************
1199 * SpuClearChannel: clear an spu channel
1200 *****************************************************************************
1201 * This function destroys the subpictures which belong to the spu channel
1202 * corresponding to i_channel_id.
1203 *****************************************************************************/
1204 static void SpuClearChannel( spu_t *p_spu, int i_channel )
1206 int i_subpic; /* subpicture index */
1207 subpicture_t *p_subpic = NULL; /* first free subpicture */
1209 vlc_mutex_lock( &p_spu->subpicture_lock );
1211 for( i_subpic = 0; i_subpic < VOUT_MAX_SUBPICTURES; i_subpic++ )
1213 p_subpic = &p_spu->p_subpicture[i_subpic];
1214 if( p_subpic->i_status == FREE_SUBPICTURE
1215 || ( p_subpic->i_status != RESERVED_SUBPICTURE
1216 && p_subpic->i_status != READY_SUBPICTURE ) )
1221 if( p_subpic->i_channel == i_channel )
1223 while( p_subpic->p_region )
1225 subpicture_region_t *p_region = p_subpic->p_region;
1226 p_subpic->p_region = p_region->p_next;
1227 spu_DestroyRegion( p_spu, p_region );
1230 if( p_subpic->pf_destroy ) p_subpic->pf_destroy( p_subpic );
1231 p_subpic->i_status = FREE_SUBPICTURE;
1235 vlc_mutex_unlock( &p_spu->subpicture_lock );
1238 /*****************************************************************************
1239 * spu_ControlDefault: default methods for the subpicture unit control.
1240 *****************************************************************************/
1241 static int spu_vaControlDefault( spu_t *p_spu, int i_query, va_list args )
1247 case SPU_CHANNEL_REGISTER:
1248 pi = (int *)va_arg( args, int * );
1249 if( pi ) *pi = p_spu->i_channel++;
1252 case SPU_CHANNEL_CLEAR:
1253 i = (int)va_arg( args, int );
1254 SpuClearChannel( p_spu, i );
1258 msg_Dbg( p_spu, "control query not supported" );
1259 return VLC_EGENERIC;
1265 /*****************************************************************************
1266 * Object variables callbacks
1267 *****************************************************************************/
1269 /*****************************************************************************
1270 * UpdateSPU: update subpicture settings
1271 *****************************************************************************
1272 * This function is called from CropCallback and at initialization time, to
1273 * retrieve crop information from the input.
1274 *****************************************************************************/
1275 static void UpdateSPU( spu_t *p_spu, vlc_object_t *p_object )
1279 p_spu->b_force_palette = VLC_FALSE;
1280 p_spu->b_force_crop = VLC_FALSE;
1282 if( var_Get( p_object, "highlight", &val ) || !val.b_bool ) return;
1284 p_spu->b_force_crop = VLC_TRUE;
1285 var_Get( p_object, "x-start", &val );
1286 p_spu->i_crop_x = val.i_int;
1287 var_Get( p_object, "y-start", &val );
1288 p_spu->i_crop_y = val.i_int;
1289 var_Get( p_object, "x-end", &val );
1290 p_spu->i_crop_width = val.i_int - p_spu->i_crop_x;
1291 var_Get( p_object, "y-end", &val );
1292 p_spu->i_crop_height = val.i_int - p_spu->i_crop_y;
1294 if( var_Get( p_object, "menu-palette", &val ) == VLC_SUCCESS )
1296 memcpy( p_spu->palette, val.p_address, 16 );
1297 p_spu->b_force_palette = VLC_TRUE;
1300 msg_Dbg( p_object, "crop: %i,%i,%i,%i, palette forced: %i",
1301 p_spu->i_crop_x, p_spu->i_crop_y,
1302 p_spu->i_crop_width, p_spu->i_crop_height,
1303 p_spu->b_force_palette );
1306 /*****************************************************************************
1307 * CropCallback: called when the highlight properties are changed
1308 *****************************************************************************
1309 * This callback is called from the input thread when we need cropping
1310 *****************************************************************************/
1311 static int CropCallback( vlc_object_t *p_object, char const *psz_var,
1312 vlc_value_t oldval, vlc_value_t newval, void *p_data )
1314 (void)psz_var; (void)oldval; (void)newval;
1315 UpdateSPU( (spu_t *)p_data, p_object );
1319 /*****************************************************************************
1320 * Buffers allocation callbacks for the filters
1321 *****************************************************************************/
1322 static subpicture_t *sub_new_buffer( filter_t *p_filter )
1324 filter_owner_sys_t *p_sys = p_filter->p_owner;
1325 subpicture_t *p_subpicture = spu_CreateSubpicture( p_sys->p_spu );
1326 if( p_subpicture ) p_subpicture->i_channel = p_sys->i_channel;
1327 return p_subpicture;
1330 static void sub_del_buffer( filter_t *p_filter, subpicture_t *p_subpic )
1332 filter_owner_sys_t *p_sys = p_filter->p_owner;
1333 spu_DestroySubpicture( p_sys->p_spu, p_subpic );
1336 static subpicture_t *spu_new_buffer( filter_t *p_filter )
1339 subpicture_t *p_subpic = (subpicture_t *)malloc(sizeof(subpicture_t));
1340 if( !p_subpic ) return NULL;
1341 memset( p_subpic, 0, sizeof(subpicture_t) );
1342 p_subpic->b_absolute = VLC_TRUE;
1344 p_subpic->pf_create_region = __spu_CreateRegion;
1345 p_subpic->pf_make_region = __spu_MakeRegion;
1346 p_subpic->pf_destroy_region = __spu_DestroyRegion;
1351 static void spu_del_buffer( filter_t *p_filter, subpicture_t *p_subpic )
1353 while( p_subpic->p_region )
1355 subpicture_region_t *p_region = p_subpic->p_region;
1356 p_subpic->p_region = p_region->p_next;
1357 p_subpic->pf_destroy_region( VLC_OBJECT(p_filter), p_region );
1363 static picture_t *spu_new_video_buffer( filter_t *p_filter )
1365 picture_t *p_picture = malloc( sizeof(picture_t) );
1366 if( !p_picture ) return NULL;
1367 if( vout_AllocatePicture( p_filter, p_picture,
1368 p_filter->fmt_out.video.i_chroma,
1369 p_filter->fmt_out.video.i_width,
1370 p_filter->fmt_out.video.i_height,
1371 p_filter->fmt_out.video.i_aspect )
1378 p_picture->pf_release = RegionPictureRelease;
1383 static void spu_del_video_buffer( filter_t *p_filter, picture_t *p_pic )
1388 if( p_pic->p_data_orig ) free( p_pic->p_data_orig );
1393 static int SubFilterCallback( vlc_object_t *p_object, char const *psz_var,
1394 vlc_value_t oldval, vlc_value_t newval, void *p_data )
1396 VLC_UNUSED(p_object); VLC_UNUSED(oldval);
1397 VLC_UNUSED(newval); VLC_UNUSED(psz_var);
1399 spu_t *p_spu = (spu_t *)p_data;
1400 vlc_mutex_lock( &p_spu->subpicture_lock );
1401 spu_DeleteChain( p_spu );
1402 spu_ParseChain( p_spu );
1403 vlc_mutex_unlock( &p_spu->subpicture_lock );