Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parameters: support DI method or rate variation #7

Open
wants to merge 1 commit into
base: dispatch-test
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading