# HG changeset patch # User eugeni # Date 1162142995 0 # Node ID 5cbf1c33a6688aade3687e14b17e2d2735252f7c # Parent 81a92ae66d78c9740f6db92057c2cf2501e014a8 Revert r20517. diff -r 81a92ae66d78 -r 5cbf1c33a668 libass/ass.c --- a/libass/ass.c Sun Oct 29 15:26:13 2006 +0000 +++ b/libass/ass.c Sun Oct 29 17:29:55 2006 +0000 @@ -30,6 +30,10 @@ #include #include +#ifdef HAVE_ENCA +#include "subreader.h" // for guess_buffer_cp +#endif + #ifdef USE_ICONV #include #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 @@ 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 @@ 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) || diff -r 81a92ae66d78 -r 5cbf1c33a668 libass/ass_bitmap.c --- a/libass/ass_bitmap.c Sun Oct 29 15:26:13 2006 +0000 +++ b/libass/ass_bitmap.c Sun Oct 29 17:29:55 2006 +0000 @@ -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 @@ 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>8; - unsigned *m3= m2 + src2*mwidth; - - int mx; - *srcp= 128; - for(mx=r-1; mx>8; - unsigned *m3= m2 + src2*mwidth; - - int mx; - *srcp= 128; - for(mx=0; mx>8; - unsigned *m3= m2 + src2*mwidth; - - int mx; - *srcp= 128; - for(mx=0; mx>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) diff -r 81a92ae66d78 -r 5cbf1c33a668 libass/ass_render.c --- a/libass/ass_render.c Sun Oct 29 15:26:13 2006 +0000 +++ b/libass/ass_render.c Sun Oct 29 17:29:55 2006 +0000 @@ -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 @@ return ' '; } } - chr = ass_utf8_get_char(&p); + chr = utf8_get_char(&p); *str = p; return chr; } diff -r 81a92ae66d78 -r 5cbf1c33a668 libass/ass_utils.c --- a/libass/ass_utils.c Sun Oct 29 15:26:13 2006 +0000 +++ b/libass/ass_utils.c Sun Oct 29 17:29:55 2006 +0000 @@ -22,14 +22,9 @@ #include #include -#include #include #include -#ifdef HAVE_ENCA -#include -#endif - #include "mp_msg.h" #include "ass_utils.h" @@ -86,74 +81,3 @@ 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 diff -r 81a92ae66d78 -r 5cbf1c33a668 libass/ass_utils.h --- a/libass/ass_utils.h Sun Oct 29 15:26:13 2006 +0000 +++ b/libass/ass_utils.h Sun Oct 29 17:29:55 2006 +0000 @@ -25,11 +25,5 @@ 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 -