Commit 6cd56a27 authored by Laurent Aimar's avatar Laurent Aimar

asf/* : Convert all u* into uint*_t

         Fix playing of some live asf, seek improvement (at least for me ;)
but it's more some "kludge" with vlc clock than true fixes ...

 I will never understand how vlc clock works ....
parent 3d6b672b
......@@ -2,7 +2,7 @@
* asf.c : ASFv01 file input module for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: asf.c,v 1.4 2002/11/10 16:31:20 fenrir Exp $
* $Id: asf.c,v 1.5 2002/11/14 16:17:47 fenrir Exp $
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
......@@ -51,11 +51,11 @@ vlc_module_begin();
add_shortcut( "asf" );
vlc_module_end();
static u16 GetWLE( u8 *p_buff )
static uint16_t GetWLE( uint8_t *p_buff )
{
return( (p_buff[0]) + ( p_buff[1] <<8 ) );
}
static u32 GetDWLE( u8 *p_buff )
static uint32_t GetDWLE( uint8_t *p_buff )
{
return( p_buff[0] + ( p_buff[1] <<8 ) +
( p_buff[2] <<16 ) + ( p_buff[3] <<24 ) );
......@@ -66,12 +66,12 @@ static u32 GetDWLE( u8 *p_buff )
*****************************************************************************/
static int Activate( vlc_object_t * p_this )
{
input_thread_t *p_input = (input_thread_t *)p_this;
u8 *p_peek;
guid_t guid;
input_thread_t *p_input = (input_thread_t *)p_this;
uint8_t *p_peek;
guid_t guid;
demux_sys_t *p_demux;
int i_stream;
demux_sys_t *p_demux;
int i_stream;
/* Initialize access plug-in structures. */
if( p_input->i_mtu == 0 )
......@@ -103,6 +103,7 @@ static int Activate( vlc_object_t * p_this )
return( -1 );
}
memset( p_demux, 0, sizeof( demux_sys_t ) );
p_demux->i_first_pts = -1;
/* Now load all object ( except raw data ) */
if( !ASF_ReadObjectRoot( p_input, &p_demux->root, p_input->stream.b_seekable ) )
......@@ -284,7 +285,10 @@ static int Activate( vlc_object_t * p_this )
p_stream->p_es->i_cat = p_stream->i_cat;
vlc_mutex_lock( &p_input->stream.stream_lock );
input_SelectES( p_input, p_stream->p_es );
if( p_stream->p_es->i_fourcc != VLC_FOURCC( 'u','n','d','f' ) )
{
input_SelectES( p_input, p_stream->p_es );
}
vlc_mutex_unlock( &p_input->stream.stream_lock );
}
......@@ -331,7 +335,7 @@ static int Demux( input_thread_t *p_input )
if( p_input->stream.p_selected_program->i_synchro_state == SYNCHRO_REINIT )
{
off_t i_offset;
msleep( DEFAULT_PTS_DELAY );
i_offset = ASF_TellAbsolute( p_input ) - p_demux->i_data_begin;
if( i_offset < 0 )
......@@ -352,37 +356,29 @@ static int Demux( input_thread_t *p_input )
}
#undef p_stream
}
}
/* first wait for the good time to read a packet */
input_ClockManageRef( p_input,
p_input->stream.p_selected_program,
p_demux->i_pcr );
/* update pcr XXX in mpeg scale so in 90000 unit/s */
p_demux->i_pcr = p_demux->i_time * 9 / 100;
for( i = 0; i < 10; i++ ) // parse 10 packets
{
int i_data_packet_min = p_demux->p_fp->i_min_data_packet_size;
u8 *p_peek;
int i_skip;
int i_data_packet_min = p_demux->p_fp->i_min_data_packet_size;
uint8_t *p_peek;
int i_skip;
int i_packet_size_left;
int i_packet_flags;
int i_packet_property;
int b_packet_multiple_payload;
int i_packet_length;
int i_packet_sequence;
int i_packet_padding_length;
int i_packet_size_left;
int i_packet_flags;
int i_packet_property;
int b_packet_multiple_payload;
int i_packet_length;
int i_packet_sequence;
int i_packet_padding_length;
u32 i_packet_send_time;
u16 i_packet_duration;
int i_payload;
int i_payload_count;
int i_payload_length_type;
uint32_t i_packet_send_time;
uint16_t i_packet_duration;
int i_payload;
int i_payload_count;
int i_payload_length_type;
if( input_Peek( p_input, &p_peek, i_data_packet_min ) < i_data_packet_min )
......@@ -482,7 +478,7 @@ static int Demux( input_thread_t *p_input )
else if( i_replicated_data_length == 1 )
{
msg_Warn( p_input, "found compressed payload" );
msg_Dbg( p_input, "found compressed payload" );
i_pts = (mtime_t)i_tmp * 1000;
i_pts_delta = (mtime_t)p_peek[i_skip] * 1000; i_skip++;
......@@ -498,15 +494,14 @@ static int Demux( input_thread_t *p_input )
}
i_pts = __MAX( i_pts - p_demux->p_fp->i_preroll * 1000, 0 );
if( b_packet_multiple_payload )
{
GETVALUE2b( i_payload_length_type, i_payload_data_length, 0 );
}
else
{
msg_Warn( p_input, "single payload" );
i_payload_data_length = i_packet_length - i_packet_padding_length - i_skip;
i_payload_data_length = i_packet_length -
i_packet_padding_length - i_skip;
}
#if 0
......@@ -523,7 +518,8 @@ static int Demux( input_thread_t *p_input )
if( !( p_stream = p_demux->stream[i_stream_number] ) )
{
msg_Warn( p_input, "undeclared stream[Id 0x%x]", i_stream_number );
msg_Warn( p_input,
"undeclared stream[Id 0x%x]", i_stream_number );
i_skip += i_payload_data_length;
continue; // over payload
}
......@@ -565,14 +561,21 @@ static int Demux( input_thread_t *p_input )
if( !p_stream->p_pes ) // add a new PES
{
p_stream->i_time = ( (mtime_t)i_pts + i_payload * (mtime_t)i_pts_delta );
p_stream->i_time =
( (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->i_dts =
p_stream->p_pes->i_pts =
input_ClockGetTS( p_input,
p_input->stream.p_selected_program,
p_stream->i_time * 9 / 100 );
( p_stream->i_time+DEFAULT_PTS_DELAY) * 9 /100 );
p_stream->p_pes->p_next = NULL;
p_stream->p_pes->i_nb_data = 0;
......@@ -635,17 +638,36 @@ loop_error_recovery:
ASF_SkipBytes( p_input, i_data_packet_min );
} // loop over packet
p_demux->i_time = 0;
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 )
{
p_demux->i_time = __MAX( p_demux->i_time, p_stream->i_time );
if( p_demux->i_time < 0 )
{
p_demux->i_time = p_stream->i_time;
}
else
{
p_demux->i_time = __MIN( p_demux->i_time, p_stream->i_time );
}
}
#undef p_stream
}
if( p_demux->i_time >= 0 )
{
/* 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;
/* first wait for the good time to read next packets */
input_ClockManageRef( p_input,
p_input->stream.p_selected_program,
p_demux->i_pcr );
}
return( 1 );
}
......
......@@ -2,7 +2,7 @@
* asf.h : ASFv01 file input module for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: asf.h,v 1.1 2002/10/20 17:22:33 fenrir Exp $
* $Id: asf.h,v 1.2 2002/11/14 16:17:47 fenrir Exp $
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
......@@ -34,6 +34,7 @@ typedef struct asf_stream_s
struct demux_sys_t
{
mtime_t i_first_pts;
mtime_t i_pcr; // 1/90000 s
mtime_t i_time; // µs
......
......@@ -2,7 +2,7 @@
* libasf.c :
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: libasf.c,v 1.5 2002/11/10 16:31:20 fenrir Exp $
* $Id: libasf.c,v 1.6 2002/11/14 16:17:47 fenrir Exp $
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
......@@ -44,23 +44,24 @@
(guid).v4[4],(guid).v4[5],(guid).v4[6],(guid).v4[7]
/* Some functions to manipulate memory */
static u16 GetWLE( u8 *p_buff )
static uint16_t GetWLE( uint8_t *p_buff )
{
return( (p_buff[0]) + ( p_buff[1] <<8 ) );
}
static u32 GetDWLE( u8 *p_buff )
static uint32_t GetDWLE( uint8_t *p_buff )
{
return( p_buff[0] + ( p_buff[1] <<8 ) +
( p_buff[2] <<16 ) + ( p_buff[3] <<24 ) );
}
static u64 GetQWLE( u8 *p_buff )
static uint64_t GetQWLE( uint8_t *p_buff )
{
return( ( (u64)GetDWLE( p_buff ) )|( (u64)GetDWLE( p_buff + 4 ) << 32) );
return( ( (uint64_t)GetDWLE( p_buff ) )|
( (uint64_t)GetDWLE( p_buff + 4 ) << 32) );
}
void GetGUID( guid_t *p_guid, u8 *p_data )
void GetGUID( guid_t *p_guid, uint8_t *p_data )
{
p_guid->v1 = GetDWLE( p_data );
p_guid->v2 = GetWLE( p_data + 4);
......@@ -116,7 +117,7 @@ int ASF_SeekAbsolute( input_thread_t *p_input,
return( 1 );
}
if( p_input->stream.b_seekable &&
if( p_input->stream.b_seekable &&
p_input->stream.i_method != INPUT_METHOD_NETWORK )
{
p_input->pf_seek( p_input, i_pos );
......@@ -125,7 +126,7 @@ int ASF_SeekAbsolute( input_thread_t *p_input,
}
else if( i_pos > i_filepos )
{
u64 i_size = i_pos - i_filepos;
uint64_t i_size = i_pos - i_filepos;
do
{
data_packet_t *p_data;
......@@ -152,7 +153,7 @@ int ASF_SeekAbsolute( input_thread_t *p_input,
}
/* return 1 if success, 0 if fail */
int ASF_ReadData( input_thread_t *p_input, u8 *p_buff, int i_size )
int ASF_ReadData( input_thread_t *p_input, uint8_t *p_buff, int i_size )
{
data_packet_t *p_data;
......@@ -193,7 +194,7 @@ int ASF_ReadObjectCommon( input_thread_t *p_input,
asf_object_t *p_obj )
{
asf_object_common_t *p_common = (asf_object_common_t*)p_obj;
u8 *p_peek;
uint8_t *p_peek;
if( input_Peek( p_input, &p_peek, 24 ) < 24 )
{
......@@ -266,9 +267,9 @@ int ASF_ReadObject_Header( input_thread_t *p_input,
asf_object_t *p_obj )
{
asf_object_header_t *p_hdr = (asf_object_header_t*)p_obj;
asf_object_t *p_subobj;
int i_peek;
u8 *p_peek;
asf_object_t *p_subobj;
int i_peek;
uint8_t *p_peek;
if( ( i_peek = input_Peek( p_input, &p_peek, 30 ) ) < 30 )
{
......@@ -308,8 +309,8 @@ int ASF_ReadObject_Data( input_thread_t *p_input,
asf_object_t *p_obj )
{
asf_object_data_t *p_data = (asf_object_data_t*)p_obj;
int i_peek;
u8 *p_peek;
int i_peek;
uint8_t *p_peek;
if( ( i_peek = input_Peek( p_input, &p_peek, 50 ) ) < 50 )
{
......@@ -333,8 +334,8 @@ int ASF_ReadObject_Index( input_thread_t *p_input,
asf_object_t *p_obj )
{
asf_object_index_t *p_index = (asf_object_index_t*)p_obj;
int i_peek;
u8 *p_peek;
int i_peek;
uint8_t *p_peek;
if( ( i_peek = input_Peek( p_input, &p_peek, 56 ) ) < 56 )
{
......@@ -369,8 +370,8 @@ int ASF_ReadObject_file_properties( input_thread_t *p_input,
asf_object_t *p_obj )
{
asf_object_file_properties_t *p_fp = (asf_object_file_properties_t*)p_obj;
int i_peek;
u8 *p_peek;
int i_peek;
uint8_t *p_peek;
if( ( i_peek = input_Peek( p_input, &p_peek, 92) ) < 92 )
{
......@@ -414,8 +415,8 @@ int ASF_ReadObject_header_extention( input_thread_t *p_input,
asf_object_t *p_obj )
{
asf_object_header_extention_t *p_he = (asf_object_header_extention_t*)p_obj;
int i_peek;
u8 *p_peek;
int i_peek;
uint8_t *p_peek;
if( ( i_peek = input_Peek( p_input, &p_peek, p_he->i_object_size ) ) < 46)
{
......@@ -457,8 +458,8 @@ int ASF_ReadObject_stream_properties( input_thread_t *p_input,
{
asf_object_stream_properties_t *p_sp =
(asf_object_stream_properties_t*)p_obj;
int i_peek;
u8 *p_peek;
int i_peek;
uint8_t *p_peek;
if( ( i_peek = input_Peek( p_input, &p_peek, p_sp->i_object_size ) ) < 74 )
{
......@@ -528,8 +529,8 @@ int ASF_ReadObject_codec_list( input_thread_t *p_input,
asf_object_t *p_obj )
{
asf_object_codec_list_t *p_cl = (asf_object_codec_list_t*)p_obj;
int i_peek;
u8 *p_peek, *p_data;
int i_peek;
uint8_t *p_peek, *p_data;
int i_codec;
......@@ -638,9 +639,10 @@ void ASF_FreeObject_codec_list( input_thread_t *p_input,
int ASF_ReadObject_content_description( input_thread_t *p_input,
asf_object_t *p_obj )
{
asf_object_content_description_t *p_cd = (asf_object_content_description_t*)p_obj;
int i_peek;
u8 *p_peek, *p_data;
asf_object_content_description_t *p_cd =
(asf_object_content_description_t*)p_obj;
int i_peek;
uint8_t *p_peek, *p_data;
int i_len;
int i_title;
......
......@@ -2,7 +2,7 @@
* libasf.h :
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: libasf.h,v 1.3 2002/11/05 10:07:56 gbazin Exp $
* $Id: libasf.h,v 1.4 2002/11/14 16:17:47 fenrir Exp $
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
......@@ -27,10 +27,10 @@
*****************************************************************************/
typedef struct guid_s
{
u32 v1; /* le */
u16 v2; /* le */
u16 v3; /* le */
u8 v4[8];
uint32_t v1; /* le */
uint16_t v2; /* le */
uint16_t v3; /* le */
uint8_t v4[8];
} guid_t;
#define ASF_OBJECT_TYPE_NULL 0x0000
......@@ -189,8 +189,8 @@ typedef struct asf_object_common_s
typedef struct asf_index_entry_s
{
u32 i_packet_number;
u16 i_packet_count;
uint32_t i_packet_number;
uint16_t i_packet_count;
} asf_index_entry_t;
......@@ -202,18 +202,18 @@ typedef struct asf_index_entry_s
typedef struct asf_object_header_s
{
ASF_OBJECT_COMMON
u32 i_sub_object_count;
u8 i_reserved1; /* 0x01, but could be safely ignored */
u8 i_reserved2; /* 0x02, if not must failed to source the contain */
uint32_t i_sub_object_count;
uint8_t i_reserved1; /* 0x01, but could be safely ignored */
uint8_t i_reserved2; /* 0x02, if not must failed to source the contain */
} asf_object_header_t;
typedef struct asf_object_data_s
{
ASF_OBJECT_COMMON
guid_t i_file_id;
u64 i_total_data_packets;
u16 i_reserved;
guid_t i_file_id;
uint64_t i_total_data_packets;
uint16_t i_reserved;
} asf_object_data_t;
......@@ -221,10 +221,10 @@ typedef struct asf_object_data_s
typedef struct asf_object_index_s
{
ASF_OBJECT_COMMON
guid_t i_file_id;
u64 i_index_entry_time_interval;
u32 i_max_packet_count;
u32 i_index_entry_count;
guid_t i_file_id;
uint64_t i_index_entry_time_interval;
uint32_t i_max_packet_count;
uint32_t i_index_entry_count;
asf_index_entry_t *index_entry;
......@@ -251,16 +251,16 @@ typedef struct asf_object_file_properties_s
ASF_OBJECT_COMMON
guid_t i_file_id;
u64 i_file_size;
u64 i_creation_date;
u64 i_data_packets_count;
u64 i_play_duration;
u64 i_send_duration;
u64 i_preroll;
u32 i_flags;
u32 i_min_data_packet_size;
u32 i_max_data_packet_size;
u32 i_max_bitrate;
uint64_t i_file_size;
uint64_t i_creation_date;
uint64_t i_data_packets_count;
uint64_t i_play_duration;
uint64_t i_send_duration;
uint64_t i_preroll;
uint32_t i_flags;
uint32_t i_min_data_packet_size;
uint32_t i_max_data_packet_size;
uint32_t i_max_bitrate;
} asf_object_file_properties_t;
......@@ -271,25 +271,25 @@ typedef struct asf_object_stream_properties_s
guid_t i_stream_type;
guid_t i_error_correction_type;
u64 i_time_offset;
u32 i_type_specific_data_length;
u32 i_error_correction_data_length;
u16 i_flags;
uint64_t i_time_offset;
uint32_t i_type_specific_data_length;
uint32_t i_error_correction_data_length;
uint16_t i_flags;
/* extrated from flags */
u8 i_stream_number;
u32 i_reserved;
u8 *p_type_specific_data;
u8 *p_error_correction_data;
uint8_t i_stream_number;
uint32_t i_reserved;
uint8_t *p_type_specific_data;
uint8_t *p_error_correction_data;
} asf_object_stream_properties_t;
typedef struct asf_object_header_extention_s
{
ASF_OBJECT_COMMON
guid_t i_reserved1;
u16 i_reserved2;
u32 i_header_extention_size;
u8 *p_header_extention_data;
guid_t i_reserved1;
uint16_t i_reserved2;
uint32_t i_header_extention_size;
uint8_t *p_header_extention_data;
} asf_object_header_extention_t;
......@@ -307,8 +307,8 @@ typedef struct asf_objec_content_description_s
typedef struct string16_s
{
u16 i_length;
u16 *i_char;
uint16_t i_length;
uint16_t *i_char;
} string16_t;
#define ASF_CODEC_TYPE_VIDEO 0x0001
......@@ -317,19 +317,19 @@ typedef struct string16_s
typedef struct asf_codec_entry_s
{
u16 i_type;
uint16_t i_type;
char *psz_name;
char *psz_description;
u16 i_information_length;
u8 *p_information;
uint16_t i_information_length;
uint8_t *p_information;
} asf_codec_entry_t;
typedef struct asf_object_codec_list_s
{
ASF_OBJECT_COMMON
guid_t i_reserved;
u32 i_codec_entries_count;
guid_t i_reserved;
uint32_t i_codec_entries_count;
asf_codec_entry_t *codec;
} asf_object_codec_list_t;
......@@ -344,13 +344,13 @@ typedef struct asf_object_script_command_s
#endif
typedef struct asf_marker_s
{
u64 i_offset;
u64 i_presentation_time;
u16 i_entry_length;
u32 i_send_time;
u32 i_flags;
u32 i_marker_description_length;
u8 *i_marker_description;
uint64_t i_offset;
uint64_t i_presentation_time;
uint16_t i_entry_length;
uint32_t i_send_time;
uint32_t i_flags;
uint32_t i_marker_description_length;
uint8_t *i_marker_description;
/* u8 padding */
} asf_marker_t;
......@@ -358,9 +358,9 @@ typedef struct asf_marker_s
typedef struct asf_object_marker_s
{
ASF_OBJECT_COMMON
guid_t i_reserved1;
u32 i_count;
u16 i_reserved2;
guid_t i_reserved1;
uint32_t i_count;
uint16_t i_reserved2;
string16_t name;
asf_marker_t *marker;
......@@ -392,10 +392,10 @@ typedef union asf_object_u
off_t ASF_TellAbsolute( input_thread_t *p_input );
int ASF_SeekAbsolute( input_thread_t *p_input, off_t i_pos);
int ASF_ReadData( input_thread_t *p_input, u8 *p_buff, int i_size );
int ASF_ReadData( input_thread_t *p_input, uint8_t *p_buff, int i_size );
int ASF_SkipBytes( input_thread_t *p_input, int i_count );
void GetGUID( guid_t *p_guid, u8 *p_data );
void GetGUID( guid_t *p_guid, uint8_t *p_data );
int CmpGUID( const guid_t *p_guid1, const guid_t *p_guid2 );
int ASF_ReadObjectCommon( input_thread_t *p_input,
......
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