]> git.sesse.net Git - vlc/commitdiff
* Hooks for fast forward and slow motion support.
authorChristophe Massiot <massiot@videolan.org>
Wed, 24 Jan 2001 19:05:55 +0000 (19:05 +0000)
committerChristophe Massiot <massiot@videolan.org>
Wed, 24 Jan 2001 19:05:55 +0000 (19:05 +0000)
13 files changed:
Makefile.in
include/input_ext-dec.h
include/input_ext-intf.h
include/stream_control.h
src/input/input.c
src/input/input.h
src/input/input_clock.c [new file with mode: 0644]
src/input/input_programs.c
src/input/mpeg_system.c
src/video_decoder/video_parser.h
src/video_decoder/vpar_headers.h
src/video_parser/video_parser.c
src/video_parser/vpar_synchro.c

index ef369a550d378f9fafefb96f7a2f7a15ceb36956..e45f40b026f6a265de97d27b3c45419d44d6b19f 100644 (file)
@@ -192,6 +192,7 @@ INPUT =             src/input/input_ps.o \
                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
index a8d1b11e5a61122a27dcea5c8c36f2a0fc78043b..898eb50660b83dc8a3776959034fda637b8e3060 100644 (file)
@@ -2,7 +2,7 @@
  * 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:
  *
@@ -59,8 +59,10 @@ typedef struct pes_packet_s
     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 */
 
index e1fd3890ac4b50d5dd0b20a079f5247013b7cae1..b19c102b7785e67b4f84e402f47470dc5fe55c3e 100644 (file)
@@ -4,7 +4,7 @@
  * 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:
  *
@@ -47,6 +47,9 @@ typedef struct es_descriptor_s
     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;
@@ -85,7 +88,7 @@ typedef struct es_descriptor_s
 /* 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
@@ -105,9 +108,8 @@ typedef struct pgrm_descriptor_s
     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 */
@@ -127,9 +129,8 @@ typedef struct pgrm_descriptor_s
 
 /* 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
@@ -147,8 +148,15 @@ typedef struct stream_descriptor_s
     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;
index 92f76bf4f61b131dfcf468a3cfdd58ddcf69fbac..5f2e5ad5a35d973958e20edb2b251eddab1cc124 100644 (file)
@@ -12,8 +12,6 @@ typedef struct stream_ctrl_s
     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 */
@@ -24,5 +22,8 @@ typedef struct stream_ctrl_s
 #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
index 5872c125c1bc777d7a441491c37f79776aaa1ed0..de3dc8aa683a86cff6ef9574bc64af1612ba621a 100644 (file)
@@ -4,7 +4,7 @@
  * 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: 
  *
@@ -103,8 +103,6 @@ input_thread_t *input_CreateThread ( input_config_t * p_config, int *pi_status )
     /* 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;
 
index e5763ec3227d84aac9ec76868d80f39fcaa7a008..faa6b052c7d3ae447c07308ff6f3425ef569fbe8 100644 (file)
@@ -2,7 +2,7 @@
  * 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:
  *
@@ -100,6 +100,14 @@ vlc_thread_t input_RunDecoder( struct decoder_capabilities_s *, void * );
 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
  *****************************************************************************/
@@ -138,6 +146,7 @@ static __inline__ void input_NullPacket( input_thread_t * p_input,
             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 );
