Mercurial > mplayer.hg
annotate eosd.c @ 32391:b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
author | cigaes |
---|---|
date | Sun, 10 Oct 2010 09:27:11 +0000 |
parents | ef21cbba62ee |
children | b3110e526e19 |
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; |
31928 | 45 } |
46 | |
32391
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
47 void eosd_configure(struct mp_eosd_settings *res) |
31928 | 48 { |
32391
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
49 if (res->w != settings.w || |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
50 res->h != settings.h || |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
51 res->srcw != settings.srcw || |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
52 res->srch != settings.srch || |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
53 res->mt != settings.mt || |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
54 res->mt != settings.mb || |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
55 res->mt != settings.ml || |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
56 res->mt != settings.mr || |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
57 res->unscaled != settings.unscaled) { |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
58 settings = *res; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
59 settings.changed = 1; |
31928 | 60 } |
32391
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
61 } |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
62 |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
63 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
|
64 { |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
65 struct mp_eosd_source *src; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
66 int changed = 0; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
67 for (src = sources; src; src = src->priv_next) { |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
68 if (src->update) |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
69 src->update(src, &settings, ts); |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
70 changed |= src->changed; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
71 src->changed = 0; |
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 settings.changed = 0; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
74 images->first_source = sources; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
75 images->changed = changed; |
31928 | 76 } |
77 | |
78 void eosd_uninit(void) | |
79 { | |
32391
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
80 struct mp_eosd_source *src; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
81 for (src = sources; src; src = src->priv_next) |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
82 if (src->uninit) |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
83 src->uninit(src); |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
84 } |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
85 |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
86 struct mp_eosd_image *eosd_image_alloc(void) |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
87 { |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
88 struct mp_eosd_image *r; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
89 if (!image_pool) { |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
90 const unsigned n_alloc = 127; /* arbitrary */ |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
91 unsigned i; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
92 image_pool = calloc(n_alloc, sizeof(*image_pool)); |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
93 for (i = 0; i < n_alloc - 1; i++) |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
94 image_pool[i].next = image_pool + i + 1; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
95 image_pool[i].next = NULL; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
96 } |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
97 r = image_pool; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
98 image_pool = image_pool->next; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
99 return r; |
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 |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
102 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
|
103 { |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
104 image->next = image_pool; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
105 image_pool = image; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
106 } |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
107 |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
108 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
|
109 struct mp_eosd_image *image) |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
110 { |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
111 image->next = NULL; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
112 *source->images_tail = image; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
113 source->images_tail = &image->next; |
31928 | 114 } |
32391
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
115 |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
116 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
|
117 struct mp_eosd_image *image, |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
118 struct mp_eosd_image **prev) |
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 *prev = image->next; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
121 if (!*prev) |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
122 source->images_tail = prev; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
123 eosd_image_free(image); |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
124 } |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
125 |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
126 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
|
127 { |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
128 struct mp_eosd_image *image; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
129 |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
130 while (source->images) { |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
131 image = source->images; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
132 source->images = source->images->next; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
133 eosd_image_free(image); |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
134 } |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
135 source->images_tail = &source->images; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
136 } |
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 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
|
139 struct mp_eosd_source *src) |
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 images->source = src; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
142 while (images->source && !images->source->images) |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
143 images->source = images->source->priv_next; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
144 images->image = images->source ? images->source->images : NULL; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
145 } |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
146 |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
147 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
|
148 { |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
149 next_image_in_sources(images, images->first_source); |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
150 return images->image; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
151 } |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
152 |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
153 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
|
154 { |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
155 images->image = images->image->next; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
156 if (!images->image) |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
157 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
|
158 return images->image; |
b4c3659d16b1
Use a dynamic list for the sources of EOSD elements.
cigaes
parents:
32209
diff
changeset
|
159 } |