[Mplayer-cvslog] CVS: main Makefile,1.259,1.260 configure,1.682,1.683 subreader.c,1.98,1.99

Alex Beregszaszi alex at mplayerhq.hu
Fri Mar 21 17:54:08 CET 2003


Update of /cvsroot/mplayer/main
In directory mail:/var/tmp.root/cvs-serv26471

Modified Files:
	Makefile configure subreader.c 
Log Message:
hebrew support using fribidi libs, patch by Raindel Shachar <raindel at techunix.technion.ac.il>

Index: Makefile
===================================================================
RCS file: /cvsroot/mplayer/main/Makefile,v
retrieving revision 1.259
retrieving revision 1.260
diff -u -r1.259 -r1.260
--- Makefile	21 Mar 2003 16:06:11 -0000	1.259
+++ Makefile	21 Mar 2003 16:54:03 -0000	1.260
@@ -36,9 +36,9 @@
 VO_LIBS = $(AA_LIB) $(X_LIB) $(SDL_LIB) $(GGI_LIB) $(MP1E_LIB) $(MLIB_LIB) $(SVGA_LIB) $(DIRECTFB_LIB) 
 AO_LIBS = $(ARTS_LIB) $(ESD_LIB) $(NAS_LIB) $(SGIAUDIO_LIB)
 CODEC_LIBS = $(AV_LIB) $(FAME_LIB) $(MAD_LIB) $(VORBIS_LIB) $(FAAD_LIB) $(LIBLZO_LIB) $(DECORE_LIB) $(XVID_LIB) $(PNG_LIB) $(Z_LIB) $(JPEG_LIB) $(ALSA_LIB) $(XMMS_LIB)
-COMMON_LIBS = libmpcodecs/libmpcodecs.a mp3lib/libMP3.a liba52/liba52.a libmpeg2/libmpeg2.a $(W32_LIB) $(DS_LIB) libaf/libaf.a libmpdemux/libmpdemux.a input/libinput.a postproc/libswscale.a osdep/libosdep.a $(CSS_LIB) $(CODEC_LIBS) $(FREETYPE_LIB) $(TERMCAP_LIB) $(CDPARANOIA_LIB) $(STREAMING_LIB) $(WIN32_LIB) $(GIF_LIB) $(MACOSX_FRAMEWORKS) $(SMBSUPPORT_LIB)
+COMMON_LIBS = libmpcodecs/libmpcodecs.a mp3lib/libMP3.a liba52/liba52.a libmpeg2/libmpeg2.a $(W32_LIB) $(DS_LIB) libaf/libaf.a libmpdemux/libmpdemux.a input/libinput.a postproc/libswscale.a osdep/libosdep.a $(CSS_LIB) $(CODEC_LIBS) $(FREETYPE_LIB) $(TERMCAP_LIB) $(CDPARANOIA_LIB) $(STREAMING_LIB) $(WIN32_LIB) $(GIF_LIB) $(MACOSX_FRAMEWORKS) $(SMBSUPPORT_LIB) $(FRIBIDI_LIB)
 
-CFLAGS = $(OPTFLAGS) -Ilibmpdemux -Iloader -Ilibvo $(FREETYPE_INC) $(EXTRA_INC) $(CDPARANOIA_INC) $(SDL_INC) $(SMBSUPPORT_INC) # -Wall
+CFLAGS = $(OPTFLAGS) -Ilibmpdemux -Iloader -Ilibvo $(FREETYPE_INC) $(EXTRA_INC) $(CDPARANOIA_INC) $(SDL_INC) $(SMBSUPPORT_INC) $(FRIBIDI_INC) # -Wall
 
 ifeq ($(TARGET_ALTIVEC),yes)
 ifeq ($(TARGET_OS),Darwin)

Index: configure
===================================================================
RCS file: /cvsroot/mplayer/main/configure,v
retrieving revision 1.682
retrieving revision 1.683
diff -u -r1.682 -r1.683
--- configure	21 Mar 2003 16:06:11 -0000	1.682
+++ configure	21 Mar 2003 16:54:03 -0000	1.683
@@ -166,6 +166,7 @@
   --disable-new-conf     Disable new experimental config parser code [enabled]
   --enable-menu          Enable osd menu support (needs new config) [disabled]
   --disable-sortsub      Disable subtitles sorting [enabled]
+  --enable-fribidi       Enable using the FriBiDi libs [disabled]
   --disable-macosx       Disable Mac OS X specific features [autodetect]
 
 Codecs:
@@ -293,6 +294,8 @@
   --with-xmmslibdir=DIR    path to libxmms.so.1
   --with-cdparanoiaincdir=DIR  cdparanoia headers in DIR
   --with-cdparanoialibdir=DIR  cdparanoia libraries (libcdda_*) in DIR
+  --with-fribidi-config=PATH  path to fribidi-config
+                           (e.g. /opt/bin/fribidi-config)
 
 EOF
     exit 0
@@ -1070,6 +1073,8 @@
 _macosx=auto
 _sortsub=yes
 _freetypeconfig='freetype-config'
