]> git.sesse.net Git - vlc/blobdiff - modules/codec/subsdec.c
Fix invalid mix of closedir and free on Win32.
[vlc] / modules / codec / subsdec.c
index 23ffddd2c3e56852f4f63dbbb51029bac2026cfa..05fc3c1f927f1b4c50b7a4b8d2eb97c1367b35ae 100644 (file)
@@ -78,7 +78,7 @@ static void         StripTags      ( char * );
 /*****************************************************************************
  * Module descriptor.
  *****************************************************************************/
-static char *ppsz_encodings[] = { DEFAULT_NAME, "ASCII", "UTF-8", "",
+static const char *ppsz_encodings[] = { DEFAULT_NAME, "ASCII", "UTF-8", "",
     "ISO-8859-1", "CP1252", "MacRoman", "MacIceland","ISO-8859-15", "",
     "ISO-8859-2", "CP1250", "MacCentralEurope", "MacCroatian", "MacRomania", "",
     "ISO-8859-5", "CP1251", "MacCyrillic", "MacUkraine", "KOI8-R", "KOI8-U", "KOI8-RU", "",
@@ -99,9 +99,34 @@ static char *ppsz_encodings[] = { DEFAULT_NAME, "ASCII", "UTF-8", "",
     "HZ", "GBK", "GB18030", "JOHAB", "ARMSCII-8",
     "Georgian-Academy", "Georgian-PS", "TIS-620", "MuleLao-1", "VISCII", "TCVN",
     "HPROMAN8", "NEXTSTEP" };
+/*
+SSA supports charset selection.
+The following known charsets are used:
+
+0 = Ansi - Western European
+1 = default
+2 = symbol
+3 = invalid
+77 = Mac
+128 = Japanese (Shift JIS)
+129 = Hangul
+130 = Johab
+134 = GB2312 Simplified Chinese
+136 = Big5 Traditional Chinese
+161 = Greek
+162 = Turkish
+163 = Vietnamese
+177 = Hebrew
+178 = Arabic
+186 = Baltic
+204 = Russian (Cyrillic)
+222 = Thai
+238 = Eastern European
+254 = PC 437
+*/
 
 static int  pi_justification[] = { 0, 1, 2 };
-static char *ppsz_justification_text[] = {N_("Center"),N_("Left"),N_("Right")};
+static const char *ppsz_justification_text[] = {N_("Center"),N_("Left"),N_("Right")};
 
 #define ENCODING_TEXT N_("Subtitles text encoding")
 #define ENCODING_LONGTEXT N_("Set the encoding used in text subtitles")
@@ -175,7 +200,7 @@ static int OpenDecoder( vlc_object_t *p_this )
 
     if( p_dec->fmt_in.subs.psz_encoding && *p_dec->fmt_in.subs.psz_encoding )
     {
-        msg_Dbg( p_dec, "using character encoding: %s",
+        msg_Dbg( p_dec, "using demux suggested character encoding: %s",
                  p_dec->fmt_in.subs.psz_encoding );
         if( strcmp( p_dec->fmt_in.subs.psz_encoding, "UTF-8" ) )
             p_sys->iconv_handle = vlc_iconv_open( "UTF-8", p_dec->fmt_in.subs.psz_encoding );
@@ -193,15 +218,15 @@ static int OpenDecoder( vlc_object_t *p_this )
                     "subsdec-autodetect-utf8" );
 
             p_sys->iconv_handle = vlc_iconv_open( "UTF-8", psz_charset );
-            msg_Dbg( p_dec, "using default character encoding: %s", psz_charset );
+            msg_Dbg( p_dec, "using fallback character encoding: %s", psz_charset );
         }
         else if( !strcmp( val.psz_string, "UTF-8" ) )
         {
-            msg_Dbg( p_dec, "using character encoding: UTF-8" );
+            msg_Dbg( p_dec, "using enforced character encoding: UTF-8" );
         }
         else if( val.psz_string )
         {
-            msg_Dbg( p_dec, "using character encoding: %s", val.psz_string );
+            msg_Dbg( p_dec, "using enforced character encoding: %s", val.psz_string );
             p_sys->iconv_handle = vlc_iconv_open( "UTF-8", val.psz_string );
             if( p_sys->iconv_handle == (vlc_iconv_t)-1 )
             {
@@ -291,9 +316,11 @@ static subpicture_t *ParseText( decoder_t *p_dec, block_t *p_block )
     }
 
     /* Check validity of packet data */
-    if( p_block->i_buffer <= 1 || p_block->p_buffer[0] == '\0' )
+    /* An "empty" line containing only \0 can be used to force
+       and ephemer picture from the screen */
+    if( p_block->i_buffer < 1 )
     {
-        msg_Warn( p_dec, "empty subtitle" );
+        msg_Warn( p_dec, "no subtitle data" );
         return NULL;
     }
 
@@ -312,7 +339,7 @@ static subpicture_t *ParseText( decoder_t *p_dec, block_t *p_block )
         {
             if( IsUTF8( psz_subtitle ) == NULL )
             {
-                msg_Dbg( p_dec, "Invalid UTF-8 sequence: "
+                msg_Dbg( p_dec, "invalid UTF-8 sequence: "
                          "disabling UTF-8 subtitles autodetection" );
                 p_sys->b_autodetect_utf8 = VLC_FALSE;
             }
@@ -336,7 +363,7 @@ static subpicture_t *ParseText( decoder_t *p_dec, block_t *p_block )
             if( ( ret == (size_t)(-1) ) || inbytes_left )
             {
                 free( psz_new_subtitle );
-                msg_Err( p_dec, _("Failed to convert subtitle encoding.\n"
+                msg_Err( p_dec, _("failed to convert subtitle encoding.\n"
                         "Try manually setting a character-encoding "
                                 "before you open the file.") );
                 return NULL;
@@ -356,6 +383,8 @@ static subpicture_t *ParseText( decoder_t *p_dec, block_t *p_block )
         return NULL;
     }
 
+    p_spu->b_pausable = VLC_TRUE;
+
     /* Create a new subpicture region */
     memset( &fmt, 0, sizeof(video_format_t) );
     fmt.i_chroma = VLC_FOURCC('T','E','X','T');