annotate libvo/sub.c @ 5329:bf30f8d31e6a

reset selection
author arpi
date Mon, 25 Mar 2002 03:20:42 +0000
parents 4e64fca268e9
children a531a579f005
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
1
4088
4435dc3b8bef Add DVD subtitles to menoder
kmkaplan
parents: 4087
diff changeset
2 #include "config.h"
4435dc3b8bef Add DVD subtitles to menoder
kmkaplan
parents: 4087
diff changeset
3 #include "video_out.h"
5294
4e64fca268e9 moved font_laod.h
arpi
parents: 4807
diff changeset
4 #include "font_load.h"
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
5 #include "sub.h"
202
6ad0715dfac8 grey+alpha rendering support (for .sub)
arpi_esp
parents:
diff changeset
6
4088
4435dc3b8bef Add DVD subtitles to menoder
kmkaplan
parents: 4087
diff changeset
7 #include <stdlib.h>
2498
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
8
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
9 char * __sub_osd_names[]={
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
10 "Seekbar",
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
11 "Play",
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
12 "Pause",
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
13 "Stop",
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
14 "Rewind",
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
15 "Forward",
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
16 "Clock",
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
17 "Contrast",
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
18 "Saturation",
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
19 "Volume",
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
20 "Brightness",
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
21 "Hue"
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
22 };
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
23 char * __sub_osd_names_short[] ={ "", "|>", "||", "[]", "<<" , ">>", "", "", "", "", "", ""};
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
24
213
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
25 //static int vo_font_loaded=-1;
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
26 font_desc_t* vo_font=NULL;
202
6ad0715dfac8 grey+alpha rendering support (for .sub)
arpi_esp
parents:
diff changeset
27
1991
dee4b2ea5e5b add gui support to config scripts, and fixed some warning.
pontscho
parents: 1878
diff changeset
28 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
29 int sub_unicode=0;
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
30 int sub_utf8=0;
4773
976bf6a9ded5 subtitle positioning patch by Jiri Svoboda
atmos4
parents: 4088
diff changeset
31 int sub_pos=100;
213
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
32
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
33 inline static void vo_draw_text_osd(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)){
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
34 unsigned char *cp=vo_osd_text;
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
35 int c;
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
36 int font;
213
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
37 int y=10;
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
38 int x=20;
202
6ad0715dfac8 grey+alpha rendering support (for .sub)
arpi_esp
parents:
diff changeset
39
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
40 while (*cp){
1549
787c053b314c minor changes in sub.c
atlka
parents: 1548
diff changeset
41 c=*cp++;
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
42 if ((font=vo_font->font[c])>=0)
213
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
43 draw_alpha(x,y,
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
44 vo_font->width[c],
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
45 vo_font->pic_a[font]->h,
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
46 vo_font->pic_b[font]->bmp+vo_font->start[c],
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
47 vo_font->pic_a[font]->bmp+vo_font->start[c],
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
48 vo_font->pic_a[font]->w);
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
49 x+=vo_font->width[c]+vo_font->charspace;
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
50 }
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
51
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
52 }
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
53
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
54 int vo_osd_progbar_type=-1;
1726
38871427a131 corrections to OSD progbar position calculations
atlka
parents: 1602
diff changeset
55 int vo_osd_progbar_value=100; // 0..256
38871427a131 corrections to OSD progbar position calculations
atlka
parents: 1602
diff changeset
56
38871427a131 corrections to OSD progbar position calculations
atlka
parents: 1602
diff changeset
57 // if we have n=256 bars then OSD progbar looks like below
38871427a131 corrections to OSD progbar position calculations
atlka
parents: 1602
diff changeset
58 //
1878
96ae64356ea0 corrections to OSD mark position
atlka
parents: 1852
diff changeset
59 // 0 1 2 3 ... 256 <= vo_osd_progbar_value
96ae64356ea0 corrections to OSD mark position
atlka
parents: 1852
diff changeset
60 // | | | | |
1726
38871427a131 corrections to OSD progbar position calculations
atlka
parents: 1602
diff changeset
61 // [ === === === ... === ]
38871427a131 corrections to OSD progbar position calculations
atlka
parents: 1602
diff changeset
62 //
38871427a131 corrections to OSD progbar position calculations
atlka
parents: 1602
diff changeset
63 // the above schema is rescalled to n=elems bars
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
64
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
65 inline static void vo_draw_text_progbar(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)){
1602
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
66 unsigned char *s;
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
67 unsigned char *sa;
1726
38871427a131 corrections to OSD progbar position calculations
atlka
parents: 1602
diff changeset
68 int i,w,h,st,mark;
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
69 int y=(dys-vo_font->height)/2;
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
70 int c,font;
1548
eee7951a23af changes according to proper subfont bar positioning and char spaceing - sub.c
atlka
parents: 1524
diff changeset
71 int delimw=vo_font->width[OSD_PB_START]
1549
787c053b314c minor changes in sub.c
atlka
parents: 1548
diff changeset
72 +vo_font->width[OSD_PB_END]
787c053b314c minor changes in sub.c
atlka
parents: 1548
diff changeset
73 +vo_font->charspace;
1548
eee7951a23af changes according to proper subfont bar positioning and char spaceing - sub.c
atlka
parents: 1524
diff changeset
74 int width=(2*dxs-3*delimw)/3;
1549
787c053b314c minor changes in sub.c
atlka
parents: 1548
diff changeset
75 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
76 int elems=width/charw;
1549
787c053b314c minor changes in sub.c
atlka
parents: 1548
diff changeset
77 int x=(dxs-elems*charw-delimw)/2;
1548
eee7951a23af changes according to proper subfont bar positioning and char spaceing - sub.c
atlka
parents: 1524
diff changeset
78
1726
38871427a131 corrections to OSD progbar position calculations
atlka
parents: 1602
diff changeset
79 if (vo_osd_progbar_value<=0)
38871427a131 corrections to OSD progbar position calculations
atlka
parents: 1602
diff changeset
80 mark=0;
1878
96ae64356ea0 corrections to OSD mark position
atlka
parents: 1852
diff changeset
81 else {
96ae64356ea0 corrections to OSD mark position
atlka
parents: 1852
diff changeset
82 int ev=vo_osd_progbar_value*elems;
96ae64356ea0 corrections to OSD mark position
atlka
parents: 1852
diff changeset
83 mark=ev>>8;
96ae64356ea0 corrections to OSD mark position
atlka
parents: 1852
diff changeset
84 if (ev & 0xFF) mark++;
96ae64356ea0 corrections to OSD mark position
atlka
parents: 1852
diff changeset
85 if (mark>elems) mark=elems;
96ae64356ea0 corrections to OSD mark position
atlka
parents: 1852
diff changeset
86 }
96ae64356ea0 corrections to OSD mark position
atlka
parents: 1852
diff changeset
87
1727
9da2b587b029 changes according to OSD calculations
atlka
parents: 1726
diff changeset
88
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
89 // printf("osd.progbar width=%d xpos=%d\n",width,x);
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
90
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
91 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
92 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
93 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
94 draw_alpha((xp<0?0:xp),y,
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
95 vo_font->width[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
96 vo_font->pic_a[font]->h,
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
97 vo_font->pic_b[font]->bmp+vo_font->start[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
98 vo_font->pic_a[font]->bmp+vo_font->start[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
99 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
100 }
fcbfc99cf8e6 skip lines with negative y position if there is too many lines to display
atlka
parents: 1549
diff changeset
101
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
102 c=OSD_PB_START;
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
103 if ((font=vo_font->font[c])>=0)
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
104 draw_alpha(x,y,
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
105 vo_font->width[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
106 vo_font->pic_a[font]->h,
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
107 vo_font->pic_b[font]->bmp+vo_font->start[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
108 vo_font->pic_a[font]->bmp+vo_font->start[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
109 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
110 x+=vo_font->width[c]+vo_font->charspace;
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
111
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
112 c=OSD_PB_0;
1602
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
113 if ((font=vo_font->font[c])>=0){
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
114 w=vo_font->width[c];
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
115 h=vo_font->pic_a[font]->h;
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
116 s=vo_font->pic_b[font]->bmp+vo_font->start[c];
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
117 sa=vo_font->pic_a[font]->bmp+vo_font->start[c];
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
118 st=vo_font->pic_a[font]->w;
2204
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
119 if ((i=mark)) do {
1602
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
120 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
121 x+=charw;
2204
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
122 } while(--i);
1602
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
123 }
202
6ad0715dfac8 grey+alpha rendering support (for .sub)
arpi_esp
parents:
diff changeset
124
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
125 c=OSD_PB_1;
1602
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
126 if ((font=vo_font->font[c])>=0){
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
127 w=vo_font->width[c];
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
128 h=vo_font->pic_a[font]->h;
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
129 s =vo_font->pic_b[font]->bmp+vo_font->start[c];
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
130 sa=vo_font->pic_a[font]->bmp+vo_font->start[c];
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
131 st=vo_font->pic_a[font]->w;
2204
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
132 if ((i=elems-mark)) do {
1602
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
133 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
134 x+=charw;
2204
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
135 } while(--i);
1602
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
136 }
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
137
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
138 c=OSD_PB_END;
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
139 if ((font=vo_font->font[c])>=0)
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
140 draw_alpha(x,y,
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
141 vo_font->width[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
142 vo_font->pic_a[font]->h,
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
143 vo_font->pic_b[font]->bmp+vo_font->start[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
144 vo_font->pic_a[font]->bmp+vo_font->start[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
145 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
146 // 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
147
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
148
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
149 // vo_osd_progbar_value=(vo_osd_progbar_value+1)&0xFF;
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
150
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
151 }
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
152
254
57f0156416e3 use subreader's sub struct
arpi_esp
parents: 218
diff changeset
153 subtitle* vo_sub=NULL;
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
154
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
155 #define MAX_UCS 1600
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
156 #define MAX_UCSLINES 16
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
157
1591
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
158
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
159 inline static void vo_draw_text_sub(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)){
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
160 static int utbl[MAX_UCS+1];
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
161 static int xtbl[MAX_UCSLINES];
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
162 static int lines;
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
163 static subtitle *memsub=NULL;
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
164 static int memy;
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
165 static int memdxs;
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
166 static int memdys;
1591
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
167
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
168 unsigned char *t;
1591
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
169 int c,i,j,l,x,y,font;
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
170 int len;
1591
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
171 int k,lastk;
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
172 int lastStripPosition;
1591
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
173 int xsize,lastxsize;
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
174 int h,lasth;
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
175
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
176 if ((memsub!=vo_sub)||(memdxs!=dxs)||(memdys!=dys)){
1591
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
177
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
178 memsub=vo_sub;
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
179 memdxs=dxs;
1591
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
180 memdys=memy=dys;
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
181
1602
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
182 // too long lines divide into a smaller ones
1591
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
183 i=k=lines=lasth=0;
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
184 h=vo_font->height;
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
185 xsize=-vo_font->charspace;
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
186 lastStripPosition=-1;
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
187 l=vo_sub->lines;
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
188
2204
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
189 while (l) {
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
190 l--;
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
191 t=vo_sub->text[i++];
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
192 len=strlen(t)-1;
1824
33035a1d897e small fixes, and Y check put back to avoid sig11
arpi
parents: 1822
diff changeset
193
1852
58dd326fcc4a fix xshape, mixer, fullscreen, etc
pontscho
parents: 1824
diff changeset
194 // printf("sub(%d) '%s'\n",len,t);
1824
33035a1d897e small fixes, and Y check put back to avoid sig11
arpi
parents: 1822
diff changeset
195 // 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
196 // else
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
197 for (j=0;j<=len;j++){
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
198 if ((c=t[j])>=0x80){
2176
1ae16a34f055 speed improvements
atlka
parents: 1991
diff changeset
199 if (sub_utf8){
1ae16a34f055 speed improvements
atlka
parents: 1991
diff changeset
200 if ((c & 0xe0) == 0xc0) /* 2 bytes U+00080..U+0007FF*/
1ae16a34f055 speed improvements
atlka
parents: 1991
diff changeset
201 c = (c & 0x1f)<<6 | (t[++j] & 0x3f);
1ae16a34f055 speed improvements
atlka
parents: 1991
diff changeset
202 else if((c & 0xf0) == 0xe0)/* 3 bytes U+00800..U+00FFFF*/
1ae16a34f055 speed improvements
atlka
parents: 1991
diff changeset
203 c = ((c & 0x0f)<<6 |
1ae16a34f055 speed improvements
atlka
parents: 1991
diff changeset
204 (t[++j] & 0x3f))<<6 | (t[++j] & 0x3f);
1ae16a34f055 speed improvements
atlka
parents: 1991
diff changeset
205 } else if (sub_unicode)
1ae16a34f055 speed improvements
atlka
parents: 1991
diff changeset
206 c = (c<<8) + t[++j];
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
207 }
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
208 if (k==MAX_UCS){
2204
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
209 len=j; // end here
2205
b6cd2fea7385 corrected previous error ;-(
atlka
parents: 2204
diff changeset
210 printf ("\nMAX_UCS exceeded!\n");
1591
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
211 }
2204
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
212 if (!c) c++; // avoid UCS 0
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
213 if (c==' '){
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
214 lastk=k;
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
215 lastStripPosition=j;
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
216 lastxsize=xsize;
2204
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
217 } else if ((font=vo_font->font[c])>=0){
1591
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
218 if (vo_font->pic_a[font]->h > h){
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
219 h=vo_font->pic_a[font]->h;
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
220 }
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
221 }
2204
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
222 utbl[k++]=c;
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
223 xsize+=vo_font->width[c]+vo_font->charspace;
1591
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
224 if (dxs<xsize){
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
225 if (lastStripPosition>0){
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
226 j=lastStripPosition;
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
227 xsize=lastxsize;
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
228 k=lastk;
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
229 } else {
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
230 xsize -=vo_font->width[c]+vo_font->charspace; // go back
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
231 k--; // cut line here
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
232 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
233 }
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
234 } else if (j<len)
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
235 continue;
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
236 if (h>memy){ // out of the screen so end parsing
2205
b6cd2fea7385 corrected previous error ;-(
atlka
parents: 2204
diff changeset
237 memy -= lasth - vo_font->height; // correct the y position
2204
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
238 l=0;
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
239 break;
1591
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
240 }
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
241 utbl[k++]=0;
1591
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
242 xtbl[lines++]=(dxs-xsize)/2;
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
243 if (lines==MAX_UCSLINES||k>MAX_UCS){
2204
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
244 l=0; len=j; // end parsing
1602
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
245 } 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
246 lastStripPosition=-1;
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
247 xsize=-vo_font->charspace;
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
248 lasth=h;
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
249 h=vo_font->height;
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
250 }
2176
1ae16a34f055 speed improvements
atlka
parents: 1991
diff changeset
251 // printf("h: %d -> %d \n",vo_font->height,h);
1591
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
252 memy -=h; // according to max of vo_font->pic_a[font]->h
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
253 }
1573
c394d04d6b30 changes according to max of vo_font->pic_a[font]->h for the last line of subs
atlka
parents: 1569
diff changeset
254 }
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
255 }
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
256
4773
976bf6a9ded5 subtitle positioning patch by Jiri Svoboda
atmos4
parents: 4088
diff changeset
257 if (memy < (dys * sub_pos / 100)) { y = memy; } else { y = dys * sub_pos /100;};
1824
33035a1d897e small fixes, and Y check put back to avoid sig11
arpi
parents: 1822
diff changeset
258
33035a1d897e small fixes, and Y check put back to avoid sig11
arpi
parents: 1822
diff changeset
259 // printf("lines=%d y=%d\n",lines,y);
202
6ad0715dfac8 grey+alpha rendering support (for .sub)
arpi_esp
parents:
diff changeset
260
2204
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
261 i=j=0;
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
262 if ((l=lines)) for (;;) {
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
263 x=xtbl[i++];
1591
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
264 while ((c=utbl[j++])){
2176
1ae16a34f055 speed improvements
atlka
parents: 1991
diff changeset
265 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
266 draw_alpha(x,y,
fcbfc99cf8e6 skip lines with negative y position if there is too many lines to display
atlka
parents: 1549
diff changeset
267 vo_font->width[c],
1824
33035a1d897e small fixes, and Y check put back to avoid sig11
arpi
parents: 1822
diff changeset
268 vo_font->pic_a[font]->h+y<dys ? vo_font->pic_a[font]->h : dys-y,
1569
fcbfc99cf8e6 skip lines with negative y position if there is too many lines to display
atlka
parents: 1549
diff changeset
269 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
270 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
271 vo_font->pic_a[font]->w);
2204
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
272 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
273 }
2204
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
274 if (!--l)
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
275 return;
1591
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
276 y+=vo_font->height;
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
277 }
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
278 }
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
279
3034
24d3dca4e813 DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents: 2498
diff changeset
280 void *vo_spudec=NULL;
4081
9e581ab5e54b Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents: 3180
diff changeset
281 void *vo_vobsub=NULL;
3034
24d3dca4e813 DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents: 2498
diff changeset
282 inline static void vo_draw_spudec(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)){
4087
07d831705ec6 Support software scaling with DVD subtitles
kmkaplan
parents: 4081
diff changeset
283 spudec_draw_scaled(vo_spudec, dxs, dys, draw_alpha);
3034
24d3dca4e813 DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents: 2498
diff changeset
284 }
4081
9e581ab5e54b Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents: 3180
diff changeset
285 inline static void vo_draw_vobsub(int dxs,int dys,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)){
9e581ab5e54b Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents: 3180
diff changeset
286 vobsub_draw(vo_vobsub, dxs, dys, draw_alpha);
9e581ab5e54b Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents: 3180
diff changeset
287 }
3034
24d3dca4e813 DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents: 2498
diff changeset
288
947
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 865
diff changeset
289 static int draw_alpha_init_flag=0;
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
290
1109
a013b2124f05 -Wall like fixes
al3x
parents: 947
diff changeset
291 extern void vo_draw_alpha_init();
a013b2124f05 -Wall like fixes
al3x
parents: 947
diff changeset
292
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
293 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)){
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
294
4081
9e581ab5e54b Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents: 3180
diff changeset
295 if(vo_spudec){
9e581ab5e54b Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents: 3180
diff changeset
296 vo_draw_spudec(dxs,dys,draw_alpha);
9e581ab5e54b Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents: 3180
diff changeset
297 }
9e581ab5e54b Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents: 3180
diff changeset
298
9e581ab5e54b Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents: 3180
diff changeset
299 if(vo_vobsub){
9e581ab5e54b Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents: 3180
diff changeset
300 vo_draw_vobsub(dxs,dys,draw_alpha);
9e581ab5e54b Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents: 3180
diff changeset
301 }
9e581ab5e54b Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents: 3180
diff changeset
302
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
303 if(!vo_font) return; // no font
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
304
947
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 865
diff changeset
305 if(!draw_alpha_init_flag){
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 865
diff changeset
306 draw_alpha_init_flag=1;
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 865
diff changeset
307 vo_draw_alpha_init();
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 865
diff changeset
308 }
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 865
diff changeset
309
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
310 if(vo_osd_text){
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
311 vo_draw_text_osd(dxs,dys,draw_alpha);
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
312 }
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
313
254
57f0156416e3 use subreader's sub struct
arpi_esp
parents: 218
diff changeset
314 if(vo_sub){
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
315 vo_draw_text_sub(dxs,dys,draw_alpha);
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
316 }
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
317
1822
85dda3b18445 fixed signal 8 bug
arpi
parents: 1727
diff changeset
318 if(vo_osd_progbar_type>=0 && vo_font->font[OSD_PB_0]>=0){
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
319 vo_draw_text_progbar(dxs,dys,draw_alpha);
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
320 }
3034
24d3dca4e813 DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents: 2498
diff changeset
321
202
6ad0715dfac8 grey+alpha rendering support (for .sub)
arpi_esp
parents:
diff changeset
322 }
1726
38871427a131 corrections to OSD progbar position calculations
atlka
parents: 1602
diff changeset
323
4807
156482788caf osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents: 4773
diff changeset
324 static int vo_osd_changed_status = 0;
156482788caf osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents: 4773
diff changeset
325
156482788caf osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents: 4773
diff changeset
326 int vo_osd_changed(int new_value)
156482788caf osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents: 4773
diff changeset
327 {
156482788caf osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents: 4773
diff changeset
328 int ret = vo_osd_changed_status;
156482788caf osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents: 4773
diff changeset
329 vo_osd_changed_status = new_value;
156482788caf osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents: 4773
diff changeset
330 return ret;
156482788caf osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents: 4773
diff changeset
331 }