# HG changeset patch # User reimar # Date 1161187799 0 # Node ID 4f5c3fbbbba507e4fa81c1623994a8e3a0c5f094 # Parent eb43bae38445d24599f5626a0b2275badc0ed810 redone subcp_recode: get rid of static buffer, skip lines that failed to convert instead of removing all remaining lines and remove subcp_recode1 since subcp_recode should now work just as well. diff -r eb43bae38445 -r 4f5c3fbbbba5 libmpdemux/demux_ogg.c --- a/libmpdemux/demux_ogg.c Wed Oct 18 15:52:26 2006 +0000 +++ b/libmpdemux/demux_ogg.c Wed Oct 18 16:09:59 2006 +0000 @@ -293,7 +293,7 @@ mp_msg(MSGT_DEMUX,MSGL_DBG2,"Ogg sub lines: %d first: '%s'\n", ogg_sub.lines, ogg_sub.text[0]); #ifdef USE_ICONV - subcp_recode1(&ogg_sub); + subcp_recode(&ogg_sub); #endif vo_sub = &ogg_sub; vo_osd_changed(OSDTYPE_SUBTITLE); diff -r eb43bae38445 -r 4f5c3fbbbba5 subreader.c --- a/subreader.c Wed Oct 18 15:52:26 2006 +0000 +++ b/subreader.c Wed Oct 18 16:09:59 2006 +0000 @@ -1116,69 +1116,35 @@ } } -#define ICBUFFSIZE 512 -static char icbuffer[ICBUFFSIZE]; - -static subtitle* subcp_recode (subtitle *sub) +subtitle* subcp_recode (subtitle *sub) { int l=sub->lines; size_t ileft, oleft; char *op, *ip, *ot; + if(icdsc == (iconv_t)(-1)) return sub; while (l){ - op = icbuffer; ip = sub->text[--l]; ileft = strlen(ip); - oleft = ICBUFFSIZE - 1; + oleft = 4 * ileft; + if (!(ot = malloc(oleft + 1))){ + mp_msg(MSGT_SUBREADER,MSGL_WARN,"SUB: error allocating mem.\n"); + continue; + } + op = ot; if (iconv(icdsc, &ip, &ileft, &op, &oleft) == (size_t)(-1)) { - mp_msg(MSGT_SUBREADER,MSGL_WARN,"SUB: error recoding line (1).\n"); - l++; - break; - } - if (!(ot = malloc(op - icbuffer + 1))){ - mp_msg(MSGT_SUBREADER,MSGL_WARN,"SUB: error allocating mem.\n"); - l++; - break; + mp_msg(MSGT_SUBREADER,MSGL_WARN,"SUB: error recoding line.\n"); + free(ot); + continue; } *op='\0' ; - strcpy (ot, icbuffer); free (sub->text[l]); sub->text[l] = ot; } - if (l){ - for (l = sub->lines; l;) - free (sub->text[--l]); - return ERR; - } return sub; } - -// for demux_ogg.c: -subtitle* subcp_recode1 (subtitle *sub) -{ - int l=sub->lines; - size_t ileft, oleft; - - if(icdsc == (iconv_t)(-1)) return sub; - - while (l){ - char *ip = icbuffer; - char *op = sub->text[--l]; - strlcpy(ip, op, ICBUFFSIZE); - ileft = strlen(ip); - oleft = ICBUFFSIZE - 1; - - if (iconv(icdsc, &ip, &ileft, - &op, &oleft) == (size_t)(-1)) { - mp_msg(MSGT_SUBREADER,MSGL_V,"SUB: error recoding line (2).\n"); - return sub; - } - *op='\0' ; - } - return sub; -} #endif #ifdef USE_FRIBIDI