X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fstream_out%2Fmosaic_bridge.c;h=d39990f7011533e27e23ada8e0513f0bfa5d8c0b;hb=9d447992d1913208c433caacd3279d61c80417ae;hp=78117fef73ce55fa20aa95de22088b26ff48f3f4;hpb=15643af12d9eb61eff8a8e89d8170f3d2b73d7e1;p=vlc diff --git a/modules/stream_out/mosaic_bridge.c b/modules/stream_out/mosaic_bridge.c index 78117fef73..d39990f701 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 @@ -42,12 +40,8 @@ #include #include -#include - #include "../video_filter/mosaic.h" -#include - /***************************************************************************** * Local structures *****************************************************************************/ @@ -363,8 +357,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 ) ); - assert( p_bridge ); + p_bridge = xmalloc( sizeof( bridge_t ) ); var_Create( p_libvlc, "mosaic-struct", VLC_VAR_ADDRESS ); val.p_address = p_bridge; @@ -382,12 +375,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_or_free( p_bridge->pp_es, + p_bridge->pp_es = xrealloc( p_bridge->pp_es, (p_bridge->i_es_num + 1) * sizeof(bridged_es_t *) ); - assert( p_bridge->pp_es ); p_bridge->i_es_num++; - p_bridge->pp_es[i] = malloc( sizeof(bridged_es_t) ); - assert( p_bridge->pp_es[i] ); + p_bridge->pp_es[i] = xmalloc( sizeof(bridged_es_t) ); } p_sys->p_es = p_es = p_bridge->pp_es[i]; @@ -562,17 +553,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; } @@ -599,7 +594,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 ); @@ -642,18 +638,9 @@ static picture_t *video_new_buffer( vlc_object_t *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, @@ -673,10 +660,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,