summaryrefslogtreecommitdiffstats
path: root/libass/ass_bitmap.c
Commit message (Collapse)AuthorAgeFilesLines
* renderer: quantize blur radius and shadow offsetDr.Smile2019-05-201-4/+3
|
* renderer: eliminate use of bitmap pointers as mode flagsDr.Smile2019-05-201-0/+6
| | | | | | 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.
* bitmap: make ass_synth_blur() work on single bitmapDr.Smile2019-05-201-59/+27
| | | | | | 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-201-64/+44
| | | | | 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-201-54/+43
|
* Consolidate and quantize all transformationsDr.Smile2019-05-201-30/+3
| | | | | | | | | | | | | | 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.
* Consolidate bounding box operationsDr.Smile2017-09-171-5/+5
|
* renderer: fix handling of empty outlinesDr.Smile2017-07-311-17/+9
|
* renderer: switch to using two border outlines instead of oneDr.Smile2017-07-311-8/+19
|
* renderer: remove legacy FreeType rasterizerDr.Smile2017-07-311-105/+0
|
* rasterizer: implement simultaneous rasterization of two outlinesDr.Smile2017-07-311-1/+1
|
* cosmetic: extract most of the outline-related functions into separate fileDr.Smile2017-07-311-0/+1
|
* 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
* bitmap: use calloc instead of malloc/memsetRodger Combs2016-09-241-20/+12
| | | | This can improve perf somewhat with large bitmaps
* 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_bitmap: fix potential NULL derefwm42015-09-071-3/+7
| | | | | | | | | | | | | Another consequence of the trickiness in this code. This codepath for opaque_box=1 assumes both bm_o and bm_g are set, but if memory allocation fails somewhere, bm_o could be non-NULL, but bm_g NULL, which then would result in a crash when accessing bm_g. Possibly this code could be cleaned up to look much nicer (and not have dozens of hidden, obscure bugs), but for now this fixes the potential crash found by Coverity. Fixes CID 146125.
* Implement cascade gaussian blurDr.Smile2015-07-041-258/+24
| | | | | | | | | | 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
* Fix code path of rasterization through FreeTypeDr.Smile2015-07-011-2/+2
|
* Switch to virtual function tableDr.Smile2015-06-261-60/+66
| | | | | | | | | | 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-56/+127
|\ | | | | \be fixes including clipping and value range
| * Make sure the synth tmp buffer is large enough for be_blurOleg Oshmyan2015-02-101-1/+2
| |
| * Use correct types in be_blur_cOleg Oshmyan2015-02-101-6/+5
| | | | | | | | | | | | | | | | Also fix a related sort-of-bug: a multiple of sizeof(uint16_t) was being added to a pointer that already pointed to uint16_t. This was not causing any harm given enough space in the buffer. Fixing the above also lets us combine the two memsets.
| * Add enough padding for \be to avoid clippingOleg Oshmyan2015-02-101-0/+29
| | | | | | | | | | To avoid making bitmaps unnecessarily large, use just the necessary amount of padding for the given \be value.
| * Calculate \be using [0..64] value range (like VSFilter)Oleg Oshmyan2015-02-101-9/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | To avoid banding in the output, the full [0..255] value range is restored before the last \be pass, which then uses the full range and hides the bands by virtue of being a blur. With this, our \be finally closely matches VSFilter's. The only visible difference (other than the lack of banding) is in clipping: we add proper padding and output the whole blurred image, while VSFilter does not add any padding and hence clips the blurred image too early.
| * Apply \be after \blur (like VSFilter)Oleg Oshmyan2015-02-101-14/+14
| |
| * Don't forget to apply \be to the first/last row/column (again)Oleg Oshmyan2015-02-101-29/+26
| | | | | | | | | | The implementation of \be was changed to xy-VSFilter's, which (like VSFilter's) reads but does not write out the first/last row/column.
* | Skip memset() when using internal rasterizerDr.Smile2015-02-091-9/+4
|/
* Clean up bitmap combiningDr.Smile2015-01-281-15/+6
| | | | | | | | | | 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-4/+41
|
* Flip coordinate system in rasterizerDr.Smile2014-11-231-4/+3
|
* Fix some of the recently added checkswm42014-11-171-2/+2
|
* Some more overflow checkswm42014-11-161-4/+15
|
* Deal with code-duplication bullshitwm42014-11-161-1/+1
| | | | | | Much of outline_to_bitmap() is duplicated. What? Add the overflow check to duplicated code too.
* Check the overflow check for overflowswm42014-11-161-1/+1
| | | | | | Seriously... Checking for negative values might not be needed, but do it anyway.
* Check bitmap allocation for overflowswm42014-11-161-1/+4
| | | | | | | | This actually fixes #146. The overflow check itself is obvious. Also, make ass_align() return an unaligned value if aligning it would overflow. This is probably better, as it for example makes the overflow check in the caller simpler.
* Fix recently introduced overflow check (again)wm42014-11-141-6/+2
|
* Fix the bugwm42014-11-141-2/+2
| | | | | | Commit 8536eaa was slightly broken: for some incomprehensible reason, (w + 1) memory instead of w is needed. The missing space could lead to memory corruption and crashes.
* Use stdbool.h in another placewm42014-11-131-8/+8
| | | | Also fix that ass_synth_init() could deref NULL.
* Check for another overflow in blur codewm42014-11-131-18/+20
|
* Move apply_blur() to ass_bitmap.cwm42014-11-131-2/+92
| | | | Put all code into one place, which makes it easier to follow.
* Check against some overflows and allocation failures on blurwm42014-11-111-6/+16
| | | | This still doesn't catch all cases.
* Check more mallocswm42014-11-091-1/+2
| | | | This is just a start and gets most easy ones.
* Check more allocationsRodger Combs2014-11-081-0/+16
| | | | Part of #146
* Fix subpixel shadow shiftDr.Smile2014-11-061-34/+12
|
* Only use the subpixel value when shifting bitmaps. Fixes #142Rodger Combs2014-11-051-2/+4
|
* Remove bitmap restridingwm42014-06-011-12/+0
| | | | It turns out we don't need this.
* Skip useless memset() when copying a bitmapRodger Combs2014-05-251-3/+11
|
* Implement fast quad-tree rasterizer in C and x86/SSE2/AVX2Dr.Smile2014-04-291-8/+67
| | | | Signed-off-by: Rodger Combs <rodger.combs@gmail.com>
* Don't crash on \fscx0 with non-zero \blurOleg Oshmyan2014-03-281-5/+2
| | | | Regression in commit 98707694.
* Fix handling of top two pixel rows in be_blur_cOleg Oshmyan2014-03-131-3/+4
| | | | | | | | | 5dd56af2 replaced our implementation of \be with xy-VSFilter's. This error is not present in the xy-VSFilter code; it was introduced by accident in a merge that was later squashed as part of 5dd56af2. Note: the new \be reads in but does not write out the first and last row and column of pixels.
* Better fix for zero area outlinesDr.Smile2014-03-071-2/+8
| | | | | | Signed-off-by: wm4 <wm4@nowhere> Commit 04b51c2d broke BorderStyle=3 with text that had spaces.
* Don't crash on \fscx0wm42014-03-031-0/+3
| | | | | | | | | | | | | | Freetype can return a bounding box with all fields set to INT_MIN if an outline with all points set to 0 is used. This can happen e.g. with \fscx0, but also in more complicated cases. (In the original crashing sample, this was probably caused in combination with an embedded font.) Such a bounding box causes libass to crash, because it will enlarge the combined bitmap bounding box to a ridiculous size. Just skip outlines that have en empty bounding box. This is probably the correct thing to do, and won't pass INT_MAX down to other parts of libass.
* Don't use an unsigned it to check for <0 :|11rcombs2014-02-281-1/+1
|
* Use a function for aligned memory allocationswm42014-02-021-9/+8
| | | | ...instead of doing this manually.
* Fixed incorrect spelling in copyright notice11rcombs2014-01-291-1/+1
|
* Added copyright notice for xy \be blur11rcombs2014-01-271-0/+1
|
* Combine bitmaps before applying blur and shadow11rcombs2014-01-251-87/+138
|
* Don't forget to apply \be to the last row/columnOleg Oshmyan2013-12-171-0/+4
|
* Fix mismatched/out-of-bounds accesses in vertical \blurOleg Oshmyan2013-12-171-2/+2
|
* Speed up \blur table generationOleg Oshmyan2013-12-121-7/+11
| | | | Based on xy-VSFilter commit 54391d3a.
* Improve blur quality: use volume 65536 and initialize left columnOleg Oshmyan2013-12-121-36/+34
|
* Properly render opaque box shadows even when there is no borderOleg Oshmyan2012-12-281-2/+5
| | | | | | | | | | | | 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).
* Apply blur to both glyph and border when using opaque box bordersOleg Oshmyan2012-12-281-3/+3
|
* Fix box blur for non-bordered outlinesGrigori Goronzy2011-07-041-1/+1
| | | | | | This horrible bug was introduced by commit c13cb2. Pointed out by uau.
* Remove outdated commentGrigori Goronzy2011-06-261-2/+0
|
* bitmap: add strideGrigori Goronzy2011-06-261-36/+44
| | | | | Add stride support to the basic bitmap type used for low-level rasterization.
* Remove unused functionGrigori Goronzy2011-06-211-15/+0
|
* Convert to high-level rasterizer parts to outlinesGrigori Goronzy2011-06-151-13/+12
| | | | | This covers rasterization, filtering and blending for one render item.
* Render outlines, not glyphsGrigori Goronzy2011-06-131-34/+41
| | | | | | | | | | | | | | | | | | | libass can render both regular glyphs (extracted from a font) and drawings, which are inserted into an existing glyph so far. This is a rather crude hack. However, it is necessary, as the renderer only works with FT_Glyphs. The obvious solution is to work on the underlying outlines directly instead. This is the first step to make this possible: change the basic rasterizer to use the outline-specific rasterization functions. There are more advantages: - It's more efficient. The bitmap can be directly rendered into the bordered target bitmap. - This should make it easier to adapt the renderer to run-based rendering later on (the pixels are ORed into the target) The higher-level rendering code still needs to be adjusted.
* Relicense to ISCGrigori Goronzy2010-09-281-12/+10
| | | | | | In hope to make libass as useful as possible, relicense libass to ISC, a simplified 2-clause BSD license. All contributors who provided non-trivial changes have granted their permission for this.
* Get rid of NULL checks for freeGrigori Goronzy2010-08-091-13/+7
| | | | | The useless "if (foo) free(foo)" idiom is all over the place, just get rid of it finally...
* Check vector clip mask bounding box sizeGrigori Goronzy2010-08-011-1/+1
| | | | | | Similar to regular glyphs, check the bounding box of the clip mask and refrain from rendering humongous masks, which can take up considerably memory.
* Simple optimizations to memory handlingGrigori Goronzy2010-06-271-3/+2
|
* Copy shadow bitmap from glyph bitmapGrigori Goronzy2009-09-161-19/+13
| | | | | It's not necessary to create the shadow bitmap by adding the glyph bitmap to the outline bitmap; the outline is a superset of the glyph.
* opaque box: do not subtract glyph from borderGrigori Goronzy2009-09-011-2/+5
| | | | | Similar to VSFilter, do not subtract the glyph bitmap from the border bitmap when BorderStyle 3 is used.
* Revert "Merge glyph and outline bitmap better"Grigori Goronzy2009-09-011-1/+1
| | | | | | This reverts commit d3cd5b0148d64ae0f6e288e69b09acfe639fdcce. This hack improved blending in few situations, but at the same time broke it in lots o others; get rid of it.
* Rename typedefs (breaks API)Grigori Goronzy2009-08-061-18/+18
| | | | | | Rename all typedefs from the convention foo_bar_t, which can possibly conflict with POSIX types, to FooBar (and ASS_FooBar for public API typedefs). Fix formatting and stray comments while at it.
* Clean up typedefs/structsGrigori Goronzy2009-07-281-1/+1
| | | | | Remove useless _s suffix from struct names and remove struct name where not needed (only the typedef'd struct is used). Clean up API headers.
* Fix rasterizer error handling (double free)Grigori Goronzy2009-07-221-1/+0
| | | | | | In case rasterizing a glyph is successful, but rasterizing its outline is not, do not free the glyph bitmap. It will be freed in cache cleanup later. Freeing it earlier leads to a double free.
* Merge glyph and outline bitmap betterGrigori Goronzy2009-07-121-1/+1
| | | | | | | | Use a different threshold for merging the outline and glyph and also adjust the merge amount. This fails to give complete transparency (and thus will yield slightly darker looking glyphs,