summaryrefslogtreecommitdiffstats
path: root/libass/ass_outline.c
diff options
context:
space:
mode:
authorDr.Smile <vabnick@gmail.com>2019-05-20 00:48:26 +0300
committerDr.Smile <vabnick@gmail.com>2019-05-20 00:48:26 +0300
commitc80f332798238731e1ddf1b541748f3d5c8030f3 (patch)
tree15e6abced78c7bb18c496a9f8eb9d4d3f6613b95 /libass/ass_outline.c
parent13f5a18f2b6b7c384d2801beecd6d5c29c164ef1 (diff)
downloadlibass-c80f332798238731e1ddf1b541748f3d5c8030f3.tar.bz2
libass-c80f332798238731e1ddf1b541748f3d5c8030f3.tar.xz
Consolidate and quantize all transformations
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.
Diffstat (limited to 'libass/ass_outline.c')
-rw-r--r--libass/ass_outline.c44
1 files changed, 8 insertions, 36 deletions
diff --git a/libass/ass_outline.c b/libass/ass_outline.c
index 1ed94b8..109e09a 100644
--- a/libass/ass_outline.c
+++ b/libass/ass_outline.c
@@ -287,43 +287,15 @@ bool outline_close_contour(ASS_Outline *outline)
}
-void outline_translate(const ASS_Outline *outline, int32_t dx, int32_t dy)
-{
- for (size_t i = 0; i < outline->n_points; i++) {
- outline->points[i].x += dx;
- outline->points[i].y += dy;
- }
-}
-
-void outline_adjust(const ASS_Outline *outline, double scale_x, int32_t dx, int32_t dy)
-{
- int32_t mul = lrint(scale_x * 0x10000);
- if (mul == 0x10000) {
- outline_translate(outline, dx, dy);
- return;
- }
- for (size_t i = 0; i < outline->n_points; i++) {
- int32_t x = (int64_t) outline->points[i].x * mul >> 16;
- outline->points[i].x = x + dx;
- outline->points[i].y += dy;
- }
-}
-
-void outline_get_cbox(const ASS_Outline *outline, ASS_Rect *cbox)
+/*
+ * \brief Update bounding box of control points.
+ */
+void outline_update_cbox(const ASS_Outline *outline, ASS_Rect *cbox)
{
- if (!outline->n_points) {
- cbox->x_min = cbox->x_max = 0;
- cbox->y_min = cbox->y_max = 0;
- return;
- }
- cbox->x_min = cbox->x_max = outline->points[0].x;
- cbox->y_min = cbox->y_max = outline->points[0].y;
- for (size_t i = 1; i < outline->n_points; i++) {
- cbox->x_min = FFMIN(cbox->x_min, outline->points[i].x);
- cbox->x_max = FFMAX(cbox->x_max, outline->points[i].x);
- cbox->y_min = FFMIN(cbox->y_min, outline->points[i].y);
- cbox->y_max = FFMAX(cbox->y_max, outline->points[i].y);
- }
+ for (size_t i = 0; i < outline->n_points; i++)
+ rectangle_update(cbox,
+ outline->points[i].x, outline->points[i].y,
+ outline->points[i].x, outline->points[i].y);
}