-local sbs_chains = {}
-for input0_type, input0_deint in pairs({live = false, livedeint = true}) do
- sbs_chains[input0_type] = {}
- for input1_type, input1_deint in pairs({live = false, livedeint = true}) do
- sbs_chains[input0_type][input1_type] = {}
- for _, hq in pairs({true, false}) do
- sbs_chains[input0_type][input1_type][hq] =
- make_sbs_chain(input0_deint, input1_deint, hq)
- end
+local sbs_chains = make_cartesian_product({
+ {"live", "livedeint"}, -- input0_type
+ {"live", "livedeint"}, -- input1_type
+ {true, false} -- hq
+}, function(input0_type, input1_type, hq)
+ local input0_deint = (input0_type == "livedeint")
+ local input1_deint = (input1_type == "livedeint")
+ return make_sbs_chain(input0_deint, input1_deint, hq)
+end)
+
+function make_fade_input(chain, signal, live, deint, scale)
+ local input, wb_effect, resample_effect, last
+ if live then
+ input = chain:add_live_input(false, deint)
+ wb_effect = chain:add_effect(WhiteBalanceEffect.new())
+ input:connect_signal(signal)
+ last = wb_effect
+ else
+ input = chain:add_effect(ImageInput.new("bg.jpeg"))
+ last = input
+ end
+
+ -- If we cared about this for the non-main inputs, we would have
+ -- checked hq here and invoked ResizeEffect instead.
+ if scale then
+ resample_effect = chain:add_effect(ResampleEffect.new())
+ last = resample_effect