Commit 605a3534 authored by Christophe Massiot's avatar Christophe Massiot

Next Generation Buffer Manager for DVD and VCD plug-ins.

parent ba2dbc41
......@@ -2,7 +2,7 @@
* input_ext-dec.h: structures exported to the VideoLAN decoders
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: input_ext-dec.h,v 1.44 2001/12/12 13:48:09 massiot Exp $
* $Id: input_ext-dec.h,v 1.45 2001/12/19 10:00:00 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Michel Kaempf <maxx@via.ecp.fr>
......@@ -44,16 +44,17 @@ typedef struct data_packet_s
{
/* Nothing before this line, the code relies on that */
byte_t * p_buffer; /* raw data packet */
byte_t * p_buffer_end;
long l_size; /* buffer size */
/* Decoders information */
byte_t * p_demux_start; /* start of the PS or TS packet */
byte_t * p_payload_start;
/* start of the PES payload in this packet */
byte_t * p_payload_end; /* guess ? :-) */
boolean_t b_discard_payload; /* is the packet messed up ? */
int * pi_refcount;
unsigned int i_size; /* buffer size */
long l_size; /* buffer size */
/* Used to chain the TS packets that carry data for a same PES or PSI */
struct data_packet_s * p_next;
......
This diff is collapsed.
......@@ -4,13 +4,12 @@
* This plugins should handle all the known specificities of the DVD format,
* especially the 2048 bytes logical block size.
* It depends on:
* -input_netlist used to read packets
* -libdvdcss for access and unscrambling
* -dvd_ifo for ifo parsing and analyse
* -dvd_udf to find files
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: input_dvd.c,v 1.106 2001/12/10 04:53:10 sam Exp $
* $Id: input_dvd.c,v 1.107 2001/12/19 10:00:00 massiot Exp $
*
* Author: Stphane Borel <stef@via.ecp.fr>
*
......@@ -95,9 +94,6 @@
#define DVD_BLOCK_READ_ONCE 64
#define DVD_DATA_READ_ONCE (4 * DVD_BLOCK_READ_ONCE)
/* Size of netlist */
#define DVD_NETLIST_SIZE 256
/*****************************************************************************
* Local prototypes
*****************************************************************************/
......@@ -119,6 +115,21 @@ static int DVDFindCell( thread_dvd_data_t * );
static int DVDFindSector( thread_dvd_data_t * );
static int DVDChapterSelect( thread_dvd_data_t *, int );
/*****************************************************************************
* Declare a buffer manager
*****************************************************************************/
#define FLAGS BUFFERS_UNIQUE_SIZE
#define NB_LIFO 1
DECLARE_BUFFERS_SHARED( FLAGS, NB_LIFO );
DECLARE_BUFFERS_INIT( FLAGS, NB_LIFO );
DECLARE_BUFFERS_END_SHARED( FLAGS, NB_LIFO );
DECLARE_BUFFERS_NEWPACKET_SHARED( FLAGS, NB_LIFO );
DECLARE_BUFFERS_DELETEPACKET_SHARED( FLAGS, NB_LIFO, 150 );
DECLARE_BUFFERS_NEWPES( FLAGS, NB_LIFO );
DECLARE_BUFFERS_DELETEPES( FLAGS, NB_LIFO, 150 );
DECLARE_BUFFERS_TOIO( FLAGS, DVD_LB_SIZE );
DECLARE_BUFFERS_SHAREBUFFER( FLAGS );
/*****************************************************************************
* Functions exported as capabilities. They are declared as static so that
* we don't pollute the namespace too much.
......@@ -136,10 +147,10 @@ void _M( input_getfunctions )( function_list_t * p_function_list )
input.pf_set_area = DVDSetArea;
input.pf_set_program = DVDSetProgram;
input.pf_demux = input_DemuxPS;
input.pf_new_packet = input_NetlistNewPacket;
input.pf_new_pes = input_NetlistNewPES;
input.pf_delete_packet = input_NetlistDeletePacket;
input.pf_delete_pes = input_NetlistDeletePES;
input.pf_new_packet = input_NewPacket;
input.pf_new_pes = input_NewPES;
input.pf_delete_packet = input_DeletePacket;
input.pf_delete_pes = input_DeletePES;
input.pf_rewind = DVDRewind;
input.pf_seek = DVDSeek;
#undef input
......@@ -194,7 +205,12 @@ static void DVDInit( input_thread_t * p_input )
}
p_input->p_plugin_data = (void *)p_dvd;
p_input->p_method_data = NULL;
if( (p_input->p_method_data = input_BuffersInit()) == NULL )
{
p_input->b_error = 1;
return;
}
p_dvd->dvdhandle = (dvdcss_handle) p_input->p_handle;
......@@ -211,11 +227,6 @@ static void DVDInit( input_thread_t * p_input )
/* this value mustn't be modifed */
p_input->i_read_once = DVD_DATA_READ_ONCE;
/* Reading structures initialisation */
input_NetlistInit( p_input, DVD_NETLIST_SIZE, 2 * DVD_NETLIST_SIZE,
DVD_NETLIST_SIZE, DVD_LB_SIZE, p_dvd->i_block_once );
intf_WarnMsg( 2, "dvd info: netlist initialized" );
/* Ifo allocation & initialisation */
if( IfoCreate( p_dvd ) < 0 )
{
......@@ -385,7 +396,7 @@ static void DVDEnd( input_thread_t * p_input )
free( p_dvd );
input_NetlistEnd( p_input );
input_BuffersEnd( p_input->p_method_data );
}
/*****************************************************************************
......@@ -829,9 +840,7 @@ static int DVDRead( input_thread_t * p_input,
data_packet_t ** pp_packets )
{
thread_dvd_data_t * p_dvd;
netlist_t * p_netlist;
struct iovec * p_vec;
struct data_packet_s * pp_data[DVD_DATA_READ_ONCE];
struct iovec p_vec[DVD_DATA_READ_ONCE];
u8 * pi_cur;
int i_block_once;
int i_packet_size;
......@@ -843,9 +852,9 @@ static int DVDRead( input_thread_t * p_input,
boolean_t b_eof;
boolean_t b_eot;
boolean_t b_eoc;
data_packet_t * p_data;
p_dvd = (thread_dvd_data_t *)p_input->p_plugin_data;
p_netlist = (netlist_t *)p_input->p_method_data;
b_eoc = 0;
i_sector = p_dvd->i_title_start + p_dvd->i_sector;
......@@ -909,23 +918,20 @@ static int DVDRead( input_thread_t * p_input,
/*
intf_WarnMsg( 2, "Sector: 0x%x Read: %d Chapter: %d", p_dvd->i_sector, i_block_once, p_dvd->i_chapter );
*/
p_netlist->i_read_once = i_block_once;
/* Get an iovec pointer */
if( ( p_vec = input_NetlistGetiovec( p_netlist ) ) == NULL )
/* Get iovecs */
p_data = input_BuffersToIO( p_input->p_method_data, p_vec,
DVD_DATA_READ_ONCE );
if ( p_data == NULL )
{
intf_ErrMsg( "dvd error: can't get iovec" );
return -1;
return( -1 );
}
/* Reads from DVD */
i_read_blocks = dvdcss_readv( p_dvd->dvdhandle, p_vec,
i_block_once, DVDCSS_READ_DECRYPT );
/* Update netlist indexes: we don't do it in DVDGetiovec since we
* need know the real number of blocks read */
input_NetlistMviovec( p_netlist, i_read_blocks, pp_data );
/* Update global position */
p_dvd->i_sector += i_read_blocks;
......@@ -934,9 +940,10 @@ intf_WarnMsg( 2, "Sector: 0x%x Read: %d Chapter: %d", p_dvd->i_sector, i_block_o
/* Read headers to compute payload length */
for( i_iovec = 0 ; i_iovec < i_read_blocks ; i_iovec++ )
{
data_packet_t * p_current = p_data;
i_pos = 0;
while( i_pos < p_netlist->i_buffer_size )
while( i_pos < DVD_LB_SIZE )
{
pi_cur = (u8*)p_vec[i_iovec].iov_base + i_pos;
......@@ -945,21 +952,26 @@ intf_WarnMsg( 2, "Sector: 0x%x Read: %d Chapter: %d", p_dvd->i_sector, i_block_o
{
/* That's the case for all packets, except pack header. */
i_packet_size = U16_AT( pi_cur + 4 );
pp_packets[i_packet] = input_NetlistNewPtr( p_netlist );
(*pp_data[i_iovec]->pi_refcount)++;
pp_packets[i_packet]->pi_refcount =
pp_data[i_iovec]->pi_refcount;
pp_packets[i_packet]->p_buffer = pp_data[i_iovec]->p_buffer;
}
else
{
/* MPEG-2 Pack header. */
i_packet_size = 8;
pp_packets[i_packet] = pp_data[i_iovec];
}
if( i_pos != 0 )
{
pp_packets[i_packet] = input_ShareBuffer(
p_input->p_method_data, p_current );
}
else
{
pp_packets[i_packet] = p_data;
p_data = p_data->p_next;
}
pp_packets[i_packet]->p_payload_start =
pp_packets[i_packet]->p_buffer + i_pos;
pp_packets[i_packet]->p_demux_start =
pp_packets[i_packet]->p_demux_start + i_pos;
pp_packets[i_packet]->p_payload_end =
pp_packets[i_packet]->p_payload_start + i_packet_size + 6;
......@@ -971,6 +983,13 @@ intf_WarnMsg( 2, "Sector: 0x%x Read: %d Chapter: %d", p_dvd->i_sector, i_block_o
pp_packets[i_packet] = NULL;
while( p_data != NULL )
{
data_packet_t * p_next = p_data->p_next;
p_input->pf_delete_packet( p_input->p_method_data, p_data );
p_data = p_next;
}
vlc_mutex_lock( &p_input->stream.stream_lock );
p_input->stream.p_selected_area->i_tell =
......
......@@ -6,7 +6,7 @@
* It depends on: libdvdread for ifo files and block reading.
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: input_dvdread.c,v 1.3 2001/12/07 18:33:07 sam Exp $
* $Id: input_dvdread.c,v 1.4 2001/12/19 10:00:00 massiot Exp $
*
* Author: Stphane Borel <stef@via.ecp.fr>
*
......@@ -87,9 +87,6 @@
#define DVD_BLOCK_READ_ONCE 64
#define DVD_DATA_READ_ONCE (4 * DVD_BLOCK_READ_ONCE)
/* Size of netlist */
#define DVD_NETLIST_SIZE 512
/*****************************************************************************
* Local prototypes
*****************************************************************************/
......@@ -108,6 +105,21 @@ static int DvdReadRewind ( struct input_thread_s * );
static void DvdReadHandleDSI( thread_dvd_data_t * p_dvd, u8 * p_data );
static void DvdReadFindCell ( thread_dvd_data_t * p_dvd );
/*****************************************************************************
* Declare a buffer manager
*****************************************************************************/
#define FLAGS BUFFERS_UNIQUE_SIZE
#define NB_LIFO 1
DECLARE_BUFFERS_SHARED( FLAGS, NB_LIFO );
DECLARE_BUFFERS_INIT( FLAGS, NB_LIFO );
DECLARE_BUFFERS_END_SHARED( FLAGS, NB_LIFO );
DECLARE_BUFFERS_NEWPACKET_SHARED( FLAGS, NB_LIFO );
DECLARE_BUFFERS_DELETEPACKET_SHARED( FLAGS, NB_LIFO, 150 );
DECLARE_BUFFERS_NEWPES( FLAGS, NB_LIFO );
DECLARE_BUFFERS_DELETEPES( FLAGS, NB_LIFO, 150 );
DECLARE_BUFFERS_TOIO( FLAGS, DVD_LB_SIZE );
DECLARE_BUFFERS_SHAREBUFFER( FLAGS );
/*****************************************************************************
* Functions exported as capabilities. They are declared as static so that
* we don't pollute the namespace too much.
......@@ -124,10 +136,10 @@ void _M( input_getfunctions )( function_list_t * p_function_list )
input.pf_read = DvdReadRead;
input.pf_set_area = DvdReadSetArea;
input.pf_demux = input_DemuxPS;
input.pf_new_packet = input_NetlistNewPacket;
input.pf_new_pes = input_NetlistNewPES;
input.pf_delete_packet = input_NetlistDeletePacket;
input.pf_delete_pes = input_NetlistDeletePES;
input.pf_new_packet = input_NewPacket;
input.pf_new_pes = input_NewPES;
input.pf_delete_packet = input_DeletePacket;
input.pf_delete_pes = input_DeletePES;
input.pf_rewind = DvdReadRewind;
input.pf_seek = DvdReadSeek;
#undef input
......@@ -188,7 +200,12 @@ static void DvdReadInit( input_thread_t * p_input )
p_dvd->p_vts_file = NULL;
p_input->p_plugin_data = (void *)p_dvd;
p_input->p_method_data = NULL;
if( (p_input->p_method_data = input_BuffersInit()) == NULL )
{
p_input->b_error = 1;
return;
}
/* We read DVD_BLOCK_READ_ONCE in each loop, so the input will receive
* DVD_DATA_READ_ONCE at most */
......@@ -196,11 +213,6 @@ static void DvdReadInit( input_thread_t * p_input )
/* this value mustn't be modifed */
p_input->i_read_once = DVD_DATA_READ_ONCE;
/* Reading structures initialisation */
input_NetlistInit( p_input, DVD_NETLIST_SIZE, 2 * DVD_NETLIST_SIZE,
DVD_NETLIST_SIZE, DVD_VIDEO_LB_LEN, p_dvd->i_block_once );
intf_WarnMsg( 2, "dvdread info: netlist initialized" );
/* Ifo allocation & initialisation */
if( ! ( p_dvd->p_vmg_file = ifoOpen( p_dvd->p_dvdread, 0 ) ) )
{
......@@ -349,9 +361,7 @@ static void DvdReadEnd( input_thread_t * p_input )
ifoClose( p_dvd->p_vts_file );
ifoClose( p_dvd->p_vmg_file );
/* Close netlist */
input_NetlistEnd( p_input );
p_input->p_method_data = NULL;
input_BuffersEnd( p_input->p_method_data );
}
#define p_pgc p_dvd->p_cur_pgc
......@@ -775,10 +785,8 @@ static int DvdReadRead( input_thread_t * p_input,
data_packet_t ** pp_packets )
{
thread_dvd_data_t * p_dvd;
netlist_t * p_netlist;
u8 p_data[DVD_VIDEO_LB_LEN];
struct iovec * p_vec;
struct data_packet_s * pp_data[DVD_DATA_READ_ONCE];
struct iovec p_vec[DVD_DATA_READ_ONCE];
u8 * pi_cur;
int i_blocks;
int i_read;
......@@ -786,9 +794,9 @@ static int DvdReadRead( input_thread_t * p_input,
int i_packet_size;
int i_packet;
int i_pos;
data_packet_t * p_data;
p_dvd = (thread_dvd_data_t *)p_input->p_plugin_data;
p_netlist = (netlist_t *)p_input->p_method_data;
/*
* Playback by cell in this pgc, starting at the cell for our chapter.
......@@ -838,13 +846,14 @@ static int DvdReadRead( input_thread_t * p_input,
i_blocks = p_dvd->i_pack_len >= DVD_BLOCK_READ_ONCE
? DVD_BLOCK_READ_ONCE : p_dvd->i_pack_len;
p_dvd->i_pack_len -= i_blocks;
p_netlist->i_read_once = i_blocks;
/* Get an iovec pointer */
if( ( p_vec = input_NetlistGetiovec( p_netlist ) ) == NULL )
/* Get iovecs */
p_data = input_BuffersToIO( p_input->p_method_data, p_vec,
DVD_DATA_READ_ONCE );
if ( p_data == NULL )
{
intf_ErrMsg( "dvdread error: can't get iovec" );
return -1;
return( -1 );
}
/* Reads from DVD */
......@@ -861,18 +870,15 @@ static int DvdReadRead( input_thread_t * p_input,
/*
intf_WarnMsg( 12, "dvdread i_blocks: %d len: %d current: 0x%02x", i_read, p_dvd->i_pack_len, p_dvd->i_cur_block );
*/
/* Update netlist indexes: we don't do it in DVDGetiovec since we
* need know the real number of blocks read */
input_NetlistMviovec( p_netlist, i_read, pp_data );
i_packet = 0;
/* Read headers to compute payload length */
for( i_iovec = 0 ; i_iovec < i_read ; i_iovec++ )
{
data_packet_t * p_current = p_data;
i_pos = 0;
while( i_pos < p_netlist->i_buffer_size )
while( i_pos < DVD_LB_SIZE )
{
pi_cur = (u8*)p_vec[i_iovec].iov_base + i_pos;
......@@ -881,22 +887,27 @@ static int DvdReadRead( input_thread_t * p_input,
{
/* That's the case for all packets, except pack header. */
i_packet_size = U16_AT( pi_cur + 4 );
pp_packets[i_packet] = input_NetlistNewPtr( p_netlist );
(*pp_data[i_iovec]->pi_refcount)++;
pp_packets[i_packet]->pi_refcount =
pp_data[i_iovec]->pi_refcount;
pp_packets[i_packet]->p_buffer = pp_data[i_iovec]->p_buffer;
}
else
{
/* MPEG-2 Pack header. */
i_packet_size = 8;
pp_packets[i_packet] = pp_data[i_iovec];
}
if( i_pos != 0 )
{
pp_packets[i_packet] = input_ShareBuffer(
p_input->p_method_data, p_current );
}
else
{
pp_packets[i_packet] = p_data;
p_data = p_data->p_next;
}
pp_packets[i_packet]->p_payload_start =
pp_packets[i_packet]->p_buffer + i_pos;
pp_packets[i_packet]->p_demux_start =
pp_packets[i_packet]->p_demux_start + i_pos;
pp_packets[i_packet]->p_payload_end =
pp_packets[i_packet]->p_payload_start + i_packet_size + 6;
......@@ -911,6 +922,13 @@ static int DvdReadRead( input_thread_t * p_input,
pp_packets[i_packet] = NULL;
while( p_data != NULL )
{
data_packet_t * p_next = p_data->p_next;
p_input->pf_delete_packet( p_input->p_method_data, p_data );
p_data = p_next;
}
vlc_mutex_lock( &p_input->stream.stream_lock );
p_input->stream.p_selected_area->i_tell =
......
......@@ -2,7 +2,7 @@
* input_es.c: Elementary Stream demux and packet management
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: input_es.c,v 1.5 2001/12/13 17:58:16 jobi Exp $
* $Id: input_es.c,v 1.6 2001/12/19 10:00:00 massiot Exp $
*
* Author: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -99,7 +99,7 @@ DECLARE_BUFFERS_END( FLAGS, NB_LIFO );
DECLARE_BUFFERS_NEWPACKET( FLAGS, NB_LIFO );
DECLARE_BUFFERS_DELETEPACKET( FLAGS, NB_LIFO, 150 );
DECLARE_BUFFERS_NEWPES( FLAGS, NB_LIFO );
DECLARE_BUFFERS_DELETEPES( FLAGS, NB_LIFO, 150, 150 );
DECLARE_BUFFERS_DELETEPES( FLAGS, NB_LIFO, 150 );
DECLARE_BUFFERS_TOIO( FLAGS, ES_PACKET_SIZE );
/*****************************************************************************
......@@ -204,7 +204,7 @@ static int ESRead( input_thread_t * p_input,
if ( p_data == NULL )
{
return( -1 ); /* empty netlist */
return( -1 );
}
memset( pp_packets, 0, INPUT_READ_ONCE * sizeof(data_packet_t *) );
......@@ -216,7 +216,7 @@ static int ESRead( input_thread_t * p_input,
return( -1 );
}
for( i_loop=0; i_loop * ES_PACKET_SIZE < i_read; i_loop++ )
for( i_loop = 0; i_loop * ES_PACKET_SIZE < i_read; i_loop++ )
{
pp_packets[i_loop] = p_data;
p_data = p_data->p_next;
......
......@@ -2,7 +2,7 @@
* input_ps.c: PS demux and packet management
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: input_ps.c,v 1.5 2001/12/19 03:50:22 sam Exp $
* $Id: input_ps.c,v 1.6 2001/12/19 10:00:00 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Cyril Deguet <asmax@via.ecp.fr>
......@@ -103,7 +103,7 @@ DECLARE_BUFFERS_END( FLAGS, NB_LIFO );
DECLARE_BUFFERS_NEWPACKET( FLAGS, NB_LIFO );
DECLARE_BUFFERS_DELETEPACKET( FLAGS, NB_LIFO, 150 );
DECLARE_BUFFERS_NEWPES( FLAGS, NB_LIFO );
DECLARE_BUFFERS_DELETEPES( FLAGS, NB_LIFO, 150, 150 );
DECLARE_BUFFERS_DELETEPES( FLAGS, NB_LIFO, 150 );
/*****************************************************************************
......@@ -482,11 +482,11 @@ static int PSRead( input_thread_t * p_input,
if( U32_AT(p_header) != 0x1B9 )
{
/* Copy the header we already read. */
memcpy( p_data->p_buffer, p_header, 6 );
memcpy( p_data->p_demux_start, p_header, 6 );
/* Read the remaining of the packet. */
if( i_packet_size && (i_error =
SafeRead( p_input, p_data->p_buffer + 6, i_packet_size )) )
SafeRead( p_input, p_data->p_demux_start + 6, i_packet_size )) )
{
return( i_error );
}
......@@ -494,12 +494,12 @@ static int PSRead( input_thread_t * p_input,
/* In MPEG-2 pack headers we still have to read stuffing bytes. */
if( U32_AT(p_header) == 0x1BA )
{
if( i_packet_size == 8 && (p_data->p_buffer[13] & 0x7) != 0 )
if( i_packet_size == 8 && (p_data->p_demux_start[13] & 0x7) != 0 )
{
/* MPEG-2 stuffing bytes */
byte_t p_garbage[8];
if( (i_error = SafeRead( p_input, p_garbage,
p_data->p_buffer[13] & 0x7)) )
p_data->p_demux_start[13] & 0x7)) )
{
return( i_error );
}
......@@ -509,7 +509,7 @@ static int PSRead( input_thread_t * p_input,
else
{
/* Copy the small header. */
memcpy( p_data->p_buffer, p_header, 4 );
memcpy( p_data->p_demux_start, p_header, 4 );
}
/* Give the packet to the other input stages. */
......
......@@ -2,7 +2,7 @@
* input_ts.c: TS demux and netlist management
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: input_ts.c,v 1.4 2001/12/12 17:41:15 massiot Exp $
* $Id: input_ts.c,v 1.5 2001/12/19 10:00:00 massiot Exp $
*
* Authors: Henri Fallon <henri@videolan.org>
*
......@@ -102,7 +102,7 @@ DECLARE_BUFFERS_END( FLAGS, NB_LIFO );
DECLARE_BUFFERS_NEWPACKET( FLAGS, NB_LIFO );
DECLARE_BUFFERS_DELETEPACKET( FLAGS, NB_LIFO, 1000 );
DECLARE_BUFFERS_NEWPES( FLAGS, NB_LIFO );
DECLARE_BUFFERS_DELETEPES( FLAGS, NB_LIFO, 1000, 150 );
DECLARE_BUFFERS_DELETEPES( FLAGS, NB_LIFO, 150 );
DECLARE_BUFFERS_TOIO( FLAGS, TS_PACKET_SIZE );
/*****************************************************************************
......@@ -326,10 +326,10 @@ static int TSRead( input_thread_t * p_input,
p_data = p_data->p_next;
pp_packets[i_loop]->p_next = NULL;
if( pp_packets[i_loop]->p_buffer[0] != 0x47 )
if( pp_packets[i_loop]->p_demux_start[0] != 0x47 )
intf_ErrMsg( "input error: bad TS packet (starts with "
"0x%.2x, should be 0x47)",
pp_packets[i_loop]->p_buffer[0] );
pp_packets[i_loop]->p_demux_start[0] );
}
for( ; i_loop < INPUT_READ_ONCE ; i_loop++ )
{
......
This diff is collapsed.
......@@ -2,7 +2,7 @@
* mpeg_system.c: TS, PS and PES management
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: mpeg_system.c,v 1.75 2001/12/17 16:42:27 sam Exp $
* $Id: mpeg_system.c,v 1.76 2001/12/19 10:00:00 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Michel Lespinasse <walken@via.ecp.fr>
......@@ -508,13 +508,13 @@ static u16 GetID( data_packet_t * p_data )
{
u16 i_id;
i_id = p_data->p_payload_start[3]; /* stream_id */
i_id = p_data->p_demux_start[3]; /* stream_id */
if( i_id == 0xBD )
{
/* FIXME : this is not valid if the header is split in multiple
* packets */
/* stream_private_id */
i_id |= p_data->p_payload_start[ 9 + p_data->p_payload_start[8] ] << 8;
i_id |= p_data->p_demux_start[ 9 + p_data->p_demux_start[8] ] << 8;
}
return( i_id );
}
......@@ -533,14 +533,14 @@ static void DecodePSM( input_thread_t * p_input, data_packet_t * p_data )
int i;
int i_new_es_number = 0;
if( p_data->p_payload_start + 10 > p_data->p_payload_end )
if( p_data->p_demux_start + 10 > p_data->p_payload_end )
{
intf_ErrMsg( "input error: PSM too short : packet corrupt" );
return;
}
if( p_demux->b_has_PSM
&& p_demux->i_PSM_version == (p_data->p_payload_start[6] & 0x1F) )
&& p_demux->i_PSM_version == (p_data->p_demux_start[6] & 0x1F) )
{
/* Already got that one. */
return;
......@@ -548,12 +548,12 @@ static void DecodePSM( input_thread_t * p_input, data_packet_t * p_data )
intf_DbgMsg( "input: building PSM" );
p_demux->b_has_PSM = 1;
p_demux->i_PSM_version = p_data->p_payload_start[6] & 0x1F;
p_demux->i_PSM_version = p_data->p_demux_start[6] & 0x1F;
/* Go to elementary_stream_map_length, jumping over
* program_stream_info. */
p_byte = p_data->p_payload_start + 10
+ U16_AT(&p_data->p_payload_start[8]);
p_byte = p_data->p_demux_start + 10
+ U16_AT(&p_data->p_demux_start[8]);
if( p_byte > p_data->p_payload_end )
{
intf_ErrMsg( "input error: PSM too short, packet corrupt" );
......@@ -658,7 +658,7 @@ es_descriptor_t * input_ParsePS( input_thread_t * p_input,
u32 i_code;
es_descriptor_t * p_es = NULL;
i_code = p_data->p_payload_start[3];
i_code = p_data->p_demux_start[3];
if( i_code > 0xBC ) /* ES start code */
{
......@@ -697,7 +697,7 @@ es_descriptor_t * input_ParsePS( input_thread_t * p_input,
i_id, 0 );
if( p_es != NULL )
{
p_es->i_stream_id = p_data->p_payload_start[3];
p_es->i_stream_id = p_data->p_demux_start[3];
/* Set stream type and auto-spawn. */
if( (i_id & 0xF0) == 0xE0 )
......@@ -797,10 +797,10 @@ void input_DemuxPS( input_thread_t * p_input, data_packet_t * p_data )
boolean_t b_trash = 0;
es_descriptor_t * p_es = NULL;
i_code = ((u32)p_data->p_payload_start[0] << 24)
| ((u32)p_data->p_payload_start[1] << 16)
| ((u32)p_data->p_payload_start[2] << 8)
| p_data->p_payload_start[3];
i_code = ((u32)p_data->p_demux_start[0] << 24)
| ((u32)p_data->p_demux_start[1] << 16)
| ((u32)p_data->p_demux_start[2] << 8)
| p_data->p_demux_start[3];
if( i_code <= 0x1BC )
{
switch( i_code )
......@@ -811,12 +811,12 @@ void input_DemuxPS( input_thread_t * p_input, data_packet_t * p_data )
mtime_t scr_time;
u32 i_mux_rate;
if( (p_data->p_payload_start[4] & 0xC0) == 0x40 )
if( (p_data->p_demux_start[4] & 0xC0) == 0x40 )
{
/* MPEG-2 */
byte_t p_header[14];
byte_t * p_byte;
p_byte = p_data->p_payload_start;
p_byte = p_data->p_demux_start;
if( MoveChunk( p_header, &p_data, &p_byte, 14 ) != 14 )
{
......@@ -848,7 +848,7 @@ void input_DemuxPS( input_thread_t * p_input, data_packet_t * p_data )
/* MPEG-1 SCR is like PTS. */
byte_t p_header[12];
byte_t * p_byte;
p_byte = p_data->p_payload_start;
p_byte = p_data->p_demux_start;
if( MoveChunk( p_header, &p_data, &p_byte, 12 ) != 12 )
{
......@@ -951,7 +951,7 @@ void input_DemuxTS( input_thread_t * p_input, data_packet_t * p_data )
es_ts_data_t * p_es_demux = NULL;
pgrm_ts_data_t * p_pgrm_demux = NULL;
#define p (p_data->p_buffer)
#define p (p_data->p_demux_start)
/* Extract flags values from TS common header. */
i_pid = ((p[1] & 0x1F) << 8) | p[2];
b_unit_start = (p[1] & 0x40);
......
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