]> git.sesse.net Git - vlc/commitdiff
We now correctly parse MPEG-1 SCR and there is no need to kludge to read
authorChristophe Massiot <massiot@videolan.org>
Thu, 7 Dec 2000 15:45:18 +0000 (15:45 +0000)
committerChristophe Massiot <massiot@videolan.org>
Thu, 7 Dec 2000 15:45:18 +0000 (15:45 +0000)
the stream at the right pace.

src/input/input_ps.c
src/input/mpeg_system.c

index 41b1df2a935a1a69749a80c6e0d52cdc79481b49..8495ce67293593c01a6b9bc99a0aced3b4e358b9 100644 (file)
@@ -243,14 +243,6 @@ static void PSRead( input_thread_t * p_input,
                        p_method->stream );
             }
         }
-        else
-        {
-            /* FIXME: kludge to avoid SCR to block everything (SCR
-             * calculus appears to be wrong). */
-            p_data->p_buffer[4] = p_data->p_buffer[5] =
-                p_data->p_buffer[6] = p_data->p_buffer[7] =
-                p_data->p_buffer[8] = 0;
-        }
     }
 
     memset( p_packets, 0, sizeof(p_packets) );
index 2d3a7532d64987ce20dc2de8ca85cff16d937a53..79367977b3cb90776a6c46fb44f53ebfdf0639ad 100644 (file)
@@ -69,6 +69,7 @@ void input_DecodePES( input_thread_t * p_input, es_descriptor_t * p_es )
     {
         vlc_mutex_lock( &p_es->p_decoder_fifo->data_lock );
 
+#if 0
         if( p_input->stream.b_pace_control )
         {
             /* FIXME : normally we shouldn't need this... */
@@ -79,6 +80,7 @@ void input_DecodePES( input_thread_t * p_input, es_descriptor_t * p_es )
                 vlc_mutex_lock( &p_es->p_decoder_fifo->data_lock );
             }
         }
+#endif
 
         if( !DECODER_FIFO_ISFULL( *p_es->p_decoder_fifo ) )
         {
@@ -724,16 +726,29 @@ void input_DemuxPS( input_thread_t * p_input, data_packet_t * p_data )
                 /* Convert the SCR in microseconds. */
                 mtime_t         scr_time;
 
-                /* FIXME : this calculus is broken with MPEG-1 ! */
-                scr_time = (( ((mtime_t)(p_data->p_buffer[4] & 0x38) << 27) |
-                              ((mtime_t)(p_data->p_buffer[4] & 0x3) << 26) |
-                              ((mtime_t)(p_data->p_buffer[5]) << 20) |
-                              ((mtime_t)(p_data->p_buffer[6] & 0xF8) << 12) |
-                              ((mtime_t)(p_data->p_buffer[6] & 0x3) << 13) |
-                              ((mtime_t)(p_data->p_buffer[7]) << 5) |
-                              ((mtime_t)(p_data->p_buffer[8] & 0xF8) >> 3)
-                           ) * 300) / 27;
-
+                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] & 0x3) << 26) |
+                         ((mtime_t)(p_data->p_buffer[5]) << 20) |
+                         ((mtime_t)(p_data->p_buffer[6] & 0xF8) << 12) |
+                         ((mtime_t)(p_data->p_buffer[6] & 0x3) << 13) |
+                         ((mtime_t)(p_data->p_buffer[7]) << 5) |
+                         ((mtime_t)(p_data->p_buffer[8] & 0xF8) >> 3)
+                      ) * 300) / 27;
+                }
+                else
+                {
+                    /* MPEG-1 SCR is like PTS */
+                    scr_time =
+                      (( ((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;
+                }
                 /* Call the pace control. */
                 CRDecode( p_input, NULL, scr_time );
             }