Commit 017e74c3 authored by Christophe Massiot's avatar Christophe Massiot

* modules/mux/mpeg/pes.c: Extended prototype to allow for padding bytes

   and data_alignment in the PES header (needed for teletext).
 * modules/mux/mpeg/ts.c: Teletext (0x56 descriptor) streaming support,
   new options spu-pid and tsid, re-enabled bmax because it is useful for
   debugging the encoder, fixed in a bug in the parsing of the CSA key
parent 6db69bfe
......@@ -48,7 +48,8 @@
static inline int PESHeader( uint8_t *p_hdr, mtime_t i_pts, mtime_t i_dts,
int i_es_size, int i_stream_id, int i_private_id,
vlc_bool_t b_mpeg2 )
vlc_bool_t b_mpeg2, vlc_bool_t b_data_alignment,
int i_header_size )
{
bits_buffer_t bits;
int i_extra = 0;
......@@ -66,7 +67,7 @@ static inline int PESHeader( uint8_t *p_hdr, mtime_t i_pts, mtime_t i_dts,
}
bits_initwrite( &bits, 30, p_hdr );
bits_initwrite( &bits, 50, p_hdr );
/* add start code */
bits_write( &bits, 24, 0x01 );
......@@ -92,26 +93,28 @@ static inline int PESHeader( uint8_t *p_hdr, mtime_t i_pts, mtime_t i_dts,
{
int i_pts_dts;
if( i_pts > 0 && i_dts > 0 )
if( i_pts > 0 && i_dts > 0 && i_pts != i_dts )
{
bits_write( &bits, 16, i_es_size + i_extra+ 13 );
i_pts_dts = 0x03;
if ( !i_header_size ) i_header_size = 0xa;
}
else if( i_pts > 0 )
{
bits_write( &bits, 16, i_es_size + i_extra + 8 );
i_pts_dts = 0x02;
if ( !i_header_size ) i_header_size = 0x5;
}
else
{
bits_write( &bits, 16, i_es_size + i_extra + 3 );
i_pts_dts = 0x00;
if ( !i_header_size ) i_header_size = 0x0;
}
bits_write( &bits, 16, i_es_size + i_extra + 3
+ i_header_size ); // size
bits_write( &bits, 2, 0x02 ); // mpeg2 id
bits_write( &bits, 2, 0x00 ); // pes scrambling control
bits_write( &bits, 1, 0x00 ); // pes priority
bits_write( &bits, 1, 0x00 ); // data alignement indicator
bits_write( &bits, 1, b_data_alignment ); // data alignement indicator
bits_write( &bits, 1, 0x00 ); // copyright
bits_write( &bits, 1, 0x00 ); // original or copy
......@@ -122,18 +125,7 @@ static inline int PESHeader( uint8_t *p_hdr, mtime_t i_pts, mtime_t i_dts,
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 == 0x03 )
{
bits_write( &bits, 8, 0x0a ); // header size -> pts and dts
}
else if( i_pts_dts == 0x02 )
{
bits_write( &bits, 8, 0x05 ); // header size -> pts
}
else
{
bits_write( &bits, 8, 0x00 ); // header size -> 0
}
bits_write( &bits, 8, i_header_size ); // header size -> pts and dts
/* write pts */
if( i_pts_dts & 0x02 )
......@@ -145,6 +137,7 @@ static inline int PESHeader( uint8_t *p_hdr, mtime_t i_pts, mtime_t i_dts,
bits_write( &bits, 1, 0x01 ); // marker
bits_write( &bits, 15, i_pts );
bits_write( &bits, 1, 0x01 ); // marker
i_header_size -= 0x5;
}
/* write i_dts */
if( i_pts_dts & 0x01 )
......@@ -156,13 +149,19 @@ static inline int PESHeader( uint8_t *p_hdr, mtime_t i_pts, mtime_t i_dts,
bits_write( &bits, 1, 0x01 ); // marker
bits_write( &bits, 15, i_dts );
bits_write( &bits, 1, 0x01 ); // marker
i_header_size -= 0x5;
}
while ( i_header_size )
{
bits_write( &bits, 8, 0xff );
i_header_size--;
}
}
else /* MPEG1 */
{
int i_pts_dts;
if( i_pts > 0 && i_dts > 0 )
if( i_pts > 0 && i_dts > 0 && i_pts != i_dts )
{
bits_write( &bits, 16, i_es_size + i_extra + 10 /* + stuffing */ );
i_pts_dts = 0x03;
......@@ -232,7 +231,7 @@ int E_( EStoPES )( sout_instance_t *p_sout,
block_t **pp_pes,
block_t *p_es,
int i_stream_id,
int b_mpeg2 )
int b_mpeg2, int b_data_alignment, int i_header_size )
{
block_t *p_pes;
mtime_t i_pts, i_dts, i_length;
......@@ -242,7 +241,7 @@ int E_( EStoPES )( sout_instance_t *p_sout,
int i_private_id = -1;
uint8_t header[30]; // PES header + extra < 30 (more like 17)
uint8_t header[50]; // PES header + extra < 50 (more like 17)
int i_pes_payload;
int i_pes_header;
......@@ -267,7 +266,8 @@ int E_( EStoPES )( sout_instance_t *p_sout,
{
i_pes_payload = __MIN( i_size, PES_PAYLOAD_SIZE_MAX );
i_pes_header = PESHeader( header, i_pts, i_dts, i_pes_payload,
i_stream_id, i_private_id, b_mpeg2 );
i_stream_id, i_private_id, b_mpeg2,
b_data_alignment, i_header_size );
i_dts = 0; // only first PES has a dts/pts
i_pts = 0;
......
......@@ -36,4 +36,5 @@
int E_( EStoPES )( sout_instance_t *p_sout,
block_t **pp_pes, block_t *p_es,
int i_stream_id, int b_mpeg2 );
int i_stream_id, int b_mpeg2, int b_data_alignment,
int i_header_size );
......@@ -372,7 +372,7 @@ static int Mux( sout_mux_t *p_mux )
/* Get and mux a packet */
p_data = block_FifoGet( p_input->p_fifo );
E_( EStoPES )( p_mux->p_sout, &p_data, p_data, p_stream->i_stream_id,
p_mux->p_sys->b_mpeg2 );
p_mux->p_sys->b_mpeg2, 0, 0 );
block_ChainAppend( &p_ps, p_data );
......
This diff is collapsed.
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