[vlc-devel] Allowing MPEG's to start from somewhere other than at the beginning

rocky at panix.com rocky at panix.com
Sat Oct 25 16:26:26 CEST 2003

A while back I posted the patch to modules/demux/mpeg/ps.c attached
below amongst other changes for Video CD support. I has been alleged
to cause problems which is why it hasn't been applied to date. I'd
like to understand *what* problems this causes so that can be
addressed along with the reasons for why this patch is desired.

Here's problem encountered that lead to this patch. A Video CD allows
for "entries" which start places other than the beginning of a MPEG.
In a Video CD, other than the MPEG's encoded as "segments" in the
first CD XA track, MEPGs will start on a CD track boundary. However
the Video CD plugin based on libcdio/vcdimager allows the user to
specify start playing from an arbitrary entry; it's also possible for
a Video CD to be authored to require this too. 

What seems to happen in is that Activate (initialize PS structures) of
modules/demux/mpeg/ps.c gets called early on. Inside this, there there
is a loop with the comment "Pre-parse the stream to gather
stream_descriptor_t". Here we start reading from the MPEG. Since this
isn't in fact the beginning of the MPEG, the code may get
confused. But even assuming this is not the case, after this loop is
through, we seek to position 0 rather than the original starting point
p_input->stream.p_selected_area->i_tell and the MPEG unconditionally
gets reset to the beginning of the MPEG whether that was desired or

Given the above, what the patch does is pretty simple. In Activate()
before that loop, we save the starting position (i_tell) and seek to
the beginning, offset 0. And after reading the blocks, instead of
assuming the initial position was 0, we set it back to the position
previously saved.

I'd like to understand what the problem with this is so it can be
addressed. Thanks.

Here's the patch:

-------------- next part --------------
--- vlc-0.6.2/modules/demux/mpeg/ps.c	2003-03-09 18:39:05.000000000 -0500
+++ vlc-0.6.2-vcdimager/modules/demux/mpeg/ps.c	2003-08-28 23:58:07.000000000 -0400
@@ -146,7 +146,10 @@
         stream_ps_data_t * p_demux_data =
              (stream_ps_data_t *)p_input->stream.pp_programs[0]->p_demux_data;
+	off_t i_tell = p_input->stream.p_selected_area->i_tell;
         /* Pre-parse the stream to gather stream_descriptor_t. */
+        p_input->pf_seek( p_input, (off_t) 0 );
         p_input->stream.pp_programs[0]->b_is_ok = 0;
         p_demux_data->i_PSM_version = EMPTY_PSM_VERSION;
@@ -183,7 +186,7 @@
         input_AccessReinit( p_input );
-        p_input->pf_seek( p_input, (off_t)0 );
+        p_input->pf_seek( p_input, i_tell );
         vlc_mutex_lock( &p_input->stream.stream_lock );
         if( p_demux_data->b_has_PSM )
diff -Naur vlc-0.6.2/src/video_output/vout_synchro.c vlc-0.6.2-vcdimager/src/video_output/vout_synchro.c
--- vlc-0.6.2/src/video_output/vout_synchro.c	2003-06-09 02:25:38.000000000 -0400

More information about the vlc-devel mailing list