Commit 9f9e9578 authored by Christophe Massiot's avatar Christophe Massiot

Fixed a bug in System End Code handling. Contact me in case of problem.

parent 20ff5191
......@@ -2,7 +2,7 @@
* input_ps.c: PS demux and packet management
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: input_ps.c,v 1.32 2001/08/07 02:48:25 sam Exp $
* $Id: input_ps.c,v 1.33 2001/08/10 16:38:09 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Cyril Deguet <asmax@via.ecp.fr>
......@@ -470,7 +470,7 @@ static int PSRead( input_thread_t * p_input,
for( i_packet = 0; i_packet < INPUT_READ_ONCE; i_packet++ )
{
/* Read what we believe to be a packet header. */
if( (i_error = SafeRead( p_input, p_header, 6 )) )
if( (i_error = SafeRead( p_input, p_header, 4 )) )
{
return( i_error );
}
......@@ -504,11 +504,16 @@ static int PSRead( input_thread_t * p_input,
}
/* Packet found. */
*(u32 *)p_header = U32_AT(&i_startcode);
}
/* 0x1B9 == SYSTEM_END_CODE, it is only 4 bytes long. */
if( U32_AT(p_header) != 0x1B9 )
{
/* The packet is at least 6 bytes long. */
if( (i_error = SafeRead( p_input, p_header + 4, 2 )) )
{
return( i_error );
}
}
if( U32_AT(p_header) != 0x1BA )
{
......@@ -534,6 +539,12 @@ static int PSRead( input_thread_t * p_input,
return( -1 );
}
}
}
else
{
/* System End Code */
i_packet_size = -2;
}
/* Fetch a packet of the appropriate size. */
p_data = NewPacket( p_input->p_method_data, i_packet_size + 6 );
......@@ -543,6 +554,8 @@ static int PSRead( input_thread_t * p_input,
return( -1 );
}
if( U32_AT(p_header) != 0x1B9 )
{
/* Copy the header we already read. */
memcpy( p_data->p_buffer, p_header, 6 );
......@@ -567,6 +580,12 @@ static int PSRead( input_thread_t * p_input,
}
}
}
}
else
{
/* Copy the small header. */
memcpy( p_data->p_buffer, p_header, 4 );
}
/* Give the packet to the other input stages. */
pp_packets[i_packet] = p_data;
......
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