-local main_chain = EffectChain.new(16, 9)
-local input0 = main_chain:add_live_input()
-input0:connect_signal(0)
-local input1 = main_chain:add_live_input()
-input1:connect_signal(1)
-local resample_effect = main_chain:add_effect(ResampleEffect.new(), input0)
-local padding_effect = main_chain:add_effect(IntegralPaddingEffect.new())
-padding_effect:set_vec4("border_color", 0.0, 0.0, 0.0, 1.0)
-
-local resample2_effect = main_chain:add_effect(ResampleEffect.new(), input1)
--- Effect *saturation_effect = main_chain->add_effect(new SaturationEffect())
--- CHECK(saturation_effect->set_float("saturation", 0.3f))
-local wb_effect = main_chain:add_effect(WhiteBalanceEffect.new())
-wb_effect:set_float("output_color_temperature", 3500.0)
-local padding2_effect = main_chain:add_effect(IntegralPaddingEffect.new())
-
-main_chain:add_effect(OverlayEffect.new(), padding_effect, padding2_effect)
-main_chain:finalize(true)
+function make_sbs_chain(hq)
+ local chain = EffectChain.new(16, 9)
+ local input0 = chain:add_live_input(true)
+ input0:connect_signal(0)
+ local input0_wb_effect = chain:add_effect(WhiteBalanceEffect.new())
+ local input1 = chain:add_live_input(true)
+ input1:connect_signal(1)
+ local input1_wb_effect = chain:add_effect(WhiteBalanceEffect.new())
+
+ local resample_effect = nil
+ local resize_effect = nil
+ if (hq) then
+ resample_effect = chain:add_effect(ResampleEffect.new(), input0_wb_effect)
+ else
+ resize_effect = chain:add_effect(ResizeEffect.new(), input0_wb_effect)
+ end
+
+ local padding_effect = chain:add_effect(IntegralPaddingEffect.new())
+ padding_effect:set_vec4("border_color", 0.0, 0.0, 0.0, 1.0)
+
+ local resample2_effect = nil
+ local resize2_effect = nil
+ if (hq) then
+ resample2_effect = chain:add_effect(ResampleEffect.new(), input1_wb_effect)
+ else
+ resize2_effect = chain:add_effect(ResizeEffect.new(), input1_wb_effect)
+ end
+ local padding2_effect = chain:add_effect(IntegralPaddingEffect.new())
+
+ chain:add_effect(OverlayEffect.new(), padding_effect, padding2_effect)
+ chain:finalize(hq)
+
+ return {
+ chain = chain,
+ input0 = {
+ input = input0,
+ white_balance_effect = input0_wb_effect,
+ resample_effect = resample_effect,
+ resize_effect = resize_effect,
+ padding_effect = padding_effect
+ },
+ input1 = {
+ input = input1,
+ white_balance_effect = input1_wb_effect,
+ resample_effect = resample2_effect,
+ resize_effect = resize2_effect,
+ padding_effect = padding2_effect
+ }
+ }
+end
+
+local main_chain_hq = make_sbs_chain(true)
+local main_chain_lq = make_sbs_chain(false)
+
+-- A chain to fade between two inputs, of which either can be a picture
+-- or a live input. In practice only used live, but we still support the
+-- hq parameter.
+function make_fade_chain(input0_live, input1_live, hq)
+ local chain = EffectChain.new(16, 9)
+
+ local input0, wb0_effect, input0_last, input1, wb1_effect, input1_last
+
+ if input0_live then
+ input0 = chain:add_live_input(true)
+ wb0_effect = chain:add_effect(WhiteBalanceEffect.new())
+ input0:connect_signal(0)
+ input0_last = wb0_effect
+ else
+ input0 = chain:add_effect(ImageInput.new("bg.jpeg"))
+ input0_last = input0
+ end
+
+ if input1_live then
+ input1 = chain:add_live_input(true)
+ wb1_effect = chain:add_effect(WhiteBalanceEffect.new())
+ input1:connect_signal(1)
+ input1_last = wb1_effect
+ else
+ input1 = chain:add_effect(ImageInput.new("bg.jpeg"))
+ input1_last = input1
+ end
+
+ local mix_effect = chain:add_effect(MixEffect.new(), input0_last, input1_last)
+ chain:finalize(hq)
+
+ return {
+ chain = chain,
+ input0 = {
+ input = input0,
+ white_balance_effect = wb0_effect
+ },
+ input1 = {
+ input = input1,
+ white_balance_effect = wb1_effect
+ },
+ mix_effect = mix_effect
+ }
+end
+
+-- Chains to fade between two inputs, in various configurations.
+local fade_chains = {}
+for input0_type, input0_live in pairs({static = false, live = true}) do
+ fade_chains[input0_type] = {}
+ for input1_type, input1_live in pairs({static = false, live = true}) do
+ fade_chains[input0_type][input1_type] = {}
+ for _, hq in pairs({true, false}) do
+ fade_chains[input0_type][input1_type][hq] = make_fade_chain(input0_live, input1_live, hq)
+ end
+ end
+end