[vlc-commits] mux: ts: simplify fmt params

Francois Cartegnie git at videolan.org
Tue Jul 25 14:07:35 CEST 2017


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Jul 24 18:43:07 2017 +0200| [83ecc95e94a5c77ab2f681f9a9c2ca6cdab32700] | committer: Francois Cartegnie

mux: ts: simplify fmt params

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=83ecc95e94a5c77ab2f681f9a9c2ca6cdab32700
---

 modules/mux/mpeg/streams.h |  7 -----
 modules/mux/mpeg/tables.c  | 64 +++++++++++++++++++++++-----------------------
 modules/mux/mpeg/ts.c      | 30 ++++------------------
 3 files changed, 37 insertions(+), 64 deletions(-)

diff --git a/modules/mux/mpeg/streams.h b/modules/mux/mpeg/streams.h
index 5f31822980..462a54ac26 100644
--- a/modules/mux/mpeg/streams.h
+++ b/modules/mux/mpeg/streams.h
@@ -32,18 +32,11 @@ typedef struct
 
 typedef struct
 {
-    vlc_fourcc_t    i_codec;
-
     int             i_stream_id; /* keep as int for drac */
 
-    int             i_width, i_height;
-
     /* Specific to mpeg4 in mpeg2ts */
     int             i_es_id;
 
-    size_t          i_extra;
-    uint8_t         *p_extra;
-
     /* language is iso639-2T */
     size_t          i_langs;
     uint8_t         *lang;
diff --git a/modules/mux/mpeg/tables.c b/modules/mux/mpeg/tables.c
index 513c9b9d95..dd4aa74739 100644
--- a/modules/mux/mpeg/tables.c
+++ b/modules/mux/mpeg/tables.c
@@ -244,7 +244,7 @@ static void GetPMTmpeg4( vlc_object_t *p_object, dvbpsi_pmt_t *p_dvbpmt,
             bits_write( &bits, 6, 0x05 );   /* AudioStream */
         }
         else if( p_stream->ts->i_stream_type == 0x12 &&
-                 p_stream->pes->i_codec == VLC_CODEC_SUBT )
+                 p_stream->fmt->i_codec == VLC_CODEC_SUBT )
         {
             bits_write( &bits, 8, 0x0B );   /* Text Stream */
             bits_write( &bits, 6, 0x04 );   /* VisualStream */
@@ -263,7 +263,7 @@ static void GetPMTmpeg4( vlc_object_t *p_object, dvbpsi_pmt_t *p_dvbpmt,
         bits_write( &bits, 32,  0 );            /* avgBitrate */
 
         /* DecoderSpecificInfo */
-        if( p_stream->pes->i_codec == VLC_CODEC_SUBT )
+        if( p_stream->fmt->i_codec == VLC_CODEC_SUBT )
         {
             bits_align( &bits );
             bits_write( &bits, 8,   0x05 ); /* tag */
@@ -271,17 +271,17 @@ static void GetPMTmpeg4( vlc_object_t *p_object, dvbpsi_pmt_t *p_dvbpmt,
             /* Create decoder specific info for subt */
             Mpeg4SUBTDecoderSpecific_55( &bits );
         }
-        else if( p_stream->pes->i_extra > 0 )
+        else if( p_stream->fmt->i_extra > 0 )
         {
             /* DecoderSpecificInfo */
             bits_align( &bits );
             bits_write( &bits, 8,   0x05 ); /* tag */
             bits_write( &bits, 24, GetDescriptorLength24b(
-                        p_stream->pes->i_extra ) );
-            for (size_t j = 0; j < p_stream->pes->i_extra; j++ )
+                        p_stream->fmt->i_extra ) );
+            for (int j = 0; j < p_stream->fmt->i_extra; j++ )
             {
                 bits_write( &bits, 8,
-                    ((uint8_t*)p_stream->pes->p_extra)[j] );
+                    ((uint8_t*)p_stream->fmt->p_extra)[j] );
             }
         }
 
