[MPlayer-dev-eng] Right to Left subtitles flipping from matroska
Reimar Döffinger
Reimar.Doeffinger at gmx.de
Fri Nov 20 11:38:33 CET 2009
On Thu, Nov 19, 2009 at 09:25:41PM -0500, Lior Galanti wrote:
> mplayer does not flip rtl subtitles when they are muxed into a matroska container.
> i wrote a patch to add the required fribidi call to correct this and its available here:
> http://lior.galanti.googlepages.com/mkv_demux_hebrew.diff
That duplicates a lot of code, what is the problem with just reusing the
existing code like attached patch does?
-------------- next part --------------
Index: subreader.c
===================================================================
--- subreader.c (revision 29937)
+++ subreader.c (working copy)
@@ -1148,7 +1148,7 @@
#endif
#ifdef CONFIG_FRIBIDI
-static subtitle* sub_fribidi (subtitle *sub, int sub_utf8)
+static subtitle* sub_fribidi (subtitle *sub, int sub_utf8, int last)
{
FriBidiChar logical[LINE_LEN+1], visual[LINE_LEN+1]; // Hopefully these two won't smash the stack
char *ip = NULL, *op = NULL;
@@ -1167,7 +1167,7 @@
}else {
char_set_num = fribidi_parse_charset ("UTF-8");
}
- while (l) {
+ while (l > last) {
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 +1415,7 @@
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 +2269,7 @@
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 +2314,9 @@
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-dev-eng
mailing list