2001-03-24 04:36:17 +00:00
|
|
|
|
2002-04-06 19:09:06 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2002-08-14 21:28:18 +00:00
|
|
|
#include <string.h>
|
2002-04-06 19:09:06 +00:00
|
|
|
|
2002-01-11 16:06:45 +00:00
|
|
|
#include "config.h"
|
2002-11-06 23:54:29 +00:00
|
|
|
#ifdef HAVE_MALLOC_H
|
|
|
|
#include <malloc.h>
|
|
|
|
#endif
|
|
|
|
|
2006-11-25 11:20:02 +00:00
|
|
|
#ifdef USE_DVDNAV
|
2006-11-25 13:03:51 +00:00
|
|
|
#include "stream/stream.h"
|
|
|
|
#include "stream/stream_dvdnav.h"
|
2006-11-25 11:20:02 +00:00
|
|
|
#define OSD_NAV_BOX_ALPHA 0x7f
|
|
|
|
#endif
|
|
|
|
|
2007-07-29 17:57:39 +00:00
|
|
|
#ifdef HAVE_TV_TELETEXT
|
|
|
|
#include "stream/tv.h"
|
2007-09-10 11:10:50 +00:00
|
|
|
#include "osdep/timer.h"
|
2007-07-29 17:57:39 +00:00
|
|
|
#endif
|
|
|
|
|
2007-05-20 16:10:45 +00:00
|
|
|
#include "mplayer.h"
|
2002-04-15 19:17:12 +00:00
|
|
|
#include "mp_msg.h"
|
2005-11-06 02:38:47 +00:00
|
|
|
#include "help_mp.h"
|
2002-01-11 16:06:45 +00:00
|
|
|
#include "video_out.h"
|
2002-03-24 00:32:13 +00:00
|
|
|
#include "font_load.h"
|
2001-03-27 00:32:24 +00:00
|
|
|
#include "sub.h"
|
2004-10-28 01:15:53 +00:00
|
|
|
#include "spudec.h"
|
2006-08-12 15:28:01 +00:00
|
|
|
#include "libavutil/common.h"
|
2001-03-27 00:32:24 +00:00
|
|
|
|
2003-09-21 13:20:06 +00:00
|
|
|
#define NEW_SPLITTING
|
|
|
|
|
|
|
|
|
|
|
|
// Structures needed for the new splitting algorithm.
|
|
|
|
// osd_text_t contains the single subtitle word.
|
|
|
|
// osd_text_p is used to mark the lines of subtitles
|
|
|
|
struct osd_text_t {
|
|
|
|
int osd_kerning, //kerning with the previous word
|
|
|
|
osd_length, //orizontal length inside the bbox
|
|
|
|
text_length, //number of characters
|
|
|
|
*text; //characters
|
|
|
|
struct osd_text_t *prev,
|
|
|
|
*next;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct osd_text_p {
|
|
|
|
int value;
|
|
|
|
struct osd_text_t *ott;
|
|
|
|
struct osd_text_p *prev,
|
|
|
|
*next;
|
|
|
|
};
|
|
|
|
//^
|
|
|
|
|
2007-08-15 10:34:53 +00:00
|
|
|
char * sub_osd_names[]={
|
2005-11-06 02:38:47 +00:00
|
|
|
MSGTR_VO_SUB_Seekbar,
|
|
|
|
MSGTR_VO_SUB_Play,
|
|
|
|
MSGTR_VO_SUB_Pause,
|
|
|
|
MSGTR_VO_SUB_Stop,
|
|
|
|
MSGTR_VO_SUB_Rewind,
|
|
|
|
MSGTR_VO_SUB_Forward,
|
|
|
|
MSGTR_VO_SUB_Clock,
|
|
|
|
MSGTR_VO_SUB_Contrast,
|
|
|
|
MSGTR_VO_SUB_Saturation,
|
|
|
|
MSGTR_VO_SUB_Volume,
|
|
|
|
MSGTR_VO_SUB_Brightness,
|
2007-06-20 02:26:20 +00:00
|
|
|
MSGTR_VO_SUB_Hue,
|
|
|
|
MSGTR_VO_SUB_Balance
|
2001-10-27 14:30:43 +00:00
|
|
|
};
|
2007-08-15 10:34:53 +00:00
|
|
|
char * sub_osd_names_short[] ={ "", "|>", "||", "[]", "<<" , ">>", "", "", "", "", "", "", "" };
|
2001-10-27 14:30:43 +00:00
|
|
|
|
2001-03-25 04:28:40 +00:00
|
|
|
//static int vo_font_loaded=-1;
|
|
|
|
font_desc_t* vo_font=NULL;
|
2007-05-20 16:10:45 +00:00
|
|
|
font_desc_t* sub_font=NULL;
|
2001-03-24 04:36:17 +00:00
|
|
|
|
2001-09-27 17:40:43 +00:00
|
|
|
unsigned char* vo_osd_text=NULL;
|
2007-07-29 17:57:39 +00:00
|
|
|
#ifdef HAVE_TV_TELETEXT
|
|
|
|
void* vo_osd_teletext_page=NULL;
|
|
|
|
int vo_osd_teletext_half = 0;
|
|
|
|
int vo_osd_teletext_mode=0;
|
|
|
|
int vo_osd_teletext_format=0;
|
|
|
|
int vo_osd_teletext_scale=0;
|
|
|
|
#endif
|
2001-05-14 22:08:12 +00:00
|
|
|
int sub_unicode=0;
|
2001-08-13 11:08:18 +00:00
|
|
|
int sub_utf8=0;
|
2002-02-20 22:43:34 +00:00
|
|
|
int sub_pos=100;
|
2002-12-27 21:41:40 +00:00
|
|
|
int sub_width_p=100;
|
2005-10-23 15:35:28 +00:00
|
|
|
int sub_alignment=2; /* 0=top, 1=center, 2=bottom */
|
2002-10-06 17:40:51 +00:00
|
|
|
int sub_visibility=1;
|
2002-12-28 15:03:23 +00:00
|
|
|
int sub_bg_color=0; /* subtitles background color */
|
|
|
|
int sub_bg_alpha=0;
|
2003-06-09 00:24:49 +00:00
|
|
|
int sub_justify=0;
|
2006-11-25 17:44:22 +00:00
|
|
|
#ifdef USE_DVDNAV
|
|
|
|
static nav_highlight_t nav_hl;
|
|
|
|
#endif
|
2001-03-24 04:36:17 +00:00
|
|
|
|
2002-04-17 20:46:12 +00:00
|
|
|
// return the real height of a char:
|
|
|
|
static inline int get_height(int c,int h){
|
|
|
|
int font;
|
|
|
|
if ((font=vo_font->font[c])>=0)
|
|
|
|
if(h<vo_font->pic_a[font]->h) h=vo_font->pic_a[font]->h;
|
|
|
|
return h;
|
|
|
|
}
|
|
|
|
|
2002-08-28 20:45:42 +00:00
|
|
|
// renders char to a big per-object buffer where alpha and bitmap are separated
|
|
|
|
static void draw_alpha_buf(mp_osd_obj_t* obj, int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)
|
|
|
|
{
|
|
|
|
int dststride = obj->stride;
|
|
|
|
int dstskip = obj->stride-w;
|
|
|
|
int srcskip = stride-w;
|
|
|
|
int i, j;
|
|
|
|
unsigned char *b = obj->bitmap_buffer + (y0-obj->bbox.y1)*dststride + (x0-obj->bbox.x1);
|
|
|
|
unsigned char *a = obj->alpha_buffer + (y0-obj->bbox.y1)*dststride + (x0-obj->bbox.x1);
|
|
|
|
unsigned char *bs = src;
|
|
|
|
unsigned char *as = srca;
|
|
|
|
|
|
|
|
if (x0 < obj->bbox.x1 || x0+w > obj->bbox.x2 || y0 < obj->bbox.y1 || y0+h > obj->bbox.y2) {
|
|
|
|
fprintf(stderr, "osd text out of range: bbox [%d %d %d %d], txt [%d %d %d %d]\n",
|
|
|
|
obj->bbox.x1, obj->bbox.x2, obj->bbox.y1, obj->bbox.y2,
|
|
|
|
x0, x0+w, y0, y0+h);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < h; i++) {
|
|
|
|
for (j = 0; j < w; j++, b++, a++, bs++, as++) {
|
|
|
|
if (*b < *bs) *b = *bs;
|
|
|
|
if (*as) {
|
|
|
|
if (*a == 0 || *a > *as) *a = *as;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
b+= dstskip;
|
|
|
|
a+= dstskip;
|
|
|
|
bs+= srcskip;
|
|
|
|
as+= srcskip;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// allocates/enlarges the alpha/bitmap buffer
|
|
|
|
static void alloc_buf(mp_osd_obj_t* obj)
|
|
|
|
{
|
|
|
|
int len;
|
|
|
|
if (obj->bbox.x2 < obj->bbox.x1) obj->bbox.x2 = obj->bbox.x1;
|
|
|
|
if (obj->bbox.y2 < obj->bbox.y1) obj->bbox.y2 = obj->bbox.y1;
|
|
|
|
obj->stride = ((obj->bbox.x2-obj->bbox.x1)+7)&(~7);
|
|
|
|
len = obj->stride*(obj->bbox.y2-obj->bbox.y1);
|
|
|
|
if (obj->allocated<len) {
|
|
|
|
obj->allocated = len;
|
|
|
|
free(obj->bitmap_buffer);
|
|
|
|
free(obj->alpha_buffer);
|
|
|
|
obj->bitmap_buffer = (unsigned char *)memalign(16, len);
|
|
|
|
obj->alpha_buffer = (unsigned char *)memalign(16, len);
|
|
|
|
}
|
2002-12-28 15:03:23 +00:00
|
|
|
memset(obj->bitmap_buffer, sub_bg_color, len);
|
|
|
|
memset(obj->alpha_buffer, sub_bg_alpha, len);
|
2002-08-28 20:45:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// renders the buffer
|
|
|
|
inline static void vo_draw_text_from_buffer(mp_osd_obj_t* obj,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)){
|
|
|
|
if (obj->allocated > 0) {
|
|
|
|
draw_alpha(obj->bbox.x1,obj->bbox.y1,
|
|
|
|
obj->bbox.x2-obj->bbox.x1,
|
|
|
|
obj->bbox.y2-obj->bbox.y1,
|
|
|
|
obj->bitmap_buffer,
|
|
|
|
obj->alpha_buffer,
|
|
|
|
obj->stride);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-12-11 22:37:17 +00:00
|
|
|
unsigned utf8_get_char(const char **str) {
|
|
|
|
const uint8_t *strp = (const uint8_t *)*str;
|
2006-08-12 15:28:01 +00:00
|
|
|
unsigned c;
|
|
|
|
GET_UTF8(c, *strp++, goto no_utf8;);
|
2006-12-11 22:37:17 +00:00
|
|
|
*str = (const char *)strp;
|
2006-06-15 08:05:51 +00:00
|
|
|
return c;
|
|
|
|
|
|
|
|
no_utf8:
|
2006-12-11 22:37:17 +00:00
|
|
|
strp = (const uint8_t *)*str;
|
2006-06-15 08:05:51 +00:00
|
|
|
c = *strp++;
|
2006-12-11 22:37:17 +00:00
|
|
|
*str = (const char *)strp;
|
2006-06-15 08:05:51 +00:00
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
2002-04-15 20:51:34 +00:00
|
|
|
inline static void vo_update_text_osd(mp_osd_obj_t* obj,int dxs,int dys){
|
2006-12-11 22:37:17 +00:00
|
|
|
const char *cp=vo_osd_text;
|
2002-04-15 20:51:34 +00:00
|
|
|
int x=20;
|
2002-04-17 20:46:12 +00:00
|
|
|
int h=0;
|
2002-08-28 20:45:42 +00:00
|
|
|
int font;
|
2002-04-15 20:51:34 +00:00
|
|
|
|
|
|
|
obj->bbox.x1=obj->x=x;
|
|
|
|
obj->bbox.y1=obj->y=10;
|
|
|
|
|
|
|
|
while (*cp){
|
2006-06-15 08:05:51 +00:00
|
|
|
uint16_t c=utf8_get_char(&cp);
|
2002-08-28 20:45:42 +00:00
|
|
|
render_one_glyph(vo_font, c);
|
|
|
|
x+=vo_font->width[c]+vo_font->charspace;
|
2002-04-17 20:46:12 +00:00
|
|
|
h=get_height(c,h);
|
2002-04-15 20:51:34 +00:00
|
|
|
}
|
|
|
|
|
2002-04-17 20:46:12 +00:00
|
|
|
obj->bbox.x2=x-vo_font->charspace;
|
|
|
|
obj->bbox.y2=obj->bbox.y1+h;
|
2002-04-15 20:51:34 +00:00
|
|
|
obj->flags|=OSDFLAG_BBOX;
|
|
|
|
|
2002-08-28 20:45:42 +00:00
|
|
|
alloc_buf(obj);
|
2001-03-25 04:28:40 +00:00
|
|
|
|
2002-08-28 20:45:42 +00:00
|
|
|
cp=vo_osd_text;
|
|
|
|
x = obj->x;
|
2001-08-13 11:08:18 +00:00
|
|
|
while (*cp){
|
2006-06-15 08:05:51 +00:00
|
|
|
uint16_t c=utf8_get_char(&cp);
|
2001-08-13 11:08:18 +00:00
|
|
|
if ((font=vo_font->font[c])>=0)
|
2002-08-28 20:45:42 +00:00
|
|
|
draw_alpha_buf(obj,x,obj->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-03-25 04:28:40 +00:00
|
|
|
x+=vo_font->width[c]+vo_font->charspace;
|
|
|
|
}
|
2001-03-27 00:32:24 +00:00
|
|
|
}
|
|
|
|
|
2006-11-25 11:20:02 +00:00
|
|
|
#ifdef USE_DVDNAV
|
2006-11-25 17:44:22 +00:00
|
|
|
void osd_set_nav_box (uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey) {
|
|
|
|
nav_hl.sx = sx;
|
|
|
|
nav_hl.sy = sy;
|
|
|
|
nav_hl.ex = ex;
|
|
|
|
nav_hl.ey = ey;
|
|
|
|
}
|
|
|
|
|
2006-11-25 11:20:02 +00:00
|
|
|
inline static void vo_update_nav (mp_osd_obj_t *obj, int dxs, int dys) {
|
|
|
|
int len;
|
|
|
|
|
2006-11-25 17:44:22 +00:00
|
|
|
obj->bbox.x1 = obj->x = nav_hl.sx;
|
|
|
|
obj->bbox.y1 = obj->y = nav_hl.sy;
|
|
|
|
obj->bbox.x2 = nav_hl.ex;
|
|
|
|
obj->bbox.y2 = nav_hl.ey;
|
2006-11-25 11:20:02 +00:00
|
|
|
|
|
|
|
alloc_buf (obj);
|
|
|
|
len = obj->stride * (obj->bbox.y2 - obj->bbox.y1);
|
|
|
|
memset (obj->bitmap_buffer, OSD_NAV_BOX_ALPHA, len);
|
|
|
|
memset (obj->alpha_buffer, OSD_NAV_BOX_ALPHA, len);
|
2006-11-29 11:57:16 +00:00
|
|
|
obj->flags |= OSDFLAG_BBOX | OSDFLAG_CHANGED;
|
|
|
|
if (obj->bbox.y2 > obj->bbox.y1 && obj->bbox.x2 > obj->bbox.x1)
|
|
|
|
obj->flags |= OSDFLAG_VISIBLE;
|
2006-11-25 11:20:02 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-07-29 17:57:39 +00:00
|
|
|
#ifdef HAVE_TV_TELETEXT
|
|
|
|
// renders char to a big per-object buffer where alpha and bitmap are separated
|
|
|
|
static void tt_draw_alpha_buf(mp_osd_obj_t* obj, int x0,int y0, int w,int h, unsigned char* src, int stride,int fg,int bg,int alpha)
|
|
|
|
{
|
|
|
|
int dststride = obj->stride;
|
|
|
|
int dstskip = obj->stride-w;
|
|
|
|
int srcskip = stride-w;
|
|
|
|
int i, j;
|
|
|
|
unsigned char *b = obj->bitmap_buffer + (y0-obj->bbox.y1)*dststride + (x0-obj->bbox.x1);
|
|
|
|
unsigned char *a = obj->alpha_buffer + (y0-obj->bbox.y1)*dststride + (x0-obj->bbox.x1);
|
|
|
|
unsigned char *bs = src;
|
|
|
|
if (x0 < obj->bbox.x1 || x0+w > obj->bbox.x2 || y0 < obj->bbox.y1 || y0+h > obj->bbox.y2) {
|
|
|
|
mp_msg(MSGT_OSD,MSGL_ERR,"tt osd text out of range: bbox [%d %d %d %d], txt [%d %d %d %d]\n",
|
|
|
|
obj->bbox.x1, obj->bbox.x2, obj->bbox.y1, obj->bbox.y2,
|
|
|
|
x0, x0+w, y0, y0+h);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (i = 0; i < h; i++) {
|
|
|
|
for (j = 0; j < w; j++, b++, a++, bs++) {
|
|
|
|
*b=(fg-bg)*(*bs)/255+bg;
|
|
|
|
*a=alpha;
|
|
|
|
}
|
|
|
|
b+= dstskip;
|
|
|
|
a+= dstskip;
|
|
|
|
bs+= srcskip;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
inline static void vo_update_text_teletext(mp_osd_obj_t *obj, int dxs, int dys)
|
|
|
|
{
|
2007-09-01 01:22:30 +00:00
|
|
|
int h=0,w=0,i,j,font,flashon;
|
2007-07-29 17:57:39 +00:00
|
|
|
int wm,hm;
|
|
|
|
int color;
|
|
|
|
int x,y,x0,y0;
|
|
|
|
int cols,rows;
|
|
|
|
int wm12;
|
|
|
|
int hm13;
|
|
|
|
int hm23;
|
|
|
|
int start_row,max_rows;
|
|
|
|
int b,ax[6],ay[6],aw[6],ah[6];
|
|
|
|
tt_char tc;
|
|
|
|
tt_char* tdp=vo_osd_teletext_page;
|
|
|
|
unsigned char colors[8]={1,85,150,226,70,105,179,254};
|
|
|
|
unsigned char* buf[9];
|
|
|
|
|
|
|
|
obj->flags|=OSDFLAG_CHANGED|OSDFLAG_VISIBLE;
|
|
|
|
if (!tdp || !vo_osd_teletext_mode) {
|
|
|
|
obj->flags&=~OSDFLAG_VISIBLE;
|
|
|
|
return;
|
|
|
|
}
|
2007-09-01 01:22:30 +00:00
|
|
|
flashon=(GetTimer()/1000000)%2;
|
2007-07-29 17:57:39 +00:00
|
|
|
switch(vo_osd_teletext_half){
|
|
|
|
case TT_ZOOM_TOP_HALF:
|
|
|
|
start_row=0;
|
|
|
|
max_rows=VBI_ROWS/2;
|
|
|
|
break;
|
|
|
|
case TT_ZOOM_BOTTOM_HALF:
|
|
|
|
start_row=VBI_ROWS/2;
|
|
|
|
max_rows=VBI_ROWS/2;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
start_row=0;
|
|
|
|
max_rows=VBI_ROWS;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
wm=0;
|
|
|
|
for(i=start_row;i<max_rows;i++){
|
|
|
|
for(j=0;j<VBI_COLUMNS;j++){
|
|
|
|
tc=tdp[i*VBI_COLUMNS+j];
|
|
|
|
if(!tc.ctl && !tc.gfx)
|
|
|
|
{
|
|
|
|
render_one_glyph(vo_font, tc.unicode);
|
|
|
|
if (wm<vo_font->width[tc.unicode])
|
|
|
|
wm=vo_font->width[tc.unicode];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
hm=vo_font->height+1;
|
|
|
|
wm=dxs*hm*max_rows/(dys*VBI_COLUMNS);
|
|
|
|
|
|
|
|
//very simple teletext font auto scaling
|
|
|
|
if(!vo_osd_teletext_scale && hm*(max_rows+1)>dys){
|
|
|
|
text_font_scale_factor*=1.0*(dys)/((max_rows+1)*hm);
|
|
|
|
force_load_font=1;
|
|
|
|
vo_osd_teletext_scale=text_font_scale_factor;
|
|
|
|
obj->flags&=~OSDFLAG_VISIBLE;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
cols=dxs/wm;
|
|
|
|
rows=dys/hm;
|
|
|
|
|
|
|
|
if(cols>VBI_COLUMNS)
|
|
|
|
cols=VBI_COLUMNS;
|
|
|
|
if(rows>max_rows)
|
|
|
|
rows=max_rows;
|
|
|
|
w=cols*wm-vo_font->charspace;
|
|
|
|
h=rows*hm-vo_font->charspace;
|
|
|
|
|
|
|
|
if(w<dxs)
|
|
|
|
x0=(dxs-w)/2;
|
|
|
|
else
|
|
|
|
x0=0;
|
|
|
|
if(h<dys)
|
|
|
|
y0=(dys-h)/2;
|
|
|
|
else
|
|
|
|
y0=0;
|
|
|
|
|
|
|
|
wm12=wm>>1;
|
|
|
|
hm13=(hm+1)/3;
|
|
|
|
hm23=hm13<<1;
|
|
|
|
|
|
|
|
for(i=0;i<6;i+=2){
|
|
|
|
ax[i+0]=0;
|
|
|
|
aw[i+0]=wm12;
|
|
|
|
|
|
|
|
ax[i+1]=wm12;
|
|
|
|
aw[i+1]=wm-wm12;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(i=0;i<2;i++){
|
|
|
|
ay[i+0]=0;
|
|
|
|
ah[i+0]=hm13;
|
|
|
|
|
|
|
|
ay[i+2]=hm13;
|
|
|
|
ah[i+2]=hm-hm23;
|
|
|
|
|
|
|
|
ay[i+4]=hm-hm13;
|
|
|
|
ah[i+4]=hm13;
|
|
|
|
}
|
|
|
|
|
|
|
|
obj->x = 0;
|
|
|
|
obj->y = 0;
|
|
|
|
obj->bbox.x1 = x0;
|
|
|
|
obj->bbox.y1 = y0;
|
|
|
|
obj->bbox.x2 = x0+w;
|
|
|
|
obj->bbox.y2 = y0+h;
|
|
|
|
obj->flags |= OSDFLAG_BBOX;
|
|
|
|
alloc_buf(obj);
|
|
|
|
|
|
|
|
for(i=0;i<9;i++)
|
|
|
|
buf[i]=malloc(wm*hm);
|
|
|
|
|
|
|
|
//alpha
|
|
|
|
if(vo_osd_teletext_format==TT_FORMAT_OPAQUE ||vo_osd_teletext_format==TT_FORMAT_OPAQUE_INV)
|
|
|
|
color=1;
|
|
|
|
else
|
|
|
|
color=200;
|
|
|
|
memset(buf[8],color,wm*hm);
|
|
|
|
//colors
|
|
|
|
if(vo_osd_teletext_format==TT_FORMAT_OPAQUE ||vo_osd_teletext_format==TT_FORMAT_TRANSPARENT){
|
|
|
|
for(i=0;i<8;i++){
|
|
|
|
memset(buf[i],(unsigned char)(1.0*(255-color)*colors[i]/255),wm*hm);
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
for(i=0;i<8;i++)
|
|
|
|
memset(buf[i],(unsigned char)(1.0*(255-color)*colors[7-i]/255),wm*hm);
|
|
|
|
}
|
|
|
|
|
|
|
|
y=y0;
|
|
|
|
for(i=0;i<rows;i++){
|
|
|
|
x=x0;
|
|
|
|
for(j=0;j<cols;j++){
|
|
|
|
tc=tdp[(i+start_row)*VBI_COLUMNS+j];
|
2007-09-08 09:48:43 +00:00
|
|
|
if (tc.hidden) { x+=wm; continue;}
|
2007-09-01 01:22:30 +00:00
|
|
|
if(!tc.gfx || (tc.flh && !flashon)){
|
2007-07-29 17:57:39 +00:00
|
|
|
/* Rendering one text character */
|
|
|
|
draw_alpha_buf(obj,x,y,wm,hm,buf[tc.bg],buf[8],wm);
|
|
|
|
if(tc.unicode!=0x20 && tc.unicode!=0x00 && !tc.ctl &&
|
2007-09-01 01:22:30 +00:00
|
|
|
(!tc.flh || flashon) &&
|
2007-07-29 17:57:39 +00:00
|
|
|
(font=vo_font->font[tc.unicode])>=0 && y+hm<dys){
|
|
|
|
tt_draw_alpha_buf(obj,x,y,vo_font->width[tc.unicode],vo_font->height,
|
|
|
|
vo_font->pic_b[font]->bmp+vo_font->start[tc.unicode]-vo_font->charspace*vo_font->pic_a[font]->w,
|
|
|
|
vo_font->pic_b[font]->w,
|
|
|
|
buf[tc.fg][0],buf[tc.bg][0],buf[8][0]);
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
/*
|
|
|
|
Rendering one graphics character
|
|
|
|
TODO: support for separated graphics symbols (where six rectangles does not touch each other)
|
|
|
|
|
|
|
|
+--+ +--+ 87654321
|
|
|
|
|01| |12| --------
|
|
|
|
|10| <= |34| <= 00100110 <= 0x26
|
|
|
|
|01| |56|
|
|
|
|
+--+ +--+
|
|
|
|
|
|
|
|
(0:wm/2) (wm/2:wm-wm/2)
|
|
|
|
|
|
|
|
********** *********** (0:hm/3)
|
|
|
|
*** **** **** ****
|
|
|
|
*** 1 **** **** 2 ****
|
|
|
|
*** **** **** ****
|
|
|
|
********** ***********
|
|
|
|
********** ***********
|
|
|
|
|
|
|
|
********** *********** (hm/3:hm-2*hm/3)
|
|
|
|
********** ***********
|
|
|
|
*** **** **** ****
|
|
|
|
*** 3 **** **** 4 ****
|
|
|
|
*** **** **** ****
|
|
|
|
********** ***********
|
|
|
|
********** ***********
|
|
|
|
********** ***********
|
|
|
|
|
|
|
|
********** *********** (hm-hm/3:hm/3)
|
|
|
|
*** **** **** ****
|
|
|
|
*** 5 **** **** 6 ****
|
|
|
|
*** **** **** ****
|
|
|
|
********** ***********
|
|
|
|
********** ***********
|
|
|
|
|
|
|
|
*/
|
|
|
|
if(tc.gfx>1){ //separated gfx
|
|
|
|
for(b=0;b<6;b++){
|
|
|
|
color=(tc.unicode>>b)&1?tc.fg:tc.bg;
|
|
|
|
draw_alpha_buf(obj,x+ax[b]+1,y+ay[b]+1,aw[b]-2,ah[b]-2,buf[color],buf[8],wm);
|
|
|
|
}
|
|
|
|
//separated gfx (background borders)
|
|
|
|
//vertical
|
|
|
|
draw_alpha_buf(obj,x ,y,1,hm,buf[tc.bg],buf[8],wm);
|
|
|
|
draw_alpha_buf(obj,x+ax[1]-1,y,2,hm,buf[tc.bg],buf[8],wm);
|
|
|
|
draw_alpha_buf(obj,x+ax[1]+aw[1]-1,y,wm-ax[1]-aw[1]+1,hm,buf[tc.bg],buf[8],wm);
|
|
|
|
//horizontal
|
|
|
|
draw_alpha_buf(obj,x,y ,wm,1,buf[tc.bg],buf[8],wm);
|
|
|
|
draw_alpha_buf(obj,x,y+ay[0]+ah[0]-1,wm,2,buf[tc.bg],buf[8],wm);
|
|
|
|
draw_alpha_buf(obj,x,y+ay[2]+ah[2]-1,wm,2,buf[tc.bg],buf[8],wm);
|
|
|
|
draw_alpha_buf(obj,x,y+ay[4]+ah[4]-1,wm,hm-ay[4]-ah[4]+1,buf[tc.bg],buf[8],wm);
|
|
|
|
}else{
|
|
|
|
for(b=0;b<6;b++){
|
|
|
|
color=(tc.unicode>>b)&1?tc.fg:tc.bg;
|
|
|
|
draw_alpha_buf(obj,x+ax[b],y+ay[b],aw[b],ah[b],buf[color],buf[8],wm);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
x+=wm;
|
|
|
|
}
|
|
|
|
y+=hm;
|
|
|
|
}
|
|
|
|
for(i=0;i<9;i++)
|
|
|
|
free(buf[i]);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-03-27 00:32:24 +00:00
|
|
|
int vo_osd_progbar_type=-1;
|
2001-08-28 12:43:41 +00:00
|
|
|
int vo_osd_progbar_value=100; // 0..256
|
|
|
|
|
|
|
|
// if we have n=256 bars then OSD progbar looks like below
|
|
|
|
//
|
2001-09-10 13:23:27 +00:00
|
|
|
// 0 1 2 3 ... 256 <= vo_osd_progbar_value
|
|
|
|
// | | | | |
|
2001-08-28 12:43:41 +00:00
|
|
|
// [ === === === ... === ]
|
|
|
|
//
|
|
|
|
// the above schema is rescalled to n=elems bars
|
2001-03-27 00:32:24 +00:00
|
|
|
|
2002-04-15 19:17:12 +00:00
|
|
|
inline static void vo_update_text_progbar(mp_osd_obj_t* obj,int dxs,int dys){
|
|
|
|
|
|
|
|
obj->flags|=OSDFLAG_CHANGED|OSDFLAG_VISIBLE;
|
|
|
|
|
|
|
|
if(vo_osd_progbar_type<0 || !vo_font){
|
|
|
|
obj->flags&=~OSDFLAG_VISIBLE;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-08-28 20:45:42 +00:00
|
|
|
render_one_glyph(vo_font, OSD_PB_START);
|
|
|
|
render_one_glyph(vo_font, OSD_PB_END);
|
|
|
|
render_one_glyph(vo_font, OSD_PB_0);
|
|
|
|
render_one_glyph(vo_font, OSD_PB_1);
|
|
|
|
render_one_glyph(vo_font, vo_osd_progbar_type);
|
|
|
|
|
|
|
|
// calculate bbox corners:
|
2002-04-17 20:46:12 +00:00
|
|
|
{ int h=0;
|
2001-08-13 11:08:18 +00:00
|
|
|
int y=(dys-vo_font->height)/2;
|
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;
|
2002-08-28 20:45:42 +00:00
|
|
|
int delta = 0;
|
2002-04-17 20:46:12 +00:00
|
|
|
h=get_height(OSD_PB_START,h);
|
|
|
|
h=get_height(OSD_PB_END,h);
|
|
|
|
h=get_height(OSD_PB_0,h);
|
|
|
|
h=get_height(OSD_PB_1,h);
|
2002-12-10 23:10:24 +00:00
|
|
|
if (vo_osd_progbar_type>0 && vo_font->font[vo_osd_progbar_type]>=0){
|
|
|
|
delta = vo_font->width[vo_osd_progbar_type]+vo_font->spacewidth;
|
|
|
|
delta = (x-delta > 0) ? delta : x;
|
|
|
|
h=get_height(vo_osd_progbar_type,h);
|
|
|
|
}
|
2002-04-15 19:17:12 +00:00
|
|
|
obj->bbox.x1=obj->x=x;
|
|
|
|
obj->bbox.y1=obj->y=y;
|
|
|
|
obj->bbox.x2=x+width+delimw;
|
2002-04-17 20:46:12 +00:00
|
|
|
obj->bbox.y2=y+h; //vo_font->height;
|
2002-04-15 20:51:34 +00:00
|
|
|
obj->flags|=OSDFLAG_BBOX;
|
2002-04-15 19:17:12 +00:00
|
|
|
obj->params.progbar.elems=elems;
|
2002-08-28 20:45:42 +00:00
|
|
|
obj->bbox.x1-=delta; // space for an icon
|
2002-04-15 19:17:12 +00:00
|
|
|
}
|
|
|
|
|
2002-08-28 20:45:42 +00:00
|
|
|
alloc_buf(obj);
|
2003-01-05 13:32:57 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
int minw = vo_font->width[OSD_PB_START]+vo_font->width[OSD_PB_END]+vo_font->width[OSD_PB_0];
|
|
|
|
if (vo_osd_progbar_type>0 && vo_font->font[vo_osd_progbar_type]>=0){
|
|
|
|
minw += vo_font->width[vo_osd_progbar_type]+vo_font->charspace+vo_font->spacewidth;
|
|
|
|
}
|
|
|
|
if (obj->bbox.x2 - obj->bbox.x1 < minw) return; // space too small, don't render anything
|
|
|
|
}
|
|
|
|
|
2002-08-28 20:45:42 +00:00
|
|
|
// render it:
|
|
|
|
{ unsigned char *s;
|
2002-04-15 19:17:12 +00:00
|
|
|
unsigned char *sa;
|
|
|
|
int i,w,h,st,mark;
|
|
|
|
int x=obj->x;
|
|
|
|
int y=obj->y;
|
|
|
|
int c,font;
|
|
|
|
int charw=vo_font->width[OSD_PB_0]+vo_font->charspace;
|
|
|
|
int elems=obj->params.progbar.elems;
|
2001-08-16 09:25:32 +00:00
|
|
|
|
2001-08-28 12:43:41 +00:00
|
|
|
if (vo_osd_progbar_value<=0)
|
|
|
|
mark=0;
|
2001-09-10 13:23:27 +00:00
|
|
|
else {
|
|
|
|
int ev=vo_osd_progbar_value*elems;
|
|
|
|
mark=ev>>8;
|
|
|
|
if (ev & 0xFF) mark++;
|
|
|
|
if (mark>elems) mark=elems;
|
|
|
|
}
|
|
|
|
|
2001-08-28 14:22:37 +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;
|
2002-08-28 20:45:42 +00:00
|
|
|
draw_alpha_buf(obj,(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)
|
2002-08-28 20:45:42 +00:00
|
|
|
draw_alpha_buf(obj,x,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-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-10-15 06:14:55 +00:00
|
|
|
if ((i=mark)) do {
|
2002-08-28 20:45:42 +00:00
|
|
|
draw_alpha_buf(obj,x,y,w,h,s,sa,st);
|
2001-08-16 09:25:32 +00:00
|
|
|
x+=charw;
|
2001-10-15 06:14:55 +00:00
|
|
|
} while(--i);
|
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-10-15 06:14:55 +00:00
|
|
|
if ((i=elems-mark)) do {
|
2002-08-28 20:45:42 +00:00
|
|
|
draw_alpha_buf(obj,x,y,w,h,s,sa,st);
|
2001-08-16 09:25:32 +00:00
|
|
|
x+=charw;
|
2001-10-15 06:14:55 +00:00
|
|
|
} while(--i);
|
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)
|
2002-08-28 20:45:42 +00:00
|
|
|
draw_alpha_buf(obj,x,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-16 09:25:32 +00:00
|
|
|
// x+=vo_font->width[c]+vo_font->charspace;
|
2001-05-14 22:08:12 +00:00
|
|
|
|
2002-08-28 20:45:42 +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
|
|
|
|
2002-04-15 19:17:12 +00:00
|
|
|
// 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))
|
2001-08-20 09:14:28 +00:00
|
|
|
|
2002-04-15 19:17:12 +00:00
|
|
|
inline static void vo_update_text_sub(mp_osd_obj_t* obj,int dxs,int dys){
|
2001-08-13 11:08:18 +00:00
|
|
|
unsigned char *t;
|
2003-09-21 13:20:06 +00:00
|
|
|
int c,i,j,l,x,y,font,prevc,counter;
|
|
|
|
int k;
|
2001-08-13 11:08:18 +00:00
|
|
|
int lastStripPosition;
|
2003-09-21 13:20:06 +00:00
|
|
|
int xsize;
|
2002-04-15 20:51:34 +00:00
|
|
|
int xmin=dxs,xmax=0;
|
2001-08-20 09:14:28 +00:00
|
|
|
int h,lasth;
|
2003-09-21 13:20:06 +00:00
|
|
|
int xtblc, utblc;
|
2001-08-13 11:08:18 +00:00
|
|
|
|
2002-04-15 19:17:12 +00:00
|
|
|
obj->flags|=OSDFLAG_CHANGED|OSDFLAG_VISIBLE;
|
2002-10-06 17:40:51 +00:00
|
|
|
|
2007-05-20 16:10:45 +00:00
|
|
|
if(!vo_sub || !sub_font || !sub_visibility || (sub_font->font[40]<0)){
|
2002-04-15 19:17:12 +00:00
|
|
|
obj->flags&=~OSDFLAG_VISIBLE;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-04-17 20:46:12 +00:00
|
|
|
obj->bbox.y2=obj->y=dys;
|
2002-04-15 19:17:12 +00:00
|
|
|
obj->params.subtitle.lines=0;
|
|
|
|
|
2001-08-21 11:28:50 +00:00
|
|
|
// too long lines divide into a smaller ones
|
2002-04-15 19:17:12 +00:00
|
|
|
i=k=lasth=0;
|
2007-05-20 16:10:45 +00:00
|
|
|
h=sub_font->height;
|
2001-08-20 09:14:28 +00:00
|
|
|
lastStripPosition=-1;
|
|
|
|
l=vo_sub->lines;
|
|
|
|
|
2003-09-21 13:20:06 +00:00
|
|
|
{
|
|
|
|
struct osd_text_t *osl, *cp_ott, *tmp_ott, *tmp;
|
|
|
|
struct osd_text_p *otp_sub = NULL, *otp_sub_tmp, // these are used to store the whole sub text osd
|
|
|
|
*otp, *tmp_otp, *pmt; // these are used to manage sub text osd coming from a single sub line
|
|
|
|
int *char_seq, char_position, xlimit = dxs * sub_width_p / 100, counter;
|
|
|
|
|
2001-10-15 06:14:55 +00:00
|
|
|
while (l) {
|
2007-05-20 16:10:45 +00:00
|
|
|
xsize = -sub_font->charspace;
|
2001-10-15 06:14:55 +00:00
|
|
|
l--;
|
2001-08-13 11:08:18 +00:00
|
|
|
t=vo_sub->text[i++];
|
2003-09-21 13:20:06 +00:00
|
|
|
char_position = 0;
|
2006-12-11 22:32:13 +00:00
|
|
|
char_seq = calloc(strlen(t), sizeof(int));
|
2002-08-28 20:45:42 +00:00
|
|
|
|
|
|
|
prevc = -1;
|
|
|
|
|
2003-09-21 13:20:06 +00:00
|
|
|
otp = NULL;
|
|
|
|
osl = NULL;
|
|
|
|
x = 1;
|
|
|
|
|
|
|
|
// reading the subtitle words from vo_sub->text[]
|
2006-12-11 22:29:08 +00:00
|
|
|
while (*t) {
|
|
|
|
if (sub_utf8)
|
|
|
|
c = utf8_get_char(&t);
|
|
|
|
else if ((c = *t++) >= 0x80 && sub_unicode)
|
|
|
|
c = (c<<8) + *t++;
|
2001-08-13 11:08:18 +00:00
|
|
|
if (k==MAX_UCS){
|
2006-12-11 22:29:08 +00:00
|
|
|
t += strlen(t); // end here
|
2002-04-15 19:17:12 +00:00
|
|
|
mp_msg(MSGT_OSD,MSGL_WARN,"\nMAX_UCS exceeded!\n");
|
2001-08-20 09:14:28 +00:00
|
|
|
}
|
2001-10-15 06:14:55 +00:00
|
|
|
if (!c) c++; // avoid UCS 0
|
2007-05-20 16:10:45 +00:00
|
|
|
render_one_glyph(sub_font, c);
|
2002-12-23 01:37:43 +00:00
|
|
|
|
2003-09-21 13:20:06 +00:00
|
|
|
if (c == ' ') {
|
|
|
|
struct osd_text_t *tmp_ott = (struct osd_text_t *) calloc(1, sizeof(struct osd_text_t));
|
|
|
|
|
|
|
|
if (osl == NULL) {
|
|
|
|
osl = cp_ott = tmp_ott;
|
|
|
|
} else {
|
|
|
|
tmp_ott->prev = cp_ott;
|
|
|
|
cp_ott->next = tmp_ott;
|
|
|
|
tmp_ott->osd_kerning =
|
2007-05-20 16:10:45 +00:00
|
|
|
sub_font->charspace + sub_font->width[' '];
|
2003-09-21 13:20:06 +00:00
|
|
|
cp_ott = tmp_ott;
|
|
|
|
}
|
|
|
|
tmp_ott->osd_length = xsize;
|
|
|
|
tmp_ott->text_length = char_position;
|
|
|
|
tmp_ott->text = (int *) malloc(char_position * sizeof(int));
|
|
|
|
for (counter = 0; counter < char_position; ++counter)
|
|
|
|
tmp_ott->text[counter] = char_seq[counter];
|
|
|
|
char_position = 0;
|
|
|
|
xsize = 0;
|
|
|
|
prevc = c;
|
|
|
|
} else {
|
2007-05-20 16:10:45 +00:00
|
|
|
int delta_xsize = sub_font->width[c] + sub_font->charspace + kerning(sub_font, prevc, c);
|
2003-09-21 13:20:06 +00:00
|
|
|
|
|
|
|
if (xsize + delta_xsize <= dxs) {
|
|
|
|
if (!x) x = 1;
|
|
|
|
prevc = c;
|
|
|
|
char_seq[char_position++] = c;
|
|
|
|
xsize += delta_xsize;
|
2007-05-20 16:10:45 +00:00
|
|
|
if ((!suboverlap_enabled) && ((font = sub_font->font[c]) >= 0)) {
|
|
|
|
if (sub_font->pic_a[font]->h > h) {
|
|
|
|
h = sub_font->pic_a[font]->h;
|
2003-09-21 13:20:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (x) {
|
|
|
|
mp_msg(MSGT_OSD, MSGL_WARN, "\nSubtitle word '%s' too long!\n", t);
|
|
|
|
x = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}// for len (all words from subtitle line read)
|
|
|
|
|
|
|
|
// osl holds an ordered (as they appear in the lines) chain of the subtitle words
|
|
|
|
{
|
|
|
|
struct osd_text_t *tmp_ott = (struct osd_text_t *) calloc(1, sizeof(struct osd_text_t));
|
|
|
|
|
|
|
|
if (osl == NULL) {
|
|
|
|
osl = cp_ott = tmp_ott;
|
|
|
|
} else {
|
|
|
|
tmp_ott->prev = cp_ott;
|
|
|
|
cp_ott->next = tmp_ott;
|
|
|
|
tmp_ott->osd_kerning =
|
2007-05-20 16:10:45 +00:00
|
|
|
sub_font->charspace + sub_font->width[' '];
|
2003-09-21 13:20:06 +00:00
|
|
|
cp_ott = tmp_ott;
|
|
|
|
}
|
|
|
|
tmp_ott->osd_length = xsize;
|
|
|
|
tmp_ott->text_length = char_position;
|
|
|
|
tmp_ott->text = (int *) malloc(char_position * sizeof(int));
|
|
|
|
for (counter = 0; counter < char_position; ++counter)
|
|
|
|
tmp_ott->text[counter] = char_seq[counter];
|
|
|
|
char_position = 0;
|
2007-05-20 16:10:45 +00:00
|
|
|
xsize = -sub_font->charspace;
|
2003-09-21 13:20:06 +00:00
|
|
|
}
|
2006-06-15 08:04:40 +00:00
|
|
|
free(char_seq);
|
2003-09-21 13:20:06 +00:00
|
|
|
|
|
|
|
if (osl != NULL) {
|
|
|
|
int value = 0, exit = 0, minimum = 0;
|
|
|
|
|
|
|
|
// otp will contain the chain of the osd subtitle lines coming from the single vo_sub line.
|
|
|
|
otp = tmp_otp = (struct osd_text_p *) calloc(1, sizeof(struct osd_text_p));
|
|
|
|
tmp_otp->ott = osl;
|
|
|
|
for (tmp_ott = tmp_otp->ott; exit == 0; ) {
|
2003-10-27 21:36:29 +00:00
|
|
|
do {
|
2003-09-21 13:20:06 +00:00
|
|
|
value += tmp_ott->osd_kerning + tmp_ott->osd_length;
|
|
|
|
tmp_ott = tmp_ott->next;
|
2003-10-27 21:36:29 +00:00
|
|
|
} while ((tmp_ott != NULL) && (value + tmp_ott->osd_kerning + tmp_ott->osd_length <= xlimit));
|
2003-09-21 13:20:06 +00:00
|
|
|
if (tmp_ott != NULL) {
|
|
|
|
struct osd_text_p *tmp = (struct osd_text_p *) calloc(1, sizeof(struct osd_text_p));
|
|
|
|
|
|
|
|
tmp_otp->value = value;
|
|
|
|
tmp_otp->next = tmp;
|
|
|
|
tmp->prev = tmp_otp;
|
|
|
|
tmp_otp = tmp;
|
|
|
|
tmp_otp->ott = tmp_ott;
|
2007-05-20 16:10:45 +00:00
|
|
|
value = -2 * sub_font->charspace - sub_font->width[' '];
|
2003-09-21 13:20:06 +00:00
|
|
|
} else {
|
|
|
|
tmp_otp->value = value;
|
|
|
|
exit = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef NEW_SPLITTING
|
2007-09-25 16:34:23 +00:00
|
|
|
// minimum holds the 'sum of the differences in length among the lines',
|
|
|
|
// a measure of the evenness of the lengths of the lines
|
2003-09-21 13:20:06 +00:00
|
|
|
for (tmp_otp = otp; tmp_otp->next != NULL; tmp_otp = tmp_otp->next) {
|
|
|
|
pmt = tmp_otp->next;
|
|
|
|
while (pmt != NULL) {
|
|
|
|
minimum += abs(tmp_otp->value - pmt->value);
|
|
|
|
pmt = pmt->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (otp->next != NULL) {
|
|
|
|
int mem1, mem2;
|
|
|
|
struct osd_text_p *mem, *hold;
|
|
|
|
|
|
|
|
exit = 0;
|
|
|
|
// until the last word of a line can be moved to the beginning of following line
|
2007-09-25 16:34:23 +00:00
|
|
|
// reducing the 'sum of the differences in length among the lines', it is done
|
2003-09-21 13:20:06 +00:00
|
|
|
while (exit == 0) {
|
|
|
|
hold = NULL;
|
|
|
|
exit = 1;
|
|
|
|
for (tmp_otp = otp; tmp_otp->next != NULL; tmp_otp = tmp_otp->next) {
|
|
|
|
pmt = tmp_otp->next;
|
|
|
|
for (tmp = tmp_otp->ott; tmp->next != pmt->ott; tmp = tmp->next);
|
|
|
|
if (pmt->value + tmp->osd_length + pmt->ott->osd_kerning <= xlimit) {
|
|
|
|
mem1 = tmp_otp->value;
|
|
|
|
mem2 = pmt->value;
|
|
|
|
tmp_otp->value = mem1 - tmp->osd_length - tmp->osd_kerning;
|
|
|
|
pmt->value = mem2 + tmp->osd_length + pmt->ott->osd_kerning;
|
|
|
|
|
|
|
|
value = 0;
|
|
|
|
for (mem = otp; mem->next != NULL; mem = mem->next) {
|
|
|
|
pmt = mem->next;
|
|
|
|
while (pmt != NULL) {
|
|
|
|
value += abs(mem->value - pmt->value);
|
|
|
|
pmt = pmt->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (value < minimum) {
|
|
|
|
minimum = value;
|
|
|
|
hold = tmp_otp;
|
|
|
|
exit = 0;
|
|
|
|
}
|
|
|
|
tmp_otp->value = mem1;
|
|
|
|
tmp_otp->next->value = mem2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// merging
|
|
|
|
if (exit == 0) {
|
|
|
|
tmp_otp = hold;
|
|
|
|
pmt = tmp_otp->next;
|
|
|
|
for (tmp = tmp_otp->ott; tmp->next != pmt->ott; tmp = tmp->next);
|
|
|
|
mem1 = tmp_otp->value;
|
|
|
|
mem2 = pmt->value;
|
|
|
|
tmp_otp->value = mem1 - tmp->osd_length - tmp->osd_kerning;
|
|
|
|
pmt->value = mem2 + tmp->osd_length + pmt->ott->osd_kerning;
|
|
|
|
pmt->ott = tmp;
|
|
|
|
}//~merging
|
|
|
|
}//~while(exit == 0)
|
|
|
|
}//~if(otp->next!=NULL)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// adding otp (containing splitted lines) to otp chain
|
|
|
|
if (otp_sub == NULL) {
|
|
|
|
otp_sub = otp;
|
|
|
|
for (otp_sub_tmp = otp_sub; otp_sub_tmp->next != NULL; otp_sub_tmp = otp_sub_tmp->next);
|
|
|
|
} else {
|
|
|
|
//updating ott chain
|
|
|
|
tmp = otp_sub->ott;
|
|
|
|
while (tmp->next != NULL) tmp = tmp->next;
|
|
|
|
tmp->next = otp->ott;
|
|
|
|
otp->ott->prev = tmp;
|
|
|
|
//attaching new subtitle line at the end
|
|
|
|
otp_sub_tmp->next = otp;
|
|
|
|
otp->prev = otp_sub_tmp;
|
|
|
|
do
|
|
|
|
otp_sub_tmp = otp_sub_tmp->next;
|
|
|
|
while (otp_sub_tmp->next != NULL);
|
|
|
|
}
|
|
|
|
}//~ if(osl != NULL)
|
|
|
|
} // while
|
|
|
|
|
|
|
|
// write lines into utbl
|
|
|
|
xtblc = 0;
|
|
|
|
utblc = 0;
|
|
|
|
obj->y = dys;
|
|
|
|
obj->params.subtitle.lines = 0;
|
|
|
|
for (tmp_otp = otp_sub; tmp_otp != NULL; tmp_otp = tmp_otp->next) {
|
|
|
|
|
|
|
|
if ((obj->params.subtitle.lines++) >= MAX_UCSLINES)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (h > obj->y) { // out of the screen so end parsing
|
2007-05-20 16:10:45 +00:00
|
|
|
obj->y -= lasth - sub_font->height; // correct the y position
|
2003-09-21 13:20:06 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
xsize = tmp_otp->value;
|
|
|
|
obj->params.subtitle.xtbl[xtblc++] = (dxs - xsize) / 2;
|
|
|
|
if (xmin > (dxs - xsize) / 2)
|
|
|
|
xmin = (dxs - xsize) / 2;
|
|
|
|
if (xmax < (dxs + xsize) / 2)
|
|
|
|
xmax = (dxs + xsize) / 2;
|
|
|
|
|
|
|
|
tmp = (tmp_otp->next == NULL) ? NULL : tmp_otp->next->ott;
|
|
|
|
for (tmp_ott = tmp_otp->ott; tmp_ott != tmp; tmp_ott = tmp_ott->next) {
|
|
|
|
for (counter = 0; counter < tmp_ott->text_length; ++counter) {
|
|
|
|
if (utblc > MAX_UCS) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
c = tmp_ott->text[counter];
|
2007-05-20 16:10:45 +00:00
|
|
|
render_one_glyph(sub_font, c);
|
2003-09-21 13:20:06 +00:00
|
|
|
obj->params.subtitle.utbl[utblc++] = c;
|
|
|
|
k++;
|
|
|
|
}
|
|
|
|
obj->params.subtitle.utbl[utblc++] = ' ';
|
|
|
|
}
|
|
|
|
obj->params.subtitle.utbl[utblc - 1] = 0;
|
2007-05-20 16:10:45 +00:00
|
|
|
obj->y -= sub_font->height;
|
2003-09-21 13:20:06 +00:00
|
|
|
}
|
|
|
|
if(obj->params.subtitle.lines)
|
2007-05-20 16:10:45 +00:00
|
|
|
obj->y = dys - ((obj->params.subtitle.lines - 1) * sub_font->height + sub_font->pic_a[sub_font->font[40]]->h);
|
2003-09-21 13:20:06 +00:00
|
|
|
|
|
|
|
// free memory
|
|
|
|
if (otp_sub != NULL) {
|
|
|
|
for (tmp = otp_sub->ott; tmp->next != NULL; free(tmp->prev)) {
|
|
|
|
free(tmp->text);
|
|
|
|
tmp = tmp->next;
|
|
|
|
}
|
|
|
|
free(tmp->text);
|
|
|
|
free(tmp);
|
|
|
|
|
|
|
|
for(pmt = otp_sub; pmt->next != NULL; free(pmt->prev)) {
|
|
|
|
pmt = pmt->next;
|
|
|
|
}
|
|
|
|
free(pmt);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
/// vertical alignment
|
2002-12-23 01:37:43 +00:00
|
|
|
h = dys - obj->y;
|
2005-10-23 15:34:39 +00:00
|
|
|
if (sub_alignment == 2)
|
2002-12-23 01:37:43 +00:00
|
|
|
obj->y = dys * sub_pos / 100 - h;
|
|
|
|
else if (sub_alignment == 1)
|
|
|
|
obj->y = dys * sub_pos / 100 - h / 2;
|
|
|
|
else
|
|
|
|
obj->y = dys * sub_pos / 100;
|
|
|
|
|
|
|
|
if (obj->y < 0)
|
|
|
|
obj->y = 0;
|
|
|
|
if (obj->y > dys - h)
|
|
|
|
obj->y = dys - h;
|
|
|
|
|
|
|
|
obj->bbox.y2 = obj->y + h;
|
|
|
|
|
2002-04-15 20:51:34 +00:00
|
|
|
// calculate bbox:
|
2003-06-09 00:24:49 +00:00
|
|
|
if (sub_justify) xmin = 10;
|
2002-04-15 20:51:34 +00:00
|
|
|
obj->bbox.x1=xmin;
|
|
|
|
obj->bbox.x2=xmax;
|
|
|
|
obj->bbox.y1=obj->y;
|
2007-05-20 16:10:45 +00:00
|
|
|
// obj->bbox.y2=obj->y+obj->params.subtitle.lines*sub_font->height;
|
2002-04-15 20:51:34 +00:00
|
|
|
obj->flags|=OSDFLAG_BBOX;
|
2002-08-28 20:45:42 +00:00
|
|
|
|
|
|
|
alloc_buf(obj);
|
|
|
|
|
|
|
|
y = obj->y;
|
|
|
|
|
2004-09-15 13:16:52 +00:00
|
|
|
obj->alignment = 0;
|
2003-09-21 13:20:06 +00:00
|
|
|
switch(vo_sub->alignment) {
|
2004-09-15 13:16:52 +00:00
|
|
|
case SUB_ALIGNMENT_BOTTOMLEFT:
|
|
|
|
case SUB_ALIGNMENT_MIDDLELEFT:
|
|
|
|
case SUB_ALIGNMENT_TOPLEFT:
|
2003-09-21 13:20:06 +00:00
|
|
|
obj->alignment |= 0x1;
|
|
|
|
break;
|
2004-09-15 13:16:52 +00:00
|
|
|
case SUB_ALIGNMENT_BOTTOMRIGHT:
|
|
|
|
case SUB_ALIGNMENT_MIDDLERIGHT:
|
|
|
|
case SUB_ALIGNMENT_TOPRIGHT:
|
|
|
|
obj->alignment |= 0x2;
|
2003-09-21 13:20:06 +00:00
|
|
|
break;
|
2004-09-15 13:16:52 +00:00
|
|
|
case SUB_ALIGNMENT_BOTTOMCENTER:
|
|
|
|
case SUB_ALIGNMENT_MIDDLECENTER:
|
|
|
|
case SUB_ALIGNMENT_TOPCENTER:
|
2003-09-21 13:20:06 +00:00
|
|
|
default:
|
2004-09-15 13:16:52 +00:00
|
|
|
obj->alignment |= 0x0;
|
2003-09-21 13:20:06 +00:00
|
|
|
}
|
|
|
|
|
2002-08-28 20:45:42 +00:00
|
|
|
i=j=0;
|
2003-09-21 13:20:06 +00:00
|
|
|
if ((l = obj->params.subtitle.lines)) {
|
|
|
|
for(counter = dxs; i < l; ++i)
|
|
|
|
if (obj->params.subtitle.xtbl[i] < counter) counter = obj->params.subtitle.xtbl[i];
|
|
|
|
for (i = 0; i < l; ++i) {
|
|
|
|
switch (obj->alignment&0x3) {
|
|
|
|
case 1:
|
|
|
|
// left
|
|
|
|
x = counter;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
// right
|
|
|
|
x = 2 * obj->params.subtitle.xtbl[i] - counter - ((obj->params.subtitle.xtbl[i] == counter) ? 0 : 1);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
//center
|
|
|
|
x = obj->params.subtitle.xtbl[i];
|
|
|
|
}
|
2002-08-28 20:45:42 +00:00
|
|
|
prevc = -1;
|
|
|
|
while ((c=obj->params.subtitle.utbl[j++])){
|
2007-05-20 16:10:45 +00:00
|
|
|
x += kerning(sub_font,prevc,c);
|
|
|
|
if ((font=sub_font->font[c])>=0)
|
2002-08-28 20:45:42 +00:00
|
|
|
draw_alpha_buf(obj,x,y,
|
2007-05-20 16:10:45 +00:00
|
|
|
sub_font->width[c],
|
|
|
|
sub_font->pic_a[font]->h+y<obj->dys ? sub_font->pic_a[font]->h : obj->dys-y,
|
|
|
|
sub_font->pic_b[font]->bmp+sub_font->start[c],
|
|
|
|
sub_font->pic_a[font]->bmp+sub_font->start[c],
|
|
|
|
sub_font->pic_a[font]->w);
|
|
|
|
x+=sub_font->width[c]+sub_font->charspace;
|
2002-08-28 20:45:42 +00:00
|
|
|
prevc = c;
|
2003-09-21 13:20:06 +00:00
|
|
|
}
|
2007-05-20 16:10:45 +00:00
|
|
|
y+=sub_font->height;
|
2003-09-21 13:20:06 +00:00
|
|
|
}
|
2002-08-28 20:45:42 +00:00
|
|
|
}
|
2002-04-15 20:51:34 +00:00
|
|
|
|
2002-04-15 19:17:12 +00:00
|
|
|
}
|
|
|
|
|
2002-05-25 17:40:40 +00:00
|
|
|
inline static void vo_update_spudec_sub(mp_osd_obj_t* obj, int dxs, int dys)
|
|
|
|
{
|
|
|
|
unsigned int bbox[4];
|
|
|
|
spudec_calc_bbox(vo_spudec, dxs, dys, bbox);
|
|
|
|
obj->bbox.x1 = bbox[0];
|
|
|
|
obj->bbox.x2 = bbox[1];
|
|
|
|
obj->bbox.y1 = bbox[2];
|
|
|
|
obj->bbox.y2 = bbox[3];
|
|
|
|
obj->flags |= OSDFLAG_BBOX;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline static void vo_draw_spudec_sub(mp_osd_obj_t* obj, void (*draw_alpha)(int x0, int y0, int w, int h, unsigned char* src, unsigned char* srca, int stride))
|
|
|
|
{
|
|
|
|
spudec_draw_scaled(vo_spudec, obj->dxs, obj->dys, draw_alpha);
|
|
|
|
}
|
2001-03-24 04:36:17 +00:00
|
|
|
|
2001-11-20 18:36:50 +00:00
|
|
|
void *vo_spudec=NULL;
|
2002-01-10 17:21:00 +00:00
|
|
|
void *vo_vobsub=NULL;
|
2001-11-20 18:36:50 +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
|
|
|
|
2006-02-09 14:08:03 +00:00
|
|
|
extern void vo_draw_alpha_init(void);
|
2001-06-12 14:03:18 +00:00
|
|
|
|
2002-08-22 13:58:38 +00:00
|
|
|
mp_osd_obj_t* vo_osd_list=NULL;
|
2001-03-27 00:32:24 +00:00
|
|
|
|
2006-07-08 15:26:36 +00:00
|
|
|
static mp_osd_obj_t* new_osd_obj(int type){
|
2002-04-15 19:17:12 +00:00
|
|
|
mp_osd_obj_t* osd=malloc(sizeof(mp_osd_obj_t));
|
|
|
|
memset(osd,0,sizeof(mp_osd_obj_t));
|
|
|
|
osd->next=vo_osd_list;
|
|
|
|
vo_osd_list=osd;
|
|
|
|
osd->type=type;
|
2002-08-28 20:45:42 +00:00
|
|
|
osd->alpha_buffer = NULL;
|
|
|
|
osd->bitmap_buffer = NULL;
|
|
|
|
osd->allocated = -1;
|
2002-04-15 19:17:12 +00:00
|
|
|
return osd;
|
|
|
|
}
|
2002-01-10 17:21:00 +00:00
|
|
|
|
2006-02-09 14:08:03 +00:00
|
|
|
void free_osd_list(void){
|
2002-04-15 19:17:12 +00:00
|
|
|
mp_osd_obj_t* obj=vo_osd_list;
|
|
|
|
while(obj){
|
|
|
|
mp_osd_obj_t* next=obj->next;
|
2002-08-28 20:45:42 +00:00
|
|
|
if (obj->alpha_buffer) free(obj->alpha_buffer);
|
|
|
|
if (obj->bitmap_buffer) free(obj->bitmap_buffer);
|
2002-04-15 19:17:12 +00:00
|
|
|
free(obj);
|
|
|
|
obj=next;
|
2002-01-10 17:21:00 +00:00
|
|
|
}
|
2002-04-15 19:17:12 +00:00
|
|
|
vo_osd_list=NULL;
|
|
|
|
}
|
2002-01-10 17:21:00 +00:00
|
|
|
|
2005-04-10 11:54:31 +00:00
|
|
|
#define FONT_LOAD_DEFER 6
|
|
|
|
|
2002-04-15 19:17:12 +00:00
|
|
|
int vo_update_osd(int dxs,int dys){
|
|
|
|
mp_osd_obj_t* obj=vo_osd_list;
|
|
|
|
int chg=0;
|
2005-04-10 11:54:31 +00:00
|
|
|
#ifdef HAVE_FREETYPE
|
|
|
|
static int defer_counter = 0, prev_dxs = 0, prev_dys = 0;
|
|
|
|
#endif
|
2002-08-28 20:45:42 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_FREETYPE
|
|
|
|
// here is the right place to get screen dimensions
|
2005-04-10 11:54:31 +00:00
|
|
|
if (((dxs != vo_image_width)
|
|
|
|
&& (subtitle_autoscale == 2 || subtitle_autoscale == 3))
|
|
|
|
|| ((dys != vo_image_height)
|
|
|
|
&& (subtitle_autoscale == 1 || subtitle_autoscale == 3)))
|
|
|
|
{
|
|
|
|
// screen dimensions changed
|
|
|
|
// wait a while to avoid useless reloading of the font
|
|
|
|
if (dxs == prev_dxs || dys == prev_dys) {
|
|
|
|
defer_counter++;
|
|
|
|
} else {
|
|
|
|
prev_dxs = dxs;
|
|
|
|
prev_dys = dys;
|
|
|
|
defer_counter = 0;
|
|
|
|
}
|
|
|
|
if (defer_counter >= FONT_LOAD_DEFER) force_load_font = 1;
|
|
|
|
}
|
|
|
|
|
2007-05-20 16:10:45 +00:00
|
|
|
if (force_load_font) {
|
2002-08-28 20:45:42 +00:00
|
|
|
force_load_font = 0;
|
2008-01-27 15:14:02 +00:00
|
|
|
load_font_ft(dxs, dys, &vo_font, font_name, osd_font_scale_factor);
|
2007-07-11 10:01:54 +00:00
|
|
|
if (sub_font_name)
|
2008-01-27 15:14:02 +00:00
|
|
|
load_font_ft(dxs, dys, &sub_font, sub_font_name, text_font_scale_factor);
|
2007-07-11 10:01:54 +00:00
|
|
|
else
|
2008-01-27 15:14:02 +00:00
|
|
|
load_font_ft(dxs, dys, &sub_font, font_name, text_font_scale_factor);
|
2005-04-10 11:54:31 +00:00
|
|
|
prev_dxs = dxs;
|
|
|
|
prev_dys = dys;
|
|
|
|
defer_counter = 0;
|
2007-05-20 16:10:45 +00:00
|
|
|
} else {
|
|
|
|
if (!vo_font)
|
2008-01-27 15:14:02 +00:00
|
|
|
load_font_ft(dxs, dys, &vo_font, font_name, osd_font_scale_factor);
|
2007-09-24 15:39:12 +00:00
|
|
|
if (!sub_font) {
|
2007-07-11 10:01:54 +00:00
|
|
|
if (sub_font_name)
|
2008-01-27 15:14:02 +00:00
|
|
|
load_font_ft(dxs, dys, &sub_font, sub_font_name, text_font_scale_factor);
|
2007-07-11 10:01:54 +00:00
|
|
|
else
|
2008-01-27 15:14:02 +00:00
|
|
|
load_font_ft(dxs, dys, &sub_font, font_name, text_font_scale_factor);
|
2007-09-24 15:39:12 +00:00
|
|
|
}
|
2002-08-28 20:45:42 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2002-04-15 19:17:12 +00:00
|
|
|
while(obj){
|
|
|
|
if(dxs!=obj->dxs || dys!=obj->dys || obj->flags&OSDFLAG_FORCE_UPDATE){
|
|
|
|
int vis=obj->flags&OSDFLAG_VISIBLE;
|
2002-04-15 20:51:34 +00:00
|
|
|
obj->flags&=~OSDFLAG_BBOX;
|
2002-04-15 19:17:12 +00:00
|
|
|
switch(obj->type){
|
2006-11-25 11:20:02 +00:00
|
|
|
#ifdef USE_DVDNAV
|
|
|
|
case OSDTYPE_DVDNAV:
|
|
|
|
vo_update_nav(obj,dxs,dys);
|
|
|
|
break;
|
|
|
|
#endif
|
2002-04-15 19:17:12 +00:00
|
|
|
case OSDTYPE_SUBTITLE:
|
|
|
|
vo_update_text_sub(obj,dxs,dys);
|
|
|
|
break;
|
2007-07-29 17:57:39 +00:00
|
|
|
#ifdef HAVE_TV_TELETEXT
|
|
|
|
case OSDTYPE_TELETEXT:
|
|
|
|
vo_update_text_teletext(obj,dxs,dys);
|
|
|
|
break;
|
|
|
|
#endif
|
2002-04-15 19:17:12 +00:00
|
|
|
case OSDTYPE_PROGBAR:
|
|
|
|
vo_update_text_progbar(obj,dxs,dys);
|
|
|
|
break;
|
|
|
|
case OSDTYPE_SPU:
|
2002-10-06 17:40:51 +00:00
|
|
|
if(sub_visibility && vo_spudec && spudec_visible(vo_spudec)){
|
2002-05-25 17:40:40 +00:00
|
|
|
vo_update_spudec_sub(obj, dxs, dys);
|
2002-04-15 19:17:12 +00:00
|
|
|
obj->flags|=OSDFLAG_VISIBLE|OSDFLAG_CHANGED;
|
2002-05-25 17:40:40 +00:00
|
|
|
}
|
2002-04-15 19:17:12 +00:00
|
|
|
else
|
|
|
|
obj->flags&=~OSDFLAG_VISIBLE;
|
|
|
|
break;
|
|
|
|
case OSDTYPE_OSD:
|
2002-04-15 20:51:34 +00:00
|
|
|
if(vo_font && vo_osd_text && vo_osd_text[0]){
|
|
|
|
vo_update_text_osd(obj,dxs,dys); // update bbox
|
2002-04-15 19:17:12 +00:00
|
|
|
obj->flags|=OSDFLAG_VISIBLE|OSDFLAG_CHANGED;
|
2002-04-15 20:51:34 +00:00
|
|
|
} else
|
2002-04-15 19:17:12 +00:00
|
|
|
obj->flags&=~OSDFLAG_VISIBLE;
|
|
|
|
break;
|
|
|
|
}
|
2002-04-15 20:51:34 +00:00
|
|
|
// check bbox:
|
|
|
|
if(!(obj->flags&OSDFLAG_BBOX)){
|
|
|
|
// we don't know, so assume the whole screen changed :(
|
|
|
|
obj->bbox.x1=obj->bbox.y1=0;
|
|
|
|
obj->bbox.x2=dxs;
|
|
|
|
obj->bbox.y2=dys;
|
|
|
|
obj->flags|=OSDFLAG_BBOX;
|
2002-04-17 20:46:12 +00:00
|
|
|
} else {
|
|
|
|
// check bbox, reduce it if it's out of bounds (corners):
|
|
|
|
if(obj->bbox.x1<0) obj->bbox.x1=0;
|
|
|
|
if(obj->bbox.y1<0) obj->bbox.y1=0;
|
|
|
|
if(obj->bbox.x2>dxs) obj->bbox.x2=dxs;
|
|
|
|
if(obj->bbox.y2>dys) obj->bbox.y2=dys;
|
|
|
|
if(obj->flags&OSDFLAG_VISIBLE)
|
|
|
|
// debug:
|
|
|
|
mp_msg(MSGT_OSD,MSGL_DBG2,"OSD update: %d;%d %dx%d \n",
|
2002-04-15 20:51:34 +00:00
|
|
|
obj->bbox.x1,obj->bbox.y1,obj->bbox.x2-obj->bbox.x1,
|
|
|
|
obj->bbox.y2-obj->bbox.y1);
|
|
|
|
}
|
2002-04-15 19:17:12 +00:00
|
|
|
// check if visibility changed:
|
|
|
|
if(vis != (obj->flags&OSDFLAG_VISIBLE) ) obj->flags|=OSDFLAG_CHANGED;
|
2002-04-15 20:51:34 +00:00
|
|
|
// remove the cause of automatic update:
|
2002-04-15 19:17:12 +00:00
|
|
|
obj->dxs=dxs; obj->dys=dys;
|
|
|
|
obj->flags&=~OSDFLAG_FORCE_UPDATE;
|
|
|
|
}
|
|
|
|
if(obj->flags&OSDFLAG_CHANGED){
|
|
|
|
chg|=1<<obj->type;
|
|
|
|
mp_msg(MSGT_OSD,MSGL_DBG2,"OSD chg: %d V: %s pb:%d \n",obj->type,(obj->flags&OSDFLAG_VISIBLE)?"yes":"no",vo_osd_progbar_type);
|
|
|
|
}
|
|
|
|
obj=obj->next;
|
|
|
|
}
|
|
|
|
return chg;
|
|
|
|
}
|
2001-03-27 00:32:24 +00:00
|
|
|
|
2006-02-09 14:08:03 +00:00
|
|
|
void vo_init_osd(void){
|
2001-06-02 16:02:38 +00:00
|
|
|
if(!draw_alpha_init_flag){
|
|
|
|
draw_alpha_init_flag=1;
|
|
|
|
vo_draw_alpha_init();
|
|
|
|
}
|
2002-05-17 23:47:27 +00:00
|
|
|
if(vo_osd_list) free_osd_list();
|
2002-04-15 19:17:12 +00:00
|
|
|
// temp hack, should be moved to mplayer/mencoder later
|
|
|
|
new_osd_obj(OSDTYPE_OSD);
|
|
|
|
new_osd_obj(OSDTYPE_SUBTITLE);
|
|
|
|
new_osd_obj(OSDTYPE_PROGBAR);
|
|
|
|
new_osd_obj(OSDTYPE_SPU);
|
2006-11-25 11:20:02 +00:00
|
|
|
#ifdef USE_DVDNAV
|
|
|
|
new_osd_obj(OSDTYPE_DVDNAV);
|
|
|
|
#endif
|
2007-07-29 17:57:39 +00:00
|
|
|
#if HAVE_TV_TELETEXT
|
|
|
|
new_osd_obj(OSDTYPE_TELETEXT);
|
|
|
|
#endif
|
2002-08-28 20:45:42 +00:00
|
|
|
#ifdef HAVE_FREETYPE
|
|
|
|
force_load_font = 1;
|
|
|
|
#endif
|
2002-04-15 19:17:12 +00:00
|
|
|
}
|
2001-06-02 16:02:38 +00:00
|
|
|
|
2002-04-15 22:08:50 +00:00
|
|
|
int vo_osd_changed_flag=0;
|
2002-04-15 19:17:12 +00:00
|
|
|
|
2002-04-15 22:08:50 +00:00
|
|
|
void vo_remove_text(int dxs,int dys,void (*remove)(int x0,int y0, int w,int h)){
|
|
|
|
mp_osd_obj_t* obj=vo_osd_list;
|
2002-04-15 19:17:12 +00:00
|
|
|
vo_update_osd(dxs,dys);
|
2002-04-15 22:08:50 +00:00
|
|
|
while(obj){
|
|
|
|
if(((obj->flags&OSDFLAG_CHANGED) || (obj->flags&OSDFLAG_VISIBLE)) &&
|
|
|
|
(obj->flags&OSDFLAG_OLD_BBOX)){
|
|
|
|
int w=obj->old_bbox.x2-obj->old_bbox.x1;
|
|
|
|
int h=obj->old_bbox.y2-obj->old_bbox.y1;
|
|
|
|
if(w>0 && h>0){
|
|
|
|
vo_osd_changed_flag=obj->flags&OSDFLAG_CHANGED; // temp hack
|
|
|
|
remove(obj->old_bbox.x1,obj->old_bbox.y1,w,h);
|
|
|
|
}
|
|
|
|
// obj->flags&=~OSDFLAG_OLD_BBOX;
|
|
|
|
}
|
2002-04-16 00:35:01 +00:00
|
|
|
obj=obj->next;
|
2002-04-15 22:08:50 +00:00
|
|
|
}
|
|
|
|
}
|
2002-04-15 19:17:12 +00:00
|
|
|
|
2002-04-15 22:08:50 +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)){
|
|
|
|
mp_osd_obj_t* obj=vo_osd_list;
|
|
|
|
vo_update_osd(dxs,dys);
|
2002-04-15 19:17:12 +00:00
|
|
|
while(obj){
|
2002-04-15 22:08:50 +00:00
|
|
|
if(obj->flags&OSDFLAG_VISIBLE){
|
|
|
|
vo_osd_changed_flag=obj->flags&OSDFLAG_CHANGED; // temp hack
|
2002-04-15 19:17:12 +00:00
|
|
|
switch(obj->type){
|
|
|
|
case OSDTYPE_SPU:
|
2002-05-25 17:40:40 +00:00
|
|
|
vo_draw_spudec_sub(obj, draw_alpha); // FIXME
|
2002-04-15 19:17:12 +00:00
|
|
|
break;
|
2006-11-25 11:20:02 +00:00
|
|
|
#ifdef USE_DVDNAV
|
|
|
|
case OSDTYPE_DVDNAV:
|
2007-07-29 17:57:39 +00:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_TV_TELETEXT
|
|
|
|
case OSDTYPE_TELETEXT:
|
2006-11-25 11:20:02 +00:00
|
|
|
#endif
|
2002-04-15 19:17:12 +00:00
|
|
|
case OSDTYPE_OSD:
|
|
|
|
case OSDTYPE_SUBTITLE:
|
|
|
|
case OSDTYPE_PROGBAR:
|
2002-08-28 20:45:42 +00:00
|
|
|
vo_draw_text_from_buffer(obj,draw_alpha);
|
2002-04-15 19:17:12 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
obj->old_bbox=obj->bbox;
|
2002-04-15 22:08:50 +00:00
|
|
|
obj->flags|=OSDFLAG_OLD_BBOX;
|
|
|
|
}
|
|
|
|
obj->flags&=~OSDFLAG_CHANGED;
|
|
|
|
obj=obj->next;
|
2001-03-27 00:32:24 +00:00
|
|
|
}
|
|
|
|
}
|
2002-04-15 19:17:12 +00:00
|
|
|
|
2002-02-22 15:25:11 +00:00
|
|
|
static int vo_osd_changed_status = 0;
|
|
|
|
|
|
|
|
int vo_osd_changed(int new_value)
|
|
|
|
{
|
2002-04-15 19:17:12 +00:00
|
|
|
mp_osd_obj_t* obj=vo_osd_list;
|
2002-02-22 15:25:11 +00:00
|
|
|
int ret = vo_osd_changed_status;
|
|
|
|
vo_osd_changed_status = new_value;
|
2002-04-15 19:17:12 +00:00
|
|
|
|
|
|
|
while(obj){
|
|
|
|
if(obj->type==new_value) obj->flags|=OSDFLAG_FORCE_UPDATE;
|
|
|
|
obj=obj->next;
|
|
|
|
}
|
|
|
|
|
2002-02-22 15:25:11 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2002-04-15 19:17:12 +00:00
|
|
|
|
2002-04-16 00:35:01 +00:00
|
|
|
// BBBBBBBBBBBB AAAAAAAAAAAAA BBBBBBBBBBB
|
|
|
|
// BBBBBBBBBBBB BBBBBBBBBBBBB
|
|
|
|
// BBBBBBB
|
|
|
|
|
|
|
|
// return TRUE if we have osd in the specified rectangular area:
|
|
|
|
int vo_osd_check_range_update(int x1,int y1,int x2,int y2){
|
|
|
|
mp_osd_obj_t* obj=vo_osd_list;
|
|
|
|
while(obj){
|
|
|
|
if(obj->flags&OSDFLAG_VISIBLE){
|
|
|
|
if( (obj->bbox.x1<=x2 && obj->bbox.x2>=x1) &&
|
2006-11-29 11:57:16 +00:00
|
|
|
(obj->bbox.y1<=y2 && obj->bbox.y2>=y1) &&
|
2006-12-03 09:59:55 +00:00
|
|
|
obj->bbox.y2 > obj->bbox.y1 && obj->bbox.x2 > obj->bbox.x1
|
2006-11-29 11:57:16 +00:00
|
|
|
) return 1;
|
2002-04-16 00:35:01 +00:00
|
|
|
}
|
|
|
|
obj=obj->next;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|