[Mplayer-users] Patch to 20010801 snapshot
Adam Tla/lka
atlka at pg.gda.pl
Mon Aug 6 13:51:08 CEST 2001
Hi,
MPlayer is better now ;-)
I am sending a few patches to MPlayer-20010806 :
qutf8.diff - cfg-mplyaer.h new options "-utf8" and "-q" (the same as "-quiet"
many software useses "-q", so maybe it will be usefull here too,
if not just forget about this chunk of patch)
- libvo/sub.c rewritten and improved to make use of utf8 subtitles
lines which are decoded to ints while calculating y position.
Also x positions are calculating in the same time, so while
displaying we have less to do. Tested and works.
x11.diff - changes to libvo/x11_common.c and mplayer.c which makes that
'0'..'9' keys works from X11 window too - not only from
controlling terminal ('0' works like '/' and '9' like '*')
seek.diif - changes to seek.c to obtain displaying OSD time while rewinding
an .avi file (now it displays 00:00:00 until rewinding is ended)
Regards
--
. . Adam Tla/lka mailto:atlka at pg.gda.pl ^v^ ^v^ ^v^
PGP public key: finger atlka at sunrise.pg.gda.pl
-------------- next part --------------
diff -ruN MPlayer-20010806/cfg-mplayer.h MPlayer-20010806n/cfg-mplayer.h
--- MPlayer-20010806/cfg-mplayer.h Mon Aug 6 02:30:29 2001
+++ MPlayer-20010806n/cfg-mplayer.h Mon Aug 6 12:38:53 2001
@@ -35,6 +35,7 @@
#ifdef USE_SUB
extern int sub_unicode;
+extern int sub_utf8;
#endif
#ifdef USE_OSD
@@ -92,6 +93,8 @@
{"noautosub", &sub_auto, CONF_TYPE_FLAG, 0, 1, 0},
{"unicode", &sub_unicode, CONF_TYPE_FLAG, 0, 0, 1},
{"nounicode", &sub_unicode, CONF_TYPE_FLAG, 0, 1, 0},
+ {"utf8", &sub_utf8, CONF_TYPE_FLAG, 0, 0, 1},
+ {"noutf8", &sub_utf8, CONF_TYPE_FLAG, 0, 1, 0},
#endif
#ifdef USE_OSD
{"font", &font_name, CONF_TYPE_STRING, 0, 0, 0},
@@ -196,6 +199,7 @@
{"idx", &index_mode, CONF_TYPE_FLAG, 0, -1, 1},
{"forceidx", &index_mode, CONF_TYPE_FLAG, 0, -1, 2},
+ {"q", &quiet, CONF_TYPE_FLAG, 0, 0, 1},
{"quiet", &quiet, CONF_TYPE_FLAG, 0, 0, 1},
{"verbose", &verbose, CONF_TYPE_INT, CONF_RANGE, 0, 100},
{"v", cfg_inc_verbose, CONF_TYPE_FUNC, 0, 0, 0},
diff -ruN MPlayer-20010806/libvo/sub.c MPlayer-20010806n/libvo/sub.c
--- MPlayer-20010806/libvo/sub.c Tue Jun 12 16:03:18 2001
+++ MPlayer-20010806n/libvo/sub.c Mon Aug 6 12:31:31 2001
@@ -6,17 +6,17 @@
unsigned char* vo_osd_text="00:00:00";
int sub_unicode=0;
+int sub_utf8=0;
-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)){
- int len=strlen(vo_osd_text);
- int j;
+static inline 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;
int y=10;
int x=20;
- for(j=0;j<len;j++){
- int c=vo_osd_text[j];
- int font=vo_font->font[c];
- if(font>=0)
+ while ((c=*cp++)!=0){
+ if ((font=vo_font->font[c])>=0)
draw_alpha(x,y,
vo_font->width[c],
vo_font->pic_a[font]->h,
@@ -31,9 +31,9 @@
int vo_osd_progbar_type=-1;
int vo_osd_progbar_value=100; // 0..255
-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)){
+static inline 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)){
int i;
- int y=dys/2;
+ int y=(dys-vo_font->height)/2;
int x;
int c,font;
int width=(dxs*2/3-vo_font->width[0x10]-vo_font->width[0x12]);
@@ -90,97 +90,110 @@
subtitle* vo_sub=NULL;
-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)){
- int i;
- int y;
- y=dys-(1+vo_sub->lines-1)*vo_font->height-10;
-
- // too long lines divide into smaller ones
- for(i=0;i<vo_sub->lines;i++){
- unsigned char* text=vo_sub->text[i];
- int len=strlen(text);
- int j;
- int xsize=-vo_font->charspace;
- int lastStripPosition=-1;
- int previousStrip=0;
- int lastxsize=0;
-
- for(j=0;j<len;j++){
- int c=text[j];
- int w;
- if (sub_unicode && (c>=0x80)) c=(c<<8)+text[++j];
- w = vo_font->width[c];
- if (text[j]==' ' && dxs>xsize)
- {
- lastStripPosition=j;
- lastxsize=xsize;
- }
- xsize+=w+vo_font->charspace;
- if (dxs<xsize && lastStripPosition>0)
- {
- xsize=lastxsize;
- j=lastStripPosition;
- y-=vo_font->height;
- previousStrip=lastStripPosition;
- xsize=-vo_font->charspace;
- }
- }
- }
-
+#define MAX_UCS 1600
+#define MAX_UCSLINES 16
- for(i=0;i<vo_sub->lines;i++){
- unsigned char* text=vo_sub->text[i];// "Hello World! H?DEJ?!";
- int len=strlen(text);
- int j,k;
- int xsize=-vo_font->charspace;
- int x=0;
-
- int lastStripPosition=-1;
- int previousStrip=0;
- int lastxsize=xsize;
-
- for(j=0;j<len;j++){
- int c=text[j];
- int w;
- if (sub_unicode && (c>=0x80)) c=(c<<8)+text[++j];
- w = vo_font->width[c];
- if (c==' ' && dxs>xsize)
- {
- lastStripPosition=j;
- lastxsize=xsize;
- }
- xsize+=w+vo_font->charspace;
- if ((dxs<xsize && lastStripPosition>0) || j==len-1)
- {
- if (j==len-1) lastStripPosition=len;
- else xsize=lastxsize;
- j=lastStripPosition;
-
- x=dxs/2-xsize/2;
-
- for(k=previousStrip;k<lastStripPosition;k++){
- int c=text[k];
- int font;
- if (sub_unicode && (c>=0x80)) c=(c<<8)+text[++k];
- font=vo_font->font[c];
- if(x>=0 && x+vo_font->width[c]<dxs)
- if(font>=0)
- 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;
- }
- x=0;
- y+=vo_font->height;
- previousStrip=lastStripPosition;
- xsize=lastxsize=-vo_font->charspace;
+static inline 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;
+ unsigned char *t;
+ int i;
+ int j;
+ int k;
+ int x;
+ int y;
+
+ int c;
+ int len;
+ int line;
+ int font;
+ int lastStripPosition;
+ int xsize;
+ int lastxsize;
+ int lastk;
+
+ if ((memsub!=vo_sub)||(memdxs!=dxs)||(memdys!=dys)){
+ memsub=vo_sub;
+ memdxs=dxs;
+ memdys=dys;
+
+ lines=0;
+ k=0;
+
+ memy=dys-vo_font->height/4;
+
+ // too long lines divide into smaller ones
+ for (i=0;i<vo_sub->lines;i++){
+ t=vo_sub->text[i];
+ len=strlen(t)-1;
+ xsize=lastxsize=-vo_font->charspace;
+ lastStripPosition=-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){
+ utbl[k]=0;
+ i=vo_sub->lines;
+ break;
+ } else
+ utbl[k++]=c;
+ if (c==' '){
+ lastk=k;
+ lastStripPosition=j;
+ lastxsize=xsize;
+ }
+ xsize+=vo_font->width[c]+vo_font->charspace;
+ if (dxs<xsize && lastStripPosition>0){
+ j=lastStripPosition;
+ k=lastk;
+ } else if (j==len){
+ lastxsize=xsize;
+ } else
+ continue;
+ utbl[k++]=0;
+ xtbl[lines++]=(dxs-lastxsize)/2;
+ if (lines==MAX_UCSLINES||k>MAX_UCS){
+ i=vo_sub->lines;
+ break;
+ }
+ memy-=vo_font->height;
+ xsize=lastxsize=-vo_font->charspace;
}
- }
- }
-
+ }
+ }
+
+ y = memy;
+
+ for (k=0,i=0;i<lines;i++){
+ x = xtbl[i];
+ while ((c=utbl[k++])!=0){
+ font=vo_font->font[c];
+ if ((x>=0) && (x+vo_font->width[c]<=dxs))
+ if (font>=0)
+ 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;
+ }
+ y+=vo_font->height;
+ }
}
static int draw_alpha_init_flag=0;
-------------- next part --------------
diff -ruN MPlayer-20010806/libvo/x11_common.c MPlayer-20010806n/libvo/x11_common.c
--- MPlayer-20010806/libvo/x11_common.c Mon Aug 6 02:22:44 2001
+++ MPlayer-20010806n/libvo/x11_common.c Mon Aug 6 10:12:22 2001
@@ -134,7 +134,9 @@
case wsM: mplayer_put_key('m'); break;
case wso:
case wsO: mplayer_put_key('o'); break;
- default: if((key>='a' && key<='z')||(key>='A' && key<='Z')) mplayer_put_key(key);
+ default: if((key>='a' && key<='z')||
+ (key>='A' && key<='Z')||
+ (key>='0' && key<='9')) mplayer_put_key(key);
}
}
diff -ruN MPlayer-20010806/mplayer.c MPlayer-20010806n/mplayer.c
--- MPlayer-20010806/mplayer.c Mon Aug 6 02:33:30 2001
+++ MPlayer-20010806n/mplayer.c Mon Aug 6 09:57:03 2001
@@ -1624,6 +1624,9 @@
case 'x':
sub_delay += 0.1;
break;
+ case '9': c='/'; goto _jump1;
+ case '0': c='*';
+_jump1:
case '*':
case '/': {
float mixer_l, mixer_r;
-------------- next part --------------
diff -ruN MPlayer-20010806/seek.c MPlayer-20010806n/seek.c
--- MPlayer-20010806/seek.c Wed Aug 1 11:14:02 2001
+++ MPlayer-20010806n/seek.c Mon Aug 6 11:14:39 2001
@@ -187,6 +187,7 @@
}
}
+ d_video->pts=avi_video_pts; // for displaying time while seeking AST
break;
//FIXME: OFF_T - didn't test ASF case yet (don't have a large asf...)
More information about the MPlayer-users
mailing list