X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fstream_out%2Fmosaic_bridge.c;h=d071189f502ece60dd5568aaadbc31fbfd3fe3af;hb=ddb69692c44d26b2c7454d807c04a52464febf25;hp=496459310a2377d0373011ed66559a40acd7e58e;hpb=52c18c4dec68158eedd655e0502820b7d7b6128f;p=vlc diff --git a/modules/stream_out/mosaic_bridge.c b/modules/stream_out/mosaic_bridge.c index 496459310a..d071189f50 100644 --- a/modules/stream_out/mosaic_bridge.c +++ b/modules/stream_out/mosaic_bridge.c @@ -30,8 +30,6 @@ # include "config.h" #endif -#include /* ENOMEM */ - #include #include #include @@ -41,11 +39,10 @@ #include #include +#include #include "../video_filter/mosaic.h" -#include - /***************************************************************************** * Local structures *****************************************************************************/ @@ -157,7 +154,7 @@ vlc_module_begin () HEIGHT_LONGTEXT, true ) add_string( CFG_PREFIX "sar", "1:1", NULL, RATIO_TEXT, RATIO_LONGTEXT, false ) - add_string( CFG_PREFIX "chroma", 0, NULL, CHROMA_TEXT, CHROMA_LONGTEXT, + add_string( CFG_PREFIX "chroma", NULL, NULL, CHROMA_TEXT, CHROMA_LONGTEXT, false ) add_module_list( CFG_PREFIX "vfilter", "video filter2", @@ -272,6 +269,13 @@ static void Close( vlc_object_t * p_this ) sout_stream_t *p_stream = (sout_stream_t*)p_this; sout_stream_sys_t *p_sys = p_stream->p_sys; + /* Delete the callbacks */ + var_DelCallback( p_stream, CFG_PREFIX "height", HeightCallback, p_stream ); + var_DelCallback( p_stream, CFG_PREFIX "width", WidthCallback, p_stream ); + var_DelCallback( p_stream, CFG_PREFIX "alpha", alphaCallback, p_stream ); + var_DelCallback( p_stream, CFG_PREFIX "x", xCallback, p_stream ); + var_DelCallback( p_stream, CFG_PREFIX "y", yCallback, p_stream ); + p_stream->p_sout->i_out_pace_nocontrol--; free( p_sys->psz_id ); @@ -281,8 +285,8 @@ static void Close( vlc_object_t * p_this ) static int video_filter_buffer_allocation_init( filter_t *p_filter, void *p_data ) { - p_filter->pf_vout_buffer_new = video_new_buffer_filter; - p_filter->pf_vout_buffer_del = video_del_buffer_filter; + p_filter->pf_video_buffer_new = video_new_buffer_filter; + p_filter->pf_video_buffer_del = video_del_buffer_filter; p_filter->p_owner = p_data; return VLC_SUCCESS; } @@ -299,7 +303,7 @@ static sout_stream_id_t * Add( sout_stream_t *p_stream, es_format_t *p_fmt ) return NULL; /* Create decoder object */ - p_sys->p_decoder = vlc_object_create( p_stream, VLC_OBJECT_DECODER ); + p_sys->p_decoder = vlc_object_create( p_stream, sizeof( decoder_t ) ); if( !p_sys->p_decoder ) return NULL; vlc_object_attach( p_sys->p_decoder, p_stream ); @@ -317,7 +321,6 @@ static sout_stream_id_t * Add( sout_stream_t *p_stream, es_format_t *p_fmt ) p_sys->p_decoder->p_owner = malloc( sizeof(decoder_owner_sys_t) ); if( !p_sys->p_decoder->p_owner ) { - vlc_object_detach( p_sys->p_decoder ); vlc_object_release( p_sys->p_decoder ); return NULL; } @@ -340,7 +343,6 @@ static sout_stream_id_t * Add( sout_stream_t *p_stream, es_format_t *p_fmt ) msg_Err( p_stream, "cannot find decoder" ); } free( p_sys->p_decoder->p_owner ); - vlc_object_detach( p_sys->p_decoder ); vlc_object_release( p_sys->p_decoder ); return NULL; } @@ -354,7 +356,7 @@ static sout_stream_id_t * Add( sout_stream_t *p_stream, es_format_t *p_fmt ) vlc_object_t *p_libvlc = VLC_OBJECT( p_stream->p_libvlc ); vlc_value_t val; - p_bridge = malloc( sizeof( bridge_t ) ); + p_bridge = xmalloc( sizeof( bridge_t ) ); var_Create( p_libvlc, "mosaic-struct", VLC_VAR_ADDRESS ); val.p_address = p_bridge; @@ -372,11 +374,10 @@ static sout_stream_id_t * Add( sout_stream_t *p_stream, es_format_t *p_fmt ) if ( i == p_bridge->i_es_num ) { - p_bridge->pp_es = realloc( p_bridge->pp_es, - (p_bridge->i_es_num + 1) - * sizeof(bridged_es_t *) ); + p_bridge->pp_es = xrealloc( p_bridge->pp_es, + (p_bridge->i_es_num + 1) * sizeof(bridged_es_t *) ); p_bridge->i_es_num++; - p_bridge->pp_es[i] = malloc( sizeof(bridged_es_t) ); + p_bridge->pp_es[i] = xmalloc( sizeof(bridged_es_t) ); } p_sys->p_es = p_es = p_bridge->pp_es[i]; @@ -449,7 +450,6 @@ static int Del( sout_stream_t *p_stream, sout_stream_id_t *id ) if( p_sys->p_decoder->p_description ) vlc_meta_Delete( p_sys->p_decoder->p_description ); - vlc_object_detach( p_sys->p_decoder ); vlc_object_release( p_sys->p_decoder ); free( p_owner ); @@ -551,17 +551,21 @@ static int Send( sout_stream_t *p_stream, sout_stream_id_t *id, else fmt_out.i_chroma = VLC_CODEC_I420; + const unsigned i_fmt_in_aspect = + (int64_t)VOUT_ASPECT_FACTOR * + fmt_in.i_sar_num * fmt_in.i_width / + (fmt_in.i_sar_den * fmt_in.i_height); if ( !p_sys->i_height ) { fmt_out.i_width = p_sys->i_width; fmt_out.i_height = (p_sys->i_width * VOUT_ASPECT_FACTOR - * p_sys->i_sar_num / p_sys->i_sar_den / fmt_in.i_aspect) + * p_sys->i_sar_num / p_sys->i_sar_den / i_fmt_in_aspect) & ~0x1; } else if ( !p_sys->i_width ) { fmt_out.i_height = p_sys->i_height; - fmt_out.i_width = (p_sys->i_height * fmt_in.i_aspect + fmt_out.i_width = (p_sys->i_height * i_fmt_in_aspect * p_sys->i_sar_den / p_sys->i_sar_num / VOUT_ASPECT_FACTOR) & ~0x1; } @@ -588,7 +592,8 @@ static int Send( sout_stream_t *p_stream, sout_stream_id_t *id, p_new_pic = picture_New( p_pic->format.i_chroma, p_pic->format.i_width, p_pic->format.i_height, - p_sys->p_decoder->fmt_out.video.i_aspect ); + p_sys->p_decoder->fmt_out.video.i_sar_num, + p_sys->p_decoder->fmt_out.video.i_sar_den ); if( !p_new_pic ) { picture_Release( p_pic ); @@ -627,21 +632,13 @@ static picture_t *video_new_buffer( vlc_object_t *p_this, decoder_owner_sys_t *p_sys, es_format_t *fmt_out ) { + VLC_UNUSED(p_this); if( fmt_out->video.i_width != p_sys->video.i_width || fmt_out->video.i_height != p_sys->video.i_height || fmt_out->video.i_chroma != p_sys->video.i_chroma || - fmt_out->video.i_aspect != p_sys->video.i_aspect ) + (int64_t)fmt_out->video.i_sar_num * p_sys->video.i_sar_den != + (int64_t)fmt_out->video.i_sar_den * p_sys->video.i_sar_num ) { - if( !fmt_out->video.i_sar_num || - !fmt_out->video.i_sar_den ) - { - fmt_out->video.i_sar_num = - fmt_out->video.i_aspect * fmt_out->video.i_height; - - fmt_out->video.i_sar_den = - VOUT_ASPECT_FACTOR * fmt_out->video.i_width; - } - vlc_ureduce( &fmt_out->video.i_sar_num, &fmt_out->video.i_sar_den, fmt_out->video.i_sar_num, @@ -661,10 +658,7 @@ static picture_t *video_new_buffer( vlc_object_t *p_this, /* */ fmt_out->video.i_chroma = fmt_out->i_codec; - return picture_New( fmt_out->video.i_chroma, - fmt_out->video.i_width, - fmt_out->video.i_height, - fmt_out->video.i_aspect ); + return picture_NewFromFormat( &fmt_out->video ); } inline static void video_del_buffer_decoder( decoder_t *p_this,