changeset 34342:575ad51cc996

Allow compiling libass without fribidi again.
author reimar
date Sun, 11 Dec 2011 15:13:39 +0000
parents 946ecaf41dc1
children 9c695b52687e
files configure libass/ass_shaper.c libass/ass_shaper.h
diffstat 3 files changed, 33 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/configure	Sun Dec 11 14:54:56 2011 +0000
+++ b/configure	Sun Dec 11 15:13:39 2011 +0000
@@ -5963,8 +5963,8 @@
 
 
 echocheck "SSA/ASS support"
-# libass depends on FreeType and FriBiDi
-if test "$_freetype" = no || test "$_fribidi" = no ; then
+# libass depends on FreeType
+if test "$_freetype" = no ; then
     _ass=no
     ass_internal=no
     res_comment="FreeType and FriBiDi support needed"
--- a/libass/ass_shaper.c	Sun Dec 11 14:54:56 2011 +0000
+++ b/libass/ass_shaper.c	Sun Dec 11 15:13:39 2011 +0000
@@ -18,7 +18,9 @@
 
 #include "config.h"
 
+#ifdef CONFIG_FRIBIDI
 #include <fribidi/fribidi.h>
+#endif
 
 #include "ass_shaper.h"
 #include "ass_render.h"
@@ -43,9 +45,11 @@
 
     // FriBidi log2vis
     int n_glyphs;
+#ifdef CONFIG_FRIBIDI
     FriBidiChar *event_text;
     FriBidiCharType *ctypes;
     FriBidiLevel *emblevels;
+#endif
     FriBidiStrIndex *cmap;
     FriBidiParType base_direction;
 
@@ -79,8 +83,10 @@
  */
 void ass_shaper_info(ASS_Library *lib)
 {
-    ass_msg(lib, MSGL_V, "Shaper: FriBidi "
-            FRIBIDI_VERSION " (SIMPLE)"
+    ass_msg(lib, MSGL_V, "Shaper:"
+#ifdef CONFIG_FRIBIDI
+            " FriBidi " FRIBIDI_VERSION " (SIMPLE)"
+#endif
 #ifdef CONFIG_HARFBUZZ
             " HarfBuzz-ng %s (COMPLEX)", hb_version_string()
 #endif
@@ -94,9 +100,11 @@
 static void check_allocations(ASS_Shaper *shaper, size_t new_size)
 {
     if (new_size > shaper->n_glyphs) {
+#ifdef CONFIG_FRIBIDI
         shaper->event_text = realloc(shaper->event_text, sizeof(FriBidiChar) * new_size);
         shaper->ctypes     = realloc(shaper->ctypes, sizeof(FriBidiCharType) * new_size);
         shaper->emblevels  = realloc(shaper->emblevels, sizeof(FriBidiLevel) * new_size);
+#endif
         shaper->cmap       = realloc(shaper->cmap, sizeof(FriBidiStrIndex) * new_size);
     }
 }
@@ -110,9 +118,11 @@
     ass_cache_done(shaper->metrics_cache);
     free(shaper->features);
 #endif
+#ifdef CONFIG_FRIBIDI
     free(shaper->event_text);
     free(shaper->ctypes);
     free(shaper->emblevels);
+#endif
     free(shaper->cmap);
     free(shaper);
 }
@@ -493,6 +503,7 @@
 }
 #endif
 
+#ifdef CONFIG_FRIBIDI
 /**
  * \brief Shape event text with FriBidi. Does mirroring and simple
  * Arabic shaping.
@@ -519,6 +530,7 @@
 
     free(joins);
 }
+#endif
 
 /**
  * \brief Toggle kerning for HarfBuzz shaping.
@@ -595,6 +607,9 @@
  */
 void ass_shaper_shape(ASS_Shaper *shaper, TextInfo *text_info)
 {
+#ifndef CONFIG_FRIBIDI
+    check_allocations(shaper, text_info->length);
+#else
     int i, last_break;
     FriBidiParType dir;
     GlyphInfo *glyphs = text_info->glyphs;
@@ -645,6 +660,7 @@
             glyphs[i].skip++;
         }
     }
+#endif
 }
 
 /**
@@ -655,7 +671,9 @@
 {
     ASS_Shaper *shaper = calloc(sizeof(*shaper), 1);
 
+#ifdef CONFIG_FRIBIDI
     shaper->base_direction = FRIBIDI_PAR_ON;
+#endif
     check_allocations(shaper, prealloc);
 
 #ifdef CONFIG_HARFBUZZ
@@ -697,6 +715,7 @@
     for (i = 0; i < text_info->length; i++)
         shaper->cmap[i] = i;
 
+#ifdef CONFIG_FRIBIDI
     // Create reorder map line-by-line
     for (i = 0; i < text_info->n_lines; i++) {
         LineInfo *line = text_info->lines + i;
@@ -708,6 +727,7 @@
                 shaper->emblevels + line->offset, NULL,
                 shaper->cmap + line->offset);
     }
+#endif
 
     return shaper->cmap;
 }
@@ -721,6 +741,7 @@
  */
 FriBidiParType resolve_base_direction(int enc)
 {
+#ifdef CONFIG_FRIBIDI
     switch (enc) {
         case 1:
             return FRIBIDI_PAR_ON;
@@ -730,4 +751,7 @@
         default:
             return FRIBIDI_PAR_LTR;
     }
+#else
+    return 0;
+#endif
 }
--- a/libass/ass_shaper.h	Sun Dec 11 14:54:56 2011 +0000
+++ b/libass/ass_shaper.h	Sun Dec 11 15:13:39 2011 +0000
@@ -21,7 +21,12 @@
 
 #include "config.h"
 
+#ifdef CONFIG_FRIBIDI
 #include <fribidi/fribidi.h>
+#else
+typedef int FriBidiParType;
+typedef int FriBidiStrIndex;
+#endif
 #include "ass_render.h"
 
 void ass_shaper_info(ASS_Library *lib);