]> git.sesse.net Git - vlc/blob - extras/contrib/src/Patches/libass_mplayer_updates.patch
libass: upgrade libass contrib with the latest enhancements from Mplayer.
[vlc] / extras / contrib / src / Patches / libass_mplayer_updates.patch
1 diff -ruN libass-0.9.5/libass/ass.c libass-0.9.5-patched/libass/ass.c
2 --- libass/libass/ass.c 2008-05-22 20:01:18.000000000 +0200
3 +++ libass-0.9.5-patched/libass/ass.c   2008-08-08 23:59:21.000000000 +0200
4 @@ -846,16 +846,22 @@
5                 char* ip;
6                 char* op;
7                 size_t rc;
8 +                int clear = 0;
9                 
10 -               outbuf = malloc(size);
11 +               outbuf = malloc(osize);
12                 ip = data;
13                 op = outbuf;
14                 
15 -               while (ileft) {
16 +               while (1) {
17 +                        if(ileft)
18                         rc = iconv(icdsc, &ip, &ileft, &op, &oleft);
19 +                        else {// clear the conversion state and leave
20 +                            clear = 1;
21 +                            rc = iconv(icdsc, NULL, NULL, &op, &oleft);
22 +                        }
23                         if (rc == (size_t)(-1)) {
24                                 if (errno == E2BIG) {
25 -                                       int offset = op - outbuf;
26 +                                       size_t offset = op - outbuf;
27                                         outbuf = (char*)realloc(outbuf, osize + size);
28                                         op = outbuf + offset;
29                                         osize += size;
30 @@ -864,7 +870,9 @@
31                                         mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_ErrorRecodingFile);
32                                         return NULL;
33                                 }
34 -                       }
35 +                       } else
36 +                            if( clear )
37 +                                break;
38                 }
39                 outbuf[osize - oleft - 1] = 0;
40         }
41 diff -ruN libass-0.9.5/libass/ass_bitmap.c libass-0.9.5-patched/libass/ass_bitmap.c
42 --- libass/libass/ass_bitmap.c  2008-05-22 20:01:18.000000000 +0200
43 +++ libass-0.9.5-patched/libass/ass_bitmap.c    2008-08-09 00:04:36.000000000 +0200
44 @@ -274,9 +274,10 @@
45         resize_tmp(priv, (*bm_g)->w, (*bm_g)->h);
46         
47         if (be) {
48 -               blur((*bm_g)->buffer, priv->tmp, (*bm_g)->w, (*bm_g)->h, (*bm_g)->w, (int*)priv->gt2, priv->g_r, priv->g_w);
49                 if (*bm_o)
50                         blur((*bm_o)->buffer, priv->tmp, (*bm_o)->w, (*bm_o)->h, (*bm_o)->w, (int*)priv->gt2, priv->g_r, priv->g_w);
51 +               else
52 +                       blur((*bm_g)->buffer, priv->tmp, (*bm_g)->w, (*bm_g)->h, (*bm_g)->w, (int*)priv->gt2, priv->g_r, priv->g_w);
53         }
54  
55         if (*bm_o)
56 diff -ruN libass-0.9.5/libass/ass_fontconfig.c libass-0.9.5-patched/libass/ass_fontconfig.c
57 --- libass/libass/ass_fontconfig.c      2008-05-22 20:01:18.000000000 +0200
58 +++ libass-0.9.5-patched/libass/ass_fontconfig.c        2008-08-08 23:59:21.000000000 +0200
59 @@ -129,6 +129,8 @@
60                 goto error;
61  
62         fset = FcFontSort(priv->config, pat, FcTrue, NULL, &result);
63 +        if(!fset)
64 +            goto error;
65  
66         for (curf = 0; curf < fset->nfont; ++curf) {
67                 FcPattern* curp = fset->fonts[curf];
68 @@ -351,12 +353,15 @@
69         FcPattern* pattern;
70         FcFontSet* fset;
71         FcBool res;
72 +        int face_index, num_faces = 1;
73  
74 -       rc = FT_New_Memory_Face(ftlibrary, (unsigned char*)data, data_size, 0, &face);
75 +       for (face_index = 0; face_index < num_faces; ++face_index) {
76 +        rc = FT_New_Memory_Face(ftlibrary, (unsigned char*)data, data_size, 0, &face);
77         if (rc) {
78                 mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_ErrorOpeningMemoryFont, name);
79                 return;
80         }
81 +        num_faces = face->num_faces;
82  
83         pattern = FcFreeTypeQueryFace(face, (unsigned char*)name, 0, FcConfigGetBlanks(priv->config));
84         if (!pattern) {
85 @@ -380,6 +385,7 @@
86         }
87  
88         FT_Done_Face(face);
89 +        }
90  #endif
91  }
92  
93 @@ -419,7 +425,8 @@
94         for (i = 0; i < library->num_fontdata; ++i)
95                 process_fontdata(priv, library, ftlibrary, i);
96  
97 -       if (FcDirCacheValid((const FcChar8 *)dir) == FcFalse)
98 +       if(dir) {
99 +        if (FcDirCacheValid((const FcChar8 *)dir) == FcFalse)
100         {
101                 mp_msg(MSGT_ASS, MSGL_INFO, MSGTR_LIBASS_UpdatingFontCache);
102                 if (FcGetVersion() >= 20390 && FcGetVersion() < 20400)
103 @@ -457,6 +464,7 @@
104         if (!rc) {
105                 mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_FcConfigAppFontAddDirFailed);
106         }
107 +        }
108  
109         priv->family_default = family ? strdup(family) : 0;
110         priv->path_default = path ? strdup(path) : 0;
111 diff -ruN libass-0.9.5/libass/ass_render.c libass-0.9.5-patched/libass/ass_render.c
112 --- libass/libass/ass_render.c  2008-05-22 20:01:18.000000000 +0200
113 +++ libass-0.9.5-patched/libass/ass_render.c    2008-08-09 00:04:28.000000000 +0200
114 @@ -149,8 +149,8 @@
115                 EVENT_HSCROLL, // "Banner" transition effect, text_width is unlimited
116                 EVENT_VSCROLL // "Scroll up", "Scroll down" transition effects
117                 } evt_type;
118 -       int pos_x, pos_y; // position
119 -       int org_x, org_y; // origin
120 +       double pos_x, pos_y; // position
121 +       double org_x, org_y; // origin
122         char have_origin; // origin is explicitly defined; if 0, get_base_point() is used
123         double scale_x, scale_y;
124         double hspacing; // distance between letters, in pixels
125 @@ -161,6 +161,7 @@
126         uint32_t fade; // alpha from \fad
127         char be; // blur edges
128         int shadow;
129 +       int drawing_mode; // not implemented; when != 0 text is discarded, except for style override tags
130  
131         effect_t effect_type;
132         int effect_timing;
133 @@ -456,19 +457,19 @@
134  /**
135   * \brief Mapping between script and screen coordinates
136   */
137 -static int x2scr(int x) {
138 +static int x2scr(double x) {
139         return x*frame_context.orig_width_nocrop / frame_context.track->PlayResX +
140                 FFMAX(global_settings->left_margin, 0);
141  }
142  /**
143   * \brief Mapping between script and screen coordinates
144   */
145 -static int y2scr(int y) {
146 +static int y2scr(double y) {
147         return y * frame_context.orig_height_nocrop / frame_context.track->PlayResY +
148                 FFMAX(global_settings->top_margin, 0);
149  }
150  // the same for toptitles
151 -static int y2scr_top(int y) {
152 +static int y2scr_top(double y) {
153         if (global_settings->use_margins)
154                 return y * frame_context.orig_height_nocrop / frame_context.track->PlayResY;
155         else
156 @@ -476,7 +477,7 @@
157                         FFMAX(global_settings->top_margin, 0);
158  }
159  // the same for subtitles
160 -static int y2scr_sub(int y) {
161 +static int y2scr_sub(double y) {
162         if (global_settings->use_margins)
163                 return y * frame_context.orig_height_nocrop / frame_context.track->PlayResY +
164                         FFMAX(global_settings->top_margin, 0) +
165 @@ -679,11 +680,11 @@
166   * \param pwr multiplier for some tag effects (comes from \t tags)
167   */
168  static char* parse_tag(char* p, double pwr) {
169 -#define skip_all(x) if (*p == (x)) ++p; else { \
170 -       while ((*p != (x)) && (*p != '}') && (*p != 0)) {++p;} }
171 +#define skip_to(x) while ((*p != (x)) && (*p != '}') && (*p != 0)) { ++p;}
172  #define skip(x) if (*p == (x)) ++p; else { return p; }
173         
174 -       skip_all('\\');
175 +       skip_to('\\');
176 +       skip('\\');
177         if ((*p == '}') || (*p == 0))
178                 return p;
179  
180 @@ -727,7 +728,7 @@
181         } else if (mystrcmp(&p, "move")) {
182                 int x1, x2, y1, y2;
183                 long long t1, t2, delta_t, t;
184 -               int x, y;
185 +               double x, y;
186                 double k;
187                 skip('(');
188                 x1 = strtol(p, &p, 10);
189 @@ -787,7 +788,7 @@
190         } else if (mystrcmp(&p, "fn")) {
191                 char* start = p;
192                 char* family;
193 -               skip_all('\\');
194 +               skip_to('\\');
195                 if (p > start) {
196                         family = malloc(p - start + 1);
197                         strncpy(family, start, p - start);
198 @@ -888,6 +889,7 @@
199                 render_context.org_x = v1;
200                 render_context.org_y = v2;
201                 render_context.have_origin = 1;
202 +               render_context.detect_collisions = 0;
203         } else if (mystrcmp(&p, "t")) {
204                 double v[3];
205                 int v1, v2;
206 @@ -928,7 +930,8 @@
207                 }
208                 while (*p == '\\')
209                         p = parse_tag(p, k); // maybe k*pwr ? no, specs forbid nested \t's 
210 -               skip_all(')'); // FIXME: better skip(')'), but much more tags support required
211 +               skip_to(')'); // in case there is some unknown tag or a comment
212 +               skip(')');
213         } else if (mystrcmp(&p, "clip")) {
214                 int x0, y0, x1, y1;
215                 int res = 1;
216 @@ -1026,12 +1029,19 @@
217                         render_context.shadow = val;
218                 else
219                         render_context.shadow = render_context.style->Shadow;
220 +       } else if (mystrcmp(&p, "pbo")) {
221 +               (void)strtol(p, &p, 10); // ignored
222 +       } else if (mystrcmp(&p, "p")) {
223 +               int val;
224 +               if (!mystrtoi(&p, 10, &val))
225 +                       val = 0;
226 +               render_context.drawing_mode = !!val;
227         }
228  
229         return p;
230  
231  #undef skip
232 -#undef skip_all
233 +#undef skip_to
234  }
235  
236  /**
237 @@ -1071,7 +1081,7 @@
238                         p += 2;
239                         *str = p;
240                         return '\n';
241 -               } else if (*(p+1) == 'n') {
242 +               } else if ((*(p+1) == 'n') || (*(p+1) == 'h')) {
243                         p += 2;
244                         *str = p;
245                         return ' ';
246 @@ -1201,6 +1211,7 @@
247         render_context.clip_y1 = frame_context.track->PlayResY;
248         render_context.detect_collisions = 1;
249         render_context.fade = 0;
250 +       render_context.drawing_mode = 0;
251         render_context.effect_type = EF_NONE;
252         render_context.effect_timing = 0;
253         render_context.effect_skip_timing = 0;
254 @@ -1748,7 +1759,9 @@
255         while (1) {
256                 // get next char, executing style override
257                 // this affects render_context
258 -               code = get_next_char(&p);
259 +               do {
260 +                       code = get_next_char(&p);
261 +               } while (code && render_context.drawing_mode); // skip everything in drawing mode
262                 
263                 // face could have been changed in get_next_char
264                 if (!render_context.font) {
265 @@ -1934,7 +1947,7 @@
266         if (render_context.evt_type == EVENT_POSITIONED) {
267                 int base_x = 0;
268                 int base_y = 0;
269 -               mp_msg(MSGT_ASS, MSGL_DBG2, "positioned event at %d, %d\n", render_context.pos_x, render_context.pos_y);
270 +               mp_msg(MSGT_ASS, MSGL_DBG2, "positioned event at %f, %f\n", render_context.pos_x, render_context.pos_y);
271                 get_base_point(bbox, alignment, &base_x, &base_y);
272                 device_x = x2scr(render_context.pos_x) - base_x;
273                 device_y = y2scr(render_context.pos_y) - base_y;