annotate libvo/sub.c @ 5664:ee6c9530729f

bbox calculation fixed (font->height < real height)
author arpi
date Wed, 17 Apr 2002 20:46:12 +0000
parents bd5c0d8346f0
children 7bea806b9c5f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5503
a531a579f005 #include cleanup
arpi
parents: 5294
diff changeset
1
a531a579f005 #include cleanup
arpi
parents: 5294
diff changeset
2 #include <stdio.h>
a531a579f005 #include cleanup
arpi
parents: 5294
diff changeset
3 #include <stdlib.h>
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
4
4088
4435dc3b8bef Add DVD subtitles to menoder
kmkaplan
parents: 4087
diff changeset
5 #include "config.h"
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
6 #include "mp_msg.h"
4088
4435dc3b8bef Add DVD subtitles to menoder
kmkaplan
parents: 4087
diff changeset
7 #include "video_out.h"
5294
4e64fca268e9 moved font_laod.h
arpi
parents: 4807
diff changeset
8 #include "font_load.h"
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
9 #include "sub.h"
202
6ad0715dfac8 grey+alpha rendering support (for .sub)
arpi_esp
parents:
diff changeset
10
2498
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
11 char * __sub_osd_names[]={
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
12 "Seekbar",
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
13 "Play",
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
14 "Pause",
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
15 "Stop",
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
16 "Rewind",
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
17 "Forward",
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
18 "Clock",
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
19 "Contrast",
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
20 "Saturation",
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
21 "Volume",
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
22 "Brightness",
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
23 "Hue"
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
24 };
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
25 char * __sub_osd_names_short[] ={ "", "|>", "||", "[]", "<<" , ">>", "", "", "", "", "", ""};
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
26
213
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
27 //static int vo_font_loaded=-1;
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
28 font_desc_t* vo_font=NULL;
202
6ad0715dfac8 grey+alpha rendering support (for .sub)
arpi_esp
parents:
diff changeset
29
1991
dee4b2ea5e5b add gui support to config scripts, and fixed some warning.
pontscho
parents: 1878
diff changeset
30 unsigned char* vo_osd_text=NULL;
803
b25a887b6054 sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents: 726
diff changeset
31 int sub_unicode=0;
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
32 int sub_utf8=0;
4773
976bf6a9ded5 subtitle positioning patch by Jiri Svoboda
atmos4
parents: 4088
diff changeset
33 int sub_pos=100;
213
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
34
5664
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
35 // return the real height of a char:
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
36 static inline int get_height(int c,int h){
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
37 int font;
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
38 if ((font=vo_font->font[c])>=0)
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
39 if(h<vo_font->pic_a[font]->h) h=vo_font->pic_a[font]->h;
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
40 return h;
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
41 }
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
42
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
43 inline static void vo_update_text_osd(mp_osd_obj_t* obj,int dxs,int dys){
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
44 unsigned char *cp=vo_osd_text;
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
45 int x=20;
5664
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
46 int h=0;
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
47
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
48 obj->bbox.x1=obj->x=x;
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
49 obj->bbox.y1=obj->y=10;
202
6ad0715dfac8 grey+alpha rendering support (for .sub)
arpi_esp
parents:
diff changeset
50
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
51 while (*cp){
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
52 int c=*cp++;
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
53 x+=vo_font->width[c]+vo_font->charspace;
5664
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
54 h=get_height(c,h);
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
55 }
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
56
5664
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
57 obj->bbox.x2=x-vo_font->charspace;
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
58 obj->bbox.y2=obj->bbox.y1+h;
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
59 obj->flags|=OSDFLAG_BBOX;
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
60
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
61 }
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
62
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
63 inline static void vo_draw_text_osd(mp_osd_obj_t* obj,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)){
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
64 unsigned char *cp=vo_osd_text;
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
65 int font;
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
66 int x=obj->x;
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
67
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
68 while (*cp){
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
69 int c=*cp++;
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
70 if ((font=vo_font->font[c])>=0)
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
71 draw_alpha(x,obj->y,
213
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
72 vo_font->width[c],
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
73 vo_font->pic_a[font]->h,
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
74 vo_font->pic_b[font]->bmp+vo_font->start[c],
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
75 vo_font->pic_a[font]->bmp+vo_font->start[c],
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
76 vo_font->pic_a[font]->w);
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
77 x+=vo_font->width[c]+vo_font->charspace;
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
78 }
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
79 }
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
80
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
81 int vo_osd_progbar_type=-1;
1726
38871427a131 corrections to OSD progbar position calculations
atlka
parents: 1602
diff changeset
82 int vo_osd_progbar_value=100; // 0..256
38871427a131 corrections to OSD progbar position calculations
atlka
parents: 1602
diff changeset
83
38871427a131 corrections to OSD progbar position calculations
atlka
parents: 1602
diff changeset
84 // if we have n=256 bars then OSD progbar looks like below
38871427a131 corrections to OSD progbar position calculations
atlka
parents: 1602
diff changeset
85 //
1878
96ae64356ea0 corrections to OSD mark position
atlka
parents: 1852
diff changeset
86 // 0 1 2 3 ... 256 <= vo_osd_progbar_value
96ae64356ea0 corrections to OSD mark position
atlka
parents: 1852
diff changeset
87 // | | | | |
1726
38871427a131 corrections to OSD progbar position calculations
atlka
parents: 1602
diff changeset
88 // [ === === === ... === ]
38871427a131 corrections to OSD progbar position calculations
atlka
parents: 1602
diff changeset
89 //
38871427a131 corrections to OSD progbar position calculations
atlka
parents: 1602
diff changeset
90 // the above schema is rescalled to n=elems bars
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
91
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
92 inline static void vo_update_text_progbar(mp_osd_obj_t* obj,int dxs,int dys){
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
93
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
94 obj->flags|=OSDFLAG_CHANGED|OSDFLAG_VISIBLE;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
95
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
96 if(vo_osd_progbar_type<0 || !vo_font){
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
97 obj->flags&=~OSDFLAG_VISIBLE;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
98 return;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
99 }
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
100
5664
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
101 { int h=0;
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
102 int y=(dys-vo_font->height)/2;
1548
eee7951a23af changes according to proper subfont bar positioning and char spaceing - sub.c
atlka
parents: 1524
diff changeset
103 int delimw=vo_font->width[OSD_PB_START]
1549
787c053b314c minor changes in sub.c
atlka
parents: 1548
diff changeset
104 +vo_font->width[OSD_PB_END]
787c053b314c minor changes in sub.c
atlka
parents: 1548
diff changeset
105 +vo_font->charspace;
1548
eee7951a23af changes according to proper subfont bar positioning and char spaceing - sub.c
atlka
parents: 1524
diff changeset
106 int width=(2*dxs-3*delimw)/3;
1549
787c053b314c minor changes in sub.c
atlka
parents: 1548
diff changeset
107 int charw=vo_font->width[OSD_PB_0]+vo_font->charspace;
1548
eee7951a23af changes according to proper subfont bar positioning and char spaceing - sub.c
atlka
parents: 1524
diff changeset
108 int elems=width/charw;
1549
787c053b314c minor changes in sub.c
atlka
parents: 1548
diff changeset
109 int x=(dxs-elems*charw-delimw)/2;
5664
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
110 h=get_height(OSD_PB_START,h);
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
111 h=get_height(OSD_PB_END,h);
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
112 h=get_height(OSD_PB_0,h);
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
113 h=get_height(OSD_PB_1,h);
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
114 obj->bbox.x1=obj->x=x;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
115 obj->bbox.y1=obj->y=y;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
116 obj->bbox.x2=x+width+delimw;
5664
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
117 obj->bbox.y2=y+h; //vo_font->height;
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
118 obj->flags|=OSDFLAG_BBOX;
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
119 obj->params.progbar.elems=elems;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
120 }
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
121
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
122 }
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
123
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
124 inline static void vo_draw_text_progbar(mp_osd_obj_t* obj,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)){
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
125 unsigned char *s;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
126 unsigned char *sa;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
127 int i,w,h,st,mark;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
128 int x=obj->x;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
129 int y=obj->y;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
130 int c,font;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
131 int charw=vo_font->width[OSD_PB_0]+vo_font->charspace;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
132 int elems=obj->params.progbar.elems;
1548
eee7951a23af changes according to proper subfont bar positioning and char spaceing - sub.c
atlka
parents: 1524
diff changeset
133
1726
38871427a131 corrections to OSD progbar position calculations
atlka
parents: 1602
diff changeset
134 if (vo_osd_progbar_value<=0)
38871427a131 corrections to OSD progbar position calculations
atlka
parents: 1602
diff changeset
135 mark=0;
1878
96ae64356ea0 corrections to OSD mark position
atlka
parents: 1852
diff changeset
136 else {
96ae64356ea0 corrections to OSD mark position
atlka
parents: 1852
diff changeset
137 int ev=vo_osd_progbar_value*elems;
96ae64356ea0 corrections to OSD mark position
atlka
parents: 1852
diff changeset
138 mark=ev>>8;
96ae64356ea0 corrections to OSD mark position
atlka
parents: 1852
diff changeset
139 if (ev & 0xFF) mark++;
96ae64356ea0 corrections to OSD mark position
atlka
parents: 1852
diff changeset
140 if (mark>elems) mark=elems;
96ae64356ea0 corrections to OSD mark position
atlka
parents: 1852
diff changeset
141 }
96ae64356ea0 corrections to OSD mark position
atlka
parents: 1852
diff changeset
142
1727
9da2b587b029 changes according to OSD calculations
atlka
parents: 1726
diff changeset
143
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
144 // printf("osd.progbar width=%d xpos=%d\n",width,x);
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
145
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
146 c=vo_osd_progbar_type;
1569
fcbfc99cf8e6 skip lines with negative y position if there is too many lines to display
atlka
parents: 1549
diff changeset
147 if(vo_osd_progbar_type>0 && (font=vo_font->font[c])>=0) {
fcbfc99cf8e6 skip lines with negative y position if there is too many lines to display
atlka
parents: 1549
diff changeset
148 int xp=x-vo_font->width[c]-vo_font->spacewidth;
fcbfc99cf8e6 skip lines with negative y position if there is too many lines to display
atlka
parents: 1549
diff changeset
149 draw_alpha((xp<0?0:xp),y,
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
150 vo_font->width[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
151 vo_font->pic_a[font]->h,
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
152 vo_font->pic_b[font]->bmp+vo_font->start[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
153 vo_font->pic_a[font]->bmp+vo_font->start[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
154 vo_font->pic_a[font]->w);
1569
fcbfc99cf8e6 skip lines with negative y position if there is too many lines to display
atlka
parents: 1549
diff changeset
155 }
fcbfc99cf8e6 skip lines with negative y position if there is too many lines to display
atlka
parents: 1549
diff changeset
156
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
157 c=OSD_PB_START;
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
158 if ((font=vo_font->font[c])>=0)
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
159 draw_alpha(x,y,
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
160 vo_font->width[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
161 vo_font->pic_a[font]->h,
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
162 vo_font->pic_b[font]->bmp+vo_font->start[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
163 vo_font->pic_a[font]->bmp+vo_font->start[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
164 vo_font->pic_a[font]->w);
1548
eee7951a23af changes according to proper subfont bar positioning and char spaceing - sub.c
atlka
parents: 1524
diff changeset
165 x+=vo_font->width[c]+vo_font->charspace;
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
166
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
167 c=OSD_PB_0;
1602
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
168 if ((font=vo_font->font[c])>=0){
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
169 w=vo_font->width[c];
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
170 h=vo_font->pic_a[font]->h;
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
171 s=vo_font->pic_b[font]->bmp+vo_font->start[c];
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
172 sa=vo_font->pic_a[font]->bmp+vo_font->start[c];
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
173 st=vo_font->pic_a[font]->w;
2204
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
174 if ((i=mark)) do {
1602
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
175 draw_alpha(x,y,w,h,s,sa,st);
1548
eee7951a23af changes according to proper subfont bar positioning and char spaceing - sub.c
atlka
parents: 1524
diff changeset
176 x+=charw;
2204
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
177 } while(--i);
1602
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
178 }
202
6ad0715dfac8 grey+alpha rendering support (for .sub)
arpi_esp
parents:
diff changeset
179
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
180 c=OSD_PB_1;
1602
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
181 if ((font=vo_font->font[c])>=0){
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
182 w=vo_font->width[c];
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
183 h=vo_font->pic_a[font]->h;
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
184 s =vo_font->pic_b[font]->bmp+vo_font->start[c];
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
185 sa=vo_font->pic_a[font]->bmp+vo_font->start[c];
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
186 st=vo_font->pic_a[font]->w;
2204
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
187 if ((i=elems-mark)) do {
1602
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
188 draw_alpha(x,y,w,h,s,sa,st);
1548
eee7951a23af changes according to proper subfont bar positioning and char spaceing - sub.c
atlka
parents: 1524
diff changeset
189 x+=charw;
2204
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
190 } while(--i);
1602
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
191 }
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
192
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
193 c=OSD_PB_END;
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
194 if ((font=vo_font->font[c])>=0)
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
195 draw_alpha(x,y,
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
196 vo_font->width[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
197 vo_font->pic_a[font]->h,
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
198 vo_font->pic_b[font]->bmp+vo_font->start[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
199 vo_font->pic_a[font]->bmp+vo_font->start[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
200 vo_font->pic_a[font]->w);
1548
eee7951a23af changes according to proper subfont bar positioning and char spaceing - sub.c
atlka
parents: 1524
diff changeset
201 // x+=vo_font->width[c]+vo_font->charspace;
803
b25a887b6054 sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents: 726
diff changeset
202
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
203
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
204 // vo_osd_progbar_value=(vo_osd_progbar_value+1)&0xFF;
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
205
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
206 }
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
207
254
57f0156416e3 use subreader's sub struct
arpi_esp
parents: 218
diff changeset
208 subtitle* vo_sub=NULL;
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
209
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
210 // 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))
1591
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
211
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
212 inline static void vo_update_text_sub(mp_osd_obj_t* obj,int dxs,int dys){
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
213 unsigned char *t;
1591
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
214 int c,i,j,l,x,y,font;
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
215 int len;
1591
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
216 int k,lastk;
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
217 int lastStripPosition;
1591
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
218 int xsize,lastxsize;
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
219 int xmin=dxs,xmax=0;
1591
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
220 int h,lasth;
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
221
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
222 obj->flags|=OSDFLAG_CHANGED|OSDFLAG_VISIBLE;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
223
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
224 if(!vo_sub || !vo_font){
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
225 obj->flags&=~OSDFLAG_VISIBLE;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
226 return;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
227 }
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
228
5664
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
229 obj->bbox.y2=obj->y=dys;
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
230 obj->params.subtitle.lines=0;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
231
1602
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
232 // too long lines divide into a smaller ones
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
233 i=k=lasth=0;
1591
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
234 h=vo_font->height;
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
235 xsize=-vo_font->charspace;
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
236 lastStripPosition=-1;
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
237 l=vo_sub->lines;
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
238
2204
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
239 while (l) {
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
240 l--;
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
241 t=vo_sub->text[i++];
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
242 len=strlen(t)-1;
1824
33035a1d897e small fixes, and Y check put back to avoid sig11
arpi
parents: 1822
diff changeset
243
1852
58dd326fcc4a fix xshape, mixer, fullscreen, etc
pontscho
parents: 1824
diff changeset
244 // printf("sub(%d) '%s'\n",len,t);
1824
33035a1d897e small fixes, and Y check put back to avoid sig11
arpi
parents: 1822
diff changeset
245 // if(len<0) memy -=h; // according to max of vo_font->pic_a[font]->h
33035a1d897e small fixes, and Y check put back to avoid sig11
arpi
parents: 1822
diff changeset
246 // else
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
247 for (j=0;j<=len;j++){
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
248 if ((c=t[j])>=0x80){
2176
1ae16a34f055 speed improvements
atlka
parents: 1991
diff changeset
249 if (sub_utf8){
1ae16a34f055 speed improvements
atlka
parents: 1991
diff changeset
250 if ((c & 0xe0) == 0xc0) /* 2 bytes U+00080..U+0007FF*/
1ae16a34f055 speed improvements
atlka
parents: 1991
diff changeset
251 c = (c & 0x1f)<<6 | (t[++j] & 0x3f);
1ae16a34f055 speed improvements
atlka
parents: 1991
diff changeset
252 else if((c & 0xf0) == 0xe0)/* 3 bytes U+00800..U+00FFFF*/
1ae16a34f055 speed improvements
atlka
parents: 1991
diff changeset
253 c = ((c & 0x0f)<<6 |
1ae16a34f055 speed improvements
atlka
parents: 1991
diff changeset
254 (t[++j] & 0x3f))<<6 | (t[++j] & 0x3f);
1ae16a34f055 speed improvements
atlka
parents: 1991
diff changeset
255 } else if (sub_unicode)
1ae16a34f055 speed improvements
atlka
parents: 1991
diff changeset
256 c = (c<<8) + t[++j];
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
257 }
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
258 if (k==MAX_UCS){
2204
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
259 len=j; // end here
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
260 mp_msg(MSGT_OSD,MSGL_WARN,"\nMAX_UCS exceeded!\n");
1591
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
261 }
2204
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
262 if (!c) c++; // avoid UCS 0
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
263 if (c==' '){
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
264 lastk=k;
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
265 lastStripPosition=j;
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
266 lastxsize=xsize;
2204
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
267 } else if ((font=vo_font->font[c])>=0){
1591
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
268 if (vo_font->pic_a[font]->h > h){
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
269 h=vo_font->pic_a[font]->h;
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
270 }
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
271 }
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
272 obj->params.subtitle.utbl[k++]=c;
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
273 xsize+=vo_font->width[c]+vo_font->charspace;
1591
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
274 if (dxs<xsize){
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
275 if (lastStripPosition>0){
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
276 j=lastStripPosition;
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
277 xsize=lastxsize;
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
278 k=lastk;
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
279 } else {
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
280 xsize -=vo_font->width[c]+vo_font->charspace; // go back
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
281 k--; // cut line here
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
282 while (t[j] && t[j]!=' ') j++; // jump to the nearest space
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
283 }
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
284 } else if (j<len)
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
285 continue;
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
286 if (h>obj->y){ // out of the screen so end parsing
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
287 obj->y -= lasth - vo_font->height; // correct the y position
2204
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
288 l=0;
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
289 break;
1591
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
290 }
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
291 obj->params.subtitle.utbl[k++]=0;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
292 obj->params.subtitle.xtbl[obj->params.subtitle.lines++]=(dxs-xsize)/2;
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
293 if(xmin>(dxs-xsize)/2) xmin=(dxs-xsize)/2;
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
294 if(xmax<(dxs+xsize)/2) xmax=(dxs+xsize)/2;
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
295 if (obj->params.subtitle.lines==MAX_UCSLINES||k>MAX_UCS){
2204
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
296 l=0; len=j; // end parsing
1602
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
297 } else if(l || j<len){ // not the last line or not the last char
1591
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
298 lastStripPosition=-1;
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
299 xsize=-vo_font->charspace;
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
300 lasth=h;
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
301 h=vo_font->height;
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
302 }
2176
1ae16a34f055 speed improvements
atlka
parents: 1991
diff changeset
303 // printf("h: %d -> %d \n",vo_font->height,h);
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
304 obj->y -=h; // according to max of vo_font->pic_a[font]->h
1591
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
305 }
1573
c394d04d6b30 changes according to max of vo_font->pic_a[font]->h for the last line of subs
atlka
parents: 1569
diff changeset
306 }
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
307
5664
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
308 if (obj->y >= (dys * sub_pos / 100)){
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
309 int old=obj->y;
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
310 obj->y = dys * sub_pos /100;
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
311 obj->bbox.y2-=old-obj->y;
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
312 }
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
313
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
314 // calculate bbox:
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
315 obj->bbox.x1=xmin;
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
316 obj->bbox.x2=xmax;
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
317 obj->bbox.y1=obj->y;
5664
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
318 // obj->bbox.y2=obj->y+obj->params.subtitle.lines*vo_font->height;
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
319 obj->flags|=OSDFLAG_BBOX;
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
320
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
321 }
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
322
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
323 inline static void vo_draw_text_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)){
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
324 int i,j,c,x,l,font;
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
325 int y=obj->y;
202
6ad0715dfac8 grey+alpha rendering support (for .sub)
arpi_esp
parents:
diff changeset
326
2204
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
327 i=j=0;
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
328 if ((l=obj->params.subtitle.lines)) for (;;) {
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
329 x=obj->params.subtitle.xtbl[i++];
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
330 while ((c=obj->params.subtitle.utbl[j++])){
2176
1ae16a34f055 speed improvements
atlka
parents: 1991
diff changeset
331 if ((font=vo_font->font[c])>=0)
1569
fcbfc99cf8e6 skip lines with negative y position if there is too many lines to display
atlka
parents: 1549
diff changeset
332 draw_alpha(x,y,
fcbfc99cf8e6 skip lines with negative y position if there is too many lines to display
atlka
parents: 1549
diff changeset
333 vo_font->width[c],
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
334 vo_font->pic_a[font]->h+y<obj->dys ? vo_font->pic_a[font]->h : obj->dys-y,
1569
fcbfc99cf8e6 skip lines with negative y position if there is too many lines to display
atlka
parents: 1549
diff changeset
335 vo_font->pic_b[font]->bmp+vo_font->start[c],
fcbfc99cf8e6 skip lines with negative y position if there is too many lines to display
atlka
parents: 1549
diff changeset
336 vo_font->pic_a[font]->bmp+vo_font->start[c],
fcbfc99cf8e6 skip lines with negative y position if there is too many lines to display
atlka
parents: 1549
diff changeset
337 vo_font->pic_a[font]->w);
2204
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
338 x+=vo_font->width[c]+vo_font->charspace;
1569
fcbfc99cf8e6 skip lines with negative y position if there is too many lines to display
atlka
parents: 1549
diff changeset
339 }
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
340 if (!--l) break;
1591
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
341 y+=vo_font->height;
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
342 }
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
343 }
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
344
3034
24d3dca4e813 DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents: 2498
diff changeset
345 void *vo_spudec=NULL;
4081
9e581ab5e54b Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents: 3180
diff changeset
346 void *vo_vobsub=NULL;
3034
24d3dca4e813 DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents: 2498
diff changeset
347
947
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 865
diff changeset
348 static int draw_alpha_init_flag=0;
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
349
1109
a013b2124f05 -Wall like fixes
al3x
parents: 947
diff changeset
350 extern void vo_draw_alpha_init();
a013b2124f05 -Wall like fixes
al3x
parents: 947
diff changeset
351
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
352 static mp_osd_obj_t* vo_osd_list=NULL;
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
353
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
354 mp_osd_obj_t* new_osd_obj(int type){
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
355 mp_osd_obj_t* osd=malloc(sizeof(mp_osd_obj_t));
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
356 memset(osd,0,sizeof(mp_osd_obj_t));
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
357 osd->next=vo_osd_list;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
358 vo_osd_list=osd;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
359 osd->type=type;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
360 return osd;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
361 }
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
362
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
363 void free_osd_list(){
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
364 mp_osd_obj_t* obj=vo_osd_list;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
365 while(obj){
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
366 mp_osd_obj_t* next=obj->next;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
367 free(obj);
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
368 obj=next;
4081
9e581ab5e54b Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents: 3180
diff changeset
369 }
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
370 vo_osd_list=NULL;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
371 }
4081
9e581ab5e54b Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents: 3180
diff changeset
372
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
373 int vo_update_osd(int dxs,int dys){
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
374 mp_osd_obj_t* obj=vo_osd_list;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
375 int chg=0;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
376 while(obj){
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
377 if(dxs!=obj->dxs || dys!=obj->dys || obj->flags&OSDFLAG_FORCE_UPDATE){
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
378 int vis=obj->flags&OSDFLAG_VISIBLE;
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
379 obj->flags&=~OSDFLAG_BBOX;
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
380 switch(obj->type){
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
381 case OSDTYPE_SUBTITLE:
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
382 vo_update_text_sub(obj,dxs,dys);
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
383 break;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
384 case OSDTYPE_PROGBAR:
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
385 vo_update_text_progbar(obj,dxs,dys);
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
386 break;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
387 case OSDTYPE_SPU:
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
388 if(vo_spudec && spudec_visible(vo_spudec))
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
389 obj->flags|=OSDFLAG_VISIBLE|OSDFLAG_CHANGED;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
390 else
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
391 obj->flags&=~OSDFLAG_VISIBLE;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
392 break;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
393 case OSDTYPE_VOBSUB:
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
394 if(vo_vobsub)
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
395 obj->flags|=OSDFLAG_VISIBLE|OSDFLAG_CHANGED;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
396 else
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
397 obj->flags&=~OSDFLAG_VISIBLE;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
398 break;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
399 case OSDTYPE_OSD:
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
400 if(vo_font && vo_osd_text && vo_osd_text[0]){
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
401 vo_update_text_osd(obj,dxs,dys); // update bbox
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
402 obj->flags|=OSDFLAG_VISIBLE|OSDFLAG_CHANGED;
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
403 } else
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
404 obj->flags&=~OSDFLAG_VISIBLE;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
405 break;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
406 }
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
407 // check bbox:
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
408 if(!(obj->flags&OSDFLAG_BBOX)){
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
409 // we don't know, so assume the whole screen changed :(
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
410 obj->bbox.x1=obj->bbox.y1=0;
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
411 obj->bbox.x2=dxs;
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
412 obj->bbox.y2=dys;
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
413 obj->flags|=OSDFLAG_BBOX;
5664
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
414 } else {
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
415 // check bbox, reduce it if it's out of bounds (corners):
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
416 if(obj->bbox.x1<0) obj->bbox.x1=0;
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
417 if(obj->bbox.y1<0) obj->bbox.y1=0;
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
418 if(obj->bbox.x2>dxs) obj->bbox.x2=dxs;
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
419 if(obj->bbox.y2>dys) obj->bbox.y2=dys;
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
420 if(obj->flags&OSDFLAG_VISIBLE)
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
421 // debug:
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
422 mp_msg(MSGT_OSD,MSGL_DBG2,"OSD update: %d;%d %dx%d \n",
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
423 obj->bbox.x1,obj->bbox.y1,obj->bbox.x2-obj->bbox.x1,
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
424 obj->bbox.y2-obj->bbox.y1);
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
425 }
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
426 // check if visibility changed:
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
427 if(vis != (obj->flags&OSDFLAG_VISIBLE) ) obj->flags|=OSDFLAG_CHANGED;
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
428 // remove the cause of automatic update:
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
429 obj->dxs=dxs; obj->dys=dys;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
430 obj->flags&=~OSDFLAG_FORCE_UPDATE;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
431 }
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
432 if(obj->flags&OSDFLAG_CHANGED){
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
433 chg|=1<<obj->type;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
434 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);
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
435 }
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
436 obj=obj->next;
4081
9e581ab5e54b Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents: 3180
diff changeset
437 }
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
438 return chg;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
439 }
4081
9e581ab5e54b Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents: 3180
diff changeset
440
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
441 void vo_init_osd(){
947
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 865
diff changeset
442 if(!draw_alpha_init_flag){
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 865
diff changeset
443 draw_alpha_init_flag=1;
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 865
diff changeset
444 vo_draw_alpha_init();
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 865
diff changeset
445 }
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
446 if(vo_osd_list) free_osd_list;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
447 // temp hack, should be moved to mplayer/mencoder later
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
448 new_osd_obj(OSDTYPE_OSD);
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
449 new_osd_obj(OSDTYPE_SUBTITLE);
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
450 new_osd_obj(OSDTYPE_PROGBAR);
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
451 new_osd_obj(OSDTYPE_SPU);
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
452 new_osd_obj(OSDTYPE_VOBSUB);
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
453 }
947
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 865
diff changeset
454
5642
eb0cb6185e6c osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents: 5640
diff changeset
455 int vo_osd_changed_flag=0;
eb0cb6185e6c osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents: 5640
diff changeset
456
eb0cb6185e6c osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents: 5640
diff changeset
457 void vo_remove_text(int dxs,int dys,void (*remove)(int x0,int y0, int w,int h)){
eb0cb6185e6c osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents: 5640
diff changeset
458 mp_osd_obj_t* obj=vo_osd_list;
eb0cb6185e6c osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents: 5640
diff changeset
459 vo_update_osd(dxs,dys);
eb0cb6185e6c osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents: 5640
diff changeset
460 while(obj){
eb0cb6185e6c osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents: 5640
diff changeset
461 if(((obj->flags&OSDFLAG_CHANGED) || (obj->flags&OSDFLAG_VISIBLE)) &&
eb0cb6185e6c osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents: 5640
diff changeset
462 (obj->flags&OSDFLAG_OLD_BBOX)){
eb0cb6185e6c osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents: 5640
diff changeset
463 int w=obj->old_bbox.x2-obj->old_bbox.x1;
eb0cb6185e6c osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents: 5640
diff changeset
464 int h=obj->old_bbox.y2-obj->old_bbox.y1;
eb0cb6185e6c osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents: 5640
diff changeset
465 if(w>0 && h>0){
eb0cb6185e6c osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents: 5640
diff changeset
466 vo_osd_changed_flag=obj->flags&OSDFLAG_CHANGED; // temp hack
eb0cb6185e6c osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents: 5640
diff changeset
467 remove(obj->old_bbox.x1,obj->old_bbox.y1,w,h);
eb0cb6185e6c osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents: 5640
diff changeset
468 }
eb0cb6185e6c osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents: 5640
diff changeset
469 // obj->flags&=~OSDFLAG_OLD_BBOX;
eb0cb6185e6c osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents: 5640
diff changeset
470 }
5645
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
471 obj=obj->next;
5642
eb0cb6185e6c osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents: 5640
diff changeset
472 }
eb0cb6185e6c osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents: 5640
diff changeset
473 }
eb0cb6185e6c osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents: 5640
diff changeset
474
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
475 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)){
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
476 mp_osd_obj_t* obj=vo_osd_list;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
477 vo_update_osd(dxs,dys);
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
478 while(obj){
5642
eb0cb6185e6c osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents: 5640
diff changeset
479 if(obj->flags&OSDFLAG_VISIBLE){
eb0cb6185e6c osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents: 5640
diff changeset
480 vo_osd_changed_flag=obj->flags&OSDFLAG_CHANGED; // temp hack
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
481 switch(obj->type){
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
482 case OSDTYPE_SPU:
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
483 spudec_draw_scaled(vo_spudec, dxs, dys, draw_alpha); // FIXME
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
484 break;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
485 case OSDTYPE_VOBSUB:
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
486 vobsub_draw(vo_vobsub, dxs, dys, draw_alpha); // FIXME
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
487 break;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
488 case OSDTYPE_OSD:
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
489 vo_draw_text_osd(obj,draw_alpha);
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
490 break;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
491 case OSDTYPE_SUBTITLE:
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
492 vo_draw_text_sub(obj,draw_alpha);
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
493 break;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
494 case OSDTYPE_PROGBAR:
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
495 vo_draw_text_progbar(obj,draw_alpha);
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
496 break;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
497 }
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
498 obj->old_bbox=obj->bbox;
5642
eb0cb6185e6c osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents: 5640
diff changeset
499 obj->flags|=OSDFLAG_OLD_BBOX;
eb0cb6185e6c osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents: 5640
diff changeset
500 }
eb0cb6185e6c osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents: 5640
diff changeset
501 obj->flags&=~OSDFLAG_CHANGED;
eb0cb6185e6c osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents: 5640
diff changeset
502 obj=obj->next;
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
503 }
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
504 }
3034
24d3dca4e813 DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents: 2498
diff changeset
505
4807
156482788caf osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents: 4773
diff changeset
506 static int vo_osd_changed_status = 0;
156482788caf osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents: 4773
diff changeset
507
156482788caf osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents: 4773
diff changeset
508 int vo_osd_changed(int new_value)
156482788caf osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents: 4773
diff changeset
509 {
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
510 mp_osd_obj_t* obj=vo_osd_list;
4807
156482788caf osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents: 4773
diff changeset
511 int ret = vo_osd_changed_status;
156482788caf osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents: 4773
diff changeset
512 vo_osd_changed_status = new_value;
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
513
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
514 while(obj){
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
515 if(obj->type==new_value) obj->flags|=OSDFLAG_FORCE_UPDATE;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
516 obj=obj->next;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
517 }
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
518
4807
156482788caf osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents: 4773
diff changeset
519 return ret;
156482788caf osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents: 4773
diff changeset
520 }
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
521
5645
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
522 // BBBBBBBBBBBB AAAAAAAAAAAAA BBBBBBBBBBB
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
523 // BBBBBBBBBBBB BBBBBBBBBBBBB
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
524 // BBBBBBB
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
525
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
526 // return TRUE if we have osd in the specified rectangular area:
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
527 int vo_osd_check_range_update(int x1,int y1,int x2,int y2){
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
528 mp_osd_obj_t* obj=vo_osd_list;
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
529 while(obj){
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
530 if(obj->flags&OSDFLAG_VISIBLE){
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
531 if( (obj->bbox.x1<=x2 && obj->bbox.x2>=x1) &&
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
532 (obj->bbox.y1<=y2 && obj->bbox.y2>=y1) ) return 1;
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
533 }
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
534 obj=obj->next;
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
535 }
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
536 return 0;
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
537 }