core: audio: make ogg missing audio timing workaround more complex
[mplayer/glamo.git] / DOCS / tech / osd.txt
blob7e7376745fd7fccb23c468cd1aff0f5ee745ea61
1 draft of new OSD engine:
2 ========================
3 written by A'rpi
4 including ideas from mailing list from Jiri Svoboda, Tobias Diedrich,
5 Artur Zaprzala, Michael Niedermayer, Felix Buenemann, LGB
7 requirements:
8 - be able to do partial rendering, within a given bounding box
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
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
15 - OSD elements should be cached - so rendering once into the cache and
16   reuse this while it's unchanged
18 - color support (colorspace could be YA, YUVA, RGB)
20 - change brightness, saturation, hue of chars ???
22 - way to disable alphablending, and use black outline (FAST_OSD now)
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)
27 - develop some text-based apps: osdterm, osdzilla etc ;)
29 Ok. The basic idea of my design is using 'OSD objects', a data structure
30 in a 1 (or 2?) way linked list.
31 There would be different object types, sharing type-dependent data in a
32 union. The basic types: box, text, symbol, progressbar, group.
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
36 or multiline subtitle text.
38 Each object could have flags, for example:
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
44   absolute coordinates, or percent. flags to set left/center/right alignment...
45 - start and end timestamp, to automagically set/reset visible flag
47 OK, my first draft:
49 typedef struct mp_osd_obj_s {
50     struct mp_osd_obj_s* next;
51     unsigned char type;
52     unsigned char alignment; // 2 bits: x;y percentages, 2 bits: x;y relative to parent; 2 bits: alignment left/right/center
53     unsigned short flags;
54     int x,y;    // coords
55     unsigned char color[4]; // YUVA
56     mp_osd_bbox_t bbox; // bounding box
57     unsigned int start,duration; // PTS
58     union {
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;
85     } params;
86 } mp_osd_obj_t;