summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile4
-rw-r--r--cfg-mplayer.h2
-rw-r--r--command.c15
-rwxr-xr-xconfigure53
-rw-r--r--libmpcodecs/vf_ass.c2
-rw-r--r--libmpcodecs/vf_vo.c2
-rw-r--r--libmpdemux/demux_ty.c3
-rw-r--r--libvo/vo_direct3d.c8
-rw-r--r--libvo/vo_gl.c9
-rw-r--r--libvo/vo_gl3.c8
-rw-r--r--libvo/vo_vdpau.c8
-rw-r--r--mplayer.c86
-rw-r--r--mplayer.h8
-rw-r--r--sub/ass_mp.c15
-rw-r--r--sub/font_load.h7
-rw-r--r--sub/font_load_ft.c13
-rw-r--r--sub/osd_font.h2
-rw-r--r--sub/osd_ft.c969
-rw-r--r--sub/osd_libass.c375
-rw-r--r--sub/sub.c985
-rw-r--r--sub/sub.h40
-rw-r--r--sub/sub_cc.c2
-rw-r--r--sub/subreader.c2
23 files changed, 1508 insertions, 1110 deletions
diff --git a/Makefile b/Makefile
index 246265c663..2417e1caf0 100644
--- a/Makefile
+++ b/Makefile
@@ -213,6 +213,10 @@ SRCS_COMMON-$(WIN32DLL) += libmpcodecs/ad_acm.c \
SRCS_COMMON-$(XANIM_CODECS) += libmpcodecs/vd_xanim.c
SRCS_COMMON-$(XMMS_PLUGINS) += libmpdemux/demux_xmms.c
SRCS_COMMON-$(XVID4) += libmpcodecs/vd_xvid4.c
+
+SRCS_COMMON-$(OLD_OSD) += sub/osd_ft.c
+SRCS_COMMON-$(LIBASS_OSD) += sub/osd_libass.c
+
SRCS_COMMON = asxparser.c \
av_log.c \
av_opts.c \
diff --git a/cfg-mplayer.h b/cfg-mplayer.h
index 3aacdd274f..ae27169c5f 100644
--- a/cfg-mplayer.h
+++ b/cfg-mplayer.h
@@ -680,14 +680,12 @@ const m_option_t common_opts[] = {
{"spualign", &spu_alignment, CONF_TYPE_INT, CONF_RANGE, -1, 2, NULL},
{"spuaa", &spu_aamode, CONF_TYPE_INT, CONF_RANGE, 0, 31, NULL},
{"spugauss", &spu_gaussvar, CONF_TYPE_FLOAT, CONF_RANGE, 0.0, 3.0, NULL},
-#ifdef CONFIG_FREETYPE
{"subfont-encoding", &subtitle_font_encoding, CONF_TYPE_STRING, 0, 0, 0, NULL},
{"subfont-text-scale", &text_font_scale_factor, CONF_TYPE_FLOAT, CONF_RANGE, 0, 100, NULL},
{"subfont-osd-scale", &osd_font_scale_factor, CONF_TYPE_FLOAT, CONF_RANGE, 0, 100, NULL},
{"subfont-blur", &subtitle_font_radius, CONF_TYPE_FLOAT, CONF_RANGE, 0, 8, NULL},
{"subfont-outline", &subtitle_font_thickness, CONF_TYPE_FLOAT, CONF_RANGE, 0, 8, NULL},
{"subfont-autoscale", &subtitle_autoscale, CONF_TYPE_INT, CONF_RANGE, 0, 3, NULL},
-#endif
OPT_START_CONDITIONAL(CONFIG_ASS, "libass"),
OPT_MAKE_FLAGS("ass", ass_enabled, 0),
OPT_FLOATRANGE("ass-font-scale", ass_font_scale, 0, 0, 100),
diff --git a/command.c b/command.c
index cfb8d0ec17..6a32148de8 100644
--- a/command.c
+++ b/command.c
@@ -43,7 +43,6 @@
#include "mp_osd.h"
#include "libvo/video_out.h"
#include "libvo/csputils.h"
-#include "sub/font_load.h"
#include "playtree.h"
#include "libao2/audio_out.h"
#include "mpcommon.h"
@@ -2062,7 +2061,6 @@ static int mp_property_sub_forced_only(m_option_t *prop, int action,
}
-#ifdef CONFIG_FREETYPE
/// Subtitle scale (RW)
static int mp_property_sub_scale(m_option_t *prop, int action, void *arg,
MPContext *mpctx)
@@ -2081,8 +2079,7 @@ static int mp_property_sub_scale(m_option_t *prop, int action, void *arg,
}
#endif
text_font_scale_factor = *(float *) arg;
- force_load_font = 1;
- vo_osd_changed(OSDTYPE_SUBTITLE);
+ vo_osd_resized();
return M_PROPERTY_OK;
case M_PROPERTY_STEP_UP:
case M_PROPERTY_STEP_DOWN:
@@ -2097,8 +2094,7 @@ static int mp_property_sub_scale(m_option_t *prop, int action, void *arg,
text_font_scale_factor += (arg ? *(float *) arg : 0.1) *
(action == M_PROPERTY_STEP_UP ? 1.0 : -1.0);
M_PROPERTY_CLAMP(prop, text_font_scale_factor);
- force_load_font = 1;
- vo_osd_changed(OSDTYPE_SUBTITLE);
+ vo_osd_resized();
return M_PROPERTY_OK;
default:
#ifdef CONFIG_ASS
@@ -2109,7 +2105,6 @@ static int mp_property_sub_scale(m_option_t *prop, int action, void *arg,
return m_property_float_ro(prop, action, arg, text_font_scale_factor);
}
}
-#endif
#ifdef CONFIG_TV
@@ -2378,10 +2373,8 @@ static const m_option_t mp_properties[] = {
M_OPT_RANGE, 0, 1, NULL },
{ "sub_forced_only", mp_property_sub_forced_only, CONF_TYPE_FLAG,
M_OPT_RANGE, 0, 1, NULL },
-#ifdef CONFIG_FREETYPE
{ "sub_scale", mp_property_sub_scale, CONF_TYPE_FLOAT,
M_OPT_RANGE, 0, 100, NULL },
-#endif
#ifdef CONFIG_ASS
{ "ass_use_margins", mp_property_ass_use_margins, CONF_TYPE_FLAG,
M_OPT_RANGE, 0, 1, NULL },
@@ -2497,9 +2490,7 @@ static struct property_osd_display {
{ "sub_delay", 0, OSD_MSG_SUB_DELAY, _("Sub delay: %s") },
{ "sub_visibility", 0, -1, _("Subtitles: %s") },
{ "sub_forced_only", 0, -1, _("Forced sub only: %s") },
-#ifdef CONFIG_FREETYPE
{ "sub_scale", 0, -1, _("Sub Scale: %s")},
-#endif
{ "ass_vsfilter_aspect_compat", 0, -1,
_("Subtitle VSFilter aspect compat: %s")},
#ifdef CONFIG_TV
@@ -2624,9 +2615,7 @@ static struct {
{ "sub_delay", MP_CMD_SUB_DELAY, 0},
{ "sub_visibility", MP_CMD_SUB_VISIBILITY, 1},
{ "sub_forced_only", MP_CMD_SUB_FORCED_ONLY, 1},
-#ifdef CONFIG_FREETYPE
{ "sub_scale", MP_CMD_SUB_SCALE, 0},
-#endif
#ifdef CONFIG_ASS
{ "ass_use_margins", MP_CMD_ASS_USE_MARGINS, 1},
#endif
diff --git a/configure b/configure
index 0d407c693d..eade144dba 100755
--- a/configure
+++ b/configure
@@ -361,6 +361,7 @@ Optional features:
--disable-pthreads disable Posix threads support [autodetect]
--disable-w32threads disable Win32 threads support [autodetect]
--disable-libass disable subtitle rendering with libass [autodetect]
+ --disable-libass-osd disable OSD rendering with libass [autodetect]
--enable-rpath enable runtime linker path for extra libs [disabled]
--disable-libpostproc disable postprocess filter (vf_pp) [autodetect]
@@ -657,6 +658,7 @@ _vstream=auto
_pthreads=auto
_w32threads=auto
_ass=auto
+_libass_osd=auto
_rpath=no
libpostproc=auto
_asmalign_pot=auto
@@ -991,6 +993,8 @@ for ac_option do
--disable-w32threads) _w32threads=no ;;
--enable-libass) _ass=yes ;;
--disable-libass) _ass=no ;;
+ --enable-libass-osd) _libass_osd=yes ;;
+ --disable-libass-osd) _libass_osd=no ;;
--enable-rpath) _rpath=yes ;;
--disable-rpath) _rpath=no ;;
--enable-libpostproc) libpostproc=yes ;;
@@ -4542,6 +4546,39 @@ else
noinputmodules="cddb $noinputmodules"
fi
+
+echocheck "SSA/ASS support"
+if test "$_ass" = auto ; then
+ if pkg_config_add libass ; then
+ _ass=yes
+ def_ass='#define CONFIG_ASS 1'
+ else
+ die "Unable to find development files for libass. Aborting. If you really mean to compile without libass support use --disable-libass."
+ fi
+else
+ def_ass='#undef CONFIG_ASS'
+fi
+echores "$_ass"
+
+
+echocheck "libass OSD support"
+_old_osd=yes
+if test "$_libass_osd" = auto ; then
+ _libass_osd=no
+ if test "$_ass" = yes ; then
+ _libass_osd=yes
+ _old_osd=no
+ _bitmap_font=no
+ # disable unneeded dependencies
+ _freetype=no
+ _fontconfig=no
+ # this should always be forced, because libass does bidi itself
+ _fribidi=no
+ fi
+fi
+echores "$_libass_osd"
+
+
echocheck "bitmap font support"
if test "$_bitmap_font" = yes ; then
def_bitmap_font="#define CONFIG_BITMAP_FONT 1"
@@ -4593,20 +4630,6 @@ fi
echores "$_fontconfig"
-echocheck "SSA/ASS support"
-if test "$_ass" = auto ; then
- if pkg_config_add libass ; then
- _ass=yes
- def_ass='#define CONFIG_ASS 1'
- else
- die "Unable to find development files for libass. Aborting. If you really mean to compile without libass support use --disable-libass."
- fi
-else
- def_ass='#undef CONFIG_ASS'
-fi
-echores "$_ass"
-
-
echocheck "fribidi with charsets"
if test "$_fribidi" = auto ; then
_fribidi=no
@@ -5724,6 +5747,8 @@ JPEG = $_jpeg
LADSPA = $_ladspa
LIBA52 = $_liba52
LIBASS = $_ass
+LIBASS_OSD = $_libass_osd
+OLD_OSD = $_old_osd
LIBBLURAY = $_bluray
LIBBS2B = $_libbs2b
LIBDCA = $_libdca
diff --git a/libmpcodecs/vf_ass.c b/libmpcodecs/vf_ass.c
index 4dcddb1d08..0d14dff446 100644
--- a/libmpcodecs/vf_ass.c
+++ b/libmpcodecs/vf_ass.c
@@ -72,8 +72,6 @@ static const struct vf_priv_s {
} *line_limits;
} vf_priv_dflt;
-extern float sub_delay;
-
static int config(struct vf_instance *vf,
int width, int height, int d_width, int d_height,
unsigned int flags, unsigned int outfmt)
diff --git a/libmpcodecs/vf_vo.c b/libmpcodecs/vf_vo.c
index a6bd165dee..e23eca4b71 100644
--- a/libmpcodecs/vf_vo.c
+++ b/libmpcodecs/vf_vo.c
@@ -33,8 +33,6 @@
#include "sub/ass_mp.h"
#include "sub/sub.h"
-extern float sub_delay;
-
struct vf_priv_s {
struct vo *vo;
#ifdef CONFIG_ASS
diff --git a/libmpdemux/demux_ty.c b/libmpdemux/demux_ty.c
index cc9bb8f902..527d350bc6 100644
--- a/libmpdemux/demux_ty.c
+++ b/libmpdemux/demux_ty.c
@@ -50,8 +50,7 @@
#include "parse_es.h"
#include "stheader.h"
#include "sub/sub_cc.h"
-
-extern int sub_justify;
+#include "sub/sub.h"
// 2/c0: audio data
// 3/c0: audio packet header (PES header)
diff --git a/libvo/vo_direct3d.c b/libvo/vo_direct3d.c
index fb2f58f5cc..872fdd376d 100644
--- a/libvo/vo_direct3d.c
+++ b/libvo/vo_direct3d.c
@@ -40,7 +40,6 @@
#include "aspect.h"
#include "w32_common.h"
#include "libavutil/common.h"
-#include "sub/font_load.h"
#include "sub/sub.h"
#include "eosd_packer.h"
@@ -893,12 +892,7 @@ static bool resize_d3d(d3d_priv *priv)
calc_fs_rect(priv);
-#ifdef CONFIG_FREETYPE
- // font needs to be adjusted
- force_load_font = 1;
-#endif
- // OSD needs to be drawn fresh for new size
- vo_osd_changed(OSDTYPE_OSD);
+ vo_osd_resized();
priv->vo->want_redraw = true;
diff --git a/libvo/vo_gl.c b/libvo/vo_gl.c
index f44404b2be..1a1336de9c 100644
--- a/libvo/vo_gl.c
+++ b/libvo/vo_gl.c
@@ -36,7 +36,6 @@
#include "libmpcodecs/mp_image.h"
#include "geometry.h"
#include "osd.h"
-#include "sub/font_load.h"
#include "sub/sub.h"
#include "eosd_packer.h"
@@ -171,13 +170,7 @@ static void resize(struct vo *vo, int x, int y)
gl->MatrixMode(GL_MODELVIEW);
gl->LoadIdentity();
- if (!p->scaled_osd) {
-#ifdef CONFIG_FREETYPE
- // adjust font size to display size
- force_load_font = 1;
-#endif
- vo_osd_changed(OSDTYPE_OSD);
- }
+ vo_osd_resized();
gl->Clear(GL_COLOR_BUFFER_BIT);
vo->want_redraw = true;
}
diff --git a/libvo/vo_gl3.c b/libvo/vo_gl3.c
index d1b0540761..6a3f427ef9 100644
--- a/libvo/vo_gl3.c
+++ b/libvo/vo_gl3.c
@@ -45,7 +45,6 @@
#include "libmpcodecs/mp_image.h"
#include "geometry.h"
#include "osd.h"
-#include "sub/font_load.h"
#include "sub/sub.h"
#include "eosd_packer.h"
@@ -1186,12 +1185,7 @@ static void resize(struct gl_priv *p)
update_window_sized_objects(p);
update_all_uniforms(p);
-#ifdef CONFIG_FREETYPE
- // adjust font size to display size
- force_load_font = 1;
-#endif
- vo_osd_changed(OSDTYPE_OSD);
-
+ vo_osd_resized();
gl->Clear(GL_COLOR_BUFFER_BIT);
vo->want_redraw = true;
}
diff --git a/libvo/vo_vdpau.c b/libvo/vo_vdpau.c
index 9343dea3e1..65c371f237 100644
--- a/libvo/vo_vdpau.c
+++ b/libvo/vo_vdpau.c
@@ -50,8 +50,6 @@
#include "libavcodec/vdpau.h"
-#include "sub/font_load.h"
-
#include "libavutil/common.h"
#include "libavutil/mathematics.h"
@@ -384,11 +382,7 @@ static void resize(struct vo *vo)
vc->src_rect_vid.y1 = vc->flip ? src_rect.top : src_rect.bottom;
vc->border_x = borders.left;
vc->border_y = borders.top;
-#ifdef CONFIG_FREETYPE
- // adjust font size to display size
- force_load_font = 1;
-#endif
- vo_osd_changed(OSDTYPE_OSD);
+ vo_osd_resized();
int flip_offset_ms = vo_fs ? vc->flip_offset_fs : vc->flip_offset_window;
vo->flip_queue_offset = flip_offset_ms / 1000.;
diff --git a/mplayer.c b/mplayer.c
index 1203c45bd9..9001c221be 100644
--- a/mplayer.c
+++ b/mplayer.c
@@ -80,12 +80,12 @@
#include "sub/subreader.h"
#include "sub/find_subfiles.h"
#include "sub/dec_sub.h"
+#include "sub/sub_cc.h"
#include "mp_osd.h"
#include "libvo/video_out.h"
#include "screenshot.h"
-#include "sub/font_load.h"
#include "sub/sub.h"
#include "sub/av_sub.h"
#include "libmpcodecs/dec_teletext.h"
@@ -319,16 +319,6 @@ int frame_dropping = 0; // option 0=no drop 1= drop vo 2= drop decode
static int play_n_frames = -1;
static int play_n_frames_mf = -1;
-// sub:
-char *font_name = NULL;
-char *sub_font_name = NULL;
-extern int font_fontconfig;
-float font_factor = 0.75;
-float sub_delay = 0;
-float sub_fps = 0;
-int subcc_enabled = 0;
-int suboverlap_enabled = 1;
-
#include "sub/ass_mp.h"
char *current_module; // for debugging
@@ -708,14 +698,6 @@ void exit_player_with_rc(struct MPContext *mpctx, enum exit_reason how, int rc)
current_module = "uninit_input";
mp_input_uninit(mpctx->input);
-#ifdef CONFIG_FREETYPE
- current_module = "uninit_font";
- if (mpctx->osd && mpctx->osd->sub_font != vo_font)
- free_font_desc(mpctx->osd->sub_font);
- free_font_desc(vo_font);
- vo_font = NULL;
- done_freetype();
-#endif
osd_free(mpctx->osd);
#ifdef CONFIG_ASS
@@ -1652,7 +1634,6 @@ static void update_osd_msg(struct MPContext *mpctx)
struct MPOpts *opts = &mpctx->opts;
mp_osd_msg_t *msg;
struct osd_state *osd = mpctx->osd;
- char osd_text_timer[128];
if (mpctx->add_osd_seek_info) {
double percentage = get_percent_pos(mpctx);
@@ -1682,6 +1663,7 @@ static void update_osd_msg(struct MPContext *mpctx)
if (mpctx->sh_video && opts->term_osd != 1) {
// fallback on the timer
+ char osd_text_timer[128] = {0};
if (opts->osd_level >= 2) {
int len = get_time_length(mpctx);
int percentage = -1;
@@ -1723,19 +1705,22 @@ static void update_osd_msg(struct MPContext *mpctx)
fractions_text[0] = 0;
}
+ osd_get_function_sym(osd_text_timer, sizeof(osd_text_timer),
+ mpctx->osd_function);
+ size_t blen = strlen(osd_text_timer);
+
if (opts->osd_level == 3)
- snprintf(osd_text_timer, sizeof(osd_text_timer),
- "%c %02d:%02d:%02d%s / %02d:%02d:%02d%s",
- mpctx->osd_function, pts / 3600, (pts / 60) % 60, pts % 60,
- fractions_text, len / 3600, (len / 60) % 60, len % 60,
+ snprintf(osd_text_timer + blen, sizeof(osd_text_timer) - blen,
+ " %02d:%02d:%02d%s / %02d:%02d:%02d%s",
+ pts / 3600, (pts / 60) % 60, pts % 60, fractions_text,
+ len / 3600, (len / 60) % 60, len % 60,
percentage_text);
else
- snprintf(osd_text_timer, sizeof(osd_text_timer),
- "%c %02d:%02d:%02d%s%s",
- mpctx->osd_function, pts / 3600, (pts / 60) % 60,
- pts % 60, fractions_text, percentage_text);
- } else
- osd_text_timer[0] = 0;
+ snprintf(osd_text_timer + blen, sizeof(osd_text_timer) - blen,
+ " %02d:%02d:%02d%s%s",
+ pts / 3600, (pts / 60) % 60, pts % 60, fractions_text,
+ percentage_text);
+ }
if (strcmp(osd->osd_text, osd_text_timer)) {
osd_set_text(osd, osd_text_timer);
@@ -4090,45 +4075,12 @@ int main(int argc, char *argv[])
//------ load global data first ------
- mpctx->osd = osd_create();
-
- // check font
-#ifdef CONFIG_FREETYPE
- init_freetype();
-#endif
-#ifdef CONFIG_FONTCONFIG
- if (font_fontconfig <= 0) {
-#endif
-#ifdef CONFIG_BITMAP_FONT
- if (font_name) {
- vo_font = read_font_desc(font_name, font_factor, verbose > 1);
- if (!vo_font)
- mp_tmsg(MSGT_CPLAYER, MSGL_ERR, "Cannot load bitmap font: %s\n",
- filename_recode(font_name));
- } else {
- // try default:
- vo_font = read_font_desc(mem_ptr = get_path("font/font.desc"),
- font_factor, verbose > 1);
- free(mem_ptr); // release the buffer created by get_path()
- if (!vo_font)
- vo_font = read_font_desc(MPLAYER_DATADIR "/font/font.desc",
- font_factor, verbose > 1);
- }
- if (sub_font_name)
- mpctx->osd->sub_font = read_font_desc(sub_font_name, font_factor,
- verbose > 1);
- else
- mpctx->osd->sub_font = vo_font;
-#endif
-#ifdef CONFIG_FONTCONFIG
-}
-#endif
-
#ifdef CONFIG_ASS
mpctx->ass_library = mp_ass_init(opts);
- mpctx->osd->ass_library = mpctx->ass_library;
#endif
+ mpctx->osd = osd_create(opts, mpctx->ass_library);
+
#ifdef HAVE_RTC
if (opts->rtc) {
char *rtc_device = opts->rtc_device;
@@ -4792,9 +4744,7 @@ goto_enable_cache:
if (mpctx->sh_video) {
if (mpctx->sh_video->output_flags & VFCAP_SPU && vo_spudec)
spudec_set_hw_spu(vo_spudec, mpctx->video_out);
-#ifdef CONFIG_FREETYPE
- force_load_font = 1;
-#endif
+ osd_font_invalidate();
} else if (!mpctx->sh_audio)
goto goto_next_file;
diff --git a/mplayer.h b/mplayer.h
index 267b6501b3..91d4d35f49 100644
--- a/mplayer.h
+++ b/mplayer.h
@@ -31,16 +31,8 @@ extern char ** video_driver_list;
extern char ** audio_driver_list;
extern float audio_delay;
-extern unsigned int osd_visible;
-
-extern char * font_name;
-extern char * sub_font_name;
-extern float font_factor;
extern double force_fps;
-extern float sub_delay;
-extern float sub_fps;
-
extern int stream_cache_size;
extern int frame_dropping;
diff --git a/sub/ass_mp.c b/sub/ass_mp.c
index 88c55862f2..3dd743776d 100644
--- a/sub/ass_mp.c
+++ b/sub/ass_mp.c
@@ -34,22 +34,11 @@
#include "path.h"
#include "ass_mp.h"
#include "subreader.h"
+#include "sub/sub.h"
#include "stream/stream.h"
#include "options.h"
-#ifdef CONFIG_FONTCONFIG
-extern int font_fontconfig;
-#else
-static int font_fontconfig = -1;
-#endif
-extern char *font_name;
-extern char *sub_font_name;
-extern float text_font_scale_factor;
-extern int subtitle_autoscale;
-
-#ifdef CONFIG_ICONV
-extern char *sub_cp;
-#else
+#ifndef CONFIG_ICONV
static char *sub_cp = 0;
#endif
diff --git a/sub/font_load.h b/sub/font_load.h
index 7efe067aaf..933f84804f 100644
--- a/sub/font_load.h
+++ b/sub/font_load.h
@@ -83,13 +83,6 @@ typedef struct font_desc {
extern font_desc_t* vo_font;
-extern char *subtitle_font_encoding;
-extern float text_font_scale_factor;
-extern float osd_font_scale_factor;
-extern float subtitle_font_radius;
-extern float subtitle_font_thickness;
-extern int subtitle_autoscale;
-
extern int vo_image_width;
extern int vo_image_height;
diff --git a/sub/font_load_ft.c b/sub/font_load_ft.c
index eb6d70b657..9eb0ab50e8 100644
--- a/sub/font_load_ft.c
+++ b/sub/font_load_ft.c
@@ -48,23 +48,14 @@
#include "mp_msg.h"
#include "mplayer.h"
#include "path.h"
+#include "sub/sub.h"
+
#include "osd_font.h"
#if (FREETYPE_MAJOR > 2) || (FREETYPE_MAJOR == 2 && FREETYPE_MINOR >= 1)
#define HAVE_FREETYPE21
#endif
-char *subtitle_font_encoding = NULL;
-float text_font_scale_factor = 3.5;
-float osd_font_scale_factor = 4.0;
-float subtitle_font_radius = 2.0;
-float subtitle_font_thickness = 2.0;
-// 0 = no autoscale
-// 1 = video height
-// 2 = video width
-// 3 = diagonal
-int subtitle_autoscale = 3;
-
int vo_image_width = 0;
int vo_image_height = 0;
int force_load_font;
diff --git a/sub/osd_font.h b/sub/osd_font.h
index 6be45bc1fa..616c27d155 100644
--- a/sub/osd_font.h
+++ b/sub/osd_font.h
@@ -19,7 +19,7 @@
#ifndef MPLAYER_OSD_FONT_H
#define MPLAYER_OSD_FONT_H
-const unsigned char osd_font_pfb[] = {
+static const unsigned char osd_font_pfb[] = {
0x80,0x01,0x02,0x17,0x00,0x00,0x25,0x21,0x50,0x53,0x2d,0x41,0x64,0x6f,0x62,0x65,
0x46,0x6f,0x6e,0x74,0x2d,0x31,0x2e,0x30,0x3a,0x20,0x4f,0x53,0x44,0x20,0x31,0x2e,
0x30,0x30,0x0a,0x25,0x25,0x43,0x72,0x65,0x61,0x74,0x69,0x6f,0x6e,0x44,0x61,0x74,
diff --git a/sub/osd_ft.c b/sub/osd_ft.c
new file mode 100644
index 0000000000..f44100a3b9
--- /dev/null
+++ b/sub/osd_ft.c
@@ -0,0 +1,969 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "config.h"
+#include "stream/stream.h"
+#include "stream/stream_dvdnav.h"
+#define OSD_NAV_BOX_ALPHA 0x7f
+
+#include "libmpcodecs/dec_teletext.h"
+#include "osdep/timer.h"
+
+#include "talloc.h"
+#include "mplayer.h"
+#include "path.h"
+#include "mp_msg.h"
+#include "libvo/video_out.h"
+#include "sub.h"
+#include "sub/font_load.h"
+#include "spudec.h"
+#include "libavutil/common.h"
+
+#define FONT_LOAD_DEFER 6
+#define NEW_SPLITTING
+
+//static int vo_font_loaded=-1;
+font_desc_t* vo_font=NULL;
+
+// Structures needed for the new splitting algorithm.
+// osd_text_t contains the single subtitle word.
+// osd_text_p is used to mark the lines of subtitles
+struct osd_text_t {
+ int osd_kerning, //kerning with the previous word
+ osd_length, //orizontal length inside the bbox
+ text_length, //number of characters
+ *text; //characters
+ struct osd_text_t *prev,
+ *next;
+};
+
+struct osd_text_p {
+ int value;
+ struct osd_text_t *ott;
+ struct osd_text_p *prev,
+ *next;
+};
+//^
+
+
+// return the real height of a char:
+static inline int get_height(int c,int h){
+ int font;
+ if ((font=vo_font->font[c])>=0)
+ if(h<vo_font->pic_a[font]->h) h=vo_font->pic_a[font]->h;
+ return h;
+}
+
+
+void vo_update_text_osd(struct osd_state *osd, mp_osd_obj_t *obj)
+{
+ const char *cp = osd->osd_text;
+ int x=20;
+ int h=0;
+ int font;
+
+ obj->bbox.x1=obj->x=x;
+ obj->bbox.y1=obj->y=10;
+
+ while (*cp){
+ uint16_t c=utf8_get_char(&cp);
+ render_one_glyph(vo_font, c);
+ x+=vo_font->width[c]+vo_font->charspace;
+ h=get_height(c,h);
+ }
+
+ obj->bbox.x2=x-vo_font->charspace;
+ obj->bbox.y2=obj->bbox.y1+h;
+ obj->flags|=OSDFLAG_BBOX;
+
+ osd_alloc_buf(obj);
+
+ cp = osd->osd_text;
+ x = obj->x;
+ while (*cp){
+ uint16_t c=utf8_get_char(&cp);
+ if ((font=vo_font->font[c])>=0)
+ draw_alpha_buf(obj,x,obj->y,
+ vo_font->width[c],
+ vo_font->pic_a[font]->h,
+ vo_font->pic_b[font]->bmp+vo_font->start[c],
+ vo_font->pic_a[font]->bmp+vo_font->start[c],
+ vo_font->pic_a[font]->w);
+ x+=vo_font->width[c]+vo_font->charspace;
+ }
+}
+
+static int vo_osd_teletext_scale=0;
+
+// renders char to a big per-object buffer where alpha and bitmap are separated
+static void tt_draw_alpha_buf(mp_osd_obj_t* obj, int x0,int y0, int w,int h, unsigned char* src, int stride,int fg,int bg,int alpha)
+{
+ int dststride = obj->stride;
+ int dstskip = obj->stride-w;
+ int srcskip = stride-w;
+ int i, j;
+ unsigned char *b = obj->bitmap_buffer + (y0-obj->bbox.y1)*dststride + (x0-obj->bbox.x1);
+ unsigned char *a = obj->alpha_buffer + (y0-obj->bbox.y1)*dststride + (x0-obj->bbox.x1);
+ unsigned char *bs = src;
+ if (x0 < obj->bbox.x1 || x0+w > obj->bbox.x2 || y0 < obj->bbox.y1 || y0+h > obj->bbox.y2) {
+ mp_msg(MSGT_OSD,MSGL_ERR,"tt osd text out of range: bbox [%d %d %d %d], txt [%d %d %d %d]\n",
+ obj->bbox.x1, obj->bbox.x2, obj->bbox.y1, obj->bbox.y2,
+ x0, x0+w, y0, y0+h);
+ return;
+ }
+ for (i = 0; i < h; i++) {
+ for (j = 0; j < w; j++, b++, a++, bs++) {
+ *b=(fg-bg)*(*bs)/255+bg;
+ *a=alpha;
+ }
+ b+= dstskip;
+ a+= dstskip;
+ bs+= srcskip;
+ }
+}
+void vo_update_text_teletext(struct osd_state *osd, mp_osd_obj_t *obj)
+{
+ int h=0,w=0,i,j,font,flashon;
+ int wm,hm;
+ int color;
+ int x,y,x0,y0;
+ int cols,rows;
+ int wm12;
+ int hm13;
+ int hm23;
+ int start_row,max_rows;
+ int b,ax[6],ay[6],aw[6],ah[6];
+ tt_char tc;
+ tt_char* tdp=vo_osd_teletext_page;
+ static const uint8_t colors[8]={1,85,150,226,70,105,179,254};
+ unsigned char* buf[9];
+ int dxs = osd->w, dys = osd->h;
+
+ obj->flags|=OSDFLAG_CHANGED|OSDFLAG_VISIBLE;
+ if (!tdp || !vo_osd_teletext_mode) {
+ obj->flags&=~OSDFLAG_VISIBLE;
+ return;
+ }
+ flashon=(GetTimer()/1000000)%2;
+ switch(vo_osd_teletext_half){
+ case TT_ZOOM_TOP_HALF:
+ start_row=0;
+ max_rows=VBI_ROWS/2;
+ break;
+ case TT_ZOOM_BOTTOM_HALF:
+ start_row=VBI_ROWS/2;
+ max_rows=VBI_ROWS/2;
+ break;
+ default:
+ start_row=0;
+ max_rows=VBI_ROWS;
+ break;
+ }
+ wm=0;
+ for(i=start_row;i<max_rows;i++){
+ for(j=0;j<VBI_COLUMNS;j++){
+ tc=tdp[i*VBI_COLUMNS+j];
+ if(!tc.ctl && !tc.gfx)
+ {
+ render_one_glyph(vo_font, tc.unicode);
+ if (wm<vo_font->width[tc.unicode])
+ wm=vo_font->width[tc.unicode];
+ }
+ }
+ }
+
+ hm=vo_font->height+1;
+ wm=dxs*hm*max_rows/(dys*VBI_COLUMNS);
+
+#ifdef CONFIG_FREETYPE
+ //very simple teletext font auto scaling
+ if(!vo_osd_teletext_scale && hm*(max_rows+1)>dys){
+ osd_font_scale_factor*=1.0*(dys)/((max_rows+1)*hm);
+ force_load_font=1;
+ vo_osd_teletext_scale=osd_font_scale_factor;
+ obj->flags&=~OSDFLAG_VISIBLE;
+ return;
+ }
+#endif
+
+ cols=dxs/wm;
+ rows=dys/hm;
+
+ if(cols>VBI_COLUMNS)
+ cols=VBI_COLUMNS;
+ if(rows>max_rows)
+ rows=max_rows;
+ w=cols*wm-vo_font->charspace;
+ h=rows*hm-vo_font->charspace;
+
+ if(w<dxs)
+ x0=(dxs-w)/2;
+ else
+ x0=0;
+ if(h<dys)
+ y0=(dys-h)/2;
+ else
+ y0=0;
+
+ wm12=wm>>1;
+ hm13=(hm+1)/3;
+ hm23=hm13<<1;
+
+ for(i=0;i<6;i+=2){
+ ax[i+0]=0;
+ aw[i+0]=wm12;
+
+ ax[i+1]=wm12;
+ aw[i+1]=wm-wm12;
+ }
+
+ for(i=0;i<2;i++){
+ ay[i+0]=0;
+ ah[i+0]=hm13;
+
+ ay[i+2]=hm13;
+ ah[i+2]=hm-hm23;
+
+ ay[i+4]=hm-hm13;
+ ah[i+4]=hm13;
+ }
+
+ obj->x = 0;
+ obj->y = 0;
+ obj->bbox.x1 = x0;
+ obj->bbox.y1 = y0;
+ obj->bbox.x2 = x0+w;
+ obj->bbox.y2 = y0+h;
+ obj->flags |= OSDFLAG_BBOX;
+ osd_alloc_buf(obj);
+
+ for(i=0;i<9;i++)
+ buf[i]=malloc(wm*hm);
+
+ //alpha
+ if(vo_osd_teletext_format==TT_FORMAT_OPAQUE ||vo_osd_teletext_format==TT_FORMAT_OPAQUE_INV)
+ color=1;
+ else
+ color=200;
+ memset(buf[8],color,wm*hm);
+ //colors
+ if(vo_osd_teletext_format==TT_FORMAT_OPAQUE ||vo_osd_teletext_format==TT_FORMAT_TRANSPARENT){
+ for(i=0;i<8;i++){
+ memset(buf[i],(unsigned char)(1.0*(255-color)*colors[i]/255),wm*hm);
+ }
+ }else{
+ for(i=0;i<8;i++)
+ memset(buf[i],(unsigned char)(1.0*(255-color)*colors[7-i]/255),wm*hm);
+ }
+
+ y=y0;
+ for(i=0;i<rows;i++){
+ x=x0;
+ for(j=0;j<cols;j++){
+ tc=tdp[(i+start_row)*VBI_COLUMNS+j];
+ if (tc.hidden) { x+=wm; continue;}
+ if(!tc.gfx || (tc.flh && !flashon)){
+ /* Rendering one text character */
+ draw_alpha_buf(obj,x,y,wm,hm,buf[tc.bg],buf[8],wm);
+ if(tc.unicode!=0x20 && tc.unicode!=0x00 && !tc.ctl &&
+ (!tc.flh || flashon) &&
+ (font=vo_font->font[tc.unicode])>=0 && y+hm<dys){
+ tt_draw_alpha_buf(obj,x,y,vo_font->width[tc.unicode],vo_font->height,
+ vo_font->pic_b[font]->bmp+vo_font->start[tc.unicode]-vo_font->charspace*vo_font->pic_a[font]->w,
+ vo_font->pic_b[font]->w,
+ buf[tc.fg][0],buf[tc.bg][0],buf[8][0]);
+ }
+ }else{
+/*
+Rendering one graphics character
+TODO: support for separated graphics symbols (where six rectangles does not touch each other)
+
+ +--+ +--+ 87654321
+ |01| |12| --------
+ |10| <= |34| <= 00100110 <= 0x26
+ |01| |56|
+ +--+ +--+
+