summaryrefslogtreecommitdiffstats
path: root/libass/ass_render.c
Commit message (Collapse)AuthorAgeFilesLines
* renderer: remove legacy FreeType rasterizerDr.Smile2017-07-311-4/+0
|
* stroker: implement fast two-outline strokerDr.Smile2017-07-311-124/+10
|
* rasterizer: implement simultaneous rasterization of two outlinesDr.Smile2017-07-311-1/+4
|
* cosmetic: extract most of the outline-related functions into separate fileDr.Smile2017-07-311-0/+1
|
* Allow using shadow offset to adjust size of text backgroundRicardo Constantino2017-06-011-4/+8
| | | | | | | | | | | | Text background refers to the libass-only BorderStyle 4, which is similar to 3, but isn't affected by outline/border size and doesn't render shadow, so shadow offset can be used. You can override the horizontal and vertical box size separately with override tags, just like you can override the color with shadow color. Closes #270
* Reduce precision of border width in outline cache keysOleg Oshmyan2017-01-311-4/+4
| | | | | | | The value used to generate outline cache values is 26.6, so there is no point in storing the more precise 16.16 in the cache key. Indeed, this can only reduce the efficiency of the cache and provide an extra opportunity for overflow.
* Reflect border_scale in outline cache keysOleg Oshmyan2017-01-311-4/+4
| | | | | | | | | border_scale can change, e. g. when ass_render_frame is called twice with the same renderer but different tracks. Glyphs with equal \bord tag values but different border_scale values produce different border outlines and hence should be distinguished in outline cache keys. To this end, store scaled border widths (which are really used when generating the outlines) in cache keys instead of \bord tag values.
* render: remove redundant has_clipsDr.Smile2017-01-311-18/+4
| | | | | | | | | | | | | has_clips was a workaround for the case where a new image reused the same memory address as another image used in the previous frame. In case of such reuse, comparison by pointer address failed to distinguish the different images in ass_detect_change(). After commit dd06ca30ea79ce50116a43cc5521d4eaf60a017e, images in the previous frame are no longer freed before the comparison with current frame. Thus no such reuse can occur, and the workaround is redundant. See https://github.com/libass/libass/pull/258.
* render: clip BorderStyle=4 against screenwm42017-01-111-7/+15
| | | | | | | | ASS_Images returned by libass are guaranteed to be clipped. Not doing this will cause invalid memory accesses in applications which try to use this guarantee. Fixes #254.
* Add text justificationDan Oscarsson2016-11-121-3/+37
| | | | | | | | | | | | | | | | | | | | | | | Subtitle recommendations often include that multi line subtitles should be left justified as this is easier for the eyes. This is also the standard used by several television companies. This add the possibility to define how subtitles are to be justified, independently of where they are aligned. The most common way could be to set justify to left, and have alignment to center. But you can, for example, have alignment to left and justify to center, giving subtitles to the left but justifed on the center (instead of normal left justified). Using justify right and alignment of center, might be good choice for Arabic. If justify is not defined, all works like before. If justify is defined, subtitles are aligned as defined by alignment and justified as defined by justify. ASS is not extended by this, justify can only be defined by setting Justify to wanted justification.
* Remove unused variableGrigori Goronzy2016-10-051-3/+0
|
* Fix line wrapping mode 0/3 bugsGrigori Goronzy2016-10-051-1/+4
| | | | | | | | | | | | | | | | | | This fixes two separate bugs: a) Don't move a linebreak into the first symbol. This results in a empty line at the front, which does not help to equalize line lengths at all. Instead, merge line with the second one. b) When moving a linebreak into a symbol that already is a break, the number of lines must be decremented. Otherwise, uninitialized memory is possibly used for later layout operations. Found by fuzzer test case id:000085,sig:11,src:003377+003350,op:splice,rep:8. This might also affect and hopefully fix libass#229. v2: change semantics according to review
* bitmap: use calloc instead of malloc/memsetRodger Combs2016-09-241-5/+6
| | | | This can improve perf somewhat with large bitmaps
* render: add refcounting functionality to image listsDr.Smile2016-06-301-24/+38
|
* render: keep track of any associated resources within ASS_ImageDr.Smile2016-06-301-105/+78
| | | | | That resources can be cached composite bitmap or raw bitmap buffer. Consequently, free lists are no longer needed.
* cache: keep ref_count of all active objects nonzeroDr.Smile2016-06-301-22/+56
|
* cache: replace size_func with parameter in ass_cache_commit()Dr.Smile2016-06-301-8/+18
|
* cache: remove ass_cache_cancel(), cache failures insteadDr.Smile2016-06-301-79/+68
|
* cache: switch to gradual cache clearingDr.Smile2016-06-301-87/+79
| | | | | | | | | | | Advantages over the old algorithm consist of the following. * There are no glitches due to full cache clearing. Items are arranged into linked list ordered by time of last use. Only the oldest items get deleted at the clearing event. * Each item now keeps track of number of references. Referenced cache values are immune to clearing. * Reduced amount of total cache memory for the same performance. * Reduced number of memory allocations per cache item.
* Fully fix compilation with MSVC/ICLOleg Oshmyan2015-09-171-0/+1
| | | | | | | | | As before, this does not add any build system support: a config.h file and a project must still be manually created (or the compiler can be run manually instead of using a project). Signed-off-by: Grigori Goronzy <greg@kinoho.net> Signed-off-by: Oleg Oshmyan <chortos@inbox.lv>
* ass_render: fix potential NULL derefwm42015-09-071-1/+1
| | | | Fixes CID 146421.
* ass_render: fix potential NULL derefwm42015-09-071-2/+2
| | | | | | | | | | The logic here is pretty complicated. The caller of this function guards it with "if(info->bm || info->bm_o){", and generally indeed only one of them is set. But in some cases, both are needed. fix_outline() definitely dereferences both. This is not necessarily guaranteed, e.g. on out of memory errors. Add the missing checks. Fixes CID 146125.
* Merge branch 'fonts'Grigori Goronzy2015-09-071-5/+8
|\
| * fontselect: simplify cmap lookup for embedded fontsGrigori Goronzy2015-07-101-2/+2
| | | | | | | | | | FreeType can do it for us and is probably more efficient. Also fixes deinitialization order of ASS_Renderer to make this work.
| * Custom font matching and font sourcesGrigori Goronzy2015-07-101-4/+7
| | | | | | | | | | | | | | Implement a simple font sorter (FontSelector) and an interface to deal with multiple font sources (FontProvider). Unfinished business, but works for the most part. Currently the only implemented FontProvider uses fontconfig.
* | Properly skip glyphs for multiple consecutive line breaksOleg Oshmyan2015-08-031-1/+1
|/ | | | | | | | | This corrects the calculated width of events that contain \N\N, which previously included the width of the glyph corresponding to '\n' (more generally, for n consecutive line breaks, only the first glyph was skipped and n-1 glyphs were included). Reported on IRC.
* Implement cascade gaussian blurDr.Smile2015-07-041-10/+2
| | | | | | | | | | That's complete version with SSE2/AVX2 assembly. Should be much faster than old algorithm even in pure C. Algorithm description can be found in this article (PDF): https://github.com/MrSmile/CascadeBlur/releases Close #9
* Switch to virtual function tableDr.Smile2015-06-261-75/+35
| | | | | | | | | | Use one pointer to table of functions instead of scattered bunch of function pointers. Different versions of these tables can be constructed in compile time. Also, bitmap memory alignment now depends only on SSE2/AVX2 support and is constant for every width. That simplifies code without noticeable performance penalty.
* Merge pull request #160 from astiob/beGrigori Goronzy2015-06-231-1/+1
|\ | | | | \be fixes including clipping and value range
| * Add enough padding for \be to avoid clippingOleg Oshmyan2015-02-101-1/+1
| | | | | | | | | | To avoid making bitmaps unnecessarily large, use just the necessary amount of padding for the given \be value.
* | Fix crash when stroked outline overflows SHRT_MAXDr.Smile2015-06-141-1/+1
| |
* | Do not apply ass_set_line_position() to positioned eventswm42015-06-111-3/+4
| | | | | | | | | | Even if we wanted this, the result would be inconsistent if e.g. \clip is used.
* | Remove several dead storesGrigori Goronzy2015-06-071-6/+4
| | | | | | | | Reported by clang scan-build static analysis.
* | Check possible NULL dereferenceGrigori Goronzy2015-06-071-1/+1
| | | | | | | | | | | | Reported by clang scan-build static analysis. This cannot happen with the current code, but the check might make this more robust in case anything changes.
* | Strictly clip non-dialog events against the video rectanglewm42015-05-251-0/+13
| | | | | | | | | | | | Only normal dialog lines are allowed to appear outside. Fixes #177.
* | Apply fade only when the fade alpha is positive (like VSFilter)Oleg Oshmyan2015-05-251-2/+4
| |
* | Fix memory leak with drawingswm42015-05-101-1/+6
| | | | | | | | | | | | What. Closes #175.
* | Remove RenderContext.drawingwm42015-05-101-19/+19
| | | | | | | | | | This really didn't make a lot of sense. This is a simplification, and should not affect actual program behavior.
* | Don't use margins for events that should not be overriddenwm42015-03-161-0/+12
| | | | | | | | | | | | | | libass already does not use the margins for events using \pos. This is not quite complete: there are other tags that we consider as "not dialogue", and which should not be overridden. These tags do not use EVENT_POSITIONED, and thus use the margins, which can mess up rendering.
* | Reorder functionswm42015-03-161-12/+12
| | | | | | | | Just move the *_pos ones about the variants without this postfix.
* | Fix BorderStyle=3 with zero Outline and ShadowDr.Smile2015-03-061-1/+5
| |
* | Prevent selective style overrides with scrollingwm42015-03-061-2/+3
| | | | | | | | Similar to xy-VSFilter.
* | Refine list of tags that prevent selective style overrideswm42015-03-061-1/+1
| | | | | | | | | | | | | | Somewhat stolen from: https://github.com/Cyberbeing/xy-VSFilter/blob/xy_sub_filter_rc3/src/subtitles/RTS.cpp#L2004 (xy-VSFilter started work on this in commit 014da6d9766417d7886eb867c9f2c14038f2a226)
* | Allow more fine grained control over style overrideswm42015-02-261-28/+69
| | | | | | | | | | | | | | | | Add tons of ASS_OVERRIDE_ flags, which control whether certain ASS_Style fields are copied when doing selective style overrides with ass_set_selective_style_override_enabled(). This comes with some cleanup. It should be fully backwards-compatible.
* | Change what fields are overridden with style overridewm42015-02-261-1/+1
| | | | | | | | | | | | | | | | "Bold" should obviously be taken from the script's style, like it's done with StrikeOut and Underline. treat_fontname_as_pattern is specific to the font, and thus should be taken from the same style as the font (the override style).
* | Always use the new style with \r and style overrideswm42015-02-261-6/+6
|/ | | | | | I don't know why it was done this way, but some fields were always taken from the event's style, instead of the (possibly different) \r style. Undo this, as it seems like an unnecessary complication.
* Fix incorrect memsetDr.Smile2015-01-291-1/+1
|
* Remove unused function is_skip_symbolRodger Combs2015-01-291-4/+0
|
* Clean up bitmap combiningDr.Smile2015-01-281-306/+202
| | | | | | | | | | Now pre- and post-combining operations are clearly separated, many parameters in cache keys are no longer necessary due to that. Also an ambiguous (in case of multiple fonts) text string is replaced with a list of direct bitmap references in composite cache key. Fixes #153. Fixes #82.
* Replace FT_Outline with ASS_OutlineDr.Smile2014-11-231-49/+91
|
* More malloc checkingwm42014-11-181-12/+27
| | | | In both cases, fallback to doing nothing if alloc fails.
* More malloc checkingwm42014-11-171-1/+4
| | | | | | | | | | Use strndup() instead of malloc+copy. Make all code deal with the possibility that ASS_Drawing.text can be NULL (which can happen on allocation failure). Skip fix_collisions() on malloc failure - the lines will overlap, but at least libass won't crash.
* Split some parts of ass_render_event into functionswm42014-11-151-276/+332
| | | | | The split doesn't necessarily follow any logic; for the most part it just moves each processing loop into its own function.
* Move apply_blur() to ass_bitmap.cwm42014-11-131-71/+3
| | | | Put all code into one place, which makes it easier to follow.
* Check against some overflows and allocation failures on blurwm42014-11-111-2/+1
| | | | This still doesn't catch all cases.
* Check more allocationsRodger Combs2014-11-081-1/+7
| | | | Part of #146
* Fix subpixel shadow shiftDr.Smile2014-11-061-15/+15
|
* Provide slightly more fine-grained control over style overrideswm42014-10-171-5/+15
|
* Fix caching of combined bitmaps after complex shapingOleg Oshmyan2014-09-051-8/+10
|
* Check FT_Outline_New return valuewm42014-08-311-1/+6
| | | | | Makes #131 not crash. The function likely fails because the number of points exceeds SHRT_MAX.
* Simplify drawing text assignmentOleg Oshmyan2014-06-061-2/+2
|
* Use ass_drawing_add_chars for vector drawingsOleg Oshmyan2014-06-061-28/+20
| | | | | | This not only provides a performance improvement but also conveniently fixes the following issue: we used to interpret backslash-escapes in vector drawings, but we shouldn't.
* Require closing '}' for override tagsOleg Oshmyan2014-06-061-15/+10
| | | | | | | | Like VSFilter. '{' without a following '}' is just text, though in vector drawing mode it still delimits individual drawings. This also lets us nicely avoid '\0' hacks in the \t override tag handler in parse_tag.
* Add a mechanism for selective style overrideswm42014-06-051-21/+80
| | | | | | | | | | | | | | | This adds 2 new API functions: ass_set_selective_style_override() ass_set_selective_style_override_enabled() They can be used to force dialog text to use a specific ASS_Style. It uses a fuzzy heuristic for that, and the quality of results may vary. It does style overriding selectively and tries not to override things that need explicit styling. The heuristic for that isn't set in stone either, and can change with future libass versions. Closes libass#88.
* Merge pull request #100 from astiob/strokeGrigori Goronzy2014-06-021-1/+8
|\ | | | | Use FT_Outline_EmboldenXY
| * Use FT_Outline_EmboldenXY if availableOleg Oshmyan2014-05-301-1/+8
| |
* | Add BorderStyle=4, background color for textwm42014-06-011-0/+20
| | | | | | | | | | | | | | | | This is somewhat similar to BorderStyle=3, but with a number of differences. Mainly, this new BorderStyle doesn't create overlaps within an event. Closes #105.
* | Fix change detection when text is clipped to screenwm42014-06-011-3/+7
| | | | | | | | | | | | The glyphs are clipped before combining, so the combined bitmap can always have the same position, size, and address. This breaks the change detection. Or at least I think that's what happens.
* | Remove bitmap restridingwm42014-06-011-24/+0
|/ | | | It turns out we don't need this.
* shaper: add FriBidi error handlingGrigori Goronzy2014-05-291-1/+11
| | | | | | It is unlikely, but FriBidi might not process a string correctly, and we should handle that. Tested by making it fail always. This should also fix some compiler warnings.
*