Mercurial > mplayer.hg
annotate libvo/sub.c @ 8583:4c18c4e7f34e
-subwidth
author | arpi |
---|---|
date | Fri, 27 Dec 2002 21:41:40 +0000 |
parents | a9d454af3497 |
children | 7fe391d6c293 |
rev | line source |
---|---|
5503 | 1 |
2 #include <stdio.h> | |
3 #include <stdlib.h> | |
7003
60a473935d7d
warning fixes by Sylvain Petreolle <spetreolle@yahoo.fr>
arpi
parents:
6190
diff
changeset
|
4 #include <string.h> |
218 | 5 |
4088 | 6 #include "config.h" |
8123
9fc45fe0d444
*HUGE* set of compiler warning fixes, unused variables removal
arpi
parents:
7628
diff
changeset
|
7 #ifdef HAVE_MALLOC_H |
9fc45fe0d444
*HUGE* set of compiler warning fixes, unused variables removal
arpi
parents:
7628
diff
changeset
|
8 #include <malloc.h> |
9fc45fe0d444
*HUGE* set of compiler warning fixes, unused variables removal
arpi
parents:
7628
diff
changeset
|
9 #endif |
9fc45fe0d444
*HUGE* set of compiler warning fixes, unused variables removal
arpi
parents:
7628
diff
changeset
|
10 |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
11 #include "mp_msg.h" |
4088 | 12 #include "video_out.h" |
5294 | 13 #include "font_load.h" |
218 | 14 #include "sub.h" |
7003
60a473935d7d
warning fixes by Sylvain Petreolle <spetreolle@yahoo.fr>
arpi
parents:
6190
diff
changeset
|
15 #include "../spudec.h" |
202 | 16 |
2498 | 17 char * __sub_osd_names[]={ |
18 "Seekbar", | |
19 "Play", | |
20 "Pause", | |
21 "Stop", | |
22 "Rewind", | |
23 "Forward", | |
24 "Clock", | |
25 "Contrast", | |
26 "Saturation", | |
27 "Volume", | |
28 "Brightness", | |
29 "Hue" | |
30 }; | |
31 char * __sub_osd_names_short[] ={ "", "|>", "||", "[]", "<<" , ">>", "", "", "", "", "", ""}; | |
32 | |
213 | 33 //static int vo_font_loaded=-1; |
34 font_desc_t* vo_font=NULL; | |
202 | 35 |
1991
dee4b2ea5e5b
add gui support to config scripts, and fixed some warning.
pontscho
parents:
1878
diff
changeset
|
36 unsigned char* vo_osd_text=NULL; |
803
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
37 int sub_unicode=0; |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
38 int sub_utf8=0; |
4773 | 39 int sub_pos=100; |
8583 | 40 int sub_width_p=100; |
8578 | 41 int sub_alignment=0; /* 0=top, 1=center, 2=bottom */ |
7628
d6608342591d
This patch adds the functionality to disable/enable subtitles while playing
arpi
parents:
7121
diff
changeset
|
42 int sub_visibility=1; |
213 | 43 |
5664 | 44 // return the real height of a char: |
45 static inline int get_height(int c,int h){ | |
46 int font; | |
47 if ((font=vo_font->font[c])>=0) | |
48 if(h<vo_font->pic_a[font]->h) h=vo_font->pic_a[font]->h; | |
49 return h; | |
50 } | |
51 | |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
52 // renders char to a big per-object buffer where alpha and bitmap are separated |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
53 static void draw_alpha_buf(mp_osd_obj_t* obj, int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride) |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
54 { |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
55 int dststride = obj->stride; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
56 int dstskip = obj->stride-w; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
57 int srcskip = stride-w; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
58 int i, j; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
59 unsigned char *b = obj->bitmap_buffer + (y0-obj->bbox.y1)*dststride + (x0-obj->bbox.x1); |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
60 unsigned char *a = obj->alpha_buffer + (y0-obj->bbox.y1)*dststride + (x0-obj->bbox.x1); |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
61 unsigned char *bs = src; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
62 unsigned char *as = srca; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
63 |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
64 if (x0 < obj->bbox.x1 || x0+w > obj->bbox.x2 || y0 < obj->bbox.y1 || y0+h > obj->bbox.y2) { |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
65 fprintf(stderr, "osd text out of range: bbox [%d %d %d %d], txt [%d %d %d %d]\n", |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
66 obj->bbox.x1, obj->bbox.x2, obj->bbox.y1, obj->bbox.y2, |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
67 x0, x0+w, y0, y0+h); |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
68 return; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
69 } |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
70 |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
71 for (i = 0; i < h; i++) { |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
72 for (j = 0; j < w; j++, b++, a++, bs++, as++) { |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
73 if (*b < *bs) *b = *bs; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
74 if (*as) { |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
75 if (*a == 0 || *a > *as) *a = *as; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
76 } |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
77 } |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
78 b+= dstskip; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
79 a+= dstskip; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
80 bs+= srcskip; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
81 as+= srcskip; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
82 } |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
83 } |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
84 |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
85 // allocates/enlarges the alpha/bitmap buffer |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
86 static void alloc_buf(mp_osd_obj_t* obj) |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
87 { |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
88 int len; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
89 if (obj->bbox.x2 < obj->bbox.x1) obj->bbox.x2 = obj->bbox.x1; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
90 if (obj->bbox.y2 < obj->bbox.y1) obj->bbox.y2 = obj->bbox.y1; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
91 obj->stride = ((obj->bbox.x2-obj->bbox.x1)+7)&(~7); |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
92 len = obj->stride*(obj->bbox.y2-obj->bbox.y1); |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
93 if (obj->allocated<len) { |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
94 obj->allocated = len; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
95 free(obj->bitmap_buffer); |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
96 free(obj->alpha_buffer); |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
97 obj->bitmap_buffer = (unsigned char *)memalign(16, len); |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
98 obj->alpha_buffer = (unsigned char *)memalign(16, len); |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
99 } |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
100 memset(obj->bitmap_buffer, 0, len); |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
101 memset(obj->alpha_buffer, 0, len); |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
102 } |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
103 |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
104 // renders the buffer |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
105 inline static void vo_draw_text_from_buffer(mp_osd_obj_t* obj,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)){ |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
106 if (obj->allocated > 0) { |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
107 draw_alpha(obj->bbox.x1,obj->bbox.y1, |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
108 obj->bbox.x2-obj->bbox.x1, |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
109 obj->bbox.y2-obj->bbox.y1, |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
110 obj->bitmap_buffer, |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
111 obj->alpha_buffer, |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
112 obj->stride); |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
113 } |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
114 } |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
115 |
5640 | 116 inline static void vo_update_text_osd(mp_osd_obj_t* obj,int dxs,int dys){ |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
117 unsigned char *cp=vo_osd_text; |
5640 | 118 int x=20; |
5664 | 119 int h=0; |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
120 int font; |
5640 | 121 |
122 obj->bbox.x1=obj->x=x; | |
123 obj->bbox.y1=obj->y=10; | |
202 | 124 |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
125 while (*cp){ |
5640 | 126 int c=*cp++; |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
127 render_one_glyph(vo_font, c); |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
128 x+=vo_font->width[c]+vo_font->charspace; |
5664 | 129 h=get_height(c,h); |
5640 | 130 } |
131 | |
5664 | 132 obj->bbox.x2=x-vo_font->charspace; |
133 obj->bbox.y2=obj->bbox.y1+h; | |
5640 | 134 obj->flags|=OSDFLAG_BBOX; |
135 | |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
136 alloc_buf(obj); |
5640 | 137 |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
138 cp=vo_osd_text; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
139 x = obj->x; |
5640 | 140 while (*cp){ |
141 int c=*cp++; | |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
142 if ((font=vo_font->font[c])>=0) |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
143 draw_alpha_buf(obj,x,obj->y, |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
144 vo_font->width[c], |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
145 vo_font->pic_a[font]->h, |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
146 vo_font->pic_b[font]->bmp+vo_font->start[c], |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
147 vo_font->pic_a[font]->bmp+vo_font->start[c], |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
148 vo_font->pic_a[font]->w); |
213 | 149 x+=vo_font->width[c]+vo_font->charspace; |
150 } | |
218 | 151 } |
152 | |
153 int vo_osd_progbar_type=-1; | |
1726 | 154 int vo_osd_progbar_value=100; // 0..256 |
155 | |
156 // if we have n=256 bars then OSD progbar looks like below | |
157 // | |
1878 | 158 // 0 1 2 3 ... 256 <= vo_osd_progbar_value |
159 // | | | | | | |
1726 | 160 // [ === === === ... === ] |
161 // | |
162 // the above schema is rescalled to n=elems bars | |
218 | 163 |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
164 inline static void vo_update_text_progbar(mp_osd_obj_t* obj,int dxs,int dys){ |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
165 |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
166 obj->flags|=OSDFLAG_CHANGED|OSDFLAG_VISIBLE; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
167 |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
168 if(vo_osd_progbar_type<0 || !vo_font){ |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
169 obj->flags&=~OSDFLAG_VISIBLE; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
170 return; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
171 } |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
172 |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
173 render_one_glyph(vo_font, OSD_PB_START); |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
174 render_one_glyph(vo_font, OSD_PB_END); |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
175 render_one_glyph(vo_font, OSD_PB_0); |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
176 render_one_glyph(vo_font, OSD_PB_1); |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
177 render_one_glyph(vo_font, vo_osd_progbar_type); |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
178 |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
179 // calculate bbox corners: |
5664 | 180 { int h=0; |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
181 int y=(dys-vo_font->height)/2; |
1548
eee7951a23af
changes according to proper subfont bar positioning and char spaceing - sub.c
atlka
parents:
1524
diff
changeset
|
182 int delimw=vo_font->width[OSD_PB_START] |
1549 | 183 +vo_font->width[OSD_PB_END] |
184 +vo_font->charspace; | |
1548
eee7951a23af
changes according to proper subfont bar positioning and char spaceing - sub.c
atlka
parents:
1524
diff
changeset
|
185 int width=(2*dxs-3*delimw)/3; |
1549 | 186 int charw=vo_font->width[OSD_PB_0]+vo_font->charspace; |
1548
eee7951a23af
changes according to proper subfont bar positioning and char spaceing - sub.c
atlka
parents:
1524
diff
changeset
|
187 int elems=width/charw; |
1549 | 188 int x=(dxs-elems*charw-delimw)/2; |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
189 int delta = 0; |
5664 | 190 h=get_height(OSD_PB_START,h); |
191 h=get_height(OSD_PB_END,h); | |
192 h=get_height(OSD_PB_0,h); | |
193 h=get_height(OSD_PB_1,h); | |
8422 | 194 if (vo_osd_progbar_type>0 && vo_font->font[vo_osd_progbar_type]>=0){ |
195 delta = vo_font->width[vo_osd_progbar_type]+vo_font->spacewidth; | |
196 delta = (x-delta > 0) ? delta : x; | |
197 h=get_height(vo_osd_progbar_type,h); | |
198 } | |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
199 obj->bbox.x1=obj->x=x; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
200 obj->bbox.y1=obj->y=y; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
201 obj->bbox.x2=x+width+delimw; |
5664 | 202 obj->bbox.y2=y+h; //vo_font->height; |
5640 | 203 obj->flags|=OSDFLAG_BBOX; |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
204 obj->params.progbar.elems=elems; |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
205 obj->bbox.x1-=delta; // space for an icon |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
206 } |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
207 |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
208 alloc_buf(obj); |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
209 |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
210 // render it: |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
211 { unsigned char *s; |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
212 unsigned char *sa; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
213 int i,w,h,st,mark; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
214 int x=obj->x; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
215 int y=obj->y; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
216 int c,font; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
217 int charw=vo_font->width[OSD_PB_0]+vo_font->charspace; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
218 int elems=obj->params.progbar.elems; |
1548
eee7951a23af
changes according to proper subfont bar positioning and char spaceing - sub.c
atlka
parents:
1524
diff
changeset
|
219 |
1726 | 220 if (vo_osd_progbar_value<=0) |
221 mark=0; | |
1878 | 222 else { |
223 int ev=vo_osd_progbar_value*elems; | |
224 mark=ev>>8; | |
225 if (ev & 0xFF) mark++; | |
226 if (mark>elems) mark=elems; | |
227 } | |
228 | |
1727 | 229 |
218 | 230 // printf("osd.progbar width=%d xpos=%d\n",width,x); |
231 | |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
232 c=vo_osd_progbar_type; |
1569
fcbfc99cf8e6
skip lines with negative y position if there is too many lines to display
atlka
parents:
1549
diff
changeset
|
233 if(vo_osd_progbar_type>0 && (font=vo_font->font[c])>=0) { |
fcbfc99cf8e6
skip lines with negative y position if there is too many lines to display
atlka
parents:
1549
diff
changeset
|
234 int xp=x-vo_font->width[c]-vo_font->spacewidth; |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
235 draw_alpha_buf(obj,(xp<0?0:xp),y, |
218 | 236 vo_font->width[c], |
237 vo_font->pic_a[font]->h, | |
238 vo_font->pic_b[font]->bmp+vo_font->start[c], | |
239 vo_font->pic_a[font]->bmp+vo_font->start[c], | |
240 vo_font->pic_a[font]->w); | |
1569
fcbfc99cf8e6
skip lines with negative y position if there is too many lines to display
atlka
parents:
1549
diff
changeset
|
241 } |
fcbfc99cf8e6
skip lines with negative y position if there is too many lines to display
atlka
parents:
1549
diff
changeset
|
242 |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
243 c=OSD_PB_START; |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
244 if ((font=vo_font->font[c])>=0) |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
245 draw_alpha_buf(obj,x,y, |
218 | 246 vo_font->width[c], |
247 vo_font->pic_a[font]->h, | |
248 vo_font->pic_b[font]->bmp+vo_font->start[c], | |
249 vo_font->pic_a[font]->bmp+vo_font->start[c], | |
250 vo_font->pic_a[font]->w); | |
1548
eee7951a23af
changes according to proper subfont bar positioning and char spaceing - sub.c
atlka
parents:
1524
diff
changeset
|
251 x+=vo_font->width[c]+vo_font->charspace; |
218 | 252 |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
253 c=OSD_PB_0; |
1602 | 254 if ((font=vo_font->font[c])>=0){ |
255 w=vo_font->width[c]; | |
256 h=vo_font->pic_a[font]->h; | |
257 s=vo_font->pic_b[font]->bmp+vo_font->start[c]; | |
258 sa=vo_font->pic_a[font]->bmp+vo_font->start[c]; | |
259 st=vo_font->pic_a[font]->w; | |
2204 | 260 if ((i=mark)) do { |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
261 draw_alpha_buf(obj,x,y,w,h,s,sa,st); |
1548
eee7951a23af
changes according to proper subfont bar positioning and char spaceing - sub.c
atlka
parents:
1524
diff
changeset
|
262 x+=charw; |
2204 | 263 } while(--i); |
1602 | 264 } |
202 | 265 |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
266 c=OSD_PB_1; |
1602 | 267 if ((font=vo_font->font[c])>=0){ |
268 w=vo_font->width[c]; | |
269 h=vo_font->pic_a[font]->h; | |
270 s =vo_font->pic_b[font]->bmp+vo_font->start[c]; | |
271 sa=vo_font->pic_a[font]->bmp+vo_font->start[c]; | |
272 st=vo_font->pic_a[font]->w; | |
2204 | 273 if ((i=elems-mark)) do { |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
274 draw_alpha_buf(obj,x,y,w,h,s,sa,st); |
1548
eee7951a23af
changes according to proper subfont bar positioning and char spaceing - sub.c
atlka
parents:
1524
diff
changeset
|
275 x+=charw; |
2204 | 276 } while(--i); |
1602 | 277 } |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
278 |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
279 c=OSD_PB_END; |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
280 if ((font=vo_font->font[c])>=0) |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
281 draw_alpha_buf(obj,x,y, |
218 | 282 vo_font->width[c], |
283 vo_font->pic_a[font]->h, | |
284 vo_font->pic_b[font]->bmp+vo_font->start[c], | |
285 vo_font->pic_a[font]->bmp+vo_font->start[c], | |
286 vo_font->pic_a[font]->w); | |
1548
eee7951a23af
changes according to proper subfont bar positioning and char spaceing - sub.c
atlka
parents:
1524
diff
changeset
|
287 // x+=vo_font->width[c]+vo_font->charspace; |
803
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
288 |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
289 } |
218 | 290 // vo_osd_progbar_value=(vo_osd_progbar_value+1)&0xFF; |
291 | |
292 } | |
293 | |
254 | 294 subtitle* vo_sub=NULL; |
218 | 295 |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
296 // vo_draw_text_sub(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)) |
1591 | 297 |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
298 inline static void vo_update_text_sub(mp_osd_obj_t* obj,int dxs,int dys){ |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
299 unsigned char *t; |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
300 int c,i,j,l,x,y,font,prevc; |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
301 int len; |
1591 | 302 int k,lastk; |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
303 int lastStripPosition; |
1591 | 304 int xsize,lastxsize; |
5640 | 305 int xmin=dxs,xmax=0; |
1591 | 306 int h,lasth; |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
307 |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
308 obj->flags|=OSDFLAG_CHANGED|OSDFLAG_VISIBLE; |
7628
d6608342591d
This patch adds the functionality to disable/enable subtitles while playing
arpi
parents:
7121
diff
changeset
|
309 |
d6608342591d
This patch adds the functionality to disable/enable subtitles while playing
arpi
parents:
7121
diff
changeset
|
310 if(!vo_sub || !vo_font || !sub_visibility){ |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
311 obj->flags&=~OSDFLAG_VISIBLE; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
312 return; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
313 } |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
314 |
5664 | 315 obj->bbox.y2=obj->y=dys; |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
316 obj->params.subtitle.lines=0; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
317 |
1602 | 318 // too long lines divide into a smaller ones |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
319 i=k=lasth=0; |
1591 | 320 h=vo_font->height; |
321 xsize=-vo_font->charspace; | |
322 lastStripPosition=-1; | |
323 l=vo_sub->lines; | |
324 | |
2204 | 325 while (l) { |
326 l--; | |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
327 t=vo_sub->text[i++]; |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
328 len=strlen(t)-1; |
1824 | 329 |
1852 | 330 // printf("sub(%d) '%s'\n",len,t); |
1824 | 331 // if(len<0) memy -=h; // according to max of vo_font->pic_a[font]->h |
332 // else | |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
333 |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
334 prevc = -1; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
335 |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
336 for (j=0;j<=len;j++){ |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
337 if ((c=t[j])>=0x80){ |
2176 | 338 if (sub_utf8){ |
339 if ((c & 0xe0) == 0xc0) /* 2 bytes U+00080..U+0007FF*/ | |
340 c = (c & 0x1f)<<6 | (t[++j] & 0x3f); | |
8451 | 341 else if((c & 0xf0) == 0xe0){ /* 3 bytes U+00800..U+00FFFF*/ |
342 c = (((c & 0x0f)<<6) | (t[++j] & 0x3f))<<6; | |
343 c |= (t[++j] & 0x3f); | |
344 } | |
2176 | 345 } else if (sub_unicode) |
346 c = (c<<8) + t[++j]; | |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
347 } |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
348 if (k==MAX_UCS){ |
2204 | 349 len=j; // end here |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
350 mp_msg(MSGT_OSD,MSGL_WARN,"\nMAX_UCS exceeded!\n"); |
1591 | 351 } |
2204 | 352 if (!c) c++; // avoid UCS 0 |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
353 render_one_glyph(vo_font, c); |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
354 if (c==' '){ |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
355 lastk=k; |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
356 lastStripPosition=j; |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
357 lastxsize=xsize; |
8361
2202c00001e3
overlapping subtitles support is now optional, can be disabled (-nooverlapsub)
arpi
parents:
8123
diff
changeset
|
358 } else if ((!suboverlap_enabled) && ((font = vo_font->font[c]) >= 0)) { |
2202c00001e3
overlapping subtitles support is now optional, can be disabled (-nooverlapsub)
arpi
parents:
8123
diff
changeset
|
359 /* |
2202c00001e3
overlapping subtitles support is now optional, can be disabled (-nooverlapsub)
arpi
parents:
8123
diff
changeset
|
360 With overlapping subtitles, we need to comment this out, |
2202c00001e3
overlapping subtitles support is now optional, can be disabled (-nooverlapsub)
arpi
parents:
8123
diff
changeset
|
361 beacuse that part of the code creates subtitles with the |
2202c00001e3
overlapping subtitles support is now optional, can be disabled (-nooverlapsub)
arpi
parents:
8123
diff
changeset
|
362 last line blank (" "): in this case previous 'if' statement |
2202c00001e3
overlapping subtitles support is now optional, can be disabled (-nooverlapsub)
arpi
parents:
8123
diff
changeset
|
363 is false an following 'if' is not executed. When, instead, |
2202c00001e3
overlapping subtitles support is now optional, can be disabled (-nooverlapsub)
arpi
parents:
8123
diff
changeset
|
364 a subtitle with a non-blank last line arrives, the following |
2202c00001e3
overlapping subtitles support is now optional, can be disabled (-nooverlapsub)
arpi
parents:
8123
diff
changeset
|
365 code is executed, and the result is a small 'jump' of the |
2202c00001e3
overlapping subtitles support is now optional, can be disabled (-nooverlapsub)
arpi
parents:
8123
diff
changeset
|
366 subtiles. We can not simply delete the following, unless |
2202c00001e3
overlapping subtitles support is now optional, can be disabled (-nooverlapsub)
arpi
parents:
8123
diff
changeset
|
367 having the last subtitle line partly drawn outside the |
2202c00001e3
overlapping subtitles support is now optional, can be disabled (-nooverlapsub)
arpi
parents:
8123
diff
changeset
|
368 screen, so, some lines forward, we introduce an increment |
2202c00001e3
overlapping subtitles support is now optional, can be disabled (-nooverlapsub)
arpi
parents:
8123
diff
changeset
|
369 which affects both blank and non-blank lines. |
2202c00001e3
overlapping subtitles support is now optional, can be disabled (-nooverlapsub)
arpi
parents:
8123
diff
changeset
|
370 *sfalco* |
2202c00001e3
overlapping subtitles support is now optional, can be disabled (-nooverlapsub)
arpi
parents:
8123
diff
changeset
|
371 */ |
1591 | 372 if (vo_font->pic_a[font]->h > h){ |
373 h=vo_font->pic_a[font]->h; | |
374 } | |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
375 } |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
376 obj->params.subtitle.utbl[k++]=c; |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
377 xsize+=vo_font->width[c]+vo_font->charspace+kerning(vo_font,prevc,c); |
8583 | 378 if (dxs*sub_width_p/100<xsize){ |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
379 prevc = -1; |
1591 | 380 if (lastStripPosition>0){ |
381 j=lastStripPosition; | |
382 xsize=lastxsize; | |
383 k=lastk; | |
384 } else { | |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
385 xsize -=vo_font->width[c]+vo_font->charspace+kerning(vo_font,prevc,c);; // go back |
1591 | 386 k--; // cut line here |
387 while (t[j] && t[j]!=' ') j++; // jump to the nearest space | |
388 } | |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
389 } else if (j<len) { |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
390 prevc = c; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
391 continue; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
392 } |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
393 if (h>obj->y){ // out of the screen so end parsing |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
394 obj->y -= lasth - vo_font->height; // correct the y position |
2204 | 395 l=0; |
396 break; | |
1591 | 397 } |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
398 obj->params.subtitle.utbl[k++]=0; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
399 obj->params.subtitle.xtbl[obj->params.subtitle.lines++]=(dxs-xsize)/2; |
5640 | 400 if(xmin>(dxs-xsize)/2) xmin=(dxs-xsize)/2; |
401 if(xmax<(dxs+xsize)/2) xmax=(dxs+xsize)/2; | |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
402 if (obj->params.subtitle.lines==MAX_UCSLINES||k>MAX_UCS){ |
2204 | 403 l=0; len=j; // end parsing |
1602 | 404 } else if(l || j<len){ // not the last line or not the last char |
1591 | 405 lastStripPosition=-1; |
406 xsize=-vo_font->charspace; | |
407 lasth=h; | |
408 h=vo_font->height; | |
409 } | |
2176 | 410 // printf("h: %d -> %d \n",vo_font->height,h); |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
411 obj->y -=h; // according to max of vo_font->pic_a[font]->h |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
412 prevc = -1; |
1591 | 413 } |
1573
c394d04d6b30
changes according to max of vo_font->pic_a[font]->h for the last line of subs
atlka
parents:
1569
diff
changeset
|
414 } |
5640 | 415 |
8361
2202c00001e3
overlapping subtitles support is now optional, can be disabled (-nooverlapsub)
arpi
parents:
8123
diff
changeset
|
416 /* |
2202c00001e3
overlapping subtitles support is now optional, can be disabled (-nooverlapsub)
arpi
parents:
8123
diff
changeset
|
417 Here is the little increment we talked about before. '40' is the |
2202c00001e3
overlapping subtitles support is now optional, can be disabled (-nooverlapsub)
arpi
parents:
8123
diff
changeset
|
418 ASCII code for '(', which, hopefully, is the highest char of the |
2202c00001e3
overlapping subtitles support is now optional, can be disabled (-nooverlapsub)
arpi
parents:
8123
diff
changeset
|
419 font. |
2202c00001e3
overlapping subtitles support is now optional, can be disabled (-nooverlapsub)
arpi
parents:
8123
diff
changeset
|
420 *sfalco* |
2202c00001e3
overlapping subtitles support is now optional, can be disabled (-nooverlapsub)
arpi
parents:
8123
diff
changeset
|
421 */ |
2202c00001e3
overlapping subtitles support is now optional, can be disabled (-nooverlapsub)
arpi
parents:
8123
diff
changeset
|
422 if(suboverlap_enabled) obj->y -= vo_font->pic_a[vo_font->font[40]]->h - vo_font->height; |
8534
922ce27eb683
This patch adds support for vertical subtitle alignment
arpi
parents:
8451
diff
changeset
|
423 |
922ce27eb683
This patch adds support for vertical subtitle alignment
arpi
parents:
8451
diff
changeset
|
424 h = dys - obj->y; |
922ce27eb683
This patch adds support for vertical subtitle alignment
arpi
parents:
8451
diff
changeset
|
425 if (sub_alignment == 2) |
922ce27eb683
This patch adds support for vertical subtitle alignment
arpi
parents:
8451
diff
changeset
|
426 obj->y = dys * sub_pos / 100 - h; |
922ce27eb683
This patch adds support for vertical subtitle alignment
arpi
parents:
8451
diff
changeset
|
427 else if (sub_alignment == 1) |
922ce27eb683
This patch adds support for vertical subtitle alignment
arpi
parents:
8451
diff
changeset
|
428 obj->y = dys * sub_pos / 100 - h / 2; |
922ce27eb683
This patch adds support for vertical subtitle alignment
arpi
parents:
8451
diff
changeset
|
429 else |
922ce27eb683
This patch adds support for vertical subtitle alignment
arpi
parents:
8451
diff
changeset
|
430 obj->y = dys * sub_pos / 100; |
922ce27eb683
This patch adds support for vertical subtitle alignment
arpi
parents:
8451
diff
changeset
|
431 |
922ce27eb683
This patch adds support for vertical subtitle alignment
arpi
parents:
8451
diff
changeset
|
432 if (obj->y < 0) |
922ce27eb683
This patch adds support for vertical subtitle alignment
arpi
parents:
8451
diff
changeset
|
433 obj->y = 0; |
922ce27eb683
This patch adds support for vertical subtitle alignment
arpi
parents:
8451
diff
changeset
|
434 if (obj->y > dys - h) |
922ce27eb683
This patch adds support for vertical subtitle alignment
arpi
parents:
8451
diff
changeset
|
435 obj->y = dys - h; |
922ce27eb683
This patch adds support for vertical subtitle alignment
arpi
parents:
8451
diff
changeset
|
436 |
922ce27eb683
This patch adds support for vertical subtitle alignment
arpi
parents:
8451
diff
changeset
|
437 obj->bbox.y2 = obj->y + h; |
922ce27eb683
This patch adds support for vertical subtitle alignment
arpi
parents:
8451
diff
changeset
|
438 |
5640 | 439 // calculate bbox: |
440 obj->bbox.x1=xmin; | |
441 obj->bbox.x2=xmax; | |
442 obj->bbox.y1=obj->y; | |
5664 | 443 // obj->bbox.y2=obj->y+obj->params.subtitle.lines*vo_font->height; |
5640 | 444 obj->flags|=OSDFLAG_BBOX; |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
445 |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
446 alloc_buf(obj); |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
447 |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
448 y = obj->y; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
449 |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
450 i=j=0; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
451 if ((l=obj->params.subtitle.lines)) for (;;) { |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
452 x=obj->params.subtitle.xtbl[i++]; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
453 prevc = -1; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
454 while ((c=obj->params.subtitle.utbl[j++])){ |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
455 x += kerning(vo_font,prevc,c); |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
456 if ((font=vo_font->font[c])>=0) |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
457 draw_alpha_buf(obj,x,y, |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
458 vo_font->width[c], |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
459 vo_font->pic_a[font]->h+y<obj->dys ? vo_font->pic_a[font]->h : obj->dys-y, |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
460 vo_font->pic_b[font]->bmp+vo_font->start[c], |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
461 vo_font->pic_a[font]->bmp+vo_font->start[c], |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
462 vo_font->pic_a[font]->w); |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
463 x+=vo_font->width[c]+vo_font->charspace; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
464 prevc = c; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
465 } |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
466 if (!--l) break; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
467 y+=vo_font->height; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
468 } |
5640 | 469 |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
470 } |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
471 |
6190
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
472 inline static void vo_update_spudec_sub(mp_osd_obj_t* obj, int dxs, int dys) |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
473 { |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
474 unsigned int bbox[4]; |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
475 spudec_calc_bbox(vo_spudec, dxs, dys, bbox); |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
476 obj->bbox.x1 = bbox[0]; |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
477 obj->bbox.x2 = bbox[1]; |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
478 obj->bbox.y1 = bbox[2]; |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
479 obj->bbox.y2 = bbox[3]; |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
480 obj->flags |= OSDFLAG_BBOX; |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
481 } |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
482 |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
483 inline static void vo_draw_spudec_sub(mp_osd_obj_t* obj, void (*draw_alpha)(int x0, int y0, int w, int h, unsigned char* src, unsigned char* srca, int stride)) |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
484 { |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
485 spudec_draw_scaled(vo_spudec, obj->dxs, obj->dys, draw_alpha); |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
486 } |
218 | 487 |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
2498
diff
changeset
|
488 void *vo_spudec=NULL; |
4081
9e581ab5e54b
Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents:
3180
diff
changeset
|
489 void *vo_vobsub=NULL; |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
2498
diff
changeset
|
490 |
947
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
865
diff
changeset
|
491 static int draw_alpha_init_flag=0; |
218 | 492 |
1109 | 493 extern void vo_draw_alpha_init(); |
494 | |
7067
b395b1240954
fix dxr3 subtitle handling and add some optimizations
pontscho
parents:
7003
diff
changeset
|
495 mp_osd_obj_t* vo_osd_list=NULL; |
218 | 496 |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
497 mp_osd_obj_t* new_osd_obj(int type){ |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
498 mp_osd_obj_t* osd=malloc(sizeof(mp_osd_obj_t)); |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
499 memset(osd,0,sizeof(mp_osd_obj_t)); |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
500 osd->next=vo_osd_list; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
501 vo_osd_list=osd; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
502 osd->type=type; |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
503 osd->alpha_buffer = NULL; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
504 osd->bitmap_buffer = NULL; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
505 osd->allocated = -1; |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
506 return osd; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
507 } |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
508 |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
509 void free_osd_list(){ |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
510 mp_osd_obj_t* obj=vo_osd_list; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
511 while(obj){ |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
512 mp_osd_obj_t* next=obj->next; |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
513 if (obj->alpha_buffer) free(obj->alpha_buffer); |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
514 if (obj->bitmap_buffer) free(obj->bitmap_buffer); |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
515 free(obj); |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
516 obj=next; |
4081
9e581ab5e54b
Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents:
3180
diff
changeset
|
517 } |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
518 vo_osd_list=NULL; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
519 } |
4081
9e581ab5e54b
Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents:
3180
diff
changeset
|
520 |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
521 int vo_update_osd(int dxs,int dys){ |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
522 mp_osd_obj_t* obj=vo_osd_list; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
523 int chg=0; |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
524 |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
525 #ifdef HAVE_FREETYPE |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
526 // here is the right place to get screen dimensions |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
527 if (force_load_font) { |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
528 force_load_font = 0; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
529 load_font(dxs, dys); |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
530 } |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
531 #endif |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
532 |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
533 while(obj){ |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
534 if(dxs!=obj->dxs || dys!=obj->dys || obj->flags&OSDFLAG_FORCE_UPDATE){ |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
535 int vis=obj->flags&OSDFLAG_VISIBLE; |
5640 | 536 obj->flags&=~OSDFLAG_BBOX; |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
537 switch(obj->type){ |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
538 case OSDTYPE_SUBTITLE: |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
539 vo_update_text_sub(obj,dxs,dys); |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
540 break; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
541 case OSDTYPE_PROGBAR: |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
542 vo_update_text_progbar(obj,dxs,dys); |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
543 break; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
544 case OSDTYPE_SPU: |
7628
d6608342591d
This patch adds the functionality to disable/enable subtitles while playing
arpi
parents:
7121
diff
changeset
|
545 if(sub_visibility && vo_spudec && spudec_visible(vo_spudec)){ |
6190
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
546 vo_update_spudec_sub(obj, dxs, dys); |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
547 obj->flags|=OSDFLAG_VISIBLE|OSDFLAG_CHANGED; |
6190
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
548 } |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
549 else |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
550 obj->flags&=~OSDFLAG_VISIBLE; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
551 break; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
552 case OSDTYPE_OSD: |
5640 | 553 if(vo_font && vo_osd_text && vo_osd_text[0]){ |
554 vo_update_text_osd(obj,dxs,dys); // update bbox | |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
555 obj->flags|=OSDFLAG_VISIBLE|OSDFLAG_CHANGED; |
5640 | 556 } else |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
557 obj->flags&=~OSDFLAG_VISIBLE; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
558 break; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
559 } |
5640 | 560 // check bbox: |
561 if(!(obj->flags&OSDFLAG_BBOX)){ | |
562 // we don't know, so assume the whole screen changed :( | |
563 obj->bbox.x1=obj->bbox.y1=0; | |
564 obj->bbox.x2=dxs; | |
565 obj->bbox.y2=dys; | |
566 obj->flags|=OSDFLAG_BBOX; | |
5664 | 567 } else { |
568 // check bbox, reduce it if it's out of bounds (corners): | |
569 if(obj->bbox.x1<0) obj->bbox.x1=0; | |
570 if(obj->bbox.y1<0) obj->bbox.y1=0; | |
571 if(obj->bbox.x2>dxs) obj->bbox.x2=dxs; | |
572 if(obj->bbox.y2>dys) obj->bbox.y2=dys; | |
573 if(obj->flags&OSDFLAG_VISIBLE) | |
574 // debug: | |
575 mp_msg(MSGT_OSD,MSGL_DBG2,"OSD update: %d;%d %dx%d \n", | |
5640 | 576 obj->bbox.x1,obj->bbox.y1,obj->bbox.x2-obj->bbox.x1, |
577 obj->bbox.y2-obj->bbox.y1); | |
578 } | |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
579 // check if visibility changed: |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
580 if(vis != (obj->flags&OSDFLAG_VISIBLE) ) obj->flags|=OSDFLAG_CHANGED; |
5640 | 581 // remove the cause of automatic update: |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
582 obj->dxs=dxs; obj->dys=dys; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
583 obj->flags&=~OSDFLAG_FORCE_UPDATE; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
584 } |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
585 if(obj->flags&OSDFLAG_CHANGED){ |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
586 chg|=1<<obj->type; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
587 mp_msg(MSGT_OSD,MSGL_DBG2,"OSD chg: %d V: %s pb:%d \n",obj->type,(obj->flags&OSDFLAG_VISIBLE)?"yes":"no",vo_osd_progbar_type); |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
588 } |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
589 obj=obj->next; |
4081
9e581ab5e54b
Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents:
3180
diff
changeset
|
590 } |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
591 return chg; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
592 } |
4081
9e581ab5e54b
Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents:
3180
diff
changeset
|
593 |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
594 void vo_init_osd(){ |
947
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
865
diff
changeset
|
595 if(!draw_alpha_init_flag){ |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
865
diff
changeset
|
596 draw_alpha_init_flag=1; |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
865
diff
changeset
|
597 vo_draw_alpha_init(); |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
865
diff
changeset
|
598 } |
6110 | 599 if(vo_osd_list) free_osd_list(); |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
600 // temp hack, should be moved to mplayer/mencoder later |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
601 new_osd_obj(OSDTYPE_OSD); |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
602 new_osd_obj(OSDTYPE_SUBTITLE); |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
603 new_osd_obj(OSDTYPE_PROGBAR); |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
604 new_osd_obj(OSDTYPE_SPU); |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
605 #ifdef HAVE_FREETYPE |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
606 force_load_font = 1; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
607 #endif |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
608 } |
947
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
865
diff
changeset
|
609 |
5642
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
610 int vo_osd_changed_flag=0; |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
611 |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
612 void vo_remove_text(int dxs,int dys,void (*remove)(int x0,int y0, int w,int h)){ |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
613 mp_osd_obj_t* obj=vo_osd_list; |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
614 vo_update_osd(dxs,dys); |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
615 while(obj){ |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
616 if(((obj->flags&OSDFLAG_CHANGED) || (obj->flags&OSDFLAG_VISIBLE)) && |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
617 (obj->flags&OSDFLAG_OLD_BBOX)){ |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
618 int w=obj->old_bbox.x2-obj->old_bbox.x1; |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
619 int h=obj->old_bbox.y2-obj->old_bbox.y1; |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
620 if(w>0 && h>0){ |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
621 vo_osd_changed_flag=obj->flags&OSDFLAG_CHANGED; // temp hack |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
622 remove(obj->old_bbox.x1,obj->old_bbox.y1,w,h); |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
623 } |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
624 // obj->flags&=~OSDFLAG_OLD_BBOX; |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
625 } |
5645 | 626 obj=obj->next; |
5642
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
627 } |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
628 } |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
629 |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
630 void vo_draw_text(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)){ |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
631 mp_osd_obj_t* obj=vo_osd_list; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
632 vo_update_osd(dxs,dys); |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
633 while(obj){ |
5642
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
634 if(obj->flags&OSDFLAG_VISIBLE){ |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
635 vo_osd_changed_flag=obj->flags&OSDFLAG_CHANGED; // temp hack |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
636 switch(obj->type){ |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
637 case OSDTYPE_SPU: |
6190
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
638 vo_draw_spudec_sub(obj, draw_alpha); // FIXME |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
639 break; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
640 case OSDTYPE_OSD: |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
641 case OSDTYPE_SUBTITLE: |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
642 case OSDTYPE_PROGBAR: |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
643 vo_draw_text_from_buffer(obj,draw_alpha); |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
644 break; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
645 } |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
646 obj->old_bbox=obj->bbox; |
5642
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
647 obj->flags|=OSDFLAG_OLD_BBOX; |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
648 } |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
649 obj->flags&=~OSDFLAG_CHANGED; |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
650 obj=obj->next; |
218 | 651 } |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
652 } |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
2498
diff
changeset
|
653 |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4773
diff
changeset
|
654 static int vo_osd_changed_status = 0; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4773
diff
changeset
|
655 |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4773
diff
changeset
|
656 int vo_osd_changed(int new_value) |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4773
diff
changeset
|
657 { |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
658 mp_osd_obj_t* obj=vo_osd_list; |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4773
diff
changeset
|
659 int ret = vo_osd_changed_status; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4773
diff
changeset
|
660 vo_osd_changed_status = new_value; |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
661 |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
662 while(obj){ |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
663 if(obj->type==new_value) obj->flags|=OSDFLAG_FORCE_UPDATE; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
664 obj=obj->next; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
665 } |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
666 |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4773
diff
changeset
|
667 return ret; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4773
diff
changeset
|
668 } |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
669 |
5645 | 670 // BBBBBBBBBBBB AAAAAAAAAAAAA BBBBBBBBBBB |
671 // BBBBBBBBBBBB BBBBBBBBBBBBB | |
672 // BBBBBBB | |
673 | |
674 // return TRUE if we have osd in the specified rectangular area: | |
675 int vo_osd_check_range_update(int x1,int y1,int x2,int y2){ | |
676 mp_osd_obj_t* obj=vo_osd_list; | |
677 while(obj){ | |
678 if(obj->flags&OSDFLAG_VISIBLE){ | |
679 if( (obj->bbox.x1<=x2 && obj->bbox.x2>=x1) && | |
680 (obj->bbox.y1<=y2 && obj->bbox.y2>=y1) ) return 1; | |
681 } | |
682 obj=obj->next; | |
683 } | |
684 return 0; | |
685 } |