Commit 2b75de8f authored by Christophe Massiot's avatar Christophe Massiot

Next Generation Buffer Manager, for TS plug-in. Please test in-ten-si-vely !

parent 6a74f9fb
......@@ -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.43 2001/12/12 11:18:38 massiot Exp $
* $Id: input_ext-dec.h,v 1.44 2001/12/12 13:48:09 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Michel Kaempf <maxx@via.ecp.fr>
......@@ -84,6 +84,9 @@ typedef struct pes_packet_s
p_next fields of the data_packet_t struct) */
data_packet_t * p_first; /* The first packet contained by this
* PES (used by decoders). */
data_packet_t * p_last; /* The last packet contained by this
PES (used by the buffer allocator) */
int i_nb_data;
/* Chained list used by the input buffers manager */
struct pes_packet_s * p_next;
......
......@@ -4,7 +4,7 @@
* control the pace of reading.
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: input_ext-intf.h,v 1.52 2001/12/10 04:53:10 sam Exp $
* $Id: input_ext-intf.h,v 1.53 2001/12/12 13:48:09 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
......@@ -66,7 +66,6 @@ typedef struct es_descriptor_s
/* PES parser information */
struct pes_packet_s * p_pes; /* Current PES */
struct data_packet_s * p_last; /* The last packet gathered at present */
int i_pes_real_size; /* as indicated by the header */
/* Decoder information */
......
This diff is collapsed.
......@@ -2,7 +2,7 @@
* input_ps.c: PS demux and packet management
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: input_ps.c,v 1.3 2001/12/12 11:18:38 massiot Exp $
* $Id: input_ps.c,v 1.4 2001/12/12 13:48:09 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 );
DECLARE_BUFFERS_DELETEPES( FLAGS, NB_LIFO, 150, 150 );
/*****************************************************************************
......
......@@ -2,7 +2,7 @@
* input_ts.c: TS demux and netlist management
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: input_ts.c,v 1.2 2001/12/10 04:53:11 sam Exp $
* $Id: input_ts.c,v 1.3 2001/12/12 13:48:09 massiot Exp $
*
* Authors: Henri Fallon <henri@videolan.org>
*
......@@ -91,6 +91,20 @@ static void TSEnd ( struct input_thread_s * );
static int TSRead ( struct input_thread_s *,
data_packet_t * p_packets[INPUT_READ_ONCE] );
/*****************************************************************************
* Declare a buffer manager
*****************************************************************************/
#define FLAGS BUFFERS_UNIQUE_SIZE
#define NB_LIFO 1
DECLARE_BUFFERS_EMBEDDED( FLAGS, NB_LIFO );
DECLARE_BUFFERS_INIT( FLAGS, NB_LIFO );
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_TOIO( FLAGS, TS_PACKET_SIZE );
/*****************************************************************************
* Functions exported as capabilities. They are declared as static so that
* we don't pollute the namespace too much.
......@@ -108,10 +122,10 @@ void _M( input_getfunctions )( function_list_t * p_function_list )
input.pf_set_program = input_SetProgram;
input.pf_read = TSRead;
input.pf_demux = input_DemuxTS;
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 = NULL;
input.pf_seek = NULL;
#undef input
......@@ -160,7 +174,6 @@ static int TSProbe( probedata_t * p_data )
*****************************************************************************/
static void TSInit( input_thread_t * p_input )
{
/* Initialize netlist and TS structures */
thread_ts_data_t * p_method;
es_descriptor_t * p_pat_es;
es_ts_data_t * p_demux_data;
......@@ -184,11 +197,9 @@ static void TSInit( input_thread_t * p_input )
p_input->p_method_data = NULL;
/* Initialize netlist */
if( input_NetlistInit( p_input, NB_DATA, NB_DATA, NB_PES, TS_PACKET_SIZE,
INPUT_READ_ONCE ) )
if( (p_input->p_method_data = input_BuffersInit()) == NULL )
{
intf_ErrMsg( "TS input : Could not initialize netlist" );
p_input->b_error = 1;
return;
}
......@@ -227,7 +238,7 @@ static void TSEnd( input_thread_t * p_input )
input_DelES( p_input, p_pat_es );
free(p_input->p_plugin_data);
input_NetlistEnd( p_input );
input_BuffersEnd( p_input->p_method_data );
}
/*****************************************************************************
......@@ -243,7 +254,8 @@ static int TSRead( input_thread_t * p_input,
unsigned int i_loop;
int i_read;
int i_data = 1;
struct iovec * p_iovec;
struct iovec p_iovec[INPUT_READ_ONCE];
data_packet_t * p_data;
struct timeval timeout;
/* Init */
......@@ -278,11 +290,12 @@ static int TSRead( input_thread_t * p_input,
if( i_data )
{
/* Get iovecs */
p_iovec = input_NetlistGetiovec( p_input->p_method_data );
p_data = input_BuffersToIO( p_input->p_method_data, p_iovec,
INPUT_READ_ONCE );
if ( p_iovec == NULL )
{
return( -1 ); /* empty netlist */
return( -1 );
}
#if defined( WIN32 )
......@@ -306,24 +319,13 @@ static int TSRead( input_thread_t * p_input,
i_read = 0;
}
#endif
if( i_read == -1 )
{
intf_ErrMsg( "input error: TS readv error" );
return( -1 );
}
/* EOF */
if( i_read == 0 && p_input->stream.b_seekable )
{
return( 1 );
}
input_NetlistMviovec( p_input->p_method_data,
(int)(((i_read-1)/TS_PACKET_SIZE)+1) , pp_packets );
/* check correct TS header */
for( i_loop=0; i_loop * TS_PACKET_SIZE < i_read; i_loop++ )
{
pp_packets[i_loop] = p_data;
p_data = p_data->p_next;
pp_packets[i_loop]->p_next = NULL;
if( pp_packets[i_loop]->p_buffer[0] != 0x47 )
intf_ErrMsg( "input error: bad TS packet (starts with "
"0x%.2x, should be 0x47)",
......@@ -331,9 +333,26 @@ static int TSRead( input_thread_t * p_input,
}
for( ; i_loop < INPUT_READ_ONCE ; i_loop++ )
{
data_packet_t * p_next = p_data->p_next;
input_DeletePacket( p_input->p_method_data, p_data );
p_data = p_next;
pp_packets[i_loop] = NULL;
}
/* Error */
if( i_read == -1 )
{
intf_ErrMsg( "input error: TS readv error" );
return( -1 );
}
/* EOF */
if( i_read == 0 && p_input->stream.b_seekable )
{
return( 1 );
}
p_input->stream.p_selected_area->i_tell += i_read;
}
return 0;
......
......@@ -2,7 +2,7 @@
* mpeg_system.c: TS, PS and PES management
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: mpeg_system.c,v 1.71 2001/12/11 13:55:55 massiot Exp $
* $Id: mpeg_system.c,v 1.72 2001/12/12 13:48:09 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Michel Lespinasse <walken@via.ecp.fr>
......@@ -476,10 +476,11 @@ void input_GatherPES( input_thread_t * p_input, data_packet_t * p_data,
else
{
/* Update the relations between the data packets */
p_es->p_last->p_next = p_data;
p_pes->p_last->p_next = p_data;
}
p_es->p_last = p_data;
p_pes->p_last = p_data;
p_pes->i_nb_data++;
/* Size of the payload carried in the data packet */
p_pes->i_pes_size += (p_data->p_payload_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