mirror of
https://github.com/mpv-player/mpv
synced 2025-03-20 10:17:31 +00:00
sub/osd interface changes
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@219 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
3bdf0810d7
commit
180ba6b355
104
libvo/sub.c
104
libvo/sub.c
@ -1,19 +1,12 @@
|
||||
|
||||
#include "sub.h"
|
||||
|
||||
//static int vo_font_loaded=-1;
|
||||
font_desc_t* vo_font=NULL;
|
||||
|
||||
int vo_sub_lines=2;
|
||||
unsigned char* vo_sub_text[8];
|
||||
|
||||
unsigned char* vo_osd_text="00: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)){
|
||||
int i;
|
||||
int y;
|
||||
|
||||
if(!vo_font) return; // no font
|
||||
|
||||
if(vo_osd_text){
|
||||
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;
|
||||
int y=10;
|
||||
@ -31,12 +24,78 @@ void vo_draw_text(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h,
|
||||
vo_font->pic_a[font]->w);
|
||||
x+=vo_font->width[c]+vo_font->charspace;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int vo_osd_progbar_type=-1;
|
||||
int vo_osd_progbar_value=100; // 0..255
|
||||
|
||||
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 len=strlen(vo_osd_text);
|
||||
int i;
|
||||
int y=dys/2;
|
||||
int x;
|
||||
int c,font;
|
||||
int width=(dxs/2-vo_font->width[0x10]-vo_font->width[0x12]);
|
||||
int elems=width/vo_font->width[0x11];
|
||||
int mark=(vo_osd_progbar_value*(elems+1))>>8;
|
||||
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)
|
||||
draw_alpha(x-vo_font->width[c]-vo_font->spacewidth,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);
|
||||
|
||||
c=OSD_PB_START;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];
|
||||
|
||||
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_END;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];
|
||||
|
||||
}
|
||||
|
||||
#if 1
|
||||
// vo_osd_progbar_value=(vo_osd_progbar_value+1)&0xFF;
|
||||
|
||||
}
|
||||
|
||||
|
||||
int vo_sub_lines=2;
|
||||
unsigned char* vo_sub_text[8];
|
||||
|
||||
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;
|
||||
|
||||
if(vo_sub_lines<=0) return; // no text
|
||||
y=dys-(1+vo_sub_lines)*vo_font->height;
|
||||
|
||||
for(i=0;i<vo_sub_lines;i++){
|
||||
@ -74,9 +133,24 @@ void vo_draw_text(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h,
|
||||
y+=vo_font->height;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
|
||||
if(vo_osd_text){
|
||||
vo_draw_text_osd(dxs,dys,draw_alpha);
|
||||
}
|
||||
|
||||
if(vo_sub_lines>0){
|
||||
vo_draw_text_sub(dxs,dys,draw_alpha);
|
||||
}
|
||||
|
||||
if(vo_osd_progbar_type>=0){
|
||||
vo_draw_text_progbar(dxs,dys,draw_alpha);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
29
libvo/sub.h
Normal file
29
libvo/sub.h
Normal file
@ -0,0 +1,29 @@
|
||||
|
||||
extern font_desc_t* vo_font;
|
||||
|
||||
extern unsigned char* vo_osd_text;
|
||||
|
||||
extern int vo_osd_progbar_type;
|
||||
extern int vo_osd_progbar_value; // 0..255
|
||||
|
||||
extern int vo_sub_lines;
|
||||
extern unsigned char* vo_sub_text[8];
|
||||
|
||||
#define OSD_PLAY 0x01
|
||||
#define OSD_PAUSE 0x02
|
||||
#define OSD_STOP 0x03
|
||||
#define OSD_REW 0x04
|
||||
#define OSD_FFW 0x05
|
||||
#define OSD_CLOCK 0x06
|
||||
#define OSD_CONTRAST 0x07
|
||||
#define OSD_SATURATION 0x08
|
||||
#define OSD_VOLUME 0x09
|
||||
#define OSD_BRIGHTNESS 0x0A
|
||||
#define OSD_HUE 0x0B
|
||||
|
||||
#define OSD_PB_START 0x10
|
||||
#define OSD_PB_0 0x11
|
||||
#define OSD_PB_END 0x12
|
||||
#define OSD_PB_1 0x13
|
||||
|
||||
|
@ -105,8 +105,4 @@ typedef struct vo_functions_s
|
||||
// NULL terminated array of all drivers
|
||||
extern vo_functions_t* video_out_drivers[];
|
||||
|
||||
extern int vo_sub_lines;
|
||||
extern unsigned char* vo_sub_text[8];
|
||||
extern unsigned char* vo_osd_text;
|
||||
extern font_desc_t* vo_font;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user