1
0
mirror of https://github.com/mpv-player/mpv synced 2025-03-22 11:18:32 +00:00

stats: add support for deprecated properties

Previously, we used a property and when it was unavailable we assumed it
doesn't exist before assuming it really is just unavailable. This lead
to unnecessarily falling back to deprecated properties which made mpv
print deprecation warnings.
Now we can really check if a property is not known to mpv.
The alternative would've been to check the error part of mp.get_property
and perform string comparisons on the returned error message.

Not sure if supporting old mpv versions is actually worth it though.

Fixes #37 #36
This commit is contained in:
Julian 2017-06-16 12:38:41 +02:00 committed by wm4
parent 6f9a7d1fdb
commit fa80ac13b6

View File

@ -89,6 +89,23 @@ local function init_buffers()
vsjitter_buf = {0, pos = 1, len = 50, max = 0} vsjitter_buf = {0, pos = 1, len = 50, max = 0}
end end
-- Save all properties known to this version of mpv
local property_list = {}
for p in string.gmatch(mp.get_property("property-list"), "([^,]+)") do property_list[p] = true end
-- Mapping of properties to their deprecated names
local property_aliases = {
["decoder-frame-drop-count"] = "drop-frame-count",
["frame-drop-count"] = "vo-drop-frame-count",
["container-fps"] = "fps",
}
-- Return deprecated name for the given property
local function compat(p)
while not property_list[p] and property_aliases[p] do
p = property_aliases[p]
end
return p
end
local function set_ASS(b) local function set_ASS(b)
if not o.ass_formatting then if not o.ass_formatting then
@ -236,8 +253,7 @@ local function append_perfdata(s)
local ds = mp.get_property_bool("display-sync-active", false) local ds = mp.get_property_bool("display-sync-active", false)
local target_fps = ds and mp.get_property_number("display-fps", 0) local target_fps = ds and mp.get_property_number("display-fps", 0)
or mp.get_property_number("container-fps", 0) or mp.get_property_number(compat("container-fps"), 0)
or mp.get_property_number("fps", 0)
if target_fps > 0 then target_fps = 1 / target_fps * 1e6 end if target_fps > 0 then target_fps = 1 / target_fps * 1e6 end
local last_s = vo_p["render-last"] + vo_p["present-last"] + vo_p["upload-last"] local last_s = vo_p["render-last"] + vo_p["present-last"] + vo_p["upload-last"]
@ -374,13 +390,8 @@ local function add_video(s)
{no=true, [""]=true}) {no=true, [""]=true})
end end
append_property(s, "avsync", {prefix="A-V:"}) append_property(s, "avsync", {prefix="A-V:"})
if append_property(s, "decoder-frame-drop-count", {prefix="Dropped:"}) then if append_property(s, compat("decoder-frame-drop-count"), {prefix="Dropped:"}) then
append_property(s, "frame-drop-count", {prefix="VO:", nl=""}) append_property(s, compat("frame-drop-count"), {prefix="VO:", nl=""})
append_property(s, "mistimed-frame-count", {prefix="Mistimed:", nl=""})
append_property(s, "vo-delayed-frame-count", {prefix="Delayed:", nl=""})
-- Deprecated FPS properties for backwards compatibility
elseif append_property(s, "drop-frame-count", {prefix="Dropped:"}) then
append_property(s, "vo-drop-frame-count", {prefix="VO:", nl=""})
append_property(s, "mistimed-frame-count", {prefix="Mistimed:", nl=""}) append_property(s, "mistimed-frame-count", {prefix="Mistimed:", nl=""})
append_property(s, "vo-delayed-frame-count", {prefix="Delayed:", nl=""}) append_property(s, "vo-delayed-frame-count", {prefix="Delayed:", nl=""})
end end
@ -391,8 +402,7 @@ local function add_video(s)
append_property(s, "estimated-display-fps", append_property(s, "estimated-display-fps",
{prefix="Display FPS:", suffix=" (estimated)"}) {prefix="Display FPS:", suffix=" (estimated)"})
end end
if append_property(s, "container-fps", {prefix="FPS:", suffix=" (specified)"}) or if append_property(s, compat("container-fps"), {prefix="FPS:", suffix=" (specified)"}) then
append_property(s, "fps", {prefix="FPS:", suffix=" (specified)"}) then
append_property(s, "estimated-vf-fps", append_property(s, "estimated-vf-fps",
{suffix=" (estimated)", nl="", indent=""}) {suffix=" (estimated)", nl="", indent=""})
else else