]> granicus.if.org Git - libass/commitdiff
Revert r20517.
authoreugeni <eugeni@b3059339-0415-0410-9bf9-f77b7e298cf2>
Sun, 29 Oct 2006 17:29:55 +0000 (17:29 +0000)
committereugeni <eugeni@b3059339-0415-0410-9bf9-f77b7e298cf2>
Sun, 29 Oct 2006 17:29:55 +0000 (17:29 +0000)
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@20519 b3059339-0415-0410-9bf9-f77b7e298cf2

libass/ass.c
libass/ass_bitmap.c
libass/ass_render.c
libass/ass_utils.c
libass/ass_utils.h

index a4039e9f2d92d78349e2759d1f4d9dcc3c3f983a..f55675bb056c274ef356c656c1d96192fe370be9 100644 (file)
 #include <unistd.h>
 #include <inttypes.h>
 
+#ifdef HAVE_ENCA
+#include "subreader.h" // for guess_buffer_cp
+#endif
+
 #ifdef USE_ICONV
 #include <iconv.h>
 #endif
@@ -38,6 +42,7 @@
 #include "ass.h"
 #include "ass_utils.h"
 #include "ass_library.h"
+#include "libvo/sub.h" // for utf8_get_char
 
 typedef enum {PST_UNKNOWN = 0, PST_INFO, PST_STYLES, PST_EVENTS, PST_FONTS} parser_state_t;
 
@@ -805,7 +810,7 @@ static char* sub_recode(char* data, size_t size, char* codepage)
                char enca_lang[3], enca_fallback[100];
                if (sscanf(codepage, "enca:%2s:%99s", enca_lang, enca_fallback) == 2
                                || sscanf(codepage, "ENCA:%2s:%99s", enca_lang, enca_fallback) == 2) {
-                       cp_tmp = ass_guess_buffer_cp((unsigned char*)data, size, enca_lang, enca_fallback);
+                       cp_tmp = guess_buffer_cp((unsigned char*)data, size, enca_lang, enca_fallback);
                }
 #endif
                if ((icdsc = iconv_open (tocp, cp_tmp)) != (iconv_t)(-1)){
@@ -991,7 +996,7 @@ static char* validate_fname(char* name)
        q = fname = malloc(sz + 1);
        p = name;
        while (*p) {
-               code = ass_utf8_get_char(&p);
+               code = utf8_get_char(&p);
                if (code == 0)
                        break;
                if (    (code > 0x7F) ||
index e2e8e8f62a78ee952b443253ad8e63a4cfe3afcd..244bfbf3051bb074c539d4f961334220995dab11 100644 (file)
@@ -26,6 +26,7 @@
 #include FT_GLYPH_H
 
 #include "mp_msg.h"
+#include "libvo/font_load.h" // for blur()
 #include "ass_bitmap.h"
 
 struct ass_synth_priv_s {
@@ -89,122 +90,6 @@ static int generate_tables(ass_synth_priv_t* priv, double radius)
        return 0;
 }
 
-static void blur(unsigned char *buffer, unsigned short *tmp2,
-         int width, int height, int stride, int *m2, int r, int mwidth)
-{
-       int x, y;
-
-       unsigned char  *s = buffer;
-       unsigned short *t = tmp2+1;
-       for(y=0; y<height; y++) {
-               memset(t-1, 0, (width+1)*sizeof(short));
-
-               for(x=0; x<r; x++) {
-                       const int src= s[x];
-                       if(src) {
-                               register unsigned short *dstp= t + x-r;
-                               int mx;
-                               unsigned *m3= m2 + src*mwidth;
-                               for(mx=r-x; mx<mwidth; mx++) {
-                                       dstp[mx]+= m3[mx];
-                               }
-                       }
-               }
-
-               for(; x<width-r; x++) {
-                       const int src= s[x];
-                       if(src) {
-                               register unsigned short *dstp= t + x-r;
-                               int mx;
-                               unsigned *m3= m2 + src*mwidth;
-                               for(mx=0; mx<mwidth; mx++) {
-                                       dstp[mx]+= m3[mx];
-                               }
-                       }
-               }
-
-               for(; x<width; x++) {
-                       const int src= s[x];
-                       if(src) {
-                               register unsigned short *dstp= t + x-r;
-                               int mx;
-                               const int x2= r+width -x;
-                               unsigned *m3= m2 + src*mwidth;
-                               for(mx=0; mx<x2; mx++) {
-                                       dstp[mx]+= m3[mx];
-                               }
-                       }
-               }
-
-               s+= stride;
-               t+= width + 1;
-       }
-
-       t = tmp2;
-       for(x=0; x<width; x++) {
-               for(y=0; y<r; y++) {
-                       unsigned short *srcp= t + y*(width+1) + 1;
-                       int src= *srcp;
-                       if(src) {
-                               register unsigned short *dstp= srcp - 1 + width+1;
-                               const int src2= (src + 128)>>8;
-                               unsigned *m3= m2 + src2*mwidth;
-
-                               int mx;
-                               *srcp= 128;
-                               for(mx=r-1; mx<mwidth; mx++) {
-                                       *dstp += m3[mx];
-                                       dstp+= width+1;
-                               }
-                       }
-               }
-               for(; y<height-r; y++) {
-                       unsigned short *srcp= t + y*(width+1) + 1;
-                       int src= *srcp;
-                       if(src) {
-                               register unsigned short *dstp= srcp - 1 - r*(width+1);
-                               const int src2= (src + 128)>>8;
-                               unsigned *m3= m2 + src2*mwidth;
-
-                               int mx;
-                               *srcp= 128;
-                               for(mx=0; mx<mwidth; mx++) {
-                                       *dstp += m3[mx];
-                                       dstp+= width+1;
-                               }
-                       }
-               }
-               for(; y<height; y++) {
-                       unsigned short *srcp= t + y*(width+1) + 1;
-                       int src= *srcp;
-                       if(src) {
-                               const int y2=r+height-y;
-                               register unsigned short *dstp= srcp - 1 - r*(width+1);
-                               const int src2= (src + 128)>>8;
-                               unsigned *m3= m2 + src2*mwidth;
-
-                               int mx;
-                               *srcp= 128;
-                               for(mx=0; mx<y2; mx++) {
-                                       *dstp += m3[mx];
-                                       dstp+= width+1;
-                               }
-                       }
-               }
-               t++;
-       }
-
-       t = tmp2;
-       s = buffer;
-       for(y=0; y<height; y++) {
-               for(x=0; x<width; x++) {
-                       s[x]= t[x]>>8;
-               }
-               s+= stride;
-               t+= width + 1;
-       }
-}
-
 static void resize_tmp(ass_synth_priv_t* priv, int w, int h)
 {
        if (priv->tmp_w >= w && priv->tmp_h >= h)
index 589a518cc96f8edf9e7726e470ad264f72d7abb6..73d3cfba27ec3868e73963e8cd70661aca69319a 100644 (file)
@@ -38,6 +38,8 @@
 #include "ass_fontconfig.h"
 #include "ass_library.h"
 
+#include "libvo/sub.h" // for utf8_get_char
+
 #define MAX_GLYPHS 1000
 #define MAX_LINES 100
 
@@ -1077,7 +1079,7 @@ static unsigned get_next_char(char** str)
                        return ' ';
                }
        }
-       chr = ass_utf8_get_char(&p);
+       chr = utf8_get_char(&p);
        *str = p;
        return chr;
 }
index 6c3f9f0e77cc5ac9105e4937f531fcab8e235e28..0758f7dbb7f62d2c5e6af277b37f835fb8129f00 100644 (file)
 
 #include <stdlib.h>
 #include <inttypes.h>
-#include <string.h>
 #include <sys/time.h>
 #include <time.h>
 
-#ifdef HAVE_ENCA
-#include <enca.h>
-#endif
-
 #include "mp_msg.h"
 #include "ass_utils.h"
 
@@ -86,74 +81,3 @@ int strtocolor(char** q, uint32_t* res)
        return result;
 }
 
