summaryrefslogtreecommitdiffstats
path: root/libass
diff options
context:
space:
mode:
authoreugeni <eugeni@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-10-29 17:29:55 +0000
committereugeni <eugeni@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-10-29 17:29:55 +0000
commitef5dee5d5680e0d59d140e76103c1805aed4fbc6 (patch)
treeeaab9476e1157562b141594ea6423644da49ff0b /libass
parent978061ad2749f3af2186edfe48efb8c518fc4e4f (diff)
downloadmpv-ef5dee5d5680e0d59d140e76103c1805aed4fbc6.tar.bz2
mpv-ef5dee5d5680e0d59d140e76103c1805aed4fbc6.tar.xz
Revert r20517.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@20519 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libass')
-rw-r--r--libass/ass.c9
-rw-r--r--libass/ass_bitmap.c117
-rw-r--r--libass/ass_render.c4
-rw-r--r--libass/ass_utils.c76
-rw-r--r--libass/ass_utils.h6
5 files changed, 11 insertions, 201 deletions
diff --git a/libass/ass.c b/libass/ass.c
index a4039e9f2d..f55675bb05 100644
--- a/libass/ass.c
+++ b/libass/ass.c
@@ -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 @@ 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) ||
diff --git a/libass/ass_bitmap.c b/libass/ass_bitmap.c
index e2e8e8f62a..244bfbf305 100644
--- a/libass/ass_bitmap.c
+++ b/libass/ass_bitmap.c
@@ -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)
diff --git a/libass/ass_render.c b/libass/ass_render.c
index 589a518cc9..73d3cfba27 100644
--- a/libass/ass_render.c
+++ b/libass/ass_render.c
@@ -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;
}
diff --git a/libass/ass_utils.c b/libass/ass_utils.c
index 6c3f9f0e77..0758f7dbb7 100644
--- a/libass/ass_utils.c
+++ b/libass/ass_utils.c
@@ -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 @@ 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
diff --git a/libass/ass_utils.h b/libass/ass_utils.h
index d98649ef50..c4453902bc 100644
--- a/libass/ass_utils.h
+++ b/libass/ass_utils.h
@@ -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