Mercurial > mplayer.hg
annotate eosd.c @ 32456:728bd5c2aea7
Move spudec.[ch] to the sub directory.
author | cigaes |
---|---|
date | Wed, 27 Oct 2010 16:38:51 +0000 |
parents | fbee56276c87 |
children |
rev | line source |
---|---|
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" | |
32209 | 26 #include "ass_mp.h" |
31928 | 27 #include "eosd.h" |
28 | |
32391
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
29 static struct mp_eosd_source *sources; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
30 static struct mp_eosd_settings settings; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
31 static struct mp_eosd_image *image_pool; |
31928 | 32 |
33 void eosd_init(vf_instance_t *vf) | |
34 { | |
35 vf->control(vf, VFCTRL_INIT_EOSD, NULL); | |
36 } | |
37 | |
32391
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
38 void eosd_register(struct mp_eosd_source *src) |
31928 | 39 { |
32391
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
40 struct mp_eosd_source *p, **prev = &sources; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
41 for (p = sources; p && p->z_index < src->z_index; p = p->priv_next) |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
42 prev = &p->priv_next; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
43 src->priv_next = p; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
44 *prev = src; |
32426
fbee56276c87
Add a flag "initialized" to the mp_eosd_source structure.
cigaes
parents:
32397
diff
changeset
|
45 src->initialized = 0; |
31928 | 46 } |
47 | |
32397
b3110e526e19
EOSD: add a function to test if a source has already been registered.
cigaes
parents:
32391
diff
changeset
|
48 int eosd_registered(struct mp_eosd_source *source) |
b3110e526e19
EOSD: add a function to test if a source has already been registered.
cigaes
parents:
32391
diff
changeset
|
49 { |
b3110e526e19
EOSD: add a function to test if a source has already been registered.
cigaes
parents:
32391
diff
changeset
|
50 struct mp_eosd_source *p; |
b3110e526e19
EOSD: add a function to test if a source has already been registered.
cigaes
parents:
32391
diff
changeset
|
51 for (p = sources; p; p = p->priv_next) |
b3110e526e19
EOSD: add a function to test if a source has already been registered.
cigaes
parents:
32391
diff
changeset
|
52 if (p == source) |
b3110e526e19
EOSD: add a function to test if a source has already been registered.
cigaes
parents:
32391
diff
changeset
|
53 return 1; |
b3110e526e19
EOSD: add a function to test if a source has already been registered.
cigaes
parents:
32391
diff
changeset
|
54 return 0; |
b3110e526e19
EOSD: add a function to test if a source has already been registered.
cigaes
parents:
32391
diff
changeset
|
55 } |
b3110e526e19
EOSD: add a function to test if a source has already been registered.
cigaes
parents:
32391
diff
changeset
|
56 |
32391
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
57 void eosd_configure(struct mp_eosd_settings *res) |
31928 | 58 { |
32391
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
59 if (res->w != settings.w || |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
60 res->h != settings.h || |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
61 res->srcw != settings.srcw || |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
62 res->srch != settings.srch || |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
63 res->mt != settings.mt || |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
64 res->mt != settings.mb || |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
65 res->mt != settings.ml || |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
66 res->mt != settings.mr || |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
67 res->unscaled != settings.unscaled) { |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
68 settings = *res; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
69 settings.changed = 1; |
31928 | 70 } |
32391
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
71 } |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
72 |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
73 void eosd_render_frame(double ts, struct mp_eosd_image_list *images) |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
74 { |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
75 struct mp_eosd_source *src; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
76 int changed = 0; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
77 for (src = sources; src; src = src->priv_next) { |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
78 if (src->update) |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
79 src->update(src, &settings, ts); |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
80 changed |= src->changed; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
81 src->changed = 0; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
82 } |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
83 settings.changed = 0; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
84 images->first_source = sources; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
85 images->changed = changed; |
31928 | 86 } |
87 | |
88 void eosd_uninit(void) | |
89 { | |
32391
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
90 struct mp_eosd_source *src; |
32426
fbee56276c87
Add a flag "initialized" to the mp_eosd_source structure.
cigaes
parents:
32397
diff
changeset
|
91 for (src = sources; src; src = src->priv_next) { |
fbee56276c87
Add a flag "initialized" to the mp_eosd_source structure.
cigaes
parents:
32397
diff
changeset
|
92 // TODO: maybe only call if src->initialized is set. |
32391
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
93 if (src->uninit) |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
94 src->uninit(src); |
32426
fbee56276c87
Add a flag "initialized" to the mp_eosd_source structure.
cigaes
parents:
32397
diff
changeset
|
95 src->initialized = 0; |
fbee56276c87
Add a flag "initialized" to the mp_eosd_source structure.
cigaes
parents:
32397
diff
changeset
|
96 } |
32391
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
97 } |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
98 |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
99 struct mp_eosd_image *eosd_image_alloc(void) |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
100 { |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
101 struct mp_eosd_image *r; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
102 if (!image_pool) { |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
103 const unsigned n_alloc = 127; /* arbitrary */ |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
104 unsigned i; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
105 image_pool = calloc(n_alloc, sizeof(*image_pool)); |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
106 for (i = 0; i < n_alloc - 1; i++) |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
107 image_pool[i].next = image_pool + i + 1; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
108 image_pool[i].next = NULL; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
109 } |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
110 r = image_pool; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
111 image_pool = image_pool->next; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
112 return r; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
113 } |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
114 |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
115 void eosd_image_free(struct mp_eosd_image *image) |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
116 { |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
117 image->next = image_pool; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
118 image_pool = image; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
119 } |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
120 |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
121 void eosd_image_append(struct mp_eosd_source *source, |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
122 struct mp_eosd_image *image) |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
123 { |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
124 image->next = NULL; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
125 *source->images_tail = image; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
126 source->images_tail = &image->next; |
31928 | 127 } |
32391
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
128 |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
129 void eosd_image_remove(struct mp_eosd_source *source, |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
130 struct mp_eosd_image *image, |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
131 struct mp_eosd_image **prev) |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
132 { |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
133 *prev = image->next; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
134 if (!*prev) |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
135 source->images_tail = prev; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
136 eosd_image_free(image); |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
137 } |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
138 |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
139 void eosd_image_remove_all(struct mp_eosd_source *source) |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
140 { |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
141 struct mp_eosd_image *image; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
142 |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
143 while (source->images) { |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
144 image = source->images; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
145 source->images = source->images->next; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
146 eosd_image_free(image); |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
147 } |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
148 source->images_tail = &source->images; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
149 } |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
150 |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
151 static void next_image_in_sources(struct mp_eosd_image_list *images, |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
152 struct mp_eosd_source *src) |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
153 { |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
154 images->source = src; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
155 while (images->source && !images->source->images) |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
156 images->source = images->source->priv_next; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
157 images->image = images->source ? images->source->images : NULL; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
158 } |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
159 |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
160 struct mp_eosd_image *eosd_image_first(struct mp_eosd_image_list *images) |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
161 { |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
162 next_image_in_sources(images, images->first_source); |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
163 return images->image; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
164 } |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
165 |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
166 struct mp_eosd_image *eosd_image_next(struct mp_eosd_image_list *images) |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
167 { |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
168 images->image = images->image->next; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
169 if (!images->image) |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
170 next_image_in_sources(images, images->source->priv_next); |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
171 return images->image; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
172 } |