/*****************************************************************************
* copy.c
*****************************************************************************
- * Copyright (C) 2001, 2002 VideoLAN
- * $Id: copy.c,v 1.22 2004/01/25 17:41:30 murray Exp $
+ * Copyright (C) 2001, 2002, 2006 the VideoLAN team
+ * $Id$
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Eric Petit <titer@videolan.org>
*
* 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 <stdlib.h> /* malloc(), free() */
-#include <vlc/vlc.h>
-#include <vlc/decoder.h>
-#include <vlc/input.h>
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
+#include <vlc_plugin.h>
+#include <vlc_codec.h>
+#include <vlc_block.h>
/*****************************************************************************
* Module descriptor
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();
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
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 */
- memcpy( &p_dec->fmt_out, &p_dec->fmt_in, sizeof( es_format_t ) );
- if( p_dec->fmt_in.i_extra > 0 )
- {
- p_dec->fmt_out.p_extra = malloc( p_dec->fmt_in.i_extra );
- memcpy( p_dec->fmt_out.p_extra, p_dec->fmt_in.p_extra,
- p_dec->fmt_in.i_extra );
- }
+ es_format_Copy( &p_dec->fmt_out, &p_dec->fmt_in );
/* Fix the value of the fourcc */
switch( p_dec->fmt_in.i_codec )
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 )
{
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;
- if( p_block->i_pts <= 0 )
- {
- p_block->i_pts = p_block->i_dts;
- }
- else if( p_block->i_dts <= 0 )
+ if( p_block->i_dts <= 0 )
{
p_block->i_dts = p_block->i_pts;
}
- if( p_block->i_pts <= 0 )
+ if( p_block->i_dts <= 0 )
{
- msg_Dbg( p_dec, "need pts > 0" );
+ msg_Dbg( p_dec, "need dts > 0" );
block_Release( p_block );
return NULL;
}
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;
+}