X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;ds=sidebyside;f=modules%2Fstream_out%2Ftranscode.c;h=eceda3bd81e10c9df0a1be2ddbbd03aa867534f1;hb=1b6fc30078a4ab7fdb7a6309743020499c520de9;hp=4110c3183522467de93fd19b6b45bb5f072a1199;hpb=ac58629e0db818d81d2be1aafca8b784286efa43;p=vlc diff --git a/modules/stream_out/transcode.c b/modules/stream_out/transcode.c index 4110c31835..eceda3bd81 100644 --- a/modules/stream_out/transcode.c +++ b/modules/stream_out/transcode.c @@ -739,10 +739,7 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt ) id = malloc( sizeof( sout_stream_id_t ) ); if( !id ) - { - msg_Err( p_stream, "out of memory" ); goto error; - } memset( id, 0, sizeof(sout_stream_id_t) ); id->id = NULL; @@ -752,10 +749,7 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt ) /* Create decoder object */ id->p_decoder = vlc_object_create( p_stream, VLC_OBJECT_DECODER ); if( !id->p_decoder ) - { - msg_Err( p_stream, "out of memory" ); goto error; - } vlc_object_attach( id->p_decoder, p_stream ); id->p_decoder->p_module = NULL; id->p_decoder->fmt_in = *p_fmt; @@ -764,10 +758,7 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt ) /* Create encoder object */ id->p_encoder = vlc_object_create( p_stream, VLC_OBJECT_ENCODER ); if( !id->p_encoder ) - { - msg_Err( p_stream, "out of memory" ); goto error; - } vlc_object_attach( id->p_encoder, p_stream ); id->p_encoder->p_module = NULL; @@ -931,23 +922,26 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt ) return id; - error: - if( id->p_decoder ) +error: + if( id ) { - vlc_object_detach( id->p_decoder ); - vlc_object_release( id->p_decoder ); - id->p_decoder = NULL; - } + if( id->p_decoder ) + { + vlc_object_detach( id->p_decoder ); + vlc_object_release( id->p_decoder ); + id->p_decoder = NULL; + } - if( id->p_encoder ) - { - vlc_object_detach( id->p_encoder ); - es_format_Clean( &id->p_encoder->fmt_out ); - vlc_object_release( id->p_encoder ); - id->p_encoder = NULL; - } + if( id->p_encoder ) + { + vlc_object_detach( id->p_encoder ); + es_format_Clean( &id->p_encoder->fmt_out ); + vlc_object_release( id->p_encoder ); + id->p_encoder = NULL; + } - free( id ); + free( id ); + } return NULL; } @@ -1112,6 +1106,7 @@ static int transcode_audio_new( sout_stream_t *p_stream, { sout_stream_sys_t *p_sys = p_stream->p_sys; es_format_t fmt_last; + int i; /* * Open decoder @@ -1151,11 +1146,7 @@ static int transcode_audio_new( sout_stream_t *p_stream, id->p_decoder->fmt_out.i_codec ); id->p_encoder->fmt_in.audio.i_format = id->p_decoder->fmt_out.i_codec; - if( ( id->p_encoder->fmt_out.i_codec == VLC_FOURCC('s','a','m','r') ) || - ( id->p_encoder->fmt_out.i_codec == VLC_FOURCC('s','a','w','b') ) ) - id->p_encoder->fmt_in.audio.i_rate = id->p_encoder->fmt_out.audio.i_rate; - else - id->p_encoder->fmt_in.audio.i_rate = fmt_last.audio.i_rate; + id->p_encoder->fmt_in.audio.i_rate = id->p_encoder->fmt_out.audio.i_rate; id->p_encoder->fmt_in.audio.i_physical_channels = id->p_encoder->fmt_out.audio.i_physical_channels; id->p_encoder->fmt_in.audio.i_original_channels = @@ -1191,14 +1182,12 @@ static int transcode_audio_new( sout_stream_t *p_stream, fmt_last.audio.i_rate != id->p_encoder->fmt_in.audio.i_rate ) { /* We'll have to go through fl32 first */ - es_format_t fmt_out = id->p_encoder->fmt_in; - fmt_out.i_codec = fmt_out.audio.i_format = VLC_FOURCC('f','l','3','2'); - filter_chain_AppendFilter( id->p_f_chain, NULL, NULL, &fmt_last, &fmt_out ); - fmt_last = fmt_out; + fmt_last.i_codec = fmt_last.audio.i_format = VLC_FOURCC('f','l','3','2'); + fmt_last.audio.i_bitspersample = aout_BitsPerSample( fmt_last.i_codec ); + filter_chain_AppendFilter( id->p_f_chain, NULL, NULL, NULL, &fmt_last ); + fmt_last = *filter_chain_GetFmtOut( id->p_f_chain ); } - /* FIXME: same comment as in "#if 0"ed code */ - int i; for( i = 0; i < 4; i++ ) { if( (fmt_last.audio.i_channels != @@ -1211,28 +1200,6 @@ static int transcode_audio_new( sout_stream_t *p_stream, } } -#if 0 -/* FIXME FIXME FIXME WHAT DOES THIS CODE DO? LOOKS LIKE IT'S RANDOMLY TRYING -TO CHAIN A BUNCH OF AUDIO FILTERS */ - for( i = 0; i < TRANSCODE_FILTERS; i++ ) - { - if( (fmt_last.audio.i_channels != - id->p_encoder->fmt_in.audio.i_channels) || - (fmt_last.audio.i_rate != id->p_encoder->fmt_in.audio.i_rate) || - (fmt_last.i_codec != id->p_encoder->fmt_in.i_codec) ) - { - id->pp_filter[id->i_filter] = - transcode_audio_filter_new( p_stream, id, &fmt_last, - &id->p_encoder->fmt_in, NULL ); - - if( id->pp_filter[id->i_filter] ) - id->i_filter++; - else - break; - } - } -#endif - /* Final checks to see if conversions were successful */ if( fmt_last.i_codec != id->p_encoder->fmt_in.i_codec ) { @@ -1699,11 +1666,15 @@ static void transcode_video_encoder_init( sout_stream_t *p_stream, f_aspect = f_aspect * i_dst_width / i_dst_height; /* Store calculated values */ - id->p_encoder->fmt_out.video.i_width = i_dst_width; - id->p_encoder->fmt_out.video.i_height = i_dst_height; + id->p_encoder->fmt_out.video.i_width = + id->p_encoder->fmt_out.video.i_visible_width = i_dst_width; + id->p_encoder->fmt_out.video.i_height = + id->p_encoder->fmt_out.video.i_visible_height = i_dst_height; - id->p_encoder->fmt_in.video.i_width = i_dst_width; - id->p_encoder->fmt_in.video.i_height = i_dst_height; + id->p_encoder->fmt_in.video.i_width = + id->p_encoder->fmt_in.video.i_visible_width = i_dst_width; + id->p_encoder->fmt_in.video.i_height = + id->p_encoder->fmt_in.video.i_visible_height = i_dst_height; msg_Dbg( p_stream, "source %ix%i, destination %ix%i", i_src_width, i_src_height, @@ -1947,7 +1918,7 @@ static int transcode_video_process( sout_stream_t *p_stream, transcode_video_filter_allocation_init, transcode_video_filter_allocation_clear, p_stream->p_sys ); - filter_chain_Reset( id->p_uf_chain, &id->p_decoder->fmt_out, + filter_chain_Reset( id->p_uf_chain, &id->p_encoder->fmt_in, &id->p_encoder->fmt_in ); filter_chain_AppendFromString( id->p_uf_chain, p_sys->psz_vf2 ); p_fmt_out = filter_chain_GetFmtOut( id->p_uf_chain ); @@ -2009,7 +1980,10 @@ static int transcode_video_process( sout_stream_t *p_stream, } } - fmt = filter_chain_GetFmtOut( id->p_f_chain )->video; + if( filter_chain_GetLength( id->p_f_chain ) > 0 ) + fmt = filter_chain_GetFmtOut( id->p_f_chain )->video; + else + fmt = id->p_decoder->fmt_out.video; /* FIXME (shouldn't have to be done here) */ fmt.i_sar_num = fmt.i_aspect * fmt.i_height / fmt.i_width; @@ -2109,7 +2083,7 @@ static int EncoderThread( sout_stream_sys_t *p_sys ) sout_stream_id_t *id = p_sys->id_video; picture_t *p_pic; - while( !p_sys->b_die && !p_sys->b_error ) + while( vlc_object_alive (p_sys) && !p_sys->b_error ) { block_t *p_block; @@ -2117,9 +2091,9 @@ static int EncoderThread( sout_stream_sys_t *p_sys ) while( p_sys->i_last_pic == p_sys->i_first_pic ) { vlc_cond_wait( &p_sys->cond, &p_sys->lock_out ); - if( p_sys->b_die || p_sys->b_error ) break; + if( !vlc_object_alive (p_sys) || p_sys->b_error ) break; } - if( p_sys->b_die || p_sys->b_error ) + if( !vlc_object_alive (p_sys) || p_sys->b_error ) { vlc_mutex_unlock( &p_sys->lock_out ); break;