summaryrefslogtreecommitdiff
path: root/pkg/mpv/patch/0005-Support-lua-5.4.patch
blob: 0236347428e4d09a30b9149f532bf22bf6a39958 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
From 8ab50c2f6569389e574546a306bd73da142c060b Mon Sep 17 00:00:00 2001
From: Michael Forney <mforney@mforney.org>
Date: Sun, 3 Dec 2023 11:57:01 -0800
Subject: [PATCH] Support lua 5.4

---
 player/lua.c       | 5 -----
 player/lua/osc.lua | 8 ++++----
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/player/lua.c b/player/lua.c
index b3a7167dce..0f2249bc96 100644
--- a/player/lua.c
+++ b/player/lua.c
@@ -452,11 +452,6 @@ static int load_lua(struct mp_script_args *args)
 
     stats_register_thread_cputime(ctx->stats, "cpu");
 
-    if (LUA_VERSION_NUM != 501 && LUA_VERSION_NUM != 502) {
-        MP_FATAL(ctx, "Only Lua 5.1 and 5.2 are supported.\n");
-        goto error_out;
-    }
-
     lua_State *L = ctx->state = luaL_newstate();
     if (!L) {
         MP_FATAL(ctx, "Could not initialize Lua.\n");
diff --git a/player/lua/osc.lua b/player/lua/osc.lua
index a244280a35..799b6a16df 100644
--- a/player/lua/osc.lua
+++ b/player/lua/osc.lua
@@ -170,7 +170,7 @@ local margins_opts = {
 function get_virt_scale_factor()
     local w, h = mp.get_osd_size()
     if w <= 0 or h <= 0 then
-        return 0, 0
+        return 1, 1
     end
     return osc_param.playresx / w, osc_param.playresy / h
 end
@@ -188,7 +188,7 @@ end
 
 function set_virt_mouse_area(x0, y0, x1, y1, name)
     local sx, sy = get_virt_scale_factor()
-    mp.set_mouse_area(x0 / sx, y0 / sy, x1 / sx, y1 / sy, name)
+    mp.set_mouse_area(x0 // sx, y0 // sy, x1 // sx, y1 // sy, name)
 end
 
 function scale_value(x0, x1, y0, y1, val)
@@ -294,7 +294,7 @@ end
 
 -- multiplies two alpha values, formular can probably be improved
 function mult_alpha(alphaA, alphaB)
-    return 255 - (((1-(alphaA/255)) * (1-(alphaB/255))) * 255)
+    return alphaA + alphaB - alphaA * alphaB / 255
 end
 
 function add_area(name, x1, y1, x2, y2)
@@ -313,7 +313,7 @@ function ass_append_alpha(ass, alpha, modifier)
         if state.animation then
             av = mult_alpha(av, state.animation)
         end
-        ar[ai] = av
+        ar[ai] = math.floor(av)
     end
 
     ass:append(string.format("{\\1a&H%X&\\2a&H%X&\\3a&H%X&\\4a&H%X&}",
-- 
2.42.0