]> git.sesse.net Git - vlc/commitdiff
* ts: use right stream_id for A52 (0xbd -> fix mplayer playback) and add a
authorLaurent Aimar <fenrir@videolan.org>
Thu, 14 Aug 2003 23:37:54 +0000 (23:37 +0000)
committerLaurent Aimar <fenrir@videolan.org>
Thu, 14 Aug 2003 23:37:54 +0000 (23:37 +0000)
  "registration descriptor" (-> fix xine playback) when using a52.

modules/mux/mpeg/pes.c
modules/mux/mpeg/ts.c

index e6c77b108c75f1141c04db8516f4737f1b9a4cdc..8bfe203b38ef476d76e3ca469e745bbaab5637e0 100644 (file)
@@ -2,7 +2,7 @@
  * pes.c: PES packetizer used by the MPEG multiplexers
  *****************************************************************************
  * Copyright (C) 2001, 2002 VideoLAN
- * $Id: pes.c,v 1.9 2003/08/02 01:33:53 fenrir Exp $
+ * $Id: pes.c,v 1.10 2003/08/14 23:37:54 fenrir Exp $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *          Eric Petit <titer@videolan.org>
@@ -81,7 +81,8 @@ static inline int PESHeader( uint8_t *p_hdr, mtime_t i_pts, mtime_t i_dts,
 
                 /* For PES_PRIVATE_STREAM_1 there is an extra header after the
                    pes header */
-                if( i_stream_id == PES_PRIVATE_STREAM_1 )
+                /* i_private_id != -1 because TS use 0xbd without private_id */
+                if( i_stream_id == PES_PRIVATE_STREAM_1 && i_private_id != -1 )
                 {
                     i_extra = 1;
                     if( ( i_private_id&0xf8 ) == 0x80 )
@@ -156,18 +157,18 @@ static inline int PESHeader( uint8_t *p_hdr, mtime_t i_pts, mtime_t i_dts,
                     bits_write( &bits, 1, 0x01 ); // marker
                 }
             }
-           else /* MPEG1 */
-           {
+            else /* MPEG1 */
+            {
                 int i_pts_dts;
 
                 if( i_pts >= 0 && i_dts >= 0 )
                 {
-                   bits_write( &bits, 16, i_es_size + 10 /* + stuffing */ );
+                    bits_write( &bits, 16, i_es_size + 10 /* + stuffing */ );
                     i_pts_dts = 0x03;
                 }
                 else if( i_pts >= 0 )
                 {
-                    bits_write( &bits, 16, i_es_size + 5 /* + stuffing */ );
+                    bits_write( &bits, 16, i_es_size + 5 /* + stuffing */ );
                     i_pts_dts = 0x02;
                 }
                 else
@@ -202,12 +203,12 @@ static inline int PESHeader( uint8_t *p_hdr, mtime_t i_pts, mtime_t i_dts,
                     bits_write( &bits, 15, i_dts );
                     bits_write( &bits, 1, 0x01 ); // marker
                 }
-               if( !i_pts_dts )
+                if( !i_pts_dts )
                 {
                     bits_write( &bits, 8, 0x0F );
                 }
 
-           }
+            }
 
             /* now should be stuffing */
             /* and then pes data */
index d6756d4c0d775dca59b758505e972c122625b449..d9d75c6544270dd1ac71c5f340e510809c3c910c 100644 (file)
@@ -2,7 +2,7 @@
  * ts.c: MPEG-II TS Muxer
  *****************************************************************************
  * Copyright (C) 2001, 2002 VideoLAN
- * $Id: ts.c,v 1.27 2003/08/14 11:47:32 gbazin Exp $
+ * $Id: ts.c,v 1.28 2003/08/14 23:37:54 fenrir Exp $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *          Eric Petit <titer@videolan.org>
@@ -59,6 +59,8 @@
  *  - check PCR frequency requirement
  *  - check PAT/PMT  "        "
  *  - check PCR/PCR "soft"
+ *  - check if "registration" descriptor : "AC-3" should be a program
+ *    descriptor or an es one. (xine want an es one)
  *
  *  - remove creation of PAT/PMT without dvbpsi
  *  - ?
@@ -173,7 +175,6 @@ struct sout_mux_sys_t
 
     int             i_stream_id_mpga;
     int             i_stream_id_mpgv;
-    int             i_stream_id_a52;
 
     int             i_audio_bound;
     int             i_video_bound;
@@ -241,7 +242,6 @@ static int Open( vlc_object_t *p_this )
     srand( (uint32_t)mdate() );
 
     p_sys->i_stream_id_mpga = 0xc0;
-    p_sys->i_stream_id_a52  = 0x80;
     p_sys->i_stream_id_mpgv = 0xe0;
 
     p_sys->i_audio_bound = 0;
@@ -424,8 +424,7 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
                     break;
                 case VLC_FOURCC( 'a', '5','2', ' ' ):
                     p_stream->i_stream_type = 0x81;
-                    p_stream->i_stream_id = p_sys->i_stream_id_a52;
-                    p_sys->i_stream_id_a52++;
+                    p_stream->i_stream_id = 0xbd;
                     break;
                 case VLC_FOURCC( 'm', 'p','4', 'a' ):
                     p_stream->i_stream_type = 0x11;
@@ -1294,6 +1293,11 @@ static void GetPMT( sout_mux_t *p_mux,
         bits_buffer_t bits;
         bits_buffer_t bits_fix_IOD;
 
+        /* Make valgrind happy : it works at byte level not bit one so
+         * bit_write confuse it (but DON'T CHANGE the way that bit_write is
+         * working (needed when fixing some bits) */
+        memset( iod, 0, 4096 );
+
         bits_initwrite( &bits, 4096, iod );
         // IOD_label
         bits_write( &bits, 8,   0x01 );
@@ -1412,47 +1416,41 @@ static void GetPMT( sout_mux_t *p_mux,
                                 p_stream->i_pid );
         if( p_stream->i_stream_id == 0xfa || p_stream->i_stream_id == 0xfb )
         {
-            uint8_t     data[512];
-            bits_buffer_t bits;
+            uint8_t     es_id[2];
 
             /* SL descriptor */
-            bits_initwrite( &bits, 512, data );
-            bits_write( &bits, 16, p_stream->i_es_id );
-
-            dvbpsi_PMTESAddDescriptor( p_es,
-                                       0x1f,
-                                       bits.i_data,
-                                       bits.p_data );
+            es_id[0] = (p_stream->i_es_id >> 8)&0xff;
+            es_id[1] = (p_stream->i_es_id)&0xff;
+            dvbpsi_PMTESAddDescriptor( p_es, 0x1f, 2, es_id );
         }
-        else if( p_stream->i_stream_id == 0xa0 )
+        else if( p_stream->i_stream_type == 0xa0 )
         {
             uint8_t     data[512];
-            uint8_t     fcc[4];
-            bits_buffer_t bits;
-
-            memcpy( fcc, &p_stream->i_bih_codec, 4 );
+            int         i_extra = __MIN( p_stream->i_decoder_specific_info,
+                                        502 );
 
             /* private DIV3 descripor */
-            bits_initwrite( &bits, 512, data );
-            bits_write( &bits, 8,  fcc[0]);
-            bits_write( &bits, 8,  fcc[1]);
-            bits_write( &bits, 8,  fcc[2]);
-            bits_write( &bits, 8,  fcc[3]);
-            bits_write( &bits, 16, p_stream->i_bih_width );
-            bits_write( &bits, 16, p_stream->i_bih_height );
-            bits_write( &bits, 16, p_stream->i_decoder_specific_info );
-            if( p_stream->i_decoder_specific_info > 0 )
+            memcpy( &data[0], &p_stream->i_bih_codec, 4 );
+            data[4] = ( p_stream->i_bih_width >> 8 )&&0xff;
+            data[5] = ( p_stream->i_bih_width      )&&0xff;
+            data[6] = ( p_stream->i_bih_height>> 8 )&&0xff;
+            data[7] = ( p_stream->i_bih_height     )&&0xff;
+            data[8] = ( i_extra >> 8 )&&0xff;
+            data[9] = ( i_extra      )&&0xff;
+            if( i_extra > 0 )
             {
-                int i;
-                for( i = 0; i < p_stream->i_decoder_specific_info; i++ )
-                {
-                    bits_write( &bits, 8, p_stream->p_decoder_specific_info[i] );
-                }
+                memcpy( &data[10], p_stream->p_decoder_specific_info, i_extra );
             }
-            dvbpsi_PMTESAddDescriptor( p_es,
-                                       0xa0,    // private
-                                       bits.i_data,
-                                       bits.p_data );
+
+            /* 0xa0 is private */
+            dvbpsi_PMTESAddDescriptor( p_es, 0xa0, i_extra  + 10, data );
+        }
+        else if( p_stream->i_stream_type == 0x81 )
+        {
+            uint8_t format[4] = { 0x41, 0x43, 0x2d, 0x33 };
+
+            /* "registration" descriptor : "AC-3" */
+            dvbpsi_PMTESAddDescriptor( p_es, 0x05, 4, format );
         }
     }