Skip to content

Commit

Permalink
parameters: support DI method or rate variation
Browse files Browse the repository at this point in the history
Allow user config to set either method or rate
and variate the other for deinterlace tests.

Signed-off-by: U. Artie Eoff <[email protected]>
  • Loading branch information
uartie committed May 28, 2020
1 parent 6aba307 commit 6303560
Showing 1 changed file with 35 additions and 7 deletions.
42 changes: 35 additions & 7 deletions lib/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 6303560

Please sign in to comment.