changes according to -utf8 option, draw_osd() function added

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@1502 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
atlka 2001-08-13 11:08:18 +00:00
parent eefce080f0
commit ca99c8dc89
23 changed files with 257 additions and 139 deletions

View File

@ -35,6 +35,7 @@ extern int vo_dbpp;
#ifdef USE_SUB
extern int sub_unicode;
extern int sub_utf8;
#endif
#ifdef USE_OSD
@ -92,6 +93,8 @@ struct config conf[]={
{"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},

View File

@ -6,17 +6,19 @@ font_desc_t* vo_font=NULL;
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;
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;
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 (*cp){
c=*cp;
cp++;
if ((font=vo_font->font[c])>=0)
draw_alpha(x,y,
vo_font->width[c],
vo_font->pic_a[font]->h,
@ -31,9 +33,9 @@ static void vo_draw_text_osd(int dxs,int dys,void (*draw_alpha)(int x0,int y0, i
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)){
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)){
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]);
@ -42,8 +44,8 @@ static void vo_draw_text_progbar(int dxs,int dys,void (*draw_alpha)(int x0,int y
x=(dxs-width)/2;
// printf("osd.progbar width=%d xpos=%d\n",width,x);
c=vo_osd_progbar_type;font=vo_font->font[c];
if(vo_osd_progbar_type>0 && font>=0)
c=vo_osd_progbar_type;
if(vo_osd_progbar_type>0 && (font=vo_font->font[c])>=0)
draw_alpha(x-vo_font->width[c]-vo_font->spacewidth,y,
vo_font->width[c],
vo_font->pic_a[font]->h,
@ -51,8 +53,8 @@ static void vo_draw_text_progbar(int dxs,int dys,void (*draw_alpha)(int x0,int y
vo_font->pic_a[font]->bmp+vo_font->start[c],
vo_font->pic_a[font]->w);
c=OSD_PB_START;font=vo_font->font[c];
if(font>=0)
c=OSD_PB_START;
if ((font=vo_font->font[c])>=0)
draw_alpha(x,y,
vo_font->width[c],
vo_font->pic_a[font]->h,
@ -61,20 +63,32 @@ static void vo_draw_text_progbar(int dxs,int dys,void (*draw_alpha)(int x0,int y
vo_font->pic_a[font]->w);
x+=vo_font->width[c];
for(i=0;i<elems;i++){
c=(i<mark)?OSD_PB_0:OSD_PB_1;font=vo_font->font[c];
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];
}
c=OSD_PB_0;
if ((font=vo_font->font[c])>=0)
for (i=mark;i--;){
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];
}
c=OSD_PB_END;font=vo_font->font[c];
if(font>=0)
c=OSD_PB_1;
if ((font=vo_font->font[c])>=0)
for (i=elems-mark;i--;){
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];
}
c=OSD_PB_END;
if ((font=vo_font->font[c])>=0)
draw_alpha(x,y,
vo_font->width[c],
vo_font->pic_a[font]->h,
@ -90,64 +104,88 @@ static void vo_draw_text_progbar(int dxs,int dys,void (*draw_alpha)(int x0,int y
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;
#define MAX_UCS 1600
#define MAX_UCSLINES 16
// 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;
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;
unsigned char *t;
int i;
int j;
int k;
int l;
int x;
int y;
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;
}
}
}
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;
memy=dys-vo_font->height/4;
// too long lines divide into smaller ones
i=k=lines=0; l=vo_sub->lines;
while (l--){
t=vo_sub->text[i++];
len=strlen(t)-1;
xsize=lastxsize=-vo_font->charspace;
lastStripPosition=-1;
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;
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]=l=0;
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){
l=0;
break;
}
memy-=vo_font->height;
xsize=lastxsize=-vo_font->charspace;
}
xsize+=w+vo_font->charspace;
if ((dxs<xsize && lastStripPosition>0) || j==len-1)
@ -179,8 +217,28 @@ static void vo_draw_text_sub(int dxs,int dys,void (*draw_alpha)(int x0,int y0, i
xsize=lastxsize=-vo_font->charspace;
}
}
}
}
y = memy;
k=i=0; l=lines;
while (l--){
x = xtbl[i++];
while (utbl[k]){
c=utbl[k];
k++;
if (x>=0 && x+vo_font->width[c]<=dxs)
if ((font=vo_font->font[c])>=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;

View File

@ -72,6 +72,11 @@ typedef struct vo_functions_s
*/
uint32_t (*draw_slice)(uint8_t *src[], int stride[], int w,int h, int x,int y);
/*
* Draws OSD to the screen buffer
*/
void (*draw_osd)(void);
/*
* Blit/Flip buffer to the screen. Must be called after each frame!
*/

View File

@ -37,6 +37,7 @@ static uint32_t query_format(uint32_t format);
get_info,\
draw_frame,\
draw_slice,\
draw_osd,\
flip_page,\
check_events,\
uninit,\

View File

@ -450,6 +450,10 @@ draw_slice(uint8_t *src[], uint32_t slice_num)
return 0;
}
static void draw_osd(void)
{
}
static void
flip_page(void)
{

View File

@ -23,6 +23,9 @@
* - works only on x86 architectures
*
* $Log$
* Revision 1.30 2001/08/13 11:08:18 atlka
* changes according to -utf8 option, draw_osd() function added
*
* Revision 1.29 2001/07/16 18:41:52 jkeil
* vo_dga doesn't compile on non-x86 architecture due to x86 asm usage.
*
@ -524,10 +527,12 @@ static void check_events(void)
#include "sub.h"
static void draw_osd(void)
{ vo_draw_text(vo_dga_src_width,vo_dga_src_height,draw_alpha); }
static void flip_page( void ){
if(vo_dga_dbf_mem_offset != 0){
vo_draw_text(vo_dga_src_width,vo_dga_src_height,draw_alpha);
#ifdef HAVE_DGA2
XDGASetViewport (vo_dga_dpy, XDefaultScreen(vo_dga_dpy),
@ -539,7 +544,6 @@ static void flip_page( void ){
#endif
vo_dga_dbf_current = 1 - vo_dga_dbf_current;
}
check_events();
}
//---------------------------------------------------------

View File

@ -1130,10 +1130,13 @@ static void put_frame(void)
}
}
static void flip_page(void)
static void draw_osd(void)
{
vo_draw_text(in_width, in_height, draw_alpha);
check_events();
}
static void flip_page(void)
{
put_frame();
}

View File

@ -173,10 +173,12 @@ static void check_events(void)
int e=vo_x11_check_events(vo_dga_dpy);
}
static void flip_page( void ){
check_events();
// printf("vo_dga: In flippage\n");
static void draw_osd(void)
{
}
static void flip_page( void ){
// printf("vo_dga: In flippage\n");
}
static unsigned int pix_buf_y[4][2048];

View File

@ -524,12 +524,15 @@ static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src,
}
#endif
static void flip_page(void)
static void draw_osd(void)
{
check_events();
#ifdef GGI_OSD
vo_draw_text(ggi_conf.width, ggi_conf.height, draw_alpha);
#endif
}
static void flip_page(void)
{
ggiFlush(ggi_conf.vis);
}

View File

@ -332,13 +332,14 @@ static void check_events(void)
if(e&VO_EVENT_RESIZE) resize(vo_dwidth,vo_dheight);
}
static void draw_osd(void)
{
}
static void
flip_page(void)
{
check_events();
// glEnable(GL_TEXTURE_2D);
// glBindTexture(GL_TEXTURE_2D, texture_id);

View File

@ -49,6 +49,10 @@ get_info(void)
return &vo_info;
}
static void draw_osd(void)
{
}
static void flip_page (void)
{
char buf2[100];

View File

@ -113,9 +113,13 @@ uninit(void)
printf("vo: uninit!\n");
}
static void flip_page(void)
static void draw_osd(void)
{
vo_draw_text(mga_vid_config.src_width,mga_vid_config.src_height,draw_alpha);
}
static void flip_page(void)
{
vo_mga_flip_page();
}

View File

@ -45,6 +45,10 @@ static uint32_t draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int
return 0;
}
static void draw_osd(void)
{
}
static void
flip_page(void)
{

View File

@ -221,6 +221,10 @@ static uint32_t draw_frame(uint8_t * src[])
}
static void draw_osd(void)
{
}
static void flip_page (void)
{
char buf[100];

View File

@ -1152,9 +1152,15 @@ static void check_events (void)
}
}
static void draw_osd(void)
{ struct sdl_priv_s *priv = &sdl_priv;
/* update osd/subtitles */
vo_draw_text(priv->width,priv->height,draw_alpha);
}
/**
* Display the surface we have written our data to and check for events.
* Display the surface we have written our data to
*
* params : mode == index of the desired fullscreen mode
* returns : doesn't return
@ -1164,12 +1170,6 @@ static void flip_page (void)
{
struct sdl_priv_s *priv = &sdl_priv;
/* update osd/subtitles */
vo_draw_text(priv->width,priv->height,draw_alpha);
/* check and react on keypresses and window resizes */
check_events();
switch(priv->format) {
case IMGFMT_RGB15:
case IMGFMT_BGR15:

View File

@ -509,7 +509,8 @@ static uint32_t draw_slice(uint8_t *image[], int stride[],
return (0);
}
static void flip_page(void) {
static void draw_osd(void)
{
if (y_pos) {
gl_fillbox(0, 0, WIDTH, y_pos, 0);
gl_fillbox(0, HEIGHT - y_pos, WIDTH, y_pos, 0);
@ -520,6 +521,9 @@ static void flip_page(void) {
}
vo_draw_text(WIDTH, HEIGHT, draw_alpha);
}
static void flip_page(void) {
gl_copyscreen(screen);
}
@ -538,13 +542,9 @@ static void uninit(void) {
free(scalebuf);
if (yuvbuf != NULL)
free(yuvbuf);
if (modelist != NULL) {
while (modelist->next != NULL) {
list = modelist;
while (list->next != NULL)
list = list->next;
free(list);
}
free(modelist);
while (modelist != NULL) {
list=modelist;
modelist=modelist->next;
free(list);
}
}

View File

@ -272,8 +272,9 @@ draw_slice(uint8_t *src[], int stride[], int w,int h,int x,int y)
return 0;
}
static void draw_osd(void)
{
}
static void
flip_page(void)

View File

@ -373,7 +373,6 @@ static void Display_Image( XImage *myximage,uint8_t *ImageData )
0,0,
( vo_dwidth - myximage->width ) / 2,( vo_dheight - myximage->height ) / 2,
myximage->width,myximage->height,True );
XFlush( mDisplay );
}
else
#endif
@ -382,7 +381,6 @@ static void Display_Image( XImage *myximage,uint8_t *ImageData )
0,0,
( vo_dwidth - myximage->width ) / 2,( vo_dheight - myximage->height ) / 2,
myximage->width,myximage->height );
XFlush( mDisplay );
}
#endif
}
@ -405,10 +403,12 @@ static void draw_alpha(int x0,int y0, int w,int h, unsigned char* src, unsigned
}
}
static void draw_osd(void)
{ vo_draw_text(image_width,image_height,draw_alpha); }
static void flip_page( void ){
vo_draw_text(image_width,image_height,draw_alpha);
check_events();
Display_Image( myximage,ImageData );
XSync(mDisplay, False);
}
static uint32_t draw_slice( uint8_t *src[],int stride[],int w,int h,int x,int y )

