Files
oasis-linux-mirror/pkg/mpv/patch/0005-Support-lua-5.4.patch
2024-08-15 01:09:25 -07:00

70 lines
2.1 KiB
Diff

From ae44889fc30137f38b74cd0119fe7196c0a1b043 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 63547694e2..0b8c632acd 100644
--- a/player/lua.c
+++ b/player/lua.c
@@ -455,11 +455,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 3ba1890a92..945af861f0 100644
--- a/player/lua/osc.lua
+++ b/player/lua/osc.lua
@@ -175,7 +175,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
@@ -193,7 +193,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)
@@ -299,7 +299,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)
@@ -318,7 +318,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.44.0