Commit 2535b235 authored by Christophe Massiot's avatar Christophe Massiot

We now read the DTS (but we don't use it for the moment).

NB : b_has_pts has disappeared for brevity reasons, use i_pts != 0 instead.
parent a8bca726
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* input_ext-dec.h: structures exported to the VideoLAN decoders * input_ext-dec.h: structures exported to the VideoLAN decoders
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: input_ext-dec.h,v 1.6 2000/12/26 19:14:46 massiot Exp $ * $Id: input_ext-dec.h,v 1.7 2000/12/27 18:35:45 massiot Exp $
* *
* Authors: * Authors:
* *
...@@ -59,8 +59,8 @@ typedef struct pes_packet_s ...@@ -59,8 +59,8 @@ typedef struct pes_packet_s
boolean_t b_discontinuity; /* This packet doesn't follow the boolean_t b_discontinuity; /* This packet doesn't follow the
* previous one */ * previous one */
boolean_t b_has_pts; /* is the following field set ? */ mtime_t i_pts;/* the PTS for this packet (zero if unset) */
mtime_t i_pts; /* the PTS for this packet (if set above) */ mtime_t i_dts;/* the DTS for this packet (zero if unset) */
int i_pes_size; /* size of the current PES packet */ int i_pes_size; /* size of the current PES packet */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* ac3_decoder_thread.c: ac3 decoder thread * ac3_decoder_thread.c: ac3 decoder thread
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: ac3_decoder_thread.c,v 1.21 2000/12/22 13:04:44 sam Exp $ * $Id: ac3_decoder_thread.c,v 1.22 2000/12/27 18:35:45 massiot Exp $
* *
* Authors: * Authors:
* *
...@@ -229,10 +229,10 @@ static void RunThread (ac3dec_thread_t * p_ac3dec) ...@@ -229,10 +229,10 @@ static void RunThread (ac3dec_thread_t * p_ac3dec)
p_ac3dec->sync_ptr = 0; p_ac3dec->sync_ptr = 0;
} }
if (DECODER_FIFO_START(*p_ac3dec->p_fifo)->b_has_pts) if (DECODER_FIFO_START(*p_ac3dec->p_fifo)->i_pts)
{ {
p_ac3dec->p_aout_fifo->date[p_ac3dec->p_aout_fifo->l_end_frame] = DECODER_FIFO_START(*p_ac3dec->p_fifo)->i_pts; p_ac3dec->p_aout_fifo->date[p_ac3dec->p_aout_fifo->l_end_frame] = DECODER_FIFO_START(*p_ac3dec->p_fifo)->i_pts;
DECODER_FIFO_START(*p_ac3dec->p_fifo)->b_has_pts = 0; DECODER_FIFO_START(*p_ac3dec->p_fifo)->i_pts = 0;
} }
else else
{ {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* audio_decoder.c: MPEG audio decoder thread * audio_decoder.c: MPEG audio decoder thread
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: audio_decoder.c,v 1.42 2000/12/22 13:04:44 sam Exp $ * $Id: audio_decoder.c,v 1.43 2000/12/27 18:35:45 massiot Exp $
* *
* Authors: Michel Kaempf <maxx@via.ecp.fr> * Authors: Michel Kaempf <maxx@via.ecp.fr>
* Michel Lespinasse <walken@via.ecp.fr> * Michel Lespinasse <walken@via.ecp.fr>
...@@ -217,11 +217,11 @@ static void RunThread (adec_thread_t * p_adec) ...@@ -217,11 +217,11 @@ static void RunThread (adec_thread_t * p_adec)
} }
if( DECODER_FIFO_START( *p_adec->p_fifo)->b_has_pts ) if( DECODER_FIFO_START( *p_adec->p_fifo)->i_pts )
{ {
p_adec->p_aout_fifo->date[p_adec->p_aout_fifo->l_end_frame] = p_adec->p_aout_fifo->date[p_adec->p_aout_fifo->l_end_frame] =
DECODER_FIFO_START( *p_adec->p_fifo )->i_pts; DECODER_FIFO_START( *p_adec->p_fifo )->i_pts;
DECODER_FIFO_START(*p_adec->p_fifo)->b_has_pts = 0; DECODER_FIFO_START(*p_adec->p_fifo)->i_pts = 0;
} }
else else
{ {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* input_netlist.c: netlist management * input_netlist.c: netlist management
***************************************************************************** *****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN * Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: input_netlist.c,v 1.21 2000/12/22 13:04:45 sam Exp $ * $Id: input_netlist.c,v 1.22 2000/12/27 18:35:45 massiot Exp $
* *
* Authors: Henri Fallon <henri@videolan.org> * Authors: Henri Fallon <henri@videolan.org>
* *
...@@ -313,7 +313,7 @@ struct pes_packet_s * input_NetlistNewPES( void * p_method_data ) ...@@ -313,7 +313,7 @@ struct pes_packet_s * input_NetlistNewPES( void * p_method_data )
p_return->b_messed_up = p_return->b_messed_up =
p_return->b_data_alignment = p_return->b_data_alignment =
p_return->b_discontinuity = p_return->b_discontinuity =
p_return->b_has_pts = 0; p_return->i_pts = p_return->i_dts = 0;
p_return->i_pes_size = 0; p_return->i_pes_size = 0;
p_return->p_first = NULL; p_return->p_first = NULL;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* input_ps.c: PS demux and packet management * input_ps.c: PS demux and packet management
***************************************************************************** *****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN * Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: input_ps.c,v 1.14 2000/12/27 09:54:53 sam Exp $ * $Id: input_ps.c,v 1.15 2000/12/27 18:35:45 massiot Exp $
* *
* Authors: * Authors:
* *
...@@ -442,7 +442,7 @@ static pes_packet_t * NewPES( void * p_garbage ) ...@@ -442,7 +442,7 @@ static pes_packet_t * NewPES( void * p_garbage )
} }
p_pes->b_messed_up = p_pes->b_data_alignment = p_pes->b_discontinuity = p_pes->b_messed_up = p_pes->b_data_alignment = p_pes->b_discontinuity =
p_pes->b_has_pts = 0; p_pes->i_pts = p_pes->i_dts = 0;
p_pes->i_pes_size = 0; p_pes->i_pes_size = 0;
p_pes->p_first = NULL; p_pes->p_first = NULL;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* mpeg_system.c: TS, PS and PES management * mpeg_system.c: TS, PS and PES management
***************************************************************************** *****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN * Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: mpeg_system.c,v 1.19 2000/12/26 19:14:47 massiot Exp $ * $Id: mpeg_system.c,v 1.20 2000/12/27 18:35:45 massiot Exp $
* *
* Authors: * Authors:
* *
...@@ -186,11 +186,12 @@ void input_ParsePES( input_thread_t * p_input, es_descriptor_t * p_es ) ...@@ -186,11 +186,12 @@ void input_ParsePES( input_thread_t * p_input, es_descriptor_t * p_es )
{ {
/* MPEG-2 : the PES header contains at least 3 more bytes. */ /* MPEG-2 : the PES header contains at least 3 more bytes. */
size_t i_max_len; size_t i_max_len;
boolean_t b_has_pts, b_has_dts;
byte_t p_full_header[12];
p_pes->b_data_alignment = p_header[6] & 0x04; p_pes->b_data_alignment = p_header[6] & 0x04;
/* Re-use p_header buffer now that we don't need it. */ i_max_len = MoveChunk( p_full_header, &p_data, &p_byte, 12 );
i_max_len = MoveChunk( p_header, &p_data, &p_byte, 7 );
if( i_max_len < 2 ) if( i_max_len < 2 )
{ {
intf_WarnMsg( 3, intf_WarnMsg( 3,
...@@ -201,11 +202,12 @@ void input_ParsePES( input_thread_t * p_input, es_descriptor_t * p_es ) ...@@ -201,11 +202,12 @@ void input_ParsePES( input_thread_t * p_input, es_descriptor_t * p_es )
return; return;
} }
p_pes->b_has_pts = p_header[0] & 0x80; b_has_pts = p_full_header[0] & 0x80;
i_pes_header_size = p_header[1] + 9; b_has_dts = p_full_header[0] & 0x40;
i_pes_header_size = p_full_header[1] + 9;
/* Now parse the optional header extensions */ /* Now parse the optional header extensions */
if( p_pes->b_has_pts ) if( b_has_pts )
{ {
if( i_max_len < 7 ) if( i_max_len < 7 )
{ {
...@@ -218,15 +220,37 @@ void input_ParsePES( input_thread_t * p_input, es_descriptor_t * p_es ) ...@@ -218,15 +220,37 @@ void input_ParsePES( input_thread_t * p_input, es_descriptor_t * p_es )
return; return;
} }
p_pes->i_pts = p_pes->i_pts =
( ((mtime_t)(p_header[2] & 0x0E) << 29) | ( ((mtime_t)(p_full_header[2] & 0x0E) << 29) |
(((mtime_t)U16_AT(p_header + 3) << 14) - (1 << 14)) | (((mtime_t)U16_AT(p_full_header + 3) << 14) - (1 << 14)) |
((mtime_t)U16_AT(p_header + 5) >> 1) ) * 300; ((mtime_t)U16_AT(p_full_header + 5) >> 1) ) * 300;
p_pes->i_pts /= 27; p_pes->i_pts /= 27;
if( b_has_dts )
{
if( i_max_len < 12 )
{
intf_WarnMsg( 3,
"PES packet too short to have a MPEG-2 header" );
p_input->p_plugin->pf_delete_pes(
p_input->p_method_data,
p_pes );
p_pes = NULL;
return;
}
p_pes->i_dts =
( ((mtime_t)(p_full_header[7] & 0x0E) << 29) |
(((mtime_t)U16_AT(p_full_header + 10) << 14)
- (1 << 14)) |
((mtime_t)U16_AT(p_full_header + 12) >> 1) ) * 300;
p_pes->i_dts /= 27;
}
} }
} }
else else
{ {
/* Probably MPEG-1 */ /* Probably MPEG-1 */
boolean_t b_has_pts, b_has_dts;
i_pes_header_size = 6; i_pes_header_size = 6;
p_data = p_pes->p_first; p_data = p_pes->p_first;
p_byte = p_data->p_payload_start; p_byte = p_data->p_payload_start;
...@@ -272,18 +296,15 @@ void input_ParsePES( input_thread_t * p_input, es_descriptor_t * p_es ) ...@@ -272,18 +296,15 @@ void input_ParsePES( input_thread_t * p_input, es_descriptor_t * p_es )
i_pes_header_size++; i_pes_header_size++;
if( *p_byte & 0x10 ) b_has_pts = *p_byte & 0x20;
{ b_has_dts = *p_byte & 0x10;
/* DTS */
i_pes_header_size += 5; if( b_has_pts )
}
if( (p_pes->b_has_pts = (*p_byte & 0x20)) )
{ {
/* PTS */ byte_t p_ts[5];
byte_t p_pts[5];
i_pes_header_size += 4; i_pes_header_size += 4;
if( MoveChunk( p_pts, &p_data, &p_byte, 5 ) != 5 ) if( MoveChunk( p_ts, &p_data, &p_byte, 5 ) != 5 )
{ {
intf_WarnMsg( 3, intf_WarnMsg( 3,
"PES packet too short to have a MPEG-1 header" ); "PES packet too short to have a MPEG-1 header" );
...@@ -294,26 +315,46 @@ void input_ParsePES( input_thread_t * p_input, es_descriptor_t * p_es ) ...@@ -294,26 +315,46 @@ void input_ParsePES( input_thread_t * p_input, es_descriptor_t * p_es )
} }
p_pes->i_pts = p_pes->i_pts =
( ((mtime_t)(p_pts[0] & 0x0E) << 29) | ( ((mtime_t)(p_ts[0] & 0x0E) << 29) |
(((mtime_t)U16_AT(p_pts + 1) << 14) - (1 << 14)) | (((mtime_t)U16_AT(p_ts + 1) << 14) - (1 << 14)) |
((mtime_t)U16_AT(p_pts + 3) >> 1) ) * 300; ((mtime_t)U16_AT(p_ts + 3) >> 1) ) * 300;
p_pes->i_pts /= 27; p_pes->i_pts /= 27;
if( b_has_dts )
{
i_pes_header_size += 5;
if( MoveChunk( p_ts, &p_data, &p_byte, 5 ) != 5 )
{
intf_WarnMsg( 3,
"PES packet too short to have a MPEG-1 header" );
p_input->p_plugin->pf_delete_pes(
p_input->p_method_data, p_pes );
p_pes = NULL;
return;
}
p_pes->i_dts =
( ((mtime_t)(p_ts[0] & 0x0E) << 29) |
(((mtime_t)U16_AT(p_ts + 1) << 14) - (1 << 14)) |
((mtime_t)U16_AT(p_ts + 3) >> 1) ) * 300;
p_pes->i_dts /= 27;
}
} }
} }
/* PTS management */ /* PTS management */
if( p_pes->b_has_pts ) if( p_pes->i_pts )
{ {
//intf_Msg("%lld", p_pes->i_pts); //intf_Msg("%lld", p_pes->i_pts);
switch( p_es->p_pgrm->i_synchro_state ) switch( p_es->p_pgrm->i_synchro_state )
{ {
case SYNCHRO_NOT_STARTED: case SYNCHRO_NOT_STARTED:
case SYNCHRO_START: case SYNCHRO_START:
p_pes->b_has_pts = 0; p_pes->i_pts = p_pes->i_dts = 0;
break; break;
case SYNCHRO_REINIT: /* We skip a PES | Why ?? --Meuuh */ case SYNCHRO_REINIT: /* We skip a PES | Why ?? --Meuuh */
p_pes->b_has_pts = 0; p_pes->i_pts = p_pes->i_dts = 0;
p_es->p_pgrm->i_synchro_state = SYNCHRO_START; p_es->p_pgrm->i_synchro_state = SYNCHRO_START;
break; break;
...@@ -321,6 +362,9 @@ void input_ParsePES( input_thread_t * p_input, es_descriptor_t * p_es ) ...@@ -321,6 +362,9 @@ void input_ParsePES( input_thread_t * p_input, es_descriptor_t * p_es )
p_pes->i_pts += p_es->p_pgrm->delta_cr p_pes->i_pts += p_es->p_pgrm->delta_cr
+ p_es->p_pgrm->delta_absolute + p_es->p_pgrm->delta_absolute
+ DEFAULT_PTS_DELAY; + DEFAULT_PTS_DELAY;
p_pes->i_dts += p_es->p_pgrm->delta_cr
+ p_es->p_pgrm->delta_absolute
+ DEFAULT_PTS_DELAY;
break; break;
} }
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* lpcm_decoder_thread.c: lpcm decoder thread * lpcm_decoder_thread.c: lpcm decoder thread
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: lpcm_decoder_thread.c,v 1.6 2000/12/22 13:04:45 sam Exp $ * $Id: lpcm_decoder_thread.c,v 1.7 2000/12/27 18:35:45 massiot Exp $
* *
* Authors: * Authors:
* *
...@@ -179,10 +179,10 @@ static void RunThread (lpcmdec_thread_t * p_lpcmdec) ...@@ -179,10 +179,10 @@ static void RunThread (lpcmdec_thread_t * p_lpcmdec)
/* have to find a synchro point */ /* have to find a synchro point */
} }
if (DECODER_FIFO_START(*p_lpcmdec->p_fifo)->b_has_pts) if (DECODER_FIFO_START(*p_lpcmdec->p_fifo)->i_pts)
{ {
p_lpcmdec->p_aout_fifo->date[p_lpcmdec->p_aout_fifo->l_end_frame] = DECODER_FIFO_START(*p_lpcmdec->p_fifo)->i_pts; p_lpcmdec->p_aout_fifo->date[p_lpcmdec->p_aout_fifo->l_end_frame] = DECODER_FIFO_START(*p_lpcmdec->p_fifo)->i_pts;
DECODER_FIFO_START(*p_lpcmdec->p_fifo)->b_has_pts = 0; DECODER_FIFO_START(*p_lpcmdec->p_fifo)->i_pts = 0;
} }
else else
{ {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* vpar_synchro.c : frame dropping routines * vpar_synchro.c : frame dropping routines
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: vpar_synchro.c,v 1.65 2000/12/27 18:09:02 massiot Exp $ * $Id: vpar_synchro.c,v 1.66 2000/12/27 18:35:45 massiot Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* Samuel Hocevar <sam@via.ecp.fr> * Samuel Hocevar <sam@via.ecp.fr>
...@@ -482,7 +482,7 @@ void vpar_SynchroNewPicture( vpar_thread_t * p_vpar, int i_coding_type ) ...@@ -482,7 +482,7 @@ void vpar_SynchroNewPicture( vpar_thread_t * p_vpar, int i_coding_type )
if( i_coding_type == B_CODING_TYPE ) if( i_coding_type == B_CODING_TYPE )
{ {
if( p_pes->b_has_pts ) if( p_pes->i_pts )
{ {
if( p_pes->i_pts < p_vpar->synchro.current_pts ) if( p_pes->i_pts < p_vpar->synchro.current_pts )
{ {
...@@ -490,7 +490,7 @@ void vpar_SynchroNewPicture( vpar_thread_t * p_vpar, int i_coding_type ) ...@@ -490,7 +490,7 @@ void vpar_SynchroNewPicture( vpar_thread_t * p_vpar, int i_coding_type )
"vpar synchro warning: pts_date < current_date" ); "vpar synchro warning: pts_date < current_date" );
} }
p_vpar->synchro.current_pts = p_pes->i_pts; p_vpar->synchro.current_pts = p_pes->i_pts;
p_pes->b_has_pts = 0; p_pes->i_pts = 0;
} }
else else
{ {
...@@ -516,11 +516,11 @@ void vpar_SynchroNewPicture( vpar_thread_t * p_vpar, int i_coding_type ) ...@@ -516,11 +516,11 @@ void vpar_SynchroNewPicture( vpar_thread_t * p_vpar, int i_coding_type )
p_vpar->synchro.backward_pts = 0; p_vpar->synchro.backward_pts = 0;
} }
if( p_pes->b_has_pts ) if( p_pes->i_pts )
{ {
/* Store the PTS for the next time we have to date an I picture. */ /* Store the PTS for the next time we have to date an I picture. */
p_vpar->synchro.backward_pts = p_pes->i_pts; p_vpar->synchro.backward_pts = p_pes->i_pts;
p_pes->b_has_pts = 0; p_pes->i_pts = 0;
} }
} }
......
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