]> git.sesse.net Git - vlc/blobdiff - modules/demux/ts.c
skins2: fix minor artefact with animated image
[vlc] / modules / demux / ts.c
index 72a997e90773b9347b1ddfc507cbbbe205a01659..df8c54d1c51953ae10107d02a69d5d3492dd6641 100644 (file)
@@ -167,20 +167,20 @@ vlc_module_begin ()
     set_subcategory( SUBCAT_INPUT_DEMUX )
 
     add_string( "ts-extra-pmt", NULL, PMT_TEXT, PMT_LONGTEXT, true )
-    add_bool( "ts-es-id-pid", true, NULL, PID_TEXT, PID_LONGTEXT, true )
+    add_bool( "ts-es-id-pid", true, PID_TEXT, PID_LONGTEXT, true )
     add_string( "ts-out", NULL, TSOUT_TEXT, TSOUT_LONGTEXT, true )
     add_integer( "ts-out-mtu", 1400, MTUOUT_TEXT,
                  MTUOUT_LONGTEXT, true )
     add_string( "ts-csa-ck", NULL, CSA_TEXT, CSA_LONGTEXT, true )
     add_string( "ts-csa2-ck", NULL, CSA_TEXT, CSA_LONGTEXT, true )
     add_integer( "ts-csa-pkt", 188, CPKT_TEXT, CPKT_LONGTEXT, true )
-    add_bool( "ts-silent", false, NULL, SILENT_TEXT, SILENT_LONGTEXT, true )
+    add_bool( "ts-silent", false, SILENT_TEXT, SILENT_LONGTEXT, true )
 
     add_savefile( "ts-dump-file", NULL, TSDUMP_TEXT, TSDUMP_LONGTEXT, false )
-    add_bool( "ts-dump-append", false, NULL, APPEND_TEXT, APPEND_LONGTEXT, false )
+    add_bool( "ts-dump-append", false, APPEND_TEXT, APPEND_LONGTEXT, false )
     add_integer( "ts-dump-size", 16384, DUMPSIZE_TEXT,
                  DUMPSIZE_LONGTEXT, true )
-    add_bool( "ts-split-es", true, NULL, SPLIT_ES_TEXT, SPLIT_ES_LONGTEXT, false )
+    add_bool( "ts-split-es", true, SPLIT_ES_TEXT, SPLIT_ES_LONGTEXT, false )
 
     set_capability( "demux", 10 )
     set_callbacks( Open, Close )
@@ -1553,11 +1553,8 @@ static void PIDInit( ts_pid_t *pid, bool b_psi, ts_psi_t *p_owner )
         if( !b_old_valid )
         {
             pid->psi = xmalloc( sizeof( ts_psi_t ) );
-            if( pid->psi )
-            {
-                pid->psi->handle = NULL;
-                TAB_INIT( pid->psi->i_prg, pid->psi->prg );
-            }
+            pid->psi->handle = NULL;
+            TAB_INIT( pid->psi->i_prg, pid->psi->prg );
         }
         assert( pid->psi );
 
@@ -1680,7 +1677,7 @@ static void ParsePES( demux_t *p_demux, ts_pid_t *pid )
     if( header[0] != 0 || header[1] != 0 || header[2] != 1 )
     {
         if( !p_demux->p_sys->b_silent )
-            msg_Warn( p_demux, "invalid header [0x%x:%x:%x:%x] (pid: %d)",
+            msg_Warn( p_demux, "invalid header [0x%02x:%02x:%02x:%02x] (pid: %d)",
                       header[0], header[1],header[2],header[3], pid->i_pid );
         block_ChainRelease( p_pes );
         return;
@@ -2621,10 +2618,8 @@ static char *EITConvertToUTF8( const unsigned char *psz_instring,
                                bool b_broken )
 {
     const char *psz_encoding;
-    char *psz_outstring;
     char psz_encbuf[sizeof( "ISO_8859-123" )];
-    size_t i_in, i_out, offset = 1;
-    vlc_iconv_t iconv_handle;
+    size_t offset = 1;
 
     if( i_length < 1 ) return NULL;
     if( psz_instring[0] >= 0x20 )
@@ -2710,55 +2705,26 @@ static char *EITConvertToUTF8( const unsigned char *psz_instring,
         offset = 0;
     }
 
-    i_in = i_length - offset;
-    i_out = i_in * 6 + 1;
+    psz_instring += offset;
+    i_length -= offset;
 
-    psz_outstring = malloc( i_out );
-    if( !psz_outstring )
-    {
-        return NULL;
+    char *psz = FromCharset( psz_encoding, psz_instring, i_length );
+    if( psz == NULL )
+    {    /* Invalid character set (e.g. ISO_8859-12) */
+        psz = strndup( (const char *)psz_instring, i_length );
+        if( unlikely(psz == NULL) )
+            return NULL;
+        EnsureUTF8( psz );
     }
 
-    iconv_handle = vlc_iconv_open( "UTF-8", psz_encoding );
-    if( iconv_handle == (vlc_iconv_t)(-1) )
+    /* Convert EIT-coded CR/LFs */
+    for(char *p = strstr( psz, "\xc2\x8a" ); p != NULL;
+        p = strstr( p, "\xc2\x8a" ))
     {
-         /* Invalid character set (e.g. ISO_8859-12) */
-         memcpy( psz_outstring, &psz_instring[offset], i_in );
-         psz_outstring[i_in] = '\0';
-         EnsureUTF8( psz_outstring );
-    }
-    else
-    {
-        const char *psz_in = (const char *)&psz_instring[offset];
-        char *psz_out = psz_outstring;
-
-        while( vlc_iconv( iconv_handle, &psz_in, &i_in,
-                          &psz_out, &i_out ) == (size_t)(-1) )
-        {
-            /* skip naughty byte. This may fail terribly for multibyte stuff,
-             * but what can we do anyway? */
-            psz_in++;
-            i_in--;
-            vlc_iconv( iconv_handle, NULL, NULL, NULL, NULL ); /* reset */
-        }
-        vlc_iconv_close( iconv_handle );
-
-        *psz_out = '\0';
-
-        /* Convert EIT-coded CR/LFs */
-        unsigned char *pbuf = (unsigned char *)psz_outstring;
-        for( ; pbuf < (unsigned char *)psz_out ; pbuf++)
-        {
-            if( pbuf[0] == 0xc2 && pbuf[1] == 0x8a )
-            {
-                pbuf[0] = ' ';
-                pbuf[1] = '\n';
-            }
-        }
-
-
+        p[0] = ' ';
+        p[1] = '\n';
     }
-    return psz_outstring;
+    return psz;
 }
 
 static void SDTCallBack( demux_t *p_demux, dvbpsi_sdt_t *p_sdt )