Commit ea928459 authored by Gildas Bazin's avatar Gildas Bazin

* modules/mux/mpeg: for video ES, always put the pts and dts in the pes header...

* modules/mux/mpeg: for video ES, always put the pts and dts in the pes header when they are both available (makes vlc a lot happier when demuxing the stream, especially for other video codecs than mpeg2).
parent 27309e80
...@@ -47,7 +47,8 @@ ...@@ -47,7 +47,8 @@
#define PES_PAYLOAD_SIZE_MAX 65500 #define PES_PAYLOAD_SIZE_MAX 65500
static inline int PESHeader( uint8_t *p_hdr, mtime_t i_pts, mtime_t i_dts, 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, int i_es_size, es_format_t *p_fmt,
int i_stream_id, int i_private_id,
vlc_bool_t b_mpeg2, vlc_bool_t b_data_alignment, vlc_bool_t b_mpeg2, vlc_bool_t b_data_alignment,
int i_header_size ) int i_header_size )
{ {
...@@ -93,7 +94,8 @@ static inline int PESHeader( uint8_t *p_hdr, mtime_t i_pts, mtime_t i_dts, ...@@ -93,7 +94,8 @@ static inline int PESHeader( uint8_t *p_hdr, mtime_t i_pts, mtime_t i_dts,
{ {
int i_pts_dts; int i_pts_dts;
if( i_pts > 0 && i_dts > 0 && i_pts != i_dts ) if( i_pts > 0 && i_dts > 0 &&
( i_pts != i_dts || p_fmt->i_cat == VIDEO_ES ) )
{ {
i_pts_dts = 0x03; i_pts_dts = 0x03;
if ( !i_header_size ) i_header_size = 0xa; if ( !i_header_size ) i_header_size = 0xa;
...@@ -161,7 +163,8 @@ static inline int PESHeader( uint8_t *p_hdr, mtime_t i_pts, mtime_t i_dts, ...@@ -161,7 +163,8 @@ static inline int PESHeader( uint8_t *p_hdr, mtime_t i_pts, mtime_t i_dts,
{ {
int i_pts_dts; int i_pts_dts;
if( i_pts > 0 && i_dts > 0 && i_pts != i_dts ) if( i_pts > 0 && i_dts > 0 &&
( i_pts != i_dts || p_fmt->i_cat == VIDEO_ES ) )
{ {
bits_write( &bits, 16, i_es_size + i_extra + 10 /* + stuffing */ ); bits_write( &bits, 16, i_es_size + i_extra + 10 /* + stuffing */ );
i_pts_dts = 0x03; i_pts_dts = 0x03;
...@@ -227,10 +230,8 @@ static inline int PESHeader( uint8_t *p_hdr, mtime_t i_pts, mtime_t i_dts, ...@@ -227,10 +230,8 @@ static inline int PESHeader( uint8_t *p_hdr, mtime_t i_pts, mtime_t i_dts,
} }
} }
int E_( EStoPES )( sout_instance_t *p_sout, int E_( EStoPES )( sout_instance_t *p_sout, block_t **pp_pes, block_t *p_es,
block_t **pp_pes, es_format_t *p_fmt, int i_stream_id,
block_t *p_es,
int i_stream_id,
int b_mpeg2, int b_data_alignment, int i_header_size ) int b_mpeg2, int b_data_alignment, int i_header_size )
{ {
block_t *p_pes; block_t *p_pes;
...@@ -266,7 +267,7 @@ int E_( EStoPES )( sout_instance_t *p_sout, ...@@ -266,7 +267,7 @@ int E_( EStoPES )( sout_instance_t *p_sout,
{ {
i_pes_payload = __MIN( i_size, PES_PAYLOAD_SIZE_MAX ); i_pes_payload = __MIN( i_size, PES_PAYLOAD_SIZE_MAX );
i_pes_header = PESHeader( header, i_pts, i_dts, i_pes_payload, i_pes_header = PESHeader( header, i_pts, i_dts, i_pes_payload,
i_stream_id, i_private_id, b_mpeg2, p_fmt, i_stream_id, i_private_id, b_mpeg2,
b_data_alignment, i_header_size ); b_data_alignment, i_header_size );
i_dts = 0; // only first PES has a dts/pts i_dts = 0; // only first PES has a dts/pts
i_pts = 0; i_pts = 0;
...@@ -314,7 +315,6 @@ int E_( EStoPES )( sout_instance_t *p_sout, ...@@ -314,7 +315,6 @@ int E_( EStoPES )( sout_instance_t *p_sout,
i_dts += i_length; i_dts += i_length;
} }
return( 0 );
}
return 0;
}
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/ *****************************************************************************/
#define PES_PROGRAM_STREAM_MAP 0xbc #define PES_PROGRAM_STREAM_MAP 0xbc
#define PES_PRIVATE_STREAM_1 0xbd #define PES_PRIVATE_STREAM_1 0xbd
#define PES_PADDING 0xbe #define PES_PADDING 0xbe
...@@ -33,8 +32,6 @@ ...@@ -33,8 +32,6 @@
#define PES_DSMCC_STREAM 0xf2 #define PES_DSMCC_STREAM 0xf2
#define PES_ITU_T_H222_1_TYPE_E_STREAM 0xf8 #define PES_ITU_T_H222_1_TYPE_E_STREAM 0xf8
int E_( EStoPES )( sout_instance_t *p_sout, block_t **pp_pes, block_t *p_es,
int E_( EStoPES )( sout_instance_t *p_sout, es_format_t *p_fmt, int i_stream_id,
block_t **pp_pes, block_t *p_es, int b_mpeg2, int b_data_alignment, int i_header_size );
int i_stream_id, int b_mpeg2, int b_data_alignment,
int i_header_size );
...@@ -371,7 +371,8 @@ static int Mux( sout_mux_t *p_mux ) ...@@ -371,7 +371,8 @@ static int Mux( sout_mux_t *p_mux )
/* Get and mux a packet */ /* Get and mux a packet */
p_data = block_FifoGet( p_input->p_fifo ); p_data = block_FifoGet( p_input->p_fifo );
E_( EStoPES )( p_mux->p_sout, &p_data, p_data, p_stream->i_stream_id, E_( EStoPES )( p_mux->p_sout, &p_data, p_data,
p_input->p_fmt, p_stream->i_stream_id,
p_mux->p_sys->b_mpeg2, 0, 0 ); p_mux->p_sys->b_mpeg2, 0, 0 );
block_ChainAppend( &p_ps, p_data ); block_ChainAppend( &p_ps, p_data );
......
...@@ -1095,6 +1095,7 @@ static int Mux( sout_mux_t *p_mux ) ...@@ -1095,6 +1095,7 @@ static int Mux( sout_mux_t *p_mux )
p_spu->p_buffer[2] = ' '; p_spu->p_buffer[2] = ' ';
E_(EStoPES)( p_mux->p_sout, &p_spu, p_spu, E_(EStoPES)( p_mux->p_sout, &p_spu, p_spu,
p_input->p_fmt,
p_stream->i_stream_id, 1, p_stream->i_stream_id, 1,
0, 0 ); 0, 0 );
p_data->p_next = p_spu; p_data->p_next = p_spu;
...@@ -1131,8 +1132,8 @@ static int Mux( sout_mux_t *p_mux ) ...@@ -1131,8 +1132,8 @@ static int Mux( sout_mux_t *p_mux )
p_data->i_pts = p_data->i_dts; p_data->i_pts = p_data->i_dts;
} }
E_( EStoPES )( p_mux->p_sout, &p_data, p_data, E_( EStoPES )( p_mux->p_sout, &p_data, p_data,
p_stream->i_stream_id, 1, p_input->p_fmt, p_stream->i_stream_id,
b_data_alignment, i_header_size ); 1, b_data_alignment, i_header_size );
BufferChainAppend( &p_stream->chain_pes, p_data ); BufferChainAppend( &p_stream->chain_pes, 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