]> git.sesse.net Git - ultimatescore/blobdiff - nageru/ultimate.lua
Add an extra laptop input.
[ultimatescore] / nageru / ultimate.lua
index 771a86369602dcb9eea9d04e5bef706c60578850..36b67b3a19b1d504a8344aca98ede1643e0a1962 100644 (file)
@@ -11,7 +11,8 @@ local neutral_colors = {
        {0.5, 0.5, 0.5},  -- Input 1.
        {0.5, 0.5, 0.5},  -- Input 2.
        {0.5, 0.5, 0.5},  -- Input 3.
-       {0.5, 0.5, 0.5}   -- Input 4.
+       {0.5, 0.5, 0.5},  -- Input 4.
+       {0.5, 0.5, 0.5}   -- Input 5.
 }
 
 local overlay_transition_start = -2.0
@@ -22,7 +23,7 @@ local overlay_enabled = false
 
 local live_signal_num = 0
 local preview_signal_num = 1
-local NUM_CAMERAS = 5  -- Remember to update neutral_colors, too.
+local NUM_CAMERAS = 6  -- Remember to update neutral_colors, too.
 
 -- Valid values for live_signal_num and preview_signal_num.
 local INPUT0_SIGNAL_NUM = 0
@@ -30,6 +31,7 @@ local INPUT1_SIGNAL_NUM = 1
 local INPUT2_SIGNAL_NUM = 2
 local INPUT3_SIGNAL_NUM = 3
 local INPUT4_SIGNAL_NUM = 4
+local INPUT5_SIGNAL_NUM = 5
 local SBS_SIGNAL_NUM = NUM_CAMERAS
 local STATIC_SIGNAL_NUM = NUM_CAMERAS + 1
 
@@ -103,7 +105,7 @@ function make_fade_input(chain, signal, live, deint, scale)
                input:connect_signal(signal)
                last = input
        else
-               input = chain:add_effect(ImageInput.new("tfk_pause.png"))
+               input = chain:add_effect(ImageInput.new(cef_path .. "/nageru/dsn-bg.png"))
                last = input
        end
 
@@ -292,12 +294,12 @@ local simple_chains = make_cartesian_product({
        return make_simple_chain(input_deint, input_scale, has_overlay, hq)
 end)
 
--- A chain to show a single static picture on screen. Never with CasparCG overlay.
+-- A chain to show a single static picture on screen. Never with HTML overlay.
 local static_chains = make_cartesian_product({
        {true, false}            -- hq
 }, function(hq)
        local chain = EffectChain.new(16, 9)
-       local chain_input = chain:add_effect(ImageInput.new("tfk_pause.png"))
+       local chain_input = chain:add_effect(ImageInput.new(cef_path .. "/nageru/dsn-bg.png"))
 
        chain:finalize(hq)
        return {
@@ -349,7 +351,7 @@ function num_channels()
 end
 
 function is_plain_signal(num)
-       return num >= INPUT0_SIGNAL_NUM and num <= INPUT4_SIGNAL_NUM
+       return num >= INPUT0_SIGNAL_NUM and num <= INPUT5_SIGNAL_NUM
 end
 
 -- Helper function to write e.g. “720p60”. The difference between this
@@ -410,6 +412,8 @@ function channel_name(channel)
                return "Goal R (" .. get_channel_resolution(signal_num) .. ")"
        elseif signal_num == INPUT4_SIGNAL_NUM then
                return "Commentators (" .. get_channel_resolution(signal_num) .. ")"
+       elseif signal_num == INPUT5_SIGNAL_NUM then
+               return "Laptop (" .. get_channel_resolution(signal_num) .. ")"
        elseif signal_num == SBS_SIGNAL_NUM then
                return "Side-by-side"
        elseif signal_num == STATIC_SIGNAL_NUM then
@@ -693,6 +697,8 @@ function get_sbs_chain(signals, t, width, height, input_resolution)
        return sbs_chains[input0_type][overlay_enabled][input1_type][true]
 end
 
+local last_rate = 0.0
+
 -- API ENTRY POINT
 -- Called every frame. Get the chain for displaying at input <num>,
 -- where 0 is live, 1 is preview, 2 is the first channel to display
@@ -746,12 +752,18 @@ function get_chain(num, t, width, height, signals)
        last_resolution = input_resolution
 
        -- Save some CPU time if we're not having SBS on live.
+       local new_rate
        if live_signal_num == SBS_SIGNAL_NUM or
           preview_signal_num == SBS_SIGNAL_NUM or
           transition_type == ZOOM_TRANSITION then
-               bg_video:change_rate(1.0)
+               new_rate = 1.0
        else
-               bg_video:change_rate(0.0001)
+               new_rate = 0.0001
+       end
+       if new_rate ~= last_rate then
+               -- Avoid waking up the video thread (which may be sleeping) if the rate is the same.
+               bg_video:change_rate(new_rate)
+               last_rate = new_rate
        end
 
        if num == 0 then  -- Live.