Commit 98e4c6af authored by Gildas Bazin's avatar Gildas Bazin

* modules/mux/mpeg/pes.c: allow cases where we don't write a pts.
* modules/stream_out/display.c: handle cases where we don't have a pts/dts.
parent 70d76253
......@@ -2,7 +2,7 @@
* pes.c
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
* $Id: pes.c,v 1.5 2003/03/03 14:21:08 gbazin Exp $
* $Id: pes.c,v 1.6 2003/06/09 07:16:41 gbazin Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Eric Petit <titer@videolan.org>
......@@ -77,7 +77,8 @@ static inline int PESHeader( uint8_t *p_hdr, mtime_t i_pts, mtime_t i_dts, int i
int i_pts_dts;
int i_extra = 0;
/* *** for PES_PRIVATE_STREAM_1 there is an extra header after the pes hdr *** */
/* For PES_PRIVATE_STREAM_1 there is an extra header after the
pes header */
if( i_stream_id == PES_PRIVATE_STREAM_1 )
{
i_extra = 1;
......@@ -87,16 +88,21 @@ static inline int PESHeader( uint8_t *p_hdr, mtime_t i_pts, mtime_t i_dts, int i
}
}
if( i_dts >= 0 )
if( i_pts >= 0 && i_dts >= 0 )
{
bits_write( &bits, 16, i_es_size + i_extra+ 13 );
i_pts_dts = 0x03;
}
else
else if( i_pts >= 0 )
{
bits_write( &bits, 16, i_es_size + i_extra + 8 );
i_pts_dts = 0x02;
}
else
{
bits_write( &bits, 16, i_es_size + i_extra + 3 );
i_pts_dts = 0x00;
}
bits_write( &bits, 2, 0x02 ); // mpeg2 id
bits_write( &bits, 2, 0x00 ); // pes scrambling control
......@@ -112,16 +118,22 @@ static inline int PESHeader( uint8_t *p_hdr, mtime_t i_pts, mtime_t i_dts, int i
bits_write( &bits, 1, 0x00 ); // additional copy info flag
bits_write( &bits, 1, 0x00 ); // pes crc flag
bits_write( &bits, 1, 0x00 ); // pes extention flags
if( i_pts_dts & 0x01 )
if( i_pts_dts == 0x03 )
{
bits_write( &bits, 8, 0x0a ); // header size -> pts and dts
}
else
else if( i_pts_dts == 0x02 )
{
bits_write( &bits, 8, 0x05 ); // header size -> pts
}
else
{
bits_write( &bits, 8, 0x00 ); // header size -> 0
}
/* write pts */
if( i_pts_dts & 0x02 )
{
bits_write( &bits, 4, i_pts_dts ); // '0010' or '0011'
bits_write( &bits, 3, i_pts >> 30 );
bits_write( &bits, 1, 0x01 ); // marker
......@@ -129,7 +141,7 @@ static inline int PESHeader( uint8_t *p_hdr, mtime_t i_pts, mtime_t i_dts, int i
bits_write( &bits, 1, 0x01 ); // marker
bits_write( &bits, 15, i_pts );
bits_write( &bits, 1, 0x01 ); // marker
}
/* write i_dts */
if( i_pts_dts & 0x01 )
{
......
......@@ -2,7 +2,7 @@
* display.c
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
* $Id: display.c,v 1.4 2003/05/05 22:23:40 gbazin Exp $
* $Id: display.c,v 1.5 2003/06/09 07:16:42 gbazin Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
......@@ -233,7 +233,8 @@ static int Del ( sout_stream_t *p_stream, sout_stream_id_t *id )
return VLC_SUCCESS;
}
static int Send ( sout_stream_t *p_stream, sout_stream_id_t *id, sout_buffer_t *p_buffer )
static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
sout_buffer_t *p_buffer )
{
sout_stream_sys_t *p_sys = p_stream->p_sys;
......@@ -250,15 +251,18 @@ static int Send ( sout_stream_t *p_stream, sout_stream_id_t *id, sout_bu
msg_Err( p_stream, "cannot allocate new PES" );
return VLC_EGENERIC;
}
if( !( p_data = input_NewPacket( p_sys->p_input->p_method_data, p_buffer->i_size ) ) )
if( !( p_data = input_NewPacket( p_sys->p_input->p_method_data,
p_buffer->i_size ) ) )
{
msg_Err( p_stream, "cannot allocate new data_packet" );
return VLC_EGENERIC;
}
p_data->p_payload_end = p_data->p_payload_start + p_buffer->i_size;
p_pes->i_dts = p_buffer->i_dts + p_sys->i_delay;
p_pes->i_pts = p_buffer->i_pts + p_sys->i_delay;
p_pes->i_dts = p_buffer->i_dts < 0 ? 0 :
p_buffer->i_dts + p_sys->i_delay;
p_pes->i_pts = p_buffer->i_pts < 0 ? 0 :
p_buffer->i_pts + p_sys->i_delay;
p_pes->p_first = p_pes->p_last = p_data;
p_pes->i_nb_data = 1;
p_pes->i_pes_size = p_buffer->i_size;
......
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