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