summaryrefslogtreecommitdiffstats
path: root/libass/ass_parse.c
diff options
context:
space:
mode:
authorOneric <oneric@oneric.stub>2022-10-22 03:48:24 +0200
committerOneric <oneric@oneric.stub>2022-10-22 03:56:29 +0200
commitcb49725e2f446f0c24aa1bcd161eb74abfe11291 (patch)
tree96503cd4a59212a1c19a65feb7f89da06317d2fe /libass/ass_parse.c
parent4958453575f59a029a411a318495da35184f4278 (diff)
downloadlibass-cb49725e2f446f0c24aa1bcd161eb74abfe11291.tar.bz2
libass-cb49725e2f446f0c24aa1bcd161eb74abfe11291.tar.xz
parse: replace mult_alpha and change_alpha exports
They are both used only once outside of ass_parse.c to apply fade, so instead export one function handling VSFilter-compatible fade application.
Diffstat (limited to 'libass/ass_parse.c')
-rw-r--r--libass/ass_parse.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/libass/ass_parse.c b/libass/ass_parse.c
index db25879..242fa4c 100644
--- a/libass/ass_parse.c
+++ b/libass/ass_parse.c
@@ -153,7 +153,7 @@ static void change_color(uint32_t *var, uint32_t new, double pwr)
}
// like change_color, but for alpha component only
-inline void change_alpha(uint32_t *var, int32_t new, double pwr)
+static inline void change_alpha(uint32_t *var, int32_t new, double pwr)
{
*var = (*var & 0xFFFFFF00) | (uint8_t)calc_anim_int32(new, _a(*var), pwr);
}
@@ -166,11 +166,18 @@ inline void change_alpha(uint32_t *var, int32_t new, double pwr)
* At least one of the parameters must be less than or equal to 0xFF.
* The result is less than or equal to max(a, b, 0xFF).
*/
-inline uint32_t mult_alpha(uint32_t a, uint32_t b)
+static inline uint32_t mult_alpha(uint32_t a, uint32_t b)
{
return a - ((uint64_t) a * b + 0x7F) / 0xFF + b;
}
+void ass_apply_fade(uint32_t *clr, int fade)
+{
+ // VSFilter compatibility: apply fade only when it's positive
+ if (fade > 0)
+ change_alpha(clr, mult_alpha(_a(*clr), fade), 1);
+}
+
/**
* \brief Calculate alpha value by piecewise linear function
* Used for \fad, \fade implementation.