mirror of https://github.com/mpv-player/mpv
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.
This commit is contained in:
parent
252347731a
commit
f4de509f01
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue