5364
|
1 First draft on video filter layer by A'rpi
|
|
2 =================================
|
|
3
|
|
4 Main goals:
|
|
5 - it should be in libmpcodecs
|
|
6 - it should reduce number of memcpys and memoru allocation to minimum
|
|
7 - it should do postprocessing, colorspace convert, scale and crop/expand/flip
|
|
8 [is there any other type of filters? maybe we could generalize these]
|
|
9 - maybe: sub/osd
|
|
10
|
|
11 Implementation:
|
|
12
|
|
13 The video filter plugin should implement the get_image() call (called from
|
|
14 the video decoder) and call get_image() for the destination image.
|
|
15
|
|
16 so, it would have:
|
|
17
|
|
18 optional:
|
|
19 int get_image(mp_image_t* mpi) // called through control()
|
|
20
|
|
21 if the filter doesn't implement this call, the core (vd.c) will alloc
|
|
22 buffer using memalign() as for disabled direct rendering.
|
|
23
|
|
24 mandatory:
|
|
25 mp_vfilter_data* init()
|
|
26
|
|
27 void uninit(mp_vfilter_data* vfd)
|
|
28
|
|
29 int control(mp_vfilter_data* vfd, ...)
|
|
30
|
|
31 mp_image_t* process(mp_vfilter_data* vfd, mp_image_t* mpi,(*get_image)())
|
|
32
|
|
33 this function will receive an mpi (maybe previously returned by get_image())
|
|
34 and should return the filtered mpi. it should use mpcodecs_get_image() to
|
|
35 allocate a new mpi.
|
|
36 the returned mpi may be EXPORT type, so just doing some pointer/stride
|
|
37 tricks (usually enough for crop/expand/flip) without duplicating the
|
|
38 image buffer or doing the modifications in the incoming buffer (if its
|
|
39 type allows it - so no flags PRESERVE/READABLE set)
|
|
40
|
|
41 mp_vfilter_data would be a transparent (to caller) pointer, used by the
|
|
42 filter instance to store its internal data, tables, parameters etc.
|
|
43 it would allow a fliter to be used more than one times in the queue.
|
|
44 for example: resize in 2 step, postproc+resize+postproc, expand+scale+crop etc
|
|
45
|
|
46 the tricky part of these filters is finding and implementing Direct
|
|
47 Filtering(C) using get_image().
|
|
48
|
|
49 anyway, as first step you can skip get_image() implementation, and just
|
|
50 leave it to vd.c core. in most cases it will be enough, direct filtering
|
|
51 only helps with simple filters (crop/expand/flip) in most cases.
|
|
52
|