[vlc-commits] mux: ts: don't set fmt.extra for subt

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


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

mux: ts: don't set fmt.extra for subt

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

 modules/mux/mpeg/tables.c | 63 +++++++++++++++++++++++++++++++++++++++++++++-
 modules/mux/mpeg/ts.c     | 64 ++++++-----------------------------------------
 2 files changed, 69 insertions(+), 58 deletions(-)

diff --git a/modules/mux/mpeg/tables.c b/modules/mux/mpeg/tables.c
index 66028892aa..513c9b9d95 100644
--- a/modules/mux/mpeg/tables.c
+++ b/modules/mux/mpeg/tables.c
@@ -119,6 +119,57 @@ static uint32_t GetDescriptorLength24b( int i_length )
     return( 0x808000 | ( i_l3 << 16 ) | ( i_l2 << 8 ) | i_l1 );
 }
 
+static void Mpeg4SUBTDecoderSpecific_55( bits_buffer_t *b )
+{
+    bits_write( b, 8, 0x10 ); /* textFormat, 0x10 for 3GPP TS 26.245 */
+    bits_write( b, 8, 0x00 ); /* flags: 1b: associated video info flag
+                                        3b: reserved
+                                        1b: duration flag
+                                        3b: reserved */
+    bits_write( b, 8, 52 );   /* remaining size */
+
+    bits_write( b, 32, 0x00 ); /* display flags */
+
+    bits_write( b, 8, 0x00 ); /* horizontal justification (-1: left, 0 center, 1 right) */
+    bits_write( b, 8, 0x01 );  /* vertical   justification (-1: top, 0 center, 1 bottom) */
+
+    bits_write( b, 24, 0x00 ); /* background rgb */
+    bits_write( b, 8,  0xff ); /* background a */
+
+    bits_write( b, 16,  0x00 ); /* text box top */
+    bits_write( b, 16,  0x00 ); /* text box left */
+    bits_write( b, 16,  0x00 ); /* text box bottom */
+    bits_write( b, 16,  0x00 ); /* text box right */
+
+    bits_write( b, 16,  0x00 ); /* start char */
+    bits_write( b, 16,  0x00 ); /* end char */
+    bits_write( b, 16,  0x00 ); /* default font id */
+
+
+    bits_write( b, 8, 0x00 );   /* font style flags */
+    bits_write( b, 8,   12 );   /* font size */
+
+    bits_write( b, 24, 0x00 );  /* foreground rgb */
+    bits_write( b,  8, 0x00 );  /* foreground a */
+
+    bits_write( b, 24, 0x00 );
+    bits_write( b,  8,   22 );  /* atom size */
+
+    bits_write( b,  8,   'f' ); /* atom id */
+    bits_write( b,  8,   't' );
+    bits_write( b,  8,   'a' );
+    bits_write( b,  8,   'b' );
+
+    bits_write( b,  8,  0x00 );
+    bits_write( b,  8,  0x01 ); /* entry count */
+
+    bits_write( b, 16,  0x00 ); /* font id */
+    bits_write( b,  8,     9 ); /* font name length */
+    const char fontname[] = "Helvetica";
+    for(int i=0; i<9; i++)
+        bits_write( b,  8, fontname[i] ); /* font name */
+}
+
 static void GetPMTmpeg4( vlc_object_t *p_object, dvbpsi_pmt_t *p_dvbpmt,
                          unsigned i_mapped_streams, const pes_mapped_stream_t *p_mapped_streams )
 {
@@ -211,7 +262,16 @@ static void GetPMTmpeg4( vlc_object_t *p_object, dvbpsi_pmt_t *p_dvbpmt,
         bits_write( &bits, 32,  0x7fffffff );   /* maxBitrate */
         bits_write( &bits, 32,  0 );            /* avgBitrate */
 
-        if( p_stream->pes->i_extra > 0 )
+        /* DecoderSpecificInfo */
+        if( p_stream->pes->i_codec == VLC_CODEC_SUBT )
+        {
+            bits_align( &bits );
+            bits_write( &bits, 8,   0x05 ); /* tag */
+            bits_write( &bits, 24,  55 );
+            /* Create decoder specific info for subt */
+            Mpeg4SUBTDecoderSpecific_55( &bits );
+        }
+        else if( p_stream->pes->i_extra > 0 )
         {
             /* DecoderSpecificInfo */
             bits_align( &bits );
@@ -224,6 +284,7 @@ static void GetPMTmpeg4( vlc_object_t *p_object, dvbpsi_pmt_t *p_dvbpmt,
                     ((uint8_t*)p_stream->pes->p_extra)[j] );
             }
         }
+
         /* fix Decoder length */
         bits_write( &bits_fix_Decoder, 24,
                     GetDescriptorLength24b( bits.i_data -
diff --git a/modules/mux/mpeg/ts.c b/modules/mux/mpeg/ts.c
index 5a48115517..bf08bc9ba1 100644
--- a/modules/mux/mpeg/ts.c
+++ b/modules/mux/mpeg/ts.c
@@ -974,66 +974,16 @@ static int AddStream( sout_mux_t *p_mux, sout_input_t *p_input )
         }
     }
 
-    /* Create decoder specific info for subt */
-    if( p_stream->pes.i_codec == VLC_CODEC_SUBT )
+    /* 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 = 55;
-        p_stream->pes.p_extra = malloc( p_stream->pes.i_extra );
-        if (!p_stream->pes.p_extra)
+        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;
 
-        uint8_t *p = p_stream->pes.p_extra;
-        p[0] = 0x10;    /* textFormat, 0x10 for 3GPP TS 26.245 */
-        p[1] = 0x00;    /* flags: 1b: associated video info flag
-                                3b: reserved
-                                1b: duration flag
-                                3b: reserved */
-        p[2] = 52;      /* remaining size */
-
-        p += 3;
-
-        p[0] = p[1] = p[2] = p[3] = 0; p+=4;    /* display flags */
-        *p++ = 0;  /* horizontal justification (-1: left, 0 center, 1 right) */
-        *p++ = 1;  /* vertical   justification (-1: top, 0 center, 1 bottom) */
-
-        p[0] = p[1] = p[2] = 0x00; p+=3;/* background rgb */
-        *p++ = 0xff;                    /* background a */
-
-        p[0] = p[1] = 0; p += 2;        /* text box top */
-        p[0] = p[1] = 0; p += 2;        /* text box left */
-        p[0] = p[1] = 0; p += 2;        /* text box bottom */
-        p[0] = p[1] = 0; p += 2;        /* text box right */
-
-        p[0] = p[1] = 0; p += 2;        /* start char */
-        p[0] = p[1] = 0; p += 2;        /* end char */
-        p[0] = p[1] = 0; p += 2;        /* default font id */
-
-        *p++ = 0;                       /* font style flags */
-        *p++ = 12;                      /* font size */
-
-        p[0] = p[1] = p[2] = 0x00; p+=3;/* foreground rgb */
-        *p++ = 0x00;                    /* foreground a */
-
-        p[0] = p[1] = p[2] = 0; p[3] = 22; p += 4;
-        memcpy( p, "ftab", 4 ); p += 4;
-        *p++ = 0; *p++ = 1;             /* entry count */
-        p[0] = p[1] = 0; p += 2;        /* font id */
-        *p++ = 9;                       /* font name length */
-        memcpy( p, "Helvetica", 9 );    /* font name */
-    }
-    else
-    {
-        /* 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 );
-        }
+        memcpy( p_stream->pes.p_extra, fmt->p_extra, fmt->i_extra );
     }
 
     /* Init pes chain */



More information about the vlc-commits mailing list