From 63035601f114f18779c0b496ad33d5654074b1f4 Mon Sep 17 00:00:00 2001 From: "U. Artie Eoff" Date: Tue, 26 May 2020 13:15:56 -0700 Subject: [PATCH] parameters: support DI method or rate variation Allow user config to set either method or rate and variate the other for deinterlace tests. Signed-off-by: U. Artie Eoff --- lib/parameters.py | 42 +++++++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/lib/parameters.py b/lib/parameters.py index 64c5b19a..773200c2 100644 --- a/lib/parameters.py +++ b/lib/parameters.py @@ -449,15 +449,43 @@ def gen_vpp_sharpen_parameters(spec): gen_vpp_hue_parameters = gen_vpp_sharpen_parameters gen_vpp_saturation_parameters = gen_vpp_sharpen_parameters -def gen_vpp_deinterlace_variants(spec, modes): +def gen_vpp_deinterlace_variants(spec, default_modes): for case, params in spec.items(): - variants = params.get("modes", modes) - for variant in variants: - yield [case, variant["method"], variant["rate"]] - -def gen_vpp_deinterlace_parameters(spec, modes): + # Keeps track of variants (modes) that we've already yielded for this + # case so we don't produce duplicates. + seen = set() + + # Use the modes from the user spec/config if it's defined. Otherwise, use + # the modes provided by the default_modes. + modes = params.get("modes", default_modes) + + # For each specified mode, generate and yield each variant for this case + for mode in modes: + method = mode.get("method", None) + rate = mode.get("rate", None) + + if method is None: # method is variant, rate is fixed + assert rate is not None, "user config must specify method and/or rate" + # select all modes from the default_modes that match the specified rate. + gmodes = filter(lambda m: m["rate"] == rate, default_modes) + elif rate is None: # rate is variant, method is fixed + assert method is not None, "user config must specify method and/or rate" + # select all modes from the default_modes that match the specified method. + gmodes = filter(lambda m: m["method"] == method, default_modes) + else: # rate and method are fixed + gmodes = [mode] + + # For each generated mode, yield a unique variant for this case + for gmode in gmodes: + mode_hash = tuple(sorted(gmode.values())) + # only yield if we haven't seen this mode for this case + if mode_hash not in seen: + yield [case, gmode["method"], gmode["rate"]] + seen.add(mode_hash) + +def gen_vpp_deinterlace_parameters(spec, default_modes): keys = ("case", "method", "rate") - params = gen_vpp_deinterlace_variants(spec, modes) + params = gen_vpp_deinterlace_variants(spec, default_modes) return keys, params def gen_vpp_csc_variants(spec):