View File

@ -161,6 +161,9 @@ static void check_events(void)
}
static void draw_osd(void)
{ vo_draw_text(mga_vid_config.src_width,mga_vid_config.src_height,draw_alpha);}
static void flip_page(void){
#ifdef SHOW_TIME
unsigned int t;
@ -170,10 +173,7 @@ static void flip_page(void){
timer=t;
#endif
vo_draw_text(mga_vid_config.src_width,mga_vid_config.src_height,draw_alpha);
check_events();
vo_mga_flip_page();
vo_mga_flip_page();
}
static uint32_t init( uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t fullscreen, char *title, uint32_t format )

View File

@ -328,16 +328,20 @@ static void draw_alpha(int x0,int y0, int w,int h, unsigned char* src, unsigned
}
static void draw_osd(void)
{ vo_draw_text(image_width,image_height,draw_alpha);}
static void flip_page(void)
{
vo_draw_text(image_width,image_height,draw_alpha);
check_events();
XvShmPutImage(mDisplay, xv_port, mywindow, mygc, xvimage[current_buf],
0, 0, image_width, image_height,
drwX,drwY,drwWidth,(mFullscreen?drwHeight - 1:drwHeight),
False);
XFlush(mDisplay);
current_buf=(current_buf+1)%num_buffers;
if (num_buffers>1){
current_buf=(current_buf+1)%num_buffers;
XFlush(mDisplay);
} else
XSync(mDisplay, False);
return;
}

View File

@ -137,7 +137,8 @@ void vo_x11_putkey(int key){
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);
}
}

