summaryrefslogtreecommitdiffstats
path: root/libass/ass_render.c
Commit message (Collapse)AuthorAgeFilesLines
* 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.
* Implement fast quad-tree rasterizer in C and x86/SSE2/AVX2Dr.Smile2014-04-291-5/+41
| | | | Signed-off-by: Rodger Combs <rodger.combs@gmail.com>
* Fix premature parser exit on }{ in drawing modeOleg Oshmyan2014-04-271-1/+1
| | | | Fixes #75.
* Initialize \pbo for each eventOleg Oshmyan2014-04-101-0/+1
| | | | | Regression in commit 1f5eb5eb. Fixes issue #74.
* Fix change detection in presence of vector clipswm42014-03-061-1/+4
| | | | | | | | | | | | | | | | | Fixes this test case: Dialogue: 0,0:00:00.00,0:00:02.00,,,0,0,0,,{\fs50\pos(250,250)\iclip(m 0 0 l 400 0 l 400 220 l0 220)}Hello Dialogue: 0,0:00:02.00,0:10:00.00,,,0,0,0,,{\fs50\pos(250,250)\iclip(m 0 0 l 400 0 l 400 230 l0 230)}Hello The problem here is that the rendered output bitmap list itself does not change, only its contents (due to the different vector clip). ass_render_frame() will not set *detect_change correctly, and an application using this flag (like mplayer or mpv) will not update the screen as needed. Fix this with a very cheap hack: always report a full change if there's a vector clip. This is basically an emergency fix until we have a proper way to detect the change.
* Assume SSE2 on x86_6411rcombs2014-02-281-6/+3
|
* Don't include skipped glyphs in combined bitmapsOleg Oshmyan2014-02-121-3/+7
| | | | | | | Make sure to correctly handle situations where glyphs have info->linebreak and info->skip set at the same time. Fixes libass#44.
* Don't reset wrap_style on \rGrigori Goronzy2014-02-111-1/+1
| | | | This isn't part of a style. Fixes libass#45, GC#116.
* Use cluster advance in compute_string_bbox to account for \fspOleg Oshmyan2014-02-111-7/+4
| | | | Fixes libass#16 (the remaining sub-issue).
* Use a function for aligned memory allocationswm42014-02-021-14/+9
| | | | ...instead of doing this manually.
* Fix subpixel jumping of rotated glyph runsOleg Oshmyan2014-01-291-1/+5
| | | | | Rotation origin was not taken into account when caching glyph run bitmaps.
* Make apply_blur and make_shadow_bitmap static; remove an unneeded local variable11rcombs2014-01-251-94/+92
|
* Make sure to release each event's vector clip maskOleg Oshmyan2014-01-261-9/+6
| | | | | | | | Events with a clip mask but no text such as just Dialogue: ...,{\clip(m 47 32 )} had their clip masks carried over to the next event. Fixes GitHub issue #22.
* Simplify storage size handlingOleg Oshmyan2014-01-261-2/+2
| | | | No functional changes.
* Parser: don't increment render_priv->state.bm_run_id (unnecessary)11rcombs2014-01-251-1/+0
|
* Added x86 ASM functions11rcombs2014-01-251-4/+29
|
* Combine bitmaps before applying blur and shadow11rcombs2014-01-251-224/+521
|
* Remove some ass_msg() callswm42014-01-241-13/+0
| | | | | | | These aren't very useful for debugging due to the high volume of the log output in problem cases. In fact, all they do is making the code slower (the message callback can easily appear in the profiler output, even if the callback doesn't actually print the messages).
* Don't ignore trailing empty lineOleg Oshmyan2014-01-151-4/+5
| | | | | Trailing \N is effectively ignored, but \N\N should still yield an empty line.
* Do not reset \pbo and \p values after each drawingOleg Oshmyan2014-01-081-3/+5
| | | | Confirmed with VSFilter. This complements the previous commit.
* Terminate drawings on {Oleg Oshmyan2014-01-081-7/+8
| | | | | This brings us in line with VSFilter and also fixes Google Code issue #101.
* Distinguish cached glyphs with different hspacing when border_style == 3Oleg Oshmyan2014-01-081-0/+6
| | | | hspacing affects opaque box borders.
* Fix \fsp: use orig_scale_x, not post-fix_glyph_scaling scale_xOleg Oshmyan2014-01-081-1/+1
|
* Don't try to remove end-of-line \fspOleg Oshmyan2014-01-081-4/+0
| | | | | | | | VSFilter does not do this. The code being removed was already buggy: i > 0 should have been "got any non-skipped glyphs since last_break?", and hspacing should have been taken from glyphs[i-1].
* Scale distance to screen plane like blur radiusOleg Oshmyan2014-01-081-1/+2
| | | | | VSFilter forgets to scale this distance, just like it forgets to scale blur radius.
* A whole bunch of parsing and default value fixesOleg Oshmyan2014-01-071-1/+2
| | | | Obtained by reading the xy-VSFilter source code.
* Reset text origin on \fay changes for VSFilter compatibilitywm42013-10-241-2/+9
| | | | | | | | | | | | | | | | | | | | Comparing this rendering of this line: {\fnTahoma\c&H000000&\fs100\an7\fay0.115\pos(240,250)}——————–>{\fay0.0}——> To this line: {\fnTahoma\c&H000000&\fs100\an7\fay0.0\pos(240,250)}——————–>{\fay0.0}——> The second arrow is in the same place for both lines when using VSFilter, but the origin of the second shear is different when using libass. After every change in \fay or a newline, the vertical offset resets to 0. Fixes issue #80. Bug report and patch by BwackNinja (BwackNi...@gmail.com) (this commit corresponds to the patch issue_80_3.patch)
* Cosmetics: remove repetitionwm42013-09-261-38/+35
|
* Fix Hinting againwm42013-09-261-21/+43
| | | | | | | | | | | | Commit 05eb520 missed some duplicated bits in ass_shaper.c. <wm4> oh crap <zgreg> oh crap indeed Instead of duplicating the logic in ass_shaper.c, just change the glyphs before they even get into processing. This way, all code reading the font size etc. is affected. This essentially reverts commit c207000c, because it's not needed anymore.
* Skip both newline and carriage return.Reimar Döffinger2013-09-251-3/+5
| | | | | | | | '\r' characters weren't skipped correctly. SKIP_SYMBOL from original patch renamed to IS_SKIP_SYMBOL. Signed-off-by: wm4 <wm4@nowhere>
* Restore hintingwm42013-09-241-3/+10
| | | | | | | | | | | | | | | | | | | This was broken since commit f780146. For reasons why, read the commit message of that commit. To make it short, we set the font size to something large and constant (256), and scale the font outlines returned by freetype to the size we need in order to get smooth animation and accurate positioning. Of course, this obviously breaks hinting. Fix hinting by not using the hack mentioned above if hinting enabled. To mitigate the issues caused by freetype grid fitting and extremely bad ASS scripts (such as setting font size to very small values and scaling them up with \fscx/y), we still adjust the font size such that the font is never scaled in Y direction (only in X direction, because the \fscx/y tags can change aspect ratio). Also see google code issue #46.
* Remove unused variableswm42013-06-221-5/+0
|
* Allow different ASS_Library for ASS_Track and ASS_Rendererwm42013-06-221-3/+0
| | | | | | | | | | | Remove the explicit check whether the ASS_Track and ASS_Renderer were created from the same ASS_Library object. Logging will not be entirely consistent (some log messages go to the ASS_Track library when rendering), but otherwise it works. ASS_Library also contains embedded fonts added with ass_add_font(). It looks like the renderer will use the fonts from the ASS_Renderer library object.
* Fix blur scalingwm42013-06-221-0/+2
| | | | | | | | | Commit 0e1702ad7a6a827d "Add ass_set_storage_size and fix related scaling issues" attempted to fix blur scaling. This breaks blur scaling for players which don't call ass_set_storage_size(). This commit reverts the default behavior to the old behavior. The behavior when ass_set_storage_size() is called should be unchanged.
* Don't overwrite user-defined aspect ratio settingswm42013-03-291-2/+13
| | | | | | | | | | | | | | | | | | | | | ass_set_storage_size() overwrote the user-defined aspect ratio set with ass_set_aspect_ratio(). Change it so that if ass_set_aspect_ratio() is used, the ass_set_storage_size() parameters are not used for any aspect ratio calculations. (The storage size is still used for calculating the blur scale.) This simplifies the code as well, because the aspect ratio is now centrally calculated in ass_start_frame(). Update the doxygen. Make it clear that ass_set_storage_size() will be used for aspect ratio calculation, unless ass_set_aspect_ratio() is used. Also mention what libass actually does with the dar and sar parameters: it uses them to calculate a pixel aspect ratio, nothing else. Explicitly allow resetting the storage size with w=h=0. Document that it's allowed to remove the user defined aspect ratio by setting a pixel aspedct ratio of 0. See issue 6.
* Add type field to ASS_Image structwm42013-03-201-9/+13
| | | | Patch by chrisburel, posted on Google code issue 31.
* shaper: proper script/language handlingGrigori Goronzy2013-03-041-2/+1
| | | | | | | | | | | | | | | | | | | | | Determine script for each character and use this as an additional property for splitting up the text into runs. Characters of Common or Inherited script assume the script of the preceding character. If that is not possible (First character(s) in a run are Common/Inherited, for instance), a backwards scan is done so they can assume the script of the following character. Additionally, determine default language in case no override is set. This simply maps a language to a script, if a language exists that is mostly representative for a given script. Pango's mapping has been adapted. This helps with fonts that don't have OpenType features set up for default script/language pairs. It's also considered to be right approach by most people, and might help with correct OpenType rendering in some other cases. Fixes issue 85.
* Add ass_set_storage_size and fix related scaling issuesOleg Oshmyan2013-03-031-2/+7
| | | | | | | | \blur radius is not scaled from script to storage resolution but is scaled from storage to display resolution. The same applies to borders and shadows if ScaledBorderAndShadow is "no". (If it is "yes", borders and shadows are scaled from script to display resolution just like before.)
* Scale border size with user font size coefficientwm42013-01-111-0/+1
|
* Add Blur field to ASS_Stylewm42013-01-111-1/+1
| | | | | Useful when applications specify the style manually for non-ASS subtitles.
* Use glyph properties instead of renderer state in draw_opaque_boxOleg Oshmyan2012-12-281-7/+7
| | | | | | | scale_x, scale_y and hspacing should be read from the GlyphInfo of the glyph the box is based on, not from render_priv->state. The values in the renderer state are affected by override tags specified after this glyph, so they are irrelevant.
* Properly render opaque box shadows even when there is no borderOleg Oshmyan2012-12-281-3/+3
| | | | | | | | | | | | Even if the border size is zero, the shadow is supposed to be a copy of a hypothetical border: when border_style is 1, this coincides with the borderless glyph, but when border_style is 3, the shadow must be an opaque box. Opaque box borders are now generated regardless of border size being non-zero, and outline_to_bitmap3 gets a new flag indicating whether it should discard the border (after generating a shadow from it).
* Removes an useless warning message.Xidorn Quan2012-12-141-5/+0
| | | | | | Function "outline_to_bitmap" gives a warning itself when it returns NULL, so it is useless to print an addition warning for checking its return value.
* shaper: add hack to workaround grid-fittingGrigori Goronzy2012-10-161-1/+2
| | | | | This complements commit 7af780, which didn't correctly apply the hack to the advance/position as calculated by the shaper.
* Fix change detection in a rare caseGrigori Goronzy2012-10-011-1/+5
| | | | | | | | | If an empty track is passed to ass_render_frame, always set the change detection value to 2 (content and positions changed). This is acceptable in both the case that the previous call resulted in images (obviously) and in the case that the previous call resulted in no images (in that case the change detection result doesn't actually matter).
* Fix change detection when cache is clearedwm42012-10-011-0/+6
| | | | | | | | | | | check_cache_limits() clears the image list. If all subtitles disappear right in the frame the cache has been cleared, ass_detect_change() will see two empty image lists (old - not empty, but cleared, new - empty), and signal to the application that there was no change. As result, media players which rely on the change detection will keep displaying the last subtitle until the next subtitle event. This bug was found by uau and has been reported on IRC in February.
* Add ass_set_line_position() API function for subtitle positionwm42012-10-011-3/+12
| | | | | | | | This allows users to change the vertical position of normal subtitles. MPlayer has such a feature as -sub-pos option using its internal subtitle renderer. Bump LIBASS_VERSION to indicate the API addition.
* Fix \fay when used with multiline subswm42012-09-291-0/+1
| | | | | | | | | When \fay tag is applied to a multiline sub, it causes subsequent lines of the sub to be offset vertically as if it was rendered next to the previous line (not below). Patch by Hector Martin <hector@marcansoft.com>, with an additional correction related to libass issue #46.
* Fix issues with shearing in combination with scalingwm42012-09-291-11/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are two problems. First, the shearing tags (\fay and \fax) misbehave when used with scaling tags (\fscx and \fscy). We have to compensate for the scaling in either direction when shearing, because the shearing is applied after scaling. VSFilter, which by definition has the correct behavior, does it the other way around. Second, libass doesn't scale smoothly when small font sizes are involved. These can come either from downscaling (e.g. make the mplayer window smaller than the video with a video output like gl or vdpau), or from setting the font size manually. In these cases, the font size passed to freetype get very low, so that rounding errors or size adjustments due to hinting or other pixel grid fitting add up. The result is text rendered in the wrong size, or "pulsating" text if the font size depends on animated parameters. This is worsened by the practice found in subtitle scripts to use tag combinations like "\fscy2500\fs2" to get more precision for controlling font size (needed because VSFilter doesn't read fractional scale values). We solve the second issue by always requesting a constant font size from freetype, and then scaling the resulting glyph to the desired size. This seems to disable freetype's glyph fitting issue. The caveat is that it (obviously) also disables hinting, which may result in worse text quality. However, the combination of applying \fs and \fscx tags, and animating them, seems to leave no other choice. This fixes libass issue #46 (hopefully).
* Terminate drawings immediately on a \p0 tagwm42012-09-291-5/+32
| | | | | | | | | | | | | | | | The parsing code allowed override tags after \p0 to affect the drawing. This is incorrect. Finish the drawing object as soon as \p0 is encountered instead. This requires moving the code executing the style overrides from get_next_char() in ass_parse.c to the main render loop in ass_renderer.c, because we have to re-enter the rendering loop inside of a tag. The old code was simply executing all tags until a new character could be returned to the renderer loop, mutating up the state (RenderContext fields) for the drawing after the drawing was closed, but before it was rendered. This fixes libass issue #47.
* Fix resetting border style with \rSTYLEwm42012-09-291-4/+6
| | | | | | | | | With \rSTYLE, it is possible to change the border style within the same subtitle event. You can do this by setting a different BorderStyle value in the newly requested style. VSFilter handles this as expected, while libass uses a single border style for the whole subtitle event. This fixes libass issue #56.
* Refactor and fix border generationGrigori Goronzy2012-04-211-1/+3
| | | | | Make sure to update the border appropriately in the second pass, after parsing.
* Support \rSTYLENAME syntax</