[vlc-devel] [PATCH 14/18] demux:ts: init the ts_es_t to its es_format_t when possible

Steve Lhomme robux4 at videolabs.io
Mon Jul 17 16:33:20 CEST 2017


---
 modules/demux/mpeg/ts_psi.c     | 8 +++-----
 modules/demux/mpeg/ts_streams.c | 9 ++++++---
 modules/demux/mpeg/ts_streams.h | 2 +-
 3 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/modules/demux/mpeg/ts_psi.c b/modules/demux/mpeg/ts_psi.c
index 622f4a13ee..603914d79e 100644
--- a/modules/demux/mpeg/ts_psi.c
+++ b/modules/demux/mpeg/ts_psi.c
@@ -677,11 +677,10 @@ static void PMTSetupEsTeletext( demux_t *p_demux, ts_stream_t *p_pes,
             }
             else
             {
-                p_page_es = ts_es_New( p_pes->p_es->p_program );
+                p_page_es = ts_es_New( p_pes->p_es->p_program, p_fmt );
                 if( !p_page_es )
                     break;
 
-                es_format_Copy( &p_page_es->fmt, p_fmt );
                 free( p_page_es->fmt.psz_language );
                 free( p_page_es->fmt.psz_description );
                 p_page_es->fmt.psz_language = NULL;
@@ -753,11 +752,10 @@ static void PMTSetupEsDvbSubtitle( demux_t *p_demux, ts_stream_t *p_pes,
             }
             else
             {
-                p_subs_es = ts_es_New( p_pes->p_es->p_program );
+                p_subs_es = ts_es_New( p_pes->p_es->p_program, p_fmt );
                 if( !p_subs_es )
                     break;
 
-                es_format_Copy( &p_subs_es->fmt, p_fmt );
                 free( p_subs_es->fmt.psz_language );
                 free( p_subs_es->fmt.psz_description );
                 p_subs_es->fmt.psz_language = NULL;
@@ -1816,7 +1814,7 @@ static void PMTCallBack( void *data, dvbpsi_pmt_t *p_dvbpsipmt )
                 /* Set up EAS spu es */
                 if( p_pmt->e_streams.i_size )
                 {
-                    ts_es_t *p_eas_es = ts_es_New( p_pmt );
+                    ts_es_t *p_eas_es = ts_es_New( p_pmt, NULL );
                     if( likely(p_eas_es) )
                     {
                         es_format_Change( &p_eas_es->fmt, SPU_ES, VLC_CODEC_SCTE_18 );
diff --git a/modules/demux/mpeg/ts_streams.c b/modules/demux/mpeg/ts_streams.c
index 9b5ec2d8d9..c65d2b876b 100644
--- a/modules/demux/mpeg/ts_streams.c
+++ b/modules/demux/mpeg/ts_streams.c
@@ -167,7 +167,7 @@ void ts_pmt_Del( demux_t *p_demux, ts_pmt_t *pmt )
     free( pmt );
 }
 
-ts_es_t * ts_es_New( ts_pmt_t *p_program )
+ts_es_t * ts_es_New( ts_pmt_t *p_program, const es_format_t *p_fmt )
 {
     ts_es_t *p_es = malloc( sizeof(*p_es) );
     if( p_es )
@@ -179,7 +179,10 @@ ts_es_t * ts_es_New( ts_pmt_t *p_program )
         p_es->p_extraes = NULL;
         p_es->p_next = NULL;
         p_es->b_interlaced = false;
-        es_format_Init( &p_es->fmt, UNKNOWN_ES, 0 );
+        if (p_fmt)
+            es_format_Copy( &p_es->fmt, p_fmt );
+        else
+            es_format_Init( &p_es->fmt, UNKNOWN_ES, 0 );
         p_es->fmt.i_group = p_program->i_number;
         p_es->metadata.i_format = 0;
         p_es->metadata.i_service_id = 0;
@@ -272,7 +275,7 @@ ts_stream_t *ts_stream_New( demux_t *p_demux, ts_pmt_t *p_program )
     if( !pes )
         return NULL;
 
-    pes->p_es = ts_es_New( p_program );
+    pes->p_es = ts_es_New( p_program, NULL );
     if( !pes->p_es )
     {
         free( pes );
diff --git a/modules/demux/mpeg/ts_streams.h b/modules/demux/mpeg/ts_streams.h
index 982c1a0576..080fb89db3 100644
--- a/modules/demux/mpeg/ts_streams.h
+++ b/modules/demux/mpeg/ts_streams.h
@@ -60,7 +60,7 @@ ts_pmt_t *ts_pat_Get_pmt( ts_pat_t *, uint16_t );
 ts_pmt_t *ts_pmt_New( demux_t * );
 void ts_pmt_Del( demux_t *, ts_pmt_t * );
 
-ts_es_t * ts_es_New( ts_pmt_t * );
+ts_es_t * ts_es_New( ts_pmt_t *, const es_format_t * );
 void ts_stream_Add_es( ts_stream_t *, ts_es_t *, bool );
 ts_es_t * ts_stream_Extract_es( ts_stream_t *, const ts_pmt_t * );
 ts_es_t * ts_stream_Find_es( ts_stream_t *, const ts_pmt_t * );
-- 
2.12.1



More information about the vlc-devel mailing list