]> git.sesse.net Git - vlc/commitdiff
We now read the DTS (but we don't use it for the moment).
authorChristophe Massiot <massiot@videolan.org>
Wed, 27 Dec 2000 18:35:45 +0000 (18:35 +0000)
committerChristophe Massiot <massiot@videolan.org>
Wed, 27 Dec 2000 18:35:45 +0000 (18:35 +0000)
NB : b_has_pts has disappeared for brevity reasons, use i_pts != 0 instead.

include/input_ext-dec.h
src/ac3_decoder/ac3_decoder_thread.c
src/audio_decoder/audio_decoder.c
src/input/input_netlist.c
src/input/input_ps.c
src/input/mpeg_system.c
src/lpcm_decoder/lpcm_decoder_thread.c
src/video_parser/vpar_synchro.c

index 55e0a38b7a8e5a31a72ebb30ff241cbe0162141f..33ec47134af41be94e5cbb9de805c1cef55be310 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.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:
  *
@@ -59,8 +59,8 @@ typedef struct pes_packet_s
     boolean_t               b_discontinuity; /* This packet doesn't follow the
                                               * previous one                 */
 
-    boolean_t               b_has_pts;       /* is the following field set ? */
-    mtime_t                 i_pts; /* the PTS for this packet (if set above) */
+    mtime_t                 i_pts;/* the PTS for this packet (zero if unset) */
+    mtime_t                 i_dts;/* the DTS for this packet (zero if unset) */
 
     int                     i_pes_size;    /* size of the current PES packet */
 
index abbf7d4226cc82b3a8fd69eb6e5b58d784e78cd6..73f7d6629d501d416fddd73acad72f4f1aeddf1d 100644 (file)
@@ -2,7 +2,7 @@
  * ac3_decoder_thread.c: ac3 decoder thread
  *****************************************************************************
  * 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:
  *
@@ -229,10 +229,10 @@ static void RunThread (ac3dec_thread_t * p_ac3dec)
             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;
-            DECODER_FIFO_START(*p_ac3dec->p_fifo)->b_has_pts = 0;
+            DECODER_FIFO_START(*p_ac3dec->p_fifo)->i_pts = 0;
         }
         else
         {
index 96a042f5631a5e4a03ccbcabd077b958e294abff..3ff05af0cf7b06d9af519bee5f1814223a52d7fa 100644 (file)
@@ -2,7 +2,7 @@
  * audio_decoder.c: MPEG audio decoder thread
  *****************************************************************************
  * 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>
  *          Michel Lespinasse <walken@via.ecp.fr>
@@ -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] =
                 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
         {
index 1cf6a64b59a753dcf183ffd5419fb78d161fbc5e..e4dab28cd80647d12ffb57c13a68b1ba1ff9f493 100644 (file)
@@ -2,7 +2,7 @@
  * input_netlist.c: netlist management
  *****************************************************************************
  * 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>
  *
@@ -313,7 +313,7 @@ struct pes_packet_s * input_NetlistNewPES( void * p_method_data )
     p_return->b_messed_up = 
         p_return->b_data_alignment = 
         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->p_first = NULL;
    
index 07c613cebe17a7ff6f431015daa2ac08d2315e28..407f9c1dfd56b4aff07b5a6be21340457772a0d0 100644 (file)
@@ -2,7 +2,7 @@
  * input_ps.c: PS demux and packet management
  *****************************************************************************
  * 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: 
  *
@@ -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_has_pts = 0;
+        p_pes->i_pts = p_pes->i_dts = 0;
     p_pes->i_pes_size = 0;
     p_pes->p_first = NULL;
 
index 423be65dbe613536741a323e5ec5851571a80242..00e8b2926d21aaeea3d15052e384302698a1b96f 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.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: 
  *
@@ -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. */
                 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;
 
-                /* Re-use p_header buffer now that we don't need it. */
-                i_max_len = MoveChunk( p_header, &p_data, &p_byte, 7 );
+                i_max_len = MoveChunk( p_full_header, &p_data, &p_byte, 12 );
                 if( i_max_len < 2 )
                 {
                     intf_WarnMsg( 3,
@@ -201,11 +202,12 @@ void input_ParsePES( input_thread_t * p_input, es_descriptor_t * p_es )
                     return;
                 }
 
-                p_pes->b_has_pts = p_header[0] & 0x80;
-                i_pes_header_size = p_header[1] + 9;
+                b_has_pts = p_full_header[0] & 0x80;
+                b_has_dts = p_full_header[0] & 0x40;
+                i_pes_header_size = p_full_header[1] + 9;
 
                 /* Now parse the optional header extensions */
-                if( p_pes->b_has_pts )
+                if( b_has_pts )
                 {
                     if( i_max_len < 7 )
                     {
@@ -218,15 +220,37 @@ void input_ParsePES( input_thread_t * p_input, es_descriptor_t * p_es )
                         return;
                     }
                     p_pes->i_pts =
-                      ( ((mtime_t)(p_header[2] & 0x0E) << 29) |
-                        (((mtime_t)U16_AT(p_header + 3) << 14) - (1 << 14)) |
-                        ((mtime_t)U16_AT(p_header + 5) >> 1) ) * 300;
+                    ( ((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;
+
+                    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
             {
                 /* Probably MPEG-1 */
+                boolean_t       b_has_pts, b_has_dts;
+
                 i_pes_header_size = 6;
                 p_data = p_pes->p_first;
                 p_byte = p_data->p_payload_start;
@@ -272,18 +296,15 @@ void input_ParsePES( input_thread_t * p_input, es_descriptor_t * p_es )
 
                 i_pes_header_size++;
 
-                if( *p_byte & 0x10 )
-                {
-                    /* DTS */
-                    i_pes_header_size += 5;
-                }
-                if( (p_pes->b_has_pts = (*p_byte & 0x20)) )
+                b_has_pts = *p_byte & 0x20;
+                b_has_dts = *p_byte & 0x10;
+
+                if( b_has_pts )
                 {
-                    /* PTS */
-                    byte_t      p_pts[5];
+                    byte_t      p_ts[5];
 
                     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,
                             "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 )
                     }
 
                     p_pes->i_pts =
-                      ( ((mtime_t)(p_pts[0] & 0x0E) << 29) |
-                        (((mtime_t)U16_AT(p_pts + 1) << 14) - (1 << 14)) |
-                        ((mtime_t)U16_AT(p_pts + 3) >> 1) ) * 300;
+                      ( ((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;
+
+                    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 */
-            if( p_pes->b_has_pts )
+            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->b_has_pts = 0;
+                    p_pes->i_pts = p_pes->i_dts = 0;
                     break;
 
                 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;
                     break;
 
@@ -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_es->p_pgrm->delta_absolute
                                          + DEFAULT_PTS_DELAY;
+                    p_pes->i_dts += p_es->p_pgrm->delta_cr
+                                         + p_es->p_pgrm->delta_absolute
+                                         + DEFAULT_PTS_DELAY;
                     break;
                 }
             }
index 6feeea23e5af6a6b7ac71a8a176014730b29f615..6a93fab9c893dac6243da6a82dca1edd8e3dff2e 100644 (file)
@@ -2,7 +2,7 @@
  * lpcm_decoder_thread.c: lpcm decoder thread
  *****************************************************************************
  * 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:
  *
@@ -179,10 +179,10 @@ static void RunThread (lpcmdec_thread_t * p_lpcmdec)
             /* 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;
-               DECODER_FIFO_START(*p_lpcmdec->p_fifo)->b_has_pts = 0;
+               DECODER_FIFO_START(*p_lpcmdec->p_fifo)->i_pts = 0;
         }
         else
         {
index e10129f8399ab1269e97fd8486d14d66c24903f2..d45c6da42ec7233417f4a7c8cea8b19638f4e082 100644 (file)
@@ -2,7 +2,7 @@
  * vpar_synchro.c : frame dropping routines
  *****************************************************************************
  * 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>
  *          Samuel Hocevar <sam@via.ecp.fr>
@@ -482,7 +482,7 @@ void vpar_SynchroNewPicture( vpar_thread_t * p_vpar, int i_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 )
             {
@@ -490,7 +490,7 @@ void vpar_SynchroNewPicture( vpar_thread_t * p_vpar, int i_coding_type )
                         "vpar synchro warning: pts_date < current_date" );
             }
             p_vpar->synchro.current_pts = p_pes->i_pts;
-            p_pes->b_has_pts = 0;
+            p_pes->i_pts = 0;
         }
         else
         {
@@ -516,11 +516,11 @@ void vpar_SynchroNewPicture( vpar_thread_t * p_vpar, int i_coding_type )
             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. */
             p_vpar->synchro.backward_pts = p_pes->i_pts;
-            p_pes->b_has_pts = 0;
+            p_pes->i_pts = 0;
         }
     }