Commit 4bcf1bae authored by Christophe Massiot's avatar Christophe Massiot

* Implemented video_parser bitstream callback for PTS/DTS.

parent 420ec3aa
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* video_parser.h : video parser thread * video_parser.h : video parser thread
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * 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 <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -95,8 +95,6 @@ typedef struct vpar_thread_s ...@@ -95,8 +95,6 @@ typedef struct vpar_thread_s
decoder_fifo_t * p_fifo; /* PES input fifo */ decoder_fifo_t * p_fifo; /* PES input fifo */
bit_stream_t bit_stream; bit_stream_t bit_stream;
vdec_config_t * p_config; vdec_config_t * p_config;
/* Bitstream context */
mtime_t next_pts, next_dts;
/* Output properties */ /* Output properties */
vout_thread_t * p_vout; /* video output thread */ vout_thread_t * p_vout; /* video output thread */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* vpar_headers.h : video parser : headers parsing * vpar_headers.h : video parser : headers parsing
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * 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 <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* Stphane Borel <stef@via.ecp.fr> * Stphane Borel <stef@via.ecp.fr>
...@@ -82,6 +82,7 @@ typedef struct sequence_s ...@@ -82,6 +82,7 @@ typedef struct sequence_s
/* Parser context */ /* Parser context */
picture_t * p_forward; /* current forward reference frame */ picture_t * p_forward; /* current forward reference frame */
picture_t * p_backward; /* current backward reference frame */ picture_t * p_backward; /* current backward reference frame */
mtime_t next_pts, next_dts;
/* Copyright extension */ /* Copyright extension */
boolean_t b_copyright_flag; /* Whether the following boolean_t b_copyright_flag; /* Whether the following
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* video_parser.c : video parser thread * video_parser.c : video parser thread
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * 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 <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* Samuel Hocevar <sam@via.ecp.fr> * Samuel Hocevar <sam@via.ecp.fr>
...@@ -70,7 +70,8 @@ static int InitThread ( vpar_thread_t *p_vpar ); ...@@ -70,7 +70,8 @@ static int InitThread ( vpar_thread_t *p_vpar );
static void RunThread ( vpar_thread_t *p_vpar ); static void RunThread ( vpar_thread_t *p_vpar );
static void ErrorThread ( vpar_thread_t *p_vpar ); static void ErrorThread ( vpar_thread_t *p_vpar );
static void EndThread ( 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 * vpar_CreateThread: create a generic parser thread
...@@ -150,6 +151,8 @@ static int InitThread( vpar_thread_t *p_vpar ) ...@@ -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.pf_init_bit_stream( &p_vpar->bit_stream,
p_vpar->p_config->decoder_config.p_decoder_fifo ); 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 */ /* Initialize parsing data */
p_vpar->sequence.p_forward = NULL; p_vpar->sequence.p_forward = NULL;
...@@ -158,7 +161,8 @@ static int InitThread( vpar_thread_t *p_vpar ) ...@@ -158,7 +161,8 @@ static int InitThread( vpar_thread_t *p_vpar )
p_vpar->sequence.nonintra_quant.b_allocated = 0; p_vpar->sequence.nonintra_quant.b_allocated = 0;
p_vpar->sequence.chroma_intra_quant.b_allocated = 0; p_vpar->sequence.chroma_intra_quant.b_allocated = 0;
p_vpar->sequence.chroma_nonintra_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 */ /* Initialize copyright information */
p_vpar->sequence.b_copyright_flag = 0; p_vpar->sequence.b_copyright_flag = 0;
...@@ -205,12 +209,14 @@ static int InitThread( vpar_thread_t *p_vpar ) ...@@ -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]->b_error = 0;
p_vpar->pp_vdec[0]->p_vpar = p_vpar; p_vpar->pp_vdec[0]->p_vpar = p_vpar;
# if VDEC_NICE
/* Re-nice ourself */ /* Re-nice ourself */
if( nice(VDEC_NICE) == -1 ) if( nice(VDEC_NICE) == -1 )
{ {
intf_WarnMsg( 2, "vpar warning : couldn't nice() (%s)", intf_WarnMsg( 2, "vpar warning : couldn't nice() (%s)",
strerror(errno) ); strerror(errno) );
} }
# endif
#endif #endif
/* Initialize lookup tables */ /* Initialize lookup tables */
...@@ -436,7 +442,18 @@ static void EndThread( vpar_thread_t *p_vpar ) ...@@ -436,7 +442,18 @@ static void EndThread( vpar_thread_t *p_vpar )
/***************************************************************************** /*****************************************************************************
* BitstreamCallback: Import parameters from the new data/PES packet * BitstreamCallback: Import parameters from the new data/PES packet
***************************************************************************** *****************************************************************************
* This function is called when the thread ends after a sucessful * This function is called by input's NextDataPacket.
* initialization.
*****************************************************************************/ *****************************************************************************/
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;
}
}
...@@ -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.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 <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* Samuel Hocevar <sam@via.ecp.fr> * Samuel Hocevar <sam@via.ecp.fr>
...@@ -421,7 +421,6 @@ mtime_t vpar_SynchroDate( vpar_thread_t * p_vpar ) ...@@ -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, void vpar_SynchroNewPicture( vpar_thread_t * p_vpar, int i_coding_type,
boolean_t b_repeat_field ) boolean_t b_repeat_field )
{ {
pes_packet_t * p_pes;
mtime_t period = 1000000 / (p_vpar->sequence.i_frame_rate) * 1001; mtime_t period = 1000000 / (p_vpar->sequence.i_frame_rate) * 1001;
switch( i_coding_type ) switch( i_coding_type )
...@@ -470,9 +469,6 @@ void vpar_SynchroNewPicture( vpar_thread_t * p_vpar, int i_coding_type, ...@@ -470,9 +469,6 @@ void vpar_SynchroNewPicture( vpar_thread_t * p_vpar, int i_coding_type,
break; break;
} }
/* FIXME: use decoder_fifo callback */
p_pes = DECODER_FIFO_START( *p_vpar->bit_stream.p_decoder_fifo );
if( b_repeat_field ) if( b_repeat_field )
{ {
/* MPEG-2 repeat_first_field */ /* MPEG-2 repeat_first_field */
...@@ -487,30 +483,36 @@ void vpar_SynchroNewPicture( vpar_thread_t * p_vpar, int i_coding_type, ...@@ -487,30 +483,36 @@ 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->i_pts ) if( p_vpar->sequence.next_pts )
{ {
if( p_pes->i_pts - p_vpar->synchro.current_pts > PTS_THRESHOLD if( p_vpar->sequence.next_pts - p_vpar->synchro.current_pts
|| p_vpar->synchro.current_pts - p_pes->i_pts > PTS_THRESHOLD ) > PTS_THRESHOLD
|| p_vpar->synchro.current_pts - p_vpar->sequence.next_pts
> PTS_THRESHOLD )
{ {
intf_WarnMsg( 2, intf_WarnMsg( 2,
"vpar synchro warning: pts != current_date (%lld)", "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_vpar->synchro.current_pts = p_vpar->sequence.next_pts;
p_pes->i_pts = 0; p_vpar->sequence.next_pts = 0;
} }
} }
else else
{ {
if( p_vpar->synchro.backward_pts ) if( p_vpar->synchro.backward_pts )
{ {
if( p_pes->i_dts && if( p_vpar->sequence.next_dts &&
(p_pes->i_dts - p_vpar->synchro.backward_pts > PTS_THRESHOLD (p_vpar->sequence.next_dts - p_vpar->synchro.backward_pts
|| p_vpar->synchro.backward_pts - p_pes->i_dts > PTS_THRESHOLD) ) > PTS_THRESHOLD
|| p_vpar->synchro.backward_pts - p_vpar->sequence.next_dts
> PTS_THRESHOLD) )
{ {
intf_WarnMsg( 2, intf_WarnMsg( 2,
"vpar synchro warning: backward_pts != dts (%lld)", "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 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, ...@@ -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.current_pts = p_vpar->synchro.backward_pts;
p_vpar->synchro.backward_pts = 0; 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 if( p_vpar->sequence.next_dts - p_vpar->synchro.current_pts
|| p_vpar->synchro.current_pts - p_pes->i_dts > PTS_THRESHOLD ) > PTS_THRESHOLD
|| p_vpar->synchro.current_pts - p_vpar->sequence.next_dts
> PTS_THRESHOLD )
{ {
intf_WarnMsg( 2, intf_WarnMsg( 2,
"vpar synchro warning: dts != current_pts (%lld)", "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. */ /* By definition of a DTS. */
p_vpar->synchro.current_pts = p_pes->i_dts; p_vpar->synchro.current_pts = p_vpar->sequence.next_dts;
p_pes->i_dts = 0; 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. */ /* 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_vpar->sequence.next_pts;
p_pes->i_pts = 0; p_vpar->sequence.next_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
} }
} }
......
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