Mercurial > mplayer.hg
annotate libvo/sub.c @ 24043:a8e3361e694c
Document how to encode with some more libavcodec audio codecs.
patch by A C Hurst, A.Hurst sheffield.ac uk
author | diego |
---|---|
date | Wed, 15 Aug 2007 08:45:01 +0000 |
parents | 037737866f6a |
children | 7e2808fb1807 |
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 |
23903 | 17 #ifdef HAVE_TV_TELETEXT |
18 #include "stream/tv.h" | |
19 #endif | |
20 | |
23338
2a66d95355f0
add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents:
21582
diff
changeset
|
21 #include "mplayer.h" |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
22 #include "mp_msg.h" |
16923
a6a03ff1ddef
Added translatable messages for OSD localization to help/help_mp-en.h
ptt
parents:
16839
diff
changeset
|
23 #include "help_mp.h" |
4088 | 24 #include "video_out.h" |
5294 | 25 #include "font_load.h" |
218 | 26 #include "sub.h" |
13787
e047e70a9767
Handle "xxx.h" vs "../xxx.h" include paths in a consistent way.
diego
parents:
13343
diff
changeset
|
27 #include "spudec.h" |
19366 | 28 #include "libavutil/common.h" |
202 | 29 |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
30 #define NEW_SPLITTING |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
31 |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
32 |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
33 // Structures needed for the new splitting algorithm. |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
34 // osd_text_t contains the single subtitle word. |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
35 // osd_text_p is used to mark the lines of subtitles |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
36 struct osd_text_t { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
37 int osd_kerning, //kerning with the previous word |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
38 osd_length, //orizontal length inside the bbox |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
39 text_length, //number of characters |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
40 *text; //characters |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
41 struct osd_text_t *prev, |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
42 *next; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
43 }; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
44 |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
45 struct osd_text_p { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
46 int value; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
47 struct osd_text_t *ott; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
48 struct osd_text_p *prev, |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
49 *next; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
50 }; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
51 //^ |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
52 |
2498 | 53 char * __sub_osd_names[]={ |
16923
a6a03ff1ddef
Added translatable messages for OSD localization to help/help_mp-en.h
ptt
parents:
16839
diff
changeset
|
54 MSGTR_VO_SUB_Seekbar, |
a6a03ff1ddef
Added translatable messages for OSD localization to help/help_mp-en.h
ptt
parents:
16839
diff
changeset
|
55 MSGTR_VO_SUB_Play, |
a6a03ff1ddef
Added translatable messages for OSD localization to help/help_mp-en.h
ptt
parents:
16839
diff
changeset
|
56 MSGTR_VO_SUB_Pause, |
a6a03ff1ddef
Added translatable messages for OSD localization to help/help_mp-en.h
ptt
parents:
16839
diff
changeset
|
57 MSGTR_VO_SUB_Stop, |
a6a03ff1ddef
Added translatable messages for OSD localization to help/help_mp-en.h
ptt
parents:
16839
diff
changeset
|
58 MSGTR_VO_SUB_Rewind, |
a6a03ff1ddef
Added translatable messages for OSD localization to help/help_mp-en.h
ptt
parents:
16839
diff
changeset
|
59 MSGTR_VO_SUB_Forward, |
a6a03ff1ddef
Added translatable messages for OSD localization to help/help_mp-en.h
ptt
parents:
16839
diff
changeset
|
60 MSGTR_VO_SUB_Clock, |
a6a03ff1ddef
Added translatable messages for OSD localization to help/help_mp-en.h
ptt
parents:
16839
diff
changeset
|
61 MSGTR_VO_SUB_Contrast, |
a6a03ff1ddef
Added translatable messages for OSD localization to help/help_mp-en.h
ptt
parents:
16839
diff
changeset
|
62 MSGTR_VO_SUB_Saturation, |
a6a03ff1ddef
Added translatable messages for OSD localization to help/help_mp-en.h
ptt
parents:
16839
diff
changeset
|
63 MSGTR_VO_SUB_Volume, |
a6a03ff1ddef
Added translatable messages for OSD localization to help/help_mp-en.h
ptt
parents:
16839
diff
changeset
|
64 MSGTR_VO_SUB_Brightness, |
23568 | 65 MSGTR_VO_SUB_Hue, |
66 MSGTR_VO_SUB_Balance | |
2498 | 67 }; |
23568 | 68 char * __sub_osd_names_short[] ={ "", "|>", "||", "[]", "<<" , ">>", "", "", "", "", "", "", "" }; |
2498 | 69 |
213 | 70 //static int vo_font_loaded=-1; |
71 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
|
72 font_desc_t* sub_font=NULL; |
202 | 73 |
1991
dee4b2ea5e5b
add gui support to config scripts, and fixed some warning.
pontscho
parents:
1878
diff
changeset
|
74 unsigned char* vo_osd_text=NULL; |
23903 | 75 #ifdef HAVE_TV_TELETEXT |
76 void* vo_osd_teletext_page=NULL; | |
77 int vo_osd_teletext_half = 0; | |
78 int vo_osd_teletext_mode=0; | |
79 int vo_osd_teletext_format=0; | |
80 int vo_osd_teletext_scale=0; | |
81 #endif | |
803
b25a887b6054
sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents:
726
diff
changeset
|
82 int sub_unicode=0; |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
83 int sub_utf8=0; |
4773 | 84 int sub_pos=100; |
8583 | 85 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
|
86 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
|
87 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
|
88 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
|
89 int sub_bg_alpha=0; |
10263 | 90 int sub_justify=0; |
21219 | 91 #ifdef USE_DVDNAV |
92 static nav_highlight_t nav_hl; | |
93 #endif | |
213 | 94 |
5664 | 95 // return the real height of a char: |
96 static inline int get_height(int c,int h){ | |
97 int font; | |
98 if ((font=vo_font->font[c])>=0) | |
99 if(h<vo_font->pic_a[font]->h) h=vo_font->pic_a[font]->h; | |
100 return h; | |
101 } | |
102 | |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
103 // 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
|
104 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
|
105 { |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
106 int dststride = obj->stride; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
107 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
|
108 int srcskip = stride-w; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
109 int i, j; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
110 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
|
111 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
|
112 unsigned char *bs = src; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
113 unsigned char *as = srca; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
114 |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
115 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
|
116 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
|
117 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
|
118 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
|
119 return; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
120 } |
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 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
|
123 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
|
124 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
|
125 if (*as) { |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
126 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
|
127 } |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
128 } |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
129 b+= dstskip; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
130 a+= dstskip; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
131 bs+= srcskip; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
132 as+= srcskip; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
133 } |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
134 } |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
135 |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
136 // 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
|
137 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
|
138 { |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
139 int len; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
140 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
|
141 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
|
142 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
|
143 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
|
144 if (obj->allocated<len) { |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
145 obj->allocated = len; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
146 free(obj->bitmap_buffer); |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
147 free(obj->alpha_buffer); |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
148 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
|
149 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
|
150 } |
8617
6ffbe7608013
Me: -sub-bg-* would be nicer. "Background" is usually shortened as "bg", not "bkg".
rathann
parents:
8601
diff
changeset
|
151 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
|
152 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
|
153 } |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
154 |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
155 // renders the buffer |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
156 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
|
157 if (obj->allocated > 0) { |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
158 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
|
159 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
|
160 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
|
161 obj->bitmap_buffer, |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
162 obj->alpha_buffer, |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
163 obj->stride); |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
164 } |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
165 } |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
166 |
21582
239f2c145b2f
Mark utf8_get_char parameter as const and fix a compiler warning
reimar
parents:
21581
diff
changeset
|
167 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
|
168 const uint8_t *strp = (const uint8_t *)*str; |
19366 | 169 unsigned c; |
170 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
|
171 *str = (const char *)strp; |
18717 | 172 return c; |
173 | |
174 no_utf8: | |
21582
239f2c145b2f
Mark utf8_get_char parameter as const and fix a compiler warning
reimar
parents:
21581
diff
changeset
|
175 strp = (const uint8_t *)*str; |
18717 | 176 c = *strp++; |
21582
239f2c145b2f
Mark utf8_get_char parameter as const and fix a compiler warning
reimar
parents:
21581
diff
changeset
|
177 *str = (const char *)strp; |
18717 | 178 return c; |
179 } | |
180 | |
5640 | 181 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
|
182 const char *cp=vo_osd_text; |
5640 | 183 int x=20; |
5664 | 184 int h=0; |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
185 int font; |
5640 | 186 |
187 obj->bbox.x1=obj->x=x; | |
188 obj->bbox.y1=obj->y=10; | |
202 | 189 |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
190 while (*cp){ |
18717 | 191 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
|
192 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
|
193 x+=vo_font->width[c]+vo_font->charspace; |
5664 | 194 h=get_height(c,h); |
5640 | 195 } |
196 | |
5664 | 197 obj->bbox.x2=x-vo_font->charspace; |
198 obj->bbox.y2=obj->bbox.y1+h; | |
5640 | 199 obj->flags|=OSDFLAG_BBOX; |
200 | |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
201 alloc_buf(obj); |
5640 | 202 |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
203 cp=vo_osd_text; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
204 x = obj->x; |
5640 | 205 while (*cp){ |
18717 | 206 uint16_t c=utf8_get_char(&cp); |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
207 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
|
208 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
|
209 vo_font->width[c], |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
210 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
|
211 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
|
212 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
|
213 vo_font->pic_a[font]->w); |
213 | 214 x+=vo_font->width[c]+vo_font->charspace; |
215 } | |
218 | 216 } |
217 | |
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
|
218 #ifdef USE_DVDNAV |
21219 | 219 void osd_set_nav_box (uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey) { |
220 nav_hl.sx = sx; | |
221 nav_hl.sy = sy; | |
222 nav_hl.ex = ex; | |
223 nav_hl.ey = ey; | |
224 } | |
225 | |
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
|
226 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
|
227 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
|
228 |
21219 | 229 obj->bbox.x1 = obj->x = nav_hl.sx; |
230 obj->bbox.y1 = obj->y = nav_hl.sy; | |
231 obj->bbox.x2 = nav_hl.ex; | |
232 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
|
233 |
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
19366
diff
changeset
|
234 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
|
235 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
|
236 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
|
237 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
|
238 obj->flags |= OSDFLAG_BBOX | OSDFLAG_CHANGED; |
d81ffbf9615f
EMISSINGBRAIN: No, OSD objects of size 0 sure are _not_ visible.
reimar
parents:
21219
diff
changeset
|
239 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
|
240 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
|
241 } |
a067e7e18b50
support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents:
19366
diff
changeset
|
242 #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
|
243 |
23903 | 244 #ifdef HAVE_TV_TELETEXT |
245 // renders char to a big per-object buffer where alpha and bitmap are separated | |
246 static void tt_draw_alpha_buf(mp_osd_obj_t* obj, int x0,int y0, int w,int h, unsigned char* src, int stride,int fg,int bg,int alpha) | |
247 { | |
248 int dststride = obj->stride; | |
249 int dstskip = obj->stride-w; | |
250 int srcskip = stride-w; | |
251 int i, j; | |
252 unsigned char *b = obj->bitmap_buffer + (y0-obj->bbox.y1)*dststride + (x0-obj->bbox.x1); | |
253 unsigned char *a = obj->alpha_buffer + (y0-obj->bbox.y1)*dststride + (x0-obj->bbox.x1); | |
254 unsigned char *bs = src; | |
255 if (x0 < obj->bbox.x1 || x0+w > obj->bbox.x2 || y0 < obj->bbox.y1 || y0+h > obj->bbox.y2) { | |
256 mp_msg(MSGT_OSD,MSGL_ERR,"tt osd text out of range: bbox [%d %d %d %d], txt [%d %d %d %d]\n", | |
257 obj->bbox.x1, obj->bbox.x2, obj->bbox.y1, obj->bbox.y2, | |
258 x0, x0+w, y0, y0+h); | |
259 return; | |
260 } | |
261 for (i = 0; i < h; i++) { | |
262 for (j = 0; j < w; j++, b++, a++, bs++) { | |
263 *b=(fg-bg)*(*bs)/255+bg; | |
264 *a=alpha; | |
265 } | |
266 b+= dstskip; | |
267 a+= dstskip; | |
268 bs+= srcskip; | |
269 } | |
270 } | |
271 inline static void vo_update_text_teletext(mp_osd_obj_t *obj, int dxs, int dys) | |
272 { | |
273 int h=0,w=0,i,j,font; | |
274 int wm,hm; | |
275 int color; | |
276 int x,y,x0,y0; | |
277 int cols,rows; | |
278 int wm12; | |
279 int hm13; | |
280 int hm23; | |
281 int start_row,max_rows; | |
282 int b,ax[6],ay[6],aw[6],ah[6]; | |
283 tt_char tc; | |
284 tt_char* tdp=vo_osd_teletext_page; | |
285 unsigned char colors[8]={1,85,150,226,70,105,179,254}; | |
286 unsigned char* buf[9]; | |
287 | |
288 obj->flags|=OSDFLAG_CHANGED|OSDFLAG_VISIBLE; | |
289 if (!tdp || !vo_osd_teletext_mode) { | |
290 obj->flags&=~OSDFLAG_VISIBLE; | |
291 return; | |
292 } | |
293 switch(vo_osd_teletext_half){ | |
294 case TT_ZOOM_TOP_HALF: | |
295 start_row=0; | |
296 max_rows=VBI_ROWS/2; | |
297 break; | |
298 case TT_ZOOM_BOTTOM_HALF: | |
299 start_row=VBI_ROWS/2; | |
300 max_rows=VBI_ROWS/2; | |
301 break; | |
302 default: | |
303 start_row=0; | |
304 max_rows=VBI_ROWS; | |
305 break; | |
306 } | |
307 wm=0; | |
308 for(i=start_row;i<max_rows;i++){ | |
309 for(j=0;j<VBI_COLUMNS;j++){ | |
310 tc=tdp[i*VBI_COLUMNS+j]; | |
311 if(!tc.ctl && !tc.gfx) | |
312 { | |
313 render_one_glyph(vo_font, tc.unicode); | |
314 if (wm<vo_font->width[tc.unicode]) | |
315 wm=vo_font->width[tc.unicode]; | |
316 } | |
317 } | |
318 } | |
319 | |
320 hm=vo_font->height+1; | |
321 wm=dxs*hm*max_rows/(dys*VBI_COLUMNS); | |
322 | |
323 //very simple teletext font auto scaling | |
324 if(!vo_osd_teletext_scale && hm*(max_rows+1)>dys){ | |
325 text_font_scale_factor*=1.0*(dys)/((max_rows+1)*hm); | |
326 force_load_font=1; | |
327 vo_osd_teletext_scale=text_font_scale_factor; | |
328 obj->flags&=~OSDFLAG_VISIBLE; | |
329 return; | |
330 } | |
331 | |
332 cols=dxs/wm; | |
333 rows=dys/hm; | |
334 | |
335 if(cols>VBI_COLUMNS) | |
336 cols=VBI_COLUMNS; | |
337 if(rows>max_rows) | |
338 rows=max_rows; | |
339 w=cols*wm-vo_font->charspace; | |
340 h=rows*hm-vo_font->charspace; | |
341 | |
342 if(w<dxs) | |
343 x0=(dxs-w)/2; | |
344 else | |
345 x0=0; | |
346 if(h<dys) | |
347 y0=(dys-h)/2; | |
348 else | |
349 y0=0; | |
350 | |
351 wm12=wm>>1; | |
352 hm13=(hm+1)/3; | |
353 hm23=hm13<<1; | |
354 | |
355 for(i=0;i<6;i+=2){ | |
356 ax[i+0]=0; | |
357 aw[i+0]=wm12; | |
358 | |
359 ax[i+1]=wm12; | |
360 aw[i+1]=wm-wm12; | |
361 } | |
362 | |
363 for(i=0;i<2;i++){ | |
364 ay[i+0]=0; | |
365 ah[i+0]=hm13; | |
366 | |
367 ay[i+2]=hm13; | |
368 ah[i+2]=hm-hm23; | |
369 | |
370 ay[i+4]=hm-hm13; | |
371 ah[i+4]=hm13; | |
372 } | |
373 | |
374 obj->x = 0; | |
375 obj->y = 0; | |
376 obj->bbox.x1 = x0; | |
377 obj->bbox.y1 = y0; | |
378 obj->bbox.x2 = x0+w; | |
379 obj->bbox.y2 = y0+h; | |
380 obj->flags |= OSDFLAG_BBOX; | |
381 alloc_buf(obj); | |
382 | |
383 for(i=0;i<9;i++) | |
384 buf[i]=malloc(wm*hm); | |
385 | |
386 //alpha | |
387 if(vo_osd_teletext_format==TT_FORMAT_OPAQUE ||vo_osd_teletext_format==TT_FORMAT_OPAQUE_INV) | |
388 color=1; | |
389 else | |
390 color=200; | |
391 memset(buf[8],color,wm*hm); | |
392 //colors | |
393 if(vo_osd_teletext_format==TT_FORMAT_OPAQUE ||vo_osd_teletext_format==TT_FORMAT_TRANSPARENT){ | |
394 for(i=0;i<8;i++){ | |
395 memset(buf[i],(unsigned char)(1.0*(255-color)*colors[i]/255),wm*hm); | |
396 } | |
397 }else{ | |
398 for(i=0;i<8;i++) | |
399 memset(buf[i],(unsigned char)(1.0*(255-color)*colors[7-i]/255),wm*hm); | |
400 } | |
401 | |
402 y=y0; | |
403 for(i=0;i<rows;i++){ | |
404 x=x0; | |
405 for(j=0;j<cols;j++){ | |
406 tc=tdp[(i+start_row)*VBI_COLUMNS+j]; | |
407 if(!tc.gfx){ | |
408 /* Rendering one text character */ | |
409 draw_alpha_buf(obj,x,y,wm,hm,buf[tc.bg],buf[8],wm); | |
410 if(tc.unicode!=0x20 && tc.unicode!=0x00 && !tc.ctl && | |
411 (font=vo_font->font[tc.unicode])>=0 && y+hm<dys){ | |
412 tt_draw_alpha_buf(obj,x,y,vo_font->width[tc.unicode],vo_font->height, | |
413 vo_font->pic_b[font]->bmp+vo_font->start[tc.unicode]-vo_font->charspace*vo_font->pic_a[font]->w, | |
414 vo_font->pic_b[font]->w, | |
415 buf[tc.fg][0],buf[tc.bg][0],buf[8][0]); | |
416 } | |
417 }else{ | |
418 /* | |
419 Rendering one graphics character | |
420 TODO: support for separated graphics symbols (where six rectangles does not touch each other) | |
421 | |
422 +--+ +--+ 87654321 | |
423 |01| |12| -------- | |
424 |10| <= |34| <= 00100110 <= 0x26 | |
425 |01| |56| | |
426 +--+ +--+ | |
427 | |
428 (0:wm/2) (wm/2:wm-wm/2) | |
429 | |
430 ********** *********** (0:hm/3) | |
431 *** **** **** **** | |
432 *** 1 **** **** 2 **** | |
433 *** **** **** **** | |
434 ********** *********** | |
435 ********** *********** | |
436 | |
437 ********** *********** (hm/3:hm-2*hm/3) | |
438 ********** *********** | |
439 *** **** **** **** | |
440 *** 3 **** **** 4 **** | |
441 *** **** **** **** | |
442 ********** *********** | |
443 ********** *********** | |
444 ********** *********** | |
445 | |
446 ********** *********** (hm-hm/3:hm/3) | |
447 *** **** **** **** | |
448 *** 5 **** **** 6 **** | |
449 *** **** **** **** | |
450 ********** *********** | |
451 ********** *********** | |
452 | |
453 */ | |
454 if(tc.gfx>1){ //separated gfx | |
455 for(b=0;b<6;b++){ | |
456 color=(tc.unicode>>b)&1?tc.fg:tc.bg; | |
457 draw_alpha_buf(obj,x+ax[b]+1,y+ay[b]+1,aw[b]-2,ah[b]-2,buf[color],buf[8],wm); | |
458 } | |
459 //separated gfx (background borders) | |
460 //vertical | |
461 draw_alpha_buf(obj,x ,y,1,hm,buf[tc.bg],buf[8],wm); | |
462 draw_alpha_buf(obj,x+ax[1]-1,y,2,hm,buf[tc.bg],buf[8],wm); | |
463 draw_alpha_buf(obj,x+ax[1]+aw[1]-1,y,wm-ax[1]-aw[1]+1,hm,buf[tc.bg],buf[8],wm); | |
464 //horizontal | |
465 draw_alpha_buf(obj,x,y ,wm,1,buf[tc.bg],buf[8],wm); | |
466 draw_alpha_buf(obj,x,y+ay[0]+ah[0]-1,wm,2,buf[tc.bg],buf[8],wm); | |
467 draw_alpha_buf(obj,x,y+ay[2]+ah[2]-1,wm,2,buf[tc.bg],buf[8],wm); | |
468 draw_alpha_buf(obj,x,y+ay[4]+ah[4]-1,wm,hm-ay[4]-ah[4]+1,buf[tc.bg],buf[8],wm); | |
469 }else{ | |
470 for(b=0;b<6;b++){ | |
471 color=(tc.unicode>>b)&1?tc.fg:tc.bg; | |
472 draw_alpha_buf(obj,x+ax[b],y+ay[b],aw[b],ah[b],buf[color],buf[8],wm); | |
473 } | |
474 } | |
475 } | |
476 x+=wm; | |
477 } | |
478 y+=hm; | |
479 } | |
480 for(i=0;i<9;i++) | |
481 free(buf[i]); | |
482 } | |
483 #endif | |
484 | |
218 | 485 int vo_osd_progbar_type=-1; |
1726 | 486 int vo_osd_progbar_value=100; // 0..256 |
487 | |
488 // if we have n=256 bars then OSD progbar looks like below | |
489 // | |
1878 | 490 // 0 1 2 3 ... 256 <= vo_osd_progbar_value |
491 // | | | | | | |
1726 | 492 // [ === === === ... === ] |
493 // | |
494 // the above schema is rescalled to n=elems bars | |
218 | 495 |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
496 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
|
497 |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
498 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
|
499 |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
500 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
|
501 obj->flags&=~OSDFLAG_VISIBLE; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
502 return; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
503 } |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
504 |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
505 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
|
506 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
|
507 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
|
508 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
|
509 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
|
510 |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
511 // calculate bbox corners: |
5664 | 512 { int h=0; |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
513 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
|
514 int delimw=vo_font->width[OSD_PB_START] |
1549 | 515 +vo_font->width[OSD_PB_END] |
516 +vo_font->charspace; | |
1548
eee7951a23af
changes according to proper subfont bar positioning and char spaceing - sub.c
atlka
parents:
1524
diff
changeset
|
517 int width=(2*dxs-3*delimw)/3; |
1549 | 518 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
|
519 int elems=width/charw; |
1549 | 520 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
|
521 int delta = 0; |
5664 | 522 h=get_height(OSD_PB_START,h); |
523 h=get_height(OSD_PB_END,h); | |
524 h=get_height(OSD_PB_0,h); | |
525 h=get_height(OSD_PB_1,h); | |
8422 | 526 if (vo_osd_progbar_type>0 && vo_font->font[vo_osd_progbar_type]>=0){ |
527 delta = vo_font->width[vo_osd_progbar_type]+vo_font->spacewidth; | |
528 delta = (x-delta > 0) ? delta : x; | |
529 h=get_height(vo_osd_progbar_type,h); | |
530 } | |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
531 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
|
532 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
|
533 obj->bbox.x2=x+width+delimw; |
5664 | 534 obj->bbox.y2=y+h; //vo_font->height; |
5640 | 535 obj->flags|=OSDFLAG_BBOX; |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
536 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
|
537 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
|
538 } |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
539 |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
540 alloc_buf(obj); |
8794 | 541 |
542 { | |
543 int minw = vo_font->width[OSD_PB_START]+vo_font->width[OSD_PB_END]+vo_font->width[OSD_PB_0]; | |
544 if (vo_osd_progbar_type>0 && vo_font->font[vo_osd_progbar_type]>=0){ | |
545 minw += vo_font->width[vo_osd_progbar_type]+vo_font->charspace+vo_font->spacewidth; | |
546 } | |
547 if (obj->bbox.x2 - obj->bbox.x1 < minw) return; // space too small, don't render anything | |
548 } | |
549 | |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
550 // render it: |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
551 { unsigned char *s; |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
552 unsigned char *sa; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
553 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
|
554 int x=obj->x; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
555 int y=obj->y; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
556 int c,font; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
557 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
|
558 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
|
559 |
1726 | 560 if (vo_osd_progbar_value<=0) |
561 mark=0; | |
1878 | 562 else { |
563 int ev=vo_osd_progbar_value*elems; | |
564 mark=ev>>8; | |
565 if (ev & 0xFF) mark++; | |
566 if (mark>elems) mark=elems; | |
567 } | |
568 | |
1727 | 569 |
218 | 570 // printf("osd.progbar width=%d xpos=%d\n",width,x); |
571 | |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
572 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
|
573 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
|
574 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
|
575 draw_alpha_buf(obj,(xp<0?0:xp),y, |
218 | 576 vo_font->width[c], |
577 vo_font->pic_a[font]->h, | |
578 vo_font->pic_b[font]->bmp+vo_font->start[c], | |
579 vo_font->pic_a[font]->bmp+vo_font->start[c], | |
580 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
|
581 } |
fcbfc99cf8e6
skip lines with negative y position if there is too many lines to display
atlka
parents:
1549
diff
changeset
|
582 |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
583 c=OSD_PB_START; |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
584 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
|
585 draw_alpha_buf(obj,x,y, |
218 | 586 vo_font->width[c], |
587 vo_font->pic_a[font]->h, | |
588 vo_font->pic_b[font]->bmp+vo_font->start[c], | |
589 vo_font->pic_a[font]->bmp+vo_font->start[c], | |
590 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
|
591 x+=vo_font->width[c]+vo_font->charspace; |
218 | 592 |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
593 c=OSD_PB_0; |
1602 | 594 if ((font=vo_font->font[c])>=0){ |
595 w=vo_font->width[c]; | |
596 h=vo_font->pic_a[font]->h; | |
597 s=vo_font->pic_b[font]->bmp+vo_font->start[c]; | |
598 sa=vo_font->pic_a[font]->bmp+vo_font->start[c]; | |
599 st=vo_font->pic_a[font]->w; | |
2204 | 600 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
|
601 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
|
602 x+=charw; |
2204 | 603 } while(--i); |
1602 | 604 } |
202 | 605 |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
606 c=OSD_PB_1; |
1602 | 607 if ((font=vo_font->font[c])>=0){ |
608 w=vo_font->width[c]; | |
609 h=vo_font->pic_a[font]->h; | |
610 s =vo_font->pic_b[font]->bmp+vo_font->start[c]; | |
611 sa=vo_font->pic_a[font]->bmp+vo_font->start[c]; | |
612 st=vo_font->pic_a[font]->w; | |
2204 | 613 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
|
614 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
|
615 x+=charw; |
2204 | 616 } while(--i); |
1602 | 617 } |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
618 |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
619 c=OSD_PB_END; |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
620 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
|
621 draw_alpha_buf(obj,x,y, |
218 | 622 vo_font->width[c], |
623 vo_font->pic_a[font]->h, | |
624 vo_font->pic_b[font]->bmp+vo_font->start[c], | |
625 vo_font->pic_a[font]->bmp+vo_font->start[c], | |
626 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
|
627 // 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
|
628 |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
629 } |
218 | 630 // vo_osd_progbar_value=(vo_osd_progbar_value+1)&0xFF; |
631 | |
632 } | |
633 | |
254 | 634 subtitle* vo_sub=NULL; |
218 | 635 |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
636 // 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 | 637 |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
638 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
|
639 unsigned char *t; |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
640 int c,i,j,l,x,y,font,prevc,counter; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
641 int k; |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
642 int lastStripPosition; |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
643 int xsize; |
5640 | 644 int xmin=dxs,xmax=0; |
1591 | 645 int h,lasth; |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
646 int xtblc, utblc; |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
647 |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
648 obj->flags|=OSDFLAG_CHANGED|OSDFLAG_VISIBLE; |
7628
d6608342591d
This patch adds the functionality to disable/enable subtitles while playing
arpi
parents:
7121
diff
changeset
|
649 |
23338
2a66d95355f0
add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents:
21582
diff
changeset
|
650 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
|
651 obj->flags&=~OSDFLAG_VISIBLE; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
652 return; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
653 } |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
654 |
5664 | 655 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
|
656 obj->params.subtitle.lines=0; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
657 |
1602 | 658 // 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
|
659 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
|
660 h=sub_font->height; |
1591 | 661 lastStripPosition=-1; |
662 l=vo_sub->lines; | |
663 | |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
664 { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
665 struct osd_text_t *osl, *cp_ott, *tmp_ott, *tmp; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
666 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
|
667 *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
|
668 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
|
669 |
2204 | 670 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
|
671 xsize = -sub_font->charspace; |
2204 | 672 l--; |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
673 t=vo_sub->text[i++]; |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
674 char_position = 0; |
21581 | 675 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
|
676 |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
677 prevc = -1; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
678 |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
679 otp = NULL; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
680 osl = NULL; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
681 x = 1; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
682 |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
683 // reading the subtitle words from vo_sub->text[] |
21580 | 684 while (*t) { |
685 if (sub_utf8) | |
686 c = utf8_get_char(&t); | |
687 else if ((c = *t++) >= 0x80 && sub_unicode) | |
688 c = (c<<8) + *t++; | |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1109
diff
changeset
|
689 if (k==MAX_UCS){ |
21580 | 690 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
|
691 mp_msg(MSGT_OSD,MSGL_WARN,"\nMAX_UCS exceeded!\n"); |
1591 | 692 } |
2204 | 693 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
|
694 render_one_glyph(sub_font, c); |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
695 |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
696 if (c == ' ') { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
697 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
|
698 |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
699 if (osl == NULL) { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
700 osl = cp_ott = tmp_ott; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
701 } else { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
702 tmp_ott->prev = cp_ott; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
703 cp_ott->next = tmp_ott; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
704 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
|
705 sub_font->charspace + sub_font->width[' ']; |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
706 cp_ott = tmp_ott; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
707 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
708 tmp_ott->osd_length = xsize; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
709 tmp_ott->text_length = char_position; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
710 tmp_ott->text = (int *) malloc(char_position * sizeof(int)); |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
711 for (counter = 0; counter < char_position; ++counter) |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
712 tmp_ott->text[counter] = char_seq[counter]; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
713 char_position = 0; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
714 xsize = 0; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
715 prevc = c; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
716 } 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
|
717 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
|
718 |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
719 if (xsize + delta_xsize <= dxs) { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
720 if (!x) x = 1; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
721 prevc = c; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
722 char_seq[char_position++] = c; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
723 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
|
724 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
|
725 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
|
726 h = sub_font->pic_a[font]->h; |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
727 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
728 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
729 } else { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
730 if (x) { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
731 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
|
732 x = 0; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
733 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
734 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
735 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
736 }// for len (all words from subtitle line read) |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
737 |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
738 // 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
|
739 { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
740 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
|
741 |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
742 if (osl == NULL) { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
743 osl = cp_ott = tmp_ott; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
744 } else { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
745 tmp_ott->prev = cp_ott; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
746 cp_ott->next = tmp_ott; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
747 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
|
748 sub_font->charspace + sub_font->width[' ']; |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
749 cp_ott = tmp_ott; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
750 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
751 tmp_ott->osd_length = xsize; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
752 tmp_ott->text_length = char_position; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
753 tmp_ott->text = (int *) malloc(char_position * sizeof(int)); |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
754 for (counter = 0; counter < char_position; ++counter) |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
755 tmp_ott->text[counter] = char_seq[counter]; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
756 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
|
757 xsize = -sub_font->charspace; |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
758 } |
18716 | 759 free(char_seq); |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
760 |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
761 if (osl != NULL) { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
762 int value = 0, exit = 0, minimum = 0; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
763 |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
764 // 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
|
765 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
|
766 tmp_otp->ott = osl; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
767 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
|
768 do { |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
769 value += tmp_ott->osd_kerning + tmp_ott->osd_length; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
770 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
|
771 } 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
|
772 if (tmp_ott != NULL) { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
773 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
|
774 |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
775 tmp_otp->value = value; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
776 tmp_otp->next = tmp; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
777 tmp->prev = tmp_otp; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
778 tmp_otp = tmp; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
779 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
|
780 value = -2 * sub_font->charspace - sub_font->width[' ']; |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
781 } else { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
782 tmp_otp->value = value; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
783 exit = 1; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
784 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
785 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
786 |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
787 |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
788 #ifdef NEW_SPLITTING |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
789 // 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
|
790 // a measure of the eveness of the lenghts of the lines |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
791 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
|
792 pmt = tmp_otp->next; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
793 while (pmt != NULL) { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
794 minimum += abs(tmp_otp->value - pmt->value); |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
795 pmt = pmt->next; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
796 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
797 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
798 |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
799 if (otp->next != NULL) { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
800 int mem1, mem2; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
801 struct osd_text_p *mem, *hold; |
5640 | 802 |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
803 exit = 0; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
804 // 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
|
805 // 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
|
806 while (exit == 0) { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
807 hold = NULL; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
808 exit = 1; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
809 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
|
810 pmt = tmp_otp->next; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
811 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
|
812 if (pmt->value + tmp->osd_length + pmt->ott->osd_kerning <= xlimit) { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
813 mem1 = tmp_otp->value; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
814 mem2 = pmt->value; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
815 tmp_otp->value = mem1 - tmp->osd_length - tmp->osd_kerning; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
816 pmt->value = mem2 + tmp->osd_length + pmt->ott->osd_kerning; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
817 |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
818 value = 0; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
819 for (mem = otp; mem->next != NULL; mem = mem->next) { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
820 pmt = mem->next; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
821 while (pmt != NULL) { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
822 value += abs(mem->value - pmt->value); |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
823 pmt = pmt->next; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
824 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
825 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
826 if (value < minimum) { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
827 minimum = value; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
828 hold = tmp_otp; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
829 exit = 0; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
830 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
831 tmp_otp->value = mem1; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
832 tmp_otp->next->value = mem2; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
833 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
834 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
835 // merging |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
836 if (exit == 0) { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
837 tmp_otp = hold; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
838 pmt = tmp_otp->next; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
839 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
|
840 mem1 = tmp_otp->value; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
841 mem2 = pmt->value; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
842 tmp_otp->value = mem1 - tmp->osd_length - tmp->osd_kerning; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
843 pmt->value = mem2 + tmp->osd_length + pmt->ott->osd_kerning; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
844 pmt->ott = tmp; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
845 }//~merging |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
846 }//~while(exit == 0) |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
847 }//~if(otp->next!=NULL) |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
848 #endif |
8534
922ce27eb683
This patch adds support for vertical subtitle alignment
arpi
parents:
8451
diff
changeset
|
849 |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
850 // adding otp (containing splitted lines) to otp chain |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
851 if (otp_sub == NULL) { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
852 otp_sub = otp; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
853 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
|
854 } else { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
855 //updating ott chain |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
856 tmp = otp_sub->ott; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
857 while (tmp->next != NULL) tmp = tmp->next; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
858 tmp->next = otp->ott; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
859 otp->ott->prev = tmp; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
860 //attaching new subtitle line at the end |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
861 otp_sub_tmp->next = otp; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
862 otp->prev = otp_sub_tmp; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
863 do |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
864 otp_sub_tmp = otp_sub_tmp->next; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
865 while (otp_sub_tmp->next != NULL); |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
866 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
867 }//~ if(osl != NULL) |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
868 } // while |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
869 |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
870 // write lines into utbl |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
871 xtblc = 0; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
872 utblc = 0; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
873 obj->y = dys; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
874 obj->params.subtitle.lines = 0; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
875 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
|
876 |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
877 if ((obj->params.subtitle.lines++) >= MAX_UCSLINES) |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
878 break; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
879 |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
880 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
|
881 obj->y -= lasth - sub_font->height; // correct the y position |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
882 break; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
883 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
884 xsize = tmp_otp->value; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
885 obj->params.subtitle.xtbl[xtblc++] = (dxs - xsize) / 2; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
886 if (xmin > (dxs - xsize) / 2) |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
887 xmin = (dxs - xsize) / 2; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
888 if (xmax < (dxs + xsize) / 2) |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
889 xmax = (dxs + xsize) / 2; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
890 |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
891 tmp = (tmp_otp->next == NULL) ? NULL : tmp_otp->next->ott; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
892 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
|
893 for (counter = 0; counter < tmp_ott->text_length; ++counter) { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
894 if (utblc > MAX_UCS) { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
895 break; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
896 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
897 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
|
898 render_one_glyph(sub_font, c); |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
899 obj->params.subtitle.utbl[utblc++] = c; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
900 k++; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
901 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
902 obj->params.subtitle.utbl[utblc++] = ' '; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
903 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
904 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
|
905 obj->y -= sub_font->height; |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
906 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
907 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
|
908 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
|
909 |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
910 // free memory |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
911 if (otp_sub != NULL) { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
912 for (tmp = otp_sub->ott; tmp->next != NULL; free(tmp->prev)) { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
913 free(tmp->text); |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
914 tmp = tmp->next; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
915 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
916 free(tmp->text); |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
917 free(tmp); |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
918 |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
919 for(pmt = otp_sub; pmt->next != NULL; free(pmt->prev)) { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
920 pmt = pmt->next; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
921 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
922 free(pmt); |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
923 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
924 |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
925 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
926 /// vertical alignment |
8534
922ce27eb683
This patch adds support for vertical subtitle alignment
arpi
parents:
8451
diff
changeset
|
927 h = dys - obj->y; |
16838
fb79161e09f4
reverse incorrect sub alignment change, ok'd by diego
rfelker
parents:
16834
diff
changeset
|
928 if (sub_alignment == 2) |
8534
922ce27eb683
This patch adds support for vertical subtitle alignment
arpi
parents:
8451
diff
changeset
|
929 obj->y = dys * sub_pos / 100 - h; |
922ce27eb683
This patch adds support for vertical subtitle alignment
arpi
parents:
8451
diff
changeset
|
930 else if (sub_alignment == 1) |
922ce27eb683
This patch adds support for vertical subtitle alignment
arpi
parents:
8451
diff
changeset
|
931 obj->y = dys * sub_pos / 100 - h / 2; |
922ce27eb683
This patch adds support for vertical subtitle alignment
arpi
parents:
8451
diff
changeset
|
932 else |
922ce27eb683
This patch adds support for vertical subtitle alignment
arpi
parents:
8451
diff
changeset
|
933 obj->y = dys * sub_pos / 100; |
922ce27eb683
This patch adds support for vertical subtitle alignment
arpi
parents:
8451
diff
changeset
|
934 |
922ce27eb683
This patch adds support for vertical subtitle alignment
arpi
parents:
8451
diff
changeset
|
935 if (obj->y < 0) |
922ce27eb683
This patch adds support for vertical subtitle alignment
arpi
parents:
8451
diff
changeset
|
936 obj->y = 0; |
922ce27eb683
This patch adds support for vertical subtitle alignment
arpi
parents:
8451
diff
changeset
|
937 if (obj->y > dys - h) |
922ce27eb683
This patch adds support for vertical subtitle alignment
arpi
parents:
8451
diff
changeset
|
938 obj->y = dys - h; |
922ce27eb683
This patch adds support for vertical subtitle alignment
arpi
parents:
8451
diff
changeset
|
939 |
922ce27eb683
This patch adds support for vertical subtitle alignment
arpi
parents:
8451
diff
changeset
|
940 obj->bbox.y2 = obj->y + h; |
922ce27eb683
This patch adds support for vertical subtitle alignment
arpi
parents:
8451
diff
changeset
|
941 |
5640 | 942 // calculate bbox: |
10263 | 943 if (sub_justify) xmin = 10; |
5640 | 944 obj->bbox.x1=xmin; |
945 obj->bbox.x2=xmax; | |
946 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
|
947 // obj->bbox.y2=obj->y+obj->params.subtitle.lines*sub_font->height; |
5640 | 948 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
|
949 |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
950 alloc_buf(obj); |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
951 |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
952 y = obj->y; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
953 |
13343
1a4b6e575484
This time is a patch to improve subtitle alignment management. It
faust3
parents:
12794
diff
changeset
|
954 obj->alignment = 0; |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
955 switch(vo_sub->alignment) { |
13343
1a4b6e575484
This time is a patch to improve subtitle alignment management. It
faust3
parents:
12794
diff
changeset
|
956 case SUB_ALIGNMENT_BOTTOMLEFT: |
1a4b6e575484
This time is a patch to improve subtitle alignment management. It
faust3
parents:
12794
diff
changeset
|
957 case SUB_ALIGNMENT_MIDDLELEFT: |
1a4b6e575484
This time is a patch to improve subtitle alignment management. It
faust3
parents:
12794
diff
changeset
|
958 case SUB_ALIGNMENT_TOPLEFT: |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
959 obj->alignment |= 0x1; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
960 break; |
13343
1a4b6e575484
This time is a patch to improve subtitle alignment management. It
faust3
parents:
12794
diff
changeset
|
961 case SUB_ALIGNMENT_BOTTOMRIGHT: |
1a4b6e575484
This time is a patch to improve subtitle alignment management. It
faust3
parents:
12794
diff
changeset
|
962 case SUB_ALIGNMENT_MIDDLERIGHT: |
1a4b6e575484
This time is a patch to improve subtitle alignment management. It
faust3
parents:
12794
diff
changeset
|
963 case SUB_ALIGNMENT_TOPRIGHT: |
1a4b6e575484
This time is a patch to improve subtitle alignment management. It
faust3
parents:
12794
diff
changeset
|
964 obj->alignment |= 0x2; |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
965 break; |
13343
1a4b6e575484
This time is a patch to improve subtitle alignment management. It
faust3
parents:
12794
diff
changeset
|
966 case SUB_ALIGNMENT_BOTTOMCENTER: |
1a4b6e575484
This time is a patch to improve subtitle alignment management. It
faust3
parents:
12794
diff
changeset
|
967 case SUB_ALIGNMENT_MIDDLECENTER: |
1a4b6e575484
This time is a patch to improve subtitle alignment management. It
faust3
parents:
12794
diff
changeset
|
968 case SUB_ALIGNMENT_TOPCENTER: |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
969 default: |
13343
1a4b6e575484
This time is a patch to improve subtitle alignment management. It
faust3
parents:
12794
diff
changeset
|
970 obj->alignment |= 0x0; |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
971 } |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
972 |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
973 i=j=0; |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
974 if ((l = obj->params.subtitle.lines)) { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
975 for(counter = dxs; i < l; ++i) |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
976 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
|
977 for (i = 0; i < l; ++i) { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
978 switch (obj->alignment&0x3) { |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
979 case 1: |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
980 // left |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
981 x = counter; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
982 break; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
983 case 2: |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
984 // right |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
985 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
|
986 break; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
987 default: |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
988 //center |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
989 x = obj->params.subtitle.xtbl[i]; |
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
990 } |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
991 prevc = -1; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
992 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
|
993 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
|
994 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
|
995 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
|
996 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
|
997 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
|
998 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
|
999 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
|
1000 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
|
1001 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
|
1002 prevc = c; |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
1003 } |
23338
2a66d95355f0
add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents:
21582
diff
changeset
|
1004 y+=sub_font->height; |
10916
c36db88bfbc4
Subtitle alignment & smart splitting by Salvatore Falco
henry
parents:
10263
diff
changeset
|
1005 } |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
1006 } |
5640 | 1007 |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1008 } |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1009 |
6190
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
1010 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
|
1011 { |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
1012 unsigned int bbox[4]; |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
1013 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
|
1014 obj->bbox.x1 = bbox[0]; |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
1015 obj->bbox.x2 = bbox[1]; |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
1016 obj->bbox.y1 = bbox[2]; |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
1017 obj->bbox.y2 = bbox[3]; |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
1018 obj->flags |= OSDFLAG_BBOX; |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
1019 } |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
1020 |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
1021 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
|
1022 { |
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
1023 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
|
1024 } |
218 | 1025 |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
2498
diff
changeset
|
1026 void *vo_spudec=NULL; |
4081
9e581ab5e54b
Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents:
3180
diff
changeset
|
1027 void *vo_vobsub=NULL; |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
2498
diff
changeset
|
1028 |
947
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
865
diff
changeset
|
1029 static int draw_alpha_init_flag=0; |
218 | 1030 |
17566
f580a7755ac5
Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents:
16923
diff
changeset
|
1031 extern void vo_draw_alpha_init(void); |
1109 | 1032 |
7067
b395b1240954
fix dxr3 subtitle handling and add some optimizations
pontscho
parents:
7003
diff
changeset
|
1033 mp_osd_obj_t* vo_osd_list=NULL; |
218 | 1034 |
18950 | 1035 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
|
1036 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
|
1037 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
|
1038 osd->next=vo_osd_list; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1039 vo_osd_list=osd; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1040 osd->type=type; |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
1041 osd->alpha_buffer = NULL; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
1042 osd->bitmap_buffer = NULL; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
1043 osd->allocated = -1; |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1044 return osd; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1045 } |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1046 |
17566
f580a7755ac5
Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents:
16923
diff
changeset
|
1047 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
|
1048 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
|
1049 while(obj){ |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1050 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
|
1051 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
|
1052 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
|
1053 free(obj); |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1054 obj=next; |
4081
9e581ab5e54b
Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents:
3180
diff
changeset
|
1055 } |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1056 vo_osd_list=NULL; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1057 } |
4081
9e581ab5e54b
Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents:
3180
diff
changeset
|
1058 |
15085
1f8a1de5585c
defer loading of the font after display size change to avoid useless
henry
parents:
15078
diff
changeset
|
1059 #define FONT_LOAD_DEFER 6 |
1f8a1de5585c
defer loading of the font after display size change to avoid useless
henry
parents:
15078
diff
changeset
|
1060 |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1061 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
|
1062 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
|
1063 int chg=0; |
15085
1f8a1de5585c
defer loading of the font after display size change to avoid useless
henry
parents:
15078
diff
changeset
|
1064 #ifdef HAVE_FREETYPE |
1f8a1de5585c
defer loading of the font after display size change to avoid useless
henry
parents:
15078
diff
changeset
|
1065 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
|
1066 #endif |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
1067 |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
1068 #ifdef HAVE_FREETYPE |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
1069 // 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
|
1070 if (((dxs != vo_image_width) |
1f8a1de5585c
defer loading of the font after display size change to avoid useless
henry
parents:
15078
diff
changeset
|
1071 && (subtitle_autoscale == 2 || subtitle_autoscale == 3)) |
1f8a1de5585c
defer loading of the font after display size change to avoid useless
henry
parents:
15078
diff
changeset
|
1072 || ((dys != vo_image_height) |
1f8a1de5585c
defer loading of the font after display size change to avoid useless
henry
parents:
15078
diff
changeset
|
1073 && (subtitle_autoscale == 1 || subtitle_autoscale == 3))) |
1f8a1de5585c
defer loading of the font after display size change to avoid useless
henry
parents:
15078
diff
changeset
|
1074 { |
1f8a1de5585c
defer loading of the font after display size change to avoid useless
henry
parents:
15078
diff
changeset
|
1075 // screen dimensions changed |
1f8a1de5585c
defer loading of the font after display size change to avoid useless
henry
parents:
15078
diff
changeset
|
1076 // 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
|
1077 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
|
1078 defer_counter++; |
1f8a1de5585c
defer loading of the font after display size change to avoid useless
henry
parents:
15078
diff
changeset
|
1079 } else { |
1f8a1de5585c
defer loading of the font after display size change to avoid useless
henry
parents:
15078
diff
changeset
|
1080 prev_dxs = dxs; |
1f8a1de5585c
defer loading of the font after display size change to avoid useless
henry
parents:
15078
diff
changeset
|
1081 prev_dys = dys; |
1f8a1de5585c
defer loading of the font after display size change to avoid useless
henry
parents:
15078
diff
changeset
|
1082 defer_counter = 0; |
1f8a1de5585c
defer loading of the font after display size change to avoid useless
henry
parents:
15078
diff
changeset
|
1083 } |
1f8a1de5585c
defer loading of the font after display size change to avoid useless
henry
parents:
15078
diff
changeset
|
1084 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
|
1085 } |
1f8a1de5585c
defer loading of the font after display size change to avoid useless
henry
parents:
15078
diff
changeset
|
1086 |
23338
2a66d95355f0
add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents:
21582
diff
changeset
|
1087 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
|
1088 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
|
1089 load_font_ft(dxs, dys, &vo_font, font_name); |
23742
93c871be0258
Use -font for subtitles when -subfont is not given, patch by kiriuja
zuxy
parents:
23573
diff
changeset
|
1090 if (sub_font_name) |
93c871be0258
Use -font for subtitles when -subfont is not given, patch by kiriuja
zuxy
parents:
23573
diff
changeset
|
1091 load_font_ft(dxs, dys, &sub_font, sub_font_name); |
93c871be0258
Use -font for subtitles when -subfont is not given, patch by kiriuja
zuxy
parents:
23573
diff
changeset
|
1092 else |
93c871be0258
Use -font for subtitles when -subfont is not given, patch by kiriuja
zuxy
parents:
23573
diff
changeset
|
1093 sub_font = vo_font; |
15085
1f8a1de5585c
defer loading of the font after display size change to avoid useless
henry
parents:
15078
diff
changeset
|
1094 prev_dxs = dxs; |
1f8a1de5585c
defer loading of the font after display size change to avoid useless
henry
parents:
15078
diff
changeset
|
1095 prev_dys = dys; |
1f8a1de5585c
defer loading of the font after display size change to avoid useless
henry
parents:
15078
diff
changeset
|
1096 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
|
1097 } else { |
2a66d95355f0
add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents:
21582
diff
changeset
|
1098 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
|
1099 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
|
1100 if (!sub_font) |
23742
93c871be0258
Use -font for subtitles when -subfont is not given, patch by kiriuja
zuxy
parents:
23573
diff
changeset
|
1101 if (sub_font_name) |
93c871be0258
Use -font for subtitles when -subfont is not given, patch by kiriuja
zuxy
parents:
23573
diff
changeset
|
1102 load_font_ft(dxs, dys, &sub_font, sub_font_name); |
93c871be0258
Use -font for subtitles when -subfont is not given, patch by kiriuja
zuxy
parents:
23573
diff
changeset
|
1103 else |
93c871be0258
Use -font for subtitles when -subfont is not given, patch by kiriuja
zuxy
parents:
23573
diff
changeset
|
1104 sub_font = vo_font; |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
1105 } |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
1106 #endif |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
1107 |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1108 while(obj){ |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1109 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
|
1110 int vis=obj->flags&OSDFLAG_VISIBLE; |
5640 | 1111 obj->flags&=~OSDFLAG_BBOX; |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1112 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
|
1113 #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
|
1114 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
|
1115 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
|
1116 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
|
1117 #endif |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1118 case OSDTYPE_SUBTITLE: |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1119 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
|
1120 break; |
23903 | 1121 #ifdef HAVE_TV_TELETEXT |
1122 case OSDTYPE_TELETEXT: | |
1123 vo_update_text_teletext(obj,dxs,dys); | |
1124 break; | |
1125 #endif | |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1126 case OSDTYPE_PROGBAR: |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1127 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
|
1128 break; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1129 case OSDTYPE_SPU: |
7628
d6608342591d
This patch adds the functionality to disable/enable subtitles while playing
arpi
parents:
7121
diff
changeset
|
1130 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
|
1131 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
|
1132 obj->flags|=OSDFLAG_VISIBLE|OSDFLAG_CHANGED; |
6190
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
1133 } |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1134 else |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1135 obj->flags&=~OSDFLAG_VISIBLE; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1136 break; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1137 case OSDTYPE_OSD: |
5640 | 1138 if(vo_font && vo_osd_text && vo_osd_text[0]){ |
1139 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
|
1140 obj->flags|=OSDFLAG_VISIBLE|OSDFLAG_CHANGED; |
5640 | 1141 } else |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1142 obj->flags&=~OSDFLAG_VISIBLE; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1143 break; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1144 } |
5640 | 1145 // check bbox: |
1146 if(!(obj->flags&OSDFLAG_BBOX)){ | |
1147 // we don't know, so assume the whole screen changed :( | |
1148 obj->bbox.x1=obj->bbox.y1=0; | |
1149 obj->bbox.x2=dxs; | |
1150 obj->bbox.y2=dys; | |
1151 obj->flags|=OSDFLAG_BBOX; | |
5664 | 1152 } else { |
1153 // check bbox, reduce it if it's out of bounds (corners): | |
1154 if(obj->bbox.x1<0) obj->bbox.x1=0; | |
1155 if(obj->bbox.y1<0) obj->bbox.y1=0; | |
1156 if(obj->bbox.x2>dxs) obj->bbox.x2=dxs; | |
1157 if(obj->bbox.y2>dys) obj->bbox.y2=dys; | |
1158 if(obj->flags&OSDFLAG_VISIBLE) | |
1159 // debug: | |
1160 mp_msg(MSGT_OSD,MSGL_DBG2,"OSD update: %d;%d %dx%d \n", | |
5640 | 1161 obj->bbox.x1,obj->bbox.y1,obj->bbox.x2-obj->bbox.x1, |
1162 obj->bbox.y2-obj->bbox.y1); | |
1163 } | |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1164 // check if visibility changed: |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1165 if(vis != (obj->flags&OSDFLAG_VISIBLE) ) obj->flags|=OSDFLAG_CHANGED; |
5640 | 1166 // 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
|
1167 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
|
1168 obj->flags&=~OSDFLAG_FORCE_UPDATE; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1169 } |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1170 if(obj->flags&OSDFLAG_CHANGED){ |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1171 chg|=1<<obj->type; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1172 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
|
1173 } |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1174 obj=obj->next; |
4081
9e581ab5e54b
Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents:
3180
diff
changeset
|
1175 } |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1176 return chg; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1177 } |
4081
9e581ab5e54b
Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents:
3180
diff
changeset
|
1178 |
17566
f580a7755ac5
Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents:
16923
diff
changeset
|
1179 void vo_init_osd(void){ |
947
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
865
diff
changeset
|
1180 if(!draw_alpha_init_flag){ |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
865
diff
changeset
|
1181 draw_alpha_init_flag=1; |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
865
diff
changeset
|
1182 vo_draw_alpha_init(); |
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
865
diff
changeset
|
1183 } |
6110 | 1184 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
|
1185 // 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
|
1186 new_osd_obj(OSDTYPE_OSD); |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1187 new_osd_obj(OSDTYPE_SUBTITLE); |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1188 new_osd_obj(OSDTYPE_PROGBAR); |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1189 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
|
1190 #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
|
1191 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
|
1192 #endif |
23903 | 1193 #if HAVE_TV_TELETEXT |
1194 new_osd_obj(OSDTYPE_TELETEXT); | |
1195 #endif | |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
1196 #ifdef HAVE_FREETYPE |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
1197 force_load_font = 1; |
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
1198 #endif |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1199 } |
947
76fd9463b9d3
FAST_OSD option to disable font outline antialiasing
arpi_esp
parents:
865
diff
changeset
|
1200 |
5642
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
1201 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
|
1202 |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
1203 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
|
1204 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
|
1205 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
|
1206 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
|
1207 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
|
1208 (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
|
1209 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
|
1210 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
|
1211 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
|
1212 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
|
1213 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
|
1214 } |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
1215 // 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
|
1216 } |
5645 | 1217 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
|
1218 } |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
1219 } |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
1220 |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1221 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
|
1222 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
|
1223 vo_update_osd(dxs,dys); |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1224 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
|
1225 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
|
1226 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
|
1227 switch(obj->type){ |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1228 case OSDTYPE_SPU: |
6190
bd6748605681
Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents:
6110
diff
changeset
|
1229 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
|
1230 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
|
1231 #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
|
1232 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
|
1233 #endif |
23903 | 1234 #ifdef HAVE_TV_TELETEXT |
1235 case OSDTYPE_TELETEXT: | |
1236 #endif | |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1237 case OSDTYPE_OSD: |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1238 case OSDTYPE_SUBTITLE: |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1239 case OSDTYPE_PROGBAR: |
7121
6abc330b5b32
subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents:
7067
diff
changeset
|
1240 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
|
1241 break; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1242 } |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1243 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
|
1244 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
|
1245 } |
eb0cb6185e6c
osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents:
5640
diff
changeset
|
1246 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
|
1247 obj=obj->next; |
218 | 1248 } |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1249 } |
3034
24d3dca4e813
DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents:
2498
diff
changeset
|
1250 |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4773
diff
changeset
|
1251 static int vo_osd_changed_status = 0; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4773
diff
changeset
|
1252 |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4773
diff
changeset
|
1253 int vo_osd_changed(int new_value) |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4773
diff
changeset
|
1254 { |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1255 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
|
1256 int ret = vo_osd_changed_status; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4773
diff
changeset
|
1257 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
|
1258 |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1259 while(obj){ |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1260 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
|
1261 obj=obj->next; |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1262 } |
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1263 |
4807
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4773
diff
changeset
|
1264 return ret; |
156482788caf
osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents:
4773
diff
changeset
|
1265 } |
5638
86663f1b9b00
new osd code, use osd objs to follow changes and do minimal updates
arpi
parents:
5503
diff
changeset
|
1266 |
5645 | 1267 // BBBBBBBBBBBB AAAAAAAAAAAAA BBBBBBBBBBB |
1268 // BBBBBBBBBBBB BBBBBBBBBBBBB | |
1269 // BBBBBBB | |
1270 | |
1271 // return TRUE if we have osd in the specified rectangular area: | |
1272 int vo_osd_check_range_update(int x1,int y1,int x2,int y2){ | |
1273 mp_osd_obj_t* obj=vo_osd_list; | |
1274 while(obj){ | |
1275 if(obj->flags&OSDFLAG_VISIBLE){ | |
1276 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
|
1277 (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
|
1278 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
|
1279 ) return 1; |
5645 | 1280 } |
1281 obj=obj->next; | |
1282 } | |
1283 return 0; | |
1284 } |