4091
|
1 //First Announce by Ivan Kalvachev
|
|
2 //Some explanations by Arpi & Pontscho
|
3342
|
3
|
4091
|
4 If you have any suggestion related to the subjects in this document you
|
3491
|
5 could send them to mplayer developer or advanced users mail lists. If you are
|
|
6 developer and have CVS access do not delete parts of this document, but you
|
|
7 could feel free to add paragraphs that you will sign with your name.
|
4091
|
8 Be warned that the text could be changed, modified and your name could be
|
|
9 moved at the top of the document.
|
3491
|
10
|
3342
|
11 1.libvo2 drivers
|
|
12 1.1 functions
|
|
13 Currently these functions are implemented:
|
|
14 init
|
|
15 control
|
|
16 start
|
|
17 stop
|
|
18 get_surface
|
4091
|
19 update_surface - renamed draw
|
|
20 show_surface - renamed flip_page
|
3342
|
21 query
|
|
22 hw_decode
|
|
23 subpicture
|
|
24
|
4091
|
25 Here is detailed description of the functions:
|
|
26 init - initialisation. It is called once on mplayer start
|
|
27 control - this function is message oriented interface for controlling the libvo2 driver
|
|
28 start - sets given mode and display it on the screen
|
|
29 stop - closes libvo2 driver, after stop we may call start again
|
3342
|
30 query - the negotiation is more complex than just finding which imgfmt the
|
4091
|
31 device could show, we must have list of capabilities, etc.
|
3491
|
32 This function will have at least 3 modes:
|
4091
|
33 a) return list with description of available modes.
|
|
34 b) check could we use this mode with these parameters. E.g. if we want
|
3342
|
35 RGB32 with 3 surfaces for windows image 800x600 we may get out of video
|
|
36 memory. We don't want error because this mode could be used with 2
|
|
37 surfaces.
|
|
38 c) return supported subpicture formats if any.
|
4091
|
39 +d) supported functionality by hw_decode
|
3342
|
40
|
|
41 As you may see I have removed some functionality from control() and made
|
|
42 separate function. Why? It is generally good thing functions that are
|
|
43 critical to the driver to have it's own implementation.
|
4091
|
44 get_surface - this function give us surfaces where we could write. In most
|
|
45 cases this is video memory, but it is possible to be and computer RAM, with
|
|
46 some special meaning (AGP memory , X shared memory, GL texture ...).
|
3342
|
47
|
|
48 update_surface - as in the note above, this is draw function. Why I change
|
|
49 it's name? I have 2 reasons, first I don't want implementation like vo1,
|
|
50 second it really must update video surface, it must directly call the
|
|
51 system function that will do it. This function should work only with
|
3491
|
52 slices, the size of slice should not be limited and should be passed
|
|
53 (e.g ystart, yend), if we want draw function, we will call one form libvo2
|
4091
|
54 core, that will call this one with ystart=0; yend=Ymax;. Also some system
|
3342
|
55 screen update functions wait for vertical retrace before return, other
|
|
56 functions just can't handle partial updates. In this case we should inform
|
|
57 libvo2 core that device cannot slice, and libvo2 core must take care of
|
4091
|
58 the additional buffering and update_surface becomes usual draw function.
|
|
59 When update_surface() is used with combination on get_surface(), ONLY VALID
|
|
60 POINTERS ARE THESE RETURNED BY get_surface(). Watch out with cropping.
|
3342
|
61
|
4091
|
62 show_surface - this functions is always called on frame change. it is used
|
|
63 to show the given surface on the screen.
|
3491
|
64 If there is only one surface then it is always visible and this function
|
|
65 does nothing.
|
4091
|
66
|
3491
|
67 hw_decode - to make all dvb,dxr3, TV etc. developers happy. This function
|
3342
|
68 is for you. Be careful, don't OBSEBE it, think and for the future, this
|
|
69 function should have and ability to control HW IDCT, MC that one day will
|
|
70 be supported and under linux. Be careful:)
|
|
71
|
|
72 subpicture - this function will place subtitles. It must be called once to
|
|
73 place them and once to remove them, it should not be called on every
|
|
74 frame, the driver will take care of this. Currently I propose this
|
|
75 implementation: we get array of bitmaps. Each one have its own starting
|
|
76 x, y and it's own height and width, each one (or all together) could be
|
|
77 in specific imgfmt (spfmt). THE BITMAPS SHOULD NOT OVERLAP! This may not
|
|
78 be hw limitation but sw subtitles may get confused if they work as 'c'
|
4091
|
79 filter (look my libvo2 core). Anyway, so far I don't know hardware that
|
|
80 have such limitations, but it is safer to be so (and faster I think).
|
|
81 It is generally good to merge small bitmaps (like characters) in larger
|
|
82 ones and make all subtitles as one bitmap( or one bitmap for one subtitle line).
|
|
83 There will be and one for each OSD time & seek/brightness/contrast/volume bar.
|
3342
|
84
|
|
85 1.2 control()
|
|
86 OK, here is list of some control()s that I think that could be useful:
|
|
87 SET_ASPECT
|
|
88 SET_SCALLE_X, SET_SIZE_X
|
|
89 SET_SCALLE_Y, SET_SIZE_Y
|
|
90 RESET_SIZE
|
|
91 GET/SET_POSITION_X
|
|
92 GET/SET_POSTIION_Y
|
|
93 GET/SET_RESOLUTION
|
|
94 GET/SET_DISPLAY
|
|
95 GET/SET_ATTRIBUTES
|
4091
|
96 + GET/SET_WIN_DECORATION
|
3342
|
97
|
|
98 Here is description of how these controls to be used:
|
|
99
|
|
100 SET_ASPECT - this is the move/video aspect, why not calculate it in
|
|
101 different place (mplayer.c) and pass the results to driver by
|
|
102 set_size_x/y. First this is only if hardware could scale. Second we may
|
3491
|
103 need this value if we have TV and we won't calculate any new height and
|
|
104 width.
|
3342
|
105
|
|
106 SET_SCALLE_X/Y - this is to enlarge/downscale the image, it WILL NOT
|
|
107 override SET_ASPECT, they will have cumulative effect, this could be used
|
|
108 for deinterlacing (HALF SIZE). Second if we want to zoom 200% we don't
|
|
109 want to lose aspect calculations. Or better SET_SCALLE to work with
|
|
110 current size?
|
|
111
|
|
112 SET_SIZE_X/Y - This is for custom enlarge, to save some scale calculation
|
|
113 and for more precise results.
|
|
114
|
3491
|
115 RESET_SIZE - Set the original size of image, we must call SET_ASPECT again.
|
3342
|
116
|
|
117 GET/SET_POSOTION_X/Y - This if for windows only, to allow custom move on
|
|
118 window.
|
|
119
|
|
120 GET/SET_RESOLUTION - change resolution and/or bpp if possible. To be used
|
3491
|
121 for changing desktop resolution or the resolution of the current
|
3342
|
122 fullscreen mode (NOT TO SET IT just to change it if we don't like it)
|
|
123
|
|
124 GET/SET_DISPLAY - mainly for X11 and remote displays. Not very useful, but
|
|
125 may be handy.
|
|
126
|
|
127 GET/SET_ATTRIBUTES - Xv overlays have contrast, brightness, hue,
|
|
128 saturation etc. these and others could be controlled by this. If we want
|
|
129 to query it we must call GET_*, and the to check does our attribute is in
|
|
130 there (xv developers be careful, 2 or 3 of default attributes sometimes
|
|
131 are not queried by X, but could be set).
|
|
132
|
3491
|
133 Do you think that TV encoding (NTSC,PAL,SECAM) should have it's own attribute?
|
3342
|
134 I would like to hear the GUI developers. Could we separate Mouse/Keyboard
|
|
135 from the driver. What info do you need to do it. Don't forget that SDL have
|
|
136 it's own keyboard/mouse interface. Maybe we should allow video driver to
|
|
137 change the libin driver ?
|
|
138
|
3491
|
139 <SOP>
|
|
140 Arpi wrote:
|
|
141 I've asked Pontscho (he doesn't understand english well...).
|
|
142 There is 2 option of GUI<->mplayer interface.
|
|
143
|
|
144 The current, ugly (IMHO) way:
|
|
145 gui have the control of the video window, it does handle resizing, moving,
|
|
146 key events etc. all window manipulation in libvo drivers are disabled as gui
|
|
147 is enabled. it was required as libvo isn't inited and running when gui
|
|
148 already display the video window.
|
|
149
|
|
150 The wanted way:
|
|
151 GUI shouldn't control the X window directly, it should use libvo2 control
|
|
152 calls to resize/move/etc it. But there is a big problem: X cannot be opened
|
|
153 twice from a process. It means GUI and libvo2 should share the X connection.
|
|
154 And, as GUI run first (and when file is selected etc then libvo2 is started)
|
|
155 it should connect to X and later pass the connection to libvo2. It needs an
|
|
156 extra control() call and some extra code in mplayer.c
|
|
157
|
|
158 but this way gui could work with non-X stuff, like SDL, fbdev (on second
|
|
159 head for TVout etc), hardware decoders (dvb.dxr3) etc.
|
|
160
|
|
161 as X is so special, libvo2 should have a core function to open/get an X
|
|
162 connection, and it should be used by all X-based X drivers and gui.
|
|
163
|
|
164 also, GUI needs functions to get mouse and keyboard events, and to
|
|
165 enable/disable window decoration (title, border).
|
|
166
|
|
167 we need fullscreen switch control function too.
|
|
168
|
|
169 > Maybe we should allow video driver to change the libin driver ?
|
|
170 forget libin. most input stuff is handled by libvo drivers.
|
|
171 think of all X stuff (x11,xv,dga,xmga,gl), SDL, aalib, svgalib.
|
|
172 only a few transparent drivers (fbdev, mga, tdfxfb, vesa) has not, but all
|
|
173 of them are running on console (and maybe on second head) at fullscreen, so
|
|
174 they may not need mouse events. console keyboard events are already catched
|
|
175 and handled by getch2.
|
|
176
|
|
177 I can't see any sense of writing libin.
|
|
178
|
|
179 mpalyer.c should _handle_ all input events, collected from lirc interface,
|
|
180 getch2, libvo2 etc. and it should set update flags, for gui and osd.
|
|
181
|
|
182 but we should share some plugin code. examples: *_vid code, all common X
|
|
183 code. it can be either implementing them in libvo2 core (and called from
|
|
184 plugins) or include these files from all drivers which need it. later method
|
|
185 is a bit cleaner (from viewpoint of core-plugin independency) but results
|
|
186 bigger binaries...
|
|
187 <EOP, Arpi>
|
|
188
|
|
189 Btw. when we finish we will have libin, but it will be spread around mplayer.
|
4091
|
190 I agree that libin could be build in in libvo2 driver, but there have to be
|
|
191 standart way to send commands to the mplayer itself.
|
|
192
|
3491
|
193
|
3342
|
194 1.3. query()
|
|
195
|
|
196 Here come and some attributes for the queried modes, each supported mode
|
|
197 should have such description. It is even possible to have more than one mode
|
4091
|
198 that could display given imgfmt. I think that we have to separate window from fullscreen
|
|
199 modes and to have yv12 mode for window and yv12 fullscreen mode. We need and naming
|
|
200 scheme, in order to have *.conf control over modes - to disable buggy modes, to limit
|
|
201 surfaces (buggy ones), to manually disable slices etc. The naming should not change from
|
|
202 one computer to another and have to be flexible.
|
3491
|
203 {
|
4091
|
204 IMGFMT - image format (RGB,YV12, etc...)
|
|
205
|
|
206 Height - the height of fullscreen mode or the maximum height of window mode
|
|
207
|
|
208 Width - the width of fullscreen mode or the maximum withd of window mode
|
|
209
|
|
210 }
|
|
211 {
|
|
212 Scale y/n - hardware scale, do you think that we must have one for x and
|
3342
|
213 one for y (win does)?
|
|
214
|
|
215 Fullscreen y/n - if the supported mode is fullscreen, if we have yv12 for
|
3491
|
216 fullscreen and window we must threat them as separate modes.
|
|
217
|
|
218 Window y/n - The mode will show the image in a window. Could be removed as
|
|
219 it is mutually exclusive with Fullscreen
|
3342
|
220
|
|
221 GetSurface y/n - if driver could give us video surface we'll use get_surface()
|
|
222
|
|
223 UpdateSurfece y/n - if driver will update video surface through sys function (X,SDL)
|
|
224
|
|
225 HWdecode y/n - if driver could take advantage of hw_decode()
|
|
226
|
|
227 MaxSurfaces 1..n - Theoretical maximum of surfaces
|
|
228
|
|
229 SubPicture y/n - Could we put subpicture (OSD) of any kind by hw
|
|
230
|
|
231 WriteCombine y/n - if GetSurface==yes, most (or all) pci&agp cards are
|
|
232 extremely slow on byte access, this is hint to vo2 core those surfaces
|
4091
|
233 that got affected by WC. Some surfaces are in memory (X shm, OpenGL textures)
|
|
234 This is only a hint.
|
3342
|
235
|
|
236 us_clip y/n - if UpdateSurface=yes, this shows could update_surface()
|
|
237 remove strides (when stride> width ), this is used and for cropping. If
|
|
238 not, we must do it.
|
|
239
|
3491
|
240 us_slice y/n - if UpdateSurface=yes, this shows that update_surface()
|
|
241 could draw slices and that after updating surface,it won't wait for
|
|
242 vertical retrace, so we could update surface slice by slice.
|
|
243 If us_slice==n we will have to accumulate all slices in some buffer.
|
3342
|
244
|
|
245 us_upsidedown - if UpdateSufrace=yes, this shows that update_suface()
|
4091
|
246 could flip the image vertically. In some case this could be combined with
|
3491
|
247 us_clip /stride tricks/
|
3342
|
248
|
|
249 switch_resoliton y/n - if window=y, this shows could we switch resolution
|
3491
|
250 of desktop, if fullscreen==y, shows that we could change resolution, after
|
3342
|
251 we have set the fullscreen mode.
|
|
252
|
|
253 deinterlace y/n - indicates that the device could deinterlace on it's own
|
4091
|
254 (radeon, TV out).
|
|
255 }
|
3342
|
256 1.4 conclusion
|
|
257
|
|
258 As you see, I have removed all additional buffering from the driver. There
|
3491
|
259 is a lot of functionality that should be checked and handled by libvo2 core.
|
4091
|
260 If some of the functionality is not supported the libvo2 core should add filters
|
|
261 that will support it by software.
|
3342
|
262
|
4091
|
263 Some of the parameters should be able to
|
|
264 be overridden by user config, mainly
|
|
265 to disable buggy modes or parameters. I
|
|
266 believe that this should not be done
|
|
267 by command line as there are enough
|
|
268 commands now.
|
|
269
|
|
270 I wait comments and ideas.
|
3491
|
271 //--------------------------------------------------------------------------
|
3342
|
272 2. libvo2 core
|
|
273 2.1 functions
|
|
274 now these function are implemented:
|
|
275 init
|
|
276 new
|
|
277 start
|
|
278 query_format
|
|
279 close
|
|
280
|
|
281 and as draw.c:
|
|
282 choose_buffering
|
|
283 draw_slice_start
|
|
284 draw_slice
|
|
285 draw_frame
|
|
286 flip
|
|
287
|
|
288 init() is called at mplayer start. internal initialisation.
|
|
289 new() -> rename to open_drv() or something like this.
|
|
290 query_format -> not usable in this form, this function mean that all
|
|
291 negotiation will be performed outside libvo2. Replace or find better name.
|
|
292 close -> open/close :)
|
|
293
|
|
294 choose_buffering - all buffering must stay hidden. The only exception is for
|
|
295 hw_decode. In the new implementation this functions is not usable.
|
3491
|
296 It will be replaced with some kind of negotiation.
|
4091
|
297 draw_slice_start, draw_slice -> if you like it this way, then it's OK. But i think that
|
|
298 draw_slice_done could help.
|
|
299
|
3342
|
300 draw_frame -> classic draw function.
|
|
301
|
|
302 2.2 Minimal buffering
|
|
303
|
|
304 I should say that I stand after the idea all buffering, postprocessing,
|
|
305 format conversion , sw draw of subtitles, etc to be done in libvo2 core.
|
|
306 Why? First this is the only way we could fully control buffering and
|
|
307 decrease it to minimum. Less buffers means less coping. In some cases this
|
3491
|
308 could have the opposite effect (look at direct rendering).
|
3342
|
309
|
|
310 The first step of the analyse is to find out what we need:
|
|
311
|
3491
|
312 DECODER - num_out_buffers={1/2/3/...}
|
|
313 {
|
|
314 buffer_type:{fixed/static/movable}
|
|
315 read_only:{yes/no}
|
|
316 } * (num_out_buffers)
|
3342
|
317 slice:{not/supported}
|
|
318
|
|
319 FILTER 1..x - processing:{ c-copy(buff1,buff2), p-process(buff1) },
|
|
320 slice:{not/supported}
|
|
321 write_combine:{not/safe},
|
|
322 runtime_remove:{static/dynamic}
|
|
323
|
4091
|
324 VIDEO_OUT - method:{get_surface,update_surface},
|
3342
|
325 slice:{not/supported},
|
|
326 write_combine:{not/safe},
|
|
327 clip:{can/not},
|
|
328 upsidedown:(can/not),
|
|
329 surfaces:{1/2/3,..,n}
|
|
330
|
|
331
|
4091
|
332
|
|
333 I use one letter code for the type of filters. You could find them in filters section.
|
3342
|
334 Details:
|
|
335
|
|
336 DECODER - We always get buffer from the decoder, some decoders could give
|
|
337 pointer to it's internal buffers, other takes pointers to buffers where
|
|
338 they should store the final image. Some decoders could call draw_slice
|
|
339 after they have finished with some portion of the image.
|
|
340
|
3491
|
341 num_out_buffers - number of output buffers. Each one could have it's own
|
|
342 parameters. In the usual case there will be only one buffer. Some
|
|
343 decoders may have 2 internal buffers like odivx, or like mpeg12 - 3 buffers
|
|
344 of different types(2 static and 1 temp).
|
|
345
|
|
346 buffer_type -
|
|
347 - fixed - we don't have control where the buffer will be. We could
|
|
348 just take pointer to this buffer. No direct rendering is possible.
|
|
349 - static - we could set this buffer but then we can't change it's position.
|
|
350 - movable - we could set this buffer to any location at any time.
|
|
351 read_only - the data in this buffer will be used in future so we must not
|
|
352 try to write in there or we'll corrupt the video. If we have any 'p' kind
|
|
353 of filter we'll make copy.
|
3342
|
354
|
|
355 slice - this flag shows that decoder knows and want to work with slices.
|
|
356
|
|
357 FILTER - postprocessing, sw drawing subtitles, format conversion, crop,
|
3491
|
358 external filters.
|
3342
|
359
|
|
360 slice - could this filter work with slice order. We could use slice even
|
|
361 when decoder does not support slice, we just need 2 or more filters that
|
|
362 does. This could give us remarkable speed boost.
|
|
363
|
|
364 processing - some filters can copy the image from one buffer to the other,
|
|
365 I call them 'c', convert and crop(stride copy) are good examples but don't
|
|
366 forget simple 1:1 copy. Other filters does process only part if the image,
|
3491
|
367 and could reuse the given buffer, e.g. putting subtitles. I call them 'p'
|
|
368 Other filters could work in one buffer, but could work and with 2, I call
|
|
369 them 't' class, after analyse they will fade to 'c' or 'p'.
|
3342
|
370
|
|
371 runtime_remove - postprocess with autoq. Subtitles appear and disappear,
|
|
372 should we copy image from one buffer to another if there is no processing
|
|
373 at all?
|
|
374
|
|
375 //clip, crop, upsidedown - all 'c' filters must support strides, and should
|
|
376 be able to remove them and to make some tricks like crop and upside_down.
|
|
377
|
|
378 VIDEO_OUT - take a look of libvo2 driver I propose.
|
|
379 method - If we get surface -'S'. If we use draw* (update_surface) - 'd'
|
|
380
|
3491
|
381 As you may see hw_decode don't have complicated buffering:)
|
4091
|
382
|
3342
|
383 I make the analyse this way. First I put decoder buffer, then I put all
|
4091
|
384 filters, that may be needed, and finally I put video out method. Then I add
|
|
385 temp buffers where needed. This is simple enough to be made on runtime.
|
|
386
|
|
387 2.5 Various
|
|
388 2.5.1 clip&crop - we have x1,y1 that shows how much of the beginning and
|
|
389 x2,y2 how much of the end we should remove.
|
|
390 plane+=(x1*sizeof(pixel))+(y1*stride);//let plane point to 1'st visible pixel
|
|
391 height-=y1+y2;
|
|
392 width-=x1+x2;
|
|
393 isn't is simple? no copy just change few variables. In order to make normal
|
|
394 plane we just need to copy it to frame where stide=width;
|
|
395
|
|
396 2.5.2 flip,upsidedown - in windows this is indicated by negative height, here
|
|
397 in mplayer we may use negative stride, so we must make sure that filters and
|
|
398 drivers could use negative stride
|
|
399 plane+=(width-1)*stride;//point to the last line
|
|
400 stride=-stride;//make stride point to previus line
|
|
401 and this one is very simple, and I hope that could work with all know image formats
|
|
402
|
|
403 BE careful, some modes may pack 2 pixels in 1 byte!
|
|
404 Other modes (YUYV) require y1 to be multiply of 2.
|
|
405
|
|
406 stride is always in bytes, while width & height are in pixels
|
|
407
|
|
408 2.5.3 PostProcessing
|
|
409 Arpi was afraid that postprocessing needs more internal data to work. I think
|
|
410 that the quantization table should be passed as additional plane.
|
|
411 How to be done this? When using Frame structure there is qbase that should point
|
|
412 to quantization table. The only problem is that usually the table is with fixed
|
|
413 size. I expect recommendations how to be properly implemented. should we crop it? Or add qstride, qheight, qwidth? Or mark the size of marcoblocks and
|
|
414 calc table size form image size? Currently pp work with fixed 8x8 blocks.
|
|
415 There may have and problem with interlaced images.
|
|
416 / for frame look at 2.3.4 /
|
|
417 I recommend splitting postprocessing to it's original filters and ability to
|
|
418 use them separately.
|
3342
|
419
|
|
420 2.3. Rules for minimal buffering
|
4091
|
421 2.3.1 Direct rendering.
|
3491
|
422 Direct rendering means that the decoder will use video surface as output buffer.
|
|
423 Most of the decoders have internal buffers and on request they copy
|
4091
|
424 the ready image from one of them to a given location. As we can't get pointer
|
3491
|
425 to the internal buffer the fastest way is to give video surface as
|
|
426 output buffer and the decoder will draw it for us. This is safe as most of
|
|
427 copy routines are optimised for double words aligned access.
|
|
428 If we get internal buffer, we could copy the image on our own. This is not
|
|
429 direct rendering but it gets the same speed. If fact that's why -vc odivx
|
|
430 is faster that -vc divx4 while they use the same divx4linux library.
|
|
431 Sometimes it's possible to set video surface as internal buffer, but in most
|
|
432 cases the decoding process is byte oriented and many unaligned access is
|
|
433 performed. Moreover, reading from video memory on some cards is extremely
|
|
434 slow, about 4 times and more (and this is without setting MTRR), but some
|
|
435 decoders could take advantage of this. In the best case (reading performed
|
|
436 from the cache and using combined write ) we'll watch DivX movie with the same
|
|
437 speed as DivX4 is skipping frames.
|
|
438
|
|
439 What does we need for Direct Rendering?
|
|
440 1. We should be able to get video surfaces.
|
|
441 2. The decoder should have at least one buffer with buffer_type != fixed.
|
|
442 3. If we have 'c' filter we can not use direct rendering. If we have
|
|
443 'p' filter we may allow it.
|
|
444 4. If decoder have one static buffer, then we are limited to 1 video surface.
|
4091
|
445 In this case we may see how the frame is rendered (ugly refresh in best case)
|
|
446 5. Each static buffer and each read_only buffer needs to have it own
|
3491
|
447 video surface. If we don't have enough ... well we may make some tricks
|
|
448 but it is too complicated //using direct rendering for the first in
|
4091
|
449 the list and the rest will use memory buffering. And we must have (1 or 2 ) free
|
3491
|
450 video surfaces for the rest of decoder buffers//
|
4091
|
451 6. Normal (buffer_type=movable, read_only=no) buffer could be redirected to
|
3491
|
452 any available video surface.
|
|
453
|
4091
|
454 2.3.2 Normal process
|
|
455 The usual case libvo2 core takes responsibility to move the data. It must
|
3491
|
456 follow these rules:
|
4091
|
457 1. The 'p' filters process in the buffer of the left, if we have read_only
|
|
458 buffer then vo2 core must insert 'c' copy filter and temp buffer.
|
|
459 2. With 'c' filter we must make sure that we have buffer on the right(->) side. I think
|
|
460 that
|
|
461 3. In the usual case 't' are replaced with 'p' except when 't' is before video surface.
|
|
462 We must have at least one 'c' if core have to make crop, clip, or flip image
|
3491
|
463 upside down.
|
4091
|
464 4. Take care for the additional buffering when we have 1 surface (the libvo1 way).
|
|
465 5. Be aware that some filters must be before other. E.g. Postporcessing should
|
3342
|
466 be before subtitles:)
|
4091
|
467 6. If we want scale (-zoom), and vo2 driver can't make it then add and scale
|
3491
|
468 filter 'c'. For better understanding I have only one convert filter that can
|
|
469 copy, convert, scale, convert and scale. In mplayer it really will be only
|
|
470 one filter.
|
4091
|
471 7. If we have video surface then the final 'c' filters will update it for us. If the filter
|
|
472 and video surface are not WriteCombine safe we may add buffering. In case we use both
|
|
473 get_surface and update_surface, after writing in video surface we must call and
|
|
474 update_sufrace() function.
|
|
475
|
|
476 If we must update_surface() then we will call it with the last buffer. This buffer could
|
|
477 be and the internal decoder buffer if there are no 'c' filters. This buffer could be
|
|
478 returned and by get_surface().
|
|
479
|
|
480 2.3.3 Slices.
|
|
481 Slice is a small rectangle of the image. In decoders world it represents
|
|
482 independently rendered portion of the image. In mplayer slice width is equal
|
|
483 to the image width, the height is usually 8 but there is no problem to vary.
|
|
484 The slices advantage is that working with smaller part of the image the most
|
|
485 of data stays in the cache, so post processing would read the data for free.
|
|
486 This makes slice processing of video data preferred even when decoder and/or
|
|
487 video driver couldn't work with slices.
|
|
488 Smaller slices increase possibility of data to be in the cache, but also
|
|
489 increase the overhead of function calls( brunch prediction too), so it may be
|
|
490 good to tune the size, when it is possible (mainly at 2 filter slices)
|
|
491
|
|
492 Here are some rules:
|
|
493 1. Slices are always with width of the image
|
|
494 2. Slices always are one after another, so you could not skip few lines because
|
|
495 they are not changed. This is made for postprocessing filter as there may
|
|
496 have different output image based on different neighbourhood lines(slices).
|
|
497 3. Slice always finish with last line, this is extended of 2. rule.
|
|
498 4. Slice buffers are normal buffers that could contain a whole frame. This is
|
|
499 need in case we have to accumulate slices for frame process (draw). This is
|
|
500 needed and for pp filters.
|
|
501 5. Slice processing could be used if:
|
|
502 5.1. decoder know for slices and call function when one is completed. The next
|
|
503 filter (or video driver) should be able to work with slices.
|
|
504 5.2. Two or more filters could work with slices. Call them one after another.
|
|
505 The result will be accumulated in the buffer of the last filter (look down
|
|
506 for 'p' type)
|
|
507 5.3. If the final filter can slice and vo2_driver can slice
|
|
508 6. All filers should have independent counters for processed lines. These counters
|
|
509 must be controlled by vo2 core.
|
|
510
|
|
511 2.3.3.1 Slice counters.
|
|
512 For the incoming image we need:
|
|
513 1. value that show the last valid line.
|
|
514 2. value that show the line from where filter will start working. It is updated by the
|
|
515 filter to remember what portion of the image is processed. Vo2 core will zero it
|
|
516 on new frame.
|
|
517
|
|
518 For the result image we need:
|
|
519 1. value that show which line is ready. This will be last valid line for next filter.
|
|
520
|
|
521 The filter may need more internal variables. And as it may be used 2 or more times
|
|
522 in one chain it must be reentrant. So that internal variables should be passed to
|
|
523 filter as parameter.
|
|
524
|
|
525 2.3.3.2 Auto slice.
|
|
526 In case we have complete frame that will be processed by few filters that support slices, we must start processing this frame slice by slice. We have same situation
|
|
527 when one filter accumulates too many lines and forces the next filters to work with bigger slice.
|
|
528 To avoid that case and to automatically start slicing we need to limit the slice size
|
|
529 and when slice is bigger to break it apart. If some filter needs more image lines then
|
|
530 it will wait until it accumulates them.
|
|
531
|
|
532 2.3.4. Frame structure
|
|
533 So far we have buffer, that contain image, we have filters that work with
|
|
534 buffers. For croping and for normal work with the image data we need to know
|
|
535 dimensions of the image. We also need some structure to pass to the filters as
|
|
536 they have to know from where to read, and where they should write.
|
|
537 So I introduce Frame struct:
|
|
538 {
|
|
539 imgfmt - the image format, the most important parameter
|
|
540 height, width - dimensions in pixel
|
|
541 stride - size of image line in bytes, it could be larger then width*sizeof(pixel),
|
|
542 it could be and negative (for vertical flip)
|
|
543 base0,base1,base2,base3 - pointers to planes, thay depend on imgfmt
|
|
544 baseq - quant storage plane. we may need to add qstride, or some qhight/qwidth
|
|
545 palette - pointer to table with palette colors.
|
|
546 flags read-only - this frame is read only.
|
|
547 //screen position ??
|
|
548 }
|
3342
|
549
|
|
550
|
|
551 2.4 Negotiation
|
|
552 Few words about negotiation. It is hard thing to find the best mode. Here is
|
|
553 algorithm that could find the best mode. But first I must say that we need
|
|
554 some kind of weight for the filters and drawing. I think that we could use
|
|
555 something like megabytes/second, something that we may measure or benchmark.
|
|
556
|
|
557 1. We choose codec
|
|
558 2. We choose video driver.
|
|
559 3. For each combination find the total weight and if there are any
|
|
560 optional filters find min and max weight. Be careful max weight is not
|
4091
|
561 always at maximum filters!! (e.g. cropping)
|
3342
|
562 4. Compare the results.
|
|
563
|
|
564 I may say that we don't need automatic codec selection as now we could put
|
|
565 best codecs at beginning of codecs.conf as it is now. We may need to make
|
3491
|
566 the same thing with videodrv.conf. Or better make config files with preferred
|
|
567 order of decoders and video modes:)
|
3342
|
568
|
4091
|
569 I wait comments and ideas.
|