comparison sub/eosd.h @ 32460:d80bbc5868de

Move eosd.[ch] to the sub directory. Remove a duplicate include of eosd.h.
author cigaes
date Wed, 27 Oct 2010 17:03:26 +0000
parents
children
comparison
equal deleted inserted replaced
32459:1a605463f62b 32460:d80bbc5868de
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 #ifndef MPLAYER_EOSD_H
23 #define MPLAYER_EOSD_H
24
25 #include <stdint.h>
26 #include "libmpcodecs/vf.h"
27
28 enum {
29 EOSD_CHANGED_LAYOUT = 0x1,
30 EOSD_CHANGED_BITMAP = 0x2,
31 };
32
33 struct mp_eosd_settings {
34 int w, h; ///< screen dimensions, including black borders
35 int srcw, srch; ///< unscaled source dimensions
36 int mt, mb, ml, mr; ///< borders (top, bottom, left, right)
37 int unscaled; ///< EOSD objects are rendered at native resolution
38 int changed; ///< settings have changed since last update
39 };
40
41 struct mp_eosd_image {
42 struct mp_eosd_image *next; ///< Next image, or NULL
43 uint8_t *bitmap; ///< 1bpp stride*h alpha buffer
44 void *opaque; ///< Arbitrary value for the client's use
45 int w, h; ///< Bitmap width, height
46 int stride; ///< Bitmap stride
47 uint32_t color; ///< Bitmap color and transparency, RGBT
48 /// T is the complement of A (alpha=opacity).
49 int dst_x, dst_y; ///< Bitmap placement inside the video frame
50 };
51
52 struct mp_eosd_source {
53
54 /**
55 * Linked list of images element.
56 * The client is responsible for initializing and maintaining this list.
57 * It can alter it at any time in the main MPlayer thread.
58 */
59 struct mp_eosd_image *images;
60
61 /**
62 * Pointer to the next field of the last image, or to images if the list
63 * is empty.
64 * The client is not required to handle this field, but list
65 * manipulation functions (see below) use it.
66 */
67 struct mp_eosd_image **images_tail;
68
69 /**
70 * Callback to update the images. Can be NULL.
71 */
72 void (*update)(struct mp_eosd_source *, const struct mp_eosd_settings *,
73 double);
74
75 /**
76 * Callback to uninit the source. Can be NULL.
77 */
78 void (*uninit)(struct mp_eosd_source *);
79
80 /**
81 * Changed flags of the images.
82 * The client must set it to a combination of EOSD_CHANGED_* whenever
83 * the images are altered.
84 * The core EOSD system resets it.
85 */
86 int changed;
87
88 /**
89 * Z-index of the images.
90 * Images with a higher Z-index are rendered on top.
91 */
92 int z_index;
93
94 /**
95 * Initialized flag of the source.
96 * Set by the source, automatically cleared when a source is added,
97 * removed or reinitialized.
98 */
99 int initialized;
100
101 struct mp_eosd_source *priv_next;
102 };
103
104 struct mp_eosd_image_list {
105 struct mp_eosd_source *first_source;
106 struct mp_eosd_source *source;
107 struct mp_eosd_image *image;
108 int changed;
109 };
110
111 /**
112 * Initialize the EOSD subsystem.
113 *
114 * @param vf the video filter chain where the rendering will take place.
115 */
116 void eosd_init(vf_instance_t *vf);
117
118 /**
119 * Configure the resolution for EOSD rendering.
120 * Should be called by the rendering engine whenever the resolution or
121 * settings change.
122 *
123 * @param res resolution and margins of the rendering area.
124 */
125 void eosd_configure(struct mp_eosd_settings *res);
126
127 /**
128 * Renders the EOSD elements for the current frame.
129 * Should be called by the rendering engine when it is about to do or
130 * prepare the rendering.
131 *
132 * @param[in] ts presentation timestamp of the frame.
133 * @param[out] images list of images to render.
134 * The list and list elements are only valid until any
135 * client alter them.
136 * The renderer should therefore not call anything that
137 * may alter the EOSD elements.
138 */
139 void eosd_render_frame(double ts, struct mp_eosd_image_list *images);
140
141 /**
142 * Shut down the EOSD subsystem and free the associated resources.
143 */
144 void eosd_uninit(void);
145
146 /**
147 * Register a source of EOSD images.
148 */
149 void eosd_register(struct mp_eosd_source *source);
150
151 /**
152 * Test whether a source has already been registered.
153 */
154 int eosd_registered(struct mp_eosd_source *source);
155
156 /**
157 * Allocate a structure for an EOSD image.
158 */
159 struct mp_eosd_image *eosd_image_alloc(void);
160
161 /**
162 * Free a previously allocated structure.
163 */
164 void eosd_image_free(struct mp_eosd_image *image);
165
166 /**
167 * Append an image to the list of images associated to a source.
168 * This function requires that the images_tail pointer is correctly set.
169 */
170 void eosd_image_append(struct mp_eosd_source *source,
171 struct mp_eosd_image *image);
172
173 /**
174 * Remove an image from the list of images associated to a source.
175 * The image structure is freed using eosd_image_free.
176 *
177 * @param source source where the image is.
178 * @param image image to remove.
179 * @param prev pointeur to the prev field of the previous image,
180 * or to source->images if this is the first image.
181 */
182 void eosd_image_remove(struct mp_eosd_source *source,
183 struct mp_eosd_image *image,
184 struct mp_eosd_image **prev);
185
186 /**
187 * Remove all images associated to a source and free the corresponding
188 * structures.
189 * This function also resets the images_tail pointer.
190 */
191 void eosd_image_remove_all(struct mp_eosd_source *source);
192
193 /**
194 * Reset the cursor of an image list and get the first image.
195 */
196 struct mp_eosd_image *eosd_image_first(struct mp_eosd_image_list *images);
197
198 /**
199 * Get the next image in an image list.
200 * The renderer must NOT use the next field in the image structure.
201 */
202 struct mp_eosd_image *eosd_image_next(struct mp_eosd_image_list *images);
203
204 #endif /* MPLAYER_EOSD_H */