diff options
author | wm4 <wm4@mplayer2.org> | 2012-03-22 06:26:37 +0100 |
---|---|---|
committer | wm4 <wm4@mplayer2.org> | 2012-07-28 23:36:07 +0200 |
commit | 74e7a1e937c10d9f4d8ce9b0ba4edee52044a757 (patch) | |
tree | c421c5b79b36ad4e29b3141b4b5753107b77a343 /mplayer.c | |
parent | 7a06095dc3e5a3590f489aad3619dc6023a5b0f5 (diff) | |
download | mpv-74e7a1e937c10d9f4d8ce9b0ba4edee52044a757.tar.bz2 mpv-74e7a1e937c10d9f4d8ce9b0ba4edee52044a757.tar.xz |
osd: use libass for OSD rendering
The OSD will now be rendered with libass. The old rendering code, which
used freetype/fontconfig and did text layout manually, is disabled. To
re-enable the old code, use the --disable-libass-osd configure switch.
Some switches do nothing with the new code enabled, such as -subalign,
-sub-bg-alpha, -sub-bg-color, and many more. (The reason is mostly that
the code for rendering unstyled subtitles with libass doesn't make any
attempts to support them. Some of them could be supported in theory.)
Teletext rendering is not implemented in the new OSD rendering code. I
don't have any teletext sources for testing, and since teletext is
being phased out world-wide, the need for this is questionable.
Note that rendering is extremely inefficient, mostly because the libass
output is blended with the extremely strange mplayer OSD format. This
could be improved at a later point.
Remove most OSD rendering from vo_aa.c, because that was extremely
hacky, can't be made work with osd_libass, and didn't work anyway in
my tests.
Internally, some cleanup is done. Subtitle and OSD related variable
declarations were literally all over the place. Move them to sub.h and
sub.c, which were hoarding most of these declarations already. Make the
player core in mplayer.c free of concerns like bitmap font loading.
The old OSD rendering code has been moved to osd_ft.c. The font_load.c
and font_load_ft.c are only needed and compiled if the old OSD
rendering code is configured.
Diffstat (limited to 'mplayer.c')
-rw-r--r-- | mplayer.c | 86 |
1 files changed, 18 insertions, 68 deletions
@@ -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; |