summaryrefslogtreecommitdiffstats
path: root/libass
Commit message (Collapse)AuthorAgeFilesLines
* Match *VSF's shift direction for \an(4|5|6)Oneric2020-07-051-1/+1
| | | | | | closes #143 As libass doesn't support the 'Collsions' header, we are only concerned with the default stacking direction of *VSF here
* ass_shaper: fix harfbuzz deprecation warning; closes #320rcombs2020-07-051-7/+23
|
* Style-Nit: Adjust whitespacesOneric2020-07-056-20/+20
| | | | | | | - Convert tabs to spaces - Ensure one space between keywords and parenthesis - Ensure space between ')' and '{' - Trim trailing whitespace
* Supress -Wimplicit-fallthrough warnings for false positivesOneric2020-07-051-3/+3
|
* ass_font: fix typo in zero height checkOleg Oshmyan2020-07-051-1/+1
|
* font: simplify metrics handling; fixes #361rcombs2020-07-051-39/+26
| | | | | We used to do a lot of work to get freetype to imitate VSFilter's font-metrics handling. Instead, we now just duplicate its behavior directly early on.
* Fix incorrect collision detection coordinates with anamorphic videoOleg Oshmyan2020-07-051-1/+1
| | | | device_x is in anamorphic coordinates, the product of x2scr (not x2scr_scaled).
* renderer: fix default aspect ratio calculationOleg Oshmyan2020-07-051-4/+4
| | | | | | The ratio was accidentally flipped. Use the actual video size, not the screen size that includes margins.
* renderer: fix subtitles to full screen frame iff use_marginsOleg Oshmyan2020-07-053-54/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Based on a commit by wm4. Nowadays, margins are used by players such as mpv to implement video zoom & pan, although this was not expected when margins were first implemented in libass. This results in unpleasant rendering when panning too far, and it is argued that subtitles should not change size or move when panning and zooming at all. libass also makes an attempt to keep subtitles on screen even when the use of margins is disabled. This is unintuitive and prone to break. Fix this by strictly separating events which render as if they were part of the video, and events which should use margins. The latter will now use the entire screen as canvas, rather than using the video frame. This actually simplifies the various y2scr functions. To preserve scaling (mainly for styled subtitles where line breaks are carefully chosen based on font/video size ratio) and to avoid badly stretching out things like ASS Margins due to aspect ratio differences between video and screen, estimate the unpanned & unzoomed video size from the video aspect ratio and the screen size, and base all scaling on that. This means that if the user plays a video in letterboxed mode without extra margins, they get the same scaling as if they were playing the same video with the same video rectangle size without any margins at all (with some elements merely spaced out to make use of the black bars); and when they zoom & pan afterwards, the subtitles don't move or change size. This changes behavior even with ass_set_use_margins(_, 0). Before this, normal dialogue was forced into the visible video area (if negative margins were set); now it renders it as if it were part of the video. This also changes the behavior of left and right margins even with ass_set_use_margins(_, 1). Before this, normal dialogue was forced into the visible video width (with both positive and negative margins); now it renders across the entire width of the screen/window. For 4:3 video letterboxed on 16:9 screen, this means text will cross the edges of the video, which may look worse than before.
* renderer: remove bogus clip rect for unclipped subtitleswm42020-07-051-0/+6
| | | | | | | | | | | | | | Normal subtitles in use_margins mode, which do not have \clip tags or similar, were clipped in a nonsensical way. It was especially visible when moving subtitles up with ass_set_line_position(). This happened because state.clip_* is initialized with a clipping rectangle for the video area. Later it tries to translate the clipping rect accordingly, but this does not make much sense if you account for the margins. Just reset the clipping rect to the screen in these cases. explicit=0 is enough to know that the clipping rect was never explicitly set.
* Update names in copyright headersrcombs2020-05-294-4/+4
|
* ass_render: fix crash on parse_events failure after a drawingrcombs2020-05-271-1/+3
| | | | Closes #397
* render: silence a couple LLVM static analyzer warningsrcombs2020-05-261-4/+4
| | | | | | | | The while() checked the pointer for nullness, so the analyzer assumed it could potentially be null, and thus warned on the reference to it later. Using a do/while instead means we're only checking for subsequent linked-list entries, which was the intent here anyway, and avoids the warning.
* render: handle failure to realloc max_glyphsrcombs2020-05-261-10/+14
|
* render: handle more allocation failures in ass_renderer_initrcombs2020-05-261-12/+19
|
* render: allow passing null to ass_renderer_donercombs2020-05-261-0/+3
|
* render: reorder context fields to eliminate paddingrcombs2020-05-261-13/+14
|
* x86/cpuid: fix missing includercombs2020-05-261-0/+2
|
* fontselect: fix leak on errorrcombs2020-05-261-0/+1
|
* coretext: fix leak on errorrcombs2020-05-261-5/+6
|
* ass.c: add assert to silence analyzer warningrcombs2020-05-261-0/+1
|
* Fix libtool versionOleg Oshmyan2020-03-301-2/+2
|
* api: add ass_track_set_feature()wm42020-03-294-2/+46
| | | | | | | | Since C does not allow empty enums, there is an "example", which doesn't do anything. I think we might be able to make this change the default bidi direction or so. As if this commit, the flag set by it is also not available outside of ass.c, which should be solved by moving parser_priv to an internal header.
* API: clarify how new fields can be added to public typeswm42020-03-292-0/+5
| | | | | | | | This just gives a minor hint that all fields are frozen, but that the size of the structs are not part of the ABI. Most importantly, ASS_Style and ASS_Event are completely ABI-frozen, because ASS_Track has the "styles" and "events" arrays.
* ass_blur: check for memory allocation size overflowswm42020-03-061-1/+7
| | | | | | | | | Check for overflows that could happen with alignment and the multiplication. The INT_MAX / 4 is somewhat approximate and assumes that degenerate alignment values won't happen. This still assumes that a possibly overflowing end_w/end_h calculation doesn't make the compiler's optimizer destroy the overflow checks.
* parse: fix setting font size when no font is loaded; fixes #365rcombs2020-01-061-10/+1
|
* render: silence warningRodger Combs2019-11-071-1/+1
|
* coretext: move meta var into loop and zero-initializeRodger Combs2019-11-071-4/+1
| | | | | This makes it a bit clearer that the struct's contents won't be reused across multiple iterations
* fontselect: leave returned struct in a valid state on errorRodger Combs2019-11-071-0/+3
| | | | This fixes a double-free in be0d1613f79a95073d18d96a60e1394abf9316a2
* parse_tags: fix case where t==t1==t2Rodger Combs2019-11-071-1/+1
| | | | | This previously gave the pre-transition value; VSFilter's behavior is to give the post-transition value.
* coretext: fix error handling in get_font_fileMarvin Scholz2019-11-071-1/+7
| | | | | | | | Fixes a crash in case a font does not has kCTFontURLAttribute, which is the case for example on macOS 10.15.1 for the ".AppleSymbolsFB" font. Fix #358
* coretext: replace CT attr reads with freetype lookupsRodger Combs2019-09-261-112/+24
| | | | | This makes results much more consistent with other platforms, particularly around cases where fonts have multiple conflicting names.
* fontselect: add overflow checkRodger Combs2019-09-261-2/+2
|
* fontselect: expose the freetype-provided family as wellRodger Combs2019-09-261-9/+7
|
* fontselect: provide a way to use freetype to get font infoRodger Combs2019-09-262-0/+55
|
* coretext: use weight steps from macOS SDKRodger Combs2019-09-261-6/+26
|
* fontconfig: improve weight mappingRodger Combs2019-09-261-5/+36
| | | | | Use FcWeightToOpenType when available; otherwise, use an if/elseif ladder implementing the inverse of fontconfig's behavior.
* fontselect: load actual weight instead of a guess, when possibleRodger Combs2019-09-261-1/+1
|
* font: don't faux-bold fonts that are already bold enoughRodger Combs2019-09-261-2/+1
| | | | | | And conversely, do faux-bold fonts that are too thin The offset of 150 matches VSFilter's behavior
* font: add function to get the actual weight of a font faceRodger Combs2019-09-262-0/+18
|
* coretext: fix reading weights of some fontsRodger Combs2019-09-261-4/+4
| | | | | | | Some fonts have weights that can be expressed more precisely as doubles than as floats. In these cases, when writing to a float, CFNumberGetValue will set the value to the closest approximation, but return false (so we'd just clobber whatever it set with 0). Easy fix: just store to a double instead.
* renderer: fix incorrect deallocationDr.Smile2019-09-262-5/+5
| | | | | | | | | shift_event() can change "bitmap" field of ASS_Image struct so direct deallocation is no longer possible. This commit introduces additional field "buffer" into ASS_ImagePriv for that purpose. Fixes https://github.com/libass/libass/issues/310.
* Use FriBiDi 1.x API when availableKhaled Hosny2019-09-261-0/+22
| | | | This allows making use of the updated UBA in Unicode 6.3 and up.
* Update ass_fontselect.hC.W. Betts2019-09-261-3/+3
| | | | Fix documentation misspellings/texts. As reported by Clang.
* Fix bunch of UBDr.Smile2019-05-212-3/+5
| | | | Found by Coverity Scan and -fsanitize=undefined
* renderer: synchronize glyph motion to help composite cacheDr.Smile2019-05-201-14/+29
| | | | | | | | | | | | Slow movement of one glyph looks like periodic jumps by quantization step. In case of multiple glyphs at different subpixel shifts jumps of individual glyphs occur at different frames. That leads to performance penalty due to composite image regeneration at every such jump. This commit aligns glyphs in such a way that all jumps coincide at the same frames, greatly improving performance of \move commands. That optimization also helps in case of fast motion.
* outline: eliminate use of VLADr.Smile2019-05-201-2/+2
| | | | Fixes https://github.com/libass/libass/pull/321.
* outline: rearrange allocationsDr.Smile2019-05-203-13/+10
|
* Move outline transformations to ass_outline.cDr.Smile2019-05-203-29/+72
| | | | | | | | | This also potentially improves performance by copying and transforming in a single operation rather than copying first and then transforming the result. Also transformation function is specialized for case where expensive perspective division is not necessary.
* renderer: quantize blur radius and shadow offsetDr.Smile2019-05-204-14/+69
|
* renderer: eliminate use of bitmap pointers as mode flagsDr.Smile2019-05-202-42/+29
| | | | | | Render logic should depend only on input subs and not on some internal state such as bitmap pointers. That can prevent incorrect behavior in case of allocation failure.
* renderer: correctly handle case of small but nonzero \bordDr.Smile2019-05-201-1/+4
| | | | Fixes https://github.com/libass/libass/pull/309.
* renderer: rearrange render flagsDr.Smile2019-05-202-20/+28
| | | | Compatibility flag FILTER_DRAW_SHADOW has removed completely.
* bitmap: make ass_synth_blur() work on single bitmapDr.Smile2019-05-203-63/+32
| | | | | | Now ass_synth_blur() blurs one bitmap only. Higher level decisions (to blur or not to blur) have moved outside of that function.
* bitmap: remove level of indirection in bitmap functionsDr.Smile2019-05-207-202/+176
| | | | | This allows to use Bitmap struct directly as cache value and to remove bunch of unnecessary allocations.
* bitmap: use types of fixed size in Bitmap structDr.Smile2019-05-202-60/+49
|
* renderer: improve usability of rectangle_combine()Dr.Smile2019-05-201-6/+6
|
* cache: remove level of indirection in glyph metrics valueDr.Smile2019-05-203-26/+22
|
* renderer: improve handling of subpixel shiftDr.Smile2019-05-205-52/+56
| | | | | | | Integral pixel shift is extracted in quantization function now, taking account of full glyph transformation and not only translation part of it. It makes program logic more straight and ensures that subpixel shift from cache key never exceed full pixel.
* renderer: implement correct error estimation for strokingDr.Smile2019-05-201-74/+109
| | | | | Accuracy of border outline calculation should depend on subsequent transformation.
* renderer: move outline stroking immediately before rasterizationDr.Smile2019-05-202-67/+58
|
* Consolidate and quantize all transformationsDr.Smile2019-05-209-578/+578
| | | | | | | | | | | | | | This commit defers all outline transformations until rasterization stage. Combined transformation is then quantized and used as bitmap key. That should improve performance of slow animations. Also caching of initial and stroked outlines and bitmaps is now separate in preparation to proper error estimation for stroker stage. Note that Z-clipping for perspective transformations is now done differently compared to VSFilter. That clipping is mostly safety feature to protect from overflows and divisions by zero and is almost never triggered in real-world subtitles.
* renderer: fix potential memory leakDr.Smile2019-05-191-1/+3
|
* font: extract transformation from ass_font_get_glyph()Dr.Smile2019-05-193-28/+9
|
* drawing: extract transformation from parsingDr.Smile2019-05-193-134/+80
|
* cache: cleanupDr.Smile2019-05-194-79/+92
|
* cache: construct cache values only from corresponding keysDr.Smile2019-05-199-434/+448
| | | | | | | | | | | | | | | | | | | | This commit forces construction of cache values using only data available in its companion keys. That ensures logical correctness: keys are guaranteed to have all the necessary data, and prevents accidental collisions. Most fixes of cache logic correspond to minor problem when rendering is done with double parameter but cache key stores its approximate fixed-point representation. The only serious problem is missing scale of clip drawing. Also this commit removes unused scale parameters from glyph metrics cache key. Due to missing scale clip shapes that differed only in scale treated by cache system as identical. That can lead to incorrect reuse of cached bitmap of different scale instead of correct one. The only hack left is in glyph metrics cache with its unicode >= VERTICAL_LOWER_BOUND check.
* renderer: rewrite measure_text() to correctly account for leading newlinesDr.Smile2019-05-191-31/+22
|
* font: remove dependency on symbol codesDr.Smile2019-05-193-33/+27
| | | | | Leading newlines are now rendered, but still incorrectly: at full height rather than at half-height as required.
* renderer: use C99 features in some functionsDr.Smile2019-05-191-37/+30
| | | | | Note that return value is reversed in parse_events(), ass_render_event() and ass_start_frame() functions.
* drawing: separate drawing text reading from outline constructionDr.Smile2019-05-197-120/+83
| | | | Purpose of this commit is to simplify logic behind drawing handling.
* Eliminate advance.y from drawings and glyphsDr.Smile2019-05-194-15/+11
| | | | | Drawings always have advance.y = 0 and FreeType guarantees that for horizontal writing.
* drawing: remove unnecessary fields from ASS_Drawing structDr.Smile2019-05-194-22/+4
|
* font: remove unused fieldDr.Smile2019-05-193-15/+5
|
* stroker: correctly handle case of many small segmentsDr.Smile2019-01-111-45/+49
| | | | Fixes: https://github.com/libass/libass/issues/326.
* render: simplify detection of hard overridesDr.Smile2018-01-211-7/+7
| | | | | | | | | | | Previously each \r triggered full rescan of event string. After this commit such scanning is done once in init_render_context(). Additionally some lines have moved around to correctly account for state.evt_type (calculated in apply_transition_effects) and state.explicit (used in reset_render_context). That should fix cases with incorrectly applied style overrides for subs with banner scrolling effect before the first \r.
* parse_tags: handle argumentless \t inside \t() like VSFilterOleg Oshmyan2018-01-083-7/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | \t with no parantheses inside \t() resets the animation parameters of the \t() for subsequent tags, so they are animated as if the \t() was the single-argument version regardless of the actual number of arguments the \t() has. Equivalently, you could say parentheses are implied for \t inside \t(). For example, \t(20,60,\frx0\t\fry0\frz0) animates \frx from 20 to 60 ms and animates \fry and \frz for the whole duration of the line, just like \t(20,60,\frx0)\t(\fry0\frz0) or \t(20,60,\frx0\t(\fry0\frz0)). Technically, VSFilter simply resets the animation parameters for any \t it encounters but parses the embedded tags only if the \t has the right number of arguments. However, top-level animation parameters don't matter because top-level tags are not animated, while any nested \t that has parentheses terminates the containing \t because they share the closing parenthesis, so the fact that a nested \t with empty parentheses or with at least four arguments changes the animation parameters also doesn't matter because the containing \t immediately ends and the changed parameters have nothing to apply to. Thus the only situation where this has a visible effect is a nested \t without parentheses. Closes https://github.com/libass/libass/pull/296.
* parse_tags: don't recurse for nested \t()Oleg Oshmyan2018-01-081-1/+11
| | | | | | | | | | | | | This fixes https://bugs.chromium.org/p/oss-fuzz/issue