/*****************************************************************************
* mpeg4video.c: mpeg 4 video packetizer
*****************************************************************************
- * Copyright (C) 2001-2006 the VideoLAN team
+ * Copyright (C) 2001-2006 VLC authors and VideoLAN
* $Id$
*
* Authors: Gildas Bazin <gbazin@videolan.org>
* Laurent Aimar <fenrir@via.ecp.fr>
* Eric Petit <titer@videolan.org>
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 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
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
*
- * 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
#include <vlc_codec.h>
#include <vlc_block.h>
-#include "vlc_bits.h"
-#include "vlc_block_helper.h"
+#include <vlc_bits.h>
+#include <vlc_block_helper.h>
#include "packetizer_helper.h"
/*****************************************************************************
/* Misc init */
packetizer_Init( &p_sys->packetizer,
p_mp4v_startcode, sizeof(p_mp4v_startcode),
- NULL, 0,
+ NULL, 0, 4,
PacketizeReset, PacketizeParse, PacketizeValidate, p_dec );
p_sys->p_frame = NULL;
es_format_Copy( &p_dec->fmt_out, &p_dec->fmt_in );
p_dec->fmt_out.i_codec = VLC_CODEC_MP4V;
+ free(p_dec->fmt_out.p_extra);
+
if( p_dec->fmt_in.i_extra )
{
/* We have a vol */
p_dec->fmt_out.i_extra = p_dec->fmt_in.i_extra;
- p_dec->fmt_out.p_extra = malloc( p_dec->fmt_in.i_extra );
+ p_dec->fmt_out.p_extra = xmalloc( 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 );
p_sys->i_interpolated_pts =
p_sys->i_interpolated_dts =
- p_sys->i_last_ref_pts =
+ p_sys->i_last_ref_pts = VLC_TS_INVALID;
+
p_sys->i_last_time_ref =
p_sys->i_time_ref =
p_sys->i_last_time =
/* We've just started the stream, wait for the first PTS.
* We discard here so we can still get the sequence header. */
- if( p_sys->i_interpolated_pts <= 0 &&
- p_sys->i_interpolated_dts <= 0 )
+ if( p_sys->i_interpolated_pts <= VLC_TS_INVALID &&
+ p_sys->i_interpolated_dts <= VLC_TS_INVALID )
{
msg_Dbg( p_dec, "need a starting pts/dts" );
return VLC_EGENERIC;
if( (size_t)p_dec->fmt_out.i_extra != p_frag->i_buffer )
{
p_dec->fmt_out.p_extra =
- realloc( p_dec->fmt_out.p_extra, p_frag->i_buffer );
+ xrealloc( p_dec->fmt_out.p_extra, p_frag->i_buffer );
p_dec->fmt_out.i_extra = p_frag->i_buffer;
}
memcpy( p_dec->fmt_out.p_extra, p_frag->p_buffer, p_frag->i_buffer );
p_sys->i_last_timeincr = i_time_increment;
/* Correct interpolated dts when we receive a new pts/dts */
- if( p_vop->i_pts > 0 )
+ if( p_vop->i_pts > VLC_TS_INVALID )
p_sys->i_interpolated_pts = p_vop->i_pts;
- if( p_vop->i_dts > 0 )
+ if( p_vop->i_dts > VLC_TS_INVALID )
p_sys->i_interpolated_dts = p_vop->i_dts;
if( (p_sys->i_flags & BLOCK_FLAG_TYPE_B) || !p_sys->b_frame )
p_sys->i_interpolated_dts = p_sys->i_interpolated_pts;
- if( p_vop->i_pts > 0 )
+ if( p_vop->i_pts > VLC_TS_INVALID )
p_sys->i_interpolated_dts = p_vop->i_pts;
- if( p_vop->i_dts > 0 )
+ if( p_vop->i_dts > VLC_TS_INVALID )
p_sys->i_interpolated_dts = p_vop->i_dts;
p_sys->i_interpolated_pts = p_sys->i_interpolated_dts;
}
else
{
- if( p_sys->i_last_ref_pts > 0 )
+ if( p_sys->i_last_ref_pts > VLC_TS_INVALID )
p_sys->i_interpolated_dts = p_sys->i_last_ref_pts;
p_sys->i_last_ref_pts = p_sys->i_interpolated_pts;