]> git.sesse.net Git - nageru/commitdiff
Use the new texture bounce override instead of relying on a patched Movit.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 1 Nov 2015 01:21:39 +0000 (02:21 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 1 Nov 2015 01:21:39 +0000 (02:21 +0100)
mixer.cpp
theme.cpp
theme.h
theme.lua

index e85710c25c519bfbd261c6ab6cf81cb2014f4796..0f8cf903d326d87fc41b00ec65b07afa6ce1c8b7 100644 (file)
--- a/mixer.cpp
+++ b/mixer.cpp
@@ -80,6 +80,10 @@ Mixer::Mixer(const QSurfaceFormat &format)
        CHECK(init_movit(MOVIT_SHADER_DIR, MOVIT_DEBUG_OFF));
        check_error();
 
+       // Since we allow non-bouncing 4:2:2 YCbCrInputs, effective subpixel precision
+       // will be halved when sampling them, and we need to compensate here.
+       movit_texel_subpixel_precision /= 2.0;
+
        resource_pool.reset(new ResourcePool);
        theme.reset(new Theme("theme.lua", resource_pool.get()));
        output_channel[OUTPUT_LIVE].parent = this;
index c1a25bab8171c06ae0fded9f563b0186fc8cab0a..4843b0cd3fff65519d2eaea3243c9eb69dd64271 100644 (file)
--- a/theme.cpp
+++ b/theme.cpp
@@ -78,10 +78,11 @@ int EffectChain_new(lua_State* L)
 
 int EffectChain_add_live_input(lua_State* L)
 {
-       assert(lua_gettop(L) == 1);
+       assert(lua_gettop(L) == 2);
        Theme *theme = get_theme_updata(L);
        EffectChain *chain = (EffectChain *)luaL_checkudata(L, 1, "EffectChain");
-       return wrap_lua_object<LiveInputWrapper>(L, "LiveInputWrapper", theme, chain);
+       bool override_bounce = checkbool(L, 2);
+       return wrap_lua_object<LiveInputWrapper>(L, "LiveInputWrapper", theme, chain, override_bounce);
 }
 
 int EffectChain_add_effect(lua_State* L)
@@ -311,7 +312,7 @@ const luaL_Reg MixEffect_funcs[] = {
 
 }  // namespace
 
-LiveInputWrapper::LiveInputWrapper(Theme *theme, EffectChain *chain)
+LiveInputWrapper::LiveInputWrapper(Theme *theme, EffectChain *chain, bool override_bounce)
        : theme(theme)
 {
        ImageFormat inout_format;
@@ -328,7 +329,11 @@ LiveInputWrapper::LiveInputWrapper(Theme *theme, EffectChain *chain)
        input_ycbcr_format.luma_coefficients = YCBCR_REC_601;
        input_ycbcr_format.full_range = false;
 
-       input = new YCbCrInput(inout_format, input_ycbcr_format, WIDTH, HEIGHT, YCBCR_INPUT_SPLIT_Y_AND_CBCR);
+       if (override_bounce) {
+               input = new NonBouncingYCbCrInput(inout_format, input_ycbcr_format, WIDTH, HEIGHT, YCBCR_INPUT_SPLIT_Y_AND_CBCR);
+       } else {
+               input = new YCbCrInput(inout_format, input_ycbcr_format, WIDTH, HEIGHT, YCBCR_INPUT_SPLIT_Y_AND_CBCR);
+       }
        chain->add_input(input);
 }
 
diff --git a/theme.h b/theme.h
index bb6ff9bebd43ffc761c538739727800a8cc60a0c..80b01badf3f1a1c0b0a38f37e15f9270f4ee84d8 100644 (file)
--- a/theme.h
+++ b/theme.h
 #include <movit/effect_chain.h>
 #include <movit/ycbcr_input.h>
 
+class NonBouncingYCbCrInput : public movit::YCbCrInput {
+public:
+       NonBouncingYCbCrInput(const movit::ImageFormat &image_format,
+                             const movit::YCbCrFormat &ycbcr_format,
+                             unsigned width, unsigned height,
+                             movit::YCbCrInputSplitting ycbcr_input_splitting = movit::YCBCR_INPUT_PLANAR)
+           : movit::YCbCrInput(image_format, ycbcr_format, width, height, ycbcr_input_splitting) {}
+
+       bool override_disable_bounce() const override { return true; }
+};
+
 class Theme {
 public:
        Theme(const char *filename, movit::ResourcePool *resource_pool);
@@ -44,7 +55,7 @@ private:
 
 class LiveInputWrapper {
 public:
-       LiveInputWrapper(Theme *theme, movit::EffectChain *chain);
+       LiveInputWrapper(Theme *theme, movit::EffectChain *chain, bool override_bounce);
 
        void connect_signal(int signal_num);
        movit::YCbCrInput *get_input() const
index 523221ff71e808117682b64e226b386288f95a8b..543857f4f79826160a3e8e19b23e45c5222640b3 100644 (file)
--- a/theme.lua
+++ b/theme.lua
@@ -21,9 +21,9 @@ local preview_signal_num = 1
 -- The main live chain.
 function make_sbs_chain(hq)
        local chain = EffectChain.new(16, 9)
-       local input0 = chain:add_live_input()
+       local input0 = chain:add_live_input(true)
        input0:connect_signal(0)
-       local input1 = chain:add_live_input()
+       local input1 = chain:add_live_input(true)
        input1:connect_signal(1)
 
        local resample_effect = nil
@@ -75,8 +75,8 @@ local main_chain_lq = make_sbs_chain(false)
 
 -- A chain to fade between two inputs (live chain only)
 local fade_chain_hq = EffectChain.new(16, 9)
-local fade_chain_hq_input0 = fade_chain_hq:add_live_input()
-local fade_chain_hq_input1 = fade_chain_hq:add_live_input()
+local fade_chain_hq_input0 = fade_chain_hq:add_live_input(true)
+local fade_chain_hq_input1 = fade_chain_hq:add_live_input(true)
 fade_chain_hq_input0:connect_signal(0)
 fade_chain_hq_input1:connect_signal(1)
 local fade_chain_mix_effect = fade_chain_hq:add_effect(MixEffect.new(), fade_chain_hq_input0, fade_chain_hq_input1)
@@ -84,13 +84,13 @@ fade_chain_hq:finalize(true)
 
 -- A chain to show a single input on screen (HQ version).
 local simple_chain_hq = EffectChain.new(16, 9)
-local simple_chain_hq_input = simple_chain_hq:add_live_input()
+local simple_chain_hq_input = simple_chain_hq:add_live_input(true)
 simple_chain_hq_input:connect_signal(0)  -- First input card. Can be changed whenever you want.
 simple_chain_hq:finalize(true)
 
 -- A chain to show a single input on screen (LQ version).
 local simple_chain_lq = EffectChain.new(16, 9)
-local simple_chain_lq_input = simple_chain_lq:add_live_input()
+local simple_chain_lq_input = simple_chain_lq:add_live_input(true)
 simple_chain_lq_input:connect_signal(0)  -- First input card. Can be changed whenever you want.
 simple_chain_lq:finalize(false)