diff options
author | Guido Cella <guido@guidocella.xyz> | 2023-09-21 11:48:22 +0200 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2023-09-21 13:50:21 +0000 |
commit | f4de509f01f2322487e42dffd73cb8bd1118655c (patch) | |
tree | 2164bd5acd2bf7be9279e79a39c0edbf375b371c /TOOLS | |
parent | 252347731a5f8c254b8c3cac90dc1f5d2c81e0e4 (diff) | |
download | mpv-f4de509f01f2322487e42dffd73cb8bd1118655c.tar.bz2 mpv-f4de509f01f2322487e42dffd73cb8bd1118655c.tar.xz |
TOOLS/autocrop.lua: switch to auto-copy hwdec during cropdetect
I didn't set file-local-options/hwdec because you have to store the
hwdec value to restore it after cropdetect anyway, and if the user
manually changes hwdec after cropdetect, the new value isn't reset when
changing file.
Diffstat (limited to 'TOOLS')
-rw-r--r-- | TOOLS/lua/autocrop.lua | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/TOOLS/lua/autocrop.lua b/TOOLS/lua/autocrop.lua index d7e3e0b858..780e9e2d48 100644 --- a/TOOLS/lua/autocrop.lua +++ b/TOOLS/lua/autocrop.lua @@ -85,6 +85,8 @@ timers = { detect_crop = nil } +local hwdec_backup + local command_prefix = options.suppress_osd and 'no-osd' or '' function is_filter_present(label) @@ -128,6 +130,13 @@ function remove_filter(label) return false end +function restore_hwdec() + if hwdec_backup then + mp.set_property("hwdec", hwdec_backup) + hwdec_backup = nil + end +end + function cleanup() -- Remove existing filter. @@ -140,6 +149,8 @@ function cleanup() timers[index] = nil end end + + restore_hwdec() end function detect_crop() @@ -149,6 +160,13 @@ function detect_crop() return end + local hwdec_current = mp.get_property("hwdec-current") + if hwdec_current:find("-copy$") == nil and hwdec_current ~= "no" and + hwdec_current ~= "crystalhd" and hwdec_current ~= "rkmpp" then + hwdec_backup = mp.get_property("hwdec") + mp.set_property("hwdec", "auto-copy-safe") + end + -- Insert the cropdetect filter. local limit = options.detect_limit local round = options.detect_round @@ -181,6 +199,8 @@ function detect_end() timers.detect_crop = nil end + restore_hwdec() + local meta = {} -- Verify the existence of metadata. |