--- Chains to fade between two inputs, in various configurations.
-local fade_chains = make_cartesian_product({
- {"static", "live", "livedeint"}, -- input0_type
- {true, false}, -- input0_scale
- {"static", "live", "livedeint"}, -- input1_type
- {true, false}, -- input1_scale
- {true} -- hq
-}, function(input0_type, input0_scale, input1_type, input1_scale, hq)
- local input0_live = (input0_type ~= "static")
- local input1_live = (input1_type ~= "static")
- local input0_deint = (input0_type == "livedeint")
- local input1_deint = (input1_type == "livedeint")
- return make_fade_chain(input0_live, input0_deint, input0_scale, input1_live, input1_deint, input1_scale, hq)
-end)
-
--- A chain to show a single input on screen.
-function make_simple_chain(input_deint, input_scale, hq)
- local chain = EffectChain.new(16, 9)
-
- local input = chain:add_live_input(false, input_deint)
- input:connect_signal(0) -- First input card. Can be changed whenever you want.
-
- local resample_effect, resize_effect
- if input_scale then
- if hq then
- resample_effect = chain:add_effect(ResampleEffect.new())
- else
- resize_effect = chain:add_effect(ResizeEffect.new())
- end
- end
-
- local wb_effect = chain:add_effect(WhiteBalanceEffect.new())
- chain:finalize(hq)
-
- return {
- chain = chain,
- input = input,
- wb_effect = wb_effect,
- resample_effect = resample_effect,
- resize_effect = resize_effect
- }
-end
-
--- Make all possible combinations of single-input chains.
-local simple_chains = make_cartesian_product({
- {"live", "livedeint"}, -- input_type
- {true, false}, -- input_scale
- {true, false} -- hq
-}, function(input_type, input_scale, hq)
- local input_deint = (input_type == "livedeint")
- return make_simple_chain(input_deint, input_scale, hq)
-end)
-
--- A chain to show a single static picture on screen (HQ version).
-local static_chain_hq = EffectChain.new(16, 9)
-local static_chain_hq_input = static_chain_hq:add_effect(ImageInput.new("bg.jpeg"))
-static_chain_hq:finalize(true)
-
--- A chain to show a single static picture on screen (LQ version).
-local static_chain_lq = EffectChain.new(16, 9)
-local static_chain_lq_input = static_chain_lq:add_effect(ImageInput.new("bg.jpeg"))
-static_chain_lq:finalize(false)
-
--- Used for indexing into the tables of chains.
-function get_input_type(signals, signal_num)
- if signal_num == STATIC_SIGNAL_NUM then
- return "static"
- elseif signals:get_interlaced(signal_num) then
- return "livedeint"
- else
- return "live"
- end
-end
-
-function needs_scale(signals, signal_num, width, height)
- if signal_num == STATIC_SIGNAL_NUM then
- -- We assume this is already correctly scaled at load time.
- return false
- end
- assert(is_plain_signal(signal_num))
- return (signals:get_width(signal_num) ~= width or signals:get_height(signal_num) ~= height)
-end