src/input/input_dec.o \
src/input/input_programs.o \
src/input/input_netlist.o \
+ src/input/input_clock.o \
src/input/input.o
AUDIO_OUTPUT = src/audio_output/audio_output.o
* input_ext-dec.h: structures exported to the VideoLAN decoders
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
- * $Id: input_ext-dec.h,v 1.19 2001/01/22 18:04:10 massiot Exp $
+ * $Id: input_ext-dec.h,v 1.20 2001/01/24 19:05:55 massiot Exp $
*
* Authors:
*
boolean_t b_discontinuity; /* This packet doesn't follow the
* previous one */
- mtime_t i_pts;/* the PTS for this packet (zero if unset) */
- mtime_t i_dts;/* the DTS for this packet (zero if unset) */
+ mtime_t i_pts; /* PTS for this packet (zero if unset) */
+ mtime_t i_dts; /* DTS for this packet (zero if unset) */
+ int i_rate; /* current pace of reading
+ * (see stream_control.h) */
int i_pes_size; /* size of the current PES packet */
* control the pace of reading.
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
- * $Id: input_ext-intf.h,v 1.9 2001/01/14 07:08:00 stef Exp $
+ * $Id: input_ext-intf.h,v 1.10 2001/01/24 19:05:55 massiot Exp $
*
* Authors:
*
u16 i_id; /* stream ID for PS, PID for TS */
u8 i_stream_id; /* stream ID defined in the PES */
u8 i_type; /* stream type */
+ boolean_t b_audio; /* is the stream an audio stream that
+ * will need to be discarded with
+ * fast forward and slow motion ? */
/* Demultiplexer information */
void * p_demux_data;
/* These ones might violate the norm : */
#define DVD_SPU_ES 0x82
#define LPCM_AUDIO_ES 0x83
-#define UNKNOWN_ES 0xFF
+#define UNKNOWN_ES 0xFF
/*****************************************************************************
* pgrm_descriptor_t
char * psz_srv_name;
/* Synchronization information */
- /* system_date = PTS_date + delta_cr + delta_absolute */
mtime_t delta_cr;
- mtime_t delta_absolute;
+ mtime_t cr_ref, sysdate_ref;
mtime_t last_cr;
count_t c_average_count;
/* counter used to compute dynamic average values */
/* Synchro states */
#define SYNCHRO_OK 0
-#define SYNCHRO_NOT_STARTED 1
-#define SYNCHRO_START 2
-#define SYNCHRO_REINIT 3
+#define SYNCHRO_START 1
+#define SYNCHRO_REINIT 2
/*****************************************************************************
* stream_descriptor_t
boolean_t b_pace_control; /* can we read when we want ? */
boolean_t b_seekable; /* can we do lseek() ? */
/* if (b_seekable) : */
- off_t i_size; /* total size of the file (in bytes) */
- off_t i_tell;/* actual location in the file (in bytes) */
+ off_t i_size; /* total size of the file
+ * (in arbitrary units) */
+ off_t i_tell; /* actual location in the file
+ * (in arbitrary units) */
+ off_t i_seek; /* next requested location (changed
+ * by the interface thread */
+
+ /* New status and rate requested by the interface */
+ int i_new_status, i_new_rate;
/* Demultiplexer data */
void * p_demux_data;
int i_status;
/* if i_status == FORWARD_S or BACKWARD_S */
int i_rate;
- s64 i_ref_sysdate;
- s64 i_ref_clock;
boolean_t b_mute;
boolean_t b_bw; /* black & white */
#define PAUSE_S 1
#define FORWARD_S 2
#define BACKWARD_S 3
+#define REWIND_S 4 /* Not supported for the moment */
+#define NOT_STARTED_S 10
+#define START_S 11
#define DEFAULT_RATE 1000
* decoders.
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
- * $Id: input.c,v 1.72 2001/01/20 20:59:44 stef Exp $
+ * $Id: input.c,v 1.73 2001/01/24 19:05:55 massiot Exp $
*
* Authors:
*
/* Initialize stream control properties. */
p_input->stream.control.i_status = PLAYING_S;
p_input->stream.control.i_rate = DEFAULT_RATE;
- p_input->stream.control.i_ref_sysdate = 0;
- p_input->stream.control.i_ref_clock = 0;
p_input->stream.control.b_mute = 0;
p_input->stream.control.b_bw = 0;
* input.h: structures of the input not exported to other modules
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
- * $Id: input.h,v 1.11 2001/01/18 17:40:06 massiot Exp $
+ * $Id: input.h,v 1.12 2001/01/24 19:05:55 massiot Exp $
*
* Authors:
*
void input_EndDecoder( struct input_thread_s *, struct es_descriptor_s * );
void input_DecodePES( struct decoder_fifo_s *, struct pes_packet_s * );
+/*****************************************************************************
+ * Prototypes from input_clock.c
+ *****************************************************************************/
+mtime_t input_ClockToSysdate( struct input_thread_s *,
+ struct pgrm_descriptor_s *, mtime_t );
+void input_ClockNewRef( struct input_thread_s *,
+ struct pgrm_descriptor_s *, mtime_t );
+
/*****************************************************************************
* Create a NULL packet for padding in case of a data loss
*****************************************************************************/
return;
}
+ p_pes->i_rate = p_input->stream.control.i_rate;
p_pes->p_first = p_pad_data;
p_pes->b_messed_up = p_pes->b_discontinuity = 1;
input_DecodePES( p_es->p_decoder_fifo, p_pes );
--- /dev/null
+/*****************************************************************************
+ * input_clock.c: Clock/System date conversions, stream management
+ *****************************************************************************
+ * Copyright (C) 1999, 2000 VideoLAN
+ * $Id: input_clock.c,v 1.1 2001/01/24 19:05:55 massiot Exp $
+ *
+ * Authors: Christophe Massiot <massiot@via.ecp.fr>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Preamble
+ *****************************************************************************/
+#include "defs.h"
+
+#include "config.h"
+#include "common.h"
+#include "threads.h"
+#include "mtime.h"
+#include "intf_msg.h"
+
+#include "stream_control.h"
+#include "input_ext-intf.h"
+#include "input_ext-dec.h"
+
+#include "input.h"
+
+/*****************************************************************************
+ * input_ClockToSysdate: converts a movie clock to system date
+ *****************************************************************************/
+mtime_t input_ClockToSysdate( input_thread_t * p_input,
+ pgrm_descriptor_t * p_pgrm, mtime_t i_clock )
+{
+ mtime_t i_sysdate = 0;
+
+ if( p_pgrm->i_synchro_state == SYNCHRO_OK )
+ {
+ i_sysdate = (i_clock - p_pgrm->cr_ref)
+ * p_input->stream.control.i_rate
+ * 300
+ / 27
+ / DEFAULT_RATE
+ + p_pgrm->sysdate_ref;
+ }
+
+ return( i_sysdate );
+}
+
+/*****************************************************************************
+ * input_ClockNewRef: writes a new clock reference
+ *****************************************************************************/
+void input_ClockNewRef( input_thread_t * p_input, pgrm_descriptor_t * p_pgrm,
+ mtime_t i_clock )
+{
+ p_pgrm->cr_ref = i_clock;
+ p_pgrm->sysdate_ref = mdate();
+}
+
* input_programs.c: es_descriptor_t, pgrm_descriptor_t management
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
- * $Id: input_programs.c,v 1.26 2001/01/18 05:13:22 sam Exp $
+ * $Id: input_programs.c,v 1.27 2001/01/24 19:05:55 massiot Exp $
*
* Authors:
*
p_input->stream.pp_programs[i_pgrm_index]->pp_es = NULL;
p_input->stream.pp_programs[i_pgrm_index]->delta_cr = 0;
- p_input->stream.pp_programs[i_pgrm_index]->delta_absolute = 0;
+ p_input->stream.pp_programs[i_pgrm_index]->cr_ref = 0;
+ p_input->stream.pp_programs[i_pgrm_index]->sysdate_ref = 0;
p_input->stream.pp_programs[i_pgrm_index]->last_cr = 0;
p_input->stream.pp_programs[i_pgrm_index]->c_average_count = 0;
p_input->stream.pp_programs[i_pgrm_index]->i_synchro_state
- = SYNCHRO_NOT_STARTED;
+ = SYNCHRO_START;
p_input->stream.pp_programs[i_pgrm_index]->b_discontinuity = 0;
p_input->stream.pp_programs[i_pgrm_index]->p_vout
return( NULL );
}
p_input->stream.pp_es[p_input->stream.i_es_number - 1] = p_es;
- p_es->i_id = i_es_id;
/* Init its values */
+ p_es->i_id = i_es_id;
p_es->b_discontinuity = 0;
p_es->p_pes = NULL;
p_es->p_decoder_fifo = NULL;
+ p_es->b_audio = 0;
if( i_data_len )
{
intf_Msg( "input info: Dumping program 0x%x, version %d (%s)",
P->i_number, P->i_version,
P->b_is_ok ? "complete" : "partial" );
- if( P->i_synchro_state == SYNCHRO_OK )
- intf_Msg( "input info: synchro absolute delta : %lld (jitter : %lld)",
- P->delta_absolute, P->delta_cr );
#undef P
for( j = 0; j < p_input->stream.pp_programs[i]->i_es_number; j++ )
{
* mpeg_system.c: TS, PS and PES management
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
- * $Id: mpeg_system.c,v 1.26 2001/01/10 19:22:11 massiot Exp $
+ * $Id: mpeg_system.c,v 1.27 2001/01/24 19:05:55 massiot Exp $
*
* Authors:
*
p_pes = NULL;
return;
}
- p_pes->i_pts =
+ p_pes->i_pts = input_ClockToSysdate( p_input, p_es->p_pgrm,
( ((mtime_t)(p_full_header[2] & 0x0E) << 29) |
(((mtime_t)U16_AT(p_full_header + 3) << 14) - (1 << 14)) |
- ((mtime_t)U16_AT(p_full_header + 5) >> 1) ) * 300;
- p_pes->i_pts /= 27;
+ ((mtime_t)U16_AT(p_full_header + 5) >> 1) ) )
+ + DEFAULT_PTS_DELAY;
if( b_has_dts )
{
p_pes = NULL;
return;
}
- p_pes->i_dts =
+ p_pes->i_dts = input_ClockToSysdate( p_input,
+ p_es->p_pgrm,
( ((mtime_t)(p_full_header[7] & 0x0E) << 29) |
(((mtime_t)U16_AT(p_full_header + 8) << 14)
- (1 << 14)) |
- ((mtime_t)U16_AT(p_full_header + 10) >> 1) ) * 300;
- p_pes->i_dts /= 27;
+ ((mtime_t)U16_AT(p_full_header + 10) >> 1) ) )
+ + DEFAULT_PTS_DELAY;
}
}
}
return;
}
- p_pes->i_pts =
+ p_pes->i_pts = input_ClockToSysdate( p_input, p_es->p_pgrm,
( ((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_pts /= 27;
+ ((mtime_t)U16_AT(p_ts + 3) >> 1) ) )
+ + DEFAULT_PTS_DELAY;
if( b_has_dts )
{
return;
}
- p_pes->i_dts =
+ p_pes->i_dts = input_ClockToSysdate( p_input,
+ p_es->p_pgrm,
( ((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;
+ ((mtime_t)U16_AT(p_ts + 3) >> 1) ) )
+ + DEFAULT_PTS_DELAY;
}
}
}
- /* PTS management */
- if( p_pes->i_pts )
- {
- //intf_Msg("%lld", p_pes->i_pts);
- switch( p_es->p_pgrm->i_synchro_state )
- {
- case SYNCHRO_NOT_STARTED:
- case SYNCHRO_START:
- p_pes->i_pts = p_pes->i_dts = 0;
- break;
-
- case SYNCHRO_REINIT: /* We skip a PES | Why ?? --Meuuh */
- p_pes->i_pts = p_pes->i_dts = 0;
- p_es->p_pgrm->i_synchro_state = SYNCHRO_START;
- break;
-
- case SYNCHRO_OK:
- p_pes->i_pts += p_es->p_pgrm->delta_cr
- + p_es->p_pgrm->delta_absolute
- + DEFAULT_PTS_DELAY;
- if( p_pes->i_dts )
- {
- p_pes->i_dts += p_es->p_pgrm->delta_cr
- + p_es->p_pgrm->delta_absolute
- + DEFAULT_PTS_DELAY;
- }
- break;
- }
- }
break;
}
p_input->b_error = 1;
return;
}
- //intf_DbgMsg("New PES packet %p (first data: %p)", p_pes, p_data);
+ p_pes->i_rate = p_input->stream.control.i_rate;
p_pes->p_first = p_data;
/* If the PES header fits in the first data packet, we can
{
if( p_pgrm->i_synchro_state != SYNCHRO_OK )
{
- switch( p_pgrm->i_synchro_state )
- {
- case SYNCHRO_START:
- p_pgrm->delta_absolute = mdate() - cr_time;
- p_pgrm->i_synchro_state = SYNCHRO_OK;
- break;
-
- case SYNCHRO_NOT_STARTED:
- p_pgrm->i_synchro_state = SYNCHRO_START;
- break;
-
- default:
- break;
- }
+ input_ClockNewRef( p_input, p_pgrm, cr_time );
+ p_pgrm->i_synchro_state = SYNCHRO_OK;
}
else
{
( (p_pgrm->last_cr - cr_time) > CR_MAX_GAP
|| (p_pgrm->last_cr - cr_time) < - CR_MAX_GAP ) ) )
{
+#if 0
+ /* This code is deprecated */
int i_es;
/* Stream discontinuity. */
{
p_pgrm->pp_es[i_es]->b_discontinuity = 1;
}
+#endif
}
p_pgrm->last_cr = cr_time;
if( p_input->stream.b_pace_control )
{
/* Wait a while before delivering the packets to the decoder. */
- mwait( cr_time + p_pgrm->delta_absolute );
+ mwait( input_ClockToSysdate( p_input, p_pgrm, cr_time ) );
}
else
{
+#if 0
+ /* This code is deprecated, too */
mtime_t sys_time, delta_cr;
sys_time = mdate();
/ ( p_pgrm->c_average_count + 1 );
p_pgrm->c_average_count++;
}
+#endif
}
}
}
p_es = input_AddES( p_input, p_input->stream.pp_programs[0],
i_stream_id, 0 );
p_es->i_type = p_byte[0];
+ p_es->b_audio = ( p_es->i_type == MPEG1_AUDIO_ES
+ || p_es->i_type == MPEG2_AUDIO_ES
+ || p_es->i_type == AC3_AUDIO_ES
+ || p_es->i_type == LPCM_AUDIO_ES
+ );
/* input_AddES has inserted the new element at the end. */
p_input->stream.pp_programs[0]->pp_es[
{
/* MPEG audio */
p_es->i_type = MPEG2_AUDIO_ES;
+ p_es->b_audio = 1;
#ifdef AUTO_SPAWN
if( main_GetIntVariable( INPUT_DVD_AUDIO_VAR, 0 )
== REQUESTED_MPEG
{
/* AC3 audio (0x80->0x8F) */
p_es->i_type = AC3_AUDIO_ES;
+ p_es->b_audio = 1;
#ifdef AUTO_SPAWN
if( main_GetIntVariable( INPUT_DVD_AUDIO_VAR, 0 )
== REQUESTED_AC3
{
/* LPCM audio (0xA0->0xAF) */
p_es->i_type = LPCM_AUDIO_ES;
+ p_es->b_audio = 1;
/* FIXME : write the decoder */
}
else
{
case 0x1BA: /* PACK_START_CODE */
{
- /* Convert the SCR in microseconds. */
+ /* Read the SCR. */
mtime_t scr_time;
if( (p_data->p_buffer[4] & 0xC0) == 0x40 )
{
/* MPEG-2 */
scr_time =
- (( ((mtime_t)(p_data->p_buffer[4] & 0x38) << 27) |
+ ((mtime_t)(p_data->p_buffer[4] & 0x38) << 27) |
((mtime_t)(U32_AT(p_data->p_buffer + 4) & 0x03FFF800)
<< 4) |
((mtime_t)(U32_AT(p_data->p_buffer + 6) & 0x03FFF800)
- >> 11)
- ) * 300) / 27;
+ >> 11);
}
else
{
- /* MPEG-1 SCR is like PTS */
+ /* MPEG-1 SCR is like PTS. */
scr_time =
- (( ((mtime_t)(p_data->p_buffer[4] & 0x0E) << 29) |
+ ((mtime_t)(p_data->p_buffer[4] & 0x0E) << 29) |
(((mtime_t)U16_AT(p_data->p_buffer + 5) << 14)
- (1 << 14)) |
- ((mtime_t)U16_AT(p_data->p_buffer + 7) >> 1)
- ) * 300) / 27;
+ ((mtime_t)U16_AT(p_data->p_buffer + 7) >> 1);
}
/* Call the pace control. */
//intf_Msg("+%lld", scr_time);
* it. */
if( p[4] >= 7 )
{
- /* Convert the PCR in microseconds.
- * WARNING: do not remove the casts in the
- * following calculation ! */
+ /* Read the PCR. */
mtime_t pcr_time;
pcr_time =
- ( (( (mtime_t)U32_AT((u32*)&p[6]) << 1 )
- | ( p[10] >> 7 )) * 300 ) / 27;
+ ( (mtime_t)U32_AT((u32*)&p[6]) << 1 )
+ | ( p[10] >> 7 );
/* Call the pace control. */
CRDecode( p_input, p_es->p_pgrm, pcr_time );
}
* video_parser.h : video parser thread
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
- * $Id: video_parser.h,v 1.7 2001/01/21 01:36:25 massiot Exp $
+ * $Id: video_parser.h,v 1.8 2001/01/24 19:05:55 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
video_synchro_t synchro;
/* Lookup tables */
-#ifdef MPEG2_COMPLIANT
- s16 pi_crop_buf[8192];
- s16 * pi_crop;
-#endif
lookup_t pl_mb_addr_inc[2048]; /* for macroblock
address increment */
/* tables for macroblock types 0=P 1=B */
* vpar_headers.h : video parser : headers parsing
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
- * $Id: vpar_headers.h,v 1.4 2001/01/17 18:17:30 massiot Exp $
+ * $Id: vpar_headers.h,v 1.5 2001/01/24 19:05:55 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Stéphane Borel <stef@via.ecp.fr>
picture_t * p_forward; /* current forward reference frame */
picture_t * p_backward; /* current backward reference frame */
mtime_t next_pts, next_dts;
+ int i_current_rate;
/* Copyright extension */
boolean_t b_copyright_flag; /* Whether the following
* video_parser.c : video parser thread
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
- * $Id: video_parser.c,v 1.69 2001/01/18 05:13:23 sam Exp $
+ * $Id: video_parser.c,v 1.70 2001/01/24 19:05:55 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Samuel Hocevar <sam@via.ecp.fr>
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;
+ p_vpar->sequence.i_current_rate =
+ DECODER_FIFO_START( *p_bit_stream->p_decoder_fifo )->i_rate;
}
}
* vpar_synchro.c : frame dropping routines
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
- * $Id: vpar_synchro.c,v 1.79 2001/01/18 17:40:06 massiot Exp $
+ * $Id: vpar_synchro.c,v 1.80 2001/01/24 19:05:55 massiot Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Samuel Hocevar <sam@via.ecp.fr>
* Please bear in mind that B's and IP's will be inverted when displaying
* (decoding order != presentation order). Thus, t1 < t0.
*
- * FIXME: write a few words about stream structure changes.
- *
* 2. Definitions
* ===========
* t[0..12] : Presentation timestamps of pictures 0..12.
#endif
now = mdate();
- period = 1000000 * 1001 / p_vpar->sequence.i_frame_rate;
+ period = 1000000 * 1001 / p_vpar->sequence.i_frame_rate
+ * p_vpar->sequence.i_current_rate / DEFAULT_RATE;
vlc_mutex_lock( &p_vpar->p_vout->change_lock );
tau_yuv = p_vpar->p_vout->render_time;
b_decode = (pts - now) > (TAU_PRIME(I_CODING_TYPE) + DELTA);
}
if( !b_decode )
- intf_WarnMsg( 3, "vpar synchro warning: trashing I" );
+ intf_WarnMsg( 3, "vpar synchro warning: trashing I (%lld)",
+ pts - now);
break;
case P_CODING_TYPE:
void vpar_SynchroNewPicture( vpar_thread_t * p_vpar, int i_coding_type,
int i_repeat_field )
{
- mtime_t period = 1000000 * 1001 / p_vpar->sequence.i_frame_rate;
+ mtime_t period = 1000000 * 1001 / p_vpar->sequence.i_frame_rate
+ * p_vpar->sequence.i_current_rate / DEFAULT_RATE;
switch( i_coding_type )
{