1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2004-2007 the VideoLAN team
7 * Authors: Antoine Cellerier <dionoea@videolan.org>
8 * Christophe Massiot <massiot@via.ecp.fr>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 /*****************************************************************************
27 *****************************************************************************/
28 #include <errno.h> /* ENOMEM */
36 #include <vlc_block.h>
37 #include <vlc_codec.h>
39 #include <vlc_image.h>
40 #include <vlc_filter.h>
42 #include "../video_filter/mosaic.h"
44 /*****************************************************************************
46 *****************************************************************************/
47 struct sout_stream_sys_t
53 image_handler_t *p_image; /* filter for resizing */
54 int i_height, i_width;
55 unsigned int i_sar_num, i_sar_den;
59 int i_chroma; /* force image format chroma */
61 filter_t **pp_vfilters;
65 #define PICTURE_RING_SIZE 4
66 struct decoder_owner_sys_t
68 picture_t *pp_pics[PICTURE_RING_SIZE];
70 /* Current format in use by the output */
74 typedef void (* pf_release_t)( picture_t * );
75 static void ReleasePicture( picture_t *p_pic )
79 if ( p_pic->i_refcount <= 0 )
81 if ( p_pic->p_sys != NULL )
83 pf_release_t pf_release = (pf_release_t)p_pic->p_sys;
91 free( p_pic->p_data_orig );
98 /*****************************************************************************
100 *****************************************************************************/
101 static int Open ( vlc_object_t * );
102 static void Close ( vlc_object_t * );
103 static sout_stream_id_t *Add ( sout_stream_t *, es_format_t * );
104 static int Del ( sout_stream_t *, sout_stream_id_t * );
105 static int Send( sout_stream_t *, sout_stream_id_t *, block_t * );
107 inline static void video_del_buffer_decoder( decoder_t *, picture_t * );
108 inline static void video_del_buffer_filter( filter_t *, picture_t * );
109 static void video_del_buffer( picture_t * );
111 inline static picture_t *video_new_buffer_decoder( decoder_t * );
112 inline static picture_t *video_new_buffer_filter( filter_t * );
113 static picture_t *video_new_buffer( vlc_object_t *, decoder_owner_sys_t *,
114 es_format_t *, void (*)( picture_t * ) );
116 static void video_link_picture_decoder( decoder_t *, picture_t * );
117 static void video_unlink_picture_decoder( decoder_t *, picture_t * );
118 static int MosaicBridgeCallback( vlc_object_t *, char const *,
119 vlc_value_t, vlc_value_t, void * );
121 /*****************************************************************************
123 *****************************************************************************/
124 #define ID_TEXT N_("ID")
125 #define ID_LONGTEXT N_( \
126 "Specify an identifier string for this subpicture" )
128 #define WIDTH_TEXT N_("Video width")
129 #define WIDTH_LONGTEXT N_( \
130 "Output video width." )
131 #define HEIGHT_TEXT N_("Video height")
132 #define HEIGHT_LONGTEXT N_( \
133 "Output video height." )
134 #define RATIO_TEXT N_("Sample aspect ratio")
135 #define RATIO_LONGTEXT N_( \
136 "Sample aspect ratio of the destination (1:1, 3:4, 2:3)." )
138 #define VFILTER_TEXT N_("Video filter")
139 #define VFILTER_LONGTEXT N_( \
140 "Video filters will be applied to the video stream." )
142 #define CHROMA_TEXT N_("Image chroma")
143 #define CHROMA_LONGTEXT N_( \
144 "Force the use of a specific chroma. Use YUVA if you're planning " \
145 "to use the Alphamask or Bluescreen video filter." )
147 #define CFG_PREFIX "sout-mosaic-bridge-"
150 set_shortname( _( "Mosaic bridge" ) );
151 set_description(_("Mosaic bridge stream output") );
152 set_capability( "sout stream", 0 );
153 add_shortcut( "mosaic-bridge" );
155 add_string( CFG_PREFIX "id", "Id", NULL, ID_TEXT, ID_LONGTEXT,
157 add_integer( CFG_PREFIX "width", 0, NULL, WIDTH_TEXT,
158 WIDTH_LONGTEXT, true );
159 add_integer( CFG_PREFIX "height", 0, NULL, HEIGHT_TEXT,
160 HEIGHT_LONGTEXT, true );
161 add_string( CFG_PREFIX "sar", "1:1", NULL, RATIO_TEXT,
162 RATIO_LONGTEXT, false );
163 add_string( CFG_PREFIX "chroma", 0, NULL, CHROMA_TEXT, CHROMA_LONGTEXT,
166 add_module_list( CFG_PREFIX "vfilter", "video filter2",
167 NULL, NULL, VFILTER_TEXT, VFILTER_LONGTEXT, false );
169 set_callbacks( Open, Close );
172 static const char *ppsz_sout_options[] = {
173 "id", "width", "height", "sar", "vfilter", "chroma", NULL
176 /*****************************************************************************
178 *****************************************************************************/
179 static int Open( vlc_object_t *p_this )
181 sout_stream_t *p_stream = (sout_stream_t *)p_this;
182 sout_stream_sys_t *p_sys;
183 vlc_object_t *p_libvlc = VLC_OBJECT( p_this->p_libvlc );
186 config_ChainParse( p_stream, CFG_PREFIX, ppsz_sout_options,
189 p_sys = malloc( sizeof( sout_stream_sys_t ) );
195 p_stream->p_sys = p_sys;
196 p_sys->b_inited = false;
198 var_Create( p_libvlc, "mosaic-lock", VLC_VAR_MUTEX );
199 var_Get( p_libvlc, "mosaic-lock", &val );
200 p_sys->p_lock = val.p_address;
202 var_Get( p_stream, CFG_PREFIX "id", &val );
203 p_sys->psz_id = val.psz_string;
206 var_CreateGetIntegerCommand( p_stream, CFG_PREFIX "height" );
207 var_AddCallback( p_stream, CFG_PREFIX "height", MosaicBridgeCallback,
211 var_CreateGetIntegerCommand( p_stream, CFG_PREFIX "width" );
212 var_AddCallback( p_stream, CFG_PREFIX "width", MosaicBridgeCallback,
215 var_Get( p_stream, CFG_PREFIX "sar", &val );
216 if ( val.psz_string )
218 char *psz_parser = strchr( val.psz_string, ':' );
222 *psz_parser++ = '\0';
223 p_sys->i_sar_num = atoi( val.psz_string );
224 p_sys->i_sar_den = atoi( psz_parser );
225 vlc_ureduce( &p_sys->i_sar_num, &p_sys->i_sar_den,
226 p_sys->i_sar_num, p_sys->i_sar_den, 0 );
230 msg_Warn( p_stream, "bad aspect ratio %s", val.psz_string );
231 p_sys->i_sar_num = p_sys->i_sar_den = 1;
234 free( val.psz_string );
238 p_sys->i_sar_num = p_sys->i_sar_den = 1;
242 val.psz_string = var_GetNonEmptyString( p_stream, CFG_PREFIX "chroma" );
243 if( val.psz_string && strlen( val.psz_string ) >= 4 )
245 memcpy( &p_sys->i_chroma, val.psz_string, 4 );
246 msg_Dbg( p_stream, "Forcing image chroma to 0x%.8x (%4.4s)", p_sys->i_chroma, (char*)&p_sys->i_chroma );
249 p_stream->pf_add = Add;
250 p_stream->pf_del = Del;
251 p_stream->pf_send = Send;
253 p_stream->p_sout->i_out_pace_nocontrol++;
258 /*****************************************************************************
260 *****************************************************************************/
261 static void Close( vlc_object_t * p_this )
263 sout_stream_t *p_stream = (sout_stream_t*)p_this;
264 sout_stream_sys_t *p_sys = p_stream->p_sys;
266 p_stream->p_sout->i_out_pace_nocontrol--;
268 free( p_sys->psz_id );
273 static sout_stream_id_t * Add( sout_stream_t *p_stream, es_format_t *p_fmt )
275 sout_stream_sys_t *p_sys = p_stream->p_sys;
278 char *psz_chain, *psz_parser;
281 if ( p_sys->b_inited )
286 /* Create decoder object */
287 p_sys->p_decoder = vlc_object_create( p_stream, VLC_OBJECT_DECODER );
288 vlc_object_attach( p_sys->p_decoder, p_stream );
289 p_sys->p_decoder->p_module = NULL;
290 p_sys->p_decoder->fmt_in = *p_fmt;
291 p_sys->p_decoder->b_pace_control = false;
292 p_sys->p_decoder->fmt_out = p_sys->p_decoder->fmt_in;
293 p_sys->p_decoder->fmt_out.i_extra = 0;
294 p_sys->p_decoder->fmt_out.p_extra = 0;
295 p_sys->p_decoder->pf_decode_video = 0;
296 p_sys->p_decoder->pf_vout_buffer_new = video_new_buffer_decoder;
297 p_sys->p_decoder->pf_vout_buffer_del = video_del_buffer_decoder;
298 p_sys->p_decoder->pf_picture_link = video_link_picture_decoder;
299 p_sys->p_decoder->pf_picture_unlink = video_unlink_picture_decoder;
300 p_sys->p_decoder->p_owner = malloc( sizeof(decoder_owner_sys_t) );
301 for( i = 0; i < PICTURE_RING_SIZE; i++ )
302 p_sys->p_decoder->p_owner->pp_pics[i] = 0;
303 p_sys->p_decoder->p_owner->video = p_fmt->video;
304 //p_sys->p_decoder->p_cfg = p_sys->p_video_cfg;
306 p_sys->p_decoder->p_module =
307 module_Need( p_sys->p_decoder, "decoder", "$codec", 0 );
309 if( !p_sys->p_decoder->p_module )
311 msg_Err( p_stream, "cannot find decoder" );
312 vlc_object_detach( p_sys->p_decoder );
313 vlc_object_release( p_sys->p_decoder );
317 p_sys->b_inited = true;
318 vlc_mutex_lock( p_sys->p_lock );
320 p_bridge = GetBridge( p_stream );
321 if ( p_bridge == NULL )
323 vlc_object_t *p_libvlc = VLC_OBJECT( p_stream->p_libvlc );
326 p_bridge = malloc( sizeof( bridge_t ) );
328 var_Create( p_libvlc, "mosaic-struct", VLC_VAR_ADDRESS );
329 val.p_address = p_bridge;
330 var_Set( p_libvlc, "mosaic-struct", val );
332 p_bridge->i_es_num = 0;
333 p_bridge->pp_es = NULL;
336 for ( i = 0; i < p_bridge->i_es_num; i++ )
338 if ( p_bridge->pp_es[i]->b_empty )
342 if ( i == p_bridge->i_es_num )
344 p_bridge->pp_es = realloc( p_bridge->pp_es,
345 (p_bridge->i_es_num + 1)
346 * sizeof(bridged_es_t *) );
347 p_bridge->i_es_num++;
348 p_bridge->pp_es[i] = malloc( sizeof(bridged_es_t) );
351 p_sys->p_es = p_es = p_bridge->pp_es[i];
353 //p_es->fmt = *p_fmt;
354 p_es->psz_id = p_sys->psz_id;
355 p_es->p_picture = NULL;
356 p_es->pp_last = &p_es->p_picture;
357 p_es->b_empty = false;
359 vlc_mutex_unlock( p_sys->p_lock );
361 if ( p_sys->i_height || p_sys->i_width )
363 p_sys->p_image = image_HandlerCreate( p_stream );
367 p_sys->p_image = NULL;
370 msg_Dbg( p_stream, "mosaic bridge id=%s pos=%d", p_es->psz_id, i );
372 /* Create user specified video filters */
373 psz_chain = var_GetNonEmptyString( p_stream, CFG_PREFIX "vfilter" );
374 msg_Dbg( p_stream, "psz_chain: %s\n", psz_chain );
376 config_chain_t *p_cfg;
377 for( p_cfg = p_stream->p_cfg; p_cfg != NULL; p_cfg = p_cfg->p_next )
379 msg_Dbg( p_stream, " - %s\n", p_cfg->psz_value );
382 p_sys->i_vfilters = 0;
383 p_sys->pp_vfilters = NULL;
384 psz_parser = psz_chain;
385 while( psz_parser && *psz_parser )
387 config_chain_t *p_cfg;
389 filter_t **pp_vfilter;
390 psz_parser = config_ChainCreate( &psz_name, &p_cfg, psz_parser );
393 (filter_t **)realloc( p_sys->pp_vfilters,
394 p_sys->i_vfilters * sizeof(filter_t *) );
395 pp_vfilter = p_sys->pp_vfilters+(p_sys->i_vfilters - 1);
396 *pp_vfilter = vlc_object_create( p_stream, VLC_OBJECT_FILTER );
397 vlc_object_attach( *pp_vfilter, p_stream );
398 (*pp_vfilter)->pf_vout_buffer_new = video_new_buffer_filter;
399 (*pp_vfilter)->pf_vout_buffer_del = video_del_buffer_filter;
400 (*pp_vfilter)->fmt_in = p_sys->p_decoder->fmt_out;
401 if( p_sys->i_chroma )
402 (*pp_vfilter)->fmt_in.video.i_chroma = p_sys->i_chroma;
403 (*pp_vfilter)->fmt_out = (*pp_vfilter)->fmt_in;
404 (*pp_vfilter)->p_cfg = p_cfg;
405 (*pp_vfilter)->p_module =
406 module_Need( *pp_vfilter, "video filter2", psz_name, true );
407 if( (*pp_vfilter)->p_module )
410 (*pp_vfilter)->p_owner = (filter_owner_sys_t *)
411 p_sys->p_decoder->p_owner;
412 msg_Err( p_stream, "Added video filter %s to the chain",
417 /* Crap ... we didn't find a filter */
419 "no video filter matching name \"%s\" found",
421 vlc_object_detach( *pp_vfilter );
422 vlc_object_release( *pp_vfilter );
428 return (sout_stream_id_t *)p_sys;
431 static int Del( sout_stream_t *p_stream, sout_stream_id_t *id )
434 sout_stream_sys_t *p_sys = p_stream->p_sys;
437 bool b_last_es = true;
438 filter_t **pp_vfilter, **pp_end;
441 if ( !p_sys->b_inited )
446 if ( p_sys->p_decoder != NULL )
448 picture_t **pp_ring = p_sys->p_decoder->p_owner->pp_pics;
450 if( p_sys->p_decoder->p_module )
451 module_Unneed( p_sys->p_decoder, p_sys->p_decoder->p_module );
452 vlc_object_detach( p_sys->p_decoder );
453 vlc_object_release( p_sys->p_decoder );
455 for( i = 0; i < PICTURE_RING_SIZE; i++ )
457 if ( pp_ring[i] != NULL )
459 free( pp_ring[i]->p_data_orig );
460 free( pp_ring[i]->p_sys );
466 /* Destroy user specified video filters */
467 pp_vfilter = p_sys->pp_vfilters;
468 pp_end = pp_vfilter + p_sys->i_vfilters;
469 for( ; pp_vfilter < pp_end; pp_vfilter++ )
471 vlc_object_detach( *pp_vfilter );
472 if( (*pp_vfilter)->p_module )
473 module_Unneed( *pp_vfilter, (*pp_vfilter)->p_module );
474 vlc_object_release( *pp_vfilter );
476 free( p_sys->pp_vfilters );
478 vlc_mutex_lock( p_sys->p_lock );
480 p_bridge = GetBridge( p_stream );
483 p_es->b_empty = true;
484 while ( p_es->p_picture )
486 picture_t *p_next = p_es->p_picture->p_next;
487 p_es->p_picture->pf_release( p_es->p_picture );
488 p_es->p_picture = p_next;
491 for ( i = 0; i < p_bridge->i_es_num; i++ )
493 if ( !p_bridge->pp_es[i]->b_empty )
502 vlc_object_t *p_libvlc = VLC_OBJECT( p_stream->p_libvlc );
503 for ( i = 0; i < p_bridge->i_es_num; i++ )
504 free( p_bridge->pp_es[i] );
505 free( p_bridge->pp_es );
507 var_Destroy( p_libvlc, "mosaic-struct" );
510 vlc_mutex_unlock( p_sys->p_lock );
512 if ( p_sys->p_image )
514 image_HandlerDelete( p_sys->p_image );
517 p_sys->b_inited = false;
522 /*****************************************************************************
523 * PushPicture : push a picture in the mosaic-struct structure
524 *****************************************************************************/
525 static void PushPicture( sout_stream_t *p_stream, picture_t *p_picture )
527 sout_stream_sys_t *p_sys = p_stream->p_sys;
528 bridged_es_t *p_es = p_sys->p_es;
530 vlc_mutex_lock( p_sys->p_lock );
532 *p_es->pp_last = p_picture;
533 p_picture->p_next = NULL;
534 p_es->pp_last = &p_picture->p_next;
536 vlc_mutex_unlock( p_sys->p_lock );
539 static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
542 sout_stream_sys_t *p_sys = p_stream->p_sys;
545 if ( (sout_stream_sys_t *)id != p_sys )
547 block_ChainRelease( p_buffer );
551 while ( (p_pic = p_sys->p_decoder->pf_decode_video( p_sys->p_decoder,
554 picture_t *p_new_pic;
556 if( p_sys->i_height || p_sys->i_width )
558 video_format_t fmt_out, fmt_in;
560 memset( &fmt_in, 0, sizeof(video_format_t) );
561 memset( &fmt_out, 0, sizeof(video_format_t) );
562 fmt_in = p_sys->p_decoder->fmt_out.video;
565 if( p_sys->i_chroma )
566 fmt_out.i_chroma = p_sys->i_chroma;
568 fmt_out.i_chroma = VLC_FOURCC('I','4','2','0');
570 if ( !p_sys->i_height )
572 fmt_out.i_width = p_sys->i_width;
573 fmt_out.i_height = (p_sys->i_width * VOUT_ASPECT_FACTOR
574 * p_sys->i_sar_num / p_sys->i_sar_den / fmt_in.i_aspect)
577 else if ( !p_sys->i_width )
579 fmt_out.i_height = p_sys->i_height;
580 fmt_out.i_width = (p_sys->i_height * fmt_in.i_aspect
581 * p_sys->i_sar_den / p_sys->i_sar_num / VOUT_ASPECT_FACTOR)
586 fmt_out.i_width = p_sys->i_width;
587 fmt_out.i_height = p_sys->i_height;
589 fmt_out.i_visible_width = fmt_out.i_width;
590 fmt_out.i_visible_height = fmt_out.i_height;
592 p_new_pic = image_Convert( p_sys->p_image,
593 p_pic, &fmt_in, &fmt_out );
594 if ( p_new_pic == NULL )
596 msg_Err( p_stream, "image conversion failed" );
602 /* TODO: chroma conversion if needed */
604 p_new_pic = (picture_t*)malloc( sizeof(picture_t) );
605 if( p_new_pic == NULL )
607 msg_Err( p_stream, "image conversion failed" );
611 if( vout_AllocatePicture(
612 p_stream, p_new_pic, p_pic->format.i_chroma,
613 p_pic->format.i_width, p_pic->format.i_height,
614 p_sys->p_decoder->fmt_out.video.i_aspect )
618 msg_Err( p_stream, "image allocation failed" );
622 vout_CopyPicture( p_stream, p_new_pic, p_pic );
625 p_new_pic->i_refcount = 1;
626 p_new_pic->i_status = DESTROYED_PICTURE;
627 p_new_pic->i_type = DIRECT_PICTURE;
628 p_new_pic->p_sys = (picture_sys_t *)p_new_pic->pf_release;
629 p_new_pic->pf_release = ReleasePicture;
630 p_new_pic->date = p_pic->date;
631 p_pic->pf_release( p_pic );
633 if( p_sys->pp_vfilters )
635 /* Apply user specified video filters */
636 filter_t **pp_vfilter = p_sys->pp_vfilters;
637 filter_t **pp_end = pp_vfilter + p_sys->i_vfilters;
638 for( ; pp_vfilter < pp_end; pp_vfilter++ )
640 (*pp_vfilter)->fmt_in.i_codec = p_new_pic->format.i_chroma;
641 (*pp_vfilter)->fmt_out.i_codec = p_new_pic->format.i_chroma;
642 (*pp_vfilter)->fmt_in.video = p_new_pic->format;
643 (*pp_vfilter)->fmt_out.video = p_new_pic->format;
644 p_new_pic = (*pp_vfilter)->pf_video_filter( *pp_vfilter,
648 msg_Err( p_stream, "video filter failed" );
652 if( !p_new_pic ) continue;
655 PushPicture( p_stream, p_new_pic );
663 vlc_object_t *p_owner;
667 static void video_release_buffer_decoder( picture_t *p_pic )
669 if( p_pic && !p_pic->i_refcount && p_pic->pf_release && p_pic->p_sys )
671 video_del_buffer_decoder( (decoder_t *)p_pic->p_sys->p_owner, p_pic );
673 else if( p_pic && p_pic->i_refcount > 0 ) p_pic->i_refcount--;
676 static void video_release_buffer_filter( picture_t *p_pic )
678 if( p_pic && !p_pic->i_refcount && p_pic->pf_release && p_pic->p_sys )
680 video_del_buffer_filter( (filter_t *)p_pic->p_sys->p_owner, p_pic );
682 else if( p_pic && p_pic->i_refcount > 0 ) p_pic->i_refcount--;
685 inline static picture_t *video_new_buffer_decoder( decoder_t *p_dec )
687 return video_new_buffer( VLC_OBJECT( p_dec ),
688 (decoder_owner_sys_t *)p_dec->p_owner,
690 video_release_buffer_decoder );
693 inline static picture_t *video_new_buffer_filter( filter_t *p_filter )
695 return video_new_buffer( VLC_OBJECT( p_filter ),
696 (decoder_owner_sys_t *)p_filter->p_owner,
698 video_release_buffer_filter );
701 static picture_t *video_new_buffer( vlc_object_t *p_this,
702 decoder_owner_sys_t *p_sys,
703 es_format_t *fmt_out,
704 void ( *pf_release )( picture_t * ) )
706 picture_t **pp_ring = p_sys->pp_pics;
710 if( fmt_out->video.i_width != p_sys->video.i_width ||
711 fmt_out->video.i_height != p_sys->video.i_height ||
712 fmt_out->video.i_chroma != p_sys->video.i_chroma ||
713 fmt_out->video.i_aspect != p_sys->video.i_aspect )
715 if( !fmt_out->video.i_sar_num ||
716 !fmt_out->video.i_sar_den )
718 fmt_out->video.i_sar_num =
719 fmt_out->video.i_aspect * fmt_out->video.i_height;
721 fmt_out->video.i_sar_den =
722 VOUT_ASPECT_FACTOR * fmt_out->video.i_width;
725 vlc_ureduce( &fmt_out->video.i_sar_num,
726 &fmt_out->video.i_sar_den,
727 fmt_out->video.i_sar_num,
728 fmt_out->video.i_sar_den, 0 );
730 if( !fmt_out->video.i_visible_width ||
731 !fmt_out->video.i_visible_height )
733 fmt_out->video.i_visible_width = fmt_out->video.i_width;
734 fmt_out->video.i_visible_height = fmt_out->video.i_height;
737 fmt_out->video.i_chroma = fmt_out->i_codec;
738 p_sys->video = fmt_out->video;
740 for( i = 0; i < PICTURE_RING_SIZE; i++ )
742 if ( pp_ring[i] != NULL )
744 if ( pp_ring[i]->i_status == DESTROYED_PICTURE )
746 free( pp_ring[i]->p_data_orig );
747 free( pp_ring[i]->p_sys );
752 pp_ring[i]->p_sys->b_dead = true;
759 /* Find an empty space in the picture ring buffer */
760 for( i = 0; i < PICTURE_RING_SIZE; i++ )
762 if( pp_ring[i] != NULL && pp_ring[i]->i_status == DESTROYED_PICTURE )
764 pp_ring[i]->i_status = RESERVED_PICTURE;
768 for( i = 0; i < PICTURE_RING_SIZE; i++ )
770 if( pp_ring[i] == NULL ) break;
773 if( i == PICTURE_RING_SIZE )
775 msg_Err( p_this, "decoder/filter is leaking pictures, "
776 "resetting its ring buffer" );
778 for( i = 0; i < PICTURE_RING_SIZE; i++ )
780 pp_ring[i]->pf_release( pp_ring[i] );
786 p_pic = malloc( sizeof(picture_t) );
787 if( !p_pic ) return NULL;
788 fmt_out->video.i_chroma = fmt_out->i_codec;
789 vout_AllocatePicture( p_this, p_pic,
790 fmt_out->video.i_chroma,
791 fmt_out->video.i_width,
792 fmt_out->video.i_height,
793 fmt_out->video.i_aspect );
795 if( !p_pic->i_planes )
801 p_pic->pf_release = pf_release;
802 p_pic->p_sys = malloc( sizeof(picture_sys_t) );
803 p_pic->p_sys->p_owner = p_this;
804 p_pic->p_sys->b_dead = false;
805 p_pic->i_status = RESERVED_PICTURE;
812 inline static void video_del_buffer_decoder( decoder_t *p_this,
816 video_del_buffer( p_pic );
819 inline static void video_del_buffer_filter( filter_t *p_this,
823 video_del_buffer( p_pic );
826 static void video_del_buffer( picture_t *p_pic )
828 p_pic->i_refcount = 0;
829 p_pic->i_status = DESTROYED_PICTURE;
830 if ( p_pic->p_sys->b_dead )
832 free( p_pic->p_data_orig );
833 free( p_pic->p_sys );
838 static void video_link_picture_decoder( decoder_t *p_dec, picture_t *p_pic )
844 static void video_unlink_picture_decoder( decoder_t *p_dec, picture_t *p_pic )
847 video_release_buffer_decoder( p_pic );
851 /**********************************************************************
852 * Callback to update (some) params on the fly
853 **********************************************************************/
854 static int MosaicBridgeCallback( vlc_object_t *p_this, char const *psz_var,
855 vlc_value_t oldval, vlc_value_t newval,
858 VLC_UNUSED(p_this); VLC_UNUSED(oldval);
859 sout_stream_t *p_stream = (sout_stream_t *)p_data;
860 sout_stream_sys_t *p_sys = p_stream->p_sys;
861 int i_ret = VLC_SUCCESS;
863 #define VAR_IS( a ) !strcmp( psz_var, CFG_PREFIX a )
864 if( VAR_IS( "height" ) )
866 /* We create the handler before updating the value in p_sys
867 * so we don't have to worry about locking */
868 if( !p_sys->p_image && newval.i_int )
869 p_sys->p_image = image_HandlerCreate( p_stream );
870 p_sys->i_height = newval.i_int;
872 else if( VAR_IS( "width" ) )
874 /* We create the handler before updating the value in p_sys
875 * so we don't have to worry about locking */
876 if( !p_sys->p_image && newval.i_int )
877 p_sys->p_image = image_HandlerCreate( p_stream );
878 p_sys->i_width = newval.i_int;