-unsigned ass_utf8_get_char(char **str)
-{
-  uint8_t *strp = (uint8_t *)*str;
-  unsigned c = *strp++;
-  unsigned mask = 0x80;
-  int len = -1;
-  while (c & mask) {
-    mask >>= 1;
-    len++;
-  }
-  if (len <= 0 || len > 4)
-    goto no_utf8;
-  c &= mask - 1;
-  while ((*strp & 0xc0) == 0x80) {
-    if (len-- <= 0)
-      goto no_utf8;
-    c = (c << 6) | (*strp++ & 0x3f);
-  }
-  if (len)
-    goto no_utf8;
-  *str = (char *)strp;
-  return c;
-
-no_utf8:
-  strp = (uint8_t *)*str;
-  c = *strp++;
-  *str = (char *)strp;
-  return c;
-}
-
-#ifdef HAVE_ENCA
-void* ass_guess_buffer_cp(unsigned char* buffer, int buflen, char *preferred_language, char *fallback)
-{
-    const char **languages;
-    size_t langcnt;
-    EncaAnalyser analyser;
-    EncaEncoding encoding;
-    char *detected_sub_cp = NULL;
-    int i;
-
-    languages = enca_get_languages(&langcnt);
-    mp_msg(MSGT_SUBREADER, MSGL_V, "ENCA supported languages: ");
-    for (i = 0; i < langcnt; i++) {
-       mp_msg(MSGT_SUBREADER, MSGL_V, "%s ", languages[i]);
-    }
-    mp_msg(MSGT_SUBREADER, MSGL_V, "\n");
-    
-    for (i = 0; i < langcnt; i++) {
-       const char *tmp;
-       
-       if (strcasecmp(languages[i], preferred_language) != 0) continue;
-       analyser = enca_analyser_alloc(languages[i]);
-       encoding = enca_analyse_const(analyser, buffer, buflen);
-       tmp = enca_charset_name(encoding.charset, ENCA_NAME_STYLE_ICONV);
-       if (tmp && encoding.charset != ENCA_CS_UNKNOWN) {
-           detected_sub_cp = strdup(tmp);
-           mp_msg(MSGT_SUBREADER, MSGL_INFO, "ENCA detected charset: %s\n", tmp);
-       }
-       enca_analyser_free(analyser);
-    }
-    
-    free(languages);
-
-    if (!detected_sub_cp) {
-       detected_sub_cp = strdup(fallback);
-       mp_msg(MSGT_SUBREADER, MSGL_INFO, "ENCA detection failed: fallback to %s\n", fallback);
-    }
-
-    return detected_sub_cp;
-}
-#endif
index d98649ef507cb7d5578608191509f81007aa9dde..c4453902bc539f39a0bf4718c2b62ce63b8683fa 100644 (file)
@@ -25,11 +25,5 @@ int mystrtoi(char** p, int base, int* res);
 int mystrtou32(char** p, int base, uint32_t* res);
 int mystrtod(char** p, double* res);
 int strtocolor(char** q, uint32_t* res);
-unsigned ass_utf8_get_char(char **str);
-
-#ifdef HAVE_ENCA
-void* ass_guess_buffer_cp(unsigned char* buffer, int buflen, char *preferred_language, char *fallback);
-#endif
-
 #endif