@@ -315,7 +315,7 @@ static void GetPMTmpeg4( vlc_object_t *p_object, dvbpsi_pmt_t *p_dvbpmt,
 }
 
 static void UpdateServiceType( uint8_t *pi_service_cat, uint8_t *pi_service_type,
-                               const tsmux_stream_t *p_ts, const pesmux_stream_t *p_pes )
+                               const tsmux_stream_t *p_ts, const es_format_t *fmt )
 {
     uint8_t i_type = 0x00;
 
@@ -339,11 +339,13 @@ static void UpdateServiceType( uint8_t *pi_service_cat, uint8_t *pi_service_type
             break;
     }
 
-    if( i_type == 0x01 && p_pes->i_height > 468 && p_pes->i_width > 720 ) /* MPEG2 SD -> HD */
+    if( i_type == 0x01 && fmt->video.i_visible_height > 468 &&
+                          fmt->video.i_visible_width > 720 ) /* MPEG2 SD -> HD */
     {
          i_type = 0x11;
     }
-    else if( i_type == 0x16 && p_pes->i_height > 468 && p_pes->i_width > 720 ) /* Advanced codec SD -> HD */
+    else if( i_type == 0x16 && fmt->video.i_visible_height > 468 &&
+                               fmt->video.i_visible_width > 720 ) /* Advanced codec SD -> HD */
     {
          i_type = 0x19;
     }
@@ -484,32 +486,32 @@ void BuildPMT( dvbpsi_t *p_dvbpsi, vlc_object_t *p_object,
         else if( p_stream->ts->i_stream_type == 0xa0 )
         {
             uint8_t data[512];
-            size_t i_extra = __MIN( p_stream->pes->i_extra, 502 );
+            size_t i_extra = __MIN( p_stream->fmt->i_extra, 502 );
 
             /* private DIV3 descripor */
-            memcpy( &data[0], &p_stream->pes->i_codec, 4 );
-            data[4] = ( p_stream->pes->i_width >> 8 )&0xff;
-            data[5] = ( p_stream->pes->i_width      )&0xff;
-            data[6] = ( p_stream->pes->i_height>> 8 )&0xff;
-            data[7] = ( p_stream->pes->i_height     )&0xff;
+            memcpy( &data[0], &p_stream->fmt->i_codec, 4 );
+            data[4] = ( p_stream->fmt->video.i_visible_width >> 8 )&0xff;
+            data[5] = ( p_stream->fmt->video.i_visible_width      )&0xff;
+            data[6] = ( p_stream->fmt->video.i_visible_height>> 8 )&0xff;
+            data[7] = ( p_stream->fmt->video.i_visible_height     )&0xff;
             data[8] = ( i_extra >> 8 )&0xff;
             data[9] = ( i_extra      )&0xff;
             if( i_extra > 0 )
             {
-                memcpy( &data[10], p_stream->pes->p_extra, i_extra );
+                memcpy( &data[10], p_stream->fmt->p_extra, i_extra );
             }
 
             /* 0xa0 is private */
             dvbpsi_pmt_es_descriptor_add( p_es, 0xa0, i_extra + 10, data );
         }
-        else if( p_stream->pes->i_codec == VLC_CODEC_DIRAC )
+        else if( p_stream->fmt->i_codec == VLC_CODEC_DIRAC )
         {
             /* Dirac registration descriptor */
 
             uint8_t data[4] = { 'd', 'r', 'a', 'c' };
             dvbpsi_pmt_es_descriptor_add( p_es, 0x05, 4, data );
         }
-        else if( p_stream->pes->i_codec == VLC_CODEC_DTS )
+        else if( p_stream->fmt->i_codec == VLC_CODEC_DTS )
         {
             /* DTS registration descriptor (ETSI TS 101 154 Annex F) */
             if(popcount(p_stream->fmt->audio.i_bytes_per_frame) == 1)
@@ -522,7 +524,7 @@ void BuildPMT( dvbpsi_t *p_dvbpsi, vlc_object_t *p_object,
                 }
             }
         }
-        else if( p_stream->pes->i_codec == VLC_CODEC_A52 )
+        else if( p_stream->fmt->i_codec == VLC_CODEC_A52 )
         {
             uint8_t format[4] = { 'A', 'C', '-', '3'};
 
@@ -543,7 +545,7 @@ void BuildPMT( dvbpsi_t *p_dvbpsi, vlc_object_t *p_object,
                 dvbpsi_pmt_es_descriptor_add( p_es, 0x6a, 1, data );
             }
         }
-        else if( p_stream->pes->i_codec == VLC_CODEC_EAC3 )
+        else if( p_stream->fmt->i_codec == VLC_CODEC_EAC3 )
         {
             uint8_t format[4] = { 'E', 'A', 'C', '3'};
 
@@ -564,7 +566,7 @@ void BuildPMT( dvbpsi_t *p_dvbpsi, vlc_object_t *p_object,
                 dvbpsi_pmt_es_descriptor_add( p_es, 0x7a, 1, data );
             }
         }
-        else if( p_stream->pes->i_codec == VLC_CODEC_OPUS )
+        else if( p_stream->fmt->i_codec == VLC_CODEC_OPUS )
         {
             uint8_t data[2] = {
                 0x80, /* tag extension */
@@ -575,25 +577,25 @@ void BuildPMT( dvbpsi_t *p_dvbpsi, vlc_object_t *p_object,
             /* "registration" descriptor : "Opus" */
             dvbpsi_pmt_es_descriptor_add( p_es, 0x05, 4, format );
         }
-        else if( p_stream->pes->i_codec == VLC_CODEC_TELETEXT )
+        else if( p_stream->fmt->i_codec == VLC_CODEC_TELETEXT )
         {
-            if( p_stream->pes->i_extra )
+            if( p_stream->fmt->i_extra )
             {
                 dvbpsi_pmt_es_descriptor_add( p_es, 0x56,
-                                           p_stream->pes->i_extra,
-                                           p_stream->pes->p_extra );
+                                           p_stream->fmt->i_extra,
+                                           p_stream->fmt->p_extra );
             }
             continue;
         }
-        else if( p_stream->pes->i_codec == VLC_CODEC_DVBS )
+        else if( p_stream->fmt->i_codec == VLC_CODEC_DVBS )
         {
             /* DVB subtitles */
-            if( p_stream->pes->i_extra )
+            if( p_stream->fmt->i_extra )
             {
                 /* pass-through from the TS demux */
                 dvbpsi_pmt_es_descriptor_add( p_es, 0x59,
-                                           p_stream->pes->i_extra,
-                                           p_stream->pes->p_extra );
+                                           p_stream->fmt->i_extra,
+                                           p_stream->fmt->p_extra );
             }
             else
             {
@@ -628,7 +630,7 @@ void BuildPMT( dvbpsi_t *p_dvbpsi, vlc_object_t *p_object,
         {
             UpdateServiceType( &pi_service_cats[p_stream->i_mapped_prog],
                                &pi_service_types[p_stream->i_mapped_prog],
-                               p_stream->ts, p_stream->pes );
+                               p_stream->ts, p_stream->fmt );
         }
     }
 
@@ -826,8 +828,6 @@ int FillPMTESParams( ts_mux_standard standard, const es_format_t *fmt,
         return VLC_EGENERIC;
     }
 
-    pes->i_codec = fmt->i_codec;
-
     return VLC_SUCCESS;
 }
 
diff --git a/modules/mux/mpeg/ts.c b/modules/mux/mpeg/ts.c
index bf08bc9ba1..a6433c89f2 100644
--- a/modules/mux/mpeg/ts.c
+++ b/modules/mux/mpeg/ts.c
@@ -930,7 +930,7 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
         goto oom;
 
     if ( p_sys->b_es_id_pid )
-        p_stream->ts.i_pid = p_input->p_fmt->i_id & 0x1fff;
+        p_stream->ts.i_pid = p_input->fmt.i_id & 0x1fff;
     else
         p_stream->ts.i_pid = AllocatePID( p_mux, p_input->p_fmt->i_cat );
 
@@ -943,21 +943,15 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
         return VLC_EGENERIC;
     }
 
