+static float mpsub_total = 0;
+
+static int ParseMPSub( demux_t *p_demux, subtitle_t *p_subtitle, int i_idx )
+{
+ demux_sys_t *p_sys = p_demux->p_sys;
+ text_t *txt = &p_sys->txt;
+ char *psz_text = strdup( "" );
+
+ for( ;; )
+ {
+ const char *s = TextGetLine( txt );
+ float f1, f2;
+
+ if( !s )
+ return VLC_EGENERIC;
+
+ /* Data Lines */
+ if( sscanf (s, "%f %f", &f1, &f2 ) == 2 )
+ {
+ mpsub_total += f1;
+ p_subtitle->i_start = (int64_t)(1000000.0 * mpsub_total);
+ mpsub_total += f2;
+ p_subtitle->i_stop = (int64_t)(1000000.0 * mpsub_total);
+ break;
+ }
+ }
+
+ for( ;; )
+ {
+ const char *s = TextGetLine( txt );
+
+ if( !s )
+ return VLC_EGENERIC;
+
+ int i_len = strlen( s );
+ if( i_len == 0 )
+ break;
+
+ int i_old = strlen( psz_text );
+
+ psz_text = realloc( psz_text, i_old + i_len + 1 + 1 );
+ if( !psz_text )
+ return VLC_ENOMEM;
+
+ strcat( psz_text, s );
+ strcat( psz_text, "\n" );
+ }
+
+ p_subtitle->psz_text = psz_text;
+ return VLC_SUCCESS;
+}
+