[MPlayer-cvslog] r29950 - trunk/subreader.c
reimar
subversion at mplayerhq.hu
Sun Nov 22 01:09:40 CET 2009
Author: reimar
Date: Sun Nov 22 01:09:40 2009
New Revision: 29950
Log:
Make fribidi (i.e. right-to-left) support work with embedded subtitles.
Modified:
trunk/subreader.c
Modified: trunk/subreader.c
==============================================================================
--- trunk/subreader.c Sun Nov 22 00:47:19 2009 (r29949)
+++ trunk/subreader.c Sun Nov 22 01:09:40 2009 (r29950)
@@ -1148,7 +1148,13 @@ subtitle* subcp_recode (subtitle *sub)
#endif
#ifdef CONFIG_FRIBIDI
-static subtitle* sub_fribidi (subtitle *sub, int sub_utf8)
+/**
+ * Do conversion necessary for right-to-left language support via fribidi.
+ * @param sub subtitle to convert
+ * @param sub_utf8 whether the subtitle is encoded in UTF-8
+ * @param from first new subtitle, all lines before this are assumed to be already converted
+ */
+static subtitle* sub_fribidi (subtitle *sub, int sub_utf8, int from)
{
FriBidiChar logical[LINE_LEN+1], visual[LINE_LEN+1]; // Hopefully these two won't smash the stack
char *ip = NULL, *op = NULL;
@@ -1167,7 +1173,7 @@ static subtitle* sub_fribidi (subtitle *
}else {
char_set_num = fribidi_parse_charset ("UTF-8");
}
- while (l) {
+ while (l > from) {
ip = sub->text[--l];
orig_len = len = strlen( ip ); // We assume that we don't use full unicode, only UTF-8 or ISO8859-x
if(len > LINE_LEN) {
@@ -1415,7 +1421,7 @@ sub_data* sub_read_file (char *filename,
if ((sub!=ERR) && (sub_utf8 & 2)) sub=subcp_recode(sub);
#endif
#ifdef CONFIG_FRIBIDI
- if (sub!=ERR) sub=sub_fribidi(sub,sub_utf8);
+ if (sub!=ERR) sub=sub_fribidi(sub,sub_utf8,0);
#endif
if ( sub == ERR )
{
@@ -2269,6 +2275,7 @@ void sub_add_text(subtitle *sub, const c
int double_newline = 1; // ignore newlines at the beginning
int i, pos;
char *buf;
+ int orig_lines = sub->lines;
if (sub->lines >= SUB_MAX_TEXT) return;
pos = 0;
buf = malloc(MAX_SUBLINE + 1);
@@ -2313,6 +2320,9 @@ void sub_add_text(subtitle *sub, const c
if (sub->lines < SUB_MAX_TEXT &&
strlen(sub->text[sub->lines]))
sub->lines++;
+#ifdef CONFIG_FRIBIDI
+ sub = sub_fribidi(sub, sub_utf8, orig_lines);
+#endif
}
#define MP_NOPTS_VALUE (-1LL<<63)
More information about the MPlayer-cvslog
mailing list