View File

@ -1216,6 +1216,10 @@ if(1)
vdecode_time=video_time_usage-vdecode_time;
//------------------------ frame decoded. --------------------
//------------------------ add OSD to frame contents ---------
#ifndef USE_LIBVO2
video_out->draw_osd();
#endif
// Increase video timers:
sh_video->num_frames+=frame_time;
@ -1255,7 +1259,7 @@ if(1)
printf("\nstill dropping, %.2f\n", time_frame);
}
}
video_out->check_events(); // check events AST
} else {
// It's time to sleep...
current_module="sleep";
@ -1304,6 +1308,7 @@ if(1)
#ifdef USE_LIBVO2
if(blit_frame) vo2_flip(video_out,0);
#else
video_out->check_events();
if(blit_frame) video_out->flip_page();
#endif
// usec_sleep(50000); // test only!
@ -1532,16 +1537,19 @@ if(auto_quality>0){
case 'x':
sub_delay += 0.1;
break;
case '9': c='/'; goto _jump1;
case '0': c='*';
_jump1:
case '*':
case '/': {
float mixer_l, mixer_r;
mixer_getvolume( &mixer_l,&mixer_r );
if(c=='*'){
mixer_l++; if ( mixer_l > 100 ) mixer_l = 100;
mixer_r++; if ( mixer_r > 100 ) mixer_r = 100;
if ( ++mixer_l > 100 ) mixer_l = 100;
if ( ++mixer_r > 100 ) mixer_r = 100;
} else {
mixer_l--; if ( mixer_l < 0 ) mixer_l = 0;
mixer_r--; if ( mixer_r < 0 ) mixer_r = 0;
if ( --mixer_l < 0 ) mixer_l = 0;
if ( --mixer_r < 0 ) mixer_r = 0;
}
mixer_setvolume( mixer_l,mixer_r );
@ -1563,9 +1571,9 @@ if(auto_quality>0){
case '1':
case '2':
if(c=='2'){
if ( v_cont++ > 100 ) v_cont = 100;
if ( ++v_cont > 100 ) v_cont = 100;
} else {
if ( v_cont-- < 0 ) v_cont = 0;
if ( --v_cont < 0 ) v_cont = 0;
}
if(set_video_colors(sh_video,"Contrast",v_cont)){
#ifdef USE_OSD
@ -1582,9 +1590,9 @@ if(auto_quality>0){
case '3':
case '4':
if(c=='4'){
if ( v_bright++ > 100 ) v_bright = 100;
if ( ++v_bright > 100 ) v_bright = 100;
} else {
if ( v_bright-- < 0 ) v_bright = 0;
if ( --v_bright < 0 ) v_bright = 0;
}
if(set_video_colors(sh_video,"Brightness",v_bright)){
#ifdef USE_OSD
@ -1601,9 +1609,9 @@ if(auto_quality>0){
case '5':
case '6':
if(c=='6'){
if ( v_hue++ > 100 ) v_hue = 100;
if ( ++v_hue > 100 ) v_hue = 100;
} else {
if ( v_hue-- < 0 ) v_hue = 0;
if ( --v_hue < 0 ) v_hue = 0;
}
if(set_video_colors(sh_video,"Hue",v_hue)){
#ifdef USE_OSD
@ -1620,9 +1628,9 @@ if(auto_quality>0){
case '7':
case '8':
if(c=='8'){
if ( v_saturation++ > 100 ) v_saturation = 100;
if ( ++v_saturation > 100 ) v_saturation = 100;
} else {
if ( v_saturation-- < 0 ) v_saturation = 0;
if ( --v_saturation < 0 ) v_saturation = 0;
}
if(set_video_colors(sh_video,"Saturation",v_saturation)){
#ifdef USE_OSD

View File

@ -437,6 +437,7 @@ char * strreplace( char * in,char * what,char * whereof )
char * sub_filename(char* path, char * fname )
{
extern int sub_utf8;
char * sub_name1;
char * sub_name2;
char * aviptr1, * aviptr2, * tmp;
@ -444,7 +445,9 @@ char * sub_filename(char* path, char * fname )
FILE * f;
int pos=0;
char * sub_exts[] =
{ ".sub",
{ ".utf",
".UTF",
".sub",
".SUB",
".srt",
".SRT",
@ -484,6 +487,7 @@ char * sub_filename(char* path, char * fname )
if((f=fopen( sub_name,"rt" ))) {
fclose( f );
printf( "SUB: Detected sub file: %s\n",sub_name );
if (i<2) sub_utf8=1;
return sub_name;
}
}