]> git.sesse.net Git - nageru/blobdiff - nageru/theme.cpp
Expose BlurEffect and UnsharpMaskEffect.
[nageru] / nageru / theme.cpp
index 4f7b1433589f342c4eaddbeeece94a4e3dbceffc..937043f7ca72e96ad60bf7a4611857091bf13730 100644 (file)
@@ -6,6 +6,7 @@
 #include <stdarg.h>
 #include <lauxlib.h>
 #include <lua.hpp>
+#include <movit/blur_effect.h>
 #include <movit/deinterlace_effect.h>
 #include <movit/effect.h>
 #include <movit/effect_chain.h>
@@ -19,6 +20,7 @@
 #include <movit/resample_effect.h>
 #include <movit/resize_effect.h>
 #include <movit/util.h>
+#include <movit/unsharp_mask_effect.h>
 #include <movit/white_balance_effect.h>
 #include <movit/ycbcr.h>
 #include <movit/ycbcr_input.h>
@@ -140,6 +142,10 @@ Effect *instantiate_effect(EffectChain *chain, EffectType effect_type)
                return new MixEffect;
        case LIFT_GAMMA_GAIN_EFFECT:
                return new LiftGammaGainEffect;
+       case BLUR_EFFECT:
+               return new BlurEffect;
+       case UNSHARP_MASK_EFFECT:
+               return new UnsharpMaskEffect;
        default:
                fprintf(stderr, "Unhandled effect type %d\n", effect_type);
                abort();
@@ -260,9 +266,9 @@ void add_outputs_and_finalize(EffectChain *chain, bool is_main_chain)
                }
 
                output_ycbcr_format.full_range = false;
-               output_ycbcr_format.num_levels = 1 << global_flags.x264_bit_depth;
+               output_ycbcr_format.num_levels = 1 << global_flags.bit_depth;
 
-               GLenum type = global_flags.x264_bit_depth > 8 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_BYTE;
+               GLenum type = global_flags.bit_depth > 8 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_BYTE;
 
                chain->add_ycbcr_output(inout_format, OUTPUT_ALPHA_FORMAT_POSTMULTIPLIED, output_ycbcr_format, YCBCR_OUTPUT_SPLIT_Y_AND_CBCR, type);
 
@@ -272,7 +278,7 @@ void add_outputs_and_finalize(EffectChain *chain, bool is_main_chain)
                if (global_flags.use_zerocopy) {
                        chain->add_ycbcr_output(inout_format, OUTPUT_ALPHA_FORMAT_POSTMULTIPLIED, output_ycbcr_format, YCBCR_OUTPUT_INTERLEAVED, type);  // Add a copy where we'll only be using the Y component.
                }
-               chain->set_dither_bits(global_flags.x264_bit_depth > 8 ? 16 : 8);
+               chain->set_dither_bits(global_flags.bit_depth > 8 ? 16 : 8);
                chain->set_output_origin(OUTPUT_ORIGIN_TOP_LEFT);
        } else {
                chain->add_output(inout_format, OUTPUT_ALPHA_FORMAT_POSTMULTIPLIED);
@@ -308,7 +314,7 @@ int EffectChain_add_live_input(lua_State* L)
        EffectChain *chain = (EffectChain *)luaL_checkudata(L, 1, "EffectChain");
        bool override_bounce = checkbool(L, 2);
        bool deinterlace = checkbool(L, 3);
-       bmusb::PixelFormat pixel_format = global_flags.ten_bit_input ? bmusb::PixelFormat_10BitYCbCr : bmusb::PixelFormat_8BitYCbCr;
+       bmusb::PixelFormat pixel_format = global_flags.bit_depth > 8 ? bmusb::PixelFormat_10BitYCbCr : bmusb::PixelFormat_8BitYCbCr;
 
        // Needs to be nonowned to match add_video_input (see below).
        return wrap_lua_object_nonowned<LiveInputWrapper>(L, "LiveInputWrapper", theme, chain, pixel_format, override_bounce, deinterlace, /*user_connectable=*/true);
@@ -622,6 +628,18 @@ int LiftGammaGainEffect_new(lua_State* L)
        return wrap_lua_object_nonowned<EffectBlueprint>(L, "EffectBlueprint", LIFT_GAMMA_GAIN_EFFECT);
 }
 
+int BlurEffect_new(lua_State* L)
+{
+       assert(lua_gettop(L) == 0);
+       return wrap_lua_object_nonowned<EffectBlueprint>(L, "EffectBlueprint", BLUR_EFFECT);
+}
+
+int UnsharpMaskEffect_new(lua_State* L)
+{
+       assert(lua_gettop(L) == 0);
+       return wrap_lua_object_nonowned<EffectBlueprint>(L, "EffectBlueprint", UNSHARP_MASK_EFFECT);
+}
+
 int InputStateInfo_get_width(lua_State* L)
 {
        assert(lua_gettop(L) == 2);
@@ -997,6 +1015,16 @@ const luaL_Reg LiftGammaGainEffect_funcs[] = {
        { NULL, NULL }
 };
 
+const luaL_Reg BlurEffect_funcs[] = {
+       { "new", BlurEffect_new },
+       { NULL, NULL }
+};
+
+const luaL_Reg UnsharpMaskEffect_funcs[] = {
+       { "new", UnsharpMaskEffect_new },
+       { NULL, NULL }
+};
+
 // End of effects.
 
 const luaL_Reg InputStateInfo_funcs[] = {
@@ -1558,6 +1586,8 @@ Theme::Theme(const string &filename, const vector<string> &search_dirs, Resource
        register_class("ResizeEffect", ResizeEffect_funcs, RESIZE_EFFECT);
        register_class("MultiplyEffect", MultiplyEffect_funcs, MULTIPLY_EFFECT);
        register_class("MixEffect", MixEffect_funcs, MIX_EFFECT);
+       register_class("BlurEffect", BlurEffect_funcs, BLUR_EFFECT);
+       register_class("UnsharpMaskEffect", UnsharpMaskEffect_funcs, UNSHARP_MASK_EFFECT);
        register_class("LiftGammaGainEffect", LiftGammaGainEffect_funcs, LIFT_GAMMA_GAIN_EFFECT);
        register_class("InputStateInfo", InputStateInfo_funcs);
        register_class("ThemeMenu", ThemeMenu_funcs);