annotate sub/sub.c @ 35418:cedb0ba2b5c6

Move the code to set guiInfo's Track, Chapter and Angle start values. Set them before checking whether there is any media opened, because with no media opened we clear the counters.
author ib
date Thu, 29 Nov 2012 14:11:03 +0000
parents 317eee237d0f
children 19e0fc815a0e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
28446
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28401
diff changeset
1 /*
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28401
diff changeset
2 * This file is part of MPlayer.
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28401
diff changeset
3 *
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28401
diff changeset
4 * MPlayer is free software; you can redistribute it and/or modify
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28401
diff changeset
5 * it under the terms of the GNU General Public License as published by
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28401
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28401
diff changeset
7 * (at your option) any later version.
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28401
diff changeset
8 *
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28401
diff changeset
9 * MPlayer is distributed in the hope that it will be useful,
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28401
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28401
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28401
diff changeset
12 * GNU General Public License for more details.
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28401
diff changeset
13 *
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28401
diff changeset
14 * You should have received a copy of the GNU General Public License along
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28401
diff changeset
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28401
diff changeset
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
7681eab10aea Add standard license headers, unify header formatting.
diego
parents: 28401
diff changeset
17 */
5503
a531a579f005 #include cleanup
arpi
parents: 5294
diff changeset
18
a531a579f005 #include cleanup
arpi
parents: 5294
diff changeset
19 #include <stdio.h>
a531a579f005 #include cleanup
arpi
parents: 5294
diff changeset
20 #include <stdlib.h>
7003
60a473935d7d warning fixes by Sylvain Petreolle <spetreolle@yahoo.fr>
arpi
parents: 6190
diff changeset
21 #include <string.h>
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
22
4088
4435dc3b8bef Add DVD subtitles to menoder
kmkaplan
parents: 4087
diff changeset
23 #include "config.h"
28594
df67d03dde3b Convert HAVE_MALLOC_H into a 0/1 definition, fixes the warning:
diego
parents: 28586
diff changeset
24 #if HAVE_MALLOC_H
8123
9fc45fe0d444 *HUGE* set of compiler warning fixes, unused variables removal
arpi
parents: 7628
diff changeset
25 #include <malloc.h>
9fc45fe0d444 *HUGE* set of compiler warning fixes, unused variables removal
arpi
parents: 7628
diff changeset
26 #endif
9fc45fe0d444 *HUGE* set of compiler warning fixes, unused variables removal
arpi
parents: 7628
diff changeset
27
21200
c7b5dd2b2291 better nav highlight handling
ben
parents: 21193
diff changeset
28 #include "stream/stream.h"
c7b5dd2b2291 better nav highlight handling
ben
parents: 21193
diff changeset
29 #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
30 #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
31
29759
d287e2785570 Move teletext specific code from stream into libmpcodecs.
cehoyos
parents: 29660
diff changeset
32 #include "libmpcodecs/dec_teletext.h"
24378
9cea788cf2b3 warning fix:
diego
parents: 24344
diff changeset
33 #include "osdep/timer.h"
23903
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
34
32043
f6249bc89c38 Move extern declarations used by both mplayer.c and mencoder.c to mpcommon.h.
diego
parents: 30702
diff changeset
35 #include "mpcommon.h"
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
36 #include "mp_msg.h"
16923
a6a03ff1ddef Added translatable messages for OSD localization to help/help_mp-en.h
ptt
parents: 16839
diff changeset
37 #include "help_mp.h"
32467
fbe5c829c69b Move libvo/sub.[ch] from libvo to sub.
cigaes
parents: 32466
diff changeset
38 #include "libvo/video_out.h"
fbe5c829c69b Move libvo/sub.[ch] from libvo to sub.
cigaes
parents: 32466
diff changeset
39 #include "font_load.h"
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
40 #include "sub.h"
32467
fbe5c829c69b Move libvo/sub.[ch] from libvo to sub.
cigaes
parents: 32466
diff changeset
41 #include "spudec.h"
19366
614f445786af Reuse UTF-8 reading code in libavutil
reimar
parents: 18950
diff changeset
42 #include "libavutil/common.h"
202
6ad0715dfac8 grey+alpha rendering support (for .sub)
arpi_esp
parents:
diff changeset
43
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
44 #define NEW_SPLITTING
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 // Structures needed for the new splitting algorithm.
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
48 // osd_text_t contains the single subtitle word.
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
49 // osd_text_p is used to mark the lines of subtitles
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
50 struct osd_text_t {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
51 int osd_kerning, //kerning with the previous word
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
52 osd_length, //orizontal length inside the bbox
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
53 text_length, //number of characters
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
54 *text; //characters
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
55 struct osd_text_t *prev,
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
56 *next;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
57 };
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
58
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
59 struct osd_text_p {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
60 int value;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
61 struct osd_text_t *ott;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
62 struct osd_text_p *prev,
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
63 *next;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
64 };
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
65 //^
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
66
24046
7e2808fb1807 Identifiers should not start with two underscores.
diego
parents: 23903
diff changeset
67 char * sub_osd_names[]={
16923
a6a03ff1ddef Added translatable messages for OSD localization to help/help_mp-en.h
ptt
parents: 16839
diff changeset
68 MSGTR_VO_SUB_Seekbar,
a6a03ff1ddef Added translatable messages for OSD localization to help/help_mp-en.h
ptt
parents: 16839
diff changeset
69 MSGTR_VO_SUB_Play,
a6a03ff1ddef Added translatable messages for OSD localization to help/help_mp-en.h
ptt
parents: 16839
diff changeset
70 MSGTR_VO_SUB_Pause,
a6a03ff1ddef Added translatable messages for OSD localization to help/help_mp-en.h
ptt
parents: 16839
diff changeset
71 MSGTR_VO_SUB_Stop,
a6a03ff1ddef Added translatable messages for OSD localization to help/help_mp-en.h
ptt
parents: 16839
diff changeset
72 MSGTR_VO_SUB_Rewind,
a6a03ff1ddef Added translatable messages for OSD localization to help/help_mp-en.h
ptt
parents: 16839
diff changeset
73 MSGTR_VO_SUB_Forward,
a6a03ff1ddef Added translatable messages for OSD localization to help/help_mp-en.h
ptt
parents: 16839
diff changeset
74 MSGTR_VO_SUB_Clock,
a6a03ff1ddef Added translatable messages for OSD localization to help/help_mp-en.h
ptt
parents: 16839
diff changeset
75 MSGTR_VO_SUB_Contrast,
a6a03ff1ddef Added translatable messages for OSD localization to help/help_mp-en.h
ptt
parents: 16839
diff changeset
76 MSGTR_VO_SUB_Saturation,
a6a03ff1ddef Added translatable messages for OSD localization to help/help_mp-en.h
ptt
parents: 16839
diff changeset
77 MSGTR_VO_SUB_Volume,
a6a03ff1ddef Added translatable messages for OSD localization to help/help_mp-en.h
ptt
parents: 16839
diff changeset
78 MSGTR_VO_SUB_Brightness,
23568
519e42b716aa The audio balance feature implemented with af_pan.
zuxy
parents: 23510
diff changeset
79 MSGTR_VO_SUB_Hue,
519e42b716aa The audio balance feature implemented with af_pan.
zuxy
parents: 23510
diff changeset
80 MSGTR_VO_SUB_Balance
2498
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
81 };
24046
7e2808fb1807 Identifiers should not start with two underscores.
diego
parents: 23903
diff changeset
82 char * sub_osd_names_short[] ={ "", "|>", "||", "[]", "<<" , ">>", "", "", "", "", "", "", "" };
2498
38bb41c48d1f never declare variables in *.h files, pls
nick
parents: 2205
diff changeset
83
213
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
84 //static int vo_font_loaded=-1;
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
85 font_desc_t* vo_font=NULL;
23338
2a66d95355f0 add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents: 21582
diff changeset
86 font_desc_t* sub_font=NULL;
202
6ad0715dfac8 grey+alpha rendering support (for .sub)
arpi_esp
parents:
diff changeset
87
1991
dee4b2ea5e5b add gui support to config scripts, and fixed some warning.
pontscho
parents: 1878
diff changeset
88 unsigned char* vo_osd_text=NULL;
23903
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
89 void* vo_osd_teletext_page=NULL;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
90 int vo_osd_teletext_half = 0;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
91 int vo_osd_teletext_mode=0;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
92 int vo_osd_teletext_format=0;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
93 int vo_osd_teletext_scale=0;
803
b25a887b6054 sub splitting patch applied by Vlada V.Dubsky@sh.cvut.cz
arpi_esp
parents: 726
diff changeset
94 int sub_unicode=0;
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
95 int sub_utf8=0;
4773
976bf6a9ded5 subtitle positioning patch by Jiri Svoboda
atmos4
parents: 4088
diff changeset
96 int sub_pos=100;
8583
4c18c4e7f34e -subwidth
arpi
parents: 8578
diff changeset
97 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
98 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
99 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
100 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
101 int sub_bg_alpha=0;
10263
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents: 9036
diff changeset
102 int sub_justify=0;
27341
e7c989f7a7c9 Start unifying names of internal preprocessor directives.
diego
parents: 25851
diff changeset
103 #ifdef CONFIG_DVDNAV
21219
8258747951d7 keep nav highlight event in dvdnav priv structure
ben
parents: 21200
diff changeset
104 static nav_highlight_t nav_hl;
8258747951d7 keep nav highlight event in dvdnav priv structure
ben
parents: 21200
diff changeset
105 #endif
213
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
106
5664
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
107 // return the real height of a char:
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
108 static inline int get_height(int c,int h){
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
109 int font;
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
110 if ((font=vo_font->font[c])>=0)
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
111 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
112 return h;
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
113 }
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
114
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
115 // 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
116 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
117 {
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
118 int dststride = obj->stride;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
119 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
120 int srcskip = stride-w;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
121 int i, j;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
122 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
123 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
124 unsigned char *bs = src;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
125 unsigned char *as = srca;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
126
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
127 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
128 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
129 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
130 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
131 return;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
132 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28594
diff changeset
133
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
134 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
135 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
136 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
137 if (*as) {
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
138 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
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 b+= dstskip;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
142 a+= dstskip;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
143 bs+= srcskip;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
144 as+= srcskip;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
145 }
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
146 }
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
147
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
148 // 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
149 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
150 {
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
151 int len;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
152 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
153 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
154 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
155 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
156 if (obj->allocated<len) {
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
157 obj->allocated = len;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
158 free(obj->bitmap_buffer);
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
159 free(obj->alpha_buffer);
32763
ce9c41d97bfd Do not pointlessly cast the return value of memalign().
diego
parents: 32537
diff changeset
160 obj->bitmap_buffer = memalign(16, len);
ce9c41d97bfd Do not pointlessly cast the return value of memalign().
diego
parents: 32537
diff changeset
161 obj->alpha_buffer = memalign(16, len);
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
162 }
8617
6ffbe7608013 Me: -sub-bg-* would be nicer. "Background" is usually shortened as "bg", not "bkg".
rathann
parents: 8601
diff changeset
163 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
164 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
165 }
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
166
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
167 // renders the buffer
34492
1495455e6d22 Move static keyword to the beginning of function declarations.
diego
parents: 33340
diff changeset
168 static inline void vo_draw_text_from_buffer(mp_osd_obj_t* obj,
1495455e6d22 Move static keyword to the beginning of function declarations.
diego
parents: 33340
diff changeset
169 void (*draw_alpha)(int x0, int y0,
1495455e6d22 Move static keyword to the beginning of function declarations.
diego
parents: 33340
diff changeset
170 int w, int h,
1495455e6d22 Move static keyword to the beginning of function declarations.
diego
parents: 33340
diff changeset
171 unsigned char *src,
1495455e6d22 Move static keyword to the beginning of function declarations.
diego
parents: 33340
diff changeset
172 unsigned char *srca,
1495455e6d22 Move static keyword to the beginning of function declarations.
diego
parents: 33340
diff changeset
173 int stride))
1495455e6d22 Move static keyword to the beginning of function declarations.
diego
parents: 33340
diff changeset
174 {
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
175 if (obj->allocated > 0) {
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
176 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
177 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
178 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
179 obj->bitmap_buffer,
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
180 obj->alpha_buffer,
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
181 obj->stride);
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
182 }
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
183 }
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
184
21582
239f2c145b2f Mark utf8_get_char parameter as const and fix a compiler warning
reimar
parents: 21581
diff changeset
185 unsigned utf8_get_char(const char **str) {
239f2c145b2f Mark utf8_get_char parameter as const and fix a compiler warning
reimar
parents: 21581
diff changeset
186 const uint8_t *strp = (const uint8_t *)*str;
19366
614f445786af Reuse UTF-8 reading code in libavutil
reimar
parents: 18950
diff changeset
187 unsigned c;
614f445786af Reuse UTF-8 reading code in libavutil
reimar
parents: 18950
diff changeset
188 GET_UTF8(c, *strp++, goto no_utf8;);
21582
239f2c145b2f Mark utf8_get_char parameter as const and fix a compiler warning
reimar
parents: 21581
diff changeset
189 *str = (const char *)strp;
18717
0f99a5fe9c7f Support UTF8 in OSD text
reimar
parents: 18716
diff changeset
190 return c;
0f99a5fe9c7f Support UTF8 in OSD text
reimar
parents: 18716
diff changeset
191
0f99a5fe9c7f Support UTF8 in OSD text
reimar
parents: 18716
diff changeset
192 no_utf8:
21582
239f2c145b2f Mark utf8_get_char parameter as const and fix a compiler warning
reimar
parents: 21581
diff changeset
193 strp = (const uint8_t *)*str;
18717
0f99a5fe9c7f Support UTF8 in OSD text
reimar
parents: 18716
diff changeset
194 c = *strp++;
21582
239f2c145b2f Mark utf8_get_char parameter as const and fix a compiler warning
reimar
parents: 21581
diff changeset
195 *str = (const char *)strp;
18717
0f99a5fe9c7f Support UTF8 in OSD text
reimar
parents: 18716
diff changeset
196 return c;
0f99a5fe9c7f Support UTF8 in OSD text
reimar
parents: 18716
diff changeset
197 }
0f99a5fe9c7f Support UTF8 in OSD text
reimar
parents: 18716
diff changeset
198
34492
1495455e6d22 Move static keyword to the beginning of function declarations.
diego
parents: 33340
diff changeset
199 static inline void vo_update_text_osd(mp_osd_obj_t *obj, int dxs, int dys)
1495455e6d22 Move static keyword to the beginning of function declarations.
diego
parents: 33340
diff changeset
200 {
21582
239f2c145b2f Mark utf8_get_char parameter as const and fix a compiler warning
reimar
parents: 21581
diff changeset
201 const char *cp=vo_osd_text;
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
202 int x=20;
5664
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
203 int h=0;
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
204 int font;
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
205
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
206 obj->bbox.x1=obj->x=x;
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
207 obj->bbox.y1=obj->y=10;
202
6ad0715dfac8 grey+alpha rendering support (for .sub)
arpi_esp
parents:
diff changeset
208
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
209 while (*cp){
18717
0f99a5fe9c7f Support UTF8 in OSD text
reimar
parents: 18716
diff changeset
210 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
211 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
212 x+=vo_font->width[c]+vo_font->charspace;
5664
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
213 h=get_height(c,h);
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
214 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28594
diff changeset
215
5664
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
216 obj->bbox.x2=x-vo_font->charspace;
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
217 obj->bbox.y2=obj->bbox.y1+h;
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
218 obj->flags|=OSDFLAG_BBOX;
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
219
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
220 alloc_buf(obj);
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
221
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
222 cp=vo_osd_text;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
223 x = obj->x;
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
224 while (*cp){
18717
0f99a5fe9c7f Support UTF8 in OSD text
reimar
parents: 18716
diff changeset
225 uint16_t c=utf8_get_char(&cp);
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
226 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
227 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
228 vo_font->width[c],
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
229 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
230 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
231 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
232 vo_font->pic_a[font]->w);
213
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
233 x+=vo_font->width[c]+vo_font->charspace;
6ec8f6ab6cb1 subtitle+OSD font support
arpi_esp
parents: 202
diff changeset
234 }
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
235 }
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
236
27341
e7c989f7a7c9 Start unifying names of internal preprocessor directives.
diego
parents: 25851
diff changeset
237 #ifdef CONFIG_DVDNAV
21219
8258747951d7 keep nav highlight event in dvdnav priv structure
ben
parents: 21200
diff changeset
238 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
239 nav_hl.sx = sx;
8258747951d7 keep nav highlight event in dvdnav priv structure
ben
parents: 21200
diff changeset
240 nav_hl.sy = sy;
8258747951d7 keep nav highlight event in dvdnav priv structure
ben
parents: 21200
diff changeset
241 nav_hl.ex = ex;
8258747951d7 keep nav highlight event in dvdnav priv structure
ben
parents: 21200
diff changeset
242 nav_hl.ey = ey;
8258747951d7 keep nav highlight event in dvdnav priv structure
ben
parents: 21200
diff changeset
243 }
8258747951d7 keep nav highlight event in dvdnav priv structure
ben
parents: 21200
diff changeset
244
34492
1495455e6d22 Move static keyword to the beginning of function declarations.
diego
parents: 33340
diff changeset
245 static inline void vo_update_nav(mp_osd_obj_t *obj, int dxs, int dys,
1495455e6d22 Move static keyword to the beginning of function declarations.
diego
parents: 33340
diff changeset
246 int left_border, int top_border,
1495455e6d22 Move static keyword to the beginning of function declarations.
diego
parents: 33340
diff changeset
247 int right_border, int bottom_border,
1495455e6d22 Move static keyword to the beginning of function declarations.
diego
parents: 33340
diff changeset
248 int orig_w, int orig_h)
1495455e6d22 Move static keyword to the beginning of function declarations.
diego
parents: 33340
diff changeset
249 {
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
250 int len;
28255
aeefca2deed3 Change vo_draw_text to a vo_draw_text_ext function which draws DVD navigation
reimar
parents: 28051
diff changeset
251 int sx = nav_hl.sx, sy = nav_hl.sy;
aeefca2deed3 Change vo_draw_text to a vo_draw_text_ext function which draws DVD navigation
reimar
parents: 28051
diff changeset
252 int ex = nav_hl.ex, ey = nav_hl.ey;
aeefca2deed3 Change vo_draw_text to a vo_draw_text_ext function which draws DVD navigation
reimar
parents: 28051
diff changeset
253 int scaled_w = dxs - left_border - right_border;
aeefca2deed3 Change vo_draw_text to a vo_draw_text_ext function which draws DVD navigation
reimar
parents: 28051
diff changeset
254 int scaled_h = dys - top_border - bottom_border;
aeefca2deed3 Change vo_draw_text to a vo_draw_text_ext function which draws DVD navigation
reimar
parents: 28051
diff changeset
255 if (scaled_w != orig_w) {
aeefca2deed3 Change vo_draw_text to a vo_draw_text_ext function which draws DVD navigation
reimar
parents: 28051
diff changeset
256 sx = sx * scaled_w / orig_w;
aeefca2deed3 Change vo_draw_text to a vo_draw_text_ext function which draws DVD navigation
reimar
parents: 28051
diff changeset
257 ex = ex * scaled_w / orig_w;
aeefca2deed3 Change vo_draw_text to a vo_draw_text_ext function which draws DVD navigation
reimar
parents: 28051
diff changeset
258 }
aeefca2deed3 Change vo_draw_text to a vo_draw_text_ext function which draws DVD navigation
reimar
parents: 28051
diff changeset
259 if (scaled_h != orig_h) {
aeefca2deed3 Change vo_draw_text to a vo_draw_text_ext function which draws DVD navigation
reimar
parents: 28051
diff changeset
260 sy = sy * scaled_h / orig_h;
aeefca2deed3 Change vo_draw_text to a vo_draw_text_ext function which draws DVD navigation
reimar
parents: 28051
diff changeset
261 ey = ey * scaled_h / orig_h;
aeefca2deed3 Change vo_draw_text to a vo_draw_text_ext function which draws DVD navigation
reimar
parents: 28051
diff changeset
262 }
aeefca2deed3 Change vo_draw_text to a vo_draw_text_ext function which draws DVD navigation
reimar
parents: 28051
diff changeset
263 sx += left_border; ex += left_border;
aeefca2deed3 Change vo_draw_text to a vo_draw_text_ext function which draws DVD navigation
reimar
parents: 28051
diff changeset
264 sy += top_border; ey += top_border;
aeefca2deed3 Change vo_draw_text to a vo_draw_text_ext function which draws DVD navigation
reimar
parents: 28051
diff changeset
265 sx = FFMIN(FFMAX(sx, 0), dxs);
aeefca2deed3 Change vo_draw_text to a vo_draw_text_ext function which draws DVD navigation
reimar
parents: 28051
diff changeset
266 ex = FFMIN(FFMAX(ex, 0), dxs);
aeefca2deed3 Change vo_draw_text to a vo_draw_text_ext function which draws DVD navigation
reimar
parents: 28051
diff changeset
267 sy = FFMIN(FFMAX(sy, 0), dys);
aeefca2deed3 Change vo_draw_text to a vo_draw_text_ext function which draws DVD navigation
reimar
parents: 28051
diff changeset
268 ey = FFMIN(FFMAX(ey, 0), dys);
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
269
28255
aeefca2deed3 Change vo_draw_text to a vo_draw_text_ext function which draws DVD navigation
reimar
parents: 28051
diff changeset
270 obj->bbox.x1 = obj->x = sx;
aeefca2deed3 Change vo_draw_text to a vo_draw_text_ext function which draws DVD navigation
reimar
parents: 28051
diff changeset
271 obj->bbox.y1 = obj->y = sy;
aeefca2deed3 Change vo_draw_text to a vo_draw_text_ext function which draws DVD navigation
reimar
parents: 28051
diff changeset
272 obj->bbox.x2 = ex;
aeefca2deed3 Change vo_draw_text to a vo_draw_text_ext function which draws DVD navigation
reimar
parents: 28051
diff changeset
273 obj->bbox.y2 = ey;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28594
diff changeset
274
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
275 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
276 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
277 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
278 memset (obj->alpha_buffer, OSD_NAV_BOX_ALPHA, len);
21364
d81ffbf9615f EMISSINGBRAIN: No, OSD objects of size 0 sure are _not_ visible.
reimar
parents: 21219
diff changeset
279 obj->flags |= OSDFLAG_BBOX | OSDFLAG_CHANGED;
d81ffbf9615f EMISSINGBRAIN: No, OSD objects of size 0 sure are _not_ visible.
reimar
parents: 21219
diff changeset
280 if (obj->bbox.y2 > obj->bbox.y1 && obj->bbox.x2 > obj->bbox.x1)
d81ffbf9615f EMISSINGBRAIN: No, OSD objects of size 0 sure are _not_ visible.
reimar
parents: 21219
diff changeset
281 obj->flags |= OSDFLAG_VISIBLE;
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
282 }
a067e7e18b50 support for dvdnav menu buttons overlay as simple alpha boxes (rework from Otvos Attila's series of patches)
ben
parents: 19366
diff changeset
283 #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
284
23903
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
285 // renders char to a big per-object buffer where alpha and bitmap are separated
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
286 static void tt_draw_alpha_buf(mp_osd_obj_t* obj, int x0,int y0, int w,int h, unsigned char* src, int stride,int fg,int bg,int alpha)
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
287 {
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
288 int dststride = obj->stride;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
289 int dstskip = obj->stride-w;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
290 int srcskip = stride-w;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
291 int i, j;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
292 unsigned char *b = obj->bitmap_buffer + (y0-obj->bbox.y1)*dststride + (x0-obj->bbox.x1);
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
293 unsigned char *a = obj->alpha_buffer + (y0-obj->bbox.y1)*dststride + (x0-obj->bbox.x1);
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
294 unsigned char *bs = src;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
295 if (x0 < obj->bbox.x1 || x0+w > obj->bbox.x2 || y0 < obj->bbox.y1 || y0+h > obj->bbox.y2) {
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
296 mp_msg(MSGT_OSD,MSGL_ERR,"tt osd text out of range: bbox [%d %d %d %d], txt [%d %d %d %d]\n",
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
297 obj->bbox.x1, obj->bbox.x2, obj->bbox.y1, obj->bbox.y2,
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
298 x0, x0+w, y0, y0+h);
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
299 return;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
300 }
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
301 for (i = 0; i < h; i++) {
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
302 for (j = 0; j < w; j++, b++, a++, bs++) {
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
303 *b=(fg-bg)*(*bs)/255+bg;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
304 *a=alpha;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
305 }
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
306 b+= dstskip;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
307 a+= dstskip;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
308 bs+= srcskip;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
309 }
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
310 }
34492
1495455e6d22 Move static keyword to the beginning of function declarations.
diego
parents: 33340
diff changeset
311 static inline void vo_update_text_teletext(mp_osd_obj_t *obj, int dxs, int dys)
23903
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
312 {
24292
ca146808e926 Proper support for flashing chars in teletext pages.
voroshil
parents: 24046
diff changeset
313 int h=0,w=0,i,j,font,flashon;
23903
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
314 int wm,hm;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
315 int color;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
316 int x,y,x0,y0;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
317 int cols,rows;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
318 int wm12;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
319 int hm13;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
320 int hm23;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
321 int start_row,max_rows;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
322 int b,ax[6],ay[6],aw[6],ah[6];
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
323 tt_char tc;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
324 tt_char* tdp=vo_osd_teletext_page;
29821
ed46f577f157 Change type of teletext color specification from unsigned char
reimar
parents: 29809
diff changeset
325 static const uint8_t colors[8]={1,85,150,226,70,105,179,254};
23903
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
326 unsigned char* buf[9];
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
327
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
328 obj->flags|=OSDFLAG_CHANGED|OSDFLAG_VISIBLE;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
329 if (!tdp || !vo_osd_teletext_mode) {
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
330 obj->flags&=~OSDFLAG_VISIBLE;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
331 return;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
332 }
24292
ca146808e926 Proper support for flashing chars in teletext pages.
voroshil
parents: 24046
diff changeset
333 flashon=(GetTimer()/1000000)%2;
23903
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
334 switch(vo_osd_teletext_half){
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
335 case TT_ZOOM_TOP_HALF:
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
336 start_row=0;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
337 max_rows=VBI_ROWS/2;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
338 break;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
339 case TT_ZOOM_BOTTOM_HALF:
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
340 start_row=VBI_ROWS/2;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
341 max_rows=VBI_ROWS/2;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
342 break;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
343 default:
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
344 start_row=0;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
345 max_rows=VBI_ROWS;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
346 break;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
347 }
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
348 wm=0;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
349 for(i=start_row;i<max_rows;i++){
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
350 for(j=0;j<VBI_COLUMNS;j++){
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
351 tc=tdp[i*VBI_COLUMNS+j];
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
352 if(!tc.ctl && !tc.gfx)
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
353 {
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
354 render_one_glyph(vo_font, tc.unicode);
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
355 if (wm<vo_font->width[tc.unicode])
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
356 wm=vo_font->width[tc.unicode];
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
357 }
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
358 }
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
359 }
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
360
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
361 hm=vo_font->height+1;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
362 wm=dxs*hm*max_rows/(dys*VBI_COLUMNS);
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
363
29822
60563cd70955 Fix compilation of teletext code without freetype support
reimar
parents: 29821
diff changeset
364 #ifdef CONFIG_FREETYPE
23903
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
365 //very simple teletext font auto scaling
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
366 if(!vo_osd_teletext_scale && hm*(max_rows+1)>dys){
29660
1331380992e2 Fix teletext font autoscaling.
cehoyos
parents: 29263
diff changeset
367 osd_font_scale_factor*=1.0*(dys)/((max_rows+1)*hm);
23903
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
368 force_load_font=1;
29660
1331380992e2 Fix teletext font autoscaling.
cehoyos
parents: 29263
diff changeset
369 vo_osd_teletext_scale=osd_font_scale_factor;
23903
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
370 obj->flags&=~OSDFLAG_VISIBLE;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
371 return;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
372 }
29822
60563cd70955 Fix compilation of teletext code without freetype support
reimar
parents: 29821
diff changeset
373 #endif
23903
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
374
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
375 cols=dxs/wm;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
376 rows=dys/hm;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
377
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
378 if(cols>VBI_COLUMNS)
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
379 cols=VBI_COLUMNS;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
380 if(rows>max_rows)
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
381 rows=max_rows;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
382 w=cols*wm-vo_font->charspace;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
383 h=rows*hm-vo_font->charspace;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
384
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
385 if(w<dxs)
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
386 x0=(dxs-w)/2;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
387 else
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
388 x0=0;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
389 if(h<dys)
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
390 y0=(dys-h)/2;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
391 else
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
392 y0=0;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
393
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
394 wm12=wm>>1;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
395 hm13=(hm+1)/3;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
396 hm23=hm13<<1;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
397
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
398 for(i=0;i<6;i+=2){
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
399 ax[i+0]=0;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
400 aw[i+0]=wm12;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
401
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
402 ax[i+1]=wm12;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
403 aw[i+1]=wm-wm12;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
404 }
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
405
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
406 for(i=0;i<2;i++){
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
407 ay[i+0]=0;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
408 ah[i+0]=hm13;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
409
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
410 ay[i+2]=hm13;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
411 ah[i+2]=hm-hm23;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
412
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
413 ay[i+4]=hm-hm13;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
414 ah[i+4]=hm13;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
415 }
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
416
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
417 obj->x = 0;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
418 obj->y = 0;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
419 obj->bbox.x1 = x0;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
420 obj->bbox.y1 = y0;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
421 obj->bbox.x2 = x0+w;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
422 obj->bbox.y2 = y0+h;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
423 obj->flags |= OSDFLAG_BBOX;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
424 alloc_buf(obj);
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
425
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
426 for(i=0;i<9;i++)
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
427 buf[i]=malloc(wm*hm);
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
428
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
429 //alpha
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
430 if(vo_osd_teletext_format==TT_FORMAT_OPAQUE ||vo_osd_teletext_format==TT_FORMAT_OPAQUE_INV)
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
431 color=1;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
432 else
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
433 color=200;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
434 memset(buf[8],color,wm*hm);
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
435 //colors
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
436 if(vo_osd_teletext_format==TT_FORMAT_OPAQUE ||vo_osd_teletext_format==TT_FORMAT_TRANSPARENT){
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
437 for(i=0;i<8;i++){
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
438 memset(buf[i],(unsigned char)(1.0*(255-color)*colors[i]/255),wm*hm);
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
439 }
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
440 }else{
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
441 for(i=0;i<8;i++)
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
442 memset(buf[i],(unsigned char)(1.0*(255-color)*colors[7-i]/255),wm*hm);
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
443 }
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
444
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
445 y=y0;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
446 for(i=0;i<rows;i++){
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
447 x=x0;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
448 for(j=0;j<cols;j++){
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
449 tc=tdp[(i+start_row)*VBI_COLUMNS+j];
24344
09d402672398 Implement boxes for subtitle teletext pages.
voroshil
parents: 24292
diff changeset
450 if (tc.hidden) { x+=wm; continue;}
24292
ca146808e926 Proper support for flashing chars in teletext pages.
voroshil
parents: 24046
diff changeset
451 if(!tc.gfx || (tc.flh && !flashon)){
23903
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
452 /* Rendering one text character */
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
453 draw_alpha_buf(obj,x,y,wm,hm,buf[tc.bg],buf[8],wm);
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
454 if(tc.unicode!=0x20 && tc.unicode!=0x00 && !tc.ctl &&
24292
ca146808e926 Proper support for flashing chars in teletext pages.
voroshil
parents: 24046
diff changeset
455 (!tc.flh || flashon) &&
23903
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
456 (font=vo_font->font[tc.unicode])>=0 && y+hm<dys){
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
457 tt_draw_alpha_buf(obj,x,y,vo_font->width[tc.unicode],vo_font->height,
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
458 vo_font->pic_b[font]->bmp+vo_font->start[tc.unicode]-vo_font->charspace*vo_font->pic_a[font]->w,
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
459 vo_font->pic_b[font]->w,
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
460 buf[tc.fg][0],buf[tc.bg][0],buf[8][0]);
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
461 }
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
462 }else{
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
463 /*
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
464 Rendering one graphics character
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
465 TODO: support for separated graphics symbols (where six rectangles does not touch each other)
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
466
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
467 +--+ +--+ 87654321
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
468 |01| |12| --------
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
469 |10| <= |34| <= 00100110 <= 0x26
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
470 |01| |56|
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
471 +--+ +--+
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
472
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
473 (0:wm/2) (wm/2:wm-wm/2)
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
474
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
475 ********** *********** (0:hm/3)
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
476 *** **** **** ****
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28594
diff changeset
477 *** 1 **** **** 2 ****
23903
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
478 *** **** **** ****
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
479 ********** ***********
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
480 ********** ***********
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
481
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
482 ********** *********** (hm/3:hm-2*hm/3)
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
483 ********** ***********
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
484 *** **** **** ****
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
485 *** 3 **** **** 4 ****
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
486 *** **** **** ****
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
487 ********** ***********
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
488 ********** ***********
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
489 ********** ***********
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
490
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
491 ********** *********** (hm-hm/3:hm/3)
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
492 *** **** **** ****
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
493 *** 5 **** **** 6 ****
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28594
diff changeset
494 *** **** **** ****
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28594
diff changeset
495 ********** ***********
23903
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
496 ********** ***********
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
497
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28594
diff changeset
498 */
23903
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
499 if(tc.gfx>1){ //separated gfx
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
500 for(b=0;b<6;b++){
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
501 color=(tc.unicode>>b)&1?tc.fg:tc.bg;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
502 draw_alpha_buf(obj,x+ax[b]+1,y+ay[b]+1,aw[b]-2,ah[b]-2,buf[color],buf[8],wm);
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
503 }
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
504 //separated gfx (background borders)
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
505 //vertical
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
506 draw_alpha_buf(obj,x ,y,1,hm,buf[tc.bg],buf[8],wm);
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
507 draw_alpha_buf(obj,x+ax[1]-1,y,2,hm,buf[tc.bg],buf[8],wm);
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
508 draw_alpha_buf(obj,x+ax[1]+aw[1]-1,y,wm-ax[1]-aw[1]+1,hm,buf[tc.bg],buf[8],wm);
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
509 //horizontal
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
510 draw_alpha_buf(obj,x,y ,wm,1,buf[tc.bg],buf[8],wm);
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
511 draw_alpha_buf(obj,x,y+ay[0]+ah[0]-1,wm,2,buf[tc.bg],buf[8],wm);
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
512 draw_alpha_buf(obj,x,y+ay[2]+ah[2]-1,wm,2,buf[tc.bg],buf[8],wm);
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
513 draw_alpha_buf(obj,x,y+ay[4]+ah[4]-1,wm,hm-ay[4]-ah[4]+1,buf[tc.bg],buf[8],wm);
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
514 }else{
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
515 for(b=0;b<6;b++){
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
516 color=(tc.unicode>>b)&1?tc.fg:tc.bg;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
517 draw_alpha_buf(obj,x+ax[b],y+ay[b],aw[b],ah[b],buf[color],buf[8],wm);
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
518 }
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
519 }
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
520 }
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
521 x+=wm;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
522 }
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
523 y+=hm;
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
524 }
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
525 for(i=0;i<9;i++)
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
526 free(buf[i]);
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
527 }
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
528
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
529 int vo_osd_progbar_type=-1;
1726
38871427a131 corrections to OSD progbar position calculations
atlka
parents: 1602
diff changeset
530 int vo_osd_progbar_value=100; // 0..256
34686
ff81a1db421e Allow to set the OST progress position.
cigaes
parents: 34492
diff changeset
531 int progbar_align=50;
1726
38871427a131 corrections to OSD progbar position calculations
atlka
parents: 1602
diff changeset
532
38871427a131 corrections to OSD progbar position calculations
atlka
parents: 1602
diff changeset
533 // if we have n=256 bars then OSD progbar looks like below
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28594
diff changeset
534 //
1878
96ae64356ea0 corrections to OSD mark position
atlka
parents: 1852
diff changeset
535 // 0 1 2 3 ... 256 <= vo_osd_progbar_value
96ae64356ea0 corrections to OSD mark position
atlka
parents: 1852
diff changeset
536 // | | | | |
1726
38871427a131 corrections to OSD progbar position calculations
atlka
parents: 1602
diff changeset
537 // [ === === === ... === ]
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28594
diff changeset
538 //
1726
38871427a131 corrections to OSD progbar position calculations
atlka
parents: 1602
diff changeset
539 // the above schema is rescalled to n=elems bars
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
540
34492
1495455e6d22 Move static keyword to the beginning of function declarations.
diego
parents: 33340
diff changeset
541 static inline void vo_update_text_progbar(mp_osd_obj_t *obj, int dxs, int dys)
1495455e6d22 Move static keyword to the beginning of function declarations.
diego
parents: 33340
diff changeset
542 {
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
543
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
544 obj->flags|=OSDFLAG_CHANGED|OSDFLAG_VISIBLE;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28594
diff changeset
545
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
546 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
547 obj->flags&=~OSDFLAG_VISIBLE;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
548 return;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
549 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28594
diff changeset
550
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
551 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
552 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
553 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
554 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
555 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
556
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28594
diff changeset
557 // calculate bbox corners:
5664
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
558 { int h=0;
34686
ff81a1db421e Allow to set the OST progress position.
cigaes
parents: 34492
diff changeset
559 int y=((dys-vo_font->height)*progbar_align)/100;
1548
eee7951a23af changes according to proper subfont bar positioning and char spaceing - sub.c
atlka
parents: 1524
diff changeset
560 int delimw=vo_font->width[OSD_PB_START]
1549
787c053b314c minor changes in sub.c
atlka
parents: 1548
diff changeset
561 +vo_font->width[OSD_PB_END]
787c053b314c minor changes in sub.c
atlka
parents: 1548
diff changeset
562 +vo_font->charspace;
1548
eee7951a23af changes according to proper subfont bar positioning and char spaceing - sub.c
atlka
parents: 1524
diff changeset
563 int width=(2*dxs-3*delimw)/3;
1549
787c053b314c minor changes in sub.c
atlka
parents: 1548
diff changeset
564 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
565 int elems=width/charw;
1549
787c053b314c minor changes in sub.c
atlka
parents: 1548
diff changeset
566 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
567 int delta = 0;
5664
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
568 h=get_height(OSD_PB_START,h);
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
569 h=get_height(OSD_PB_END,h);
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
570 h=get_height(OSD_PB_0,h);
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
571 h=get_height(OSD_PB_1,h);
8422
1f1cc58e8e65 progbar osd buffer height adjustment fix
henry
parents: 8361
diff changeset
572 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
573 delta = vo_font->width[vo_osd_progbar_type]+vo_font->spacewidth;
1f1cc58e8e65 progbar osd buffer height adjustment fix
henry
parents: 8361
diff changeset
574 delta = (x-delta > 0) ? delta : x;
1f1cc58e8e65 progbar osd buffer height adjustment fix
henry
parents: 8361
diff changeset
575 h=get_height(vo_osd_progbar_type,h);
1f1cc58e8e65 progbar osd buffer height adjustment fix
henry
parents: 8361
diff changeset
576 }
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
577 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
578 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
579 obj->bbox.x2=x+width+delimw;
5664
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
580 obj->bbox.y2=y+h; //vo_font->height;
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
581 obj->flags|=OSDFLAG_BBOX;
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
582 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
583 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
584 }
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
585
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
586 alloc_buf(obj);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28594
diff changeset
587
8794
056fc0a8b3d2 sanity check
henry
parents: 8635
diff changeset
588 {
056fc0a8b3d2 sanity check
henry
parents: 8635
diff changeset
589 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
590 if (vo_osd_progbar_type>0 && vo_font->font[vo_osd_progbar_type]>=0){
056fc0a8b3d2 sanity check
henry
parents: 8635
diff changeset
591 minw += vo_font->width[vo_osd_progbar_type]+vo_font->charspace+vo_font->spacewidth;
056fc0a8b3d2 sanity check
henry
parents: 8635
diff changeset
592 }
056fc0a8b3d2 sanity check
henry
parents: 8635
diff changeset
593 if (obj->bbox.x2 - obj->bbox.x1 < minw) return; // space too small, don't render anything
056fc0a8b3d2 sanity check
henry
parents: 8635
diff changeset
594 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28594
diff changeset
595
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
596 // render it:
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
597 { unsigned char *s;
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
598 unsigned char *sa;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
599 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
600 int x=obj->x;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
601 int y=obj->y;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
602 int c,font;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
603 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
604 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
605
1726
38871427a131 corrections to OSD progbar position calculations
atlka
parents: 1602
diff changeset
606 if (vo_osd_progbar_value<=0)
38871427a131 corrections to OSD progbar position calculations
atlka
parents: 1602
diff changeset
607 mark=0;
1878
96ae64356ea0 corrections to OSD mark position
atlka
parents: 1852
diff changeset
608 else {
96ae64356ea0 corrections to OSD mark position
atlka
parents: 1852
diff changeset
609 int ev=vo_osd_progbar_value*elems;
96ae64356ea0 corrections to OSD mark position
atlka
parents: 1852
diff changeset
610 mark=ev>>8;
96ae64356ea0 corrections to OSD mark position
atlka
parents: 1852
diff changeset
611 if (ev & 0xFF) mark++;
96ae64356ea0 corrections to OSD mark position
atlka
parents: 1852
diff changeset
612 if (mark>elems) mark=elems;
96ae64356ea0 corrections to OSD mark position
atlka
parents: 1852
diff changeset
613 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28594
diff changeset
614
1727
9da2b587b029 changes according to OSD calculations
atlka
parents: 1726
diff changeset
615
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
616 // printf("osd.progbar width=%d xpos=%d\n",width,x);
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
617
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
618 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
619 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
620 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
621 draw_alpha_buf(obj,(xp<0?0:xp),y,
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
622 vo_font->width[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
623 vo_font->pic_a[font]->h,
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
624 vo_font->pic_b[font]->bmp+vo_font->start[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
625 vo_font->pic_a[font]->bmp+vo_font->start[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
626 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
627 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28594
diff changeset
628
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
629 c=OSD_PB_START;
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
630 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
631 draw_alpha_buf(obj,x,y,
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
632 vo_font->width[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
633 vo_font->pic_a[font]->h,
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
634 vo_font->pic_b[font]->bmp+vo_font->start[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
635 vo_font->pic_a[font]->bmp+vo_font->start[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
636 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
637 x+=vo_font->width[c]+vo_font->charspace;
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
638
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
639 c=OSD_PB_0;
1602
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
640 if ((font=vo_font->font[c])>=0){
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
641 w=vo_font->width[c];
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
642 h=vo_font->pic_a[font]->h;
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
643 s=vo_font->pic_b[font]->bmp+vo_font->start[c];
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
644 sa=vo_font->pic_a[font]->bmp+vo_font->start[c];
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
645 st=vo_font->pic_a[font]->w;
2204
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
646 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
647 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
648 x+=charw;
2204
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
649 } while(--i);
1602
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
650 }
202
6ad0715dfac8 grey+alpha rendering support (for .sub)
arpi_esp
parents:
diff changeset
651
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
652 c=OSD_PB_1;
1602
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
653 if ((font=vo_font->font[c])>=0){
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
654 w=vo_font->width[c];
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
655 h=vo_font->pic_a[font]->h;
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
656 s =vo_font->pic_b[font]->bmp+vo_font->start[c];
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
657 sa=vo_font->pic_a[font]->bmp+vo_font->start[c];
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
658 st=vo_font->pic_a[font]->w;
2204
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
659 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
660 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
661 x+=charw;
2204
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
662 } while(--i);
1602
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
663 }
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
664
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
665 c=OSD_PB_END;
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
666 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
667 draw_alpha_buf(obj,x,y,
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
668 vo_font->width[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
669 vo_font->pic_a[font]->h,
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
670 vo_font->pic_b[font]->bmp+vo_font->start[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
671 vo_font->pic_a[font]->bmp+vo_font->start[c],
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
672 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
673 // 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
674
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
675 }
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
676 // vo_osd_progbar_value=(vo_osd_progbar_value+1)&0xFF;
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
677
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
678 }
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
679
254
57f0156416e3 use subreader's sub struct
arpi_esp
parents: 218
diff changeset
680 subtitle* vo_sub=NULL;
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
681
34492
1495455e6d22 Move static keyword to the beginning of function declarations.
diego
parents: 33340
diff changeset
682 static inline void vo_update_text_sub(mp_osd_obj_t *obj, int dxs, int dys)
1495455e6d22 Move static keyword to the beginning of function declarations.
diego
parents: 33340
diff changeset
683 {
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
684 unsigned char *t;
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
685 int c,i,j,l,x,y,font,prevc,counter;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
686 int k;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
687 int xsize;
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
688 int xmin=dxs,xmax=0;
1591
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
689 int h,lasth;
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
690 int xtblc, utblc;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28594
diff changeset
691
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
692 obj->flags|=OSDFLAG_CHANGED|OSDFLAG_VISIBLE;
7628
d6608342591d This patch adds the functionality to disable/enable subtitles while playing
arpi
parents: 7121
diff changeset
693
23338
2a66d95355f0 add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents: 21582
diff changeset
694 if(!vo_sub || !sub_font || !sub_visibility || (sub_font->font[40]<0)){
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
695 obj->flags&=~OSDFLAG_VISIBLE;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
696 return;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
697 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28594
diff changeset
698
5664
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
699 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
700 obj->params.subtitle.lines=0;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
701
1602
48f589cf639b minor changes according to OSD
atlka
parents: 1591
diff changeset
702 // 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
703 i=k=lasth=0;
23338
2a66d95355f0 add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents: 21582
diff changeset
704 h=sub_font->height;
1591
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
705 l=vo_sub->lines;
86a192179276 draw speedups, cut text if too many lines
atlka
parents: 1574
diff changeset
706
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
707 {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
708 struct osd_text_t *osl, *cp_ott, *tmp_ott, *tmp;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
709 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
710 *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
711 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
712
2204
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
713 while (l) {
23338
2a66d95355f0 add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents: 21582
diff changeset
714 xsize = -sub_font->charspace;
2204
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
715 l--;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28594
diff changeset
716 t=vo_sub->text[i++];
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
717 char_position = 0;
21581
37c795807a1d Another simplification
reimar
parents: 21580
diff changeset
718 char_seq = calloc(strlen(t), sizeof(int));
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
719
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
720 prevc = -1;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
721
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
722 otp = NULL;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
723 osl = NULL;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
724 x = 1;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
725
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
726 // reading the subtitle words from vo_sub->text[]
21580
8a710a7b68ea Reuse utf8_get_char in subtitle rendering code.
reimar
parents: 21443
diff changeset
727 while (*t) {
8a710a7b68ea Reuse utf8_get_char in subtitle rendering code.
reimar
parents: 21443
diff changeset
728 if (sub_utf8)
8a710a7b68ea Reuse utf8_get_char in subtitle rendering code.
reimar
parents: 21443
diff changeset
729 c = utf8_get_char(&t);
8a710a7b68ea Reuse utf8_get_char in subtitle rendering code.
reimar
parents: 21443
diff changeset
730 else if ((c = *t++) >= 0x80 && sub_unicode)
8a710a7b68ea Reuse utf8_get_char in subtitle rendering code.
reimar
parents: 21443
diff changeset
731 c = (c<<8) + *t++;
1501
d40f2b686846 changes according to -utf8 option, draw_osd() function added
atlka
parents: 1109
diff changeset
732 if (k==MAX_UCS){
21580
8a710a7b68ea Reuse utf8_get_char in subtitle rendering code.
reimar
parents: 21443
diff changeset
733 t += strlen(t); // end here
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
734 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
735 }
2204
28901a4122c8 optimizations and corrections
atlka
parents: 2176
diff changeset
736 if (!c) c++; // avoid UCS 0
23338
2a66d95355f0 add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents: 21582
diff changeset
737 render_one_glyph(sub_font, c);
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
738
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
739 if (c == ' ') {
30702
9fc9d1e788aa Do not cast the results of malloc/calloc/realloc.
diego
parents: 30556
diff changeset
740 struct osd_text_t *tmp_ott = calloc(1, sizeof(struct osd_text_t));
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
741
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
742 if (osl == NULL) {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
743 osl = cp_ott = tmp_ott;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
744 } else {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
745 tmp_ott->prev = cp_ott;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
746 cp_ott->next = tmp_ott;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
747 tmp_ott->osd_kerning =
23338
2a66d95355f0 add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents: 21582
diff changeset
748 sub_font->charspace + sub_font->width[' '];
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
749 cp_ott = tmp_ott;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
750 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
751 tmp_ott->osd_length = xsize;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
752 tmp_ott->text_length = char_position;
30702
9fc9d1e788aa Do not cast the results of malloc/calloc/realloc.
diego
parents: 30556
diff changeset
753 tmp_ott->text = malloc(char_position * sizeof(int));
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
754 for (counter = 0; counter < char_position; ++counter)
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
755 tmp_ott->text[counter] = char_seq[counter];
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
756 char_position = 0;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
757 xsize = 0;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
758 prevc = c;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
759 } else {
23338
2a66d95355f0 add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents: 21582
diff changeset
760 int delta_xsize = sub_font->width[c] + sub_font->charspace + kerning(sub_font, prevc, c);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28594
diff changeset
761
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
762 if (xsize + delta_xsize <= dxs) {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
763 if (!x) x = 1;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
764 prevc = c;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
765 char_seq[char_position++] = c;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
766 xsize += delta_xsize;
23338
2a66d95355f0 add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents: 21582
diff changeset
767 if ((!suboverlap_enabled) && ((font = sub_font->font[c]) >= 0)) {
2a66d95355f0 add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents: 21582
diff changeset
768 if (sub_font->pic_a[font]->h > h) {
2a66d95355f0 add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents: 21582
diff changeset
769 h = sub_font->pic_a[font]->h;
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
770 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
771 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
772 } else {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
773 if (x) {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
774 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
775 x = 0;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
776 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
777 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
778 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
779 }// for len (all words from subtitle line read)
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
780
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
781 // 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
782 {
30702
9fc9d1e788aa Do not cast the results of malloc/calloc/realloc.
diego
parents: 30556
diff changeset
783 struct osd_text_t *tmp_ott = calloc(1, sizeof(struct osd_text_t));
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
784
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
785 if (osl == NULL) {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
786 osl = cp_ott = tmp_ott;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
787 } else {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
788 tmp_ott->prev = cp_ott;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
789 cp_ott->next = tmp_ott;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
790 tmp_ott->osd_kerning =
23338
2a66d95355f0 add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents: 21582
diff changeset
791 sub_font->charspace + sub_font->width[' '];
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
792 cp_ott = tmp_ott;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
793 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
794 tmp_ott->osd_length = xsize;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
795 tmp_ott->text_length = char_position;
30702
9fc9d1e788aa Do not cast the results of malloc/calloc/realloc.
diego
parents: 30556
diff changeset
796 tmp_ott->text = malloc(char_position * sizeof(int));
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
797 for (counter = 0; counter < char_position; ++counter)
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
798 tmp_ott->text[counter] = char_seq[counter];
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
799 char_position = 0;
23338
2a66d95355f0 add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents: 21582
diff changeset
800 xsize = -sub_font->charspace;
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
801 }
18716
e75ab7767078 Missing free for malloced char_seq in OSD code
reimar
parents: 17566
diff changeset
802 free(char_seq);
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
803
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
804 if (osl != NULL) {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
805 int value = 0, exit = 0, minimum = 0;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
806
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
807 // otp will contain the chain of the osd subtitle lines coming from the single vo_sub line.
30702
9fc9d1e788aa Do not cast the results of malloc/calloc/realloc.
diego
parents: 30556
diff changeset
808 otp = tmp_otp = calloc(1, sizeof(struct osd_text_p));
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
809 tmp_otp->ott = osl;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
810 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
811 do {
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
812 value += tmp_ott->osd_kerning + tmp_ott->osd_length;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
813 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
814 } 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
815 if (tmp_ott != NULL) {
30702
9fc9d1e788aa Do not cast the results of malloc/calloc/realloc.
diego
parents: 30556
diff changeset
816 struct osd_text_p *tmp = calloc(1, sizeof(struct osd_text_p));
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
817
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
818 tmp_otp->value = value;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
819 tmp_otp->next = tmp;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
820 tmp->prev = tmp_otp;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
821 tmp_otp = tmp;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
822 tmp_otp->ott = tmp_ott;
23338
2a66d95355f0 add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents: 21582
diff changeset
823 value = -2 * sub_font->charspace - sub_font->width[' '];
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
824 } else {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
825 tmp_otp->value = value;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
826 exit = 1;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
827 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
828 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
829
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
830
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
831 #ifdef NEW_SPLITTING
24595
85f669a84e7a cosmetics: misc typo fixes
diego
parents: 24582
diff changeset
832 // minimum holds the 'sum of the differences in length among the lines',
85f669a84e7a cosmetics: misc typo fixes
diego
parents: 24582
diff changeset
833 // a measure of the evenness of the lengths of the lines
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
834 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
835 pmt = tmp_otp->next;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
836 while (pmt != NULL) {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
837 minimum += abs(tmp_otp->value - pmt->value);
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
838 pmt = pmt->next;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
839 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
840 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
841
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
842 if (otp->next != NULL) {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
843 int mem1, mem2;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
844 struct osd_text_p *mem, *hold;
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
845
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
846 exit = 0;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
847 // until the last word of a line can be moved to the beginning of following line
24595
85f669a84e7a cosmetics: misc typo fixes
diego
parents: 24582
diff changeset
848 // reducing the 'sum of the differences in length among the lines', it is done
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
849 while (exit == 0) {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
850 hold = NULL;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
851 exit = 1;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
852 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
853 pmt = tmp_otp->next;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
854 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
855 if (pmt->value + tmp->osd_length + pmt->ott->osd_kerning <= xlimit) {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
856 mem1 = tmp_otp->value;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
857 mem2 = pmt->value;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
858 tmp_otp->value = mem1 - tmp->osd_length - tmp->osd_kerning;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
859 pmt->value = mem2 + tmp->osd_length + pmt->ott->osd_kerning;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
860
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
861 value = 0;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
862 for (mem = otp; mem->next != NULL; mem = mem->next) {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
863 pmt = mem->next;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
864 while (pmt != NULL) {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
865 value += abs(mem->value - pmt->value);
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
866 pmt = pmt->next;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
867 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
868 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
869 if (value < minimum) {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
870 minimum = value;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
871 hold = tmp_otp;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
872 exit = 0;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
873 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
874 tmp_otp->value = mem1;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
875 tmp_otp->next->value = mem2;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
876 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
877 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
878 // merging
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
879 if (exit == 0) {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
880 tmp_otp = hold;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
881 pmt = tmp_otp->next;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
882 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
883 mem1 = tmp_otp->value;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
884 mem2 = pmt->value;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
885 tmp_otp->value = mem1 - tmp->osd_length - tmp->osd_kerning;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
886 pmt->value = mem2 + tmp->osd_length + pmt->ott->osd_kerning;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
887 pmt->ott = tmp;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
888 }//~merging
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
889 }//~while(exit == 0)
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
890 }//~if(otp->next!=NULL)
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
891 #endif
8534
922ce27eb683 This patch adds support for vertical subtitle alignment
arpi
parents: 8451
diff changeset
892
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
893 // adding otp (containing splitted lines) to otp chain
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
894 if (otp_sub == NULL) {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
895 otp_sub = otp;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
896 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
897 } else {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
898 //updating ott chain
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
899 tmp = otp_sub->ott;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
900 while (tmp->next != NULL) tmp = tmp->next;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
901 tmp->next = otp->ott;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
902 otp->ott->prev = tmp;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
903 //attaching new subtitle line at the end
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
904 otp_sub_tmp->next = otp;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
905 otp->prev = otp_sub_tmp;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
906 do
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
907 otp_sub_tmp = otp_sub_tmp->next;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
908 while (otp_sub_tmp->next != NULL);
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
909 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
910 }//~ if(osl != NULL)
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
911 } // while
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
912
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
913 // write lines into utbl
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
914 xtblc = 0;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
915 utblc = 0;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
916 obj->y = dys;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
917 obj->params.subtitle.lines = 0;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
918 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
919
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
920 if ((obj->params.subtitle.lines++) >= MAX_UCSLINES)
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
921 break;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
922
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
923 if (h > obj->y) { // out of the screen so end parsing
23338
2a66d95355f0 add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents: 21582
diff changeset
924 obj->y -= lasth - sub_font->height; // correct the y position
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
925 break;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
926 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
927 xsize = tmp_otp->value;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
928 obj->params.subtitle.xtbl[xtblc++] = (dxs - xsize) / 2;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
929 if (xmin > (dxs - xsize) / 2)
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
930 xmin = (dxs - xsize) / 2;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
931 if (xmax < (dxs + xsize) / 2)
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
932 xmax = (dxs + xsize) / 2;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
933
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
934 tmp = (tmp_otp->next == NULL) ? NULL : tmp_otp->next->ott;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
935 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
936 for (counter = 0; counter < tmp_ott->text_length; ++counter) {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
937 if (utblc > MAX_UCS) {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
938 break;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
939 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
940 c = tmp_ott->text[counter];
23338
2a66d95355f0 add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents: 21582
diff changeset
941 render_one_glyph(sub_font, c);
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
942 obj->params.subtitle.utbl[utblc++] = c;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
943 k++;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
944 }
35220
349f03d4c033 Fix potential out-of-bounds write due to breaking
reimar
parents: 34686
diff changeset
945 if (utblc > MAX_UCS)
349f03d4c033 Fix potential out-of-bounds write due to breaking
reimar
parents: 34686
diff changeset
946 break;
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
947 obj->params.subtitle.utbl[utblc++] = ' ';
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
948 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
949 obj->params.subtitle.utbl[utblc - 1] = 0;
23338
2a66d95355f0 add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents: 21582
diff changeset
950 obj->y -= sub_font->height;
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
951 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
952 if(obj->params.subtitle.lines)
23338
2a66d95355f0 add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents: 21582
diff changeset
953 obj->y = dys - ((obj->params.subtitle.lines - 1) * sub_font->height + sub_font->pic_a[sub_font->font[40]]->h);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28594
diff changeset
954
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
955 // free memory
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
956 if (otp_sub != NULL) {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
957 for (tmp = otp_sub->ott; tmp->next != NULL; free(tmp->prev)) {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
958 free(tmp->text);
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
959 tmp = tmp->next;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
960 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
961 free(tmp->text);
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
962 free(tmp);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28594
diff changeset
963
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
964 for(pmt = otp_sub; pmt->next != NULL; free(pmt->prev)) {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
965 pmt = pmt->next;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
966 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
967 free(pmt);
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
968 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28594
diff changeset
969
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
970 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
971 /// vertical alignment
8534
922ce27eb683 This patch adds support for vertical subtitle alignment
arpi
parents: 8451
diff changeset
972 h = dys - obj->y;
16838
fb79161e09f4 reverse incorrect sub alignment change, ok'd by diego
rfelker
parents: 16834
diff changeset
973 if (sub_alignment == 2)
8534
922ce27eb683 This patch adds support for vertical subtitle alignment
arpi
parents: 8451
diff changeset
974 obj->y = dys * sub_pos / 100 - h;
922ce27eb683 This patch adds support for vertical subtitle alignment
arpi
parents: 8451
diff changeset
975 else if (sub_alignment == 1)
922ce27eb683 This patch adds support for vertical subtitle alignment
arpi
parents: 8451
diff changeset
976 obj->y = dys * sub_pos / 100 - h / 2;
922ce27eb683 This patch adds support for vertical subtitle alignment
arpi
parents: 8451
diff changeset
977 else
922ce27eb683 This patch adds support for vertical subtitle alignment
arpi
parents: 8451
diff changeset
978 obj->y = dys * sub_pos / 100;
922ce27eb683 This patch adds support for vertical subtitle alignment
arpi
parents: 8451
diff changeset
979
922ce27eb683 This patch adds support for vertical subtitle alignment
arpi
parents: 8451
diff changeset
980 if (obj->y < 0)
922ce27eb683 This patch adds support for vertical subtitle alignment
arpi
parents: 8451
diff changeset
981 obj->y = 0;
35275
317eee237d0f Support subpos values > 100 that allow the subtitles
reimar
parents: 35220
diff changeset
982 if (sub_pos <= 100 && obj->y > dys - h)
317eee237d0f Support subpos values > 100 that allow the subtitles
reimar
parents: 35220
diff changeset
983 obj->y = FFMAX(dys - h, 0);
8534
922ce27eb683 This patch adds support for vertical subtitle alignment
arpi
parents: 8451
diff changeset
984 if (obj->y > dys - h)
35275
317eee237d0f Support subpos values > 100 that allow the subtitles
reimar
parents: 35220
diff changeset
985 h = FFMAX(dys - obj->y, 0);
8534
922ce27eb683 This patch adds support for vertical subtitle alignment
arpi
parents: 8451
diff changeset
986
922ce27eb683 This patch adds support for vertical subtitle alignment
arpi
parents: 8451
diff changeset
987 obj->bbox.y2 = obj->y + h;
922ce27eb683 This patch adds support for vertical subtitle alignment
arpi
parents: 8451
diff changeset
988
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
989 // calculate bbox:
10263
0df8816f4665 TiVo demuxer and sub-cc/osd decoder
arpi
parents: 9036
diff changeset
990 if (sub_justify) xmin = 10;
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
991 obj->bbox.x1=xmin;
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
992 obj->bbox.x2=xmax;
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
993 obj->bbox.y1=obj->y;
23338
2a66d95355f0 add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents: 21582
diff changeset
994 // obj->bbox.y2=obj->y+obj->params.subtitle.lines*sub_font->height;
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
995 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
996
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
997 alloc_buf(obj);
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
998
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
999 y = obj->y;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28594
diff changeset
1000
13343
1a4b6e575484 This time is a patch to improve subtitle alignment management. It
faust3
parents: 12794
diff changeset
1001 obj->alignment = 0;
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
1002 switch(vo_sub->alignment) {
13343
1a4b6e575484 This time is a patch to improve subtitle alignment management. It
faust3
parents: 12794
diff changeset
1003 case SUB_ALIGNMENT_BOTTOMLEFT:
1a4b6e575484 This time is a patch to improve subtitle alignment management. It
faust3
parents: 12794
diff changeset
1004 case SUB_ALIGNMENT_MIDDLELEFT:
1a4b6e575484 This time is a patch to improve subtitle alignment management. It
faust3
parents: 12794
diff changeset
1005 case SUB_ALIGNMENT_TOPLEFT:
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
1006 obj->alignment |= 0x1;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
1007 break;
13343
1a4b6e575484 This time is a patch to improve subtitle alignment management. It
faust3
parents: 12794
diff changeset
1008 case SUB_ALIGNMENT_BOTTOMRIGHT:
1a4b6e575484 This time is a patch to improve subtitle alignment management. It
faust3
parents: 12794
diff changeset
1009 case SUB_ALIGNMENT_MIDDLERIGHT:
1a4b6e575484 This time is a patch to improve subtitle alignment management. It
faust3
parents: 12794
diff changeset
1010 case SUB_ALIGNMENT_TOPRIGHT:
1a4b6e575484 This time is a patch to improve subtitle alignment management. It
faust3
parents: 12794
diff changeset
1011 obj->alignment |= 0x2;
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
1012 break;
13343
1a4b6e575484 This time is a patch to improve subtitle alignment management. It
faust3
parents: 12794
diff changeset
1013 case SUB_ALIGNMENT_BOTTOMCENTER:
1a4b6e575484 This time is a patch to improve subtitle alignment management. It
faust3
parents: 12794
diff changeset
1014 case SUB_ALIGNMENT_MIDDLECENTER:
1a4b6e575484 This time is a patch to improve subtitle alignment management. It
faust3
parents: 12794
diff changeset
1015 case SUB_ALIGNMENT_TOPCENTER:
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
1016 default:
13343
1a4b6e575484 This time is a patch to improve subtitle alignment management. It
faust3
parents: 12794
diff changeset
1017 obj->alignment |= 0x0;
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
1018 }
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
1019
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
1020 i=j=0;
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
1021 if ((l = obj->params.subtitle.lines)) {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
1022 for(counter = dxs; i < l; ++i)
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
1023 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
1024 for (i = 0; i < l; ++i) {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
1025 switch (obj->alignment&0x3) {
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
1026 case 1:
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
1027 // left
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
1028 x = counter;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
1029 break;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
1030 case 2:
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
1031 // right
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
1032 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
1033 break;
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
1034 default:
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
1035 //center
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
1036 x = obj->params.subtitle.xtbl[i];
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
1037 }
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
1038 prevc = -1;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
1039 while ((c=obj->params.subtitle.utbl[j++])){
23338
2a66d95355f0 add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents: 21582
diff changeset
1040 x += kerning(sub_font,prevc,c);
2a66d95355f0 add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents: 21582
diff changeset
1041 if ((font=sub_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
1042 draw_alpha_buf(obj,x,y,
23338
2a66d95355f0 add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents: 21582
diff changeset
1043 sub_font->width[c],
2a66d95355f0 add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents: 21582
diff changeset
1044 sub_font->pic_a[font]->h+y<obj->dys ? sub_font->pic_a[font]->h : obj->dys-y,
2a66d95355f0 add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents: 21582
diff changeset
1045 sub_font->pic_b[font]->bmp+sub_font->start[c],
2a66d95355f0 add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents: 21582
diff changeset
1046 sub_font->pic_a[font]->bmp+sub_font->start[c],
2a66d95355f0 add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents: 21582
diff changeset
1047 sub_font->pic_a[font]->w);
2a66d95355f0 add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents: 21582
diff changeset
1048 x+=sub_font->width[c]+sub_font->charspace;
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
1049 prevc = c;
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
1050 }
23338
2a66d95355f0 add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents: 21582
diff changeset
1051 y+=sub_font->height;
10916
c36db88bfbc4 Subtitle alignment & smart splitting by Salvatore Falco
henry
parents: 10263
diff changeset
1052 }
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
1053 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28594
diff changeset
1054
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1055 }
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1056
34492
1495455e6d22 Move static keyword to the beginning of function declarations.
diego
parents: 33340
diff changeset
1057 static inline void vo_update_spudec_sub(mp_osd_obj_t* obj, int dxs, int dys)
6190
bd6748605681 Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents: 6110
diff changeset
1058 {
bd6748605681 Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents: 6110
diff changeset
1059 unsigned int bbox[4];
bd6748605681 Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents: 6110
diff changeset
1060 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
1061 obj->bbox.x1 = bbox[0];
bd6748605681 Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents: 6110
diff changeset
1062 obj->bbox.x2 = bbox[1];
bd6748605681 Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents: 6110
diff changeset
1063 obj->bbox.y1 = bbox[2];
bd6748605681 Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents: 6110
diff changeset
1064 obj->bbox.y2 = bbox[3];
bd6748605681 Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents: 6110
diff changeset
1065 obj->flags |= OSDFLAG_BBOX;
bd6748605681 Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents: 6110
diff changeset
1066 }
bd6748605681 Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents: 6110
diff changeset
1067
34492
1495455e6d22 Move static keyword to the beginning of function declarations.
diego
parents: 33340
diff changeset
1068 static inline void vo_draw_spudec_sub(mp_osd_obj_t *obj,
1495455e6d22 Move static keyword to the beginning of function declarations.
diego
parents: 33340
diff changeset
1069 void (*draw_alpha)(int x0, int y0,
1495455e6d22 Move static keyword to the beginning of function declarations.
diego
parents: 33340
diff changeset
1070 int w, int h,
1495455e6d22 Move static keyword to the beginning of function declarations.
diego
parents: 33340
diff changeset
1071 unsigned char *src,
1495455e6d22 Move static keyword to the beginning of function declarations.
diego
parents: 33340
diff changeset
1072 unsigned char *srca,
1495455e6d22 Move static keyword to the beginning of function declarations.
diego
parents: 33340
diff changeset
1073 int stride))
6190
bd6748605681 Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents: 6110
diff changeset
1074 {
bd6748605681 Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents: 6110
diff changeset
1075 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
1076 }
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
1077
3034
24d3dca4e813 DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents: 2498
diff changeset
1078 void *vo_spudec=NULL;
4081
9e581ab5e54b Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents: 3180
diff changeset
1079 void *vo_vobsub=NULL;
3034
24d3dca4e813 DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents: 2498
diff changeset
1080
947
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 865
diff changeset
1081 static int draw_alpha_init_flag=0;
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
1082
28051
9e739bdb049c Get rid of pointless 'extern' keywords.
diego
parents: 28049
diff changeset
1083 void vo_draw_alpha_init(void);
1109
a013b2124f05 -Wall like fixes
al3x
parents: 947
diff changeset
1084
7067
b395b1240954 fix dxr3 subtitle handling and add some optimizations
pontscho
parents: 7003
diff changeset
1085 mp_osd_obj_t* vo_osd_list=NULL;
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
1086
18950
a943bc3f26c8 Make some functions static.
uau
parents: 18935
diff changeset
1087 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
1088 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
1089 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
1090 osd->next=vo_osd_list;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1091 vo_osd_list=osd;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1092 osd->type=type;
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
1093 osd->alpha_buffer = NULL;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
1094 osd->bitmap_buffer = NULL;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
1095 osd->allocated = -1;
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1096 return osd;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1097 }
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1098
17566
f580a7755ac5 Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents: 16923
diff changeset
1099 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
1100 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
1101 while(obj){
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1102 mp_osd_obj_t* next=obj->next;
32537
8fa2f43cb760 Remove most of the NULL pointer check before free all over the code
cboesch
parents: 32467
diff changeset
1103 free(obj->alpha_buffer);
8fa2f43cb760 Remove most of the NULL pointer check before free all over the code
cboesch
parents: 32467
diff changeset
1104 free(obj->bitmap_buffer);
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1105 free(obj);
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1106 obj=next;
4081
9e581ab5e54b Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents: 3180
diff changeset
1107 }
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1108 vo_osd_list=NULL;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1109 }
4081
9e581ab5e54b Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents: 3180
diff changeset
1110
15085
1f8a1de5585c defer loading of the font after display size change to avoid useless
henry
parents: 15078
diff changeset
1111 #define FONT_LOAD_DEFER 6
1f8a1de5585c defer loading of the font after display size change to avoid useless
henry
parents: 15078
diff changeset
1112
30556
358ac046eccc libvo: Mark functions not used outside of their files as static.
diego
parents: 29822
diff changeset
1113 static int vo_update_osd_ext(int dxs,int dys, int left_border, int top_border,
358ac046eccc libvo: Mark functions not used outside of their files as static.
diego
parents: 29822
diff changeset
1114 int right_border, int bottom_border, int orig_w,
358ac046eccc libvo: Mark functions not used outside of their files as static.
diego
parents: 29822
diff changeset
1115 int orig_h)
358ac046eccc libvo: Mark functions not used outside of their files as static.
diego
parents: 29822
diff changeset
1116 {
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1117 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
1118 int chg=0;
27393
4876c89bafdd Rename font-related preprocessor directives.
diego
parents: 27370
diff changeset
1119 #ifdef CONFIG_FREETYPE
15085
1f8a1de5585c defer loading of the font after display size change to avoid useless
henry
parents: 15078
diff changeset
1120 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
1121 #endif
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
1122
27393
4876c89bafdd Rename font-related preprocessor directives.
diego
parents: 27370
diff changeset
1123 #ifdef CONFIG_FREETYPE
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
1124 // 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
1125 if (((dxs != vo_image_width)
1f8a1de5585c defer loading of the font after display size change to avoid useless
henry
parents: 15078
diff changeset
1126 && (subtitle_autoscale == 2 || subtitle_autoscale == 3))
1f8a1de5585c defer loading of the font after display size change to avoid useless
henry
parents: 15078
diff changeset
1127 || ((dys != vo_image_height)
1f8a1de5585c defer loading of the font after display size change to avoid useless
henry
parents: 15078
diff changeset
1128 && (subtitle_autoscale == 1 || subtitle_autoscale == 3)))
1f8a1de5585c defer loading of the font after display size change to avoid useless
henry
parents: 15078
diff changeset
1129 {
1f8a1de5585c defer loading of the font after display size change to avoid useless
henry
parents: 15078
diff changeset
1130 // screen dimensions changed
1f8a1de5585c defer loading of the font after display size change to avoid useless
henry
parents: 15078
diff changeset
1131 // 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
1132 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
1133 defer_counter++;
1f8a1de5585c defer loading of the font after display size change to avoid useless
henry
parents: 15078
diff changeset
1134 } else {
1f8a1de5585c defer loading of the font after display size change to avoid useless
henry
parents: 15078
diff changeset
1135 prev_dxs = dxs;
1f8a1de5585c defer loading of the font after display size change to avoid useless
henry
parents: 15078
diff changeset
1136 prev_dys = dys;
1f8a1de5585c defer loading of the font after display size change to avoid useless
henry
parents: 15078
diff changeset
1137 defer_counter = 0;
1f8a1de5585c defer loading of the font after display size change to avoid useless
henry
parents: 15078
diff changeset
1138 }
1f8a1de5585c defer loading of the font after display size change to avoid useless
henry
parents: 15078
diff changeset
1139 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
1140 }
1f8a1de5585c defer loading of the font after display size change to avoid useless
henry
parents: 15078
diff changeset
1141
23338
2a66d95355f0 add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents: 21582
diff changeset
1142 if (force_load_font) {
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
1143 force_load_font = 0;
25851
9ebd00825df2 Allow independent scaling of vo_font and sub_font.
reimar
parents: 24595
diff changeset
1144 load_font_ft(dxs, dys, &vo_font, font_name, osd_font_scale_factor);
23742
93c871be0258 Use -font for subtitles when -subfont is not given, patch by kiriuja
zuxy
parents: 23573
diff changeset
1145 if (sub_font_name)
25851
9ebd00825df2 Allow independent scaling of vo_font and sub_font.
reimar
parents: 24595
diff changeset
1146 load_font_ft(dxs, dys, &sub_font, sub_font_name, text_font_scale_factor);
23742
93c871be0258 Use -font for subtitles when -subfont is not given, patch by kiriuja
zuxy
parents: 23573
diff changeset
1147 else
25851
9ebd00825df2 Allow independent scaling of vo_font and sub_font.
reimar
parents: 24595
diff changeset
1148 load_font_ft(dxs, dys, &sub_font, font_name, text_font_scale_factor);
15085
1f8a1de5585c defer loading of the font after display size change to avoid useless
henry
parents: 15078
diff changeset
1149 prev_dxs = dxs;
1f8a1de5585c defer loading of the font after display size change to avoid useless
henry
parents: 15078
diff changeset
1150 prev_dys = dys;
1f8a1de5585c defer loading of the font after display size change to avoid useless
henry
parents: 15078
diff changeset
1151 defer_counter = 0;
23338
2a66d95355f0 add new -subfont option, that allows having a different font for OSD (controls and menu) and subtitles
ben
parents: 21582
diff changeset
1152 } else {
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28594
diff changeset
1153 if (!vo_font)
25851
9ebd00825df2 Allow independent scaling of vo_font and sub_font.
reimar
parents: 24595
diff changeset
1154 load_font_ft(dxs, dys, &vo_font, font_name, osd_font_scale_factor);
24582
6d5999a6b4e2 warning fix:
diego
parents: 24378
diff changeset
1155 if (!sub_font) {
23742
93c871be0258 Use -font for subtitles when -subfont is not given, patch by kiriuja
zuxy
parents: 23573
diff changeset
1156 if (sub_font_name)
25851
9ebd00825df2 Allow independent scaling of vo_font and sub_font.
reimar
parents: 24595
diff changeset
1157 load_font_ft(dxs, dys, &sub_font, sub_font_name, text_font_scale_factor);
23742
93c871be0258 Use -font for subtitles when -subfont is not given, patch by kiriuja
zuxy
parents: 23573
diff changeset
1158 else
25851
9ebd00825df2 Allow independent scaling of vo_font and sub_font.
reimar
parents: 24595
diff changeset
1159 load_font_ft(dxs, dys, &sub_font, font_name, text_font_scale_factor);
24582
6d5999a6b4e2 warning fix:
diego
parents: 24378
diff changeset
1160 }
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
1161 }
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
1162 #endif
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
1163
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1164 while(obj){
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1165 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
1166 int vis=obj->flags&OSDFLAG_VISIBLE;
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
1167 obj->flags&=~OSDFLAG_BBOX;
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1168 switch(obj->type){
27341
e7c989f7a7c9 Start unifying names of internal preprocessor directives.
diego
parents: 25851
diff changeset
1169 #ifdef CONFIG_DVDNAV
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
1170 case OSDTYPE_DVDNAV:
28255
aeefca2deed3 Change vo_draw_text to a vo_draw_text_ext function which draws DVD navigation
reimar
parents: 28051
diff changeset
1171 vo_update_nav(obj,dxs,dys, left_border, top_border, right_border, bottom_border, orig_w, orig_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
1172 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
1173 #endif
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1174 case OSDTYPE_SUBTITLE:
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1175 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
1176 break;
23903
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
1177 case OSDTYPE_TELETEXT:
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
1178 vo_update_text_teletext(obj,dxs,dys);
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
1179 break;
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1180 case OSDTYPE_PROGBAR:
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1181 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
1182 break;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1183 case OSDTYPE_SPU:
7628
d6608342591d This patch adds the functionality to disable/enable subtitles while playing
arpi
parents: 7121
diff changeset
1184 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
1185 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
1186 obj->flags|=OSDFLAG_VISIBLE|OSDFLAG_CHANGED;
6190
bd6748605681 Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents: 6110
diff changeset
1187 }
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1188 else
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1189 obj->flags&=~OSDFLAG_VISIBLE;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1190 break;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1191 case OSDTYPE_OSD:
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
1192 if(vo_font && vo_osd_text && vo_osd_text[0]){
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
1193 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
1194 obj->flags|=OSDFLAG_VISIBLE|OSDFLAG_CHANGED;
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
1195 } else
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1196 obj->flags&=~OSDFLAG_VISIBLE;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1197 break;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1198 }
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
1199 // check bbox:
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
1200 if(!(obj->flags&OSDFLAG_BBOX)){
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
1201 // we don't know, so assume the whole screen changed :(
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
1202 obj->bbox.x1=obj->bbox.y1=0;
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
1203 obj->bbox.x2=dxs;
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
1204 obj->bbox.y2=dys;
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
1205 obj->flags|=OSDFLAG_BBOX;
5664
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
1206 } else {
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
1207 // check bbox, reduce it if it's out of bounds (corners):
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
1208 if(obj->bbox.x1<0) obj->bbox.x1=0;
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
1209 if(obj->bbox.y1<0) obj->bbox.y1=0;
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
1210 if(obj->bbox.x2>dxs) obj->bbox.x2=dxs;
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
1211 if(obj->bbox.y2>dys) obj->bbox.y2=dys;
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
1212 if(obj->flags&OSDFLAG_VISIBLE)
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
1213 // debug:
ee6c9530729f bbox calculation fixed (font->height < real height)
arpi
parents: 5645
diff changeset
1214 mp_msg(MSGT_OSD,MSGL_DBG2,"OSD update: %d;%d %dx%d \n",
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
1215 obj->bbox.x1,obj->bbox.y1,obj->bbox.x2-obj->bbox.x1,
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
1216 obj->bbox.y2-obj->bbox.y1);
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
1217 }
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1218 // check if visibility changed:
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1219 if(vis != (obj->flags&OSDFLAG_VISIBLE) ) obj->flags|=OSDFLAG_CHANGED;
5640
a0cee3bb7f78 osd: calculating bbox
arpi
parents: 5638
diff changeset
1220 // 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
1221 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
1222 obj->flags&=~OSDFLAG_FORCE_UPDATE;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1223 }
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1224 if(obj->flags&OSDFLAG_CHANGED){
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1225 chg|=1<<obj->type;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1226 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
1227 }
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1228 obj=obj->next;
4081
9e581ab5e54b Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents: 3180
diff changeset
1229 }
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1230 return chg;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1231 }
4081
9e581ab5e54b Add vobsub support, suppress conditionnal on USE_DVDREAD.
kmkaplan
parents: 3180
diff changeset
1232
28255
aeefca2deed3 Change vo_draw_text to a vo_draw_text_ext function which draws DVD navigation
reimar
parents: 28051
diff changeset
1233 int vo_update_osd(int dxs, int dys) {
aeefca2deed3 Change vo_draw_text to a vo_draw_text_ext function which draws DVD navigation
reimar
parents: 28051
diff changeset
1234 return vo_update_osd_ext(dxs, dys, 0, 0, 0, 0, dxs, dys);
aeefca2deed3 Change vo_draw_text to a vo_draw_text_ext function which draws DVD navigation
reimar
parents: 28051
diff changeset
1235 }
aeefca2deed3 Change vo_draw_text to a vo_draw_text_ext function which draws DVD navigation
reimar
parents: 28051
diff changeset
1236
17566
f580a7755ac5 Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents: 16923
diff changeset
1237 void vo_init_osd(void){
947
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 865
diff changeset
1238 if(!draw_alpha_init_flag){
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 865
diff changeset
1239 draw_alpha_init_flag=1;
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 865
diff changeset
1240 vo_draw_alpha_init();
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 865
diff changeset
1241 }
6110
7bea806b9c5f Improvment for spu subtitles.
albeu
parents: 5664
diff changeset
1242 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
1243 // 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
1244 new_osd_obj(OSDTYPE_OSD);
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1245 new_osd_obj(OSDTYPE_SUBTITLE);
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1246 new_osd_obj(OSDTYPE_PROGBAR);
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1247 new_osd_obj(OSDTYPE_SPU);
27341
e7c989f7a7c9 Start unifying names of internal preprocessor directives.
diego
parents: 25851
diff changeset
1248 #ifdef CONFIG_DVDNAV
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
1249 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
1250 #endif
23903
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
1251 new_osd_obj(OSDTYPE_TELETEXT);
27393
4876c89bafdd Rename font-related preprocessor directives.
diego
parents: 27370
diff changeset
1252 #ifdef CONFIG_FREETYPE
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
1253 force_load_font = 1;
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
1254 #endif
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1255 }
947
76fd9463b9d3 FAST_OSD option to disable font outline antialiasing
arpi_esp
parents: 865
diff changeset
1256
5642
eb0cb6185e6c osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents: 5640
diff changeset
1257 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
1258
eb0cb6185e6c osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents: 5640
diff changeset
1259 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
1260 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
1261 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
1262 while(obj){
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28594
diff changeset
1263 if(((obj->flags&OSDFLAG_CHANGED) || (obj->flags&OSDFLAG_VISIBLE)) &&
5642
eb0cb6185e6c osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents: 5640
diff changeset
1264 (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
1265 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
1266 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
1267 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
1268 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
1269 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
1270 }
eb0cb6185e6c osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents: 5640
diff changeset
1271 // 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
1272 }
5645
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
1273 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
1274 }
eb0cb6185e6c osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents: 5640
diff changeset
1275 }
eb0cb6185e6c osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents: 5640
diff changeset
1276
28255
aeefca2deed3 Change vo_draw_text to a vo_draw_text_ext function which draws DVD navigation
reimar
parents: 28051
diff changeset
1277 void vo_draw_text_ext(int dxs, int dys, int left_border, int top_border,
aeefca2deed3 Change vo_draw_text to a vo_draw_text_ext function which draws DVD navigation
reimar
parents: 28051
diff changeset
1278 int right_border, int bottom_border, int orig_w, int orig_h,
aeefca2deed3 Change vo_draw_text to a vo_draw_text_ext function which draws DVD navigation
reimar
parents: 28051
diff changeset
1279 void (*draw_alpha)(int x0, int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride)) {
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1280 mp_osd_obj_t* obj=vo_osd_list;
28255
aeefca2deed3 Change vo_draw_text to a vo_draw_text_ext function which draws DVD navigation
reimar
parents: 28051
diff changeset
1281 vo_update_osd_ext(dxs, dys, left_border, top_border, right_border, bottom_border, orig_w, orig_h);
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1282 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
1283 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
1284 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
1285 switch(obj->type){
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1286 case OSDTYPE_SPU:
6190
bd6748605681 Bounding box and partial update patch for vob/dvdsub by Hephooey.
atmos4
parents: 6110
diff changeset
1287 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
1288 break;
27341
e7c989f7a7c9 Start unifying names of internal preprocessor directives.
diego
parents: 25851
diff changeset
1289 #ifdef CONFIG_DVDNAV
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
1290 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
1291 #endif
23903
037737866f6a Teletext support
voroshil
parents: 23742
diff changeset
1292 case OSDTYPE_TELETEXT:
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1293 case OSDTYPE_OSD:
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1294 case OSDTYPE_SUBTITLE:
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1295 case OSDTYPE_PROGBAR:
7121
6abc330b5b32 subtitle/osd cache - pre-render text to a buffer with alpha and bitmap separated
arpi
parents: 7067
diff changeset
1296 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
1297 break;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1298 }
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1299 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
1300 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
1301 }
eb0cb6185e6c osd: ok, now it's possible to do partial draw/clear of the buffer only if changed
arpi
parents: 5640
diff changeset
1302 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
1303 obj=obj->next;
218
fbfc2077ba72 sub/osd interface changes
arpi_esp
parents: 213
diff changeset
1304 }
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1305 }
3034
24d3dca4e813 DVD sub patch by Kim Minh Kaplan <kmkaplan@selfoffice.com>
arpi
parents: 2498
diff changeset
1306
28255
aeefca2deed3 Change vo_draw_text to a vo_draw_text_ext function which draws DVD navigation
reimar
parents: 28051
diff changeset
1307 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)) {
aeefca2deed3 Change vo_draw_text to a vo_draw_text_ext function which draws DVD navigation
reimar
parents: 28051
diff changeset
1308 vo_draw_text_ext(dxs, dys, 0, 0, 0, 0, dxs, dys, draw_alpha);
aeefca2deed3 Change vo_draw_text to a vo_draw_text_ext function which draws DVD navigation
reimar
parents: 28051
diff changeset
1309 }
aeefca2deed3 Change vo_draw_text to a vo_draw_text_ext function which draws DVD navigation
reimar
parents: 28051
diff changeset
1310
4807
156482788caf osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents: 4773
diff changeset
1311 static int vo_osd_changed_status = 0;
156482788caf osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents: 4773
diff changeset
1312
156482788caf osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents: 4773
diff changeset
1313 int vo_osd_changed(int new_value)
156482788caf osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents: 4773
diff changeset
1314 {
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1315 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
1316 int ret = vo_osd_changed_status;
156482788caf osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents: 4773
diff changeset
1317 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
1318
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1319 while(obj){
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1320 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
1321 obj=obj->next;
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1322 }
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1323
4807
156482788caf osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents: 4773
diff changeset
1324 return ret;
156482788caf osd outside movie support for vo_sdl, patch by Fredrik Kuivinen
atmos4
parents: 4773
diff changeset
1325 }
5638
86663f1b9b00 new osd code, use osd objs to follow changes and do minimal updates
arpi
parents: 5503
diff changeset
1326
5645
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
1327 // BBBBBBBBBBBB AAAAAAAAAAAAA BBBBBBBBBBB
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
1328 // BBBBBBBBBBBB BBBBBBBBBBBBB
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
1329 // BBBBBBB
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
1330
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
1331 // 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
1332 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
1333 mp_osd_obj_t* obj=vo_osd_list;
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
1334 while(obj){
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
1335 if(obj->flags&OSDFLAG_VISIBLE){
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
1336 if( (obj->bbox.x1<=x2 && obj->bbox.x2>=x1) &&
21364
d81ffbf9615f EMISSINGBRAIN: No, OSD objects of size 0 sure are _not_ visible.
reimar
parents: 21219
diff changeset
1337 (obj->bbox.y1<=y2 && obj->bbox.y2>=y1) &&
21443
862b3942429c 100l typo in 21380 disabled OSD with at least xvmc.
reimar
parents: 21364
diff changeset
1338 obj->bbox.y2 > obj->bbox.y1 && obj->bbox.x2 > obj->bbox.x1
21364
d81ffbf9615f EMISSINGBRAIN: No, OSD objects of size 0 sure are _not_ visible.
reimar
parents: 21219
diff changeset
1339 ) return 1;
5645
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
1340 }
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
1341 obj=obj->next;
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
1342 }
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
1343 return 0;
bd5c0d8346f0 vo_osd_check_range_update() added + 10l fix
arpi
parents: 5642
diff changeset
1344 }