# HG changeset patch # User cigaes # Date 1282591323 0 # Node ID 47c6a74eba0f93630534acfe77936c1fe76d3a03 # Parent 6e0b5a97e00fe8481af4f5a774ec27f0d8e01a07 Forgot to svn add those two files. diff -r 6e0b5a97e00f -r 47c6a74eba0f eosd.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/eosd.c Mon Aug 23 19:22:03 2010 +0000 @@ -0,0 +1,70 @@ +/* + * Extended On Screen Display + * Copyright (C) 2010 Nicolas George + * + * This file is part of MPlayer. + * + * MPlayer is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * MPlayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with MPlayer; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "mpcommon.h" +#include "libmpcodecs/vf.h" +#include "libvo/video_out.h" +#include "libvo/sub.h" +#include "libass/ass_mp.h" +#include "eosd.h" + +static ASS_Renderer *ass_renderer; +int prev_visibility; + +void eosd_ass_init(ASS_Library *ass_library) +{ + ass_renderer = ass_renderer_init(ass_library); + if (!ass_renderer) return; + ass_configure_fonts(ass_renderer); +} + +void eosd_init(vf_instance_t *vf) +{ + vf->control(vf, VFCTRL_INIT_EOSD, NULL); +} + +void eosd_configure(mp_eosd_res_t *res, int hinting) +{ + double dar = (double) (res->w - res->ml - res->mr) / (res->h - res->mt - res->mb); + if (ass_renderer) { + ass_configure(ass_renderer, res->w, res->h, hinting); + ass_set_margins(ass_renderer, res->mt, res->mb, res->ml, res->mr); + ass_set_aspect_ratio(ass_renderer, dar, (double)res->srcw/res->srch); + } +} + +ASS_Image *eosd_render_frame(double ts, int *changed) +{ + ASS_Image *r = NULL; + if (sub_visibility && ass_renderer && ass_track && ts != MP_NOPTS_VALUE) { + r = ass_mp_render_frame(ass_renderer, ass_track, (ts+sub_delay) * 1000 + .5, changed); + if (!prev_visibility && changed) + *changed = 2; + } + prev_visibility = sub_visibility; + return r; +} + +void eosd_uninit(void) +{ + if (ass_renderer) + ass_renderer_done(ass_renderer); +} diff -r 6e0b5a97e00f -r 47c6a74eba0f eosd.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/eosd.h Mon Aug 23 19:22:03 2010 +0000 @@ -0,0 +1,33 @@ +/* + * Extended On Screen Display + * Copyright (C) 2010 Nicolas George + * + * This file is part of MPlayer. + * + * MPlayer is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * MPlayer is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with MPlayer; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef MPLAYER_EOSD_H +#define MPLAYER_EOSD_H + +void eosd_init(vf_instance_t *); + +void eosd_configure(mp_eosd_res_t *, int); +ASS_Image *eosd_render_frame(double, int *); +void eosd_uninit(void); + +void eosd_ass_init(ASS_Library *); + +#endif /* MPLAYER_EOSD_H */