annotate libvo/sub.c @ 21280:db66f5bdb5cd

Remove unnecessary variable indirection.
author diego
date Sun, 26 Nov 2006 22:53:57 +0000
parents 8258747951d7
children d81ffbf9615f
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
21193
a067e7e18b50 support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents: 19366
diff changeset
11 #ifdef USE_DVDNAV
21200
c7b5dd2b2291 better nav highlight handling
ben
parents: 21193
diff changeset
12 #include "stream/stream.h"
c7b5dd2b2291 better nav highlight handling
ben
parents: 21193
diff changeset
13 #include "stream/stream_dvdnav.h"
21193
a067e7e18b50 support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents: 19366
diff changeset
14 #define OSD_NAV_BOX_ALPHA 0x7f
a067e7e18b50 support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents: 19366
diff changeset
15 #endif
a067e7e18b50 support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents: 19366
diff changeset
16
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
17 #include "mp_msg.h"
16923
a6a03ff1ddef Added translatable messages for OSD localization to help/help_mp-en.h
ptt
parents: 16839
diff changeset
18 #include "help_mp.h"
4088
4435dc3b8bef Add DVD subtitles to menoder
kmkaplan
parents: 4087
diff changeset
19 #include "video_out.h"
5294
4e64fca268e9 moved font_laod.h
arpi
parents: 4807
diff changeset
20 #include "font_load.h"
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
21 #include "sub.h"
13787
e047e70a9767 Handle "xxx.h" vs "../xxx.h" include paths in a consistent way.
diego
parents: 13343
diff changeset
22 #include "spudec.h"
19366
614f445786af Reuse UTF-8 reading code in libavutil
reimar
parents: 18950
diff changeset
23 #include "libavutil/common.h"
202
6ad0715dfac8 grey+alpha rendering support (for .sub)
arpi_esp
parents:
diff changeset
24
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
25 #define NEW_SPLITTING
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
26
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
27
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
28 // Structures needed for the new splitting algorithm.
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
29 // osd_text_t contains the single subtitle word.
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
30 // osd_text_p is used to mark the lines of subtitles
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
31 struct osd_text_t {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
32 int osd_kerning, //kerning with the previous word
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
33 osd_length, //orizontal length inside the bbox
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
34 text_length, //number of characters
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
35 *text; //characters
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
36 struct osd_text_t *prev,
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
37 *next;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
38 };
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
39
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
40 struct osd_text_p {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
41 int value;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
42 struct osd_text_t *ott;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
43 struct osd_text_p *prev,
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
44 *next;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
45 };
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
46 //^
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
47
2498
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
48 char * __sub_osd_names[]={
16923
a6a03ff1ddef Added translatable messages for OSD localization to help/help_mp-en.h
ptt
parents: 16839
diff changeset
49 MSGTR_VO_SUB_Seekbar,
a6a03ff1ddef Added translatable messages for OSD localization to help/help_mp-en.h
ptt
parents: 16839
diff changeset
50 MSGTR_VO_SUB_Play,
a6a03ff1ddef Added translatable messages for OSD localization to help/help_mp-en.h
ptt
parents: 16839
diff changeset
51 MSGTR_VO_SUB_Pause,
a6a03ff1ddef Added translatable messages for OSD localization to help/help_mp-en.h
ptt
parents: 16839
diff changeset
52 MSGTR_VO_SUB_Stop,
a6a03ff1ddef Added translatable messages for OSD localization to help/help_mp-en.h
ptt
parents: 16839
diff changeset
53 MSGTR_VO_SUB_Rewind,
a6a03ff1ddef Added translatable messages for OSD localization to help/help_mp-en.h
ptt
parents: 16839
diff changeset
54 MSGTR_VO_SUB_Forward,
a6a03ff1ddef Added translatable messages for OSD localization to help/help_mp-en.h
ptt
parents: 16839
diff changeset
55 MSGTR_VO_SUB_Clock,
a6a03ff1ddef Added translatable messages for OSD localization to help/help_mp-en.h
ptt
parents: 16839
diff changeset
56 MSGTR_VO_SUB_Contrast,
a6a03ff1ddef Added translatable messages for OSD localization to help/help_mp-en.h
ptt
parents: 16839
diff changeset
57 MSGTR_VO_SUB_Saturation,
a6a03ff1ddef Added translatable messages for OSD localization to help/help_mp-en.h
ptt
parents: 16839
diff changeset
58 MSGTR_VO_SUB_Volume,
a6a03ff1ddef Added translatable messages for OSD localization to help/help_mp-en.h
ptt
parents: 16839
diff changeset
59 MSGTR_VO_SUB_Brightness,
a6a03ff1ddef Added translatable messages for OSD localization to help/help_mp-en.h
ptt
parents: 16839
diff changeset
60 MSGTR_VO_SUB_Hue
2498
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
61 };
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
62 char * __sub_osd_names_short[] ={ "", "|>", "||", "[]", "<<" , ">>", "", "", "", "", "", ""};
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
63
213
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
64 //static int vo_font_loaded=-1;
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
65 font_desc_t* vo_font=NULL;
202
6ad0715dfac8 grey+alpha rendering support (for .sub)
arpi_esp
parents:
diff changeset
66
1991
dee4b2ea5e5b add gui support to config scripts, and fixed some warning.
pontscho
parents: 1878
diff changeset
67 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
68 int sub_unicode=0;
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
69 int sub_utf8=0;
4773
976bf6a9ded5 subtitle positioning patch by Jiri Svoboda
atmos4
parents: 4088
diff changeset
70 int sub_pos=100;
8583
4c18c4e7f34e -subwidth
arpi
parents: 8578
diff changeset
71 int sub_width_p=100;
16839
1b1b59b160ab make bottom alignment the default since it's the only sane mode when sub_pos is near bottom (default)
rfelker
parents: 16838
diff changeset
72 int sub_alignment=2; /* 0=top, 1=center, 2=bottom */
7628
d6608342591d This patch adds the functionality to disable/enable subtitles while playing
arpi
parents: 7121
diff changeset
73 int sub_visibility=1;
8617
6ffbe7608013 Me: -sub-bg-* would be nicer. "Background" is usually shortened as "bg", not "bkg".
rathann
parents: 8601
diff changeset
74 int sub_bg_color=0; /* subtitles background color */
6ffbe7608013 Me: -sub-bg-* would be nicer. "Background" is usually shortened as "bg", not "bkg".
rathann
parents: 8601
diff changeset
75 int sub_bg_alpha=0;
10263
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents: 9036
diff changeset
76 int sub_justify=0;
21219
8258747951d7 keep nav highlight event in dvdnav priv structure
ben
parents: 21200
diff changeset
77 #ifdef USE_DVDNAV
8258747951d7 keep nav highlight event in dvdnav priv structure
ben
parents: 21200
diff changeset
78 static nav_highlight_t nav_hl;
8258747951d7 keep nav highlight event in dvdnav priv structure
ben
parents: 21200
diff changeset
79 #endif
213
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
80
5664
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
81 // return the real height of a char:
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
82 static inline int get_height(int c,int h){
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
83 int font;
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
84 if ((font=vo_font->font[c])>=0)
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
85 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
86 return h;
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
87 }
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
88
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
89 // 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
90 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
91 {
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
92 int dststride = obj->stride;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
93 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
94 int srcskip = stride-w;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
95 int i, j;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
96 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
97 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
98 unsigned char *bs = src;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
99 unsigned char *as = srca;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
100
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
101 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
102 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
103 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
104 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
105 return;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
106 }
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
107
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
108 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
109 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
110 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
111 if (*as) {
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
112 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
113 }
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
114 }
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
115 b+= dstskip;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
116 a+= dstskip;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
117 bs+= srcskip;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
118 as+= srcskip;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
119 }
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
120 }
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
122 // 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
123 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
124 {
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
125 int len;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
126 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
127 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
128 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
129 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
130 if (obj->allocated<len) {
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
131 obj->allocated = len;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
132 free(obj->bitmap_buffer);
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
133 free(obj->alpha_buffer);
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
134 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
135 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
136 }
8617
6ffbe7608013 Me: -sub-bg-* would be nicer. "Background" is usually shortened as "bg", not "bkg".
rathann
parents: 8601
diff changeset
137 memset(obj->bitmap_buffer, sub_bg_color, len);
6ffbe7608013 Me: -sub-bg-* would be nicer. "Background" is usually shortened as "bg", not "bkg".
rathann
parents: 8601
diff changeset
138 memset(obj->alpha_buffer, sub_bg_alpha, len);
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
139 }
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
140
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
141 // renders the buffer
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
142 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
143 if (obj->allocated > 0) {
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
144 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
145 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
146 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
147 obj->bitmap_buffer,
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
148 obj->alpha_buffer,
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
149 obj->stride);
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
150 }
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
151 }
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
152
18935
880b99e9a891 Make utf8_get_char non-static.
eugeni
parents: 18717
diff changeset
153 unsigned utf8_get_char(char **str) {
18717
0f99a5fe9c7f Support UTF8 in OSD text
reimar
parents: 18716
diff changeset
154 uint8_t *strp = (uint8_t *)*str;
19366
614f445786af Reuse UTF-8 reading code in libavutil
reimar
parents: 18950
diff changeset
155 unsigned c;
614f445786af Reuse UTF-8 reading code in libavutil
reimar
parents: 18950
diff changeset
156 GET_UTF8(c, *strp++, goto no_utf8;);
18717
0f99a5fe9c7f Support UTF8 in OSD text
reimar
parents: 18716
diff changeset
157 *str = (char *)strp;
0f99a5fe9c7f Support UTF8 in OSD text
reimar
parents: 18716
diff changeset
158 return c;
0f99a5fe9c7f Support UTF8 in OSD text
reimar
parents: 18716
diff changeset
159
0f99a5fe9c7f Support UTF8 in OSD text
reimar
parents: 18716
diff changeset
160 no_utf8:
0f99a5fe9c7f Support UTF8 in OSD text
reimar
parents: 18716
diff changeset
161 strp = (uint8_t *)*str;
0f99a5fe9c7f Support UTF8 in OSD text
reimar
parents: 18716
diff changeset
162 c = *strp++;
0f99a5fe9c7f Support UTF8 in OSD text
reimar
parents: 18716
diff changeset
163 *str = (char *)strp;
0f99a5fe9c7f Support UTF8 in OSD text
reimar
parents: 18716
diff changeset
164 return c;
0f99a5fe9c7f Support UTF8 in OSD text
reimar
parents: 18716
diff changeset
165 }
0f99a5fe9c7f Support UTF8 in OSD text
reimar
parents: 18716
diff changeset
166
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
167 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
168 unsigned char *cp=vo_osd_text;
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
169 int x=20;
5664
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
170 int h=0;
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
171 int font;
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
172
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
173 obj->bbox.x1=obj->x=x;
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
174 obj->bbox.y1=obj->y=10;
202
6ad0715dfac8 grey+alpha rendering support (for .sub)
arpi_esp
parents:
diff changeset
175
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
176 while (*cp){
18717
0f99a5fe9c7f Support UTF8 in OSD text
reimar
parents: 18716
diff changeset
177 uint16_t c=utf8_get_char(&cp);
7121
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, c);
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
179 x+=vo_font->width[c]+vo_font->charspace;
5664
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
180 h=get_height(c,h);
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
181 }
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
182
5664
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
183 obj->bbox.x2=x-vo_font->charspace;
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
184 obj->bbox.y2=obj->bbox.y1+h;
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
185 obj->flags|=OSDFLAG_BBOX;
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
186
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
187 alloc_buf(obj);
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
188
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
189 cp=vo_osd_text;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
190 x = obj->x;
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
191 while (*cp){
18717
0f99a5fe9c7f Support UTF8 in OSD text
reimar
parents: 18716
diff changeset
192 uint16_t c=utf8_get_char(&cp);
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
193 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
194 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
195 vo_font->width[c],
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
196 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
197 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
198 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
199 vo_font->pic_a[font]->w);
213
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
200 x+=vo_font->width[c]+vo_font->charspace;
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
201 }
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
202 }
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
203
21193
a067e7e18b50 support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents: 19366
diff changeset
204 #ifdef USE_DVDNAV
21219
8258747951d7 keep nav highlight event in dvdnav priv structure
ben
parents: 21200
diff changeset
205 void osd_set_nav_box (uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey) {
8258747951d7 keep nav highlight event in dvdnav priv structure
ben
parents: 21200
diff changeset
206 nav_hl.sx = sx;
8258747951d7 keep nav highlight event in dvdnav priv structure
ben
parents: 21200
diff changeset
207 nav_hl.sy = sy;
8258747951d7 keep nav highlight event in dvdnav priv structure
ben
parents: 21200
diff changeset
208 nav_hl.ex = ex;
8258747951d7 keep nav highlight event in dvdnav priv structure
ben
parents: 21200
diff changeset
209 nav_hl.ey = ey;
8258747951d7 keep nav highlight event in dvdnav priv structure
ben
parents: 21200
diff changeset
210 }
8258747951d7 keep nav highlight event in dvdnav priv structure
ben
parents: 21200
diff changeset
211
21193
a067e7e18b50 support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents: 19366
diff changeset
212 inline static void vo_update_nav (mp_osd_obj_t *obj, int dxs, int dys) {
a067e7e18b50 support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents: 19366
diff changeset
213 int len;
a067e7e18b50 support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents: 19366
diff changeset
214
21219
8258747951d7 keep nav highlight event in dvdnav priv structure
ben
parents: 21200
diff changeset
215 obj->bbox.x1 = obj->x = nav_hl.sx;
8258747951d7 keep nav highlight event in dvdnav priv structure
ben
parents: 21200
diff changeset
216 obj->bbox.y1 = obj->y = nav_hl.sy;
8258747951d7 keep nav highlight event in dvdnav priv structure
ben
parents: 21200
diff changeset
217 obj->bbox.x2 = nav_hl.ex;
8258747951d7 keep nav highlight event in dvdnav priv structure
ben
parents: 21200
diff changeset
218 obj->bbox.y2 = nav_hl.ey;
21193
a067e7e18b50 support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents: 19366
diff changeset
219
a067e7e18b50 support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents: 19366
diff changeset
220 alloc_buf (obj);
a067e7e18b50 support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents: 19366
diff changeset
221 len = obj->stride * (obj->bbox.y2 - obj->bbox.y1);
a067e7e18b50 support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents: 19366
diff changeset
222 memset (obj->bitmap_buffer, OSD_NAV_BOX_ALPHA, len);
a067e7e18b50 support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents: 19366
diff changeset
223 memset (obj->alpha_buffer, OSD_NAV_BOX_ALPHA, len);
a067e7e18b50 support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents: 19366
diff changeset
224 obj->flags |= OSDFLAG_BBOX | OSDFLAG_VISIBLE | OSDFLAG_CHANGED;
a067e7e18b50 support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents: 19366
diff changeset
225 }
a067e7e18b50 support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents: 19366
diff changeset
226 #endif
a067e7e18b50 support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents: 19366
diff changeset
227
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
228 int vo_osd_progbar_type=-1;
1726
38871427a131 corrections to OSD progbar position calculations
atlka
parents: 1602
diff changeset
229 int vo_osd_progbar_value=100; // 0..256
38871427a131 corrections to OSD progbar position calculations
atlka
parents: 1602
diff changeset
230
38871427a131 corrections to OSD progbar position calculations
atlka
parents: 1602
diff changeset
231 // if we have n=256 bars then OSD progbar looks like below
38871427a131 corrections to OSD progbar position calculations
atlka
parents: 1602
diff changeset
232 //
1878
96ae64356ea0 corrections to OSD mark position
atlka
parents: 1852
diff changeset
233 // 0 1 2 3 ... 256 <= vo_osd_progbar_value
96ae64356ea0 corrections to OSD mark position
atlka
parents: 1852
diff changeset
234 // | | | | |
1726
38871427a131 corrections to OSD progbar position calculations
atlka
parents: 1602
diff changeset
235 // [ === === === ... === ]
38871427a131 corrections to OSD progbar position calculations
atlka
parents: 1602
diff changeset
236 //
38871427a131 corrections to OSD progbar position calculations
atlka
parents: 1602
diff changeset
237 // the above schema is rescalled to n=elems bars
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
238
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
239 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
240
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
241 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
242
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
243 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
244 obj->flags&=~OSDFLAG_VISIBLE;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
245 return;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
246 }
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
247
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
248 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
249 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
250 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
251 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
252 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
253
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
254 // calculate bbox corners:
5664
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
255 { int h=0;
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
256 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
257 int delimw=vo_font->width[OSD_PB_START]
1549
787c053b314c minor changes in sub.c
atlka
parents: 1548
diff changeset
258 +vo_font->width[OSD_PB_END]
787c053b314c minor changes in sub.c
atlka
parents: 1548
diff changeset
259 +vo_font->charspace;
1548
eee7951a23af changes according to proper subfont bar positioning and char spaceing - sub.c
atlka
parents: 1524
diff changeset
260 int width=(2*dxs-3*delimw)/3;
1549
787c053b314c minor changes in sub.c
atlka
parents: 1548
diff changeset
261 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
262 int elems=width/charw;
1549
787c053b314c minor changes in sub.c
atlka
parents: 1548
diff changeset
263 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
264 int delta = 0;
5664
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
265 h=get_height(OSD_PB_START,h);
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
266 h=get_height(OSD_PB_END,h);
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
267 h=get_height(OSD_PB_0,h);
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
268 h=get_height(OSD_PB_1,h);
8422
1f1cc58e8e65 progbar osd buffer height adjustment fix
henry
parents: 8361
diff changeset
269 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
270 delta = vo_font->width[vo_osd_progbar_type]+vo_font->spacewidth;
1f1cc58e8e65 progbar osd buffer height adjustment fix
henry
parents: 8361
diff changeset
271 delta = (x-delta > 0) ? delta : x;
1f1cc58e8e65 progbar osd buffer height adjustment fix
henry
parents: 8361
diff changeset
272 h=get_height(vo_osd_progbar_type,h);
1f1cc58e8e65 progbar osd buffer height adjustment fix
henry
parents: 8361
diff changeset
273 }
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
274 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
275 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
276 obj->bbox.x2=x+width+delimw;
5664
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
277 obj->bbox.y2=y+h; //vo_font->height;
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
278 obj->flags|=OSDFLAG_BBOX;
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
279 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
280 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
281 }
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
282
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
283 alloc_buf(obj);
8794
056fc0a8b3d2 sanity check
henry
parents: 8635
diff changeset
284
056fc0a8b3d2 sanity check
henry
parents: 8635
diff changeset
285 {
056fc0a8b3d2 sanity check
henry
parents: 8635
diff changeset
286 int minw = vo_font->width[OSD_PB_START]+vo_font->width[OSD_PB_END]+vo_font->width[OSD_PB_0];
056fc0a8b3d2 sanity check
henry
parents: 8635
diff changeset
287 if (vo_osd_progbar_type>0 && vo_font->font[vo_osd_progbar_type]>=0){
056fc0a8b3d2 sanity check
henry
parents: 8635
diff changeset
288 minw += vo_font->width[vo_osd_progbar_type]+vo_font->charspace+vo_font->spacewidth;
056fc0a8b3d2 sanity check
henry
parents: 8635
diff changeset
289 }
056fc0a8b3d2 sanity check
henry
parents: 8635
diff changeset
290 if (obj->bbox.x2 - obj->bbox.x1 < minw) return; // space too small, don't render anything
056fc0a8b3d2 sanity check
henry
parents: 8635
diff changeset
291 }
056fc0a8b3d2 sanity check
henry
parents: 8635
diff changeset
292
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
293 // render it:
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
294 { unsigned char *s;
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
295 unsigned char *sa;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
296 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
297 int x=obj->x;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
298 int y=obj->y;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
299 int c,font;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
300 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
301 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
302
1726
38871427a131 corrections to OSD progbar position calculations
atlka
parents: 1602
diff changeset
303 if (vo_osd_progbar_value<=0)
38871427a131 corrections to OSD progbar position calculations
atlka
parents: 1602
diff changeset
304 mark=0;
1878
96ae64356ea0 corrections to OSD mark position
atlka
parents: 1852
diff changeset
305 else {
96ae64356ea0 corrections to OSD mark position
atlka
parents: 1852
diff changeset
306 int ev=vo_osd_progbar_value*elems;
96ae64356ea0 corrections to OSD mark position
atlka
parents: 1852
diff changeset
307 mark=ev>>8;
96ae64356ea0 corrections to OSD mark position
atlka
parents: 1852
diff changeset
308 if (ev & 0xFF) mark++;
96ae64356ea0 corrections to OSD mark position
atlka
parents: 1852
diff changeset
309 if (mark>elems) mark=elems;
96ae64356ea0 corrections to OSD mark position
atlka
parents: 1852
diff changeset
310 }
96ae64356ea0 corrections to OSD mark position
atlka
parents: 1852
diff changeset
311
1727
9da2b587b029 changes according to OSD calculations
atlka
parents: 1726
diff changeset
312
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
313 // printf("osd.progbar width=%d xpos=%d\n",width,x);
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
314
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
315 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
316 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
317 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
318 draw_alpha_buf(obj,(xp<0?0:xp),y,
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
319 vo_font->width[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
320 vo_font->pic_a[font]->h,
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
321 vo_font->pic_b[font]->bmp+vo_font->start[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
322 vo_font->pic_a[font]->bmp+vo_font->start[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
323 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
324 }
fcbfc99cf8e6 skip lines with negative y position if there is too many lines to display
atlka
parents: 1549
diff changeset
325
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
326 c=OSD_PB_START;
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
327 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
328 draw_alpha_buf(obj,x,y,
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
329 vo_font->width[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
330 vo_font->pic_a[font]->h,
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
331 vo_font->pic_b[font]->bmp+vo_font->start[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
332 vo_font->pic_a[font]->bmp+vo_font->start[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
333 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
334 x+=vo_font->width[c]+vo_font->charspace;
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
335
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
336 c=OSD_PB_0;
1602
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
337 if ((font=vo_font->font[c])>=0){
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
338 w=vo_font->width[c];
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
339 h=vo_font->pic_a[font]->h;
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
340 s=vo_font->pic_b[font]->bmp+vo_font->start[c];
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
341 sa=vo_font->pic_a[font]->bmp+vo_font->start[c];
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
342 st=vo_font->pic_a[font]->w;
2204
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
343 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
344 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
345 x+=charw;
2204
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
346 } while(--i);
1602
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
347 }
202
6ad0715dfac8 grey+alpha rendering support (for .sub)
arpi_esp
parents:
diff changeset
348
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
349 c=OSD_PB_1;
1602
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
350 if ((font=vo_font->font[c])>=0){
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
351 w=vo_font->width[c];
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
352 h=vo_font->pic_a[font]->h;
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
353 s =vo_font->pic_b[font]->bmp+vo_font->start[c];
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
354 sa=vo_font->pic_a[font]->bmp+vo_font->start[c];
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
355 st=vo_font->pic_a[font]->w;
2204
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
356 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
357 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
358 x+=charw;
2204
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
359 } while(--i);
1602
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
360 }
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
361
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
362 c=OSD_PB_END;
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
363 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
364 draw_alpha_buf(obj,x,y,
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
365 vo_font->width[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
366 vo_font->pic_a[font]->h,
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
367 vo_font->pic_b[font]->bmp+vo_font->start[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
368 vo_font->pic_a[font]->bmp+vo_font->start[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
369 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
370 // 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
371
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
372 }
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
373 // vo_osd_progbar_value=(vo_osd_progbar_value+1)&0xFF;
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
374
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
375 }
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
376
254
57f0156416e3 use subreader's sub struct
arpi_esp
parents: 218
diff changeset
377 subtitle* vo_sub=NULL;
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
378
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
379 // 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
380
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
381 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
382 unsigned char *t;
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
383 int c,i,j,l,x,y,font,prevc,counter;
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
384 int len;
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
385 int k;
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
386 int lastStripPosition;
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
387 int xsize;
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
388 int xmin=dxs,xmax=0;
1591
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
389 int h,lasth;
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
390 int xtblc, utblc;
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
391
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
392 obj->flags|=OSDFLAG_CHANGED|OSDFLAG_VISIBLE;
7628
d6608342591d This patch adds the functionality to disable/enable subtitles while playing
arpi
parents: 7121
diff changeset
393
12794
0d17f2b4292c don't use uninitialized font descriptions
faust3
parents: 11297
diff changeset
394 if(!vo_sub || !vo_font || !sub_visibility || (vo_font->font[40]<0)){
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
395 obj->flags&=~OSDFLAG_VISIBLE;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
396 return;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
397 }
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
398
5664
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
399 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
400 obj->params.subtitle.lines=0;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
401
1602
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
402 // 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
403 i=k=lasth=0;
1591
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
404 h=vo_font->height;
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
405 lastStripPosition=-1;
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
406 l=vo_sub->lines;
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
407
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
408 {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
409 struct osd_text_t *osl, *cp_ott, *tmp_ott, *tmp;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
410 struct osd_text_p *otp_sub = NULL, *otp_sub_tmp, // these are used to store the whole sub text osd
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
411 *otp, *tmp_otp, *pmt; // these are used to manage sub text osd coming from a single sub line
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
412 int *char_seq, char_position, xlimit = dxs * sub_width_p / 100, counter;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
413
2204
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
414 while (l) {
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
415 xsize = -vo_font->charspace;
2204
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
416 l--;
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
417 t=vo_sub->text[i++];
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
418 len=strlen(t)-1;
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
419 char_position = 0;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
420 char_seq = (int *) malloc((len + 1) * sizeof(int));
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
421
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
422 prevc = -1;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
423
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
424 otp = NULL;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
425 osl = NULL;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
426 x = 1;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
427
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
428 // reading the subtitle words from vo_sub->text[]
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
429 for (j=0;j<=len;j++){
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
430 if ((c=t[j])>=0x80){
2176
1ae16a34f055 speed improvements
atlka
parents: 1991
diff changeset
431 if (sub_utf8){
1ae16a34f055 speed improvements
atlka
parents: 1991
diff changeset
432 if ((c & 0xe0) == 0xc0) /* 2 bytes U+00080..U+0007FF*/
1ae16a34f055 speed improvements
atlka
parents: 1991
diff changeset
433 c = (c & 0x1f)<<6 | (t[++j] & 0x3f);
8451
fb88ccbc5ccc compiler warning fixes
arpi
parents: 8422
diff changeset
434 else if((c & 0xf0) == 0xe0){ /* 3 bytes U+00800..U+00FFFF*/
fb88ccbc5ccc compiler warning fixes
arpi
parents: 8422
diff changeset
435 c = (((c & 0x0f)<<6) | (t[++j] & 0x3f))<<6;
fb88ccbc5ccc compiler warning fixes
arpi
parents: 8422
diff changeset
436 c |= (t[++j] & 0x3f);
fb88ccbc5ccc compiler warning fixes
arpi
parents: 8422
diff changeset
437 }
2176
1ae16a34f055 speed improvements
atlka
parents: 1991
diff changeset
438 } else if (sub_unicode)
1ae16a34f055 speed improvements
atlka
parents: 1991
diff changeset
439 c = (c<<8) + t[++j];
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
440 }
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
441 if (k==MAX_UCS){
2204
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
442 len=j; // end here
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
443 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
444 }
2204
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
445 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
446 render_one_glyph(vo_font, c);
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
447
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
448 if (c == ' ') {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
449 struct osd_text_t *tmp_ott = (struct osd_text_t *) calloc(1, sizeof(struct osd_text_t));
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
450
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
451 if (osl == NULL) {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
452 osl = cp_ott = tmp_ott;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
453 } else {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
454 tmp_ott->prev = cp_ott;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
455 cp_ott->next = tmp_ott;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
456 tmp_ott->osd_kerning =
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
457 vo_font->charspace + vo_font->width[' '];
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
458 cp_ott = tmp_ott;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
459 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
460 tmp_ott->osd_length = xsize;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
461 tmp_ott->text_length = char_position;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
462 tmp_ott->text = (int *) malloc(char_position * sizeof(int));
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
463 for (counter = 0; counter < char_position; ++counter)
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
464 tmp_ott->text[counter] = char_seq[counter];
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
465 char_position = 0;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
466 xsize = 0;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
467 prevc = c;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
468 } else {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
469 int delta_xsize = vo_font->width[c] + vo_font->charspace + kerning(vo_font, prevc, c);
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
470
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
471 if (xsize + delta_xsize <= dxs) {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
472 if (!x) x = 1;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
473 prevc = c;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
474 char_seq[char_position++] = c;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
475 xsize += delta_xsize;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
476 if ((!suboverlap_enabled) && ((font = vo_font->font[c]) >= 0)) {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
477 if (vo_font->pic_a[font]->h > h) {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
478 h = vo_font->pic_a[font]->h;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
479 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
480 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
481 } else {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
482 if (x) {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
483 mp_msg(MSGT_OSD, MSGL_WARN, "\nSubtitle word '%s' too long!\n", t);
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
484 x = 0;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
485 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
486 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
487 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
488 }// for len (all words from subtitle line read)
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
489
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
490 // osl holds an ordered (as they appear in the lines) chain of the subtitle words
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
491 {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
492 struct osd_text_t *tmp_ott = (struct osd_text_t *) calloc(1, sizeof(struct osd_text_t));
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
493
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
494 if (osl == NULL) {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
495 osl = cp_ott = tmp_ott;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
496 } else {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
497 tmp_ott->prev = cp_ott;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
498 cp_ott->next = tmp_ott;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
499 tmp_ott->osd_kerning =
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
500 vo_font->charspace + vo_font->width[' '];
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
501 cp_ott = tmp_ott;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
502 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
503 tmp_ott->osd_length = xsize;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
504 tmp_ott->text_length = char_position;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
505 tmp_ott->text = (int *) malloc(char_position * sizeof(int));
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
506 for (counter = 0; counter < char_position; ++counter)
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
507 tmp_ott->text[counter] = char_seq[counter];
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
508 char_position = 0;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
509 xsize = -vo_font->charspace;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
510 }
18716
e75ab7767078 Missing free for malloced char_seq in OSD code
reimar
parents: 17566
diff changeset
511 free(char_seq);
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
512
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
513 if (osl != NULL) {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
514 int value = 0, exit = 0, minimum = 0;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
515
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
516 // otp will contain the chain of the osd subtitle lines coming from the single vo_sub line.
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
517 otp = tmp_otp = (struct osd_text_p *) calloc(1, sizeof(struct osd_text_p));
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
518 tmp_otp->ott = osl;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
519 for (tmp_ott = tmp_otp->ott; exit == 0; ) {
11297
b4c7de4cfbf2 prevent lockups on words which do not fit on the screen - temporary fix
henry
parents: 11201
diff changeset
520 do {
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
521 value += tmp_ott->osd_kerning + tmp_ott->osd_length;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
522 tmp_ott = tmp_ott->next;
11297
b4c7de4cfbf2 prevent lockups on words which do not fit on the screen - temporary fix
henry
parents: 11201
diff changeset
523 } while ((tmp_ott != NULL) && (value + tmp_ott->osd_kerning + tmp_ott->osd_length <= xlimit));
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
524 if (tmp_ott != NULL) {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
525 struct osd_text_p *tmp = (struct osd_text_p *) calloc(1, sizeof(struct osd_text_p));
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
526
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
527 tmp_otp->value = value;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
528 tmp_otp->next = tmp;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
529 tmp->prev = tmp_otp;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
530 tmp_otp = tmp;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
531 tmp_otp->ott = tmp_ott;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
532 value = -2 * vo_font->charspace - vo_font->width[' '];
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
533 } else {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
534 tmp_otp->value = value;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
535 exit = 1;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
536 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
537 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
538
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
539
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
540 #ifdef NEW_SPLITTING
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
541 // minimum holds the 'sum of the differences in lenght among the lines',
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
542 // a measure of the eveness of the lenghts of the lines
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
543 for (tmp_otp = otp; tmp_otp->next != NULL; tmp_otp = tmp_otp->next) {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
544 pmt = tmp_otp->next;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
545 while (pmt != NULL) {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
546 minimum += abs(tmp_otp->value - pmt->value);
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
547 pmt = pmt->next;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
548 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
549 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
550
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
551 if (otp->next != NULL) {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
552 int mem1, mem2;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
553 struct osd_text_p *mem, *hold;
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
554
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
555 exit = 0;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
556 // until the last word of a line can be moved to the beginning of following line
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
557 // reducing the 'sum of the differences in lenght among the lines', it is done
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
558 while (exit == 0) {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
559 hold = NULL;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
560 exit = 1;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
561 for (tmp_otp = otp; tmp_otp->next != NULL; tmp_otp = tmp_otp->next) {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
562 pmt = tmp_otp->next;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
563 for (tmp = tmp_otp->ott; tmp->next != pmt->ott; tmp = tmp->next);
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
564 if (pmt->value + tmp->osd_length + pmt->ott->osd_kerning <= xlimit) {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
565 mem1 = tmp_otp->value;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
566 mem2 = pmt->value;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
567 tmp_otp->value = mem1 - tmp->osd_length - tmp->osd_kerning;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
568 pmt->value = mem2 + tmp->osd_length + pmt->ott->osd_kerning;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
569
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
570 value = 0;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
571 for (mem = otp; mem->next != NULL; mem = mem->next) {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
572 pmt = mem->next;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
573 while (pmt != NULL) {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
574 value += abs(mem->value - pmt->value);
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
575 pmt = pmt->next;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
576 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
577 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
578 if (value < minimum) {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
579 minimum = value;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
580 hold = tmp_otp;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
581 exit = 0;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
582 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
583 tmp_otp->value = mem1;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
584 tmp_otp->next->value = mem2;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
585 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
586 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
587 // merging
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
588 if (exit == 0) {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
589 tmp_otp = hold;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
590 pmt = tmp_otp->next;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
591 for (tmp = tmp_otp->ott; tmp->next != pmt->ott; tmp = tmp->next);
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
592 mem1 = tmp_otp->value;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
593 mem2 = pmt->value;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
594 tmp_otp->value = mem1 - tmp->osd_length - tmp->osd_kerning;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
595 pmt->value = mem2 + tmp->osd_length + pmt->ott->osd_kerning;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
596 pmt->ott = tmp;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
597 }//~merging
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
598 }//~while(exit == 0)
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
599 }//~if(otp->next!=NULL)
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
600 #endif
8534
922ce27eb683 This patch adds support for vertical subtitle alignment
arpi
parents: 8451
diff changeset
601
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
602 // adding otp (containing splitted lines) to otp chain
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
603 if (otp_sub == NULL) {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
604 otp_sub = otp;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
605 for (otp_sub_tmp = otp_sub; otp_sub_tmp->next != NULL; otp_sub_tmp = otp_sub_tmp->next);
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
606 } else {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
607 //updating ott chain
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
608 tmp = otp_sub->ott;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
609 while (tmp->next != NULL) tmp = tmp->next;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
610 tmp->next = otp->ott;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
611 otp->ott->prev = tmp;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
612 //attaching new subtitle line at the end
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
613 otp_sub_tmp->next = otp;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
614 otp->prev = otp_sub_tmp;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
615 do
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
616 otp_sub_tmp = otp_sub_tmp->next;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
617 while (otp_sub_tmp->next != NULL);
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
618 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
619 }//~ if(osl != NULL)
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
620 } // while
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
621
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
622 // write lines into utbl
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
623 xtblc = 0;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
624 utblc = 0;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
625 obj->y = dys;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
626 obj->params.subtitle.lines = 0;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
627 for (tmp_otp = otp_sub; tmp_otp != NULL; tmp_otp = tmp_otp->next) {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
628
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
629 if ((obj->params.subtitle.lines++) >= MAX_UCSLINES)
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
630 break;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
631
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
632 if (h > obj->y) { // out of the screen so end parsing
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
633 obj->y -= lasth - vo_font->height; // correct the y position
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
634 break;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
635 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
636 xsize = tmp_otp->value;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
637 obj->params.subtitle.xtbl[xtblc++] = (dxs - xsize) / 2;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
638 if (xmin > (dxs - xsize) / 2)
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
639 xmin = (dxs - xsize) / 2;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
640 if (xmax < (dxs + xsize) / 2)
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
641 xmax = (dxs + xsize) / 2;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
642
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
643 tmp = (tmp_otp->next == NULL) ? NULL : tmp_otp->next->ott;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
644 for (tmp_ott = tmp_otp->ott; tmp_ott != tmp; tmp_ott = tmp_ott->next) {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
645 for (counter = 0; counter < tmp_ott->text_length; ++counter) {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
646 if (utblc > MAX_UCS) {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
647 break;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
648 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
649 c = tmp_ott->text[counter];
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
650 render_one_glyph(vo_font, c);
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
651 obj->params.subtitle.utbl[utblc++] = c;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
652 k++;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
653 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
654 obj->params.subtitle.utbl[utblc++] = ' ';
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
655 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
656 obj->params.subtitle.utbl[utblc - 1] = 0;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
657 obj->y -= vo_font->height;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
658 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
659 if(obj->params.subtitle.lines)
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
660 obj->y = dys - ((obj->params.subtitle.lines - 1) * vo_font->height + vo_font->pic_a[vo_font->font[40]]->h);
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
661
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
662 // free memory
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
663 if (otp_sub != NULL) {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
664 for (tmp = otp_sub->ott; tmp->next != NULL; free(tmp->prev)) {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
665 free(tmp->text);
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
666 tmp = tmp->next;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
667 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
668 free(tmp->text);
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
669 free(tmp);
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
670
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
671 for(pmt = otp_sub; pmt->next != NULL; free(pmt->prev)) {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
672 pmt = pmt->next;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
673 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
674 free(pmt);
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
675 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
676
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
677 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
678 /// vertical alignment
8534
922ce27eb683 This patch adds support for vertical subtitle alignment
arpi
parents: 8451
diff changeset
679 h = dys - obj->y;
16838
fb79161e09f4 reverse incorrect sub alignment change, ok'd by diego
rfelker
parents: 16834
diff changeset
680 if (sub_alignment == 2)
8534
922ce27eb683 This patch adds support for vertical subtitle alignment
arpi
parents: 8451
diff changeset
681 obj->y = dys * sub_pos / 100 - h;
922ce27eb683 This patch adds support for vertical subtitle alignment
arpi
parents: 8451
diff changeset
682 else if (sub_alignment == 1)
922ce27eb683 This patch adds support for vertical subtitle alignment
arpi
parents: 8451
diff changeset
683 obj->y = dys * sub_pos / 100 - h / 2;
922ce27eb683 This patch adds support for vertical subtitle alignment
arpi
parents: 8451
diff changeset
684 else
922ce27eb683 This patch adds support for vertical subtitle alignment
arpi
parents: 8451
diff changeset
685 obj->y = dys * sub_pos / 100;
922ce27eb683 This patch adds support for vertical subtitle alignment
arpi
parents: 8451
diff changeset
686
922ce27eb683 This patch adds support for vertical subtitle alignment
arpi
parents: 8451
diff changeset
687 if (obj->y < 0)
922ce27eb683 This patch adds support for vertical subtitle alignment
arpi
parents: 8451
diff changeset
688 obj->y = 0;
922ce27eb683 This patch adds support for vertical subtitle alignment
arpi
parents: 8451
diff changeset
689 if (obj->y > dys - h)
922ce27eb683 This patch adds support for vertical subtitle alignment
arpi
parents: 8451
diff changeset
690 obj->y = dys - h;
922ce27eb683 This patch adds support for vertical subtitle alignment
arpi
parents: 8451
diff changeset
691
922ce27eb683 This patch adds support for vertical subtitle alignment
arpi
parents: 8451
diff changeset
692 obj->bbox.y2 = obj->y + h;
922ce27eb683 This patch adds support for vertical subtitle alignment
arpi
parents: 8451
diff changeset
693
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
694 // calculate bbox:
10263
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents: 9036
diff changeset
695 if (sub_justify) xmin = 10;
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
696 obj->bbox.x1=xmin;
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
697 obj->bbox.x2=xmax;
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
698 obj->bbox.y1=obj->y;
5664
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
699 // obj->bbox.y2=obj->y+obj->params.subtitle.lines*vo_font->height;
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
700 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
701
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
702 alloc_buf(obj);
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
703
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
704 y = obj->y;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
705
13343
1a4b6e575484 This time is a patch to improve subtitle alignment management. It
faust3
parents: 12794
diff changeset
706 obj->alignment = 0;
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
707 switch(vo_sub->alignment) {
13343
1a4b6e575484 This time is a patch to improve subtitle alignment management. It
faust3
parents: 12794
diff changeset
708 case SUB_ALIGNMENT_BOTTOMLEFT:
1a4b6e575484 This time is a patch to improve subtitle alignment management. It
faust3
parents: 12794
diff changeset
709 case SUB_ALIGNMENT_MIDDLELEFT:
1a4b6e575484 This time is a patch to improve subtitle alignment management. It
faust3
parents: 12794
diff changeset
710 case SUB_ALIGNMENT_TOPLEFT:
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
711 obj->alignment |= 0x1;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
712 break;
13343
1a4b6e575484 This time is a patch to improve subtitle alignment management. It
faust3
parents: 12794
diff changeset
713 case SUB_ALIGNMENT_BOTTOMRIGHT:
1a4b6e575484 This time is a patch to improve subtitle alignment management. It
faust3
parents: 12794
diff changeset
714 case SUB_ALIGNMENT_MIDDLERIGHT:
1a4b6e575484 This time is a patch to improve subtitle alignment management. It
faust3
parents: 12794
diff changeset
715 case SUB_ALIGNMENT_TOPRIGHT:
1a4b6e575484 This time is a patch to improve subtitle alignment management. It
faust3
parents: 12794
diff changeset
716 obj->alignment |= 0x2;
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
717 break;
13343
1a4b6e575484 This time is a patch to improve subtitle alignment management. It
faust3
parents: 12794
diff changeset
718 case SUB_ALIGNMENT_BOTTOMCENTER:
1a4b6e575484 This time is a patch to improve subtitle alignment management. It
faust3
parents: 12794
diff changeset
719 case SUB_ALIGNMENT_MIDDLECENTER:
1a4b6e575484 This time is a patch to improve subtitle alignment management. It
faust3
parents: 12794
diff changeset
720 case SUB_ALIGNMENT_TOPCENTER:
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
721 default:
13343
1a4b6e575484 This time is a patch to improve subtitle alignment management. It
faust3
parents: 12794
diff changeset
722 obj->alignment |= 0x0;
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
723 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
724
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
725 i=j=0;
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
726 if ((l = obj->params.subtitle.lines)) {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
727 for(counter = dxs; i < l; ++i)
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
728 if (obj->params.subtitle.xtbl[i] < counter) counter = obj->params.subtitle.xtbl[i];
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
729 for (i = 0; i < l; ++i) {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
730 switch (obj->alignment&0x3) {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
731 case 1:
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
732 // left
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
733 x = counter;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
734 break;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
735 case 2:
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
736 // right
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
737 x = 2 * obj->params.subtitle.xtbl[i] - counter - ((obj->params.subtitle.xtbl[i] == counter) ? 0 : 1);
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
738 break;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
739 default:
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
740 //center
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
741 x = obj->params.subtitle.xtbl[i];
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
742 }
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
743 prevc = -1;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
744 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
745 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
746 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
747 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
748 vo_font->width[c],
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
749 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
750 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
751 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
752 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
753 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
754 prevc = c;
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
755 }
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
756 y+=vo_font->height;
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
757 }
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
758 }
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
759
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
760 }
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
761
6190
bd6748605681 Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents: 6110
diff changeset
762 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
763 {
bd6748605681 Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents: 6110
diff changeset
764 unsigned int bbox[4];
bd6748605681 Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents: 6110
diff changeset
765 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
766 obj->bbox.x1 = bbox[0];
bd6748605681 Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents: 6110
diff changeset
767 obj->bbox.x2 = bbox[1];
bd6748605681 Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents: 6110
diff changeset
768 obj->bbox.y1 = bbox[2];
bd6748605681 Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents: 6110
diff changeset
769 obj->bbox.y2 = bbox[3];
bd6748605681 Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents: 6110
diff changeset
770 obj->flags |= OSDFLAG_BBOX;
bd6748605681 Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents: 6110
diff changeset
771 }
bd6748605681 Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents: 6110
diff changeset
772
bd6748605681 Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents: 6110
diff changeset
773 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
774 {
bd6748605681 Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents: 6110
diff changeset
775 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
776 }
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
777
3034
24d3dca4e813 DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents: 2498
diff changeset
778 void *vo_spudec=NULL;
4081
9e581ab5e54b Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents: 3180
diff changeset
779 void *vo_vobsub=NULL;
3034
24d3dca4e813 DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents: 2498
diff changeset
780
947
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 865
diff changeset
781 static int draw_alpha_init_flag=0;
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
782
17566
f580a7755ac5 Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents: 16923
diff changeset
783 extern void vo_draw_alpha_init(void);
1109
a013b2124f05 -Wall like fixes
al3x
parents: 947
diff changeset
784
7067
b395b1240954 fix dxr3 subtitle handling and add some optimizations
pontscho
parents: 7003
diff changeset
785 mp_osd_obj_t* vo_osd_list=NULL;
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
786
18950
a943bc3f26c8 Make some functions static.
uau
parents: 18935
diff changeset
787 static mp_osd_obj_t* new_osd_obj(int type){
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
788 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
789 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
790 osd->next=vo_osd_list;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
791 vo_osd_list=osd;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
792 osd->type=type;
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
793 osd->alpha_buffer = NULL;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
794 osd->bitmap_buffer = NULL;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
795 osd->allocated = -1;
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
796 return osd;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
797 }
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
798
17566
f580a7755ac5 Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents: 16923
diff changeset
799 void free_osd_list(void){
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
800 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
801 while(obj){
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
802 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
803 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
804 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
805 free(obj);
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
806 obj=next;
4081
9e581ab5e54b Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents: 3180
diff changeset
807 }
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
808 vo_osd_list=NULL;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
809 }
4081
9e581ab5e54b Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents: 3180
diff changeset
810
15085
1f8a1de5585c defer loading of the font after display size change to avoid useless
henry
parents: 15078
diff changeset
811 #define FONT_LOAD_DEFER 6
1f8a1de5585c defer loading of the font after display size change to avoid useless
henry
parents: 15078
diff changeset
812
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
813 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
814 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
815 int chg=0;
15085
1f8a1de5585c defer loading of the font after display size change to avoid useless
henry
parents: 15078
diff changeset
816 #ifdef HAVE_FREETYPE
1f8a1de5585c defer loading of the font after display size change to avoid useless
henry
parents: 15078
diff changeset
817 static int defer_counter = 0, prev_dxs = 0, prev_dys = 0;
1f8a1de5585c defer loading of the font after display size change to avoid useless
henry
parents: 15078
diff changeset
818 #endif
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
819
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
820 #ifdef HAVE_FREETYPE
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
821 // here is the right place to get screen dimensions
15085
1f8a1de5585c defer loading of the font after display size change to avoid useless
henry
parents: 15078
diff changeset
822 if (((dxs != vo_image_width)
1f8a1de5585c defer loading of the font after display size change to avoid useless
henry
parents: 15078
diff changeset
823 && (subtitle_autoscale == 2 || subtitle_autoscale == 3))
1f8a1de5585c defer loading of the font after display size change to avoid useless
henry
parents: 15078
diff changeset
824 || ((dys != vo_image_height)
1f8a1de5585c defer loading of the font after display size change to avoid useless
henry
parents: 15078
diff changeset
825 && (subtitle_autoscale == 1 || subtitle_autoscale == 3)))
1f8a1de5585c defer loading of the font after display size change to avoid useless
henry
parents: 15078
diff changeset
826 {
1f8a1de5585c defer loading of the font after display size change to avoid useless
henry
parents: 15078
diff changeset
827 // screen dimensions changed
1f8a1de5585c defer loading of the font after display size change to avoid useless
henry
parents: 15078
diff changeset
828 // wait a while to avoid useless reloading of the font
1f8a1de5585c defer loading of the font after display size change to avoid useless
henry
parents: 15078
diff changeset
829 if (dxs == prev_dxs || dys == prev_dys) {
1f8a1de5585c defer loading of the font after display size change to avoid useless
henry
parents: 15078
diff changeset
830 defer_counter++;
1f8a1de5585c defer loading of the font after display size change to avoid useless
henry
parents: 15078
diff changeset
831 } else {
1f8a1de5585c defer loading of the font after display size change to avoid useless
henry
parents: 15078
diff changeset
832 prev_dxs = dxs;
1f8a1de5585c defer loading of the font after display size change to avoid useless
henry
parents: 15078
diff changeset
833 prev_dys = dys;
1f8a1de5585c defer loading of the font after display size change to avoid useless
henry
parents: 15078
diff changeset
834 defer_counter = 0;
1f8a1de5585c defer loading of the font after display size change to avoid useless
henry
parents: 15078
diff changeset
835 }
1f8a1de5585c defer loading of the font after display size change to avoid useless
henry
parents: 15078
diff changeset
836 if (defer_counter >= FONT_LOAD_DEFER) force_load_font = 1;
1f8a1de5585c defer loading of the font after display size change to avoid useless
henry
parents: 15078
diff changeset
837 }
1f8a1de5585c defer loading of the font after display size change to avoid useless
henry
parents: 15078
diff changeset
838
1f8a1de5585c defer loading of the font after display size change to avoid useless
henry
parents: 15078
diff changeset
839 if (!vo_font || force_load_font) {
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
840 force_load_font = 0;
8635
81dbd28ef7c0 these patches let ,,oldstyle'' and freetype subtitle renderers live
arpi
parents: 8617
diff changeset
841 load_font_ft(dxs, dys);
15085
1f8a1de5585c defer loading of the font after display size change to avoid useless
henry
parents: 15078
diff changeset
842 prev_dxs = dxs;
1f8a1de5585c defer loading of the font after display size change to avoid useless
henry
parents: 15078
diff changeset
843 prev_dys = dys;
1f8a1de5585c defer loading of the font after display size change to avoid useless
henry
parents: 15078
diff changeset
844 defer_counter = 0;
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
845 }
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
846 #endif
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
847
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
848 while(obj){
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
849 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
850 int vis=obj->flags&OSDFLAG_VISIBLE;
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
851 obj->flags&=~OSDFLAG_BBOX;
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
852 switch(obj->type){
21193
a067e7e18b50 support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents: 19366
diff changeset
853 #ifdef USE_DVDNAV
a067e7e18b50 support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents: 19366
diff changeset
854 case OSDTYPE_DVDNAV:
a067e7e18b50 support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents: 19366
diff changeset
855 vo_update_nav(obj,dxs,dys);
a067e7e18b50 support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents: 19366
diff changeset
856 break;
a067e7e18b50 support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents: 19366
diff changeset
857 #endif
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
858 case OSDTYPE_SUBTITLE:
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
859 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
860 break;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
861 case OSDTYPE_PROGBAR:
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
862 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
863 break;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
864 case OSDTYPE_SPU:
7628
d6608342591d This patch adds the functionality to disable/enable subtitles while playing
arpi
parents: 7121
diff changeset
865 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
866 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
867 obj->flags|=OSDFLAG_VISIBLE|OSDFLAG_CHANGED;
6190
bd6748605681 Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents: 6110
diff changeset
868 }
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
869 else
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
870 obj->flags&=~OSDFLAG_VISIBLE;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
871 break;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
872 case OSDTYPE_OSD:
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
873 if(vo_font && vo_osd_text && vo_osd_text[0]){
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
874 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
875 obj->flags|=OSDFLAG_VISIBLE|OSDFLAG_CHANGED;
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
876 } else
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
877 obj->flags&=~OSDFLAG_VISIBLE;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
878 break;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
879 }
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
880 // check bbox:
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
881 if(!(obj->flags&OSDFLAG_BBOX)){
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
882 // we don't know, so assume the whole screen changed :(
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
883 obj->bbox.x1=obj->bbox.y1=0;
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
884 obj->bbox.x2=dxs;
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
885 obj->bbox.y2=dys;
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
886 obj->flags|=OSDFLAG_BBOX;
5664
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
887 } else {
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
888 // check bbox, reduce it if it's out of bounds (corners):
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
889 if(obj->bbox.x1<0) obj->bbox.x1=0;
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
890 if(obj->bbox.y1<0) obj->bbox.y1=0;
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
891 if(obj->bbox.x2>dxs) obj->bbox.x2=dxs;
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
892 if(obj->bbox.y2>dys) obj->bbox.y2=dys;
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
893 if(obj->flags&OSDFLAG_VISIBLE)
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
894 // debug:
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
895 mp_msg(MSGT_OSD,MSGL_DBG2,"OSD update: %d;%d %dx%d \n",
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
896 obj->bbox.x1,obj->bbox.y1,obj->bbox.x2-obj->bbox.x1,
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
897 obj->bbox.y2-obj->bbox.y1);
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
898 }
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
899 // check if visibility changed:
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
900 if(vis != (obj->flags&OSDFLAG_VISIBLE) ) obj->flags|=OSDFLAG_CHANGED;
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
901 // 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
902 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
903 obj->flags&=~OSDFLAG_FORCE_UPDATE;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
904 }
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
905 if(obj->flags&OSDFLAG_CHANGED){
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
906 chg|=1<<obj->type;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
907 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
908 }
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
909 obj=obj->next;
4081
9e581ab5e54b Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents: 3180
diff changeset
910 }
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
911 return chg;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
912 }
4081
9e581ab5e54b Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents: 3180
diff changeset
913
17566
f580a7755ac5 Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents: 16923
diff changeset
914 void vo_init_osd(void){
947
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 865
diff changeset
915 if(!draw_alpha_init_flag){
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 865
diff changeset
916 draw_alpha_init_flag=1;
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 865
diff changeset
917 vo_draw_alpha_init();
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 865
diff changeset
918 }
6110
7bea806b9c5f Improvment for spu subtitles.
albeu
parents: 5664
diff changeset
919 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
920 // 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
921 new_osd_obj(OSDTYPE_OSD);
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
922 new_osd_obj(OSDTYPE_SUBTITLE);
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
923 new_osd_obj(OSDTYPE_PROGBAR);
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
924 new_osd_obj(OSDTYPE_SPU);
21193
a067e7e18b50 support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents: 19366
diff changeset
925 #ifdef USE_DVDNAV
a067e7e18b50 support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents: 19366
diff changeset
926 new_osd_obj(OSDTYPE_DVDNAV);
a067e7e18b50 support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents: 19366
diff changeset
927 #endif
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
928 #ifdef HAVE_FREETYPE
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
929 force_load_font = 1;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
930 #endif
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
931 }
947
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 865
diff changeset
932
5642
eb0cb6185e6c osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents: 5640
diff changeset
933 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
934
eb0cb6185e6c osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents: 5640
diff changeset
935 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
936 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
937 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
938 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
939 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
940 (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
941 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
942 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
943 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
944 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
945 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
946 }
eb0cb6185e6c osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents: 5640
diff changeset
947 // 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
948 }
5645
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
949 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
950 }
eb0cb6185e6c osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents: 5640
diff changeset
951 }
eb0cb6185e6c osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents: 5640
diff changeset
952
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
953 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
954 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
955 vo_update_osd(dxs,dys);
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
956 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
957 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
958 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
959 switch(obj->type){
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
960 case OSDTYPE_SPU:
6190
bd6748605681 Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents: 6110
diff changeset
961 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
962 break;
21193
a067e7e18b50 support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents: 19366
diff changeset
963 #ifdef USE_DVDNAV
a067e7e18b50 support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents: 19366
diff changeset
964 case OSDTYPE_DVDNAV:
a067e7e18b50 support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents: 19366
diff changeset
965 #endif
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
966 case OSDTYPE_OSD:
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
967 case OSDTYPE_SUBTITLE:
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
968 case OSDTYPE_PROGBAR:
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
969 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
970 break;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
971 }
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
972 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
973 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
974 }
eb0cb6185e6c osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents: 5640
diff changeset
975 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
976 obj=obj->next;
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
977 }
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
978 }
3034
24d3dca4e813 DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents: 2498
diff changeset
979
4807
156482788caf osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents: 4773
diff changeset
980 static int vo_osd_changed_status = 0;
156482788caf osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents: 4773
diff changeset
981
156482788caf osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents: 4773
diff changeset
982 int vo_osd_changed(int new_value)
156482788caf osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents: 4773
diff changeset
983 {
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
984 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
985 int ret = vo_osd_changed_status;
156482788caf osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents: 4773
diff changeset
986 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
987
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
988 while(obj){
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
989 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
990 obj=obj->next;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
991 }
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
992
4807
156482788caf osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents: 4773
diff changeset
993 return ret;
156482788caf osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents: 4773
diff changeset
994 }
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
995
5645
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
996 // BBBBBBBBBBBB AAAAAAAAAAAAA BBBBBBBBBBB
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
997 // BBBBBBBBBBBB BBBBBBBBBBBBB
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
998 // BBBBBBB
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
999
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
1000 // 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
1001 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
1002 mp_osd_obj_t* obj=vo_osd_list;
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
1003 while(obj){
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
1004 if(obj->flags&OSDFLAG_VISIBLE){
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
1005 if( (obj->bbox.x1<=x2 && obj->bbox.x2>=x1) &&
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
1006 (obj->bbox.y1<=y2 && obj->bbox.y2>=y1) ) return 1;
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
1007 }
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
1008 obj=obj->next;
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
1009 }
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
1010 return 0;
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
1011 }