31928
|
1 /*
|
|
2 * Extended On Screen Display
|
|
3 * Copyright (C) 2010 Nicolas George
|
|
4 *
|
|
5 * This file is part of MPlayer.
|
|
6 *
|
|
7 * MPlayer is free software; you can redistribute it and/or modify
|
|
8 * it under the terms of the GNU General Public License as published by
|
|
9 * the Free Software Foundation; either version 2 of the License, or
|
|
10 * (at your option) any later version.
|
|
11 *
|
|
12 * MPlayer is distributed in the hope that it will be useful,
|
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15 * GNU General Public License for more details.
|
|
16 *
|
|
17 * You should have received a copy of the GNU General Public License along
|
|
18 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
|
|
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
20 */
|
|
21
|
|
22 #include "mpcommon.h"
|
|
23 #include "libmpcodecs/vf.h"
|
|
24 #include "libvo/video_out.h"
|
|
25 #include "libvo/sub.h"
|
|
26 #include "libass/ass_mp.h"
|
|
27 #include "eosd.h"
|
|
28
|
31934
|
29 #ifdef CONFIG_ASS
|
31928
|
30 static ASS_Renderer *ass_renderer;
|
|
31 int prev_visibility;
|
|
32
|
|
33 void eosd_ass_init(ASS_Library *ass_library)
|
|
34 {
|
|
35 ass_renderer = ass_renderer_init(ass_library);
|
31936
|
36 if (!ass_renderer)
|
|
37 return;
|
31928
|
38 ass_configure_fonts(ass_renderer);
|
|
39 }
|
31934
|
40 #endif
|
31928
|
41
|
|
42 void eosd_init(vf_instance_t *vf)
|
|
43 {
|
|
44 vf->control(vf, VFCTRL_INIT_EOSD, NULL);
|
|
45 }
|
|
46
|
|
47 void eosd_configure(mp_eosd_res_t *res, int hinting)
|
|
48 {
|
31934
|
49 #ifdef CONFIG_ASS
|
31928
|
50 double dar = (double) (res->w - res->ml - res->mr) / (res->h - res->mt - res->mb);
|
|
51 if (ass_renderer) {
|
|
52 ass_configure(ass_renderer, res->w, res->h, hinting);
|
|
53 ass_set_margins(ass_renderer, res->mt, res->mb, res->ml, res->mr);
|
|
54 ass_set_aspect_ratio(ass_renderer, dar, (double)res->srcw/res->srch);
|
|
55 }
|
31934
|
56 #endif
|
31928
|
57 }
|
|
58
|
|
59 ASS_Image *eosd_render_frame(double ts, int *changed)
|
|
60 {
|
|
61 ASS_Image *r = NULL;
|
31934
|
62 #ifdef CONFIG_ASS
|
31928
|
63 if (sub_visibility && ass_renderer && ass_track && ts != MP_NOPTS_VALUE) {
|
|
64 r = ass_mp_render_frame(ass_renderer, ass_track, (ts+sub_delay) * 1000 + .5, changed);
|
|
65 if (!prev_visibility && changed)
|
|
66 *changed = 2;
|
|
67 }
|
|
68 prev_visibility = sub_visibility;
|
31934
|
69 #endif
|
31928
|
70 return r;
|
|
71 }
|
|
72
|
|
73 void eosd_uninit(void)
|
|
74 {
|
31934
|
75 #ifdef CONFIG_ASS
|
31928
|
76 if (ass_renderer)
|
|
77 ass_renderer_done(ass_renderer);
|
31934
|
78 #endif
|
31928
|
79 }
|