2001-03-24 04:36:17 +00:00
|
|
|
|
2001-03-27 00:32:24 +00:00
|
|
|
#include "sub.h"
|
|
|
|
|
2001-03-25 04:28:40 +00:00
|
|
|
//static int vo_font_loaded=-1;
|
|
|
|
font_desc_t* vo_font=NULL;
|
2001-03-24 04:36:17 +00:00
|
|
|
|
2001-03-25 04:28:40 +00:00
|
|
|
unsigned char* vo_osd_text="00:00:00";
|
2001-05-14 22:08:12 +00:00
|
|
|
int sub_unicode=0;
|
2001-08-13 11:08:18 +00:00
|
|
|
int sub_utf8=0;
|
2001-03-24 04:36:17 +00:00
|
|
|
|
2001-08-13 11:08:18 +00:00
|
|
|
inline static void vo_draw_text_osd(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)){
|
|
|
|
unsigned char *cp=vo_osd_text;
|
|
|
|
int c;
|
|
|
|
int font;
|
2001-03-25 04:28:40 +00:00
|
|
|
int y=10;
|
|
|
|
int x=20;
|
|
|
|
|
2001-08-13 11:08:18 +00:00
|
|
|
while (*cp){
|
2001-08-16 11:36:13 +00:00
|
|
|
c=*cp++;
|
2001-08-13 11:08:18 +00:00
|
|
|
if ((font=vo_font->font[c])>=0)
|
2001-03-25 04:28:40 +00:00
|
|
|
draw_alpha(x,y,
|
|
|
|
vo_font->width[c],
|
|
|
|
vo_font->pic_a[font]->h,
|
|
|
|
vo_font->pic_b[font]->bmp+vo_font->start[c],
|
|
|
|
vo_font->pic_a[font]->bmp+vo_font->start[c],
|
|
|
|
vo_font->pic_a[font]->w);
|
|
|
|
x+=vo_font->width[c]+vo_font->charspace;
|
|
|
|
}
|
2001-03-27 00:32:24 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int vo_osd_progbar_type=-1;
|
|
|
|
int vo_osd_progbar_value=100; // 0..255
|
|
|
|
|
2001-08-13 11:08:18 +00:00
|
|
|
inline static void vo_draw_text_progbar(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)){
|
2001-08-21 11:28:50 +00:00
|
|
|
unsigned char *s;
|
|
|
|
unsigned char *sa;
|
|
|
|
int i,w,h,st;
|
2001-08-13 11:08:18 +00:00
|
|
|
int y=(dys-vo_font->height)/2;
|
2001-03-27 00:32:24 +00:00
|
|
|
int c,font;
|
2001-08-16 09:25:32 +00:00
|
|
|
int delimw=vo_font->width[OSD_PB_START]
|
2001-08-16 11:36:13 +00:00
|
|
|
+vo_font->width[OSD_PB_END]
|
|
|
|
+vo_font->charspace;
|
2001-08-16 09:25:32 +00:00
|
|
|
int width=(2*dxs-3*delimw)/3;
|
2001-08-16 11:36:13 +00:00
|
|
|
int charw=vo_font->width[OSD_PB_0]+vo_font->charspace;
|
2001-08-16 09:25:32 +00:00
|
|
|
int elems=width/charw;
|
2001-08-16 11:36:13 +00:00
|
|
|
int x=(dxs-elems*charw-delimw)/2;
|
2001-03-27 00:32:24 +00:00
|
|
|
int mark=(vo_osd_progbar_value*(elems+1))>>8;
|
2001-08-16 09:25:32 +00:00
|
|
|
|
2001-03-27 00:32:24 +00:00
|
|
|
// printf("osd.progbar width=%d xpos=%d\n",width,x);
|
|
|
|
|
2001-08-13 11:08:18 +00:00
|
|
|
c=vo_osd_progbar_type;
|
2001-08-17 08:47:58 +00:00
|
|
|
if(vo_osd_progbar_type>0 && (font=vo_font->font[c])>=0) {
|
|
|
|
int xp=x-vo_font->width[c]-vo_font->spacewidth;
|
|
|
|
draw_alpha((xp<0?0:xp),y,
|
2001-03-27 00:32:24 +00:00
|
|
|
vo_font->width[c],
|
|
|
|
vo_font->pic_a[font]->h,
|
|
|
|
vo_font->pic_b[font]->bmp+vo_font->start[c],
|
|
|
|
vo_font->pic_a[font]->bmp+vo_font->start[c],
|
|
|
|
vo_font->pic_a[font]->w);
|
2001-08-17 08:47:58 +00:00
|
|
|
}
|
|
|
|
|
2001-08-13 11:08:18 +00:00
|
|
|
c=OSD_PB_START;
|
|
|
|
if ((font=vo_font->font[c])>=0)
|
2001-03-27 00:32:24 +00:00
|
|
|
draw_alpha(x,y,
|
|
|
|
vo_font->width[c],
|
|
|
|
vo_font->pic_a[font]->h,
|
|
|
|
vo_font->pic_b[font]->bmp+vo_font->start[c],
|
|
|
|
vo_font->pic_a[font]->bmp+vo_font->start[c],
|
|
|
|
vo_font->pic_a[font]->w);
|
2001-08-16 09:25:32 +00:00
|
|
|
x+=vo_font->width[c]+vo_font->charspace;
|
2001-03-27 00:32:24 +00:00
|
|
|
|
2001-08-13 11:08:18 +00:00
|
|
|
c=OSD_PB_0;
|
2001-08-21 11:28:50 +00:00
|
|
|
if ((font=vo_font->font[c])>=0){
|
|
|
|
w=vo_font->width[c];
|
|
|
|
h=vo_font->pic_a[font]->h;
|
|
|
|
s=vo_font->pic_b[font]->bmp+vo_font->start[c];
|
|
|
|
sa=vo_font->pic_a[font]->bmp+vo_font->start[c];
|
|
|
|
st=vo_font->pic_a[font]->w;
|
2001-08-13 11:08:18 +00:00
|
|
|
for (i=mark;i--;){
|
2001-08-21 11:28:50 +00:00
|
|
|
draw_alpha(x,y,w,h,s,sa,st);
|
2001-08-16 09:25:32 +00:00
|
|
|
x+=charw;
|
2001-08-13 11:08:18 +00:00
|
|
|
}
|
2001-08-21 11:28:50 +00:00
|
|
|
}
|
2001-08-13 11:08:18 +00:00
|
|
|
|
|
|
|
c=OSD_PB_1;
|
2001-08-21 11:28:50 +00:00
|
|
|
if ((font=vo_font->font[c])>=0){
|
|
|
|
w=vo_font->width[c];
|
|
|
|
h=vo_font->pic_a[font]->h;
|
|
|
|
s =vo_font->pic_b[font]->bmp+vo_font->start[c];
|
|
|
|
sa=vo_font->pic_a[font]->bmp+vo_font->start[c];
|
|
|
|
st=vo_font->pic_a[font]->w;
|
2001-08-13 11:08:18 +00:00
|
|
|
for (i=elems-mark;i--;){
|
2001-08-21 11:28:50 +00:00
|
|
|
draw_alpha(x,y,w,h,s,sa,st);
|
2001-08-16 09:25:32 +00:00
|
|
|
x+=charw;
|
2001-08-13 11:08:18 +00:00
|
|
|
}
|
2001-08-21 11:28:50 +00:00
|
|
|
}
|
2001-08-13 11:08:18 +00:00
|
|
|
|
|
|
|
c=OSD_PB_END;
|
|
|
|
if ((font=vo_font->font[c])>=0)
|
2001-03-27 00:32:24 +00:00
|
|
|
draw_alpha(x,y,
|
|
|
|
vo_font->width[c],
|
|
|
|
vo_font->pic_a[font]->h,
|
|
|
|
vo_font->pic_b[font]->bmp+vo_font->start[c],
|
|
|
|
vo_font->pic_a[font]->bmp+vo_font->start[c],
|
|
|
|
vo_font->pic_a[font]->w);
|
2001-08-16 09:25:32 +00:00
|
|
|
// x+=vo_font->width[c]+vo_font->charspace;
|
2001-05-14 22:08:12 +00:00
|
|
|
|
2001-03-25 04:28:40 +00:00
|
|
|
|
2001-03-27 00:32:24 +00:00
|
|
|
// vo_osd_progbar_value=(vo_osd_progbar_value+1)&0xFF;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2001-03-30 03:01:50 +00:00
|
|
|
subtitle* vo_sub=NULL;
|
2001-03-27 00:32:24 +00:00
|
|
|
|
2001-08-13 11:08:18 +00:00
|
|
|
#define MAX_UCS 1600
|
|
|
|
#define MAX_UCSLINES 16
|
|
|
|
|
2001-08-20 09:14:28 +00:00
|
|
|
|
2001-08-13 11:08:18 +00:00
|
|
|
inline static void 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)){
|
|
|
|
static int utbl[MAX_UCS+1];
|
|
|
|
static int xtbl[MAX_UCSLINES];
|
|
|
|
static int lines;
|
|
|
|
static subtitle *memsub=NULL;
|
|
|
|
static int memy;
|
|
|
|
static int memdxs;
|
|
|
|
static int memdys;
|
2001-08-20 09:14:28 +00:00
|
|
|
|
2001-08-13 11:08:18 +00:00
|
|
|
unsigned char *t;
|
2001-08-20 09:14:28 +00:00
|
|
|
int c,i,j,l,x,y,font;
|
2001-08-13 11:08:18 +00:00
|
|
|
int len;
|
2001-08-20 09:14:28 +00:00
|
|
|
int k,lastk;
|
2001-08-13 11:08:18 +00:00
|
|
|
int lastStripPosition;
|
2001-08-20 09:14:28 +00:00
|
|
|
int xsize,lastxsize;
|
|
|
|
int h,lasth;
|
2001-08-13 11:08:18 +00:00
|
|
|
|
|
|
|
if ((memsub!=vo_sub)||(memdxs!=dxs)||(memdys!=dys)){
|
2001-08-20 09:14:28 +00:00
|
|
|
|
2001-08-13 11:08:18 +00:00
|
|
|
memsub=vo_sub;
|
|
|
|
memdxs=dxs;
|
2001-08-20 09:14:28 +00:00
|
|
|
memdys=memy=dys;
|
2001-08-13 11:08:18 +00:00
|
|
|
|
2001-08-21 11:28:50 +00:00
|
|
|
// too long lines divide into a smaller ones
|
2001-08-20 09:14:28 +00:00
|
|
|
i=k=lines=lasth=0;
|
|
|
|
h=vo_font->height;
|
|
|
|
xsize=-vo_font->charspace;
|
|
|
|
lastStripPosition=-1;
|
|
|
|
l=vo_sub->lines;
|
|
|
|
|
2001-08-13 11:08:18 +00:00
|
|
|
while (l--){
|
|
|
|
t=vo_sub->text[i++];
|
|
|
|
len=strlen(t)-1;
|
|
|
|
|
|
|
|
for (j=0;j<=len;j++){
|
|
|
|
if ((c=t[j])>=0x80){
|
|
|
|
if (sub_unicode)
|
|
|
|
c = (c<<8) + t[++j];
|
|
|
|
else
|
|
|
|
if (sub_utf8){
|
|
|
|
if ((c & 0xe0) == 0xc0) /* 2 bytes U+00080..U+0007FF*/
|
|
|
|
c = (c & 0x1f)<<6 | (t[++j] & 0x3f);
|
|
|
|
else if((c & 0xf0) == 0xe0)/* 3 bytes U+00800..U+00FFFF*/
|
|
|
|
c = ((c & 0x0f)<<6 |
|
|
|
|
(t[++j] & 0x3f))<<6 | (t[++j] & 0x3f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (k==MAX_UCS){
|
2001-08-20 09:14:28 +00:00
|
|
|
utbl[k]=l=0; break;
|
|
|
|
}
|
|
|
|
utbl[k++]=c;
|
2001-08-13 11:08:18 +00:00
|
|
|
if (c==' '){
|
|
|
|
lastk=k;
|
|
|
|
lastStripPosition=j;
|
|
|
|
lastxsize=xsize;
|
2001-08-20 09:14:28 +00:00
|
|
|
} else if ((font=vo_font->font[c])>=0){
|
|
|
|
if (vo_font->pic_a[font]->h > h){
|
|
|
|
h=vo_font->pic_a[font]->h;
|
|
|
|
}
|
2001-08-13 11:08:18 +00:00
|
|
|
}
|
|
|
|
xsize+=vo_font->width[c]+vo_font->charspace;
|
2001-08-20 09:14:28 +00:00
|
|
|
if (dxs<xsize){
|
|
|
|
if (lastStripPosition>0){
|
|
|
|
j=lastStripPosition;
|
|
|
|
xsize=lastxsize;
|
|
|
|
k=lastk;
|
|
|
|
} else {
|
|
|
|
xsize -=vo_font->width[c]+vo_font->charspace; // go back
|
|
|
|
k--; // cut line here
|
|
|
|
while (t[j] && t[j]!=' ') j++; // jump to the nearest space
|
|
|
|
}
|
|
|
|
} else if (j<len)
|
|
|
|
continue;
|
|
|
|
if (h>memy){ // out of the screen so end parsing
|
2001-08-21 11:28:50 +00:00
|
|
|
memy +=vo_font->height-lasth; // correct the y position
|
2001-08-20 09:14:28 +00:00
|
|
|
l=0; break;
|
|
|
|
}
|
2001-08-13 11:08:18 +00:00
|
|
|
utbl[k++]=0;
|
2001-08-20 09:14:28 +00:00
|
|
|
xtbl[lines++]=(dxs-xsize)/2;
|
2001-08-13 11:08:18 +00:00
|
|
|
if (lines==MAX_UCSLINES||k>MAX_UCS){
|
2001-08-20 09:14:28 +00:00
|
|
|
l=0; break;
|
2001-08-21 11:28:50 +00:00
|
|
|
} else if(l || j<len){ // not the last line or not the last char
|
2001-08-20 09:14:28 +00:00
|
|
|
lastStripPosition=-1;
|
|
|
|
xsize=-vo_font->charspace;
|
|
|
|
lasth=h;
|
|
|
|
h=vo_font->height;
|
|
|
|
}
|
|
|
|
memy -=h; // according to max of vo_font->pic_a[font]->h
|
|
|
|
}
|
2001-08-17 11:14:57 +00:00
|
|
|
}
|
2001-08-13 11:08:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
y = memy;
|
|
|
|
|
2001-08-20 09:14:28 +00:00
|
|
|
i=j=0; l=lines;
|
2001-08-13 11:08:18 +00:00
|
|
|
while (l--){
|
2001-08-17 08:47:58 +00:00
|
|
|
x= xtbl[i++];
|
2001-08-20 09:14:28 +00:00
|
|
|
while ((c=utbl[j++])){
|
2001-08-17 08:47:58 +00:00
|
|
|
if ((font=vo_font->font[c])>=0)
|
|
|
|
draw_alpha(x,y,
|
|
|
|
vo_font->width[c],
|
2001-08-17 11:14:57 +00:00
|
|
|
vo_font->pic_a[font]->h,
|
2001-08-17 08:47:58 +00:00
|
|
|
vo_font->pic_b[font]->bmp+vo_font->start[c],
|
|
|
|
vo_font->pic_a[font]->bmp+vo_font->start[c],
|
|
|
|
vo_font->pic_a[font]->w);
|
2001-08-20 09:14:28 +00:00
|
|
|
x+=vo_font->width[c]+vo_font->charspace;
|
2001-08-17 08:47:58 +00:00
|
|
|
}
|
2001-08-20 09:14:28 +00:00
|
|
|
y+=vo_font->height;
|
2001-08-13 11:08:18 +00:00
|
|
|
}
|
2001-03-24 04:36:17 +00:00
|
|
|
}
|
|
|
|
|
2001-06-02 16:02:38 +00:00
|
|
|
static int draw_alpha_init_flag=0;
|
2001-03-25 04:28:40 +00:00
|
|
|
|
2001-06-12 14:03:18 +00:00
|
|
|
extern void vo_draw_alpha_init();
|
|
|
|
|
2001-03-27 00:32:24 +00:00
|
|
|
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)){
|
|
|
|
|
|
|
|
if(!vo_font) return; // no font
|
|
|
|
|
2001-06-02 16:02:38 +00:00
|
|
|
if(!draw_alpha_init_flag){
|
|
|
|
draw_alpha_init_flag=1;
|
|
|
|
vo_draw_alpha_init();
|
|
|
|
}
|
|
|
|
|
2001-03-27 00:32:24 +00:00
|
|
|
if(vo_osd_text){
|
|
|
|
vo_draw_text_osd(dxs,dys,draw_alpha);
|
|
|
|
}
|
|
|
|
|
2001-03-30 03:01:50 +00:00
|
|
|
if(vo_sub){
|
2001-03-27 00:32:24 +00:00
|
|
|
vo_draw_text_sub(dxs,dys,draw_alpha);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(vo_osd_progbar_type>=0){
|
|
|
|
vo_draw_text_progbar(dxs,dys,draw_alpha);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|