Mercurial > mplayer.hg
changeset 34011:88eebbbbd6a0
Update included libass copy to 0.9.13 release.
Besides a license change to BSD license and other (minor?) fixes,
this fixes possible crashes with the latest (2.4.6?) freetype release.
author | reimar |
---|---|
date | Sun, 11 Sep 2011 10:33:13 +0000 |
parents | 1930c0a745df |
children | fceaeb11f890 |
files | libass/ass.c libass/ass.h libass/ass_bitmap.c libass/ass_bitmap.h libass/ass_cache.c libass/ass_cache.h libass/ass_drawing.c libass/ass_font.c libass/ass_font.h libass/ass_fontconfig.c libass/ass_fontconfig.h libass/ass_library.c libass/ass_library.h libass/ass_parse.c libass/ass_render.c libass/ass_render.h libass/ass_render_api.c libass/ass_types.h libass/ass_utils.c libass/ass_utils.h |
diffstat | 20 files changed, 319 insertions(+), 275 deletions(-) [+] |
line wrap: on
line diff
--- a/libass/ass.c Sat Sep 10 09:37:52 2011 +0000 +++ b/libass/ass.c Sun Sep 11 10:33:13 2011 +0000 @@ -3,19 +3,17 @@ * * This file is part of libass. * - * libass is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. * - * libass is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with libass; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include "config.h" @@ -166,6 +164,32 @@ } /** + * \brief Set up default style + * \param style style to edit to defaults + * The parameters are mostly taken directly from VSFilter source for + * best compatibility. + */ +static void set_default_style(ASS_Style *style) +{ + style->Name = strdup("Default"); + style->FontName = strdup("Arial"); + style->FontSize = 18; + style->PrimaryColour = 0xffffff00; + style->SecondaryColour = 0x00ffff00; + style->OutlineColour = 0x00000000; + style->BackColour = 0x00000080; + style->Bold = 200; + style->ScaleX = 1.0; + style->ScaleY = 1.0; + style->Spacing = 0; + style->BorderStyle = 1; + style->Outline = 2; + style->Shadow = 3; + style->Alignment = 2; + style->MarginL = style->MarginR = style->MarginV = 20; +} + +/** * \brief find style by name * \param track track * \param name style name @@ -179,7 +203,6 @@ if (*name == '*') ++name; // FIXME: what does '*' really mean ? for (i = track->n_styles - 1; i >= 0; --i) { - // FIXME: mb strcasecmp ? if (strcmp(track->styles[i].Name, name) == 0) return i; } @@ -310,8 +333,8 @@ // add "Default" style to the end // will be used if track does not contain a default style (or even does not contain styles at all) int sid = ass_alloc_style(track); - track->styles[sid].Name = strdup("Default"); - track->styles[sid].FontName = strdup("Arial"); + set_default_style(&track->styles[sid]); + track->default_style = sid; } for (i = 0; i < n_ignored; ++i) { @@ -470,6 +493,14 @@ q = format = strdup(track->style_format); + // Add default style first + if (track->n_styles == 0) { + // will be used if track does not contain a default style (or even does not contain styles at all) + int sid = ass_alloc_style(track); + set_default_style(&track->styles[sid]); + track->default_style = sid; + } + ass_msg(track->library, MSGL_V, "[%p] Style: %s", track, str); sid = ass_alloc_style(track);
--- a/libass/ass.h Sat Sep 10 09:37:52 2011 +0000 +++ b/libass/ass.h Sun Sep 11 10:33:13 2011 +0000 @@ -3,19 +3,17 @@ * * This file is part of libass. * - * libass is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. * - * libass is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with libass; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef LIBASS_ASS_H @@ -25,7 +23,7 @@ #include <stdarg.h> #include "ass_types.h" -#define LIBASS_VERSION 0x00911000 +#define LIBASS_VERSION 0x00913000 /* * A linked list of images produced by an ass renderer.
--- a/libass/ass_bitmap.c Sat Sep 10 09:37:52 2011 +0000 +++ b/libass/ass_bitmap.c Sun Sep 11 10:33:13 2011 +0000 @@ -3,19 +3,17 @@ * * This file is part of libass. * - * libass is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. * - * libass is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with libass; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include <stdlib.h>
--- a/libass/ass_bitmap.h Sat Sep 10 09:37:52 2011 +0000 +++ b/libass/ass_bitmap.h Sun Sep 11 10:33:13 2011 +0000 @@ -3,19 +3,17 @@ * * This file is part of libass. * - * libass is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. * - * libass is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with libass; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef LIBASS_BITMAP_H
--- a/libass/ass_cache.c Sat Sep 10 09:37:52 2011 +0000 +++ b/libass/ass_cache.c Sun Sep 11 10:33:13 2011 +0000 @@ -3,19 +3,17 @@ * * This file is part of libass. * - * libass is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. * - * libass is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with libass; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include "config.h"
--- a/libass/ass_cache.h Sat Sep 10 09:37:52 2011 +0000 +++ b/libass/ass_cache.h Sun Sep 11 10:33:13 2011 +0000 @@ -3,19 +3,17 @@ * * This file is part of libass. * - * libass is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. * - * libass is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with libass; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef LIBASS_CACHE_H
--- a/libass/ass_drawing.c Sat Sep 10 09:37:52 2011 +0000 +++ b/libass/ass_drawing.c Sun Sep 11 10:33:13 2011 +0000 @@ -118,9 +118,10 @@ // Close the last contour drawing_close_shape(drawing); - ass_msg(drawing->library, MSGL_V, - "Parsed drawing with %d points and %d contours", ol->n_points, - ol->n_contours); + if (drawing->library) + ass_msg(drawing->library, MSGL_V, + "Parsed drawing with %d points and %d contours", ol->n_points, + ol->n_contours); if (raw_mode) return; @@ -367,7 +368,8 @@ drawing->fontconfig_priv = fontconfig_priv; drawing->font = font; drawing->ftlibrary = lib; - drawing->library = font ? font->library : NULL; + if (font) + drawing->library = font->library; drawing->scale_x = 1.; drawing->scale_y = 1.;
--- a/libass/ass_font.c Sat Sep 10 09:37:52 2011 +0000 +++ b/libass/ass_font.c Sun Sep 11 10:33:13 2011 +0000 @@ -3,19 +3,17 @@ * * This file is part of libass. * - * libass is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. * - * libass is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with libass; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include "config.h" @@ -448,12 +446,13 @@ face = font->faces[face_idx]; index = FT_Get_Char_Index(face, ch); if (index == 0 && face->num_charmaps > 0) { + int i; ass_msg(font->library, MSGL_WARN, - "Glyph 0x%X not found, falling back to first charmap", ch); - FT_CharMap cur = face->charmap; - FT_Set_Charmap(face, face->charmaps[0]); - index = FT_Get_Char_Index(face, ch); - FT_Set_Charmap(face, cur); + "Glyph 0x%X not found, broken font? Trying all charmaps", ch); + for (i = 0; i < face->num_charmaps; i++) { + FT_Set_Charmap(face, face->charmaps[i]); + if ((index = FT_Get_Char_Index(face, ch)) != 0) break; + } } if (index == 0) { ass_msg(font->library, MSGL_ERR, @@ -604,8 +603,20 @@ } /** - * \brief Fix-up stroker result for huge borders by removing inside contours - * that would reverse in size + * \brief Apply fixups to please the FreeType stroker and improve the + * rendering result, especially in case the outline has some anomalies. + * At the moment, the following fixes are done: + * + * 1. Reverse contours that have "inside" winding direction but are not + * contained in any other contours' cbox. + * 2. Remove "inside" contours depending on border size, so that large + * borders do not reverse the winding direction, which leads to "holes" + * inside the border. The inside will be filled by the border of the + * outside contour anyway in this case. + * + * \param outline FreeType outline, modified in-place + * \param border_x border size, x direction, d6 format + * \param border_x border size, y direction, d6 format */ void fix_freetype_stroker(FT_OutlineGlyph glyph, int border_x, int border_y) { @@ -673,19 +684,27 @@ } } - // zero-out contours that can be removed; much simpler than copying + // if we need to modify the outline, rewrite it and skip + // the contours that we determined should be removed. if (modified) { + FT_Outline *outline = &glyph->outline; + int p = 0, c = 0; for (i = 0; i < nc; i++) { - if (valid_cont[i]) + if (!valid_cont[i]) continue; begin = (i == 0) ? 0 : glyph->outline.contours[i - 1] + 1; stop = glyph->outline.contours[i]; for (j = begin; j <= stop; j++) { - glyph->outline.points[j].x = 0; - glyph->outline.points[j].y = 0; - glyph->outline.tags[j] = 0; + outline->points[p].x = outline->points[j].x; + outline->points[p].y = outline->points[j].y; + outline->tags[p] = outline->tags[j]; + p++; } + outline->contours[c] = p - 1; + c++; } + outline->n_points = p; + outline->n_contours = c; } free(boxes);
--- a/libass/ass_font.h Sat Sep 10 09:37:52 2011 +0000 +++ b/libass/ass_font.h Sun Sep 11 10:33:13 2011 +0000 @@ -3,19 +3,17 @@ * * This file is part of libass. * - * libass is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. * - * libass is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with libass; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef LIBASS_FONT_H
--- a/libass/ass_fontconfig.c Sat Sep 10 09:37:52 2011 +0000 +++ b/libass/ass_fontconfig.c Sun Sep 11 10:33:13 2011 +0000 @@ -3,19 +3,17 @@ * * This file is part of libass. * - * libass is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. * - * libass is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with libass; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include "config.h" @@ -524,7 +522,8 @@ if (priv) { #ifdef CONFIG_FONTCONFIG - FcConfigDestroy(priv->config); + if (priv->config) + FcConfigDestroy(priv->config); #endif free(priv->path_default); free(priv->family_default);
--- a/libass/ass_fontconfig.h Sat Sep 10 09:37:52 2011 +0000 +++ b/libass/ass_fontconfig.h Sun Sep 11 10:33:13 2011 +0000 @@ -3,19 +3,17 @@ * * This file is part of libass. * - * libass is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. * - * libass is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with libass; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef LIBASS_FONTCONFIG_H
--- a/libass/ass_library.c Sat Sep 10 09:37:52 2011 +0000 +++ b/libass/ass_library.c Sun Sep 11 10:33:13 2011 +0000 @@ -3,19 +3,17 @@ * * This file is part of libass. * - * libass is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. * - * libass is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with libass; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include "config.h"
--- a/libass/ass_library.h Sat Sep 10 09:37:52 2011 +0000 +++ b/libass/ass_library.h Sun Sep 11 10:33:13 2011 +0000 @@ -3,19 +3,17 @@ * * This file is part of libass. * - * libass is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. * - * libass is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with libass; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef LIBASS_LIBRARY_H
--- a/libass/ass_parse.c Sat Sep 10 09:37:52 2011 +0000 +++ b/libass/ass_parse.c Sun Sep 11 10:33:13 2011 +0000 @@ -359,6 +359,22 @@ render_priv->state.hspacing * (1 - pwr) + val * pwr; else render_priv->state.hspacing = render_priv->state.style->Spacing; + } else if (mystrcmp(&p, "fs+")) { + double val; + if (mystrtod(&p, &val)) { + val = render_priv->state.font_size + pwr * val; + } else + val = render_priv->state.style->FontSize; + if (render_priv->state.font) + change_font_size(render_priv, val); + } else if (mystrcmp(&p, "fs-")) { + double val; + if (mystrtod(&p, &val)) + val = render_priv->state.font_size - pwr * val; + else + val = render_priv->state.style->FontSize; + if (render_priv->state.font) + change_font_size(render_priv, val); } else if (mystrcmp(&p, "fs")) { double val; if (mystrtod(&p, &val)) @@ -487,16 +503,22 @@ val = ((val - 1) % 3) + 1; // horizontal alignment val += v * 4; ass_msg(render_priv->library, MSGL_DBG2, "align %d", val); - render_priv->state.alignment = val; + if ((render_priv->state.parsed_tags & PARSED_A) == 0) { + render_priv->state.alignment = val; + render_priv->state.parsed_tags |= PARSED_A; + } } else render_priv->state.alignment = render_priv->state.style->Alignment; } else if (mystrcmp(&p, "a")) { int val; - if (mystrtoi(&p, &val) && val) - // take care of a vsfilter quirk: handle illegal \a8 like \a5 - render_priv->state.alignment = (val == 8) ? 5 : val; - else + if (mystrtoi(&p, &val) && val) { + if ((render_priv->state.parsed_tags & PARSED_A) == 0) { + // take care of a vsfilter quirk: handle illegal \a8 like \a5 + render_priv->state.alignment = (val == 8) ? 5 : val; + render_priv->state.parsed_tags |= PARSED_A; + } + } else render_priv->state.alignment = render_priv->state.style->Alignment; } else if (mystrcmp(&p, "pos")) { @@ -550,10 +572,13 @@ mystrtoll(&p, &t4); } skip(')'); - render_priv->state.fade = - interpolate_alpha(render_priv->time - - render_priv->state.event->Start, t1, t2, - t3, t4, a1, a2, a3); + if ((render_priv->state.parsed_tags & PARSED_FADE) == 0) { + render_priv->state.fade = + interpolate_alpha(render_priv->time - + render_priv->state.event->Start, t1, t2, + t3, t4, a1, a2, a3); + render_priv->state.parsed_tags |= PARSED_FADE; + } } else if (mystrcmp(&p, "org")) { int v1, v2; skip('(');
--- a/libass/ass_render.c Sat Sep 10 09:37:52 2011 +0000 +++ b/libass/ass_render.c Sun Sep 11 10:33:13 2011 +0000 @@ -3,19 +3,17 @@ * * This file is part of libass. * - * libass is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. * - * libass is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with libass; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include "config.h" @@ -889,6 +887,7 @@ { render_priv->state.event = event; render_priv->state.style = render_priv->track->styles + event->Style; + render_priv->state.parsed_tags = 0; reset_render_context(render_priv); @@ -1304,6 +1303,11 @@ FT_Done_Glyph(outline); } } + + // VSFilter compatibility: invisible fill and no border? + // In this case no shadow is supposed to be rendered. + if (!info->outline_glyph && (info->c[0] & 0xFF) == 0xFF) + info->bm_s = 0; } /** @@ -1392,16 +1396,17 @@ } // A break itself can contain a whitespace, too cur = ti->glyphs + i; - if (cur->symbol == ' ') + if (cur->symbol == ' ') { cur->skip++; - // Mark whitespace after - j = i + 1; - cur = ti->glyphs + j; - while (j < ti->length && IS_WHITESPACE(cur)) { - cur->skip++; - cur = ti->glyphs + ++j; + // Mark whitespace after + j = i + 1; + cur = ti->glyphs + j; + while (j < ti->length && IS_WHITESPACE(cur)) { + cur->skip++; + cur = ti->glyphs + ++j; + } + i = j - 1; } - i = j - 1; } } } @@ -1436,10 +1441,9 @@ break_type = 0; s1 = text_info->glyphs; // current line start for (i = 0; i < text_info->length; ++i) { - int break_at; + int break_at = -1; double s_offset, len; cur = text_info->glyphs + i; - break_at = -1; s_offset = d6_to_double(s1->bbox.xMin + s1->pos.x); len = d6_to_double(cur->bbox.xMax + cur->pos.x) - s_offset; @@ -1448,19 +1452,15 @@ break_at = i; ass_msg(render_priv->library, MSGL_DBG2, "forced line break at %d", break_at); - } - - if ((len >= max_text_width) - && (render_priv->state.wrap_style != 2)) { + } else if (cur->symbol == ' ') { + last_space = i; + } else if (len >= max_text_width + && (render_priv->state.wrap_style != 2)) { break_type = 1; break_at = last_space; - if (break_at == -1) - break_at = i - 1; - if (break_at == -1) - break_at = 0; - ass_msg(render_priv->library, MSGL_DBG2, "overfill at %d", i); - ass_msg(render_priv->library, MSGL_DBG2, "line break at %d", - break_at); + if (break_at >= 0) + ass_msg(render_priv->library, MSGL_DBG2, "line break at %d", + break_at); } if (break_at != -1) { @@ -1481,14 +1481,6 @@ s_offset = d6_to_double(s1->bbox.xMin + s1->pos.x); text_info->n_lines++; } - - if (cur->symbol == ' ') - last_space = i; - - // make sure the hard linebreak is not forgotten when - // there was a new soft linebreak just inserted - if (cur->symbol == '\n' && break_type == 1) - i--; } #define DIFF(x,y) (((x) < (y)) ? (y - x) : (x - y)) exit = 0;
--- a/libass/ass_render.h Sat Sep 10 09:37:52 2011 +0000 +++ b/libass/ass_render.h Sun Sep 11 10:33:13 2011 +0000 @@ -4,19 +4,17 @@ * * This file is part of libass. * - * libass is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. * - * libass is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with libass; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef LIBASS_RENDER_H @@ -41,6 +39,9 @@ #define GLYPH_CACHE_MAX 1000 #define BITMAP_CACHE_MAX_SIZE 30 * 1048576 +#define PARSED_FADE (1<<0) +#define PARSED_A (1<<1) + typedef struct { double xMin; double xMax; @@ -143,6 +144,7 @@ typedef struct { ASS_Event *event; ASS_Style *style; + int parsed_tags; ASS_Font *font; char *font_path;
--- a/libass/ass_render_api.c Sat Sep 10 09:37:52 2011 +0000 +++ b/libass/ass_render_api.c Sun Sep 11 10:33:13 2011 +0000 @@ -4,19 +4,17 @@ * * This file is part of libass. * - * libass is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. * - * libass is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with libass; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include "config.h"
--- a/libass/ass_types.h Sat Sep 10 09:37:52 2011 +0000 +++ b/libass/ass_types.h Sun Sep 11 10:33:13 2011 +0000 @@ -3,19 +3,17 @@ * * This file is part of libass. * - * libass is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. * - * libass is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with libass; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef LIBASS_TYPES_H
--- a/libass/ass_utils.c Sat Sep 10 09:37:52 2011 +0000 +++ b/libass/ass_utils.c Sun Sep 11 10:33:13 2011 +0000 @@ -3,19 +3,17 @@ * * This file is part of libass. * - * libass is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. * - * libass is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with libass; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include "config.h"
--- a/libass/ass_utils.h Sat Sep 10 09:37:52 2011 +0000 +++ b/libass/ass_utils.h Sun Sep 11 10:33:13 2011 +0000 @@ -3,19 +3,17 @@ * * This file is part of libass. * - * libass is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. * - * libass is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with libass; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef LIBASS_UTILS_H