summaryrefslogtreecommitdiffstats
path: root/TOOLS
diff options
context:
space:
mode:
authorKevin Mitchell <kevmitch@gmail.com>2014-05-04 13:26:47 -0700
committerKevin Mitchell <kevmitch@gmail.com>2014-05-06 10:02:41 -0700
commit0467e13725da1ef5e7308258643979dc53d2556d (patch)
tree575c0c6de07f44f9d6d4f06b7f656f4024f24005 /TOOLS
parent6e62779e98b3071330446df5ac074ff5b5aa3edf (diff)
downloadmpv-0467e13725da1ef5e7308258643979dc53d2556d.tar.bz2
mpv-0467e13725da1ef5e7308258643979dc53d2556d.tar.xz
TOOLS/lua: add cycle-deinterlace-pullup script
Override the shift+d hotkey to add a pullup step to the cycle.
Diffstat (limited to 'TOOLS')
-rw-r--r--TOOLS/lua/cycle-deinterlace-pullup.lua56
1 files changed, 56 insertions, 0 deletions
diff --git a/TOOLS/lua/cycle-deinterlace-pullup.lua b/TOOLS/lua/cycle-deinterlace-pullup.lua
new file mode 100644
index 0000000000..f8095af4cd
--- /dev/null
+++ b/TOOLS/lua/cycle-deinterlace-pullup.lua
@@ -0,0 +1,56 @@
+-- This script cycles between deinterlacing, pullup (inverse
+-- telecine), and both filters off. It uses the "deinterlace" property
+-- so that a hardware deinterlacer will be used if available.
+--
+-- It overrides the default deinterlace toggle keybinding "D"
+-- (shift+d), so that rather than merely cycling the "deinterlace" property
+-- between on and off, it adds a "pullup" step to the cycle.
+--
+-- It provides OSD feedback as to the actual state of the two filters
+-- after each cycle step/keypress.
+--
+-- Note: if hardware decoding is enabled, pullup filter will likely
+-- fail to insert.
+--
+-- TODO: It might make sense to use hardware assisted vdpaupp=pullup,
+-- if available, but I don't have hardware to test it. Patch welcome.
+
+script_name = mp.get_script_name()
+pullup_label = string.format("%s-pullup", script_name)
+
+function pullup_on()
+ for i,vf in pairs(mp.get_property_native('vf')) do
+ if vf['label'] == pullup_label then
+ return "yes"
+ end
+ end
+ return "no"
+end
+
+function do_cycle()
+ if pullup_on() == "yes" then
+ -- if pullup is on remove it
+ mp.command(string.format("vf del @%s:pullup", pullup_label))
+ return
+ elseif mp.get_property("deinterlace") == "yes" then
+ -- if deinterlace is on, turn it off and insert pullup filter
+ mp.set_property("deinterlace", "no")
+ mp.command(string.format("vf add @%s:pullup", pullup_label))
+ return
+ else
+ -- if neither is on, turn on deinterlace
+ mp.set_property("deinterlace", "yes")
+ return
+ end
+end
+
+function cycle_deinterlace_pullup_handler()
+ do_cycle()
+ -- independently determine current state and give user feedback
+ mp.osd_message(string.format("deinterlace: %s\n"..
+ "pullup: %s",
+ mp.get_property("deinterlace"),
+ pullup_on()))
+end
+
+mp.add_key_binding("D", "cycle-deinterlace-pullup", cycle_deinterlace_pullup_handler)