[MPlayer-dev-eng] [PATCH] fix libass fails with -subcp enca: and external subtitles try 2

Basin Ilya basinilya at gmail.com
Sat Feb 13 11:55:01 CET 2016


Hi.
Here's a proposed patch for https://trac.mplayerhq.hu/ticket/2281
---
 mplayer.c       | 3 ++-
 sub/subreader.c | 8 ++++----
 sub/subreader.h | 1 +
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/mplayer.c b/mplayer.c
index aa5ca33..017e149 100644
--- 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
diff --git a/sub/subreader.c b/sub/subreader.c
index ecc5ff5..510c43a 100644
--- a/sub/subreader.c
+++ b/sub/subreader.c
@@ -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
diff --git a/sub/subreader.h b/sub/subreader.h
index 0760081..554dbd7 100644
--- a/sub/subreader.h
+++ b/sub/subreader.h
@@ -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
-- 
2.7.0





More information about the MPlayer-dev-eng mailing list