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

Basin Ilya basinilya at gmail.com
Tue Feb 2 15:57:21 CET 2016


Hi.
Here's a proposed patch for https://trac.mplayerhq.hu/ticket/2281

---
 mplayer.c       | 3 ++-
 sub/subreader.c | 9 +++++----
 sub/subreader.h | 1 +
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/mplayer.c b/mplayer.c
index 527bc40..5ce15e1 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;
 +    last_sub_cp = sub_cp;
     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, last_sub_cp);
 #else
         asst = ass_read_stream(ass_library, filename, 0);
 #endif
diff --git a/sub/subreader.c b/sub/subreader.c
index ecc5ff5..b5ca649 100644
--- a/sub/subreader.c
+++ b/sub/subreader.c
@@ -54,6 +54,7 @@
 #include <iconv.h>
 #endif
 char *sub_cp=NULL;
+char *last_sub_cp=NULL;
 #ifdef CONFIG_FRIBIDI
 #include <fribidi/fribidi.h>
 char *fribidi_charset = NULL;   ///character set that will be passed to
FriBiDi
@@ -1211,22 +1212,22 @@ void	subcp_open (stream_t *st)
 {
 	char *tocp = "UTF-8";
 +	last_sub_cp = sub_cp;
 	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);
+		    last_sub_cp = guess_cp(st, enca_lang, enca_fallback);
 		  } else {
-		    cp_tmp = enca_fallback;
+		    last_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, last_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..5e6935d 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 *last_sub_cp;
  // subtitle formats
 #define SUB_INVALID   -1
-- 
2.7.0



More information about the MPlayer-dev-eng mailing list