summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Release 0.13.70.13.7Grigori Goronzy2017-06-035-5/+7
|
* 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
* Fix function prototypeGrigori Goronzy2017-06-011-1/+1
| | | | | Not a serious issue: arguments were named/ordered incorrectly. No functional change.
* fontselect: cleanup lazy font index evaluationGrigori Goronzy2017-06-011-6/+8
| | | | Fixes a possible NULL pointer dereference, reported by Coverity.
* directwrite: fix font collectionsGrigori Goronzy2017-06-014-0/+33
| | | | | | | | | | | | | | | | DirectWrite's FontFileStream does not actually use the data of a specific font in a collection, which was an expectation of the existing code. It simply returns a stream to the underlying file, collection or not. So we need to get the index of the font. This needs to be done lazily as this information is only available in a FontFace, which is expensive to initialize. Add a new optional font provider function for lazy initialization of the index and use it. This is similar to the check_postscript callback. Fixes libass#275. v2: fix type of returned value.
* Fix PlayResX/Y calculationsGrigori Goronzy2017-05-101-2/+2
| | | | | | | | | Avoid that PlayResY is set to 0 when only PlayResX is specified and set to 1. Setting PlayResY to 0 results in divide-by-zero errors. Also fix PlayResX calculations in case only PlayResY is specified, for completeness. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1474.
* Changelog: updatewm42017-04-271-0/+12
|
* Remove arbitrary bitmap size limitRodger Combs2017-02-141-2/+2
| | | | | | | | We're not aware of any specific reason for this number to be used, and actual potentially-dangerous cases should be handled by the other limits. Fixes #260
* Don't limit size of "uuencoded" font linesOleg Oshmyan2017-02-141-6/+1
|
* Fix decode_font when size % 4 != 0 or data contains illegal bytesOleg Oshmyan2017-02-141-22/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When given a byte c, decode_chars expects that 0 <= c - 33 <= 63, i. e. that only the six lowest bits of c - 33 are possibly set. With this assumption, it shifts and adds together multiple c - 33 values. When c > 96, c - 33 has high nonzero bits, which interferes with other shifted terms. c < 33 is even worse: c - 33 is negative (if unsigned char fits in int), and left-shifting negative numbers has undefined behavior. Even before the shift, on common platforms with a two's complement representation of negative integers (or if unsigned char does not fit in int and is promoted to unsigned int), c - 33 has high nonzero bits, which again interfere with other shifted terms. To make matters worse, even perfectly valid encoded data is affected when size % 4 != 0, as decode_font calls decode_chars with '\0', which leads decode_chars to shift and add -33, causing undefined behavior and/or incorrect output. Take our cue from VSFilter and bit-mask c - 33 to keep only the six relevant bits. To ensure that we get the same bits as VSFilter when c < 33 and to avoid the undefined behavior of left-shifting negative numbers, convert the number to unsigned before masking and shifting. While we are at it, rewrite decode_chars entirely to get rid of any GPL code from mkvtoolnix. Related mkvtoolnix bug: https://github.com/mbunkus/mkvtoolnix/issues/1003 Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=516. Also allocate exactly the right amount of memory for the font, because why not.
* ass_lazy_track_init: handle negative PlayResX/PlayResYOleg Oshmyan2017-02-141-6/+6
| | | | Like VSFilter, treat negative values the same as missing values.
* string2timecode: don't truncate milliseconds to intOleg Oshmyan2017-02-141-1/+1
| | | | | | | | | Commit 8c8741fe2000d4b4d89a53f894363a42288cec3e attempted to fix this expression and make it use the full range of long long, but it missed the millisecond term. This fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=522. The entire timestamp can still overflow long long though.
* Reuse numpad2align in parse_tagOleg Oshmyan2017-02-144-31/+27
|
* Fix parsing of unusual Alignment values in ASS style definitionsOleg Oshmyan2017-02-141-6/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Handle large and negative values except INT32_MIN like VSFilter. This avoids both overflow and inconsistent internal state. This fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=523. VSFilter handles INT32_MIN like a mix of \an1, \an2 and \an3: * Vertical alignment is bottom. * Lines within the event are center-aligned. * Without \pos or \move, the center of the event is aligned with the right edge of the screen minus MarginR. * With \pos or \move, the left edge of the event is aligned with the position point. * Without \org, the rotation origin is aligned with the horizontal center of the event. * (With \org, the rotation origin is as specified.) If we wanted to emulate this in libass, the cleanest way would be to introduce a new horizontal alignment constant for this purpose that would be used only for ASS style definitions with Alignment INT32_MIN. This commit makes no attempt to do this and instead arbitrarily picks \an2 for style definitions with Alignment -INT_MAX-1, which equals INT32_MIN if int is int32_t. The fact that int is platform-dependent is one of the reasons for this. We could change Alignment to be int32_t instead of int for perfect VSFilter compatibility, but the same applies to many other fields that currently use platform-dependent types.
* Don't treat :;<=>? as hexadecimal digits in color headersOleg Oshmyan2017-02-141-1/+1
| | | | Oops.
* Explicitly handle FcPatternGetString(FC_POSTSCRIPT_NAME) mismatchOleg Oshmyan2017-02-111-3/+4
| | | | | | | This does not affect functionality in any way, but it hopefully makes the logic easier to follow. Resolves CID 175691.
* Travis CI: remove HarfBuzz and re-remove Fontconfig from OS X buildsOleg Oshmyan2017-02-071-1/+1
| | | | | | | | | | | Installing HarfBuzz through Homebrew seems to be consistently slow whether we use the bottles and disable the Fontconfig cache or build it from source and drop Fontconfig and other dependencies entirely. To speed up OS X builds, disable both HarfBuzz and Fontconfig. We build with HarfBuzz and Fontconfig on Linux, and we should not have any platform-dependent code that depends on them, so this should not reduce our code coverage.
* Travis CI: re-enable Fontconfig on OS X but force no cache builtOleg Oshmyan2017-02-061-1/+1
| | | | | | | | | | | | | Building HarfBuzz from source works to avoid Fontconfig, but it is still fairly slow. To further speed up the build, try to use only the prebuilt bottle packages (which inevitably brings in Fontconfig as a dependency) but hack the Fontconfig formula to avoid building the font cache. Adding Fontconfig is not the goal of this commit, as we already have it on Linux and our Fontconfig-related code "should" work equally well on other platforms. But since we can now afford it, explicitly ask Homebrew to install Fontconfig even if the dependency that brings it in disappears from Homebrew in the future, and enjoy the improved code coverage.
* Travis CI: build with HarfBuzzOleg Oshmyan2017-02-051-1/+1
| | | | | | | | | | | | On OS X, disable some unnecessary HarfBuzz dependencies. This triggers a source build of HarfBuzz, but it should be fast and avoids bringing in Fontconfig through a dependency chain, which we want to avoid as it wastes a lot of time building its cache when installed. The dependency that brings in Fontconfig is gobject-introspection, but we don't need icu4c either, so disable that to save a little more time that would be spent installing icu4c. We could also disable glib, but the fribidi formula also has it as a dependency and brings it in anyway.
* Travis CI: run Coverity Scan on every master buildOleg Oshmyan2017-02-051-1/+1
| | | | | | We never remember to push to the coverity_scan branch, so currently Coverity Scan never runs. Our master builds are not very frequent, so we should be able to afford running Coverity Scan on every build.
* Travis CI: build using both GCC and ClangOleg Oshmyan2017-02-051-0/+9
| | | | | On OS X, `gcc` is just an alias for Clang, so exclude it to avoid wasting resources doing the exact same build job twice.
* Travis CI: remove libtool reinstall hack on OS XOleg Oshmyan2017-02-051-1/+1
| | | | | | | | | | | The problem was fixed in Homebrew in libtool 2.4.6_1: https://github.com/Homebrew/homebrew-core/commit/712f737a7f64f0fd905357c3765cdce0821a4af2 Since https://blog.travis-ci.com/2016-10-04-osx-73-default-image-live/, this libtool comes preinstalled on Travis CI, thus the hack is no longer needed. Homebrew bug report possibly relevant to the original problem: https://github.com/Homebrew/legacy-homebrew/issues/43874
* Travis CI: explicitly install FreeType on LinuxOleg Oshmyan2017-02-051-1/+1
| | | | | | | Do this for consistency with the other library dependencies. For reference, currently, both FreeType and Fontconfig are preinstalled and don't need to be explicitly mentioned.
* Travis CI: don't require Fontconfig binariesOleg Oshmyan2017-02-051-1/+1
| | | | | | | | | | Only the library is needed. In fact, `apt-get install fontconfig` didn't even install the library at all. Luckily, the package we actually want is preinstalled on Travis CI. We could continue to rely on this fact and completely remove Fontconfig from the install list, but it's clearer and possibly more future-proof to explicitly list it there.
* Travis CI: disable Fontconfig on OS XOleg Oshmyan2017-02-051-1/+1
| | | | | | Homebrew generates the Fontconfig cache when installing Fontconfig, which delays the build by several minutes. Disable the Fontconfig font provider on OS X to avoid this.
* Reduce precision of border width in outline cache keysOleg Oshmyan2017-01-312-5/+5
| | | | | | | 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-312-19/+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_api: do not discard old images on reconfigurationwm42017-01-131-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I noticed that when resizing the mpv window while playback is ongoing and with subtitles, that subtitles could sometimes get "stuck" on the screen. The stuck subtitle would remain until the next subtitle event, or until seeking to a position that has subtitles again. It turned out that this was a libass change detection bug. The following steps should reproduce the problem: 1. call ass_render_frame() with a time that has subtitles 2. call ass_set_frame_size() with a different size 3. call ass_render_frame() with a time that has no subtitles The previous call will return with *detect_change==0. To make this worse, libass will deallocate image data before the next ass_render_frame() or ass_renderer_done(), which violates the API and could possibly make some API users crash. (That the user can rely on this is not documented though.) There are two possible solutions: 1. Set a flag in ass_reconfigure(), that makes the next ass_render_frame() call always return *detect_change==2. 2. Do not discard the previous subtitles (images_root), so change detection can work reliably. This commit implements 2. - I prefer this in part because it doesn't clobber the previously returned image list before the next ass_render_frame() call. (As pointed out above, this might be unexpected behavior to the API user.) This is a regression and was possibly broken by commit dd06ca and later. I did not check whether it actually behaved sanely before that change, but it probably did to a degree.
* 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.
* Bump ABI version and release 0.13.60.13.6Oleg Oshmyan2017-01-035-6/+10
| | | | | | sizeof(ASS_Style) is actually part of the ABI, so adding the Justify field in commit e54c123d5a08b6212533ddcced2cb1a50fa3d2b2 broke the ABI even though we tried to avoid it by placing the field at the end of the struct.
* Release 0.13.50.13.5Oleg Oshmyan2016-12-295-4/+18
|
* api: make ass_set_cache_limits() work on total bitmap cache sizesDr.Smile2016-12-292-4/+16
| | | | | | Previously was possible to set only bitmap_max_size, now requested memory amount is divided between bitmap_max_size and composite_max_size.
* Fix memory leak when Language header is defined more than onceOleg Oshmyan2016-12-291-0/+1
| | | | | Discovered by OSS-Fuzz. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=229.
* parse_tag: don't consume *end == ')' when called recursivelyOleg Oshmyan2016-12-291-1/+1
| | | | | This did not cause any problems, but it's nicer to guarantee that the return value is <= end.
* Fix buffer overread in parse_tag when end points to a spaceOleg Oshmyan2016-12-291-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | When parse_tag is invoked recursively to handle the animated tags inside a \t tag, the `end` argument is taken from the `end` field of a struct arg in the enclosing parse_tag. When struct arg is filled by push_arg, this field is always right-trimmed using rskip_spaces. Ultimately, the inner parse_tag invokation sees its `end` argument point not to the ')' or '}' of the \t as it expects but rather to the spaces preceding the ')' or '}'. At this point, when parse_tag calls skip_spaces, which is ignorant of the end pointer, it happily skips over the spaces preceding the ')', moving the pointer past `end`. Subsequent `pointer != end` comparisons in parse_tag fail (as in fact `pointer > end`), and parse_tag thinks it is still inside the substring to be parsed. This is harmless in many cases, but given either of the following inputs, parse_tag reads past the end of the actual buffer that stores the string: {\t(\ } {\t(\ )(} After this commit, parse_tag knows that `end` can point to a sequence of spaces and avoids calling skip_spaces on `end`, thus avoiding the overread. Discovered by OSS-Fuzz. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=194.
* directwrite: drop SAL annotationsOleg Oshmyan2016-12-281-16/+16
| | | | | | | MinGW and old versions of mingw-w64 don't define the SAL macros. They don't serve any value to us, so just remove them from our code. See https://github.com/libass/libass/pull/251.
* ass_strtod: correctly convert large negative exponentsOleg Oshmyan2016-11-211-4/+43
| | | | | | | | | | | | Avoid overflow in dblExp that prevents subnormal numbers from being generated (or small normal numbers if `double` supports many more negative exponents than positive): if `10**abs(exp)` would overflow and we actually want a negative exponent, switch to using precomputed negative powers of 10 rather than positive. Also avoid underflow for numbers with a large negative exponent where the exponent alone underflows but the significand has enough digits to cancel this out, e. g. in `10e-324` with IEEE 754 double.
* ass_strtod: don't cast away constOleg Oshmyan2016-11-211-2/+3
|
* ass_strtod: handle overflowing exponentsOleg Oshmyan2016-11-211-7/+37
| | | | | | | | | | | | The exponent may overflow an integer, e. g. in `14e888888888888888888888888888880000000000000000000000000000` on a 32-bit platform. Correctly handle this, including the case when the exponent overflows but the whole string still describes a valid floating-point number, e. g. in `1[4294967200 zeros]e-4294967300`. This fixes libass#244. Buffer overflow was fixed in 67f647e, and this ensures that the string is converted to the correct number.
* ass_strtod: skip leading zeros in mantissaOleg Oshmyan2016-11-211-3/+14
| | | | | | | | ass_strtod reads at most 18 leading digits of the mantissa. This previously included zeros, even though they are not significant digits, e. g. 0.000000000000000001e18 was converted to 0.0. After this commit, leading zeros before and after the decimal point will be skipped, so the above number will be correctly converted to 1.0.
* ass_strtod: don't report overflow for 0.0e[huge exponent]Oleg Oshmyan2016-11-211-1/+3
|
* ass_strtod: use size_t for substring lengthsOleg Oshmyan2016-11-211-18/+19
| | | | | This fixes overflow on extremely long input strings. See libass#244.
* Add text justificationDan Oscarsson2016-11-125-3/+48
| | | | | | | | | | | | | | | | | | | | | | | 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.
* Add CVE identifiers of the fuzzing fixes.Grigori Goronzy2016-10-051-1/+3
| | | | | As assigned by [1]. Unfortunately I only learned of the CVE assignments after the release.
* Release 0.13.40.13.4Grigori Goronzy2016-10-055-4/+12
|
* 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
* Fix blur coefficient calculation buffer overflowGrigori Goronzy2016-10-041-1/+1
| | | | | Found by fuzzer test case id:000082,sig:11,src:002579,op:havoc,rep:8. Correctness should be checked, but this fixes the overflow for good.
* Fix memory leaksGrigori Goronzy2016-10-042-0/+2
| | | | Found by fuzzer test case id:000051,sig:11,sync:fuzzer3,src:004221.
* shaper: fix reallocationGrigori Goronzy2016-10-041-0/+1
| | | | | | | | Update the variable that tracks the allocated size. This potentially improves performance and avoid some side effects, which lead to undefined behavior in some cases. Fixes fuzzer test case id:000051,sig:11,sync:fuzzer3,src:004221.
* CI: Don't fail on MacOS if brew cannot remove libtool.torque2016-09-241-1/+1
| | | | | This is the better option, as it won't break the CI script if travis ends up removing the preinstalled libtool bundle for whatever reason.
* Fix broken MacOS CI.torque2016-09-241-1/+1
| | | | | | | At some point in the past Travis and homebrew colluded to break the preinstalled libtool on travis MacOS instances. Forcing brew to reinstall libtool seems to be the common solution that several other projects on github have used.
* Fix license titleGrigori Goronzy2016-09-241-1/+1
| | | | | I'm a dummy. Of course it is the ISC license. I started to relicense libass to ISC myself, after all.
* Release 0.13.30.13.3Grigori Goronzy2016-09-245-4/+12
|
* Improve license fileGrigori Goronzy2016-09-241-0/+4
| | | | Fixes libass#234.
* bitmap: use calloc instead of malloc/memsetRodger Combs2016-09-246-30/+25
| | | | This can improve perf somewhat with large bitmaps
* cache: fix ownership tracking issues of ASS_FontDr.Smile2016-07-162-1/+2
|
* font load from dir: use MSGL_INFO instead of MSGL_WARNAvi Halachmi (:avih)2016-07-111-1/+1
| | | | | | | | This is a normal course of action and should not generate a warning, especially for applications which use libass and might notify the user on such "warnin