diff --git a/src/video_decoder/video_parser.h b/src/video_decoder/video_parser.h index 76853ef545..bf96ce4af4 100644 --- a/src/video_decoder/video_parser.h +++ b/src/video_decoder/video_parser.h @@ -2,7 +2,7 @@ * video_parser.h : video parser thread ***************************************************************************** * Copyright (C) 1999, 2000 VideoLAN - * $Id: video_parser.h,v 1.3 2001/01/13 12:57:20 sam Exp $ + * $Id: video_parser.h,v 1.4 2001/01/15 13:25:09 massiot Exp $ * * Authors: Christophe Massiot * @@ -95,8 +95,6 @@ typedef struct vpar_thread_s decoder_fifo_t * p_fifo; /* PES input fifo */ bit_stream_t bit_stream; vdec_config_t * p_config; - /* Bitstream context */ - mtime_t next_pts, next_dts; /* Output properties */ vout_thread_t * p_vout; /* video output thread */ diff --git a/src/video_decoder/vpar_headers.h b/src/video_decoder/vpar_headers.h index 758a7e61ed..71057b3c59 100644 --- a/src/video_decoder/vpar_headers.h +++ b/src/video_decoder/vpar_headers.h @@ -2,7 +2,7 @@ * vpar_headers.h : video parser : headers parsing ***************************************************************************** * Copyright (C) 1999, 2000 VideoLAN - * $Id: vpar_headers.h,v 1.1 2000/12/21 17:19:52 massiot Exp $ + * $Id: vpar_headers.h,v 1.2 2001/01/15 13:25:09 massiot Exp $ * * Authors: Christophe Massiot * Stéphane Borel @@ -82,6 +82,7 @@ typedef struct sequence_s /* Parser context */ picture_t * p_forward; /* current forward reference frame */ picture_t * p_backward; /* current backward reference frame */ + mtime_t next_pts, next_dts; /* Copyright extension */ boolean_t b_copyright_flag; /* Whether the following diff --git a/src/video_parser/video_parser.c b/src/video_parser/video_parser.c index e889252b03..3c2f214950 100644 --- a/src/video_parser/video_parser.c +++ b/src/video_parser/video_parser.c @@ -2,7 +2,7 @@ * video_parser.c : video parser thread ***************************************************************************** * Copyright (C) 1999, 2000 VideoLAN - * $Id: video_parser.c,v 1.66 2001/01/13 12:57:21 sam Exp $ + * $Id: video_parser.c,v 1.67 2001/01/15 13:25:09 massiot Exp $ * * Authors: Christophe Massiot * Samuel Hocevar @@ -70,7 +70,8 @@ static int InitThread ( vpar_thread_t *p_vpar ); static void RunThread ( vpar_thread_t *p_vpar ); static void ErrorThread ( vpar_thread_t *p_vpar ); static void EndThread ( vpar_thread_t *p_vpar ); -static void BitstreamCallback ( bit_stream_t *p_bit_stream ); +static void BitstreamCallback ( bit_stream_t *p_bit_stream, + boolean_t b_new_pes ); /***************************************************************************** * vpar_CreateThread: create a generic parser thread @@ -150,6 +151,8 @@ static int InitThread( vpar_thread_t *p_vpar ) p_vpar->p_config->decoder_config.pf_init_bit_stream( &p_vpar->bit_stream, p_vpar->p_config->decoder_config.p_decoder_fifo ); + p_vpar->bit_stream.pf_bitstream_callback = BitstreamCallback; + p_vpar->bit_stream.p_callback_arg = (void *)p_vpar; /* Initialize parsing data */ p_vpar->sequence.p_forward = NULL; @@ -158,7 +161,8 @@ static int InitThread( vpar_thread_t *p_vpar ) p_vpar->sequence.nonintra_quant.b_allocated = 0; p_vpar->sequence.chroma_intra_quant.b_allocated = 0; p_vpar->sequence.chroma_nonintra_quant.b_allocated = 0; - /* FIXME : initialize matrix_coefficients, but to what value ? */ + p_vpar->sequence.i_matrix_coefficients = 1; + p_vpar->sequence.next_pts = p_vpar->sequence.next_dts = 0; /* Initialize copyright information */ p_vpar->sequence.b_copyright_flag = 0; @@ -205,12 +209,14 @@ static int InitThread( vpar_thread_t *p_vpar ) p_vpar->pp_vdec[0]->b_error = 0; p_vpar->pp_vdec[0]->p_vpar = p_vpar; +# if VDEC_NICE /* Re-nice ourself */ if( nice(VDEC_NICE) == -1 ) { intf_WarnMsg( 2, "vpar warning : couldn't nice() (%s)", strerror(errno) ); } +# endif #endif /* Initialize lookup tables */ @@ -436,7 +442,18 @@ static void EndThread( vpar_thread_t *p_vpar ) /***************************************************************************** * BitstreamCallback: Import parameters from the new data/PES packet ***************************************************************************** - * This function is called when the thread ends after a sucessful - * initialization. + * This function is called by input's NextDataPacket. *****************************************************************************/ -static void BitstreamCallback ( bit_stream_t *p_bit_stream ); +static void BitstreamCallback ( bit_stream_t * p_bit_stream, + boolean_t b_new_pes ) +{ + vpar_thread_t * p_vpar = (vpar_thread_t *)p_bit_stream->p_callback_arg; + + if( b_new_pes ) + { + p_vpar->sequence.next_pts = + DECODER_FIFO_START( *p_bit_stream->p_decoder_fifo )->i_pts; + p_vpar->sequence.next_dts = + DECODER_FIFO_START( *p_bit_stream->p_decoder_fifo )->i_dts; + } +} diff --git a/src/video_parser/vpar_synchro.c b/src/video_parser/vpar_synchro.c index 83c70c9ed1..47dc95efe2 100644 --- a/src/video_parser/vpar_synchro.c +++ b/src/video_parser/vpar_synchro.c @@ -2,7 +2,7 @@ * vpar_synchro.c : frame dropping routines ***************************************************************************** * Copyright (C) 1999, 2000 VideoLAN - * $Id: vpar_synchro.c,v 1.71 2001/01/13 12:57:21 sam Exp $ + * $Id: vpar_synchro.c,v 1.72 2001/01/15 13:25:09 massiot Exp $ * * Authors: Christophe Massiot * Samuel Hocevar @@ -421,7 +421,6 @@ mtime_t vpar_SynchroDate( vpar_thread_t * p_vpar ) void vpar_SynchroNewPicture( vpar_thread_t * p_vpar, int i_coding_type, boolean_t b_repeat_field ) { - pes_packet_t * p_pes; mtime_t period = 1000000 / (p_vpar->sequence.i_frame_rate) * 1001; switch( i_coding_type ) @@ -470,9 +469,6 @@ void vpar_SynchroNewPicture( vpar_thread_t * p_vpar, int i_coding_type, break; } - /* FIXME: use decoder_fifo callback */ - p_pes = DECODER_FIFO_START( *p_vpar->bit_stream.p_decoder_fifo ); - if( b_repeat_field ) { /* MPEG-2 repeat_first_field */ @@ -487,30 +483,36 @@ void vpar_SynchroNewPicture( vpar_thread_t * p_vpar, int i_coding_type, if( i_coding_type == B_CODING_TYPE ) { - if( p_pes->i_pts ) + if( p_vpar->sequence.next_pts ) { - if( p_pes->i_pts - p_vpar->synchro.current_pts > PTS_THRESHOLD - || p_vpar->synchro.current_pts - p_pes->i_pts > PTS_THRESHOLD ) + if( p_vpar->sequence.next_pts - p_vpar->synchro.current_pts + > PTS_THRESHOLD + || p_vpar->synchro.current_pts - p_vpar->sequence.next_pts + > PTS_THRESHOLD ) { intf_WarnMsg( 2, "vpar synchro warning: pts != current_date (%lld)", - p_vpar->synchro.current_pts - p_pes->i_pts ); + p_vpar->synchro.current_pts + - p_vpar->sequence.next_pts ); } - p_vpar->synchro.current_pts = p_pes->i_pts; - p_pes->i_pts = 0; + p_vpar->synchro.current_pts = p_vpar->sequence.next_pts; + p_vpar->sequence.next_pts = 0; } } else { if( p_vpar->synchro.backward_pts ) { - if( p_pes->i_dts && - (p_pes->i_dts - p_vpar->synchro.backward_pts > PTS_THRESHOLD - || p_vpar->synchro.backward_pts - p_pes->i_dts > PTS_THRESHOLD) ) + if( p_vpar->sequence.next_dts && + (p_vpar->sequence.next_dts - p_vpar->synchro.backward_pts + > PTS_THRESHOLD + || p_vpar->synchro.backward_pts - p_vpar->sequence.next_dts + > PTS_THRESHOLD) ) { intf_WarnMsg( 2, "vpar synchro warning: backward_pts != dts (%lld)", - p_vpar->synchro.backward_pts - p_pes->i_dts ); + p_vpar->synchro.backward_pts + - p_vpar->sequence.next_dts ); } if( p_vpar->synchro.backward_pts - p_vpar->synchro.current_pts @@ -525,43 +527,28 @@ void vpar_SynchroNewPicture( vpar_thread_t * p_vpar, int i_coding_type, p_vpar->synchro.current_pts = p_vpar->synchro.backward_pts; p_vpar->synchro.backward_pts = 0; } - else if( p_pes->i_dts ) + else if( p_vpar->sequence.next_dts ) { - if( p_pes->i_dts - p_vpar->synchro.current_pts > PTS_THRESHOLD - || p_vpar->synchro.current_pts - p_pes->i_dts > PTS_THRESHOLD ) + if( p_vpar->sequence.next_dts - p_vpar->synchro.current_pts + > PTS_THRESHOLD + || p_vpar->synchro.current_pts - p_vpar->sequence.next_dts + > PTS_THRESHOLD ) { intf_WarnMsg( 2, "vpar synchro warning: dts != current_pts (%lld)", - p_vpar->synchro.current_pts - p_pes->i_dts ); + p_vpar->synchro.current_pts + - p_vpar->sequence.next_dts ); } /* By definition of a DTS. */ - p_vpar->synchro.current_pts = p_pes->i_dts; - p_pes->i_dts = 0; + p_vpar->synchro.current_pts = p_vpar->sequence.next_dts; + p_vpar->sequence.next_dts = 0; } - if( p_pes->i_pts ) + if( p_vpar->sequence.next_pts ) { -#if 0 - int i_n_b; -#endif - /* Store the PTS for the next time we have to date an I picture. */ - p_vpar->synchro.backward_pts = p_pes->i_pts; - p_pes->i_pts = 0; - /* FIXME : disabled because it conflicts with streams having - * b_repeat_first_field */ -#if 0 - i_n_b = (p_vpar->synchro.backward_pts - - p_vpar->synchro.current_pts) / period - 1; - if( i_n_b != p_vpar->synchro.i_n_b ) - { - intf_WarnMsg( 1, - "Anticipating a stream periodicity change from" - " B[%d] to B[%d]", - p_vpar->synchro.i_n_b, i_n_b ); - p_vpar->synchro.i_n_b = i_n_b; - } -#endif + p_vpar->synchro.backward_pts = p_vpar->sequence.next_pts; + p_vpar->sequence.next_pts = 0; } }