]> git.sesse.net Git - vlc/commitdiff
Impl�mentation rudimentaire de la synchro : les packets
authorJean-Marc Dressler <polux@videolan.org>
Thu, 23 Sep 1999 20:56:39 +0000 (20:56 +0000)
committerJean-Marc Dressler <polux@videolan.org>
Thu, 23 Sep 1999 20:56:39 +0000 (20:56 +0000)
PES sont maintenant dat�s.

--
Polux

include/input.h
src/input/input.c
src/input/input_pcr.c

index 28814878f286271c5395219d8c1bac05a7fec377..d0ea44dfbb492894145f22ac1cfb65b14a6a31ac 100644 (file)
@@ -203,7 +203,6 @@ typedef struct
  * pcr_descriptor_t
  *******************************************************************************
  * Contains informations used to synchronise the decoder with the server
- * Only input_PcrDecode() is allowed to modify it
  *******************************************************************************/
 
 typedef struct pcr_descriptor_struct
@@ -211,9 +210,11 @@ typedef struct pcr_descriptor_struct
     pthread_mutex_t         lock;                     /* pcr modification lock */
 
     s64                     delta_clock;
+    s64                     delta_decode;
                             /* represents decoder_time - pcr_time in usecondes */
     count_t                 c_average;
                              /* counter used to compute dynamic average values */
+    count_t                 c_pts;
 #ifdef STATS
     /* Stats */
     count_t     c_average_jitter;
index 76ec1c08f6e71e8830696ab72dfb59408ea11ce4..4b00df790c9eea228e692d30a406791dcbb6ccbc 100644 (file)
@@ -870,12 +870,33 @@ static __inline__ void input_DemuxPES( input_thread_t *p_input,
                    the 14 bytes */
                 if( p_pes->b_has_pts )
                 {
-                   /* The PTS field is split in 3 bit records. We have to add
-                      them, and thereafter we substract the 2 marker_bits */
-                    p_pes->i_pts = ( (p_pes->p_pes_header[9] << 29) +
-                                     (U16_AT(p_pes->p_pes_header + 10) << 14) +
-                                     (U16_AT(p_pes->p_pes_header + 12) >> 1) -
-                                     (1 << 14) - (1 << 29) );
+                    pcr_descriptor_t *p_pcr;
+                    /* The PTS field is split in 3 bit records. We have to add
+                       them, and thereafter we substract the 2 marker_bits */
+
+                    p_pcr = p_input->p_pcr;
+                    pthread_mutex_lock( &p_pcr->lock );
+                    if( p_pcr->delta_clock == 0 )
+                    {
+                        p_pes->i_pts = 0;
+                    }
+                    else
+                    {
+                        p_pes->i_pts = ( ((s64)p_pes->p_pes_header[9] << 29) +
+                                         ((s64)U16_AT(p_pes->p_pes_header + 10) << 14) +
+                                         ((s64)U16_AT(p_pes->p_pes_header + 12) >> 1) -
+                                         (1 << 14) - (1 << 29) );
+                        p_pes->i_pts *= 300;
+                        p_pes->i_pts /= 27;
+                        p_pes->i_pts += p_pcr->delta_clock;
+                        if( p_pcr->c_pts == 0 )
+                        {
+                            p_pcr->delta_decode = mdate() - p_pes->i_pts + 500000;
+                        }
+                        p_pes->i_pts += p_pcr->delta_decode;
+                    }
+                    p_pcr->c_pts += 1;
+                    pthread_mutex_unlock( &p_pcr->lock );
                 }
                 break;
             }
index 602e776dd1e40663fac7a572e85a628afaf38356..bfefd19d323065526466b41d74298607e107096d 100644 (file)
@@ -30,9 +30,12 @@ void input_PcrReInit( input_thread_t *p_input )
     pcr_descriptor_t* p_pcr;
     ASSERT(p_input);
     
-    p_pcr = p_input->p_pcr;
+    pthread_mutex_lock( &p_pcr->lock );
 
+    p_pcr = p_input->p_pcr;
+    p_pcr->delta_clock = 0;
     p_pcr->c_average = 0;
+    p_pcr->c_pts = 0;
 
 #ifdef STATS
     p_pcr->c_average_jitter = 0;
@@ -42,6 +45,7 @@ void input_PcrReInit( input_thread_t *p_input )
 /* For the printf in input_PcrDecode(), this is used for debug purpose only */
     printf("\n");
 #endif
+    pthread_mutex_unlock( &p_pcr->lock );
 }
 
 /******************************************************************************