Mercurial > mplayer.hg
annotate libvo/sub.c @ 23457:a124f3abc1ec
Replace implicit use of fast_memcpy via macro by explicit use to allow
for future optimization.
author | reimar |
---|---|
date | Tue, 05 Jun 2007 14:27:54 +0000 |
parents | 2a66d95355f0 |
children | a6c619ee9d30 |
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 |
21193
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
19366
diff
changeset
|
11 #ifdef USE_DVDNAV |
21200 | 12 #include "stream/stream.h" |
13 #include "stream/stream_dvdnav.h" | |
21193
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
19366
diff
changeset
|
14 #define OSD_NAV_BOX_ALPHA 0x7f |
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
19366
diff
changeset
|
15 #endif |
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
19366
diff
changeset
|
16 |
23338
2a66d95355f0
add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents:
21582
diff
changeset
|
17 #include "mplayer.h" |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
18 #include "mp_msg.h" |
16923
a6a03ff1ddef
Added translatable messages for OSD localization to help/help_mp-en.h
ptt
parents:
16839
diff
changeset
|
19 #include "help_mp.h" |
4088 | 20 #include "video_out.h" |
5294 | 21 #include "font_load.h" |
218 | 22 #include "sub.h" |
13787
e047e70a9767
Handle "xxx.h" vs "../xxx.h" include paths in a consistent way.
diego
parents:
13343
diff
changeset
|
23 #include "spudec.h" |
19366 | 24 #include "libavutil/common.h" |
202 | 25 |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
26 #define NEW_SPLITTING |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
27 |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
28 |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
29 // Structures needed for the new splitting algorithm. |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
30 // osd_text_t contains the single subtitle word. |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
31 // osd_text_p is used to mark the lines of subtitles |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
32 struct osd_text_t { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
33 int osd_kerning, //kerning with the previous word |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
34 osd_length, //orizontal length inside the bbox |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
35 text_length, //number of characters |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
36 *text; //characters |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
37 struct osd_text_t *prev, |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
38 *next; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
39 }; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
40 |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
41 struct osd_text_p { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
42 int value; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
43 struct osd_text_t *ott; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
44 struct osd_text_p *prev, |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
45 *next; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
46 }; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
47 //^ |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
48 |
2498 | 49 char * __sub_osd_names[]={ |
16923
a6a03ff1ddef
Added translatable messages for OSD localization to help/help_mp-en.h
ptt
parents:
16839
diff
changeset
|
50 MSGTR_VO_SUB_Seekbar, |
a6a03ff1ddef
Added translatable messages for OSD localization to help/help_mp-en.h
ptt
parents:
16839
diff
changeset
|
51 MSGTR_VO_SUB_Play, |
a6a03ff1ddef
Added translatable messages for OSD localization to help/help_mp-en.h
ptt
parents:
16839
diff
changeset
|
52 MSGTR_VO_SUB_Pause, |
a6a03ff1ddef
Added translatable messages for OSD localization to help/help_mp-en.h
ptt
parents:
16839
diff
changeset
|
53 MSGTR_VO_SUB_Stop, |
a6a03ff1ddef
Added translatable messages for OSD localization to help/help_mp-en.h
ptt
parents:
16839
diff
changeset
|
54 MSGTR_VO_SUB_Rewind, |
a6a03ff1ddef
Added translatable messages for OSD localization to help/help_mp-en.h
ptt
parents:
16839
diff
changeset
|
55 MSGTR_VO_SUB_Forward, |
a6a03ff1ddef
Added translatable messages for OSD localization to help/help_mp-en.h
ptt
parents:
16839
diff
changeset
|
56 MSGTR_VO_SUB_Clock, |
a6a03ff1ddef
Added translatable messages for OSD localization to help/help_mp-en.h
ptt
parents:
16839
diff
changeset
|
57 MSGTR_VO_SUB_Contrast, |
a6a03ff1ddef
Added translatable messages for OSD localization to help/help_mp-en.h
ptt
parents:
16839
diff
changeset
|
58 MSGTR_VO_SUB_Saturation, |
a6a03ff1ddef
Added translatable messages for OSD localization to help/help_mp-en.h
ptt
parents:
16839
diff
changeset
|
59 MSGTR_VO_SUB_Volume, |
a6a03ff1ddef
Added translatable messages for OSD localization to help/help_mp-en.h
ptt
parents:
16839
diff
changeset
|
60 MSGTR_VO_SUB_Brightness, |
a6a03ff1ddef
Added translatable messages for OSD localization to help/help_mp-en.h
ptt
parents:
16839
diff
changeset
|
61 MSGTR_VO_SUB_Hue |
2498 | 62 }; |
63 char * __sub_osd_names_short[] ={ "", "|>", "||", "[]", "<<" , ">>", "", "", "", "", "", ""}; | |
64 | |
213 | 65 //static int vo_font_loaded=-1; |
66 font_desc_t* vo_font=NULL; | |
23338
2a66d95355f0
add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents:
21582
diff
changeset
|
67 font_desc_t* sub_font=NULL; |
202 | 68 |
1991
dee4b2ea5e5b
add gui support to config scripts, and fixed some warning.
pontscho
parents:
1878
diff
changeset
|
69 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
|
70 int sub_unicode=0; |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
71 int sub_utf8=0; |
4773 | 72 int sub_pos=100; |
8583 | 73 int sub_width_p=100; |
16839
1b1b59b160ab
make bottom alignment the default since it's the only sane mode when sub_pos is near bottom (default)
rfelker
parents:
16838
diff
changeset
|
74 int sub_alignment=2; /* 0=top, 1=center, 2=bottom */ |
7628
d6608342591d
This patch adds the functionality to disable/enable subtitles while playing
arpi
parents:
7121
diff
changeset
|
75 int sub_visibility=1; |
8617
6ffbe7608013
Me: -sub-bg-* would be nicer. "Background" is usually shortened as "bg", not "bkg".
rathann
parents:
8601
diff
changeset
|
76 int sub_bg_color=0; /* subtitles background color */ |
6ffbe7608013
Me: -sub-bg-* would be nicer. "Background" is usually shortened as "bg", not "bkg".
rathann
parents:
8601
diff
changeset
|
77 int sub_bg_alpha=0; |
10263 | 78 int sub_justify=0; |
21219 | 79 #ifdef USE_DVDNAV |
80 static nav_highlight_t nav_hl; | |
81 #endif | |
213 | 82 |
5664 | 83 // return the real height of a char: |
84 static inline int get_height(int c,int h){ | |
85 int font; | |
86 if ((font=vo_font->font[c])>=0) | |
87 if(h<vo_font->pic_a[font]->h) h=vo_font->pic_a[font]->h; | |
88 return h; | |
89 } | |
90 | |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
91 // 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
|
92 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
|
93 { |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
94 int dststride = obj->stride; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
95 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
|
96 int srcskip = stride-w; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
97 int i, j; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
98 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
|
99 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
|
100 unsigned char *bs = src; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
101 unsigned char *as = srca; |
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 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
|
104 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
|
105 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
|
106 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
|
107 return; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
108 } |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
109 |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
110 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
|
111 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
|
112 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
|
113 if (*as) { |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
114 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
|
115 } |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
116 } |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
117 b+= dstskip; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
118 a+= dstskip; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
119 bs+= srcskip; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
120 as+= srcskip; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
121 } |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
122 } |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
123 |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
124 // 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
|
125 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
|
126 { |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
127 int len; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
128 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
|
129 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
|
130 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
|
131 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
|
132 if (obj->allocated<len) { |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
133 obj->allocated = len; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
134 free(obj->bitmap_buffer); |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
135 free(obj->alpha_buffer); |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
136 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
|
137 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
|
138 } |
8617
6ffbe7608013
Me: -sub-bg-* would be nicer. "Background" is usually shortened as "bg", not "bkg".
rathann
parents:
8601
diff
changeset
|
139 memset(obj->bitmap_buffer, sub_bg_color, len); |
6ffbe7608013
Me: -sub-bg-* would be nicer. "Background" is usually shortened as "bg", not "bkg".
rathann
parents:
8601
diff
changeset
|
140 memset(obj->alpha_buffer, sub_bg_alpha, len); |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
141 } |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
142 |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
143 // renders the buffer |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
144 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
|
145 if (obj->allocated > 0) { |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
146 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
|
147 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
|
148 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
|
149 obj->bitmap_buffer, |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
150 obj->alpha_buffer, |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
151 obj->stride); |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
152 } |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
153 } |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
154 |
21582
239f2c145b2f
Mark utf8_get_char parameter as const and fix a compiler warning
reimar
parents:
21581
diff
changeset
|
155 unsigned utf8_get_char(const char **str) { |
239f2c145b2f
Mark utf8_get_char parameter as const and fix a compiler warning
reimar
parents:
21581
diff
changeset
|
156 const uint8_t *strp = (const uint8_t *)*str; |
19366 | 157 unsigned c; |
158 GET_UTF8(c, *strp++, goto no_utf8;); | |
21582
239f2c145b2f
Mark utf8_get_char parameter as const and fix a compiler warning
reimar
parents:
21581
diff
changeset
|
159 *str = (const char *)strp; |
18717 | 160 return c; |
161 | |
162 no_utf8: | |
21582
239f2c145b2f
Mark utf8_get_char parameter as const and fix a compiler warning
reimar
parents:
21581
diff
changeset
|
163 strp = (const uint8_t *)*str; |
18717 | 164 c = *strp++; |
21582
239f2c145b2f
Mark utf8_get_char parameter as const and fix a compiler warning
reimar
parents:
21581
diff
changeset
|
165 *str = (const char *)strp; |
18717 | 166 return c; |
167 } | |
168 | |
5640 | 169 inline static void vo_update_text_osd(mp_osd_obj_t* obj,int dxs,int dys){ |
21582
239f2c145b2f
Mark utf8_get_char parameter as const and fix a compiler warning
reimar
parents:
21581
diff
changeset
|
170 const char *cp=vo_osd_text; |
5640 | 171 int x=20; |
5664 | 172 int h=0; |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
173 int font; |
5640 | 174 |
175 obj->bbox.x1=obj->x=x; | |
176 obj->bbox.y1=obj->y=10; | |
202 | 177 |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
178 while (*cp){ |
18717 | 179 uint16_t c=utf8_get_char(&cp); |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
180 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
|
181 x+=vo_font->width[c]+vo_font->charspace; |
5664 | 182 h=get_height(c,h); |
5640 | 183 } |
184 | |
5664 | 185 obj->bbox.x2=x-vo_font->charspace; |
186 obj->bbox.y2=obj->bbox.y1+h; | |
5640 | 187 obj->flags|=OSDFLAG_BBOX; |
188 | |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
189 alloc_buf(obj); |
5640 | 190 |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
191 cp=vo_osd_text; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
192 x = obj->x; |
5640 | 193 while (*cp){ |
18717 | 194 uint16_t c=utf8_get_char(&cp); |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
195 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
|
196 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
|
197 vo_font->width[c], |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
198 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
|
199 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
|
200 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
|
201 vo_font->pic_a[font]->w); |
213 | 202 x+=vo_font->width[c]+vo_font->charspace; |
203 } | |
218 | 204 } |
205 | |
21193
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
19366
diff
changeset
|
206 #ifdef USE_DVDNAV |
21219 | 207 void osd_set_nav_box (uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey) { |
208 nav_hl.sx = sx; | |
209 nav_hl.sy = sy; | |
210 nav_hl.ex = ex; | |
211 nav_hl.ey = ey; | |
212 } | |
213 | |
21193
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
19366
diff
changeset
|
214 inline static void vo_update_nav (mp_osd_obj_t *obj, int dxs, int dys) { |
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
19366
diff
changeset
|
215 int len; |
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
19366
diff
changeset
|
216 |
21219 | 217 obj->bbox.x1 = obj->x = nav_hl.sx; |
218 obj->bbox.y1 = obj->y = nav_hl.sy; | |
219 obj->bbox.x2 = nav_hl.ex; | |
220 obj->bbox.y2 = nav_hl.ey; | |
21193
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
19366
diff
changeset
|
221 |
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
19366
diff
changeset
|
222 alloc_buf (obj); |
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
19366
diff
changeset
|
223 len = obj->stride * (obj->bbox.y2 - obj->bbox.y1); |
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
19366
diff
changeset
|
224 memset (obj->bitmap_buffer, OSD_NAV_BOX_ALPHA, len); |
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
19366
diff
changeset
|
225 memset (obj->alpha_buffer, OSD_NAV_BOX_ALPHA, len); |
21364
d81ffbf9615f
EMISSINGBRAIN: No, OSD objects of size 0 sure are _not_ visible.
reimar
parents:
21219
diff
changeset
|
226 obj->flags |= OSDFLAG_BBOX | OSDFLAG_CHANGED; |
d81ffbf9615f
EMISSINGBRAIN: No, OSD objects of size 0 sure are _not_ visible.
reimar
parents:
21219
diff
changeset
|
227 if (obj->bbox.y2 > obj->bbox.y1 && obj->bbox.x2 > obj->bbox.x1) |
d81ffbf9615f
EMISSINGBRAIN: No, OSD objects of size 0 sure are _not_ visible.
reimar
parents:
21219
diff
changeset
|
228 obj->flags |= OSDFLAG_VISIBLE; |
21193
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
19366
diff
changeset
|
229 } |
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
19366
diff
changeset
|
230 #endif |
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
19366
diff
changeset
|
231 |
218 | 232 int vo_osd_progbar_type=-1; |
1726 | 233 int vo_osd_progbar_value=100; // 0..256 |
234 | |
235 // if we have n=256 bars then OSD progbar looks like below | |
236 // | |
1878 | 237 // 0 1 2 3 ... 256 <= vo_osd_progbar_value |
238 // | | | | | | |
1726 | 239 // [ === === === ... === ] |
240 // | |
241 // the above schema is rescalled to n=elems bars | |
218 | 242 |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
243 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
|
244 |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
245 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
|
246 |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
247 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
|
248 obj->flags&=~OSDFLAG_VISIBLE; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
249 return; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
250 } |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
251 |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
252 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
|
253 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
|
254 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
|
255 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
|
256 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
|
257 |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
258 // calculate bbox corners: |
5664 | 259 { int h=0; |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
260 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
|
261 int delimw=vo_font->width[OSD_PB_START] |
1549 | 262 +vo_font->width[OSD_PB_END] |
263 +vo_font->charspace; | |
1548
eee7951a23af
changes according to proper subfont bar positioning and char spaceing - sub.c
atlka
parents:
1524
diff
changeset
|
264 int width=(2*dxs-3*delimw)/3; |
1549 | 265 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
|
266 int elems=width/charw; |
1549 | 267 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
|
268 int delta = 0; |
5664 | 269 h=get_height(OSD_PB_START,h); |
270 h=get_height(OSD_PB_END,h); | |
271 h=get_height(OSD_PB_0,h); | |
272 h=get_height(OSD_PB_1,h); | |
8422 | 273 if (vo_osd_progbar_type>0 && vo_font->font[vo_osd_progbar_type]>=0){ |
274 delta = vo_font->width[vo_osd_progbar_type]+vo_font->spacewidth; | |
275 delta = (x-delta > 0) ? delta : x; | |
276 h=get_height(vo_osd_progbar_type,h); | |
277 } | |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
278 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
|
279 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
|
280 obj->bbox.x2=x+width+delimw; |
5664 | 281 obj->bbox.y2=y+h; //vo_font->height; |
5640 | 282 obj->flags|=OSDFLAG_BBOX; |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
283 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
|
284 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
|
285 } |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
286 |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
287 alloc_buf(obj); |
8794 | 288 |
289 { | |
290 int minw = vo_font->width[OSD_PB_START]+vo_font->width[OSD_PB_END]+vo_font->width[OSD_PB_0]; | |
291 if (vo_osd_progbar_type>0 && vo_font->font[vo_osd_progbar_type]>=0){ | |
292 minw += vo_font->width[vo_osd_progbar_type]+vo_font->charspace+vo_font->spacewidth; | |
293 } | |
294 if (obj->bbox.x2 - obj->bbox.x1 < minw) return; // space too small, don't render anything | |
295 } | |
296 | |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
297 // render it: |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
298 { unsigned char *s; |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
299 unsigned char *sa; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
300 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
|
301 int x=obj->x; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
302 int y=obj->y; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
303 int c,font; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
304 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
|
305 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
|
306 |
1726 | 307 if (vo_osd_progbar_value<=0) |
308 mark=0; | |
1878 | 309 else { |
310 int ev=vo_osd_progbar_value*elems; | |
311 mark=ev>>8; | |
312 if (ev & 0xFF) mark++; | |
313 if (mark>elems) mark=elems; | |
314 } | |
315 | |
1727 | 316 |
218 | 317 // printf("osd.progbar width=%d xpos=%d\n",width,x); |
318 | |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
319 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
|
320 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
|
321 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
|
322 draw_alpha_buf(obj,(xp<0?0:xp),y, |
218 | 323 vo_font->width[c], |
324 vo_font->pic_a[font]->h, | |
325 vo_font->pic_b[font]->bmp+vo_font->start[c], | |
326 vo_font->pic_a[font]->bmp+vo_font->start[c], | |
327 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
|
328 } |
fcbfc99cf8e6
skip lines with negative y position if there is too many lines to display
atlka
parents:
1549
diff
changeset
|
329 |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
330 c=OSD_PB_START; |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
331 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
|
332 draw_alpha_buf(obj,x,y, |
218 | 333 vo_font->width[c], |
334 vo_font->pic_a[font]->h, | |
335 vo_font->pic_b[font]->bmp+vo_font->start[c], | |
336 vo_font->pic_a[font]->bmp+vo_font->start[c], | |
337 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
|
338 x+=vo_font->width[c]+vo_font->charspace; |
218 | 339 |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
340 c=OSD_PB_0; |
1602 | 341 if ((font=vo_font->font[c])>=0){ |
342 w=vo_font->width[c]; | |
343 h=vo_font->pic_a[font]->h; | |
344 s=vo_font->pic_b[font]->bmp+vo_font->start[c]; | |
345 sa=vo_font->pic_a[font]->bmp+vo_font->start[c]; | |
346 st=vo_font->pic_a[font]->w; | |
2204 | 347 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
|
348 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
|
349 x+=charw; |
2204 | 350 } while(--i); |
1602 | 351 } |
202 | 352 |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
353 c=OSD_PB_1; |
1602 | 354 if ((font=vo_font->font[c])>=0){ |
355 w=vo_font->width[c]; | |
356 h=vo_font->pic_a[font]->h; | |
357 s =vo_font->pic_b[font]->bmp+vo_font->start[c]; | |
358 sa=vo_font->pic_a[font]->bmp+vo_font->start[c]; | |
359 st=vo_font->pic_a[font]->w; | |
2204 | 360 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
|
361 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
|
362 x+=charw; |
2204 | 363 } while(--i); |
1602 | 364 } |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
365 |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
366 c=OSD_PB_END; |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
367 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
|
368 draw_alpha_buf(obj,x,y, |
218 | 369 vo_font->width[c], |
370 vo_font->pic_a[font]->h, | |
371 vo_font->pic_b[font]->bmp+vo_font->start[c], | |
372 vo_font->pic_a[font]->bmp+vo_font->start[c], | |
373 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
|
374 // 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
|
375 |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
376 } |
218 | 377 // vo_osd_progbar_value=(vo_osd_progbar_value+1)&0xFF; |
378 | |
379 } | |
380 | |
254 | 381 subtitle* vo_sub=NULL; |
218 | 382 |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
383 // 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 | 384 |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
385 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
|
386 unsigned char *t; |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
387 int c,i,j,l,x,y,font,prevc,counter; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
388 int k; |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
389 int lastStripPosition; |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
390 int xsize; |
5640 | 391 int xmin=dxs,xmax=0; |
1591 | 392 int h,lasth; |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
393 int xtblc, utblc; |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
394 |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
395 obj->flags|=OSDFLAG_CHANGED|OSDFLAG_VISIBLE; |
7628
d6608342591d
This patch adds the functionality to disable/enable subtitles while playing
arpi
parents:
7121
diff
changeset
|
396 |
23338
2a66d95355f0
add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents:
21582
diff
changeset
|
397 if(!vo_sub || !sub_font || !sub_visibility || (sub_font->font[40]<0)){ |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
398 obj->flags&=~OSDFLAG_VISIBLE; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
399 return; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
400 } |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
401 |
5664 | 402 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
|
403 obj->params.subtitle.lines=0; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
404 |
1602 | 405 // 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
|
406 i=k=lasth=0; |
23338
2a66d95355f0
add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents:
21582
diff
changeset
|
407 h=sub_font->height; |
1591 | 408 lastStripPosition=-1; |
409 l=vo_sub->lines; | |
410 | |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
411 { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
412 struct osd_text_t *osl, *cp_ott, *tmp_ott, *tmp; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
413 struct osd_text_p *otp_sub = NULL, *otp_sub_tmp, // these are used to store the whole sub text osd |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
414 *otp, *tmp_otp, *pmt; // these are used to manage sub text osd coming from a single sub line |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
415 int *char_seq, char_position, xlimit = dxs * sub_width_p / 100, counter; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
416 |
2204 | 417 while (l) { |
23338
2a66d95355f0
add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents:
21582
diff
changeset
|
418 xsize = -sub_font->charspace; |
2204 | 419 l--; |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
420 t=vo_sub->text[i++]; |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
421 char_position = 0; |
21581 | 422 char_seq = calloc(strlen(t), sizeof(int)); |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
423 |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
424 prevc = -1; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
425 |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
426 otp = NULL; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
427 osl = NULL; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
428 x = 1; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
429 |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
430 // reading the subtitle words from vo_sub->text[] |
21580 | 431 while (*t) { |
432 if (sub_utf8) | |
433 c = utf8_get_char(&t); | |
434 else if ((c = *t++) >= 0x80 && sub_unicode) | |
435 c = (c<<8) + *t++; | |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
436 if (k==MAX_UCS){ |
21580 | 437 t += strlen(t); // end here |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
438 mp_msg(MSGT_OSD,MSGL_WARN,"\nMAX_UCS exceeded!\n"); |
1591 | 439 } |
2204 | 440 if (!c) c++; // avoid UCS 0 |
23338
2a66d95355f0
add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents:
21582
diff
changeset
|
441 render_one_glyph(sub_font, c); |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
442 |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
443 if (c == ' ') { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
444 struct osd_text_t *tmp_ott = (struct osd_text_t *) calloc(1, sizeof(struct osd_text_t)); |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
445 |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
446 if (osl == NULL) { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
447 osl = cp_ott = tmp_ott; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
448 } else { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
449 tmp_ott->prev = cp_ott; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
450 cp_ott->next = tmp_ott; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
451 tmp_ott->osd_kerning = |
23338
2a66d95355f0
add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents:
21582
diff
changeset
|
452 sub_font->charspace + sub_font->width[' ']; |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
453 cp_ott = tmp_ott; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
454 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
455 tmp_ott->osd_length = xsize; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
456 tmp_ott->text_length = char_position; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
457 tmp_ott->text = (int *) malloc(char_position * sizeof(int)); |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
458 for (counter = 0; counter < char_position; ++counter) |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
459 tmp_ott->text[counter] = char_seq[counter]; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
460 char_position = 0; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
461 xsize = 0; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
462 prevc = c; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
463 } else { |
23338
2a66d95355f0
add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents:
21582
diff
changeset
|
464 int delta_xsize = sub_font->width[c] + sub_font->charspace + kerning(sub_font, prevc, c); |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
465 |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
466 if (xsize + delta_xsize <= dxs) { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
467 if (!x) x = 1; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
468 prevc = c; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
469 char_seq[char_position++] = c; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
470 xsize += delta_xsize; |
23338
2a66d95355f0
add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents:
21582
diff
changeset
|
471 if ((!suboverlap_enabled) && ((font = sub_font->font[c]) >= 0)) { |
2a66d95355f0
add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents:
21582
diff
changeset
|
472 if (sub_font->pic_a[font]->h > h) { |
2a66d95355f0
add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents:
21582
diff
changeset
|
473 h = sub_font->pic_a[font]->h; |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
474 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
475 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
476 } else { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
477 if (x) { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
478 mp_msg(MSGT_OSD, MSGL_WARN, "\nSubtitle word '%s' too long!\n", t); |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
479 x = 0; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
480 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
481 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
482 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
483 }// for len (all words from subtitle line read) |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
484 |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
485 // osl holds an ordered (as they appear in the lines) chain of the subtitle words |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
486 { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
487 struct osd_text_t *tmp_ott = (struct osd_text_t *) calloc(1, sizeof(struct osd_text_t)); |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
488 |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
489 if (osl == NULL) { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
490 osl = cp_ott = tmp_ott; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
491 } else { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
492 tmp_ott->prev = cp_ott; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
493 cp_ott->next = tmp_ott; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
494 tmp_ott->osd_kerning = |
23338
2a66d95355f0
add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents:
21582
diff
changeset
|
495 sub_font->charspace + sub_font->width[' ']; |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
496 cp_ott = tmp_ott; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
497 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
498 tmp_ott->osd_length = xsize; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
499 tmp_ott->text_length = char_position; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
500 tmp_ott->text = (int *) malloc(char_position * sizeof(int)); |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
501 for (counter = 0; counter < char_position; ++counter) |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
502 tmp_ott->text[counter] = char_seq[counter]; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
503 char_position = 0; |
23338
2a66d95355f0
add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents:
21582
diff
changeset
|
504 xsize = -sub_font->charspace; |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
505 } |
18716 | 506 free(char_seq); |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
507 |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
508 if (osl != NULL) { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
509 int value = 0, exit = 0, minimum = 0; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
510 |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
511 // otp will contain the chain of the osd subtitle lines coming from the single vo_sub line. |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
512 otp = tmp_otp = (struct osd_text_p *) calloc(1, sizeof(struct osd_text_p)); |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
513 tmp_otp->ott = osl; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
514 for (tmp_ott = tmp_otp->ott; exit == 0; ) { |
11297
b4c7de4cfbf2
prevent lockups on words which do not fit on the screen - temporary fix
henry
parents:
11201
diff
changeset
|
515 do { |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
516 value += tmp_ott->osd_kerning + tmp_ott->osd_length; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
517 tmp_ott = tmp_ott->next; |
11297
b4c7de4cfbf2
prevent lockups on words which do not fit on the screen - temporary fix
henry
parents:
11201
diff
changeset
|
518 } while ((tmp_ott != NULL) && (value + tmp_ott->osd_kerning + tmp_ott->osd_length <= xlimit)); |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
519 if (tmp_ott != NULL) { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
520 struct osd_text_p *tmp = (struct osd_text_p *) calloc(1, sizeof(struct osd_text_p)); |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
521 |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
522 tmp_otp->value = value; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
523 tmp_otp->next = tmp; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
524 tmp->prev = tmp_otp; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
525 tmp_otp = tmp; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
526 tmp_otp->ott = tmp_ott; |
23338
2a66d95355f0
add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents:
21582
diff
changeset
|
527 value = -2 * sub_font->charspace - sub_font->width[' ']; |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
528 } else { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
529 tmp_otp->value = value; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
530 exit = 1; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
531 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
532 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
533 |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
534 |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
535 #ifdef NEW_SPLITTING |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
536 // minimum holds the 'sum of the differences in lenght among the lines', |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
537 // a measure of the eveness of the lenghts of the lines |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
538 for (tmp_otp = otp; tmp_otp->next != NULL; tmp_otp = tmp_otp->next) { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
539 pmt = tmp_otp->next; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
540 while (pmt != NULL) { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
541 minimum += abs(tmp_otp->value - pmt->value); |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
542 pmt = pmt->next; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
543 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
544 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
545 |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
546 if (otp->next != NULL) { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
547 int mem1, mem2; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
548 struct osd_text_p *mem, *hold; |
5640 | 549 |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
550 exit = 0; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
551 // until the last word of a line can be moved to the beginning of following line |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
552 // reducing the 'sum of the differences in lenght among the lines', it is done |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
553 while (exit == 0) { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
554 hold = NULL; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
555 exit = 1; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
556 for (tmp_otp = otp; tmp_otp->next != NULL; tmp_otp = tmp_otp->next) { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
557 pmt = tmp_otp->next; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
558 for (tmp = tmp_otp->ott; tmp->next != pmt->ott; tmp = tmp->next); |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
559 if (pmt->value + tmp->osd_length + pmt->ott->osd_kerning <= xlimit) { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
560 mem1 = tmp_otp->value; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
561 mem2 = pmt->value; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
562 tmp_otp->value = mem1 - tmp->osd_length - tmp->osd_kerning; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
563 pmt->value = mem2 + tmp->osd_length + pmt->ott->osd_kerning; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
564 |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
565 value = 0; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
566 for (mem = otp; mem->next != NULL; mem = mem->next) { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
567 pmt = mem->next; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
568 while (pmt != NULL) { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
569 value += abs(mem->value - pmt->value); |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
570 pmt = pmt->next; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
571 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
572 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
573 if (value < minimum) { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
574 minimum = value; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
575 hold = tmp_otp; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
576 exit = 0; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
577 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
578 tmp_otp->value = mem1; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
579 tmp_otp->next->value = mem2; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
580 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
581 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
582 // merging |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
583 if (exit == 0) { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
584 tmp_otp = hold; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
585 pmt = tmp_otp->next; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
586 for (tmp = tmp_otp->ott; tmp->next != pmt->ott; tmp = tmp->next); |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
587 mem1 = tmp_otp->value; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
588 mem2 = pmt->value; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
589 tmp_otp->value = mem1 - tmp->osd_length - tmp->osd_kerning; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
590 pmt->value = mem2 + tmp->osd_length + pmt->ott->osd_kerning; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
591 pmt->ott = tmp; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
592 }//~merging |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
593 }//~while(exit == 0) |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
594 }//~if(otp->next!=NULL) |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
595 #endif |
8534
922ce27eb683
This patch adds support for vertical subtitle alignment
arpi
parents:
8451
diff
changeset
|
596 |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
597 // adding otp (containing splitted lines) to otp chain |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
598 if (otp_sub == NULL) { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
599 otp_sub = otp; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
600 for (otp_sub_tmp = otp_sub; otp_sub_tmp->next != NULL; otp_sub_tmp = otp_sub_tmp->next); |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
601 } else { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
602 //updating ott chain |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
603 tmp = otp_sub->ott; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
604 while (tmp->next != NULL) tmp = tmp->next; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
605 tmp->next = otp->ott; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
606 otp->ott->prev = tmp; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
607 //attaching new subtitle line at the end |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
608 otp_sub_tmp->next = otp; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
609 otp->prev = otp_sub_tmp; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
610 do |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
611 otp_sub_tmp = otp_sub_tmp->next; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
612 while (otp_sub_tmp->next != NULL); |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
613 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
614 }//~ if(osl != NULL) |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
615 } // while |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
616 |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
617 // write lines into utbl |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
618 xtblc = 0; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
619 utblc = 0; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
620 obj->y = dys; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
621 obj->params.subtitle.lines = 0; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
622 for (tmp_otp = otp_sub; tmp_otp != NULL; tmp_otp = tmp_otp->next) { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
623 |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
624 if ((obj->params.subtitle.lines++) >= MAX_UCSLINES) |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
625 break; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
626 |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
627 if (h > obj->y) { // out of the screen so end parsing |
23338
2a66d95355f0
add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents:
21582
diff
changeset
|
628 obj->y -= lasth - sub_font->height; // correct the y position |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
629 break; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
630 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
631 xsize = tmp_otp->value; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
632 obj->params.subtitle.xtbl[xtblc++] = (dxs - xsize) / 2; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
633 if (xmin > (dxs - xsize) / 2) |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
634 xmin = (dxs - xsize) / 2; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
635 if (xmax < (dxs + xsize) / 2) |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
636 xmax = (dxs + xsize) / 2; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
637 |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
638 tmp = (tmp_otp->next == NULL) ? NULL : tmp_otp->next->ott; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
639 for (tmp_ott = tmp_otp->ott; tmp_ott != tmp; tmp_ott = tmp_ott->next) { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
640 for (counter = 0; counter < tmp_ott->text_length; ++counter) { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
641 if (utblc > MAX_UCS) { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
642 break; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
643 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
644 c = tmp_ott->text[counter]; |
23338
2a66d95355f0
add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents:
21582
diff
changeset
|
645 render_one_glyph(sub_font, c); |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
646 obj->params.subtitle.utbl[utblc++] = c; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
647 k++; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
648 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
649 obj->params.subtitle.utbl[utblc++] = ' '; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
650 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
651 obj->params.subtitle.utbl[utblc - 1] = 0; |
23338
2a66d95355f0
add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents:
21582
diff
changeset
|
652 obj->y -= sub_font->height; |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
653 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
654 if(obj->params.subtitle.lines) |
23338
2a66d95355f0
add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents:
21582
diff
changeset
|
655 obj->y = dys - ((obj->params.subtitle.lines - 1) * sub_font->height + sub_font->pic_a[sub_font->font[40]]->h); |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
656 |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
657 // free memory |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
658 if (otp_sub != NULL) { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
659 for (tmp = otp_sub->ott; tmp->next != NULL; free(tmp->prev)) { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
660 free(tmp->text); |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
661 tmp = tmp->next; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
662 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
663 free(tmp->text); |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
664 free(tmp); |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
665 |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
666 for(pmt = otp_sub; pmt->next != NULL; free(pmt->prev)) { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
667 pmt = pmt->next; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
668 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
669 free(pmt); |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
670 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
671 |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
672 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
673 /// vertical alignment |
8534
922ce27eb683
This patch adds support for vertical subtitle alignment
arpi
parents:
8451
diff
changeset
|
674 h = dys - obj->y; |
16838
fb79161e09f4
reverse incorrect sub alignment change, ok'd by diego
rfelker
parents:
16834
diff
changeset
|
675 if (sub_alignment == 2) |
8534
922ce27eb683
This patch adds support for vertical subtitle alignment
arpi
parents:
8451
diff
changeset
|
676 obj->y = dys * sub_pos / 100 - h; |
922ce27eb683
This patch adds support for vertical subtitle alignment
arpi
parents:
8451
diff
changeset
|
677 else if (sub_alignment == 1) |
922ce27eb683
This patch adds support for vertical subtitle alignment
arpi
parents:
8451
diff
changeset
|
678 obj->y = dys * sub_pos / 100 - h / 2; |
922ce27eb683
This patch adds support for vertical subtitle alignment
arpi
parents:
8451
diff
changeset
|
679 else |
922ce27eb683
This patch adds support for vertical subtitle alignment
arpi
parents:
8451
diff
changeset
|
680 obj->y = dys * sub_pos / 100; |
922ce27eb683
This patch adds support for vertical subtitle alignment
arpi
parents:
8451
diff
changeset
|
681 |
922ce27eb683
This patch adds support for vertical subtitle alignment
arpi
parents:
8451
diff
changeset
|
682 if (obj->y < 0) |
922ce27eb683
This patch adds support for vertical subtitle alignment
arpi
parents:
8451
diff
changeset
|
683 obj->y = 0; |
922ce27eb683
This patch adds support for vertical subtitle alignment
arpi
parents:
8451
diff
changeset
|
684 if (obj->y > dys - h) |
922ce27eb683
This patch adds support for vertical subtitle alignment
arpi
parents:
8451
diff
changeset
|
685 obj->y = dys - h; |
922ce27eb683
This patch adds support for vertical subtitle alignment
arpi
parents:
8451
diff
changeset
|
686 |
922ce27eb683
This patch adds support for vertical subtitle alignment
arpi
parents:
8451
diff
changeset
|
687 obj->bbox.y2 = obj->y + h; |
922ce27eb683
This patch adds support for vertical subtitle alignment
arpi
parents:
8451
diff
changeset
|
688 |
5640 | 689 // calculate bbox: |
10263 | 690 if (sub_justify) xmin = 10; |
5640 | 691 obj->bbox.x1=xmin; |
692 obj->bbox.x2=xmax; | |
693 obj->bbox.y1=obj->y; | |
23338
2a66d95355f0
add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents:
21582
diff
changeset
|
694 // obj->bbox.y2=obj->y+obj->params.subtitle.lines*sub_font->height; |
5640 | 695 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
|
696 |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
697 alloc_buf(obj); |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
698 |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
699 y = obj->y; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
700 |
13343
1a4b6e575484
This time is a patch to improve subtitle alignment management. It
faust3
parents:
12794
diff
changeset
|
701 obj->alignment = 0; |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
702 switch(vo_sub->alignment) { |
13343
1a4b6e575484
This time is a patch to improve subtitle alignment management. It
faust3
parents:
12794
diff
changeset
|
703 case SUB_ALIGNMENT_BOTTOMLEFT: |
1a4b6e575484
This time is a patch to improve subtitle alignment management. It
faust3
parents:
12794
diff
changeset
|
704 case SUB_ALIGNMENT_MIDDLELEFT: |
1a4b6e575484
This time is a patch to improve subtitle alignment management. It
faust3
parents:
12794
diff
changeset
|
705 case SUB_ALIGNMENT_TOPLEFT: |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
706 obj->alignment |= 0x1; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
707 break; |
13343
1a4b6e575484
This time is a patch to improve subtitle alignment management. It
faust3
parents:
12794
diff
changeset
|
708 case SUB_ALIGNMENT_BOTTOMRIGHT: |
1a4b6e575484
This time is a patch to improve subtitle alignment management. It
faust3
parents:
12794
diff
changeset
|
709 case SUB_ALIGNMENT_MIDDLERIGHT: |
1a4b6e575484
This time is a patch to improve subtitle alignment management. It
faust3
parents:
12794
diff
changeset
|
710 case SUB_ALIGNMENT_TOPRIGHT: |
1a4b6e575484
This time is a patch to improve subtitle alignment management. It
faust3
parents:
12794
diff
changeset
|
711 obj->alignment |= 0x2; |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
712 break; |
13343
1a4b6e575484
This time is a patch to improve subtitle alignment management. It
faust3
parents:
12794
diff
changeset
|
713 case SUB_ALIGNMENT_BOTTOMCENTER: |
1a4b6e575484
This time is a patch to improve subtitle alignment management. It
faust3
parents:
12794
diff
changeset
|
714 case SUB_ALIGNMENT_MIDDLECENTER: |
1a4b6e575484
This time is a patch to improve subtitle alignment management. It
faust3
parents:
12794
diff
changeset
|
715 case SUB_ALIGNMENT_TOPCENTER: |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
716 default: |
13343
1a4b6e575484
This time is a patch to improve subtitle alignment management. It
faust3
parents:
12794
diff
changeset
|
717 obj->alignment |= 0x0; |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
718 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
719 |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
720 i=j=0; |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
721 if ((l = obj->params.subtitle.lines)) { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
722 for(counter = dxs; i < l; ++i) |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
723 if (obj->params.subtitle.xtbl[i] < counter) counter = obj->params.subtitle.xtbl[i]; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
724 for (i = 0; i < l; ++i) { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
725 switch (obj->alignment&0x3) { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
726 case 1: |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
727 // left |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
728 x = counter; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
729 break; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
730 case 2: |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
731 // right |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
732 x = 2 * obj->params.subtitle.xtbl[i] - counter - ((obj->params.subtitle.xtbl[i] == counter) ? 0 : 1); |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
733 break; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
734 default: |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
735 //center |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
736 x = obj->params.subtitle.xtbl[i]; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
737 } |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
738 prevc = -1; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
739 while ((c=obj->params.subtitle.utbl[j++])){ |
23338
2a66d95355f0
add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents:
21582
diff
changeset
|
740 x += kerning(sub_font,prevc,c); |
2a66d95355f0
add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents:
21582
diff
changeset
|
741 if ((font=sub_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
|
742 draw_alpha_buf(obj,x,y, |
23338
2a66d95355f0
add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents:
21582
diff
changeset
|
743 sub_font->width[c], |
2a66d95355f0
add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents:
21582
diff
changeset
|
744 sub_font->pic_a[font]->h+y<obj->dys ? sub_font->pic_a[font]->h : obj->dys-y, |
2a66d95355f0
add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents:
21582
diff
changeset
|
745 sub_font->pic_b[font]->bmp+sub_font->start[c], |
2a66d95355f0
add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents:
21582
diff
changeset
|
746 sub_font->pic_a[font]->bmp+sub_font->start[c], |
2a66d95355f0
add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents:
21582
diff
changeset
|
747 sub_font->pic_a[font]->w); |
2a66d95355f0
add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents:
21582
diff
changeset
|
748 x+=sub_font->width[c]+sub_font->charspace; |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
749 prevc = c; |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
750 } |
23338
2a66d95355f0
add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents:
21582
diff
changeset
|
751 y+=sub_font->height; |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
752 } |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
753 } |
5640 | 754 |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
755 } |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
756 |
6190
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
757 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
|
758 { |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
759 unsigned int bbox[4]; |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
760 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
|
761 obj->bbox.x1 = bbox[0]; |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
762 obj->bbox.x2 = bbox[1]; |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
763 obj->bbox.y1 = bbox[2]; |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
764 obj->bbox.y2 = bbox[3]; |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
765 obj->flags |= OSDFLAG_BBOX; |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
766 } |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
767 |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
768 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
|
769 { |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
770 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
|
771 } |
218 | 772 |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
2498
diff
changeset
|
773 void *vo_spudec=NULL; |
4081
9e581ab5e54b
Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents:
3180
diff
changeset
|
774 void *vo_vobsub=NULL; |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
2498
diff
changeset
|
775 |
947
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
865
diff
changeset
|
776 static int draw_alpha_init_flag=0; |
218 | 777 |
17566
f580a7755ac5
Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents:
16923
diff
changeset
|
778 extern void vo_draw_alpha_init(void); |
1109 | 779 |
7067
b395b1240954
fix dxr3 subtitle handling and add some optimizations
pontscho
parents:
7003
diff
changeset
|
780 mp_osd_obj_t* vo_osd_list=NULL; |
218 | 781 |
18950 | 782 static mp_osd_obj_t* new_osd_obj(int type){ |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
783 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
|
784 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
|
785 osd->next=vo_osd_list; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
786 vo_osd_list=osd; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
787 osd->type=type; |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
788 osd->alpha_buffer = NULL; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
789 osd->bitmap_buffer = NULL; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
790 osd->allocated = -1; |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
791 return osd; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
792 } |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
793 |
17566
f580a7755ac5
Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents:
16923
diff
changeset
|
794 void free_osd_list(void){ |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
795 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
|
796 while(obj){ |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
797 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
|
798 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
|
799 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
|
800 free(obj); |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
801 obj=next; |
4081
9e581ab5e54b
Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents:
3180
diff
changeset
|
802 } |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
803 vo_osd_list=NULL; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
804 } |
4081
9e581ab5e54b
Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents:
3180
diff
changeset
|
805 |
15085
1f8a1de5585c
defer loading of the font after display size change to avoid useless
henry
parents:
15078
diff
changeset
|
806 #define FONT_LOAD_DEFER 6 |
1f8a1de5585c
defer loading of the font after display size change to avoid useless
henry
parents:
15078
diff
changeset
|
807 |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
808 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
|
809 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
|
810 int chg=0; |
15085
1f8a1de5585c
defer loading of the font after display size change to avoid useless
henry
parents:
15078
diff
changeset
|
811 #ifdef HAVE_FREETYPE |
1f8a1de5585c
defer loading of the font after display size change to avoid useless
henry
parents:
15078
diff
changeset
|
812 static int defer_counter = 0, prev_dxs = 0, prev_dys = 0; |
1f8a1de5585c
defer loading of the font after display size change to avoid useless
henry
parents:
15078
diff
changeset
|
813 #endif |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
814 |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
815 #ifdef HAVE_FREETYPE |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
816 // here is the right place to get screen dimensions |
15085
1f8a1de5585c
defer loading of the font after display size change to avoid useless
henry
parents:
15078
diff
changeset
|
817 if (((dxs != vo_image_width) |
1f8a1de5585c
defer loading of the font after display size change to avoid useless
henry
parents:
15078
diff
changeset
|
818 && (subtitle_autoscale == 2 || subtitle_autoscale == 3)) |
1f8a1de5585c
defer loading of the font after display size change to avoid useless
henry
parents:
15078
diff
changeset
|
819 || ((dys != vo_image_height) |
1f8a1de5585c
defer loading of the font after display size change to avoid useless
henry
parents:
15078
diff
changeset
|
820 && (subtitle_autoscale == 1 || subtitle_autoscale == 3))) |
1f8a1de5585c
defer loading of the font after display size change to avoid useless
henry
parents:
15078
diff
changeset
|
821 { |
1f8a1de5585c
defer loading of the font after display size change to avoid useless
henry
parents:
15078
diff
changeset
|
822 // screen dimensions changed |
1f8a1de5585c
defer loading of the font after display size change to avoid useless
henry
parents:
15078
diff
changeset
|
823 // wait a while to avoid useless reloading of the font |
1f8a1de5585c
defer loading of the font after display size change to avoid useless
henry
parents:
15078
diff
changeset
|
824 if (dxs == prev_dxs || dys == prev_dys) { |
1f8a1de5585c
defer loading of the font after display size change to avoid useless
henry
parents:
15078
diff
changeset
|
825 defer_counter++; |
1f8a1de5585c
defer loading of the font after display size change to avoid useless
henry
parents:
15078
diff
changeset
|
826 } else { |
1f8a1de5585c
defer loading of the font after display size change to avoid useless
henry
parents:
15078
diff
changeset
|
827 prev_dxs = dxs; |
1f8a1de5585c
defer loading of the font after display size change to avoid useless
henry
parents:
15078
diff
changeset
|
828 prev_dys = dys; |
1f8a1de5585c
defer loading of the font after display size change to avoid useless
henry
parents:
15078
diff
changeset
|
829 defer_counter = 0; |
1f8a1de5585c
defer loading of the font after display size change to avoid useless
henry
parents:
15078
diff
changeset
|
830 } |
1f8a1de5585c
defer loading of the font after display size change to avoid useless
henry
parents:
15078
diff
changeset
|
831 if (defer_counter >= FONT_LOAD_DEFER) force_load_font = 1; |
1f8a1de5585c
defer loading of the font after display size change to avoid useless
henry
parents:
15078
diff
changeset
|
832 } |
1f8a1de5585c
defer loading of the font after display size change to avoid useless
henry
parents:
15078
diff
changeset
|
833 |
23338
2a66d95355f0
add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents:
21582
diff
changeset
|
834 if (force_load_font) { |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
835 force_load_font = 0; |
23338
2a66d95355f0
add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents:
21582
diff
changeset
|
836 load_font_ft(dxs, dys, &vo_font, font_name); |
2a66d95355f0
add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents:
21582
diff
changeset
|
837 load_font_ft(dxs, dys, &sub_font, sub_font_name); |
15085
1f8a1de5585c
defer loading of the font after display size change to avoid useless
henry
parents:
15078
diff
changeset
|
838 prev_dxs = dxs; |
1f8a1de5585c
defer loading of the font after display size change to avoid useless
henry
parents:
15078
diff
changeset
|
839 prev_dys = dys; |
1f8a1de5585c
defer loading of the font after display size change to avoid useless
henry
parents:
15078
diff
changeset
|
840 defer_counter = 0; |
23338
2a66d95355f0
add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents:
21582
diff
changeset
|
841 } else { |
2a66d95355f0
add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents:
21582
diff
changeset
|
842 if (!vo_font) |
2a66d95355f0
add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents:
21582
diff
changeset
|
843 load_font_ft(dxs, dys, &vo_font, font_name); |
2a66d95355f0
add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents:
21582
diff
changeset
|
844 if (!sub_font) |
2a66d95355f0
add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents:
21582
diff
changeset
|
845 load_font_ft(dxs, dys, &sub_font, sub_font_name); |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
846 } |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
847 #endif |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
848 |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
849 while(obj){ |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
850 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
|
851 int vis=obj->flags&OSDFLAG_VISIBLE; |
5640 | 852 obj->flags&=~OSDFLAG_BBOX; |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
853 switch(obj->type){ |
21193
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
19366
diff
changeset
|
854 #ifdef USE_DVDNAV |
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
19366
diff
changeset
|
855 case OSDTYPE_DVDNAV: |
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
19366
diff
changeset
|
856 vo_update_nav(obj,dxs,dys); |
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
19366
diff
changeset
|
857 break; |
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
19366
diff
changeset
|
858 #endif |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
859 case OSDTYPE_SUBTITLE: |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
860 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
|
861 break; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
862 case OSDTYPE_PROGBAR: |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
863 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
|
864 break; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
865 case OSDTYPE_SPU: |
7628
d6608342591d
This patch adds the functionality to disable/enable subtitles while playing
arpi
parents:
7121
diff
changeset
|
866 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
|
867 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
|
868 obj->flags|=OSDFLAG_VISIBLE|OSDFLAG_CHANGED; |
6190
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
869 } |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
870 else |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
871 obj->flags&=~OSDFLAG_VISIBLE; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
872 break; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
873 case OSDTYPE_OSD: |
5640 | 874 if(vo_font && vo_osd_text && vo_osd_text[0]){ |
875 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
|
876 obj->flags|=OSDFLAG_VISIBLE|OSDFLAG_CHANGED; |
5640 | 877 } else |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
878 obj->flags&=~OSDFLAG_VISIBLE; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
879 break; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
880 } |
5640 | 881 // check bbox: |
882 if(!(obj->flags&OSDFLAG_BBOX)){ | |
883 // we don't know, so assume the whole screen changed :( | |
884 obj->bbox.x1=obj->bbox.y1=0; | |
885 obj->bbox.x2=dxs; | |
886 obj->bbox.y2=dys; | |
887 obj->flags|=OSDFLAG_BBOX; | |
5664 | 888 } else { |
889 // check bbox, reduce it if it's out of bounds (corners): | |
890 if(obj->bbox.x1<0) obj->bbox.x1=0; | |
891 if(obj->bbox.y1<0) obj->bbox.y1=0; | |
892 if(obj->bbox.x2>dxs) obj->bbox.x2=dxs; | |
893 if(obj->bbox.y2>dys) obj->bbox.y2=dys; | |
894 if(obj->flags&OSDFLAG_VISIBLE) | |
895 // debug: | |
896 mp_msg(MSGT_OSD,MSGL_DBG2,"OSD update: %d;%d %dx%d \n", | |
5640 | 897 obj->bbox.x1,obj->bbox.y1,obj->bbox.x2-obj->bbox.x1, |
898 obj->bbox.y2-obj->bbox.y1); | |
899 } | |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
900 // check if visibility changed: |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
901 if(vis != (obj->flags&OSDFLAG_VISIBLE) ) obj->flags|=OSDFLAG_CHANGED; |
5640 | 902 // 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
|
903 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
|
904 obj->flags&=~OSDFLAG_FORCE_UPDATE; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
905 } |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
906 if(obj->flags&OSDFLAG_CHANGED){ |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
907 chg|=1<<obj->type; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
908 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
|
909 } |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
910 obj=obj->next; |
4081
9e581ab5e54b
Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents:
3180
diff
changeset
|
911 } |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
912 return chg; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
913 } |
4081
9e581ab5e54b
Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents:
3180
diff
changeset
|
914 |
17566
f580a7755ac5
Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents:
16923
diff
changeset
|
915 void vo_init_osd(void){ |
947
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
865
diff
changeset
|
916 if(!draw_alpha_init_flag){ |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
865
diff
changeset
|
917 draw_alpha_init_flag=1; |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
865
diff
changeset
|
918 vo_draw_alpha_init(); |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
865
diff
changeset
|
919 } |
6110 | 920 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
|
921 // 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
|
922 new_osd_obj(OSDTYPE_OSD); |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
923 new_osd_obj(OSDTYPE_SUBTITLE); |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
924 new_osd_obj(OSDTYPE_PROGBAR); |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
925 new_osd_obj(OSDTYPE_SPU); |
21193
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
19366
diff
changeset
|
926 #ifdef USE_DVDNAV |
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
19366
diff
changeset
|
927 new_osd_obj(OSDTYPE_DVDNAV); |
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
19366
diff
changeset
|
928 #endif |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
929 #ifdef HAVE_FREETYPE |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
930 force_load_font = 1; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
931 #endif |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
932 } |
947
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
865
diff
changeset
|
933 |
5642
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
934 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
|
935 |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
936 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
|
937 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
|
938 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
|
939 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
|
940 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
|
941 (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
|
942 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
|
943 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
|
944 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
|
945 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
|
946 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
|
947 } |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
948 // 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
|
949 } |
5645 | 950 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
|
951 } |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
952 } |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
953 |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
954 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
|
955 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
|
956 vo_update_osd(dxs,dys); |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
957 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
|
958 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
|
959 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
|
960 switch(obj->type){ |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
961 case OSDTYPE_SPU: |
6190
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
962 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
|
963 break; |
21193
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
19366
diff
changeset
|
964 #ifdef USE_DVDNAV |
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
19366
diff
changeset
|
965 case OSDTYPE_DVDNAV: |
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
19366
diff
changeset
|
966 #endif |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
967 case OSDTYPE_OSD: |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
968 case OSDTYPE_SUBTITLE: |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
969 case OSDTYPE_PROGBAR: |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
970 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
|
971 break; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
972 } |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
973 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
|
974 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
|
975 } |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
976 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
|
977 obj=obj->next; |
218 | 978 } |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
979 } |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
2498
diff
changeset
|
980 |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4773
diff
changeset
|
981 static int vo_osd_changed_status = 0; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4773
diff
changeset
|
982 |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4773
diff
changeset
|
983 int vo_osd_changed(int new_value) |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4773
diff
changeset
|
984 { |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
985 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
|
986 int ret = vo_osd_changed_status; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4773
diff
changeset
|
987 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
|
988 |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
989 while(obj){ |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
990 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
|
991 obj=obj->next; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
992 } |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
993 |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4773
diff
changeset
|
994 return ret; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4773
diff
changeset
|
995 } |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
996 |
5645 | 997 // BBBBBBBBBBBB AAAAAAAAAAAAA BBBBBBBBBBB |
998 // BBBBBBBBBBBB BBBBBBBBBBBBB | |
999 // BBBBBBB | |
1000 | |
1001 // return TRUE if we have osd in the specified rectangular area: | |
1002 int vo_osd_check_range_update(int x1,int y1,int x2,int y2){ | |
1003 mp_osd_obj_t* obj=vo_osd_list; | |
1004 while(obj){ | |
1005 if(obj->flags&OSDFLAG_VISIBLE){ | |
1006 if( (obj->bbox.x1<=x2 && obj->bbox.x2>=x1) && | |
21364
d81ffbf9615f
EMISSINGBRAIN: No, OSD objects of size 0 sure are _not_ visible.
reimar
parents:
21219
diff
changeset
|
1007 (obj->bbox.y1<=y2 && obj->bbox.y2>=y1) && |
21443
862b3942429c
100l typo in 21380 disabled OSD with at least xvmc.
reimar
parents:
21364
diff
changeset
|
1008 obj->bbox.y2 > obj->bbox.y1 && obj->bbox.x2 > obj->bbox.x1 |
21364
d81ffbf9615f
EMISSINGBRAIN: No, OSD objects of size 0 sure are _not_ visible.
reimar
parents:
21219
diff
changeset
|
1009 ) return 1; |
5645 | 1010 } |
1011 obj=obj->next; | |
1012 } | |
1013 return 0; | |
1014 } |