Mercurial > mplayer.hg
changeset 20503:5cbf1c33a668
Revert r20517.
author | eugeni |
---|---|
date | Sun, 29 Oct 2006 17:29:55 +0000 |
parents | 81a92ae66d78 |
children | 27fb949fffa9 |
files | libass/ass.c libass/ass_bitmap.c libass/ass_render.c libass/ass_utils.c libass/ass_utils.h |
diffstat | 5 files changed, 11 insertions(+), 201 deletions(-) [+] |
line wrap: on
line diff
--- 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 <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 @@ 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) ||
--- 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<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)
--- 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; }
--- 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 <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 @@ 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
--- 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 -