Fix -subcp enca: with external ASS subtitles.
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>
Sat, 20 Feb 2016 10:38:30 +0000 (10:38 +0000)
committerreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>
Sat, 20 Feb 2016 10:38:30 +0000 (10:38 +0000)
Do not pass the raw -subcp including "enca:"
to libass.
Fix for issue #2281.

Patch by Basin Ilya [basinilya gmail.com]

git-svn-id: svn://git.mplayerhq.hu/mplayer/trunk@37744 b3059339-0415-0410-9bf9-f77b7e298cf2

mplayer.c
sub/subreader.c
sub/subreader.h

index 1165d72..cb62d55 100644 (file)
--- a/mplayer.c
+++ b/mplayer.c
@@ -1085,11 +1085,12 @@ void add_subtitles(char *filename, float fps, int noerr)
     if (filename == NULL || mpctx->set_of_sub_size >= MAX_SUBTITLE_FILES)
         return;
 
+    enca_sub_cp = NULL;
     subd = sub_read_file(filename, fps);
 #ifdef CONFIG_ASS
     if (ass_enabled)
 #ifdef CONFIG_ICONV
-        asst = ass_read_stream(ass_library, filename, sub_cp);
+        asst = ass_read_stream(ass_library, filename, (enca_sub_cp ? enca_sub_cp : sub_cp));
 #else
         asst = ass_read_stream(ass_library, filename, 0);
 #endif
index ecc5ff5..510c43a 100644 (file)
@@ -54,6 +54,7 @@
 #include <iconv.h>
 #endif
 char *sub_cp=NULL;
+char *enca_sub_cp=NULL;
 #ifdef CONFIG_FRIBIDI
 #include <fribidi/fribidi.h>
 char *fribidi_charset = NULL;   ///character set that will be passed to FriBiDi
@@ -1212,21 +1213,20 @@ void    subcp_open (stream_t *st)
        char *tocp = "UTF-8";
 
        if (sub_cp){
-               const char *cp_tmp = sub_cp;
 #ifdef CONFIG_ENCA
                char enca_lang[3], enca_fallback[100];
                if (sscanf(sub_cp, "enca:%2s:%99s", enca_lang, enca_fallback) == 2
                     || sscanf(sub_cp, "ENCA:%2s:%99s", enca_lang, enca_fallback) == 2) {
                  if (st && st->flags & MP_STREAM_SEEK ) {
-                   cp_tmp = guess_cp(st, enca_lang, enca_fallback);
+                   enca_sub_cp = guess_cp(st, enca_lang, enca_fallback);
                  } else {
-                   cp_tmp = enca_fallback;
+                   enca_sub_cp = enca_fallback;
                    if (st)
                      mp_msg(MSGT_SUBREADER,MSGL_WARN,"SUB: enca failed, stream must be seekable.\n");
                  }
                }
 #endif
-               if ((icdsc = iconv_open (tocp, cp_tmp)) != (iconv_t)(-1)){
+               if ((icdsc = iconv_open (tocp, enca_sub_cp)) != (iconv_t)(-1)){
                        mp_msg(MSGT_SUBREADER,MSGL_V,"SUB: opened iconv descriptor.\n");
                        sub_utf8 = 2;
                } else
index 0760081..554dbd7 100644 (file)
@@ -33,6 +33,7 @@ extern int sub_no_text_pp;  // disable text post-processing
 extern int sub_match_fuzziness;
 extern int sub_format;
 extern char *sub_cp;
+extern char *enca_sub_cp;
 
 // subtitle formats
 #define SUB_INVALID   -1