]> git.sesse.net Git - vlc/blobdiff - src/input/input_ps.c
- Hardware YUV overlay (SDL) with real colors ;p It may suck for non
[vlc] / src / input / input_ps.c
index 41b1df2a935a1a69749a80c6e0d52cdc79481b49..5647c4a83f5b7ffe9e84d75612c4dceaef0d258d 100644 (file)
@@ -80,7 +80,6 @@ static int PSProbe( input_thread_t * p_input )
 static void PSInit( input_thread_t * p_input )
 {
     thread_ps_data_t *  p_method;
-    stream_ps_data_t *  p_demux;
 
     if( (p_method =
          (thread_ps_data_t *)malloc( sizeof(thread_ps_data_t) )) == NULL )
@@ -103,19 +102,8 @@ static void PSInit( input_thread_t * p_input )
 
     /* Pre-parse the stream to gather stream_descriptor_t. */
 
-    /* FIXME */
-    p_input->stream.pp_programs =
-         (pgrm_descriptor_t **)malloc( sizeof(pgrm_descriptor_t *) );
-    p_input->stream.pp_programs[0] =
-         (pgrm_descriptor_t *)malloc( sizeof(pgrm_descriptor_t) );
-    p_input->stream.pp_programs[0]->i_synchro_state = SYNCHRO_START;
-    p_input->stream.pp_programs[0]->delta_cr = 0;
-    p_input->stream.pp_programs[0]->last_cr = 0;
-    p_input->stream.pp_programs[0]->c_average_count = 0;
-
-    p_demux = (stream_ps_data_t *)malloc( sizeof( stream_ps_data_t) );
-    p_input->stream.p_demux_data = (void *)p_demux;
-    p_demux->b_is_PSM_complete = 0;
+    input_InitStream( p_input, 0 );
+    input_AddProgram( p_input, 0, sizeof( stream_ps_data_t ) );
 }
 
 /*****************************************************************************
@@ -162,7 +150,7 @@ static void PSRead( input_thread_t * p_input,
     if( (U32_AT(p_header) & 0xFFFFFF00) != 0x100L )
     {
         u32         i_buffer = U32_AT(p_header);
-        intf_ErrMsg( "Garbage at input (%x)\n", i_buffer );
+        intf_WarnMsg( 1, "Garbage at input (%x)\n", i_buffer );
         while( (i_buffer & 0xFFFFFF00) != 0x100L )
         {
             i_buffer <<= 8;
@@ -173,7 +161,7 @@ static void PSRead( input_thread_t * p_input,
                 return;
             }
         }
-        *(u32 *)p_header = i_buffer;
+        *(u32 *)p_header = U32_AT(&i_buffer);
         fread( p_header + 4, 2, 1, p_method->stream );
     }
 
@@ -243,14 +231,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) );
@@ -289,6 +269,27 @@ static struct data_packet_s * NewPacket( void * p_garbage,
     return( p_data );
 }
 
+/*****************************************************************************
+ * NewPES: allocates a pes packet
+ *****************************************************************************/
+static pes_packet_t * NewPES( void * p_garbage )
+{
+    pes_packet_t * p_pes;
+
+    if( (p_pes = (pes_packet_t *)malloc( sizeof(pes_packet_t) )) == NULL )
+    {
+        intf_DbgMsg( "Out of memory" );
+        return NULL;
+    }
+
+    p_pes->b_messed_up = p_pes->b_data_alignment = p_pes->b_discontinuity =
+        p_pes->b_has_pts = 0;
+    p_pes->i_pes_size = 0;
+    p_pes->p_first = NULL;
+
+    return( p_pes );
+}
+
 /*****************************************************************************
  * DeletePacket: deletes a data packet
  *****************************************************************************/
@@ -334,6 +335,7 @@ input_capabilities_t * PSKludge( void )
     p_plugin->pf_read = PSRead;
     p_plugin->pf_demux = input_DemuxPS; /* FIXME: use i_p_config_t ! */
     p_plugin->pf_new_packet = NewPacket;
+    p_plugin->pf_new_pes = NewPES;
     p_plugin->pf_delete_packet = DeletePacket;
     p_plugin->pf_delete_pes = DeletePES;
     p_plugin->pf_rewind = NULL;