]> git.sesse.net Git - vlc/blob - modules/demux/mpeg/audio.c
* raah, corrected mpeg2-layer3 playback (and streaming). (that my last
[vlc] / modules / demux / mpeg / audio.c
1 /*****************************************************************************
2  * audio.c : mpeg audio Stream input module for vlc
3  *****************************************************************************
4  * Copyright (C) 2001 VideoLAN
5  * $Id: audio.c,v 1.13 2003/02/18 00:51:40 fenrir Exp $
6  *
7  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
22  *****************************************************************************/
23
24 /*****************************************************************************
25  * Preamble
26  *****************************************************************************/
27 #include <stdlib.h>                                      /* malloc(), free() */
28 #include <string.h>
29
30 #include <vlc/vlc.h>
31 #include <vlc/input.h>
32
33 #include <sys/types.h>
34
35 /*****************************************************************************
36  * Local prototypes
37  *****************************************************************************/
38 static int  Activate ( vlc_object_t * );
39 static int  Demux ( input_thread_t * );
40
41 /* TODO: support MPEG-2.5, not difficult, but I need somes samples... */
42
43 /*****************************************************************************
44  * Module descriptor
45  *****************************************************************************/
46 vlc_module_begin();
47     set_description( _("MPEG I/II audio stream demux" ) );
48     set_capability( "demux", 50 );
49     set_callbacks( Activate, NULL );
50     add_shortcut( "mpegaudio" );
51     add_shortcut( "mp3" );
52 vlc_module_end();
53
54 /*****************************************************************************
55  * Definitions of structures  and functions used by this plugins
56  *****************************************************************************/
57
58 /* XXX set this to 0 to avoid problem with PS XXX */
59 /* but with some file or web radio will failed to detect */
60 /* it's you to choose */
61 #define MPEGAUDIO_MAXTESTPOS    0
62
63 typedef struct mpeg_header_s
64 {
65     uint32_t i_header;
66     int i_version;
67     int i_layer;
68     int i_crc;
69     int i_bitrate;
70     int i_samplerate;
71     int i_padding;
72     int i_extension;
73     int i_mode;
74     int i_modeext;
75     int i_copyright;
76     int i_original;
77     int i_emphasis;
78
79 } mpeg_header_t;
80
81 /* Xing Header if present */
82 #define FRAMES_FLAG     0x0001  /* these flags is for i_flags */
83 #define BYTES_FLAG      0x0002  /* because all is optionnal */
84 #define TOC_FLAG        0x0004
85 #define VBR_SCALE_FLAG  0x0008
86 typedef struct xing_header_s
87 {
88     int     i_flags;      /* from Xing header data */
89     int     i_frames;     /* total bit stream frames from Xing header data */
90     int     i_bytes;      /* total bit stream bytes from Xing header data */
91     int     i_vbr_scale;  /* encoded vbr scale from Xing header data */
92     uint8_t i_toc[100];   /* for seek */
93     int     i_avgbitrate; /* calculated, XXX: bits/sec not Kb */
94 } xing_header_t;
95
96 struct demux_sys_t
97 {
98     mtime_t i_pts;
99
100     es_descriptor_t *p_es;
101     mpeg_header_t   mpeg;
102     xing_header_t   xingheader;
103
104     /* extracted information */
105     int i_samplerate;
106     int i_samplelength;
107     int i_framelength;
108 };
109
110
111 static int mpegaudio_bitrate[2][3][16] =
112 {
113   {
114     /* v1 l1 */
115     { 0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 0},
116     /* v1 l2 */
117     { 0, 32, 48, 56,  64,  80,  96, 112, 128, 160, 192, 224, 256, 320, 384, 0},
118     /* v1 l3 */
119     { 0, 32, 40, 48,  56,  64,  80,  96, 112, 128, 160, 192, 224, 256, 320, 0}
120   },
121
122   {
123      /* v2 l1 */
124     { 0, 32, 48, 56,  64,  80,  96, 112, 128, 144, 160, 176, 192, 224, 256, 0},
125     /* v2 l2 */
126     { 0,  8, 16, 24,  32,  40,  48,  56,  64,  80,  96, 112, 128, 144, 160, 0},
127     /* v2 l3 */
128     { 0,  8, 16, 24,  32,  40,  48,  56,  64,  80,  96, 112, 128, 144, 160, 0}
129   }
130
131 };
132
133 static int mpegaudio_samplerate[2][4] = /* version 1 then 2 */
134 {
135     { 44100, 48000, 32000, 0 },
136     { 22050, 24000, 16000, 0 }
137 };
138
139 static char* mpegaudio_mode[4] =
140 {
141     "stereo", "joint stereo", "dual channel", "mono"
142 };
143
144 static inline uint32_t GetDWBE( uint8_t *p_buff )
145 {
146     return( ( p_buff[0] << 24 )|( p_buff[1] << 16 )|
147             ( p_buff[2] <<  8 )|( p_buff[3] ) );
148 }
149
150 /*****************************************************************************
151  * Function to manipulate stream easily
152  *****************************************************************************
153  *
154  * SkipBytes : skip bytes, not yet optimised, read bytes to be skipped :P
155  *
156  * ReadPes : read data and make a PES
157  *
158  *****************************************************************************/
159 static int SkipBytes( input_thread_t *p_input, int i_size )
160 {
161     data_packet_t *p_data;
162     int i_read;
163
164     while( i_size > 0 )
165     {
166         i_read = input_SplitBuffer(p_input, &p_data, __MIN( i_size, 1024 ) );
167         if( i_read <= 0 )
168         {
169             return( 0 );
170         }
171         input_DeletePacket( p_input->p_method_data, p_data );
172         i_size -= i_read;
173     }
174     return( 1 );
175 }
176
177 static int ReadPES( input_thread_t *p_input,
178                     pes_packet_t **pp_pes,
179                     int i_size )
180 {
181     pes_packet_t *p_pes;
182
183     *pp_pes = NULL;
184
185     if( !(p_pes = input_NewPES( p_input->p_method_data )) )
186     {
187         msg_Err( p_input, "cannot allocate new PES" );
188         return( 0 );
189     }
190
191     while( i_size > 0 )
192     {
193         data_packet_t   *p_data;
194         int i_read;
195
196         if( (i_read = input_SplitBuffer( p_input,
197                                          &p_data,
198                                          __MIN( i_size, 1024 ) ) ) <= 0 )
199         {
200             input_DeletePES( p_input->p_method_data, p_pes );
201             return( 0 );
202         }
203         if( !p_pes->p_first )
204         {
205             p_pes->p_first = p_data;
206             p_pes->i_nb_data = 1;
207             p_pes->i_pes_size = i_read;
208         }
209         else
210         {
211             p_pes->p_last->p_next  = p_data;
212             p_pes->i_nb_data++;
213             p_pes->i_pes_size += i_read;
214         }
215         p_pes->p_last  = p_data;
216         i_size -= i_read;
217     }
218     *pp_pes = p_pes;
219     return( 1 );
220 }
221
222 /*****************************************************************************
223  * CheckHeader : Test the validity of the header
224  *****************************************************************************/
225 static int CheckHeader( uint32_t i_header )
226 {
227     if( ((( i_header >> 20 )&0x0FFF) != 0x0FFF )  /* header sync */
228         || (((i_header >> 17)&0x03) == 0 )  /* valid layer ?*/
229         || (((i_header >> 12)&0x0F) == 0x0F )
230         || (((i_header >> 12)&0x0F) == 0x00 ) /* valid bitrate ? */
231         || (((i_header >> 10) & 0x03) == 0x03 ) /* valide sampling freq ? */
232         || ((i_header & 0x03) == 0x02 )) /* valid emphasis ? */
233     {
234         return( 0 ); /*invalid */
235     }
236     return( 1 ); /* valid */
237 }
238
239 /*****************************************************************************
240  * DecodedFrameSize : give the length of the decoded pcm data
241  *****************************************************************************/
242 static int DecodedFrameSize( mpeg_header_t *p_mpeg )
243 {
244     switch( p_mpeg->i_layer )
245     {
246         case( 0 ): /* layer 1 */
247             return( 384);
248         case( 1 ): /* layer 2 */
249             return( 1152 );
250         case( 2 ): /* layer 3 */
251             return( !p_mpeg->i_version ? 1152 : 576 );
252             /* XXX: perhaps we have to /2 for all layer but i'm not sure */
253     }
254     return( 0 );
255 }
256
257 /****************************************************************************
258  * GetHeader : find an mpeg header and load it
259  ****************************************************************************/
260 static int GetHeader( input_thread_t  *p_input,
261                       mpeg_header_t   *p_mpeg,
262                       int             i_max_pos,
263                       int             *pi_skip )
264 {
265     uint32_t i_header;
266     uint8_t  *p_peek;
267     int i_size;
268
269     *pi_skip = 0;
270     i_size = input_Peek( p_input, &p_peek, i_max_pos + 4 );
271
272     for( ; ; )
273     {
274         if( i_size < 4 )
275         {
276             return( 0 );
277         }
278         if( !CheckHeader( GetDWBE( p_peek ) ) )
279         {
280             p_peek++;
281             i_size--;
282             *pi_skip += 1;
283             continue;
284         }
285         /* we found an header, load it */
286         break;
287     }
288     i_header = GetDWBE( p_peek );
289     p_mpeg->i_header = i_header;
290     p_mpeg->i_version =  1 - ( ( i_header >> 19 ) & 0x01 );
291     p_mpeg->i_layer =  3 - ( ( i_header >> 17 ) & 0x03 );
292     p_mpeg->i_crc = 1 - (( i_header >> 16 ) & 0x01);
293     p_mpeg->i_bitrate =
294         mpegaudio_bitrate[p_mpeg->i_version][p_mpeg->i_layer][(i_header>>12)&0x0F];
295     p_mpeg->i_samplerate = mpegaudio_samplerate[p_mpeg->i_version][(i_header>>10)&0x03];
296     p_mpeg->i_padding = (( i_header >> 9 ) & 0x01);
297     p_mpeg->i_extension = ( i_header >> 7 ) & 0x01;
298     p_mpeg->i_mode = ( i_header >> 6 ) & 0x03;
299     p_mpeg->i_modeext = ( i_header >> 4 ) & 0x03;
300     p_mpeg->i_copyright = ( i_header >> 3 ) & 0x01;
301     p_mpeg->i_original = ( i_header >> 2 ) & 0x01;
302     p_mpeg->i_emphasis = ( i_header ) & 0x03;
303
304     return( 1 );
305 }
306
307 /*****************************************************************************
308  * ExtractXingHeader : extract a Xing header if exist
309  *****************************************************************************
310  * It also calcul avgbitrate, using Xing header if present or assume that
311  * the bitrate of the first frame is the same for the all file
312  *****************************************************************************/
313 static void ExtractXingHeader( input_thread_t *p_input,
314                                xing_header_t *p_xh )
315 {
316     int i_skip;
317     int i_size;
318     uint8_t  *p_peek;
319     mpeg_header_t mpeg;
320
321     p_xh->i_flags = 0;  /* nothing present */
322     if( !( GetHeader( p_input,
323                       &mpeg,
324                       8192,
325                       &i_skip ) ) )
326     {
327         msg_Err( p_input, "ExtractXingHeader failed, shouldn't ..." );
328         return;
329     }
330
331     p_xh->i_avgbitrate = mpeg.i_bitrate * 1000; /* default */
332
333     /* 1024 is enougth */
334     if( ( i_size = input_Peek( p_input, &p_peek, 1024 + i_skip ) ) < 8 )
335     {
336         return;
337     }
338     p_peek += i_skip;
339     i_size -= i_skip;
340
341     /* calculate pos of xing header */
342     if( !mpeg.i_version )
343     {
344         p_peek += mpeg.i_mode != 3 ? 36 : 21;
345         i_size -= mpeg.i_mode != 3 ? 36 : 21;
346     }
347     else
348     {
349         p_peek += mpeg.i_mode != 3 ? 21 : 13;
350         i_size -= mpeg.i_mode != 3 ? 21 : 13;
351     }
352     if( i_size < 8 )
353     {
354         return;
355     }
356     if( ( p_peek[0] != 'X' )||( p_peek[1] != 'i' )||
357         ( p_peek[2] != 'n' )||( p_peek[3] != 'g' ) )
358     {
359         return;
360     }
361     else
362     {
363         msg_Dbg( p_input, "Xing header is present" );
364         p_peek += 4;
365         i_size -= 4;
366     }
367     if( i_size < 4 )
368     {
369         return;
370     }
371     else
372     {
373         p_xh->i_flags = GetDWBE( p_peek );
374         p_peek += 4;
375         i_size -= 4;
376     }
377
378     if( ( p_xh->i_flags&FRAMES_FLAG )&&( i_size >= 4 ) )
379     {
380         p_xh->i_frames = GetDWBE( p_peek );
381         p_peek += 4;
382         i_size -= 4;
383     }
384     if( ( p_xh->i_flags&BYTES_FLAG ) &&( i_size >= 4 ) )
385
386     {
387         p_xh->i_bytes = GetDWBE( p_peek );
388         p_peek += 4;
389         i_size -= 4;
390     }
391     if( ( p_xh->i_flags&TOC_FLAG ) &&( i_size >= 100 ) )
392
393     {
394         memcpy( p_xh->i_toc, p_peek, 100 );
395         p_peek += 100;
396         i_size -= 100;
397     }
398     if( ( p_xh->i_flags&VBR_SCALE_FLAG ) &&( i_size >= 4 ) )
399
400     {
401         p_xh->i_vbr_scale = GetDWBE( p_peek );
402         p_peek += 4;
403         i_size -= 4;
404     }
405
406     if( ( p_xh->i_flags&FRAMES_FLAG )&&( p_xh->i_flags&BYTES_FLAG ) )
407     {
408         p_xh->i_avgbitrate =
409               ( (uint64_t)p_xh->i_bytes *
410                 (uint64_t)8 *
411                 (uint64_t)mpeg.i_samplerate) /
412                ((uint64_t)p_xh->i_frames * (uint64_t)DecodedFrameSize( &mpeg ) );
413     }
414 }
415
416 /****************************************************************************
417  * ExtractConfiguration : extract usefull informations from mpeg_header_t
418  ****************************************************************************/
419 static void ExtractConfiguration( demux_sys_t *p_demux )
420 {
421     p_demux->i_samplerate   = p_demux->mpeg.i_samplerate;
422
423     p_demux->i_samplelength = DecodedFrameSize( &p_demux->mpeg );
424
425     /* XXX if crc do i need to add 2 bytes or not? */
426     switch( p_demux->mpeg.i_layer )
427     {
428         case( 0 ):
429             p_demux->i_framelength =
430                 ( ( 12000 * p_demux->mpeg.i_bitrate ) /
431                        p_demux->mpeg.i_samplerate + p_demux->mpeg.i_padding ) * 4;
432             break;
433         case( 1 ):
434             p_demux->i_framelength =
435                   ( 144000 * p_demux->mpeg.i_bitrate ) /
436                        p_demux->mpeg.i_samplerate + p_demux->mpeg.i_padding;
437             break;
438         case( 2 ):
439             p_demux->i_framelength =
440                   (p_demux->mpeg.i_version ? 72000 : 144000) *
441                   p_demux->mpeg.i_bitrate /
442                        p_demux->mpeg.i_samplerate + p_demux->mpeg.i_padding;
443             break;
444
445     }
446 }
447
448 /****************************************************************************
449  * CheckPS : check if this stream could be some ps,
450  *           yes it's ugly ...  but another idea ?
451  *
452  ****************************************************************************/
453 static int CheckPS( input_thread_t *p_input )
454 {
455     uint8_t  *p_peek;
456     int i_startcode = 0;
457     int i_size = input_Peek( p_input, &p_peek, 8196 );
458
459     while( i_size > 4 )
460     {
461         if( ( p_peek[0] == 0 ) && ( p_peek[1] == 0 ) &&
462             ( p_peek[2] == 1 ) && ( p_peek[3] >= 0xb9 ) &&
463             ++i_startcode >= 3 )
464         {
465             return 1;
466         }
467         p_peek++;
468         i_size--;
469     }
470
471     return 0;
472 }
473
474 /*****************************************************************************
475  * Activate: initializes MPEGaudio structures
476  *****************************************************************************/
477 static int Activate( vlc_object_t * p_this )
478 {
479     input_thread_t * p_input = (input_thread_t *)p_this;
480     demux_sys_t * p_demux;
481     input_info_category_t * p_category;
482     module_t * p_id3;
483
484     int i_found;
485     int b_forced;
486     int i_skip;
487
488     /* Set the demux function */
489     p_input->pf_demux = Demux;
490
491     /* Initialize access plug-in structures. */
492     if( p_input->i_mtu == 0 )
493     {
494         /* Improve speed. */
495         p_input->i_bufsize = INPUT_DEFAULT_BUFSIZE;
496     }
497
498     if( ( *p_input->psz_demux )
499         &&( ( !strncmp( p_input->psz_demux, "mpegaudio", 10 ) )||
500             ( !strncmp( p_input->psz_demux, "mp3", 3 ) ) ) )
501     {
502         b_forced = 1;
503     }
504     else
505     {
506         b_forced = 0;
507     }
508     p_id3 = module_Need( p_input, "id3", NULL );
509     if ( p_id3 ) {
510         module_Unneed( p_input, p_id3 );
511     }
512
513     /* create p_demux and init it */
514     if( !( p_demux = p_input->p_demux_data = malloc( sizeof(demux_sys_t) ) ) )
515     {
516         msg_Err( p_input, "out of memory" );
517         return( -1 );
518     }
519     memset( p_demux, 0, sizeof(demux_sys_t) );
520
521     /* check if it could be a ps stream */
522     if( !b_forced && CheckPS(  p_input ))
523     {
524         free( p_input->p_demux_data );
525         return( -1 );
526     }
527
528
529     /* must be sure that is mpeg audio stream unless forced */
530     if( !( i_found = GetHeader( p_input,
531                                 &p_demux->mpeg,
532                                 b_forced ? 4000 : MPEGAUDIO_MAXTESTPOS,
533                                 &i_skip ) ) )
534     {
535         if( b_forced )
536         {
537             msg_Warn( p_input,
538                       "this does not look like an MPEG audio stream, "
539                       "but continuing anyway" );
540         }
541         else
542         {
543             msg_Warn( p_input, "MPEGAudio module discarded (no frame found)" );
544             free( p_input->p_demux_data );
545             return( -1 );
546         }
547     }
548     else
549     {
550         ExtractConfiguration( p_demux );
551     }
552
553
554     vlc_mutex_lock( &p_input->stream.stream_lock );
555     if( input_InitStream( p_input, 0 ) == -1)
556     {
557         msg_Err( p_input, "cannot init stream" );
558         free( p_input->p_demux_data );
559         return( -1 );
560     }
561     if( input_AddProgram( p_input, 0, 0) == NULL )
562     {
563         msg_Err( p_input, "cannot add program" );
564         free( p_input->p_demux_data );
565         return( -1 );
566     }
567     p_input->stream.pp_programs[0]->b_is_ok = 0;
568     p_input->stream.p_selected_program = p_input->stream.pp_programs[0];
569
570     /* create our ES */
571     p_demux->p_es = input_AddES( p_input,
572                                  p_input->stream.p_selected_program,
573                                  1, /* id */
574                                  0 );
575     if( !p_demux->p_es )
576     {
577         vlc_mutex_unlock( &p_input->stream.stream_lock );
578         msg_Err( p_input, "out of memory" );
579         free( p_input->p_demux_data );
580         return( -1 );
581     }
582     p_demux->p_es->i_stream_id = 1;
583     p_demux->p_es->i_fourcc = VLC_FOURCC('m','p','g','a');
584     p_demux->p_es->i_cat = AUDIO_ES;
585
586     input_SelectES( p_input, p_demux->p_es );
587
588     p_input->stream.p_selected_program->b_is_ok = 1;
589     vlc_mutex_unlock( &p_input->stream.stream_lock );
590
591
592     if( i_found )
593     {
594         /* parse Xing Header if present */
595         ExtractXingHeader( p_input, &p_demux->xingheader );
596
597         vlc_mutex_lock( &p_input->stream.stream_lock );
598         p_input->stream.i_mux_rate = p_demux->xingheader.i_avgbitrate / 50 / 8;
599         vlc_mutex_unlock( &p_input->stream.stream_lock );
600
601
602         /* all is ok :)) */
603         msg_Dbg( p_input, "audio MPEG-%d layer %d %s %dHz %dKb/s %s",
604                 p_demux->mpeg.i_version + 1,
605                 p_demux->mpeg.i_layer + 1,
606                 mpegaudio_mode[p_demux->mpeg.i_mode],
607                 p_demux->mpeg.i_samplerate,
608                 p_demux->xingheader.i_avgbitrate / 1000,
609                 p_demux->xingheader.i_flags ?
610                         "VBR (Xing)" : ""
611                     );
612
613         vlc_mutex_lock( &p_input->stream.stream_lock );
614         p_category = input_InfoCategory( p_input, "mpeg" );
615         input_AddInfo( p_category, "input type", "audio MPEG-%d",
616                        p_demux->mpeg.i_version +1 );
617         input_AddInfo( p_category, "layer", "%d", p_demux->mpeg.i_layer + 1 );
618         input_AddInfo( p_category, "mode",
619                        mpegaudio_mode[p_demux->mpeg.i_mode] );
620         input_AddInfo( p_category, "sample rate", "%dHz",
621                        p_demux->mpeg.i_samplerate );
622         input_AddInfo( p_category, "average bitrate", "%dKb/s",
623                        p_demux->xingheader.i_avgbitrate / 1000 );
624         vlc_mutex_unlock( &p_input->stream.stream_lock );
625     }
626     else
627     {
628         msg_Dbg( p_input,
629                  "assuming audio MPEG, but not frame header yet found" );
630         vlc_mutex_lock( &p_input->stream.stream_lock );
631         p_category = input_InfoCategory( p_input, "mpeg" );
632         input_AddInfo( p_category, "input type", "audio MPEG-?" );
633         vlc_mutex_unlock( &p_input->stream.stream_lock );
634
635     }
636
637     return( 0 );
638 }
639
640 /*****************************************************************************
641  * Demux: reads and demuxes data packets
642  *****************************************************************************
643  * Returns -1 in case of error, 0 in case of EOF, 1 otherwise
644  *****************************************************************************/
645 static int Demux( input_thread_t * p_input )
646 {
647     demux_sys_t  *p_demux = p_input->p_demux_data;
648     pes_packet_t *p_pes;
649     int          i_skip;
650
651     if( !GetHeader( p_input,
652                     &p_demux->mpeg,
653                     8192,
654                     &i_skip ) )
655     {
656         if( i_skip > 0)
657         {
658             msg_Dbg( p_input,
659                      "skipping %d bytes (garbage ?)",
660                      i_skip );
661             SkipBytes( p_input, i_skip );
662             return( 1 );
663         }
664         else
665         {
666             msg_Dbg( p_input,
667                      "cannot find next frame (EOF ?)" );
668             return( 0 );
669         }
670     }
671
672     ExtractConfiguration( p_demux );
673
674     input_ClockManageRef( p_input,
675                           p_input->stream.p_selected_program,
676                           p_demux->i_pts );
677
678     /*
679      * For layer 1 and 2 i_skip is garbage but for layer 3 it is not.
680      * Since mad accept without to much trouble garbage I don't skip
681      * it ( in case I misdetect garbage ... )
682      *
683      */
684     if( !ReadPES( p_input, &p_pes, p_demux->i_framelength + i_skip) )
685     {
686         msg_Warn( p_input,
687                 "cannot read data" );
688         return( -1 );
689     }
690
691     p_pes->i_rate = p_input->stream.control.i_rate;
692     p_pes->i_dts =
693         p_pes->i_pts = input_ClockGetTS( p_input,
694                                          p_input->stream.p_selected_program,
695                                          p_demux->i_pts );
696
697     if( !p_demux->p_es->p_decoder_fifo )
698     {
699         msg_Err( p_input, "no audio decoder" );
700         input_DeletePES( p_input->p_method_data, p_pes );
701         return( -1 ); /* perhaps not, it's my choice */
702     }
703     else
704     {
705         input_DecodePES( p_demux->p_es->p_decoder_fifo, p_pes );
706     }
707     p_demux->i_pts += (mtime_t)90000 *
708                       (mtime_t)p_demux->i_samplelength /
709                       (mtime_t)p_demux->i_samplerate;
710     return( 1 );
711
712 }
713
714