16835
|
1 draft of new OSD engine:
|
|
2 ========================
|
5581
|
3 written by A'rpi
|
16835
|
4 including ideas from mailing list from Jiri Svoboda, Tobias Diedrich,
|
|
5 Artur Zaprzala, Michael Niedermayer, Felix Buenemann, LGB
|
5581
|
6
|
|
7 requirements:
|
|
8 - be able to do partial rendering, within a given bounding box
|
16835
|
9 useful when parts of the OSD are outside of the image and has to be
|
|
10 updated only when OSD changes, or even has different colorspace
|
5581
|
11
|
|
12 - text should be rendered in 2-pass way: 1. alpha 2. pixels
|
|
13 so char's alpha won't overwrite previous char, and may be faster
|
16835
|
14
|
|
15 - OSD elements should be cached - so rendering once into the cache and
|
5581
|
16 reuse this while it's unchanged
|
16835
|
17
|
|
18 - color support (colorspace could be YA, YUVA, RGB)
|
5581
|
19
|
|
20 - change brightness, saturation, hue of chars ???
|
|
21
|
|
22 - way to disable alphablending, and use black outline (FAST_OSD now)
|
|
23
|
16835
|
24 - respect movie and monitor aspect, so OSD is rendered/scaled correctly
|
|
25 eg. for SVCD/anamorphic DVD with hardware scaling (now OSD is squashed)
|
5591
|
26
|
5581
|
27 - develop some text-based apps: osdterm, osdzilla etc ;)
|
|
28
|
16835
|
29 Ok. The basic idea of my design is using 'OSD objects', a data structure
|
5581
|
30 in a 1 (or 2?) way linked list.
|
16835
|
31 There would be different object types, sharing type-dependent data in a
|
5581
|
32 union. The basic types: box, text, symbol, progressbar, group.
|
|
33
|
16835
|
34 Group would be a special type, grouping other OSD objects together,
|
|
35 with a common x,y and boundingbox. Useful for grouping symbol+progrbar
|
5581
|
36 or multiline subtitle text.
|
|
37
|
16835
|
38 Each object could have flags, for example:
|
5581
|
39 - visible (set if we should display it)
|
|
40 - color (set if it's YUVA not YA)
|
|
41 - cached (set when there is a cached rendered variant)
|
|
42 - bbox updated (should be set when recalc bbox, reset when change params)
|
|
43 - several flags to control positioning. for example, x;y could be
|
16835
|
44 absolute coordinates, or percent. flags to set left/center/right alignment...
|
5581
|
45 - start and end timestamp, to automagically set/reset visible flag
|
|
46
|
16835
|
47 OK, my first draft:
|
5581
|
48
|
|
49 typedef struct mp_osd_obj_s {
|
|
50 struct mp_osd_obj_s* next;
|
|
51 unsigned char type;
|
11000
|
52 unsigned char alignment; // 2 bits: x;y percentages, 2 bits: x;y relative to parent; 2 bits: alignment left/right/center
|
5581
|
53 unsigned short flags;
|
30990
|
54 int x,y; // coords
|
5581
|
55 unsigned char color[4]; // YUVA
|
|
56 mp_osd_bbox_t bbox; // bounding box
|
|
57 unsigned int start,duration; // PTS
|
|
58 union {
|
30990
|
59 struct {
|
|
60 int x1,y1,x2,y2;
|
|
61 } line;
|
|
62 struct {
|
|
63 int x,y,w,h;
|
|
64 } rect;
|
|
65 struct {
|
|
66 char* text;
|
|
67 mp_font_t* font;
|
|
68 } text;
|
|
69 struct {
|
|
70 int symbol; // unicode
|
|
71 mp_font_t* font;
|
|
72 } symbol;
|
|
73 struct {
|
|
74 float value;
|
|
75 mp_font_t* font;
|
|
76 } pbar;
|
|
77 struct {
|
|
78 int w,h;
|
|
79 unsigned char* image;
|
|
80 unsigned int* palette;
|
|
81 } spu; // FIXME!
|
|
82 struct {
|
|
83 struct mp_osd_obj_s* children;
|
|
84 } group;
|
5581
|
85 } params;
|
|
86 } mp_osd_obj_t;
|