[MPlayer-dev-eng] [BUG][PATCH] Recent changes in CVS broke compilation when fribidi is in use + more configuration flags
Raindel Shachar
raindel at techunix.technion.ac.il
Wed Aug 13 02:20:28 CEST 2003
Hi,
a recent commit to the CVS by alex, which "fixed" a 10l bug, acctually
caused mplayer not to compile when fribidi is enabled. Attaches is a patch
which reverts the change, and adds an option to control wether sub titles
are flipped, and what char-set is used.
Please apply ASAP (preferably before next release, so that we will be able
to claim that "MPlayer has OOB Hebrew support")
Cheers
Shachar
-------------- next part --------------
Index: subreader.c
===================================================================
RCS file: /cvsroot/mplayer/main/subreader.c,v
retrieving revision 1.118
diff -u -r1.118 subreader.c
--- subreader.c 10 Aug 2003 15:14:47 -0000 1.118
+++ subreader.c 13 Aug 2003 00:08:24 -0000
@@ -27,6 +27,8 @@
#endif
#ifdef USE_FRIBIDI
#include <fribidi/fribidi.h>
+char *fribidi_charset = "ISO8859-8";
+int flip_hebrew=1;
#endif
extern char* dvdsub_lang;
@@ -1031,6 +1033,7 @@
#ifndef max
#define max(a,b) (((a)>(b))?(a):(b))
#endif
+#define ALLOCATE(tp,ln) ((tp *) malloc (sizeof (tp) * (ln)))
subtitle* sub_fribidi (subtitle *sub, int sub_utf8)
{
FriBidiChar logical[LINE_LEN+1], visual[LINE_LEN+1]; // Hopefully these two won't smash the stack
@@ -1040,45 +1043,46 @@
int l=sub->lines;
int char_set_num;
fribidi_boolean log2vis;
- fribidi_set_mirroring (FRIBIDI_TRUE);
- fribidi_set_reorder_nsm (FRIBIDI_FALSE);
+ if(flip_hebrew) {
+ fribidi_set_mirroring (FRIBIDI_TRUE);
+ fribidi_set_reorder_nsm (FRIBIDI_FALSE);
- if( sub_utf8 == 0 ) {
- char_set_num = fribidi_parse_charset ("ISO8859-8");//We might want to make this a config option
- }else {
- char_set_num = fribidi_parse_charset ("UTF-8");
- }
- while (l) {
- 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) {
- mp_msg(MSGT_SUBREADER,MSGL_WARN,"SUB: sub->text is longer than LINE_LEN.\n");
- l++;
- break;
+ if( sub_utf8 == 0 ) {
+ char_set_num = fribidi_parse_charset (fribidi_charset);
+ }else {
+ char_set_num = fribidi_parse_charset ("UTF-8");
}
- len = fribidi_charset_to_unicode (char_set_num, ip, len, logical);
- base = FRIBIDI_TYPE_ON;
- log2vis = fribidi_log2vis (logical, len, &base,
- /* output */
- visual, NULL, NULL, NULL);
- if(log2vis) {
- len = fribidi_remove_bidi_marks (visual, len, NULL, NULL,
- NULL);
- if((op = (char*)malloc(sizeof(char)*(max(2*orig_len,2*len) + 1))) == NULL) {
- if((op = ALLOCATE(char,(max(2*orig_len,2*len) + 1))) == NULL) {
- mp_msg(MSGT_SUBREADER,MSGL_WARN,"SUB: error allocating mem.\n");
+ while (l) {
+ 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) {
+ mp_msg(MSGT_SUBREADER,MSGL_WARN,"SUB: sub->text is longer than LINE_LEN.\n");
l++;
- break;
+ break;
+ }
+ len = fribidi_charset_to_unicode (char_set_num, ip, len, logical);
+ base = FRIBIDI_TYPE_ON;
+ log2vis = fribidi_log2vis (logical, len, &base,
+ /* output */
+ visual, NULL, NULL, NULL);
+ if(log2vis) {
+ len = fribidi_remove_bidi_marks (visual, len, NULL, NULL,
+ NULL);
+ if((op = ALLOCATE(char,(max(2*orig_len,2*len) + 1))) == NULL) {
+ mp_msg(MSGT_SUBREADER,MSGL_WARN,"SUB: error allocating mem.\n");
+ l++;
+ break;
+ }
+ fribidi_unicode_to_charset ( char_set_num, visual, len,op);
+ free (ip);
+ sub->text[l] = op;
}
- fribidi_unicode_to_charset ( char_set_num, visual, len,op);
- free (ip);
- sub->text[l] = op;
}
- }
- if (l){
- for (l = sub->lines; l;)
- free (sub->text[--l]);
- return ERR;
+ if (l){
+ for (l = sub->lines; l;)
+ free (sub->text[--l]);
+ return ERR;
+ }
}
return sub;
}
Index: cfg-common.h
===================================================================
RCS file: /cvsroot/mplayer/main/cfg-common.h,v
retrieving revision 1.105
diff -u -r1.105 cfg-common.h
--- cfg-common.h 11 Aug 2003 01:38:50 -0000 1.105
+++ cfg-common.h 13 Aug 2003 00:08:26 -0000
@@ -197,6 +197,15 @@
#ifdef USE_SUB
{"sub", &sub_name, CONF_TYPE_STRING_LIST, 0, 0, 0, NULL},
+#ifdef USE_FRIBIDI
+ {"fribidi_charset", &fribidi_charset, CONF_TYPE_STRING, 0, 0, 0, NULL},
+ {"flip_hebrew", &flip_hebrew, CONF_TYPE_FLAG, 0, 0, 1, NULL},
+ {"noflip_hebrew", &flip_hebrew, CONF_TYPE_FLAG, 0, 1, 0, NULL},
+#else
+ {"fribidi_charset", "mplayer wasn't compiled with FriBiDi support\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL},
+ {"flip_hebrew", "mplayer wasn't compiled with FriBiDi support\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL},
+ {"noflip_hebrew", "mplayer wasn't compiled with FriBiDi support\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL},
+#endif
#ifdef USE_ICONV
{"subcp", &sub_cp, CONF_TYPE_STRING, 0, 0, 0, NULL},
#endif
More information about the MPlayer-dev-eng
mailing list