--- The main live chain.
-function make_sbs_chain(input0_deint, input1_deint, hq)
- local chain = EffectChain.new(16, 9)
- local input0 = chain:add_live_input(not input0_deint, input0_deint) -- Override bounce only if not deinterlacing.
- input0:connect_signal(0)
- local input0_wb_effect = chain:add_effect(WhiteBalanceEffect.new())
- local input1 = chain:add_live_input(not input1_deint, input1_deint)
- input1:connect_signal(1)
- local input1_wb_effect = chain:add_effect(WhiteBalanceEffect.new())
+-- Last width/height/resolution for each channel, if we have it.
+-- Note that unlike the values we get from Nageru, the resolution is per
+-- frame and not per field, since we deinterlace.
+local last_resolution = {}
+
+-- Utility function to help creating many similar chains that can differ
+-- in a free set of chosen parameters.
+function make_cartesian_product(parms, callback)
+ return make_cartesian_product_internal(parms, callback, 1, {})
+end
+
+function make_cartesian_product_internal(parms, callback, index, args)
+ if index > #parms then
+ return callback(unpack(args))
+ end
+ local ret = {}
+ for _, value in ipairs(parms[index]) do
+ args[index] = value
+ ret[value] = make_cartesian_product_internal(parms, callback, index + 1, args)
+ end
+ return ret
+end
+
+function make_sbs_input(chain, signal, deint, hq)
+ local input = chain:add_live_input(not deint, deint) -- Override bounce only if not deinterlacing.
+ input:connect_signal(signal)
+ local wb_effect = chain:add_effect(WhiteBalanceEffect.new())