3342
|
1 This is a brief description on libvo2 interface. It is not C code, just
|
|
2 draft scheme. Feel free to suggest exact parameters.
|
|
3 I have tried to put some numbering. So if you want to reply then put the
|
|
4 topic number in the subject line. Please don't reply to the whole draft,
|
|
5 or at least don't include big paragraphs from it.
|
|
6 I'm gonna put this text as attachment to force you to copy only the parts
|
|
7 you want to reply;)
|
|
8
|
|
9 Best Regards
|
|
10 Ivan Kalvachev
|
|
11
|
|
12 1.libvo2 drivers
|
|
13 1.1 functions
|
|
14 Currently these functions are implemented:
|
|
15 init
|
|
16 control
|
|
17 start
|
|
18 stop
|
|
19 get_surface
|
|
20 flip_image
|
|
21
|
|
22 They are simple enough. So I introduce to be implemented and these functions:
|
|
23 query
|
|
24 update_surface - renamed draw
|
|
25 hw_decode
|
|
26 subpicture
|
|
27
|
|
28 Here is detailed description of new functions:
|
|
29
|
|
30 query - the negotiation is more complex than just finding which imgfmt the
|
|
31 device could show, we must have list of capabilities, testing modes, etc.
|
|
32 this function will have at least 3 modes:
|
|
33
|
|
34 a) return list of available modes with description.
|
|
35 b) check could we use this mode with these parameter. E.g. if we want
|
|
36 RGB32 with 3 surfaces for windows image 800x600 we may get out of video
|
|
37 memory. We don't want error because this mode could be used with 2
|
|
38 surfaces.
|
|
39 c) return supported subpicture formats if any.
|
|
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.
|
|
44
|
|
45 update_surface - as in the note above, this is draw function. Why I change
|
|
46 it's name? I have 2 reasons, first I don't want implementation like vo1,
|
|
47 second it really must update video surface, it must directly call the
|
|
48 system function that will do it. This function should work only with
|
|
49 slices, the size of slice should not be limited and should be passed (e.g
|
|
50 ystart, yend), if we want draw function, we will call one form libvo2
|
|
51 core, that will call this one with start=0; ymax=Ymax;. Also some system
|
|
52 screen update functions wait for vertical retrace before return, other
|
|
53 functions just can't handle partial updates. In this case we should inform
|
|
54 libvo2 core that device cannot slice, and libvo2 core must take care of
|
|
55 the additional buffering.
|
|
56
|
|
57 hw_decode - to make all dvb,dxr3, tv etc. developers happy. This function
|
|
58 is for you. Be careful, don't OBSEBE it, think and for the future, this
|
|
59 function should have and ability to control HW IDCT, MC that one day will
|
|
60 be supported and under linux. Be careful:)
|
|
61
|
|
62 subpicture - this function will place subtitles. It must be called once to
|
|
63 place them and once to remove them, it should not be called on every
|
|
64 frame, the driver will take care of this. Currently I propose this
|
|
65 implementation: we get array of bitmaps. Each one have its own starting
|
|
66 x, y and it's own height and width, each one (or all together) could be
|
|
67 in specific imgfmt (spfmt). THE BITMAPS SHOULD NOT OVERLAP! This may not
|
|
68 be hw limitation but sw subtitles may get confused if they work as 'c'
|
|
69 filter (look my libvo2 core).
|
|
70
|
|
71 1.2 control()
|
|
72 OK, here is list of some control()s that I think that could be useful:
|
|
73 SET_ASPECT
|
|
74 SET_SCALLE_X, SET_SIZE_X
|
|
75 SET_SCALLE_Y, SET_SIZE_Y
|
|
76 RESET_SIZE
|
|
77 GET/SET_POSITION_X
|
|
78 GET/SET_POSTIION_Y
|
|
79 GET/SET_RESOLUTION
|
|
80 GET/SET_DISPLAY
|
|
81 GET/SET_ATTRIBUTES
|
|
82
|
|
83 Here is description of how these controls to be used:
|
|
84
|
|
85 SET_ASPECT - this is the move/video aspect, why not calculate it in
|
|
86 different place (mplayer.c) and pass the results to driver by
|
|
87 set_size_x/y. First this is only if hardware could scale. Second we may
|
|
88 need this value if we have TV and we won't calculate new height and width.
|
|
89
|
|
90 SET_SCALLE_X/Y - this is to enlarge/downscale the image, it WILL NOT
|
|
91 override SET_ASPECT, they will have cumulative effect, this could be used
|
|
92 for deinterlacing (HALF SIZE). Second if we want to zoom 200% we don't
|
|
93 want to lose aspect calculations. Or better SET_SCALLE to work with
|
|
94 current size?
|
|
95
|
|
96 SET_SIZE_X/Y - This is for custom enlarge, to save some scale calculation
|
|
97 and for more precise results.
|
|
98
|
|
99 RESET_SIZE - Set the original size of image, we must call SET_ASPECT agein.
|
|
100
|
|
101 GET/SET_POSOTION_X/Y - This if for windows only, to allow custom move on
|
|
102 window.
|
|
103
|
|
104 GET/SET_RESOLUTION - change resolution and/or bpp if possible. To be used
|
|
105 for window or if we want to change the given resolution of the current
|
|
106 fullscreen mode (NOT TO SET IT just to change it if we don't like it)
|
|
107
|
|
108 GET/SET_DISPLAY - mainly for X11 and remote displays. Not very useful, but
|
|
109 may be handy.
|
|
110
|
|
111 GET/SET_ATTRIBUTES - Xv overlays have contrast, brightness, hue,
|
|
112 saturation etc. these and others could be controlled by this. If we want
|
|
113 to query it we must call GET_*, and the to check does our attribute is in
|
|
114 there (xv developers be careful, 2 or 3 of default attributes sometimes
|
|
115 are not queried by X, but could be set).
|
|
116
|
|
117 Do you think that TV encodings (NTSC,PAL,SECAM) should have it's own attribute?
|
|
118 I would like to hear the GUI developers. Could we separate Mouse/Keyboard
|
|
119 from the driver. What info do you need to do it. Don't forget that SDL have
|
|
120 it's own keyboard/mouse interface. Maybe we should allow video driver to
|
|
121 change the libin driver ?
|
|
122
|
|
123 1.3. query()
|
|
124
|
|
125 Here come and some attributes for the queried modes, each supported mode
|
|
126 should have such description. It is even possible to have more than one mode
|
|
127 that could display given imgfmt.
|
|
128
|
|
129 { Scale y/n - hardware scale, do you think that we mast have one for x and
|
|
130 one for y (win does)?
|
|
131
|
|
132 Fullscreen y/n - if the supported mode is fullscreen, if we have yv12 for
|
|
133 fullscreen and window we must threat them as separate modes. Window y/n -
|
|
134 same as Fullscreen.
|
|
135
|
|
136 GetSurface y/n - if driver could give us video surface we'll use get_surface()
|
|
137
|
|
138 UpdateSurfece y/n - if driver will update video surface through sys function (X,SDL)
|
|
139
|
|
140 HWdecode y/n - if driver could take advantage of hw_decode()
|
|
141
|
|
142 MaxSurfaces 1..n - Theoretical maximum of surfaces
|
|
143
|
|
144 SubPicture y/n - Could we put subpicture (OSD) of any kind by hw
|
|
145
|
|
146 WriteCombine y/n - if GetSurface==yes, most (or all) pci&agp cards are
|
|
147 extremely slow on byte access, this is hint to vo2 core those surfaces
|
|
148 that got affected by WC. This is only a hint.
|
|
149
|
|
150 us_clip y/n - if UpdateSurface=yes, this shows could update_surface()
|
|
151 remove strides (when stride> width ), this is used and for cropping. If
|
|
152 not, we must do it.
|
|
153
|
|
154 us_slice y/n - if UpdateSurface=yes, this shows that after executing
|
|
155 update_surface(), the function won't wait for vertical retrace, and we
|
|
156 could update surface slice by slice. If us_slice=0 we will have to
|
|
157 accumulate all slices in one buffer.
|
|
158
|
|
159 us_upsidedown - if UpdateSufrace=yes, this shows that update_suface()
|
|
160 could flip the image vertically. In some case this could be united with
|
|
161 us_clip /stride game/
|
|
162
|
|
163 switch_resoliton y/n - if window=y, this shows could we switch resolution
|
|
164 of desktop, if fullscreen=y, shows that we could change resolution, after
|
|
165 we have set the fullscreen mode.
|
|
166
|
|
167 deinterlace y/n - indicates that the device could deinterlace on it's own
|
|
168 (radeon, TV).
|
|
169
|
|
170 1.4 conclusion
|
|
171
|
|
172 As you see, I have removed all additional buffering from the driver. There
|
|
173 is a lot of functionality should be checked and handled by libvo2 core.
|
|
174 First we should check what else could be added to this draft. Then to check
|
|
175 all cases and how to handle them. Some of the parameters should be able to
|
|
176 be overriden by user config, mainly to disable buggy modes or parameters. I
|
|
177 belive that this should not be done by command line as there are enough
|
|
178 commands now.
|
|
179
|
|
180 //---------------------------
|
|
181 2. libvo2 core
|
|
182 2.1 functions
|
|
183 now these function are implemented:
|
|
184 init
|
|
185 new
|
|
186 start
|
|
187 query_format
|
|
188 close
|
|
189
|
|
190 and as draw.c:
|
|
191 choose_buffering
|
|
192 draw_slice_start
|
|
193 draw_slice
|
|
194 draw_frame
|
|
195 flip
|
|
196
|
|
197 init() is called at mplayer start. internal initialisation.
|
|
198 new() -> rename to open_drv() or something like this.
|
|
199 query_format -> not usable in this form, this function mean that all
|
|
200 negotiation will be performed outside libvo2. Replace or find better name.
|
|
201 close -> open/close :)
|
|
202
|
|
203 choose_buffering - all buffering must stay hidden. The only exception is for
|
|
204 hw_decode. In the new implementation this functions is not usable.
|
|
205 draw_slice_start, draw_slice -> if you like it this way, then it's OK.
|
|
206 draw_frame -> classic draw function.
|
|
207
|
|
208 2.2 Minimal buffering
|
|
209
|
|
210 I should say that I stand after the idea all buffering, postprocessing,
|
|
211 format conversion , sw draw of subtitles, etc to be done in libvo2 core.
|
|
212 Why? First this is the only way we could fully control buffering and
|
|
213 decrease it to minimum. Less buffers means less coping. In some cases this
|
|
214 could have the opposite effect (mpeg2 with internal buffers in video memory
|
|
215 without HW IDCT, MC, or if we have unaligned write).
|
|
216
|
|
217 The first step of the analyse is to find out what we need:
|
|
218
|
|
219 DECODER - type_of_buffer:{internal/static/normal},
|
|
220 slice:{not/supported}
|
|
221
|
|
222 FILTER 1..x - processing:{ c-copy(buff1,buff2), p-process(buff1) },
|
|
223 slice:{not/supported}
|
|
224 write_combine:{not/safe},
|
|
225 runtime_remove:{static/dynamic}
|
|
226
|
|
227 VIDEO_OUT - method:{get_surface/update_surface},
|
|
228 slice:{not/supported},
|
|
229 write_combine:{not/safe},
|
|
230 clip:{can/not},
|
|
231 upsidedown:(can/not),
|
|
232 surfaces:{1/2/3,..,n}
|
|
233
|
|
234 If we want direct rendering we need normal buffer, no filters, and (at
|
|
235 least) 2 video surfaces. (we may allow 'p' filter like subtitles).
|
|
236
|
|
237 If we have static buffer, we have 2 choices: to render in 1 surface
|
|
238 (visual flickering) or to make additional buffering and draw on flip_page
|
|
239 (like in libvo1).
|
|
240
|
|
241 Here I introduce and one letter codes that I use for analyse.
|
|
242 Details:
|
|
243
|
|
244 DECODER - We always get buffer from the decoder, some decoders could give
|
|
245 pointer to it's internal buffers, other takes pointers to buffers where
|
|
246 they should store the final image. Some decoders could call draw_slice
|
|
247 after they have finished with some portion of the image.
|
|
248
|
|
249 type_of_buffer - I take this from the current libvo2 spec. I call 'I'
|
|
250 internal buffer (readonly), 'K' static buffer(one,constant pointer), and
|
|
251 'B' - normal buffer.
|
|
252
|
|
253 slice - this flag shows that decoder knows and want to work with slices.
|
|
254
|
|
255 FILTER - postprocessing, sw drawing subtitles, format conversion, crop,
|
|
256 additional filters.
|
|
257
|
|
258 slice - could this filter work with slice order. We could use slice even
|
|
259 when decoder does not support slice, we just need 2 or more filters that
|
|
260 does. This could give us remarkable speed boost.
|
|
261
|
|
262 processing - some filters can copy the image from one buffer to the other,
|
|
263 I call them 'c', convert and crop(stride copy) are good examples but don't
|
|
264 forget simple 1:1 copy. Other filters does process only part if the image,
|
|
265 and could reuse the given buffer, e.g. putting subtitles. Other filters
|
|
266 could work in one buffer, but could work and with 2, I call them 't'
|
|
267 class, after analyse they will fade to 'c' or 'p'.
|
|
268
|
|
269 runtime_remove - postprocess with autoq. Subtitles appear and disappear,
|
|
270 should we copy image from one buffer to another if there is no processing
|
|
271 at all?
|
|
272
|
|
273 //clip, crop, upsidedown - all 'c' filters must support strides, and should
|
|
274 be able to remove them and to make some tricks like crop and upside_down.
|
|
275
|
|
276 VIDEO_OUT - take a look of libvo2 driver I propose.
|
|
277 method - If we get surface -'S'. If we use draw* (update_surface) - 'd'
|
|
278
|
|
279 As you may see hd_decode don't have complicated buffering:)
|
|
280 I make the analyse this way. First I put decoder buffer, then I put all
|
|
281 filters, that may be needed, and finally I put video out method.
|
|
282
|
|
283 2.3. Rules for minimal buffering
|
|
284 The rules are these:
|
|
285 The 'p' filters process in the buffer of the left, if we have 'I' buffer
|
|
286 then insert copy and new 'B' buffer.
|
|
287 With 'c' filter we must make sure that we have buffer ('B' or 'S') from the right(->) side.
|
|
288 We must take care that, if we have S we need to finish with copy ('c'), and
|
|
289 if we have 'd' we must end with some kind of buffer.
|
|
290 In the usual case 't' are replaced with 'p' except when 't' is before 'S'.
|
|
291 If we have 'B S' or 'K S' we may make direct rendering and remove the 'B' or 'K' buffer.
|
|
292 We must have at least one 'c' if we have to make crop, clip, or flip image upside down.
|
|
293 Take care for the additional buffering when we have 1 surface (the libvo1 way).
|
|
294 Be aware that some filters must be before other. E.g. Postporcessing should
|
|
295 be before subtitles:)
|
|
296 If we want scale (-zoom), and vo2 driver can't make it then add and scale
|
|
297 filter 'c'. For better understanding I have one convert filter that can
|
|
298 copy, convert, convert and scale. The only thing that is missing now is
|
|
299 simple scale (yv12).
|
|
300
|
|
301 I have made grammar for these cases but it is too big and I hope that
|
|
302 something cleverer could be made. Don't think that having only 3 filters
|
|
303 (postporcess, convert/copy, subtitles) may make the things simpler. This
|
|
304 algorithm could be used and for numerous filters used in encoders.
|
|
305
|
|
306 2.4 Negotiation
|
|
307 Few words about negotiation. It is hard thing to find the best mode. Here is
|
|
308 algorithm that could find the best mode. But first I must say that we need
|
|
309 some kind of weight for the filters and drawing. I think that we could use
|
|
310 something like megabytes/second, something that we may measure or benchmark.
|
|
311
|
|
312 1. We choose codec
|
|
313 2. We choose video driver.
|
|
314 3. For each combination find the total weight and if there are any
|
|
315 optional filters find min and max weight. Be careful max weight is not
|
|
316 always at maximum filters!!
|
|
317 4. Compare the results.
|
|
318
|
|
319 I may say that we don't need automatic codec selection as now we could put
|
|
320 best codecs at beginning of codecs.conf as it is now. We may need to make
|
|
321 same thing with videodrv.conf :)
|
|
322
|
|
323
|
|
324
|