X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Finput%2Finput_dec.c;h=905d8d8b2b2842f859ee8c8223ae35295afb4991;hb=7518bb92dd1934dcb190915f68f520556f70f11b;hp=321b5dbc0d14122c0abd112e2bcb539b5b6d7ee9;hpb=319e629d2c640cde2f7c42ab7429d5f324273a0b;p=vlc diff --git a/src/input/input_dec.c b/src/input/input_dec.c index 321b5dbc0d..905d8d8b2b 100644 --- a/src/input/input_dec.c +++ b/src/input/input_dec.c @@ -2,7 +2,7 @@ * input_dec.c: Functions for the management of decoders ***************************************************************************** * Copyright (C) 1999-2001 VideoLAN - * $Id: input_dec.c,v 1.49 2002/10/29 13:22:48 sam Exp $ + * $Id: input_dec.c,v 1.57 2003/01/25 03:12:20 fenrir Exp $ * * Authors: Christophe Massiot * @@ -10,7 +10,7 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -26,7 +26,6 @@ *****************************************************************************/ #include #include /* memcpy(), memset() */ -#include /* off_t */ #include @@ -45,6 +44,7 @@ static void DeleteDecoderFifo( decoder_fifo_t * ); decoder_fifo_t * input_RunDecoder( input_thread_t * p_input, es_descriptor_t * p_es ) { + char *psz_sout; decoder_fifo_t *p_fifo; int i_priority; @@ -57,8 +57,67 @@ decoder_fifo_t * input_RunDecoder( input_thread_t * p_input, return NULL; } - /* Get a suitable module */ - p_fifo->p_module = module_Need( p_fifo, "decoder", "$codec" ); + p_fifo->p_module = NULL; + /* If we are in sout mode, search first for packetizer module then + * codec to do transcoding */ + psz_sout = config_GetPsz( p_input, "sout" ); + if( psz_sout != NULL && *psz_sout != 0 ) + { + vlc_bool_t b_sout = VLC_TRUE; + + if( p_es->i_cat == AUDIO_ES ) + { + b_sout = config_GetInt( p_input, "sout-audio" ); + } + else if( p_es->i_cat == VIDEO_ES ) + { + b_sout = config_GetInt( p_input, "sout-video" ); + } + + if( b_sout ) + { + vlc_bool_t b_reencode = VLC_FALSE; + + if( p_es->i_cat == AUDIO_ES ) + { + char *psz_sout_acodec = config_GetPsz( p_input, "sout-acodec" ); + if( psz_sout_acodec != NULL && *psz_sout_acodec != '\0' ) + { + msg_Dbg( p_input, "audio reencoding requested -> unsupported" ); + b_reencode = VLC_TRUE; + } + } + else if( p_es->i_cat == VIDEO_ES ) + { + char *psz_sout_vcodec = config_GetPsz( p_input, "sout-vcodec" ); + if( psz_sout_vcodec != NULL && *psz_sout_vcodec != '\0' ) + { + msg_Dbg( p_input, "video reencoding requested" ); + /* force encoder video output */ + config_PutPsz( p_input, "vout", "encoder" ); + b_reencode = VLC_TRUE; + } + } + + if( !b_reencode ) + { + /* we don't want to reencode so search for a packetizer */ + p_fifo->p_module = + module_Need( p_fifo, "packetizer", "$packetizer" ); + } + else + { + /* get a suitable decoder module to do reencoding*/ + p_fifo->p_module = module_Need( p_fifo, "decoder", "$codec" ); + } + } + } + else + { + /* default Get a suitable decoder module */ + p_fifo->p_module = module_Need( p_fifo, "decoder", "$codec" ); + } + if( p_fifo->p_module == NULL ) { msg_Err( p_fifo, "no suitable decoder module for fourcc `%4.4s'", @@ -225,12 +284,58 @@ void input_FlushPESFifo( decoder_fifo_t *p_fifo ) vlc_mutex_unlock( &p_fifo->data_lock ); } + +/***************************************************************************** + * Create a NULL packet for padding in case of a data loss + *****************************************************************************/ +void input_NullPacket( input_thread_t * p_input, + es_descriptor_t * p_es ) +{ + data_packet_t * p_pad_data; + pes_packet_t * p_pes; + + if( (p_pad_data = input_NewPacketForce( p_input->p_method_data, + PADDING_PACKET_SIZE)) == NULL ) + { + msg_Err( p_input, "no new packet" ); + p_input->b_error = 1; + return; + } + + memset( p_pad_data->p_payload_start, 0, PADDING_PACKET_SIZE ); + p_pad_data->b_discard_payload = 1; + p_pes = p_es->p_pes; + + if( p_pes != NULL ) + { + p_pes->b_discontinuity = 1; + p_pes->p_last->p_next = p_pad_data; + p_pes->p_last = p_pad_data; + p_pes->i_nb_data++; + } + else + { + if( (p_pes = input_NewPES( p_input->p_method_data )) == NULL ) + { + msg_Err( p_input, "no PES packet" ); + p_input->b_error = 1; + return; + } + + p_pes->i_rate = p_input->stream.control.i_rate; + p_pes->p_first = p_pes->p_last = p_pad_data; + p_pes->i_nb_data = 1; + p_pes->b_discontinuity = 1; + input_DecodePES( p_es->p_decoder_fifo, p_pes ); + } +} + /***************************************************************************** * input_EscapeDiscontinuity: send a NULL packet to the decoders *****************************************************************************/ void input_EscapeDiscontinuity( input_thread_t * p_input ) { - int i_es, i; + unsigned int i_es, i; for( i_es = 0; i_es < p_input->stream.i_selected_es_number; i_es++ ) { @@ -251,7 +356,7 @@ void input_EscapeDiscontinuity( input_thread_t * p_input ) *****************************************************************************/ void input_EscapeAudioDiscontinuity( input_thread_t * p_input ) { - int i_es, i; + unsigned int i_es, i; for( i_es = 0; i_es < p_input->stream.i_selected_es_number; i_es++ ) { @@ -296,8 +401,9 @@ static decoder_fifo_t * CreateDecoderFifo( input_thread_t * p_input, p_fifo->i_id = p_es->i_id; p_fifo->i_fourcc = p_es->i_fourcc; - p_fifo->p_demux_data = p_es->p_demux_data; - + p_fifo->p_demux_data = p_es->p_demux_data; + p_fifo->p_waveformatex = p_es->p_waveformatex; + p_fifo->p_bitmapinfoheader = p_es->p_bitmapinfoheader; p_fifo->p_stream_ctrl = &p_input->stream.control; p_fifo->p_sout = p_input->stream.p_sout;