+_fribidi=no
+_fribidiconfig='fribidi-config'
 
 for ac_option do
   case "$ac_option" in
@@ -1257,6 +1262,9 @@
   --enable-unrarlib)	_unrarlib=yes	;;
   --disable-unrarlib)	_unrarlib=no	;;
 
+  --enable-fribidi)     _fribidi=yes    ;;
+  --disable-fribidi)    _fribidi=no     ;;
+
   --enable-dga) _dga=auto ;; # as we don't know if it's 1 or 2
   --enable-dga=*) _dga=`echo $ac_option | cut -d '=' -f 2` ;;
   --disable-dga) _dga=no ;;
@@ -1375,6 +1383,9 @@
   --with-freetype-config=*)
     _freetypeconfig=`echo $ac_option | cut -d '=' -f 2`
     ;;
+  --with-fribidi-config=*)
+    _fribidiconfig=`echo $ac_option | cut -d '=' -f 2`
+    ;;
   --with-gtk-config=*)
     _gtkconfig=`echo $ac_option | cut -d '=' -f 2`
     ;;
@@ -3789,6 +3800,38 @@
 fi
 echores "$_freetype"
 
+
+echocheck "fribidi with charsets"
+if test "$_fribidi" = yes ; then
+    if ( $_fribidiconfig --version ) >/dev/null 2>&1 ; then
+	cat > $TMPC << EOF
+#include <stdio.h>
+#include <fribidi/fribidi.h>
+int main()
+{
+    if(fribidi_parse_charset("UTF-8") != FRIBIDI_CHARSET_UTF8) {
+       printf("Fribidi headers are not consistents with the library!\n");
+       exit(1);
+    }
+    return 0;
+}
+EOF
+	_fribidi=no
+	cc_check `$_fribidiconfig --cflags` `$_fribidiconfig --libs` && ( $TMPO >> "$TMPLOG" ) && _fribidi=yes
+    else
+	_fribidi=no
+    fi
+fi
+if test "$_fribidi" = yes ; then
+    _def_fribidi='#define USE_FRIBIDI'
+    _inc_fribidi=`$_fribidiconfig --cflags`
+    _ld_fribidi=`$_fribidiconfig --libs`
+else
+    _def_fribidi='#undef USE_FRIBIDI'
+fi
+echores "$_fribidi"
+
+
 echocheck "zlib"
 cat > $TMPC << EOF
 #include <zlib.h>
@@ -5044,6 +5087,8 @@
 CDPARANOIA_LIB = $_ld_cdparanoia
 FREETYPE_INC = $_inc_freetype
 FREETYPE_LIB = $_ld_freetype
+FRIBIDI_INC = $_inc_fribidi
+FRIBIDI_LIB = $_ld_fribidi
 LIBLZO_LIB= $_ld_liblzo
 MAD_LIB = $_ld_mad
 VORBIS_LIB = $_ld_vorbis $_ld_libdv
@@ -5437,6 +5482,9 @@
 
 /* enable FreeType support */
 $_def_freetype
+
+/* enable FriBiDi usage */
+$_def_fribidi
 
 /* liblzo support */
 $_def_liblzo

Index: subreader.c
===================================================================
RCS file: /cvsroot/mplayer/main/subreader.c,v
retrieving revision 1.98
retrieving revision 1.99
diff -u -r1.98 -r1.99
--- subreader.c	7 Feb 2003 21:12:50 -0000	1.98
+++ subreader.c	21 Mar 2003 16:54:03 -0000	1.99
@@ -22,6 +22,9 @@
 #include <iconv.h>
 char *sub_cp=NULL;
 #endif
+#ifdef USE_FRIBIDI
+#include <fribidi/fribidi.h>
+#endif
 
 /* Maximal length of line of a subtitle */
 #define LINE_LEN 1000
@@ -1012,6 +1015,62 @@
 }
 #endif
 
+#ifdef USE_FRIBIDI
+#define ALLOCATE(tp,ln) ((tp *) malloc (sizeof (tp) * (ln)))
+#define max(a,b)  (((a)>(b))?(a):(b))
+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
+  char        *ip      = NULL, *op     = NULL;
+  FriBidiCharType base;
+  size_t len,orig_len;
+  int l=sub->lines;
+  int char_set_num;
+  fribidi_boolean log2vis;
+  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;
+    }
+    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;
+    }
+  }
+  if (l){
+    for (l = sub->lines; l;)
+      free (sub->text[--l]);
+    return ERR;
+  }
+  return sub;
+}
+
+#endif
+
 static void adjust_subs_time(subtitle* sub, float subtime, float fps, int block){
 	int n,m;
 	subtitle* nextsub;
@@ -1134,6 +1193,9 @@
         if(!sub) break;   // EOF
 #ifdef USE_ICONV
 	if ((sub!=ERR) && (sub_utf8 & 2)) sub=subcp_recode(sub);
+#endif
+#ifdef USE_FRIBIDI
+	if (sub!=ERR) sub=sub_fribidi(sub,sub_utf8);
 #endif
 	if ( sub == ERR )
 	 {



More information about the MPlayer-cvslog mailing list