]> git.sesse.net Git - vlc/blobdiff - modules/demux/ps.c
mpga.c: check/hack to make duration available after preparse
[vlc] / modules / demux / ps.c
index 2fae218c2aee736e4efabde80fa167596cac1b12..c069c0f7042e03fa3c5a4226ca9561c3d6103a18 100644 (file)
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
-static int  Open ( vlc_object_t * );
-static void Close( vlc_object_t * );
+static int  Open   ( vlc_object_t * );
+static int  OpenAlt( vlc_object_t * );
+static void Close  ( vlc_object_t * );
 
 vlc_module_begin();
     set_description( _("PS demuxer") );
+    set_category( CAT_INPUT );
+    set_subcategory( SUBCAT_INPUT_DEMUX );
     set_capability( "demux2", 1 );
     set_callbacks( Open, Close );
     add_shortcut( "ps" );
+
+    add_submodule();
+    set_description( _("PS demuxer") );
+    set_capability( "demux2", 9 );
+    set_callbacks( OpenAlt, Close );
 vlc_module_end();
 
 /*****************************************************************************
@@ -84,8 +92,8 @@ static int Open( vlc_object_t *p_this )
         return VLC_EGENERIC;
     }
 
-    if( p_peek[0] != 0 || p_peek[1] != 0 || p_peek[2] != 1 ||
-        p_peek[3] < 0xb9 )
+    if( p_peek[0] != 0 || p_peek[1] != 0 ||
+        p_peek[2] != 1 || p_peek[3] < 0xb9 )
     {
         msg_Warn( p_demux, "this does not look like an MPEG PS stream, "
                   "continuing anyway" );
@@ -108,6 +116,26 @@ static int Open( vlc_object_t *p_this )
     return VLC_SUCCESS;
 }
 
+static int OpenAlt( vlc_object_t *p_this )
+{
+    demux_t *p_demux = (demux_t*)p_this;
+    uint8_t *p_peek;
+
+    if( stream_Peek( p_demux->s, &p_peek, 4 ) < 4 )
+    {
+        msg_Err( p_demux, "cannot peek" );
+        return VLC_EGENERIC;
+    }
+
+    if( p_peek[0] != 0 || p_peek[1] != 0 ||
+        p_peek[2] != 1 || p_peek[3] < 0xb9 )
+    {
+        if( !p_demux->b_force ) return VLC_EGENERIC;
+    }
+
+    return Open( p_this );
+}
+
 /*****************************************************************************
  * Close
  *****************************************************************************/
@@ -167,7 +195,8 @@ static int Demux( demux_t *p_demux )
     case 0x1ba:
         if( !ps_pkt_parse_pack( p_pkt, &p_sys->i_scr, &i_mux_rate ) )
         {
-            es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_sys->i_scr );
+            /* done later on to work around bad vcd/svcd streams */
+            /* es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_sys->i_scr ); */
             if( i_mux_rate > 0 ) p_sys->i_mux_rate = i_mux_rate;
         }
         block_Release( p_pkt );
@@ -191,8 +220,8 @@ static int Demux( demux_t *p_demux )
         break;
 
     case 0x1bc:
-        msg_Dbg( p_demux, "received PSM");
-        ps_psm_fill( &p_sys->psm, p_pkt );
+        /* msg_Dbg( p_demux, "received PSM"); */
+        ps_psm_fill( &p_sys->psm, p_pkt, p_sys->tk, p_demux->out );
         block_Release( p_pkt );
         break;
 
@@ -209,6 +238,21 @@ static int Demux( demux_t *p_demux )
                 }
                 tk->b_seen = VLC_TRUE;
             }
+
+            /* The popular VCD/SVCD subtitling WinSubMux does not
+             * renumber the SCRs when merging subtitles into the PES */
+            if( tk->b_seen &&
+                ( tk->fmt.i_codec == VLC_FOURCC('o','g','t',' ') ||
+                  tk->fmt.i_codec == VLC_FOURCC('c','v','d',' ') ) )
+            {
+                p_sys->i_scr = -1;
+            }
+
+            if( p_sys->i_scr > 0 )
+                es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_sys->i_scr );
+
+            p_sys->i_scr = -1;
+
             if( tk->b_seen && tk->es &&
                 !ps_pkt_parse_pes( p_pkt, tk->i_skip ) )
             {