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