Mercurial > mplayer.hg
comparison DOCS/tech/libmpcodecs.txt @ 8020:6a11d77bef9a
- some explanations suggested by Michael & Rich
- note about mpi-local dmpi storage for get_image()
author | arpi |
---|---|
date | Fri, 01 Nov 2002 01:32:30 +0000 |
parents | f02197bd1409 |
children | f7106682cac8 |
comparison
equal
deleted
inserted
replaced
8019:ad8d6f993c81 | 8020:6a11d77bef9a |
---|---|
124 const char *author; // name and email/url of the author(s) | 124 const char *author; // name and email/url of the author(s) |
125 const char *comment;// comment, url to papers describing algo etc. | 125 const char *comment;// comment, url to papers describing algo etc. |
126 int (*open)(struct vf_instance_s* vf,char* args); | 126 int (*open)(struct vf_instance_s* vf,char* args); |
127 // pointer to the open() function: | 127 // pointer to the open() function: |
128 | 128 |
129 Sample: | |
130 | |
131 vf_info_t vf_info_foobar = { | |
132 "Universal Foo and Bar filter", | |
133 "foobar", | |
134 "Ms. Foo Bar", | |
135 "based on algo described at http://www.foo-bar.org", | |
136 open | |
137 }; | |
138 | |
129 The open() function: | 139 The open() function: |
130 | 140 |
131 open() is called when the filter is appended/inserted to the filter chain. | 141 open() is called when the filter is appended/inserted to the filter chain. |
132 it'll receive the handler (vf) and the optional filter parameters as | 142 it'll receive the handler (vf) and the optional filter parameters as |
133 char* string. Note, that encoders (ve_*) and vo wrapper (vf_vo.c) have | 143 char* string. Note, that encoders (ve_*) and vo wrapper (vf_vo.c) have |
167 | 177 |
168 The query_format() func. is called one or more times before the config(), | 178 The query_format() func. is called one or more times before the config(), |
169 to find out the capabilities and/or support status of a given colorspace (fmt). | 179 to find out the capabilities and/or support status of a given colorspace (fmt). |
170 For the return values, see vfcap.h! | 180 For the return values, see vfcap.h! |
171 Normally, a filter should return at least VFCAP_CSP_SUPPORTED for all supported | 181 Normally, a filter should return at least VFCAP_CSP_SUPPORTED for all supported |
172 colorspaces, and 0 for the unsupported ones. If your filter does linear | 182 colorspaces it accepts as input, and 0 for the unsupported ones. |
173 conversion, it should query the next filter, and pass its capability flags. | 183 If your filter does linear conversion, it should query the next filter, |
184 and merge in its capability flags. Note: you should always ensure that the | |
185 next filter will accept at least one of your possible output colorspaces! | |
174 | 186 |
175 Sample: | 187 Sample: |
176 | 188 |
177 static int query_format(struct vf_instance_s* vf, unsigned int fmt){ | 189 static int query_format(struct vf_instance_s* vf, unsigned int fmt){ |
178 switch(fmt){ | 190 switch(fmt){ |
183 return vf_next_query_format(vf,IMGFMT_YUY2) & (~VFCAP_CSP_SUPPORTED_BY_HW); | 195 return vf_next_query_format(vf,IMGFMT_YUY2) & (~VFCAP_CSP_SUPPORTED_BY_HW); |
184 } | 196 } |
185 return 0; | 197 return 0; |
186 } | 198 } |
187 | 199 |
200 For the more complex case, when you have an N->M colorspace mapping matrix, | |
201 see vf_scale or vf_rgb2bgr for examples. | |
202 | |
188 | 203 |
189 int (*config)(struct vf_instance_s* vf, | 204 int (*config)(struct vf_instance_s* vf, |
190 int width, int height, int d_width, int d_height, | 205 int width, int height, int d_width, int d_height, |
191 unsigned int flags, unsigned int outfmt); | 206 unsigned int flags, unsigned int outfmt); |
192 | 207 |
193 The config() is called to initialize/confugre the filter before using it. | 208 The config() is called to initialize/confugre the filter before using it. |
194 Its parameters are already well-known from libvo: | 209 Its parameters are already well-known from libvo: |
195 width, height: size of the coded image | 210 width, height: size of the coded image |
196 d_width, d_height: wanted display size (usually aspect corrected w/h) | 211 d_width, d_height: wanted display size (usually aspect corrected w/h) |
212 Filters should use width,height as input image dimension, but the | |
213 resizing filters (crop, expand, scale, rotate, etc) should update | |
214 d_width/d_height (display size) to preserve the correct aspect ratio! | |
215 Filters should not rely on d_width, d_height as input parameters, | |
216 the only exception is when a filter replaces some libvo functionality | |
217 (like -vop scale with -zoom, or OSD rendering wiht -vop expand). | |
197 flags: the "good" old flags set of libvo: | 218 flags: the "good" old flags set of libvo: |
198 0x01 - force fullscreen (-fs) | 219 0x01 - force fullscreen (-fs) |
199 0x02 - allow mode switching (-vm) | 220 0x02 - allow mode switching (-vm) |
200 0x04 - allow software scaling (-zoom) | 221 0x04 - allow software scaling (-zoom) |
201 0x08 - flipping (-flip) | 222 0x08 - flipping (-flip) |
265 it is not the number of bits actually used to keep colors! | 286 it is not the number of bits actually used to keep colors! |
266 So, it's 16 for both 15 and 16bit color depth, and is 32 for | 287 So, it's 16 for both 15 and 16bit color depth, and is 32 for |
267 32bpp (actually 24bit color depth) mode! | 288 32bpp (actually 24bit color depth) mode! |
268 It's 1 for 1bpp, 9 for YVU9, and is 12 for YV12 mode. Get it? | 289 It's 1 for 1bpp, 9 for YVU9, and is 12 for YV12 mode. Get it? |
269 For planar formats, you also have chroma_width, chroma_height and | 290 For planar formats, you also have chroma_width, chroma_height and |
270 chroma_x_shift, chroma_y_shift too. | 291 chroma_x_shift, chroma_y_shift too, they specify the chroma subsampling |
292 for yuv formats: | |
293 chroma_width = luma_width >>chroma_x_shift; | |
294 chroma_height= luma_height>>chroma_y_shift; | |
271 | 295 |
272 If you're done, call the rest of the filter chain to process your output | 296 If you're done, call the rest of the filter chain to process your output |
273 image: | 297 image: |
274 return vf_next_put_image(vf,dmpi); | 298 return vf_next_put_image(vf,dmpi); |
275 | 299 |
284 #define VFCTRL_SET_PP_LEVEL 5 /* set postprocessing level */ | 308 #define VFCTRL_SET_PP_LEVEL 5 /* set postprocessing level */ |
285 #define VFCTRL_SET_EQUALIZER 6 /* set color options (brightness,contrast etc) */ | 309 #define VFCTRL_SET_EQUALIZER 6 /* set color options (brightness,contrast etc) */ |
286 #define VFCTRL_GET_EQUALIZER 8 /* gset color options (brightness,contrast etc) */ | 310 #define VFCTRL_GET_EQUALIZER 8 /* gset color options (brightness,contrast etc) */ |
287 #define VFCTRL_DRAW_OSD 7 | 311 #define VFCTRL_DRAW_OSD 7 |
288 #define VFCTRL_CHANGE_RECTANGLE 9 /* Change the rectangle boundaries */ | 312 #define VFCTRL_CHANGE_RECTANGLE 9 /* Change the rectangle boundaries */ |
313 | |
289 | 314 |
290 void (*get_image)(struct vf_instance_s* vf, | 315 void (*get_image)(struct vf_instance_s* vf, |
291 mp_image_t *mpi); | 316 mp_image_t *mpi); |
292 | 317 |
293 This is for direct rendering support, works the same way as in libvo drivers. | 318 This is for direct rendering support, works the same way as in libvo drivers. |
295 If you implement it (vf->get_image!=NULL) then it will be called to do the | 320 If you implement it (vf->get_image!=NULL) then it will be called to do the |
296 buffer allocation. You SHOULD check the buffer restrictions (stride, type, | 321 buffer allocation. You SHOULD check the buffer restrictions (stride, type, |
297 readability etc) and if all OK, then allocate the requested buffer using | 322 readability etc) and if all OK, then allocate the requested buffer using |
298 the vf_get_image() func and copying the buffer pointers. | 323 the vf_get_image() func and copying the buffer pointers. |
299 | 324 |
325 NOTE: You HAVE TO save dmpi pointer, as you'll need it in put_image() later. | |
326 It is not guaranteed that you'll get the same mpi for put_image() as in | |
327 get_image() (think of out-of-order decoding, get_image is called in decoding | |
328 order, while put_image is called for display) so the only safe place to save | |
329 it is in the mpi struct itself: mpi->priv=(void*)dmpi; | |
330 | |
331 | |
300 void (*draw_slice)(struct vf_instance_s* vf, | 332 void (*draw_slice)(struct vf_instance_s* vf, |
301 unsigned char** src, int* stride, int w,int h, int x, int y); | 333 unsigned char** src, int* stride, int w,int h, int x, int y); |
302 | 334 |
303 It's the good old draw_slice callback, already known from libvo. | 335 It's the good old draw_slice callback, already known from libvo. |
304 If you filter can operate on partial images, you can implement this one | 336 If your filter can operate on partial images, you can implement this one |
305 to improve performance (cache utilization). | 337 to improve performance (cache utilization). |
306 | 338 |
307 Ah, and there is 2 set of capability/requirement flags (vfcap.h type) | 339 Ah, and there is two set of capability/requirement flags (vfcap.h type) |
308 in vf_instance_t, used by default query_format() implementation, and by | 340 in vf_instance_t, used by default query_format() implementation, and by |
309 the automatic colorspace/stride matching code (vf_next_config()). | 341 the automatic colorspace/stride matching code (vf_next_config()). |
310 | 342 |
311 // caps: | 343 // caps: |
312 unsigned int default_caps; // used by default query_format() | 344 unsigned int default_caps; // used by default query_format() |