summaryrefslogtreecommitdiffstats
path: root/subreader.c
diff options
context:
space:
mode:
authorpontscho <pontscho@b3059339-0415-0410-9bf9-f77b7e298cf2>2003-01-21 19:12:46 +0000
committerpontscho <pontscho@b3059339-0415-0410-9bf9-f77b7e298cf2>2003-01-21 19:12:46 +0000
commitebdb38271ec4b4045c4e3db4408489a52729d050 (patch)
treec2b197cbd5fb82bac5a95fcab7f6b9f36b1c9974 /subreader.c
parent337542a33163ccb9d836219f8ed202db65401efd (diff)
downloadmpv-ebdb38271ec4b4045c4e3db4408489a52729d050.tar.bz2
mpv-ebdb38271ec4b4045c4e3db4408489a52729d050.tar.xz
- add subcp
- fix some 10l in gui - fix one 10l bug in subreader git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@9057 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'subreader.c')
-rw-r--r--subreader.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/subreader.c b/subreader.c
index 620329ea0d..5f72cace66 100644
--- a/subreader.c
+++ b/subreader.c
@@ -904,6 +904,7 @@ int sub_autodetect (FILE *fd) {
int sub_utf8=0;
#else
extern int sub_utf8;
+int sub_utf8_prev=0;
#endif
extern float sub_delay;
@@ -916,9 +917,11 @@ void subcp_open (void)
{
char *tocp = "UTF-8";
icdsc = (iconv_t)(-1);
+
if (sub_cp){
if ((icdsc = iconv_open (tocp, sub_cp)) != (iconv_t)(-1)){
mp_msg(MSGT_SUBREADER,MSGL_V,"SUB: opened iconv descriptor.\n");
+ sub_utf8_prev=sub_utf8;
sub_utf8 = 2;
} else
mp_msg(MSGT_SUBREADER,MSGL_ERR,"SUB: error opening iconv descriptor.\n");
@@ -929,6 +932,7 @@ void subcp_close (void)
{
if (icdsc != (iconv_t)(-1)){
(void) iconv_close (icdsc);
+ sub_utf8=sub_utf8_prev;
mp_msg(MSGT_SUBREADER,MSGL_V,"SUB: closed iconv descriptor.\n");
}
}
@@ -947,10 +951,10 @@ subtitle* subcp_recode (subtitle *sub)
ip = sub->text[--l];
ileft = strlen(ip);
oleft = ICBUFFSIZE - 1;
-
+
if (iconv(icdsc, &ip, &ileft,
&op, &oleft) == (size_t)(-1)) {
- mp_msg(MSGT_SUBREADER,MSGL_WARN,"SUB: error recoding line.\n");
+ mp_msg(MSGT_SUBREADER,MSGL_WARN,"SUB: error recoding line (1).\n");
l++;
break;
}
@@ -988,7 +992,7 @@ subtitle* subcp_recode1 (subtitle *sub)
if (iconv(icdsc, &ip, &ileft,
&op, &oleft) == (size_t)(-1)) {
- mp_msg(MSGT_SUBREADER,MSGL_WARN,"SUB: error recoding line.\n");
+ mp_msg(MSGT_SUBREADER,MSGL_WARN,"SUB: error recoding line (2).\n");
return sub;
}
*op='\0' ;
@@ -1119,6 +1123,14 @@ subtitle* sub_read_file (char *filename, float fps) {
#ifdef USE_ICONV
if ((sub!=ERR) && (sub_utf8 & 2)) sub=subcp_recode(sub);
#endif
+ if ( sub == ERR )
+ {
+#ifdef USE_ICONV
+ subcp_close();
+#endif
+ if ( first ) free(first);
+ return NULL;
+ }
// Apply any post processing that needs recoding first
if ((sub!=ERR) && srp->post) srp->post(sub);
#ifdef USE_SORTSUB