Commit 28a40173 authored by Laurent Aimar's avatar Laurent Aimar

* asf : trying to fix pts handling.

parent 27975a94
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* asf.c : ASFv01 file input module for vlc * asf.c : ASFv01 file input module for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: asf.c,v 1.19 2003/01/29 21:54:34 fenrir Exp $ * $Id: asf.c,v 1.20 2003/02/01 01:21:04 fenrir Exp $
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -103,7 +103,6 @@ static int Activate( vlc_object_t * p_this ) ...@@ -103,7 +103,6 @@ static int Activate( vlc_object_t * p_this )
return( -1 ); return( -1 );
} }
memset( p_demux, 0, sizeof( demux_sys_t ) ); memset( p_demux, 0, sizeof( demux_sys_t ) );
p_demux->i_first_pts = -1;
/* Now load all object ( except raw data ) */ /* Now load all object ( except raw data ) */
if( !ASF_ReadObjectRoot( p_input, &p_demux->root, p_input->stream.b_seekable ) ) if( !ASF_ReadObjectRoot( p_input, &p_demux->root, p_input->stream.b_seekable ) )
...@@ -417,6 +416,33 @@ static int Activate( vlc_object_t * p_this ) ...@@ -417,6 +416,33 @@ static int Activate( vlc_object_t * p_this )
return( 0 ); return( 0 );
} }
static mtime_t GetMoviePTS( demux_sys_t *p_demux )
{
mtime_t i_time;
int i_stream;
i_time = -1;
for( i_stream = 0; i_stream < 128 ; i_stream++ )
{
#define p_stream p_demux->stream[i_stream]
if( p_stream && p_stream->p_es && p_stream->p_es->p_decoder_fifo && p_stream->i_time > 0)
{
if( i_time < 0 )
{
i_time = p_stream->i_time;
}
else
{
i_time = __MIN( i_time, p_stream->i_time );
}
}
#undef p_stream
}
return( i_time );
}
/***************************************************************************** /*****************************************************************************
* Demux: read packet and send them to decoders * Demux: read packet and send them to decoders
*****************************************************************************/ *****************************************************************************/
...@@ -668,18 +694,12 @@ static int DemuxPacket( input_thread_t *p_input, vlc_bool_t b_play_audio ) ...@@ -668,18 +694,12 @@ static int DemuxPacket( input_thread_t *p_input, vlc_bool_t b_play_audio )
p_stream->i_time = p_stream->i_time =
( (mtime_t)i_pts + i_payload * (mtime_t)i_pts_delta ); ( (mtime_t)i_pts + i_payload * (mtime_t)i_pts_delta );
if( p_demux->i_first_pts == -1 )
{
p_demux->i_first_pts = p_stream->i_time;
}
p_stream->i_time -= p_demux->i_first_pts;
p_stream->p_pes = input_NewPES( p_input->p_method_data ); p_stream->p_pes = input_NewPES( p_input->p_method_data );
p_stream->p_pes->i_dts = p_stream->p_pes->i_dts =
p_stream->p_pes->i_pts = p_stream->p_pes->i_pts =
input_ClockGetTS( p_input, input_ClockGetTS( p_input,
p_input->stream.p_selected_program, p_input->stream.p_selected_program,
( p_stream->i_time+DEFAULT_PTS_DELAY) * 9 /100 ); p_stream->i_time * 9 /100 );
p_stream->p_pes->p_next = NULL; p_stream->p_pes->p_next = NULL;
p_stream->p_pes->i_nb_data = 0; p_stream->p_pes->i_nb_data = 0;
...@@ -754,6 +774,7 @@ static int Demux( input_thread_t *p_input ) ...@@ -754,6 +774,7 @@ static int Demux( input_thread_t *p_input )
if( p_input->stream.p_selected_program->i_synchro_state == SYNCHRO_REINIT ) if( p_input->stream.p_selected_program->i_synchro_state == SYNCHRO_REINIT )
{ {
off_t i_offset; off_t i_offset;
msleep( DEFAULT_PTS_DELAY ); msleep( DEFAULT_PTS_DELAY );
i_offset = ASF_TellAbsolute( p_input ) - p_demux->i_data_begin; i_offset = ASF_TellAbsolute( p_input ) - p_demux->i_data_begin;
...@@ -766,17 +787,16 @@ static int Demux( input_thread_t *p_input ) ...@@ -766,17 +787,16 @@ static int Demux( input_thread_t *p_input )
i_offset % p_demux->p_fp->i_min_data_packet_size; i_offset % p_demux->p_fp->i_min_data_packet_size;
ASF_SeekAbsolute( p_input, p_demux->i_data_begin + i_offset ); ASF_SeekAbsolute( p_input, p_demux->i_data_begin + i_offset );
p_demux->i_time = 0; p_demux->i_time = -1;
for( i = 0; i < 128 ; i++ ) for( i = 0; i < 128 ; i++ )
{ {
#define p_stream p_demux->stream[i] #define p_stream p_demux->stream[i]
if( p_stream ) if( p_stream )
{ {
p_stream->i_time = 0; p_stream->i_time = -1;
} }
#undef p_stream #undef p_stream
} }
p_demux->i_first_pts = -1;
} }
vlc_mutex_lock( &p_input->stream.stream_lock ); vlc_mutex_lock( &p_input->stream.stream_lock );
...@@ -803,39 +823,35 @@ static int Demux( input_thread_t *p_input ) ...@@ -803,39 +823,35 @@ static int Demux( input_thread_t *p_input )
} }
vlc_mutex_unlock( &p_input->stream.stream_lock ); vlc_mutex_unlock( &p_input->stream.stream_lock );
for( ;; )
for( i = 0; i < 10; i++ ) // parse 10 packets
{ {
mtime_t i_length;
mtime_t i_time_begin = GetMoviePTS( p_demux );
int i_result; int i_result;
if( ( i_result = DemuxPacket( p_input, b_play_audio ) ) <= 0 ) if( ( i_result = DemuxPacket( p_input, b_play_audio ) ) <= 0 )
{ {
return i_result; return i_result;
} }
} if( i_time_begin == -1 )
p_demux->i_time = -1;
for( i = 0; i < 128 ; i++ )
{
#define p_stream p_demux->stream[i]
if( p_stream && p_stream->p_es && p_stream->p_es->p_decoder_fifo )
{ {
if( p_demux->i_time < 0 ) i_time_begin = GetMoviePTS( p_demux );
{ }
p_demux->i_time = p_stream->i_time; else
} {
else i_length = GetMoviePTS( p_demux ) - i_time_begin;
if( i_length < 0 || i_length >= 40 * 1000 )
{ {
p_demux->i_time = __MIN( p_demux->i_time, p_stream->i_time ); break;
} }
} }
#undef p_stream
} }
p_demux->i_time = GetMoviePTS( p_demux );
if( p_demux->i_time >= 0 ) if( p_demux->i_time >= 0 )
{ {
/* update pcr XXX in mpeg scale so in 90000 unit/s */ /* update pcr XXX in mpeg scale so in 90000 unit/s */
p_demux->i_pcr =( __MAX( p_demux->i_time /*- DEFAULT_PTS_DELAY*/, 0 ) ) * 9 / 100; p_demux->i_pcr = p_demux->i_time * 9 / 100;
/* first wait for the good time to read next packets */ /* first wait for the good time to read next packets */
input_ClockManageRef( p_input, input_ClockManageRef( p_input,
...@@ -843,7 +859,6 @@ static int Demux( input_thread_t *p_input ) ...@@ -843,7 +859,6 @@ static int Demux( input_thread_t *p_input )
p_demux->i_pcr ); p_demux->i_pcr );
} }
return( 1 ); return( 1 );
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* asf.h : ASFv01 file input module for vlc * asf.h : ASFv01 file input module for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: asf.h,v 1.2 2002/11/14 16:17:47 fenrir Exp $ * $Id: asf.h,v 1.3 2003/02/01 01:21:04 fenrir Exp $
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -34,18 +34,16 @@ typedef struct asf_stream_s ...@@ -34,18 +34,16 @@ typedef struct asf_stream_s
struct demux_sys_t struct demux_sys_t
{ {
mtime_t i_first_pts;
mtime_t i_pcr; // 1/90000 s mtime_t i_pcr; // 1/90000 s
mtime_t i_time; // µs mtime_t i_time; // µs
asf_object_root_t root; asf_object_root_t root;
asf_object_file_properties_t *p_fp; asf_object_file_properties_t *p_fp;
int i_streams; int i_streams;
asf_stream_t *stream[128]; asf_stream_t *stream[128];
off_t i_data_begin; off_t i_data_begin;
off_t i_data_end; off_t i_data_end;
}; };
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment