X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fpacketizer%2Fcopy.c;h=e62ce1bdd250eba1a4f165cb16694d27002d9068;hb=62dd14548820fb0966e6b90d586183f74a427e4b;hp=24b8465681cbc34487eee80cdd500567a80b5b2b;hpb=4efefb826ef40d9cea26919b245d81e2976d1bd1;p=vlc diff --git a/modules/packetizer/copy.c b/modules/packetizer/copy.c index 24b8465681..e62ce1bdd2 100644 --- a/modules/packetizer/copy.c +++ b/modules/packetizer/copy.c @@ -1,7 +1,7 @@ /***************************************************************************** * copy.c ***************************************************************************** - * Copyright (C) 2001, 2002 VideoLAN + * Copyright (C) 2001, 2002, 2006 the VideoLAN team * $Id$ * * Authors: Laurent Aimar @@ -19,17 +19,21 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ /***************************************************************************** * Preamble *****************************************************************************/ -#include /* malloc(), free() */ -#include -#include -#include +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include +#include +#include /***************************************************************************** * Module descriptor @@ -38,7 +42,9 @@ static int Open ( vlc_object_t * ); static void Close( vlc_object_t * ); vlc_module_begin(); - set_description( _("Copy packetizer") ); + set_category( CAT_SOUT ); + set_subcategory( SUBCAT_SOUT_PACKETIZER ); + set_description( N_("Copy packetizer") ); set_capability( "packetizer", 1 ); set_callbacks( Open, Close ); vlc_module_end(); @@ -51,7 +57,8 @@ struct decoder_sys_t block_t *p_block; }; -static block_t *Packetize ( decoder_t *, block_t ** ); +static block_t *Packetize ( decoder_t *, block_t ** ); +static block_t *PacketizeSub( decoder_t *, block_t ** ); /***************************************************************************** * Open: probe the packetizer and return score @@ -72,7 +79,10 @@ static int Open( vlc_object_t *p_this ) return VLC_EGENERIC; } - p_dec->pf_packetize = Packetize; + if( p_dec->fmt_in.i_cat == SPU_ES ) + p_dec->pf_packetize = PacketizeSub; + else + p_dec->pf_packetize = Packetize; /* Create the output format */ es_format_Copy( &p_dec->fmt_out, &p_dec->fmt_in ); @@ -237,11 +247,12 @@ static void Close( vlc_object_t *p_this ) block_ChainRelease( p_dec->p_sys->p_block ); } + es_format_Clean( &p_dec->fmt_out ); free( p_dec->p_sys ); } /***************************************************************************** - * PacketizeStd: packetize an unit (here copy a complete block ) + * Packetize: packetize an unit (here copy a complete block ) *****************************************************************************/ static block_t *Packetize ( decoder_t *p_dec, block_t **pp_block ) { @@ -249,9 +260,13 @@ static block_t *Packetize ( decoder_t *p_dec, block_t **pp_block ) block_t *p_ret = p_dec->p_sys->p_block; if( pp_block == NULL || *pp_block == NULL ) + return NULL; + if( (*pp_block)->i_flags&(BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) ) { + block_Release( *pp_block ); return NULL; } + p_block = *pp_block; *pp_block = NULL; @@ -275,3 +290,36 @@ static block_t *Packetize ( decoder_t *p_dec, block_t **pp_block ) return p_ret; } + +/***************************************************************************** + * PacketizeSub: packetize an unit (here copy a complete block ) + *****************************************************************************/ +static block_t *PacketizeSub( decoder_t *p_dec, block_t **pp_block ) +{ + block_t *p_block; + + if( pp_block == NULL || *pp_block == NULL ) + return NULL; + if( (*pp_block)->i_flags&(BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) ) + { + block_Release( *pp_block ); + return NULL; + } + + p_block = *pp_block; + *pp_block = NULL; + + if( p_block->i_dts <= 0 ) + { + p_block->i_dts = p_block->i_pts; + } + + if( p_block->i_dts <= 0 ) + { + msg_Dbg( p_dec, "need dts > 0" ); + block_Release( p_block ); + return NULL; + } + + return p_block; +}