Index: subreader.c =================================================================== RCS file: /cvsroot/mplayer/main/subreader.c,v retrieving revision 1.135 diff -u -r1.135 subreader.c --- subreader.c 25 Jun 2004 16:49:51 -0000 1.135 +++ subreader.c 25 Jul 2004 12:42:01 -0000 @@ -1041,36 +1041,33 @@ #ifdef USE_ICONV static iconv_t icdsc = (iconv_t)(-1); -#ifdef HAVE_ENCA -void subcp_open_noenca () -{ - char enca_lang[100], enca_fallback[100]; - if (sub_cp) { - if (sscanf(sub_cp, "enca:%2s:%s", enca_lang, enca_fallback) == 2 - || sscanf(sub_cp, "ENCA:%2s:%s", enca_lang, enca_fallback) == 2) { - subcp_open(enca_fallback); - } else { - subcp_open(sub_cp); - } - } -} -#else -void subcp_open_noenca () -{ - subcp_open(sub_cp); -} -#endif - -void subcp_open (char *current_sub_cp) +void subcp_open (int use_enca) { char *tocp = "UTF-8"; - if (current_sub_cp){ - if ((icdsc = iconv_open (tocp, current_sub_cp)) != (iconv_t)(-1)){ + if (sub_cp){ + char *cp_tmp = sub_cp; +#ifdef HAVE_ENCA + char enca_lang[3], enca_fallback[100]; + int free_cp_tmp = 0; + if (sscanf(sub_cp, "enca:%2s:%99s", enca_lang, enca_fallback) == 2 + || sscanf(sub_cp, "ENCA:%2s:%99s", enca_lang, enca_fallback) == 2) { + if (use_enca) { + cp_tmp = guess_cp(fd, enca_lang, enca_fallback); + free_cp_tmp = 1; + } else { + cp_tmp = enca_fallback; + } + } +#endif + if ((icdsc = iconv_open (tocp, cp_tmp)) != (iconv_t)(-1)){ mp_msg(MSGT_SUBREADER,MSGL_V,"SUB: opened iconv descriptor.\n"); sub_utf8 = 2; } else mp_msg(MSGT_SUBREADER,MSGL_ERR,"SUB: error opening iconv descriptor.\n"); +#ifdef HAVE_ENCA + if (free_cp_tmp && cp_tmp) free(cp_tmp); +#endif } } @@ -1317,9 +1314,7 @@ int n_max, n_first, i, j, sub_first, sub_orig; subtitle *first, *second, *sub, *return_sub; sub_data *subt_data; - char enca_lang[100], enca_fallback[100]; int uses_time = 0, sub_num = 0, sub_errs = 0; - char *current_sub_cp=NULL; struct subreader sr[]= { { sub_read_line_microdvd, NULL, "microdvd" }, @@ -1351,17 +1346,6 @@ rewind (fd); #ifdef USE_ICONV -#ifdef HAVE_ENCA - if (sscanf(sub_cp, "enca:%2s:%s", enca_lang, enca_fallback) == 2 - || sscanf(sub_cp, "ENCA:%2s:%s", enca_lang, enca_fallback) == 2) { - current_sub_cp = guess_cp(fd, enca_lang, enca_fallback); - } else { - current_sub_cp = sub_cp ? strdup(sub_cp) : NULL; - } -#else - current_sub_cp = sub_cp ? strdup(sub_cp) : NULL; -#endif - sub_utf8_prev=sub_utf8; { int l,k; @@ -1374,10 +1358,9 @@ break; } } - if (k<0) subcp_open(current_sub_cp); + if (k<0) subcp_open(1); } #endif - if (current_sub_cp) free(current_sub_cp); sub_num=0;n_max=32; first=(subtitle *)malloc(n_max*sizeof(subtitle)); Index: subreader.h =================================================================== RCS file: /cvsroot/mplayer/main/subreader.h,v retrieving revision 1.32 diff -u -r1.32 subreader.h --- subreader.h 8 May 2004 17:52:25 -0000 1.32 +++ subreader.h 25 Jul 2004 12:42:02 -0000 @@ -53,8 +53,7 @@ sub_data* sub_read_file (char *filename, float pts); subtitle* subcp_recode1 (subtitle *sub); -void subcp_open (char *current_sub_cp); /* for demux_ogg.c */ -void subcp_open_noenca (); /* for demux_ogg.c */ +void subcp_open (int use_enca); /* for demux_ogg.c */ void subcp_close (void); /* for demux_ogg.c */ char ** sub_filenames(char *path, char *fname); void list_sub_file(sub_data* subd); Index: libmpdemux/demux_ogg.c =================================================================== RCS file: /cvsroot/mplayer/main/libmpdemux/demux_ogg.c,v retrieving revision 1.53 diff -u -r1.53 demux_ogg.c --- libmpdemux/demux_ogg.c 27 Jun 2004 13:55:40 -0000 1.53 +++ libmpdemux/demux_ogg.c 25 Jul 2004 12:42:07 -0000 @@ -669,7 +669,7 @@ sh_video_t* sh_v; #ifdef USE_ICONV - subcp_open_noenca(); + subcp_open(0); #endif clear_sub = -1; Index: libmpdemux/demux_mkv.c =================================================================== RCS file: /cvsroot/mplayer/main/libmpdemux/demux_mkv.c,v retrieving revision 1.18 diff -u -r1.18 demux_mkv.c --- libmpdemux/demux_mkv.c 28 Jun 2004 16:43:01 -0000 1.18 +++ libmpdemux/demux_mkv.c 25 Jul 2004 12:42:16 -0000 @@ -2018,7 +2018,7 @@ char *str; #ifdef USE_ICONV - subcp_open_noenca(); + subcp_open(0); #endif stream_seek(s, s->start_pos); Index: libmpdemux/demux_mkv_old.cpp =================================================================== RCS file: /cvsroot/mplayer/main/libmpdemux/demux_mkv_old.cpp,v retrieving revision 1.55 diff -u -r1.55 demux_mkv_old.cpp --- libmpdemux/demux_mkv_old.cpp 14 Jul 2004 14:35:45 -0000 1.55 +++ libmpdemux/demux_mkv_old.cpp 25 Jul 2004 12:42:27 -0000 @@ -1552,7 +1552,7 @@ qt_image_description_t *idesc; #ifdef USE_ICONV - subcp_open_noenca(); + subcp_open(0); #endif s = demuxer->stream;