1 /*****************************************************************************
2 * vobsub.c: Demux vobsub files.
3 *****************************************************************************
4 * Copyright (C) 1999-2004 VLC authors and VideoLAN
5 * $Id: 98cdf07ae504e5a0656230f8c1fd98929df8e564 $
6 *
7 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
8 * Derk-Jan Hartman <hartman at videolan dot org>
9 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU Lesser General Public License as published by
12 * the Free Software Foundation; either version 2.1 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with this program; if not, write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
24
25 /*****************************************************************************
26 * Preamble
27 *****************************************************************************/
28
29 #ifdef HAVE_CONFIG_H
30 # include "config.h"
31 #endif
32
33 #include <limits.h>
34
35 #include <vlc_common.h>
36 #include <vlc_plugin.h>
37 #include <vlc_demux.h>
38
39 #include "mpeg/pes.h"
40 #include "mpeg/ps.h"
41 #include "vobsub.h"
42 #include "subtitle_helper.h"
43
44 /*****************************************************************************
45 * Module descriptor
46 *****************************************************************************/
47 static int Open ( vlc_object_t *p_this );
48 static void Close( vlc_object_t *p_this );
49
50 vlc_module_begin ()
51 set_description( N_("Vobsub subtitles parser") )
52 set_category( CAT_INPUT )
53 set_subcategory( SUBCAT_INPUT_DEMUX )
54 set_capability( "demux", 1 )
55
56 set_callbacks( Open, Close )
57
58 add_shortcut( "vobsub", "subtitle" )
59 vlc_module_end ()
60
61 /*****************************************************************************
62 * Prototypes:
63 *****************************************************************************/
64
65 typedef struct
66 {
67 int i_line_count;
68 int i_line;
69 char **line;
70 } text_t;
71
72 typedef struct
73 {
74 int64_t i_start;
75 int i_vobsub_location;
76 } subtitle_t;
77
78 typedef struct
79 {
80 es_out_id_t *p_es;
81 int i_track_id;
82
83 int i_current_subtitle;
84 int i_subtitles;
85 subtitle_t *p_subtitles;
86
87 int64_t i_delay;
88 } vobsub_track_t;
89
90 struct demux_sys_t
91 {
92 int64_t i_next_demux_date;
93 int64_t i_length;
94
95 text_t txt;
96 stream_t *p_vobsub_stream;
97
98 /* all tracks */
99 int i_tracks;
100 vobsub_track_t *track;
101
102 int i_original_frame_width;
103 int i_original_frame_height;
104 bool b_palette;
105 uint32_t palette[16];
106 };
107
108
109 static int Demux( demux_t * );
110 static int Control( demux_t *, int, va_list );
111
112 static int TextLoad( text_t *, stream_t *s );
113 static void TextUnload( text_t * );
114 static int ParseVobSubIDX( demux_t * );
115 static int DemuxVobSub( demux_t *, block_t *);
116
117 /*****************************************************************************
118 * Module initializer
119 *****************************************************************************/
Open(vlc_object_t * p_this)120 static int Open ( vlc_object_t *p_this )
121 {
122 demux_t *p_demux = (demux_t*)p_this;
123 demux_sys_t *p_sys;
124 char *psz_vobname, *s;
125 int i_len;
126 uint64_t i_read_offset = 0;
127
128 if( ( s = peek_Readline( p_demux->s, &i_read_offset ) ) != NULL )
129 {
130 if( !strcasestr( s, "# VobSub index file" ) )
131 {
132 msg_Dbg( p_demux, "this doesn't seem to be a vobsub file" );
133 free( s );
134 return VLC_EGENERIC;
135 }
136 free( s );
137 }
138 else
139 {
140 msg_Dbg( p_demux, "could not read vobsub IDX file" );
141 return VLC_EGENERIC;
142 }
143
144 /* */
145 p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) );
146 if( unlikely( !p_sys ) )
147 return VLC_ENOMEM;
148
149 p_sys->i_length = 0;
150 p_sys->p_vobsub_stream = NULL;
151 p_sys->i_tracks = 0;
152 p_sys->track = malloc( sizeof( vobsub_track_t ) );
153 if( unlikely( !p_sys->track ) )
154 goto error;
155 p_sys->i_original_frame_width = -1;
156 p_sys->i_original_frame_height = -1;
157 p_sys->b_palette = false;
158 memset( p_sys->palette, 0, 16 * sizeof( uint32_t ) );
159
160 /* Load the whole file */
161 TextLoad( &p_sys->txt, p_demux->s );
162
163 /* Parse it */
164 ParseVobSubIDX( p_demux );
165
166 /* Unload */
167 TextUnload( &p_sys->txt );
168
169 /* Find the total length of the vobsubs */
170 if( p_sys->i_tracks > 0 )
171 {
172 for( int i = 0; i < p_sys->i_tracks; i++ )
173 {
174 if( p_sys->track[i].i_subtitles > 1 )
175 {
176 if( p_sys->track[i].p_subtitles[p_sys->track[i].i_subtitles-1].i_start > p_sys->i_length )
177 p_sys->i_length = (int64_t) p_sys->track[i].p_subtitles[p_sys->track[i].i_subtitles-1].i_start + ( 1 *1000 *1000 );
178 }
179 }
180 }
181
182 if( asprintf( &psz_vobname, "%s://%s", p_demux->psz_access, p_demux->psz_location ) == -1 )
183 goto error;
184
185 i_len = strlen( psz_vobname );
186 if( i_len >= 4 ) memcpy( psz_vobname + i_len - 4, ".sub", 4 );
187
188 /* open file */
189 p_sys->p_vobsub_stream = vlc_stream_NewURL( p_demux, psz_vobname );
190 if( p_sys->p_vobsub_stream == NULL )
191 {
192 msg_Err( p_demux, "couldn't open .sub Vobsub file: %s",
193 psz_vobname );
194 free( psz_vobname );
195 goto error;
196 }
197 free( psz_vobname );
198
199 p_demux->pf_demux = Demux;
200 p_demux->pf_control = Control;
201
202 return VLC_SUCCESS;
203
204 error:
205 /* Clean all subs from all tracks */
206 for( int i = 0; i < p_sys->i_tracks; i++ )
207 free( p_sys->track[i].p_subtitles );
208 free( p_sys->track );
209 free( p_sys );
210
211 return VLC_EGENERIC;
212 }
213
214 /*****************************************************************************
215 * Close: Close subtitle demux
216 *****************************************************************************/
Close(vlc_object_t * p_this)217 static void Close( vlc_object_t *p_this )
218 {
219 demux_t *p_demux = (demux_t*)p_this;
220 demux_sys_t *p_sys = p_demux->p_sys;
221
222 if( p_sys->p_vobsub_stream )
223 vlc_stream_Delete( p_sys->p_vobsub_stream );
224
225 /* Clean all subs from all tracks */
226 for( int i = 0; i < p_sys->i_tracks; i++ )
227 free( p_sys->track[i].p_subtitles );
228 free( p_sys->track );
229 free( p_sys );
230 }
231
232 /*****************************************************************************
233 * Control:
234 *****************************************************************************/
Control(demux_t * p_demux,int i_query,va_list args)235 static int Control( demux_t *p_demux, int i_query, va_list args )
236 {
237 demux_sys_t *p_sys = p_demux->p_sys;
238 int64_t *pi64, i64;
239 int i;
240 double *pf, f;
241
242 switch( i_query )
243 {
244 case DEMUX_CAN_SEEK:
245 *va_arg( args, bool * ) = true;
246 return VLC_SUCCESS;
247
248 case DEMUX_GET_LENGTH:
249 pi64 = va_arg( args, int64_t * );
250 *pi64 = (int64_t) p_sys->i_length;
251 return VLC_SUCCESS;
252
253 case DEMUX_GET_TIME:
254 pi64 = va_arg( args, int64_t * );
255 for( i = 0; i < p_sys->i_tracks; i++ )
256 {
257 bool b_selected;
258 /* Check the ES is selected */
259 es_out_Control( p_demux->out, ES_OUT_GET_ES_STATE,
260 p_sys->track[i].p_es, &b_selected );
261 if( b_selected ) break;
262 }
263 if( i < p_sys->i_tracks && p_sys->track[i].i_current_subtitle < p_sys->track[i].i_subtitles )
264 {
265 *pi64 = p_sys->track[i].p_subtitles[p_sys->track[i].i_current_subtitle].i_start;
266 return VLC_SUCCESS;
267 }
268 return VLC_EGENERIC;
269
270 case DEMUX_SET_TIME:
271 i64 = va_arg( args, int64_t );
272 for( i = 0; i < p_sys->i_tracks; i++ )
273 {
274 p_sys->track[i].i_current_subtitle = 0;
275 while( p_sys->track[i].i_current_subtitle < p_sys->track[i].i_subtitles &&
276 p_sys->track[i].p_subtitles[p_sys->track[i].i_current_subtitle].i_start < i64 )
277 {
278 p_sys->track[i].i_current_subtitle++;
279 }
280
281 if( p_sys->track[i].i_current_subtitle >= p_sys->track[i].i_subtitles )
282 return VLC_EGENERIC;
283 }
284 return VLC_SUCCESS;
285
286 case DEMUX_GET_POSITION:
287 pf = va_arg( args, double * );
288 for( i = 0; i < p_sys->i_tracks; i++ )
289 {
290 bool b_selected;
291 /* Check the ES is selected */
292 es_out_Control( p_demux->out, ES_OUT_GET_ES_STATE,
293 p_sys->track[i].p_es, &b_selected );
294 if( b_selected ) break;
295 }
296 if (i >= p_sys->i_tracks) {
297 /* No selected ES found */
298 return VLC_EGENERIC;
299 }
300 if( p_sys->track[i].i_current_subtitle >= p_sys->track[i].i_subtitles )
301 {
302 *pf = 1.0;
303 }
304 else if( p_sys->track[i].i_subtitles > 0 )
305 {
306 *pf = (double)p_sys->track[i].p_subtitles[p_sys->track[i].i_current_subtitle].i_start /
307 (double)p_sys->i_length;
308 }
309 else
310 {
311 *pf = 0.0;
312 }
313 return VLC_SUCCESS;
314
315 case DEMUX_SET_POSITION:
316 f = va_arg( args, double );
317 i64 = (int64_t) f * p_sys->i_length;
318
319 for( i = 0; i < p_sys->i_tracks; i++ )
320 {
321 p_sys->track[i].i_current_subtitle = 0;
322 while( p_sys->track[i].i_current_subtitle < p_sys->track[i].i_subtitles &&
323 p_sys->track[i].p_subtitles[p_sys->track[i].i_current_subtitle].i_start < i64 )
324 {
325 p_sys->track[i].i_current_subtitle++;
326 }
327 if( p_sys->track[i].i_current_subtitle >= p_sys->track[i].i_subtitles )
328 return VLC_EGENERIC;
329 }
330 return VLC_SUCCESS;
331
332 case DEMUX_SET_NEXT_DEMUX_TIME:
333 p_sys->i_next_demux_date = va_arg( args, int64_t );
334 return VLC_SUCCESS;
335
336 case DEMUX_GET_PTS_DELAY:
337 case DEMUX_GET_FPS:
338 case DEMUX_GET_META:
339 case DEMUX_GET_TITLE_INFO:
340 case DEMUX_HAS_UNSUPPORTED_META:
341 case DEMUX_GET_ATTACHMENTS:
342 case DEMUX_CAN_RECORD:
343 return VLC_EGENERIC;
344
345 default:
346 msg_Warn( p_demux, "unknown query in subtitle control" );
347 return VLC_EGENERIC;
348 }
349 }
350
351 /*****************************************************************************
352 * Demux: Send subtitle to decoder
353 *****************************************************************************/
Demux(demux_t * p_demux)354 static int Demux( demux_t *p_demux )
355 {
356 demux_sys_t *p_sys = p_demux->p_sys;
357 int64_t i_maxdate;
358 int i_read;
359
360 for( int i = 0; i < p_sys->i_tracks; i++ )
361 {
362 #define tk p_sys->track[i]
363 if( tk.i_current_subtitle >= tk.i_subtitles )
364 continue;
365
366 i_maxdate = p_sys->i_next_demux_date;
367 if( i_maxdate <= 0 && tk.i_current_subtitle < tk.i_subtitles )
368 {
369 /* Should not happen */
370 i_maxdate = tk.p_subtitles[tk.i_current_subtitle].i_start + 1;
371 }
372
373 while( tk.i_current_subtitle < tk.i_subtitles &&
374 tk.p_subtitles[tk.i_current_subtitle].i_start < i_maxdate )
375 {
376 int i_pos = tk.p_subtitles[tk.i_current_subtitle].i_vobsub_location;
377 block_t *p_block;
378 int i_size = 0;
379
380 /* first compute SPU size */
381 if( tk.i_current_subtitle + 1 < tk.i_subtitles )
382 {
383 i_size = tk.p_subtitles[tk.i_current_subtitle+1].i_vobsub_location - i_pos;
384 }
385 if( i_size <= 0 ) i_size = 65535; /* Invalid or EOF */
386
387 /* Seek at the right place */
388 if( vlc_stream_Seek( p_sys->p_vobsub_stream, i_pos ) )
389 {
390 msg_Warn( p_demux,
391 "cannot seek in the VobSub to the correct time %d", i_pos );
392 tk.i_current_subtitle++;
393 continue;
394 }
395
396 /* allocate a packet */
397 if( ( p_block = block_Alloc( i_size ) ) == NULL )
398 {
399 tk.i_current_subtitle++;
400 continue;
401 }
402
403 /* read data */
404 i_read = vlc_stream_Read( p_sys->p_vobsub_stream, p_block->p_buffer, i_size );
405 if( i_read <= 6 )
406 {
407 block_Release( p_block );
408 tk.i_current_subtitle++;
409 continue;
410 }
411 p_block->i_buffer = i_read;
412
413 /* pts */
414 p_block->i_pts = VLC_TS_0 + tk.p_subtitles[tk.i_current_subtitle].i_start;
415
416 /* demux this block */
417 DemuxVobSub( p_demux, p_block );
418
419 block_Release( p_block );
420
421 tk.i_current_subtitle++;
422 }
423 #undef tk
424 }
425
426 /* */
427 p_sys->i_next_demux_date = 0;
428
429 return 1;
430 }
431
TextLoad(text_t * txt,stream_t * s)432 static int TextLoad( text_t *txt, stream_t *s )
433 {
434 char **lines = NULL;
435 size_t n = 0;
436
437 /* load the complete file */
438 for( ;; )
439 {
440 char *psz = vlc_stream_ReadLine( s );
441 char **ppsz_new;
442
443 if( psz == NULL || (n >= INT_MAX/sizeof(char *)) )
444 {
445 free( psz );
446 break;
447 }
448
449 ppsz_new = realloc( lines, (n + 1) * sizeof (char *) );
450 if( ppsz_new == NULL )
451 {
452 free( psz );
453 break;
454 }
455 lines = ppsz_new;
456 lines[n++] = psz;
457 }
458
459 txt->i_line_count = n;
460 txt->i_line = 0;
461 txt->line = lines;
462
463 return VLC_SUCCESS;
464 }
465
TextUnload(text_t * txt)466 static void TextUnload( text_t *txt )
467 {
468 for( int i = 0; i < txt->i_line_count; i++ )
469 free( txt->line[i] );
470 free( txt->line );
471
472 txt->i_line = 0;
473 txt->i_line_count = 0;
474 }
475
TextGetLine(text_t * txt)476 static char *TextGetLine( text_t *txt )
477 {
478 if( txt->i_line >= txt->i_line_count )
479 return( NULL );
480
481 return txt->line[txt->i_line++];
482 }
483
ParseVobSubIDX(demux_t * p_demux)484 static int ParseVobSubIDX( demux_t *p_demux )
485 {
486 demux_sys_t *p_sys = p_demux->p_sys;
487 text_t *txt = &p_sys->txt;
488 char *line;
489
490 for( ;; )
491 {
492 if( ( line = TextGetLine( txt ) ) == NULL )
493 {
494 return( VLC_EGENERIC );
495 }
496
497 if( *line == 0 || *line == '\r' || *line == '\n' || *line == '#' )
498 {
499 continue;
500 }
501 else if( !strncmp( "size:", line, 5 ) )
502 {
503 /* Store the original size of the video */
504 if( vobsub_size_parse( line, &p_sys->i_original_frame_width,
505 &p_sys->i_original_frame_height ) == VLC_SUCCESS )
506 {
507 msg_Dbg( p_demux, "original frame size: %dx%d", p_sys->i_original_frame_width, p_sys->i_original_frame_height );
508 }
509 else
510 {
511 msg_Warn( p_demux, "reading original frame size failed" );
512 }
513 }
514 else if( !strncmp( "palette:", line, 8 ) )
515 {
516 if( vobsub_palette_parse( line, p_sys->palette ) == VLC_SUCCESS )
517 {
518 p_sys->b_palette = true;
519 msg_Dbg( p_demux, "vobsub palette read" );
520 }
521 else
522 {
523 msg_Warn( p_demux, "reading original palette failed" );
524 }
525 }
526 else if( !strncmp( "id:", line, 3 ) )
527 {
528 char language[33]; /* Usually 2 or 3 letters, sometimes more.
529 Spec (or lack of) doesn't define any limit */
530 int i_track_id;
531 es_format_t fmt;
532
533 /* Lets start a new track */
534 if( sscanf( line, "id: %32[^ ,], index: %d",
535 language, &i_track_id ) != 2 )
536 {
537 if( sscanf( line, "id: , index: %d", &i_track_id ) != 1 )
538 {
539 msg_Warn( p_demux, "reading new track failed" );
540 continue;
541 }
542 language[0] = '\0';
543 }
544
545 p_sys->i_tracks++;
546 p_sys->track = xrealloc( p_sys->track,
547 sizeof( vobsub_track_t ) * (p_sys->i_tracks + 1 ) );
548
549 /* Init the track */
550 vobsub_track_t *current_tk = &p_sys->track[p_sys->i_tracks - 1];
551 memset( current_tk, 0, sizeof( vobsub_track_t ) );
552 current_tk->i_current_subtitle = 0;
553 current_tk->i_subtitles = 0;
554 current_tk->p_subtitles = xmalloc( sizeof( subtitle_t ) );
555 current_tk->i_track_id = i_track_id;
556 current_tk->i_delay = (int64_t)0;
557
558 es_format_Init( &fmt, SPU_ES, VLC_CODEC_SPU );
559 fmt.subs.spu.i_original_frame_width = p_sys->i_original_frame_width;
560 fmt.subs.spu.i_original_frame_height = p_sys->i_original_frame_height;
561 fmt.psz_language = language;
562 if( p_sys->b_palette )
563 {
564 fmt.subs.spu.palette[0] = SPU_PALETTE_DEFINED;
565 memcpy( &fmt.subs.spu.palette[1], p_sys->palette, 16 * sizeof( uint32_t ) );
566 }
567
568 current_tk->p_es = es_out_Add( p_demux->out, &fmt );
569 msg_Dbg( p_demux, "New vobsub track detected: %i [%s]", i_track_id, language );
570 }
571 else if( !strncmp( line, "timestamp:", 10 ) )
572 {
573 /*
574 * timestamp: [sign]hh:mm:ss:mss, filepos: loc
575 * loc is the hex location of the spu in the .sub file
576 */
577 int h, m, s, ms, count, loc = 0;
578 int i_sign = 1;
579 int64_t i_start, i_location = 0;
580
581 if( p_sys->i_tracks > 0 &&
582 sscanf( line, "timestamp: %d%n:%d:%d:%d, filepos: %x",
583 &h, &count, &m, &s, &ms, &loc ) >= 5 )
584 {
585 vobsub_track_t *current_tk = &p_sys->track[p_sys->i_tracks - 1];
586 subtitle_t *current_sub;
587
588 if( line[count-3] == '-' )
589 {
590 i_sign = -1;
591 h = -h;
592 }
593 i_start = (int64_t) ( h * 3600*1000 +
594 m * 60*1000 +
595 s * 1000 +
596 ms ) * 1000;
597 i_location = loc;
598
599 current_tk->i_subtitles++;
600 current_tk->p_subtitles =
601 xrealloc( current_tk->p_subtitles,
602 sizeof( subtitle_t ) * (current_tk->i_subtitles + 1 ) );
603 current_sub = ¤t_tk->p_subtitles[current_tk->i_subtitles - 1];
604
605 current_sub->i_start = i_start * i_sign;
606 current_sub->i_start += current_tk->i_delay;
607 current_sub->i_vobsub_location = i_location;
608 }
609 else
610 {
611 msg_Warn( p_demux, "reading timestamp failed" );
612 }
613 }
614 else if( !strncasecmp( line, "delay:", 6 ) )
615 {
616 /*
617 * delay: [sign]hh:mm:ss:mss
618 */
619 int h, m, s, ms, count = 0;
620 int i_sign = 1;
621 int64_t i_gap = 0;
622
623 if( p_sys->i_tracks > 0 &&
624 sscanf( line, "%*celay: %d%n:%d:%d:%d",
625 &h, &count, &m, &s, &ms ) >= 4 )
626 {
627 vobsub_track_t *current_tk = &p_sys->track[p_sys->i_tracks - 1];
628 if( line[count-3] == '-' )
629 {
630 i_sign = -1;
631 h = -h;
632 }
633 i_gap = (int64_t) ( h * 3600*1000 +
634 m * 60*1000 +
635 s * 1000 +
636 ms ) * 1000;
637
638 current_tk->i_delay = current_tk->i_delay + (i_gap * i_sign);
639 msg_Dbg( p_demux, "sign: %+d gap: %+"PRId64" global delay: %+"PRId64"",
640 i_sign, i_gap, current_tk->i_delay );
641 }
642 else
643 {
644 msg_Warn( p_demux, "reading delay failed" );
645 }
646 }
647 }
648 return( 0 );
649 }
650
DemuxVobSub(demux_t * p_demux,block_t * p_bk)651 static int DemuxVobSub( demux_t *p_demux, block_t *p_bk )
652 {
653 demux_sys_t *p_sys = p_demux->p_sys;
654 uint8_t *p = p_bk->p_buffer;
655 uint8_t *p_end = &p_bk->p_buffer[p_bk->i_buffer];
656 int i;
657
658 while( p + 6 < p_end )
659 {
660 int i_size = ps_pkt_size( p, p_end - p );
661 block_t *p_pkt;
662 int i_id;
663 int i_spu;
664
665 if( i_size <= 0 )
666 break;
667
668 if( i_size > p_end - p )
669 {
670 msg_Warn( p_demux, "broken PES size" );
671 break;
672 }
673
674 if( p[0] != 0 || p[1] != 0 || p[2] != 0x01 )
675 {
676 msg_Warn( p_demux, "invalid PES" );
677 break;
678 }
679
680 if( p[3] != 0xbd )
681 {
682 /* msg_Dbg( p_demux, "we don't need these ps packets (id=0x1%2.2x)", p[3] ); */
683 p += i_size;
684 continue;
685 }
686
687 /* Create a block */
688 p_pkt = block_Alloc( i_size );
689 if( unlikely(p_pkt == NULL) )
690 break;
691 memcpy( p_pkt->p_buffer, p, i_size);
692 p += i_size;
693
694 i_id = ps_pkt_id( p_pkt );
695 if( (i_id&0xffe0) != 0xbd20 ||
696 ps_pkt_parse_pes( VLC_OBJECT(p_demux), p_pkt, 1 ) )
697 {
698 block_Release( p_pkt );
699 continue;
700 }
701 i_spu = i_id&0x1f;
702 /* msg_Dbg( p_demux, "SPU track %d size %d", i_spu, i_size ); */
703
704 for( i = 0; i < p_sys->i_tracks; i++ )
705 {
706 vobsub_track_t *p_tk = &p_sys->track[i];
707
708 p_pkt->i_dts = p_pkt->i_pts = p_bk->i_pts;
709 p_pkt->i_length = 0;
710
711 if( p_tk->p_es && p_tk->i_track_id == i_spu )
712 {
713 es_out_Send( p_demux->out, p_tk->p_es, p_pkt );
714 p_bk->i_pts = VLC_TS_INVALID; /*only first packet has a pts */
715 break;
716 }
717 }
718 if( i >= p_sys->i_tracks )
719 {
720 block_Release( p_pkt );
721 }
722 }
723
724 return VLC_SUCCESS;
725 }
726
727