annotate libvo/sub.c @ 8601:7fe391d6c293

The following patch adds two new command line options: -sub-bkg-color n -sub-bkg-alpha n They control the color and alpha value used to initialize the subtitles and OSD BBOX. With this you can have subtitles inside a traslucent rectangle. This is useful when a movie already have "hardcoded" subtitles and you want to overwrite them with rendered subtitles avoiding too much confusion. patch by Salvador Eduardo Tropea <salvador@inti.gov.ar>
author arpi
date Sat, 28 Dec 2002 13:41:02 +0000
parents 4c18c4e7f34e
children 6ffbe7608013
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>
7003
60a473935d7d warning fixes by Sylvain Petreolle <spetreolle@yahoo.fr>
arpi
parents: 6190
diff changeset
4 #include <string.h>
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
5
4088
4435dc3b8bef Add DVD subtitles to menoder
kmkaplan
parents: 4087
diff changeset
6 #include "config.h"
8123
9fc45fe0d444 *HUGE* set of compiler warning fixes, unused variables removal
arpi
parents: 7628
diff changeset
7 #ifdef HAVE_MALLOC_H
9fc45fe0d444 *HUGE* set of compiler warning fixes, unused variables removal
arpi
parents: 7628
diff changeset
8 #include <malloc.h>
9fc45fe0d444 *HUGE* set of compiler warning fixes, unused variables removal
arpi
parents: 7628
diff changeset
9 #endif
9fc45fe0d444 *HUGE* set of compiler warning fixes, unused variables removal
arpi
parents: 7628
diff changeset
10
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
11 #include "mp_msg.h"
4088
4435dc3b8bef Add DVD subtitles to menoder
kmkaplan
parents: 4087
diff changeset
12 #include "video_out.h"
5294
4e64fca268e9 moved font_laod.h
arpi
parents: 4807
diff changeset
13 #include "font_load.h"
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
14 #include "sub.h"
7003
60a473935d7d warning fixes by Sylvain Petreolle <spetreolle@yahoo.fr>
arpi
parents: 6190
diff changeset
15 #include "../spudec.h"
202
6ad0715dfac8 grey+alpha rendering support (for .sub)
arpi_esp
parents:
diff changeset
16
2498
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
17 char * __sub_osd_names[]={
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
18 "Seekbar",
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
19 "Play",
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
20 "Pause",
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
21 "Stop",
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
22 "Rewind",
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
23 "Forward",
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
24 "Clock",
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
25 "Contrast",
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
26 "Saturation",
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
27 "Volume",
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
28 "Brightness",
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
29 "Hue"
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
30 };
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
31 char * __sub_osd_names_short[] ={ "", "|>", "||", "[]", "<<" , ">>", "", "", "", "", "", ""};
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
32
213
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
33 //static int vo_font_loaded=-1;
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
34 font_desc_t* vo_font=NULL;
202
6ad0715dfac8 grey+alpha rendering support (for .sub)
arpi_esp
parents:
diff changeset
35
1991
dee4b2ea5e5b add gui support to config scripts, and fixed some warning.
pontscho
parents: 1878
diff changeset
36 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
37 int sub_unicode=0;
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
38 int sub_utf8=0;
4773
976bf6a9ded5 subtitle positioning patch by Jiri Svoboda
atmos4
parents: 4088
diff changeset
39 int sub_pos=100;
8583
4c18c4e7f34e -subwidth
arpi
parents: 8578
diff changeset
40 int sub_width_p=100;
8578
a9d454af3497 backward compatibility :)
arpi
parents: 8534
diff changeset
41 int sub_alignment=0; /* 0=top, 1=center, 2=bottom */
7628
d6608342591d This patch adds the functionality to disable/enable subtitles while playing
arpi
parents: 7121
diff changeset
42 int sub_visibility=1;
8601
7fe391d6c293 The following patch adds two new command line options:
arpi
parents: 8583
diff changeset
43 int sub_bkg_color=0; /* subtitles background color */
7fe391d6c293 The following patch adds two new command line options:
arpi
parents: 8583
diff changeset
44 int sub_bkg_alpha=0;
213
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
45
5664
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
46 // return the real height of a char:
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
47 static inline int get_height(int c,int h){
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
48 int font;
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
49 if ((font=vo_font->font[c])>=0)
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
50 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
51 return h;
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
52 }
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
53
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
54 // renders char to a big per-object buffer where alpha and bitmap are separated
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
55 static void draw_alpha_buf(mp_osd_obj_t* obj, int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
56 {
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
57 int dststride = obj->stride;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
58 int dstskip = obj->stride-w;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
59 int srcskip = stride-w;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
60 int i, j;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
61 unsigned char *b = obj->bitmap_buffer + (y0-obj->bbox.y1)*dststride + (x0-obj->bbox.x1);
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
62 unsigned char *a = obj->alpha_buffer + (y0-obj->bbox.y1)*dststride + (x0-obj->bbox.x1);
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
63 unsigned char *bs = src;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
64 unsigned char *as = srca;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
65
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
66 if (x0 < obj->bbox.x1 || x0+w > obj->bbox.x2 || y0 < obj->bbox.y1 || y0+h > obj->bbox.y2) {
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
67 fprintf(stderr, "osd text out of range: bbox [%d %d %d %d], txt [%d %d %d %d]\n",
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
68 obj->bbox.x1, obj->bbox.x2, obj->bbox.y1, obj->bbox.y2,
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
69 x0, x0+w, y0, y0+h);
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
70 return;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
71 }
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
72
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
73 for (i = 0; i < h; i++) {
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
74 for (j = 0; j < w; j++, b++, a++, bs++, as++) {
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
75 if (*b < *bs) *b = *bs;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
76 if (*as) {
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
77 if (*a == 0 || *a > *as) *a = *as;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
78 }
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
79 }
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
80 b+= dstskip;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
81 a+= dstskip;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
82 bs+= srcskip;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
83 as+= srcskip;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
84 }
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
85 }
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
86
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
87 // allocates/enlarges the alpha/bitmap buffer
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
88 static void alloc_buf(mp_osd_obj_t* obj)
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
89 {
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
90 int len;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
91 if (obj->bbox.x2 < obj->bbox.x1) obj->bbox.x2 = obj->bbox.x1;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
92 if (obj->bbox.y2 < obj->bbox.y1) obj->bbox.y2 = obj->bbox.y1;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
93 obj->stride = ((obj->bbox.x2-obj->bbox.x1)+7)&(~7);
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
94 len = obj->stride*(obj->bbox.y2-obj->bbox.y1);
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
95 if (obj->allocated<len) {
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
96 obj->allocated = len;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
97 free(obj->bitmap_buffer);
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
98 free(obj->alpha_buffer);
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
99 obj->bitmap_buffer = (unsigned char *)memalign(16, len);
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
100 obj->alpha_buffer = (unsigned char *)memalign(16, len);
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
101 }
8601
7fe391d6c293 The following patch adds two new command line options:
arpi
parents: 8583
diff changeset
102 memset(obj->bitmap_buffer, sub_bkg_color, len);
7fe391d6c293 The following patch adds two new command line options:
arpi
parents: 8583
diff changeset
103 memset(obj->alpha_buffer, sub_bkg_alpha, len);
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
104 }
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
105
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
106 // renders the buffer
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
107 inline static void vo_draw_text_from_buffer(mp_osd_obj_t* obj,void (*draw_alpha)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)){
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
108 if (obj->allocated > 0) {
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
109 draw_alpha(obj->bbox.x1,obj->bbox.y1,
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
110 obj->bbox.x2-obj->bbox.x1,
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
111 obj->bbox.y2-obj->bbox.y1,
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
112 obj->bitmap_buffer,
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
113 obj->alpha_buffer,
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
114 obj->stride);
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
115 }
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
116 }
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
117
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
118 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
119 unsigned char *cp=vo_osd_text;
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
120 int x=20;
5664
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
121 int h=0;
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
122 int font;
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
123
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
124 obj->bbox.x1=obj->x=x;
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
125 obj->bbox.y1=obj->y=10;
202
6ad0715dfac8 grey+alpha rendering support (for .sub)
arpi_esp
parents:
diff changeset
126
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
127 while (*cp){
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
128 int c=*cp++;
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
129 render_one_glyph(vo_font, c);
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
130 x+=vo_font->width[c]+vo_font->charspace;
5664
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
131 h=get_height(c,h);
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
132 }
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
133
5664
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
134 obj->bbox.x2=x-vo_font->charspace;
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
135 obj->bbox.y2=obj->bbox.y1+h;
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
136 obj->flags|=OSDFLAG_BBOX;
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
137
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
138 alloc_buf(obj);
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
139
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
140 cp=vo_osd_text;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
141 x = obj->x;
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
142 while (*cp){
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
143 int c=*cp++;
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
144 if ((font=vo_font->font[c])>=0)
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
145 draw_alpha_buf(obj,x,obj->y,
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
146 vo_font->width[c],
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
147 vo_font->pic_a[font]->h,
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
148 vo_font->pic_b[font]->bmp+vo_font->start[c],
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
149 vo_font->pic_a[font]->bmp+vo_font->start[c],
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
150 vo_font->pic_a[font]->w);
213
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
151 x+=vo_font->width[c]+vo_font->charspace;
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
152 }
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
153 }
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
154
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
155 int vo_osd_progbar_type=-1;
1726
38871427a131 corrections to OSD progbar position calculations
atlka
parents: 1602
diff changeset
156 int vo_osd_progbar_value=100; // 0..256
38871427a131 corrections to OSD progbar position calculations
atlka
parents: 1602
diff changeset
157
38871427a131 corrections to OSD progbar position calculations
atlka
parents: 1602
diff changeset
158 // if we have n=256 bars then OSD progbar looks like below
38871427a131 corrections to OSD progbar position calculations
atlka
parents: 1602
diff changeset
159 //
1878
96ae64356ea0 corrections to OSD mark position
atlka
parents: 1852
diff changeset
160 // 0 1 2 3 ... 256 <= vo_osd_progbar_value
96ae64356ea0 corrections to OSD mark position
atlka
parents: 1852
diff changeset
161 // | | | | |
1726
38871427a131 corrections to OSD progbar position calculations
atlka
parents: 1602
diff changeset
162 // [ === === === ... === ]
38871427a131 corrections to OSD progbar position calculations
atlka
parents: 1602
diff changeset
163 //
38871427a131 corrections to OSD progbar position calculations
atlka
parents: 1602
diff changeset
164 // the above schema is rescalled to n=elems bars
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
165
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
166 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
167
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
168 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
169
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
170 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
171 obj->flags&=~OSDFLAG_VISIBLE;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
172 return;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
173 }
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
174
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
175 render_one_glyph(vo_font, OSD_PB_START);
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
176 render_one_glyph(vo_font, OSD_PB_END);
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
177 render_one_glyph(vo_font, OSD_PB_0);
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
178 render_one_glyph(vo_font, OSD_PB_1);
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
179 render_one_glyph(vo_font, vo_osd_progbar_type);
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
180
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
181 // calculate bbox corners:
5664
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
182 { int h=0;
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
183 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
184 int delimw=vo_font->width[OSD_PB_START]
1549
787c053b314c minor changes in sub.c
atlka
parents: 1548
diff changeset
185 +vo_font->width[OSD_PB_END]
787c053b314c minor changes in sub.c
atlka
parents: 1548
diff changeset
186 +vo_font->charspace;
1548
eee7951a23af changes according to proper subfont bar positioning and char spaceing - sub.c
atlka
parents: 1524
diff changeset
187 int width=(2*dxs-3*delimw)/3;
1549
787c053b314c minor changes in sub.c
atlka
parents: 1548
diff changeset
188 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
189 int elems=width/charw;
1549
787c053b314c minor changes in sub.c
atlka
parents: 1548
diff changeset
190 int x=(dxs-elems*charw-delimw)/2;
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
191 int delta = 0;
5664
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
192 h=get_height(OSD_PB_START,h);
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
193 h=get_height(OSD_PB_END,h);
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
194 h=get_height(OSD_PB_0,h);
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
195 h=get_height(OSD_PB_1,h);
8422
1f1cc58e8e65 progbar osd buffer height adjustment fix
henry
parents: 8361
diff changeset
196 if (vo_osd_progbar_type>0 && vo_font->font[vo_osd_progbar_type]>=0){
1f1cc58e8e65 progbar osd buffer height adjustment fix
henry
parents: 8361
diff changeset
197 delta = vo_font->width[vo_osd_progbar_type]+vo_font->spacewidth;
1f1cc58e8e65 progbar osd buffer height adjustment fix
henry
parents: 8361
diff changeset
198 delta = (x-delta > 0) ? delta : x;
1f1cc58e8e65 progbar osd buffer height adjustment fix
henry
parents: 8361
diff changeset
199 h=get_height(vo_osd_progbar_type,h);
1f1cc58e8e65 progbar osd buffer height adjustment fix
henry
parents: 8361
diff changeset
200 }
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
201 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
202 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
203 obj->bbox.x2=x+width+delimw;
5664
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
204 obj->bbox.y2=y+h; //vo_font->height;
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
205 obj->flags|=OSDFLAG_BBOX;
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
206 obj->params.progbar.elems=elems;
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
207 obj->bbox.x1-=delta; // space for an icon
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
208 }
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
209
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
210 alloc_buf(obj);
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
211
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
212 // render it:
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
213 { unsigned char *s;
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
214 unsigned char *sa;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
215 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
216 int x=obj->x;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
217 int y=obj->y;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
218 int c,font;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
219 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
220 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
221
1726
38871427a131 corrections to OSD progbar position calculations
atlka
parents: 1602
diff changeset
222 if (vo_osd_progbar_value<=0)
38871427a131 corrections to OSD progbar position calculations
atlka
parents: 1602
diff changeset
223 mark=0;
1878
96ae64356ea0 corrections to OSD mark position
atlka
parents: 1852
diff changeset
224 else {
96ae64356ea0 corrections to OSD mark position
atlka
parents: 1852
diff changeset
225 int ev=vo_osd_progbar_value*elems;
96ae64356ea0 corrections to OSD mark position
atlka
parents: 1852
diff changeset
226 mark=ev>>8;
96ae64356ea0 corrections to OSD mark position
atlka
parents: 1852
diff changeset
227 if (ev & 0xFF) mark++;
96ae64356ea0 corrections to OSD mark position
atlka
parents: 1852
diff changeset
228 if (mark>elems) mark=elems;
96ae64356ea0 corrections to OSD mark position
atlka
parents: 1852
diff changeset
229 }
96ae64356ea0 corrections to OSD mark position
atlka
parents: 1852
diff changeset
230
1727
9da2b587b029 changes according to OSD calculations
atlka
parents: 1726
diff changeset
231
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
232 // printf("osd.progbar width=%d xpos=%d\n",width,x);
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
233
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
234 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
235 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
236 int xp=x-vo_font->width[c]-vo_font->spacewidth;
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
237 draw_alpha_buf(obj,(xp<0?0:xp),y,
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
238 vo_font->width[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
239 vo_font->pic_a[font]->h,
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
240 vo_font->pic_b[font]->bmp+vo_font->start[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
241 vo_font->pic_a[font]->bmp+vo_font->start[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
242 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
243 }
fcbfc99cf8e6 skip lines with negative y position if there is too many lines to display
atlka
parents: 1549
diff changeset
244
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
245 c=OSD_PB_START;
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
246 if ((font=vo_font->font[c])>=0)
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
247 draw_alpha_buf(obj,x,y,
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
248 vo_font->width[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
249 vo_font->pic_a[font]->h,
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
250 vo_font->pic_b[font]->bmp+vo_font->start[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
251 vo_font->pic_a[font]->bmp+vo_font->start[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
252 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
253 x+=vo_font->width[c]+vo_font->charspace;
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
254
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
255 c=OSD_PB_0;
1602
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
256 if ((font=vo_font->font[c])>=0){
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
257 w=vo_font->width[c];
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
258 h=vo_font->pic_a[font]->h;
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
259 s=vo_font->pic_b[font]->bmp+vo_font->start[c];
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
260 sa=vo_font->pic_a[font]->bmp+vo_font->start[c];
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
261 st=vo_font->pic_a[font]->w;
2204
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
262 if ((i=mark)) do {
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
263 draw_alpha_buf(obj,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
264 x+=charw;
2204
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
265 } while(--i);
1602
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
266 }
202
6ad0715dfac8 grey+alpha rendering support (for .sub)
arpi_esp
parents:
diff changeset
267
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
268 c=OSD_PB_1;
1602
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
269 if ((font=vo_font->font[c])>=0){
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
270 w=vo_font->width[c];
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
271 h=vo_font->pic_a[font]->h;
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
272 s =vo_font->pic_b[font]->bmp+vo_font->start[c];
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
273 sa=vo_font->pic_a[font]->bmp+vo_font->start[c];
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
274 st=vo_font->pic_a[font]->w;
2204
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
275 if ((i=elems-mark)) do {
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
276 draw_alpha_buf(obj,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
277 x+=charw;
2204
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
278 } while(--i);
1602
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
279 }
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
280
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
281 c=OSD_PB_END;
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
282 if ((font=vo_font->font[c])>=0)
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
283 draw_alpha_buf(obj,x,y,
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
284 vo_font->width[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
285 vo_font->pic_a[font]->h,
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
286 vo_font->pic_b[font]->bmp+vo_font->start[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
287 vo_font->pic_a[font]->bmp+vo_font->start[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
288 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
289 // 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
290
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
291 }
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
292 // vo_osd_progbar_value=(vo_osd_progbar_value+1)&0xFF;
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
293
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
294 }
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
295
254
57f0156416e3 use subreader's sub struct
arpi_esp
parents: 218
diff changeset
296 subtitle* vo_sub=NULL;
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
297
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
298 // 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
299
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
300 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
301 unsigned char *t;
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
302 int c,i,j,l,x,y,font,prevc;
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
303 int len;
1591
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
304 int k,lastk;
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
305 int lastStripPosition;
1591
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
306 int xsize,lastxsize;
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
307 int xmin=dxs,xmax=0;
1591
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
308 int h,lasth;
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
309
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
310 obj->flags|=OSDFLAG_CHANGED|OSDFLAG_VISIBLE;
7628
d6608342591d This patch adds the functionality to disable/enable subtitles while playing
arpi
parents: 7121
diff changeset
311
d6608342591d This patch adds the functionality to disable/enable subtitles while playing
arpi
parents: 7121
diff changeset
312 if(!vo_sub || !vo_font || !sub_visibility){
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
313 obj->flags&=~OSDFLAG_VISIBLE;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
314 return;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
315 }
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
316
5664
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
317 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
318 obj->params.subtitle.lines=0;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
319
1602
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
320 // 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
321 i=k=lasth=0;
1591
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
322 h=vo_font->height;
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
323 xsize=-vo_font->charspace;
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
324 lastStripPosition=-1;
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
325 l=vo_sub->lines;
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
326
2204
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
327 while (l) {
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
328 l--;
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
329 t=vo_sub->text[i++];
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
330 len=strlen(t)-1;
1824
33035a1d897e small fixes, and Y check put back to avoid sig11
arpi
parents: 1822
diff changeset
331
1852
58dd326fcc4a fix xshape, mixer, fullscreen, etc
pontscho
parents: 1824
diff changeset
332 // printf("sub(%d) '%s'\n",len,t);
1824
33035a1d897e small fixes, and Y check put back to avoid sig11
arpi
parents: 1822
diff changeset
333 // 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
334 // else
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
335
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
336 prevc = -1;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
337
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
338 for (j=0;j<=len;j++){
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
339 if ((c=t[j])>=0x80){
2176
1ae16a34f055 speed improvements
atlka
parents: 1991
diff changeset
340 if (sub_utf8){
1ae16a34f055 speed improvements
atlka
parents: 1991
diff changeset
341 if ((c & 0xe0) == 0xc0) /* 2 bytes U+00080..U+0007FF*/
1ae16a34f055 speed improvements
atlka
parents: 1991
diff changeset
342 c = (c & 0x1f)<<6 | (t[++j] & 0x3f);
8451
fb88ccbc5ccc compiler warning fixes
arpi
parents: 8422
diff changeset
343 else if((c & 0xf0) == 0xe0){ /* 3 bytes U+00800..U+00FFFF*/
fb88ccbc5ccc compiler warning fixes
arpi
parents: 8422
diff changeset
344 c = (((c & 0x0f)<<6) | (t[++j] & 0x3f))<<6;
fb88ccbc5ccc compiler warning fixes
arpi
parents: 8422
diff changeset
345 c |= (t[++j] & 0x3f);
fb88ccbc5ccc compiler warning fixes
arpi
parents: 8422
diff changeset
346 }
2176
1ae16a34f055 speed improvements
atlka
parents: 1991
diff changeset
347 } else if (sub_unicode)
1ae16a34f055 speed improvements
atlka
parents: 1991
diff changeset
348 c = (c<<8) + t[++j];
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
349 }
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
350 if (k==MAX_UCS){
2204
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
351 len=j; // end here
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
352 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
353 }
2204
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
354 if (!c) c++; // avoid UCS 0
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
355 render_one_glyph(vo_font, c);
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
356 if (c==' '){
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
357 lastk=k;
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
358 lastStripPosition=j;
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
359 lastxsize=xsize;
8361
2202c00001e3 overlapping subtitles support is now optional, can be disabled (-nooverlapsub)
arpi
parents: 8123
diff changeset
360 } else if ((!suboverlap_enabled) && ((font = vo_font->font[c]) >= 0)) {
2202c00001e3 overlapping subtitles support is now optional, can be disabled (-nooverlapsub)
arpi
parents: 8123
diff changeset
361 /*
2202c00001e3 overlapping subtitles support is now optional, can be disabled (-nooverlapsub)
arpi
parents: 8123
diff changeset
362 With overlapping subtitles, we need to comment this out,
2202c00001e3 overlapping subtitles support is now optional, can be disabled (-nooverlapsub)
arpi
parents: 8123
diff changeset
363 beacuse that part of the code creates subtitles with the
2202c00001e3 overlapping subtitles support is now optional, can be disabled (-nooverlapsub)
arpi
parents: 8123
diff changeset
364 last line blank (" "): in this case previous 'if' statement
2202c00001e3 overlapping subtitles support is now optional, can be disabled (-nooverlapsub)
arpi
parents: 8123
diff changeset
365 is false an following 'if' is not executed. When, instead,
2202c00001e3 overlapping subtitles support is now optional, can be disabled (-nooverlapsub)
arpi
parents: 8123
diff changeset
366 a subtitle with a non-blank last line arrives, the following
2202c00001e3 overlapping subtitles support is now optional, can be disabled (-nooverlapsub)
arpi
parents: 8123
diff changeset
367 code is executed, and the result is a small 'jump' of the
2202c00001e3 overlapping subtitles support is now optional, can be disabled (-nooverlapsub)
arpi
parents: 8123
diff changeset
368 subtiles. We can not simply delete the following, unless
2202c00001e3 overlapping subtitles support is now optional, can be disabled (-nooverlapsub)
arpi
parents: 8123
diff changeset
369 having the last subtitle line partly drawn outside the
2202c00001e3 overlapping subtitles support is now optional, can be disabled (-nooverlapsub)
arpi
parents: 8123
diff changeset
370 screen, so, some lines forward, we introduce an increment
2202c00001e3 overlapping subtitles support is now optional, can be disabled (-nooverlapsub)
arpi
parents: 8123
diff changeset
371 which affects both blank and non-blank lines.
2202c00001e3 overlapping subtitles support is now optional, can be disabled (-nooverlapsub)
arpi
parents: 8123
diff changeset
372 *sfalco*
2202c00001e3 overlapping subtitles support is now optional, can be disabled (-nooverlapsub)
arpi
parents: 8123
diff changeset
373 */
1591
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
374 if (vo_font->pic_a[font]->h > h){
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
375 h=vo_font->pic_a[font]->h;
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
376 }
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
377 }
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
378 obj->params.subtitle.utbl[k++]=c;
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
379 xsize+=vo_font->width[c]+vo_font->charspace+kerning(vo_font,prevc,c);
8583
4c18c4e7f34e -subwidth
arpi
parents: 8578
diff changeset
380 if (dxs*sub_width_p/100<xsize){
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
381 prevc = -1;
1591
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
382 if (lastStripPosition>0){
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
383 j=lastStripPosition;
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
384 xsize=lastxsize;
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
385 k=lastk;
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
386 } else {
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
387 xsize -=vo_font->width[c]+vo_font->charspace+kerning(vo_font,prevc,c);; // go back
1591
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
388 k--; // cut line here
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
389 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
390 }
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
391 } else if (j<len) {
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
392 prevc = c;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
393 continue;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
394 }
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
395 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
396 obj->y -= lasth - vo_font->height; // correct the y position
2204
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
397 l=0;
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
398 break;
1591
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
399 }
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
400 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
401 obj->params.subtitle.xtbl[obj->params.subtitle.lines++]=(dxs-xsize)/2;
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
402 if(xmin>(dxs-xsize)/2) xmin=(dxs-xsize)/2;
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
403 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
404 if (obj->params.subtitle.lines==MAX_UCSLINES||k>MAX_UCS){
2204
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
405 l=0; len=j; // end parsing
1602
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
406 } 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
407 lastStripPosition=-1;
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
408 xsize=-vo_font->charspace;
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
409 lasth=h;
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
410 h=vo_font->height;
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
411 }
2176
1ae16a34f055 speed improvements
atlka
parents: 1991
diff changeset
412 // 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
413 obj->y -=h; // according to max of vo_font->pic_a[font]->h
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
414 prevc = -1;
1591
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
415 }
1573
c394d04d6b30 changes according to max of vo_font->pic_a[font]->h for the last line of subs
atlka
parents: 1569
diff changeset
416 }
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
417
8361
2202c00001e3 overlapping subtitles support is now optional, can be disabled (-nooverlapsub)
arpi
parents: 8123
diff changeset
418 /*
2202c00001e3 overlapping subtitles support is now optional, can be disabled (-nooverlapsub)
arpi
parents: 8123
diff changeset
419 Here is the little increment we talked about before. '40' is the
2202c00001e3 overlapping subtitles support is now optional, can be disabled (-nooverlapsub)
arpi
parents: 8123
diff changeset
420 ASCII code for '(', which, hopefully, is the highest char of the
2202c00001e3 overlapping subtitles support is now optional, can be disabled (-nooverlapsub)
arpi
parents: 8123
diff changeset
421 font.
2202c00001e3 overlapping subtitles support is now optional, can be disabled (-nooverlapsub)
arpi
parents: 8123
diff changeset
422 *sfalco*
2202c00001e3 overlapping subtitles support is now optional, can be disabled (-nooverlapsub)
arpi
parents: 8123
diff changeset
423 */
2202c00001e3 overlapping subtitles support is now optional, can be disabled (-nooverlapsub)
arpi
parents: 8123
diff changeset
424 if(suboverlap_enabled) obj->y -= vo_font->pic_a[vo_font->font[40]]->h - vo_font->height;
8534
922ce27eb683 This patch adds support for vertical subtitle alignment
arpi
parents: 8451
diff changeset
425
922ce27eb683 This patch adds support for vertical subtitle alignment
arpi
parents: 8451
diff changeset
426 h = dys - obj->y;
922ce27eb683 This patch adds support for vertical subtitle alignment
arpi
parents: 8451
diff changeset
427 if (sub_alignment == 2)
922ce27eb683 This patch adds support for vertical subtitle alignment
arpi
parents: 8451
diff changeset
428 obj->y = dys * sub_pos / 100 - h;
922ce27eb683 This patch adds support for vertical subtitle alignment
arpi
parents: 8451
diff changeset
429 else if (sub_alignment == 1)
922ce27eb683 This patch adds support for vertical subtitle alignment
arpi
parents: 8451
diff changeset
430 obj->y = dys * sub_pos / 100 - h / 2;
922ce27eb683 This patch adds support for vertical subtitle alignment
arpi
parents: 8451
diff changeset
431 else
922ce27eb683 This patch adds support for vertical subtitle alignment
arpi
parents: 8451
diff changeset
432 obj->y = dys * sub_pos / 100;
922ce27eb683 This patch adds support for vertical subtitle alignment
arpi
parents: 8451
diff changeset
433
922ce27eb683 This patch adds support for vertical subtitle alignment
arpi
parents: 8451
diff changeset
434 if (obj->y < 0)
922ce27eb683 This patch adds support for vertical subtitle alignment
arpi
parents: 8451
diff changeset
435 obj->y = 0;
922ce27eb683 This patch adds support for vertical subtitle alignment
arpi
parents: 8451
diff changeset
436 if (obj->y > dys - h)
922ce27eb683 This patch adds support for vertical subtitle alignment
arpi
parents: 8451
diff changeset
437 obj->y = dys - h;
922ce27eb683 This patch adds support for vertical subtitle alignment
arpi
parents: 8451
diff changeset
438
922ce27eb683 This patch adds support for vertical subtitle alignment
arpi
parents: 8451
diff changeset
439 obj->bbox.y2 = obj->y + h;
922ce27eb683 This patch adds support for vertical subtitle alignment
arpi
parents: 8451
diff changeset
440
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
441 // calculate bbox:
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
442 obj->bbox.x1=xmin;
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
443 obj->bbox.x2=xmax;
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
444 obj->bbox.y1=obj->y;
5664
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
445 // obj->bbox.y2=obj->y+obj->params.subtitle.lines*vo_font->height;
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
446 obj->flags|=OSDFLAG_BBOX;
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
447
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
448 alloc_buf(obj);
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
449
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
450 y = obj->y;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
451
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
452 i=j=0;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
453 if ((l=obj->params.subtitle.lines)) for (;;) {
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
454 x=obj->params.subtitle.xtbl[i++];
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
455 prevc = -1;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
456 while ((c=obj->params.subtitle.utbl[j++])){
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
457 x += kerning(vo_font,prevc,c);
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
458 if ((font=vo_font->font[c])>=0)
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
459 draw_alpha_buf(obj,x,y,
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
460 vo_font->width[c],
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
461 vo_font->pic_a[font]->h+y<obj->dys ? vo_font->pic_a[font]->h : obj->dys-y,
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
462 vo_font->pic_b[font]->bmp+vo_font->start[c],
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
463 vo_font->pic_a[font]->bmp+vo_font->start[c],
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
464 vo_font->pic_a[font]->w);
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
465 x+=vo_font->width[c]+vo_font->charspace;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
466 prevc = c;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
467 }
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
468 if (!--l) break;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
469 y+=vo_font->height;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
470 }
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
471
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
472 }
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
473
6190
bd6748605681 Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents: 6110
diff changeset
474 inline static void vo_update_spudec_sub(mp_osd_obj_t* obj, int dxs, int dys)
bd6748605681 Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents: 6110
diff changeset
475 {
bd6748605681 Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents: 6110
diff changeset
476 unsigned int bbox[4];
bd6748605681 Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents: 6110
diff changeset
477 spudec_calc_bbox(vo_spudec, dxs, dys, bbox);
bd6748605681 Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents: 6110
diff changeset
478 obj->bbox.x1 = bbox[0];
bd6748605681 Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents: 6110
diff changeset
479 obj->bbox.x2 = bbox[1];
bd6748605681 Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents: 6110
diff changeset
480 obj->bbox.y1 = bbox[2];
bd6748605681 Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents: 6110
diff changeset
481 obj->bbox.y2 = bbox[3];
bd6748605681 Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents: 6110
diff changeset
482 obj->flags |= OSDFLAG_BBOX;
bd6748605681 Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents: 6110
diff changeset
483 }
bd6748605681 Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents: 6110
diff changeset
484
bd6748605681 Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents: 6110
diff changeset
485 inline static void vo_draw_spudec_sub(mp_osd_obj_t* obj, void (*draw_alpha)(int x0, int y0, int w, int h, unsigned char* src, unsigned char* srca, int stride))
bd6748605681 Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents: 6110
diff changeset
486 {
bd6748605681 Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents: 6110
diff changeset
487 spudec_draw_scaled(vo_spudec, obj->dxs, obj->dys, draw_alpha);
bd6748605681 Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents: 6110
diff changeset
488 }
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
489
3034
24d3dca4e813 DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents: 2498
diff changeset
490 void *vo_spudec=NULL;
4081
9e581ab5e54b Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents: 3180
diff changeset
491 void *vo_vobsub=NULL;
3034
24d3dca4e813 DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents: 2498
diff changeset
492
947
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 865
diff changeset
493 static int draw_alpha_init_flag=0;
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
494
1109
a013b2124f05 -Wall like fixes
al3x
parents: 947
diff changeset
495 extern void vo_draw_alpha_init();
a013b2124f05 -Wall like fixes
al3x
parents: 947
diff changeset
496
7067
b395b1240954 fix dxr3 subtitle handling and add some optimizations
pontscho
parents: 7003
diff changeset
497 mp_osd_obj_t* vo_osd_list=NULL;
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
498
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
499 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
500 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
501 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
502 osd->next=vo_osd_list;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
503 vo_osd_list=osd;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
504 osd->type=type;
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
505 osd->alpha_buffer = NULL;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
506 osd->bitmap_buffer = NULL;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
507 osd->allocated = -1;
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
508 return osd;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
509 }
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
510
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
511 void free_osd_list(){
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
512 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
513 while(obj){
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
514 mp_osd_obj_t* next=obj->next;
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
515 if (obj->alpha_buffer) free(obj->alpha_buffer);
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
516 if (obj->bitmap_buffer) free(obj->bitmap_buffer);
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
517 free(obj);
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
518 obj=next;
4081
9e581ab5e54b Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents: 3180
diff changeset
519 }
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
520 vo_osd_list=NULL;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
521 }
4081
9e581ab5e54b Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents: 3180
diff changeset
522
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
523 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
524 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
525 int chg=0;
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
526
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
527 #ifdef HAVE_FREETYPE
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
528 // here is the right place to get screen dimensions
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
529 if (force_load_font) {
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
530 force_load_font = 0;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
531 load_font(dxs, dys);
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
532 }
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
533 #endif
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
534
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
535 while(obj){
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
536 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
537 int vis=obj->flags&OSDFLAG_VISIBLE;
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
538 obj->flags&=~OSDFLAG_BBOX;
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
539 switch(obj->type){
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
540 case OSDTYPE_SUBTITLE:
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
541 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
542 break;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
543 case OSDTYPE_PROGBAR:
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
544 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
545 break;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
546 case OSDTYPE_SPU:
7628
d6608342591d This patch adds the functionality to disable/enable subtitles while playing
arpi
parents: 7121
diff changeset
547 if(sub_visibility && vo_spudec && spudec_visible(vo_spudec)){
6190
bd6748605681 Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents: 6110
diff changeset
548 vo_update_spudec_sub(obj, dxs, dys);
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
549 obj->flags|=OSDFLAG_VISIBLE|OSDFLAG_CHANGED;
6190
bd6748605681 Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents: 6110
diff changeset
550 }
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
551 else
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
552 obj->flags&=~OSDFLAG_VISIBLE;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
553 break;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
554 case OSDTYPE_OSD:
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
555 if(vo_font && vo_osd_text && vo_osd_text[0]){
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
556 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
557 obj->flags|=OSDFLAG_VISIBLE|OSDFLAG_CHANGED;
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
558 } else
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
559 obj->flags&=~OSDFLAG_VISIBLE;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
560 break;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
561 }
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
562 // check bbox:
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
563 if(!(obj->flags&OSDFLAG_BBOX)){
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
564 // we don't know, so assume the whole screen changed :(
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
565 obj->bbox.x1=obj->bbox.y1=0;
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
566 obj->bbox.x2=dxs;
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
567 obj->bbox.y2=dys;
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
568 obj->flags|=OSDFLAG_BBOX;
5664
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
569 } else {
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
570 // check bbox, reduce it if it's out of bounds (corners):
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
571 if(obj->bbox.x1<0) obj->bbox.x1=0;
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
572 if(obj->bbox.y1<0) obj->bbox.y1=0;
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
573 if(obj->bbox.x2>dxs) obj->bbox.x2=dxs;
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
574 if(obj->bbox.y2>dys) obj->bbox.y2=dys;
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
575 if(obj->flags&OSDFLAG_VISIBLE)
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
576 // debug:
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
577 mp_msg(MSGT_OSD,MSGL_DBG2,"OSD update: %d;%d %dx%d \n",
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
578 obj->bbox.x1,obj->bbox.y1,obj->bbox.x2-obj->bbox.x1,
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
579 obj->bbox.y2-obj->bbox.y1);
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
580 }
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
581 // check if visibility changed:
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
582 if(vis != (obj->flags&OSDFLAG_VISIBLE) ) obj->flags|=OSDFLAG_CHANGED;
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
583 // 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
584 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
585 obj->flags&=~OSDFLAG_FORCE_UPDATE;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
586 }
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
587 if(obj->flags&OSDFLAG_CHANGED){
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
588 chg|=1<<obj->type;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
589 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
590 }
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
591 obj=obj->next;
4081
9e581ab5e54b Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents: 3180
diff changeset
592 }
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
593 return chg;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
594 }
4081
9e581ab5e54b Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents: 3180
diff changeset
595
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
596 void vo_init_osd(){
947
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 865
diff changeset
597 if(!draw_alpha_init_flag){
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 865
diff changeset
598 draw_alpha_init_flag=1;
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 865
diff changeset
599 vo_draw_alpha_init();
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 865
diff changeset
600 }
6110
7bea806b9c5f Improvment for spu subtitles.
albeu
parents: 5664
diff changeset
601 if(vo_osd_list) free_osd_list();
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
602 // 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
603 new_osd_obj(OSDTYPE_OSD);
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
604 new_osd_obj(OSDTYPE_SUBTITLE);
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
605 new_osd_obj(OSDTYPE_PROGBAR);
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
606 new_osd_obj(OSDTYPE_SPU);
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
607 #ifdef HAVE_FREETYPE
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
608 force_load_font = 1;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
609 #endif
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
610 }
947
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 865
diff changeset
611
5642
eb0cb6185e6c osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents: 5640
diff changeset
612 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
613
eb0cb6185e6c osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents: 5640
diff changeset
614 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
615 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
616 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
617 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
618 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
619 (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
620 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
621 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
622 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
623 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
624 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
625 }
eb0cb6185e6c osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents: 5640
diff changeset
626 // 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
627 }
5645
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
628 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
629 }
eb0cb6185e6c osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents: 5640
diff changeset
630 }
eb0cb6185e6c osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents: 5640
diff changeset
631
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
632 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
633 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
634 vo_update_osd(dxs,dys);
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
635 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
636 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
637 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
638 switch(obj->type){
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
639 case OSDTYPE_SPU:
6190
bd6748605681 Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents: 6110
diff changeset
640 vo_draw_spudec_sub(obj, draw_alpha); // FIXME
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
641 break;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
642 case OSDTYPE_OSD:
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
643 case OSDTYPE_SUBTITLE:
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
644 case OSDTYPE_PROGBAR:
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
645 vo_draw_text_from_buffer(obj,draw_alpha);
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
646 break;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
647 }
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
648 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
649 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
650 }
eb0cb6185e6c osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents: 5640
diff changeset
651 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
652 obj=obj->next;
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
653 }
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
654 }
3034
24d3dca4e813 DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents: 2498
diff changeset
655
4807
156482788caf osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents: 4773
diff changeset
656 static int vo_osd_changed_status = 0;
156482788caf osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents: 4773
diff changeset
657
156482788caf osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents: 4773
diff changeset
658 int vo_osd_changed(int new_value)
156482788caf osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents: 4773
diff changeset
659 {
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
660 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
661 int ret = vo_osd_changed_status;
156482788caf osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents: 4773
diff changeset
662 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
663
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
664 while(obj){
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
665 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
666 obj=obj->next;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
667 }
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
668
4807
156482788caf osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents: 4773
diff changeset
669 return ret;
156482788caf osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents: 4773
diff changeset
670 }
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
671
5645
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
672 // BBBBBBBBBBBB AAAAAAAAAAAAA BBBBBBBBBBB
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
673 // BBBBBBBBBBBB BBBBBBBBBBBBB
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
674 // BBBBBBB
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
675
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
676 // 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
677 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
678 mp_osd_obj_t* obj=vo_osd_list;
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
679 while(obj){
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
680 if(obj->flags&OSDFLAG_VISIBLE){
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
681 if( (obj->bbox.x1<=x2 && obj->bbox.x2>=x1) &&
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
682 (obj->bbox.y1<=y2 && obj->bbox.y2>=y1) ) return 1;
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
683 }
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
684 obj=obj->next;
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
685 }
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
686 return 0;
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
687 }