Mercurial > mplayer.hg
comparison libvo/sub.c @ 2176:1ae16a34f055
speed improvements
author | atlka |
---|---|
date | Fri, 12 Oct 2001 13:24:07 +0000 |
parents | dee4b2ea5e5b |
children | 28901a4122c8 |
comparison
equal
deleted
inserted
replaced
2175:1deee7703f33 | 2176:1ae16a34f055 |
---|---|
171 // printf("sub(%d) '%s'\n",len,t); | 171 // printf("sub(%d) '%s'\n",len,t); |
172 // if(len<0) memy -=h; // according to max of vo_font->pic_a[font]->h | 172 // if(len<0) memy -=h; // according to max of vo_font->pic_a[font]->h |
173 // else | 173 // else |
174 for (j=0;j<=len;j++){ | 174 for (j=0;j<=len;j++){ |
175 if ((c=t[j])>=0x80){ | 175 if ((c=t[j])>=0x80){ |
176 if (sub_unicode) | 176 if (sub_utf8){ |
177 c = (c<<8) + t[++j]; | 177 if ((c & 0xe0) == 0xc0) /* 2 bytes U+00080..U+0007FF*/ |
178 else | 178 c = (c & 0x1f)<<6 | (t[++j] & 0x3f); |
179 if (sub_utf8){ | 179 else if((c & 0xf0) == 0xe0)/* 3 bytes U+00800..U+00FFFF*/ |
180 if ((c & 0xe0) == 0xc0) /* 2 bytes U+00080..U+0007FF*/ | 180 c = ((c & 0x0f)<<6 | |
181 c = (c & 0x1f)<<6 | (t[++j] & 0x3f); | 181 (t[++j] & 0x3f))<<6 | (t[++j] & 0x3f); |
182 else if((c & 0xf0) == 0xe0)/* 3 bytes U+00800..U+00FFFF*/ | 182 } else if (sub_unicode) |
183 c = ((c & 0x0f)<<6 | | 183 c = (c<<8) + t[++j]; |
184 (t[++j] & 0x3f))<<6 | (t[++j] & 0x3f); | |
185 } | |
186 } | 184 } |
187 if (k==MAX_UCS){ | 185 if (k==MAX_UCS){ |
188 utbl[k]=l=0; break; | 186 l=0 ; len=j; // cut here |
189 } | 187 } |
190 utbl[k++]=c; | 188 utbl[k++]=c; |
191 if (c==' '){ | 189 if (c==' '){ |
192 lastk=k; | 190 lastk=k; |
193 lastStripPosition=j; | 191 lastStripPosition=j; |
194 lastxsize=xsize; | 192 lastxsize=xsize; |
195 } | 193 } |
196 #if 1 | |
197 else if ((font=vo_font->font[c])>=0){ | 194 else if ((font=vo_font->font[c])>=0){ |
198 if (vo_font->pic_a[font]->h > h){ | 195 if (vo_font->pic_a[font]->h > h){ |
199 h=vo_font->pic_a[font]->h; | 196 h=vo_font->pic_a[font]->h; |
200 } | 197 } |
201 } | 198 } |
202 #endif | |
203 #if 0 | |
204 else if ((font=vo_font->font[c])>=0){ | |
205 if ((memy-h)+vo_font->pic_a[font]->h > dys){ | |
206 h=vo_font->pic_a[font]->h; | |
207 } | |
208 } | |
209 #endif | |
210 xsize+=vo_font->width[c]+vo_font->charspace; | 199 xsize+=vo_font->width[c]+vo_font->charspace; |
211 if (dxs<xsize){ | 200 if (dxs<xsize){ |
212 if (lastStripPosition>0){ | 201 if (lastStripPosition>0){ |
213 j=lastStripPosition; | 202 j=lastStripPosition; |
214 xsize=lastxsize; | 203 xsize=lastxsize; |
219 while (t[j] && t[j]!=' ') j++; // jump to the nearest space | 208 while (t[j] && t[j]!=' ') j++; // jump to the nearest space |
220 } | 209 } |
221 } else if (j<len) | 210 } else if (j<len) |
222 continue; | 211 continue; |
223 if (h>memy){ // out of the screen so end parsing | 212 if (h>memy){ // out of the screen so end parsing |
224 memy +=vo_font->height-lasth; // correct the y position | 213 memy -=lasth - vo_font->height; // correct the y position |
225 l=0; break; | 214 l=0; break; |
226 } | 215 } |
227 utbl[k++]=0; | 216 utbl[k++]=0; |
228 xtbl[lines++]=(dxs-xsize)/2; | 217 xtbl[lines++]=(dxs-xsize)/2; |
229 if (lines==MAX_UCSLINES||k>MAX_UCS){ | 218 if (lines==MAX_UCSLINES||k>MAX_UCS){ |
230 l=0; break; | 219 l=0; j=len; // end parsing |
231 } else if(l || j<len){ // not the last line or not the last char | 220 } else if(l || j<len){ // not the last line or not the last char |
232 lastStripPosition=-1; | 221 lastStripPosition=-1; |
233 xsize=-vo_font->charspace; | 222 xsize=-vo_font->charspace; |
234 lasth=h; | 223 lasth=h; |
235 h=vo_font->height; | 224 h=vo_font->height; |
236 } | 225 } |
237 printf("h: %d -> %d \n",vo_font->height,h); | 226 // printf("h: %d -> %d \n",vo_font->height,h); |
238 memy -=h; // according to max of vo_font->pic_a[font]->h | 227 memy -=h; // according to max of vo_font->pic_a[font]->h |
239 } | 228 } |
240 } | 229 } |
241 } | 230 } |
242 | 231 |
246 | 235 |
247 i=j=0; l=lines; | 236 i=j=0; l=lines; |
248 while (i<lines){ | 237 while (i<lines){ |
249 x= xtbl[i++]; | 238 x= xtbl[i++]; |
250 while ((c=utbl[j++])){ | 239 while ((c=utbl[j++])){ |
251 if ((font=vo_font->font[c])>=0 && y<dys) | 240 if ((font=vo_font->font[c])>=0) |
252 draw_alpha(x,y, | 241 draw_alpha(x,y, |
253 vo_font->width[c], | 242 vo_font->width[c], |
254 vo_font->pic_a[font]->h+y<dys ? vo_font->pic_a[font]->h : dys-y, | 243 vo_font->pic_a[font]->h+y<dys ? vo_font->pic_a[font]->h : dys-y, |
255 vo_font->pic_b[font]->bmp+vo_font->start[c], | 244 vo_font->pic_b[font]->bmp+vo_font->start[c], |
256 vo_font->pic_a[font]->bmp+vo_font->start[c], | 245 vo_font->pic_a[font]->bmp+vo_font->start[c], |