/*****************************************************************************
* mpeg4video.c: mpeg 4 video packetizer
*****************************************************************************
- * Copyright (C) 2001, 2002 VideoLAN
+ * Copyright (C) 2001, 2002 the VideoLAN team
* $Id$
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
#include <vlc/vlc.h>
#include <vlc/decoder.h>
#include <vlc/sout.h>
+#include <vlc/input.h> /* hmmm, just for INPUT_RATE_DEFAULT */
#include "vlc_bits.h"
case VLC_FOURCC( 'm', 'p', '4', 's'):
case VLC_FOURCC( 'M', 'P', '4', 'S'):
case VLC_FOURCC( 'm', 'p', '4', 'v'):
+ case VLC_FOURCC( 'M', 'P', '4', 'V'):
case VLC_FOURCC( 'D', 'I', 'V', 'X'):
case VLC_FOURCC( 'd', 'i', 'v', 'x'):
case VLC_FOURCC( 'X', 'V', 'I', 'D'):
if( p_sys->i_buffer > 10*1000000 )
{
- msg_Err( p_dec, "mmh reseting context" );
+ msg_Warn( p_dec, "reseting context" );
p_sys->i_buffer = 0;
}
if( p_vol )
{
- /* Copy the complete VOL */
- p_dec->fmt_out.i_extra = p_start - p_vol;
- p_dec->fmt_out.p_extra =
- realloc( p_dec->fmt_out.p_extra, p_dec->fmt_out.i_extra );
- memcpy( p_dec->fmt_out.p_extra, p_vol, p_dec->fmt_out.i_extra );
- m4v_VOLParse( p_dec, &p_dec->fmt_out,
- p_dec->fmt_out.p_extra, p_dec->fmt_out.i_extra );
+ if( !p_dec->fmt_out.i_extra )
+ {
+ /* Copy the complete VOL */
+ p_dec->fmt_out.i_extra = p_start - p_vol;
+ p_dec->fmt_out.p_extra =
+ realloc( p_dec->fmt_out.p_extra, p_dec->fmt_out.i_extra );
+ memcpy( p_dec->fmt_out.p_extra, p_vol,
+ p_dec->fmt_out.i_extra );
+ m4v_VOLParse( p_dec, &p_dec->fmt_out,
+ p_dec->fmt_out.p_extra, p_dec->fmt_out.i_extra );
+ }
+
+ /* Remove VOL from the original stream */
+ memmove( p_vol, p_start,
+ p_sys->i_buffer - (p_start - p_sys->p_buffer) );
+ p_sys->i_buffer -= p_dec->fmt_out.i_extra;
+ p_start = p_vol;
p_vol = NULL;
}
(i_modulo_time_base * p_dec->p_sys->i_fps_num);
}
- p_sys->i_interpolated_pts +=
- ( (i_time_ref + i_time_increment -
- p_sys->i_last_time - p_sys->i_last_timeincr) *
- I64C(1000000) / p_dec->p_sys->i_fps_num );
+ if( p_dec->p_sys->i_fps_num < 5 && /* Work-around buggy streams */
+ p_dec->fmt_in.video.i_frame_rate > 0 &&
+ p_dec->fmt_in.video.i_frame_rate_base > 0 )
+ {
+ p_sys->i_interpolated_pts += I64C(1000000) *
+ p_dec->fmt_in.video.i_frame_rate_base *
+ p_block->i_rate / INPUT_RATE_DEFAULT /
+ p_dec->fmt_in.video.i_frame_rate;
+ }
+ else if( p_dec->p_sys->i_fps_num )
+ p_sys->i_interpolated_pts +=
+ ( I64C(1000000) * (i_time_ref + i_time_increment -
+ p_sys->i_last_time - p_sys->i_last_timeincr) *
+ p_block->i_rate / INPUT_RATE_DEFAULT /
+ p_dec->p_sys->i_fps_num );
p_sys->i_last_time = i_time_ref;
p_sys->i_last_timeincr = i_time_increment;