diff --git a/src/input/input_clock.c b/src/input/input_clock.c
new file mode 100644 (file)
index 0000000..73ff988
--- /dev/null
@@ -0,0 +1,71 @@
+/*****************************************************************************
+ * 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();
+}
+
index ddff45529212f1da49f3388715d566a54c82c4db..81a93d63333e62a224f32feb808fd282eb6da8a5 100644 (file)
@@ -2,7 +2,7 @@
  * 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:
  *
@@ -148,11 +148,12 @@ pgrm_descriptor_t * input_AddProgram( input_thread_t * p_input,
     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
@@ -277,12 +278,13 @@ es_descriptor_t * input_AddES( input_thread_t * p_input,
         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 )
     {
@@ -412,9 +414,6 @@ void input_DumpStream( input_thread_t * p_input )
         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++ )
         {
index a4158dad38ecad68c0f9872823ae4eb0abc41005..b0b12150621075c4f196cb5962eaf626fa703ac0 100644 (file)
@@ -2,7 +2,7 @@
  * 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: 
  *
@@ -217,11 +217,11 @@ void input_ParsePES( input_thread_t * p_input, es_descriptor_t * p_es )
                         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 )
                     {
@@ -235,12 +235,13 @@ void input_ParsePES( input_thread_t * p_input, es_descriptor_t * p_es )
                             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;
                     }
                 }
             }
@@ -312,11 +313,11 @@ void input_ParsePES( input_thread_t * p_input, es_descriptor_t * p_es )
                         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 )
                     {
@@ -331,44 +332,16 @@ void input_ParsePES( input_thread_t * p_input, es_descriptor_t * p_es )
                             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;
         }
 
@@ -479,7 +452,7 @@ void input_GatherPES( input_thread_t * p_input, data_packet_t * p_data,
                 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
@@ -582,20 +555,8 @@ static void CRDecode( input_thread_t * p_input, pgrm_descriptor_t * p_pgrm,
 {
     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
     {
@@ -604,6 +565,8 @@ static void CRDecode( input_thread_t * p_input, pgrm_descriptor_t * p_pgrm,
                   (    (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. */
@@ -617,16 +580,19 @@ static void CRDecode( input_thread_t * p_input, pgrm_descriptor_t * p_pgrm,
             {
                 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();
@@ -645,6 +611,7 @@ static void CRDecode( input_thread_t * p_input, pgrm_descriptor_t * p_pgrm,
                                      / ( p_pgrm->c_average_count + 1 );
                 p_pgrm->c_average_count++;
             }
+#endif
         }
     }
 }
@@ -767,6 +734,11 @@ static void DecodePSM( input_thread_t * p_input, data_packet_t * p_data )
             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[
@@ -860,6 +832,7 @@ es_descriptor_t * input_ParsePS( input_thread_t * p_input,
                     {
                         /* 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
@@ -875,6 +848,7 @@ es_descriptor_t * input_ParsePS( input_thread_t * p_input,
                     {
                         /* 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
@@ -903,6 +877,7 @@ es_descriptor_t * input_ParsePS( input_thread_t * p_input,
                     {
                         /* LPCM audio (0xA0->0xAF) */
                         p_es->i_type = LPCM_AUDIO_ES;
+                        p_es->b_audio = 1;
                         /* FIXME : write the decoder */
                     }
                     else
@@ -934,29 +909,27 @@ void input_DemuxPS( input_thread_t * p_input, data_packet_t * p_data )
         {
         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);
@@ -1126,13 +1099,11 @@ void input_DemuxTS( input_thread_t * p_input, data_packet_t * p_data )
                          * 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 );
                         }
index f377374c23945cd7a09bcbf1c3818a75a12fb691..f754f196ec436d00a603b449f36dd3af8abafa15 100644 (file)
@@ -2,7 +2,7 @@
  * 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>
  *
@@ -114,10 +114,6 @@ typedef struct vpar_thread_s
     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 */
index 0e32bea3f0adac200453d214ccd18c0eb8bb58e1..5f825cafb52901673f46fab7d3a02af8bbd10936 100644 (file)
@@ -2,7 +2,7 @@
  * 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>
@@ -83,6 +83,7 @@ typedef struct sequence_s
     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
index ccc0c28685a3e759409e44d1f7d5433fac99c795..a83bc42ceae448f6906aec76044f00964031437f 100644 (file)
@@ -2,7 +2,7 @@
  * 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>
@@ -528,5 +528,7 @@ static void BitstreamCallback ( bit_stream_t * p_bit_stream,
             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;
     }
 }
index 82e6e3e3e9207956751cc080c24cfe20f83505b3..5e2c8aa1d75d19d9e0047b429dcb7c1c789a1874 100644 (file)
@@ -2,7 +2,7 @@
  * 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>
@@ -41,8 +41,6 @@
  * 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.
@@ -230,7 +228,8 @@ boolean_t vpar_SynchroChoose( vpar_thread_t * p_vpar, int i_coding_type,
 #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;
@@ -265,7 +264,8 @@ boolean_t vpar_SynchroChoose( vpar_thread_t * p_vpar, int i_coding_type,
                 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:
@@ -422,7 +422,8 @@ mtime_t vpar_SynchroDate( vpar_thread_t * p_vpar )
 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 )
     {