-    if( p_input->p_fmt->i_cat == VIDEO_ES )
-    {
-        p_stream->pes.i_width = p_input->p_fmt->video.i_width;
-        p_stream->pes.i_height = p_input->p_fmt->video.i_height;
-    }
-
     p_stream->pes.i_langs = 1 + p_input->p_fmt->i_extra_languages;
     p_stream->pes.lang = calloc(1, p_stream->pes.i_langs * 4);
     if( !p_stream->pes.lang )
         goto oom;
 
     msg_Dbg( p_mux, "adding input codec=%4.4s pid=%d",
-             (char*)&p_stream->pes.i_codec, p_stream->ts.i_pid );
+             (char*)&p_input->fmt.i_codec, p_stream->ts.i_pid );
 
-    for (int i = 0; i < p_stream->pes.i_langs; i++) {
+    for (size_t i = 0; i < p_stream->pes.i_langs; i++) {
         char *lang = (i == 0)
             ? p_input->p_fmt->psz_language
             : p_input->p_fmt->p_extra_languages[i-1].psz_language;
@@ -974,18 +968,6 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
         }
     }
 
-    /* Copy extra data (VOL for MPEG-4 and extra BitMapInfoHeader for VFW */
-    const es_format_t *fmt = p_input->p_fmt;
-    if( fmt->i_extra > 0 )
-    {
-        p_stream->pes.i_extra = fmt->i_extra;
-        p_stream->pes.p_extra = malloc( fmt->i_extra );
-        if( !p_stream->pes.p_extra )
-            goto oom;
-
-        memcpy( p_stream->pes.p_extra, fmt->p_extra, fmt->i_extra );
-    }
-
     /* Init pes chain */
     BufferChainInit( &p_stream->state.chain_pes );
 
@@ -1026,9 +1008,6 @@ static void DelStream( sout_mux_t *p_mux, sout_input_t *p_input )
     /* Empty all data in chain_pes */
     BufferChainClean( &p_stream->state.chain_pes );
 
-    free(p_stream->pes.lang);
-    free( p_stream->pes.p_extra );
-
     pid = var_GetInteger( p_mux, SOUT_CFG_PREFIX "pid-video" );
     if ( pid > 0 && pid == p_stream->ts.i_pid )
     {
@@ -1048,6 +1027,7 @@ static void DelStream( sout_mux_t *p_mux, sout_input_t *p_input )
         msg_Dbg( p_mux, "freeing spu PID %d", pid);
     }
 
+    free(p_stream->pes.lang);
     free( p_stream );
 
     /* We only change PMT version (PAT isn't changed) */
@@ -1255,7 +1235,7 @@ static bool MuxStreams(sout_mux_t *p_mux )
         {
             msg_Warn( p_mux, "packet with too strange dts on pid %d (%4.4s)"
                       "(dts=%"PRId64",old=%"PRId64",pcr=%"PRId64")",
-                      p_stream->ts.i_pid, (char *) &p_stream->pes.i_codec,
+                      p_stream->ts.i_pid, (char *) &p_input->fmt.i_codec,
                       p_data->i_dts, p_stream->state.i_pes_dts,
                       p_pcr_stream->state.i_pes_dts );
             block_Release( p_data );



More information about the vlc-commits mailing list