X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=nageru%2Ftheme.cpp;h=06d147f6686bb07739d7cbb5ee6bafa1ed1f66d5;hb=f81ae3be1aae619fe4ad022f55d95a4a83ace076;hp=4f7b1433589f342c4eaddbeeece94a4e3dbceffc;hpb=2e5386ddae01a50ff36a6cda1e73a4c180f6e8d4;p=nageru diff --git a/nageru/theme.cpp b/nageru/theme.cpp index 4f7b143..06d147f 100644 --- a/nageru/theme.cpp +++ b/nageru/theme.cpp @@ -1,11 +1,16 @@ #include "theme.h" +#include +#include #include #include #include +#include #include #include #include +#include +#include #include #include #include @@ -19,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -26,11 +32,17 @@ #include #include #include -#include +#include #include +#include #include "audio_mixer.h" #include "defs.h" +#include "input_mapping.h" +#include "lua.h" +#include "lualib.h" +#include "shared/shared_defs.h" +#include "tweaked_inputs.h" #ifdef HAVE_CEF #include "cef_capture.h" #endif @@ -140,6 +152,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 +276,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 +288,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 +324,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(L, "LiveInputWrapper", theme, chain, pixel_format, override_bounce, deinterlace, /*user_connectable=*/true); @@ -622,6 +638,18 @@ int LiftGammaGainEffect_new(lua_State* L) return wrap_lua_object_nonowned(L, "EffectBlueprint", LIFT_GAMMA_GAIN_EFFECT); } +int BlurEffect_new(lua_State* L) +{ + assert(lua_gettop(L) == 0); + return wrap_lua_object_nonowned(L, "EffectBlueprint", BLUR_EFFECT); +} + +int UnsharpMaskEffect_new(lua_State* L) +{ + assert(lua_gettop(L) == 0); + return wrap_lua_object_nonowned(L, "EffectBlueprint", UNSHARP_MASK_EFFECT); +} + int InputStateInfo_get_width(lua_State* L) { assert(lua_gettop(L) == 2); @@ -997,6 +1025,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[] = { @@ -1420,6 +1458,15 @@ int Nageru_set_audio_bus_mute(lua_State *L) return 0; } +int Nageru_schedule_cut(lua_State *L) +{ + if (global_mixer == nullptr) { + luaL_error(L, "Cuts can not be scheduled before the theme is done initializing."); + } + global_mixer->schedule_cut(); + return 0; +} + int Nageru_get_audio_bus_eq_level_db(lua_State *L) { if (global_audio_mixer == nullptr) { @@ -1558,6 +1605,8 @@ Theme::Theme(const string &filename, const vector &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); @@ -1630,6 +1679,9 @@ void Theme::register_globals() { "get_audio_bus_mute", Nageru_get_audio_bus_mute }, { "set_audio_bus_mute", Nageru_set_audio_bus_mute }, + // Misc. + { "schedule_cut", Nageru_schedule_cut }, + { nullptr, nullptr } }; lua_pushlightuserdata(L, this); @@ -2044,8 +2096,8 @@ unique_ptr create_theme_menu_entry(lua_State *L, int index) lua_pop(L, 1); unsigned flags = 0; - if (lua_objlen(L, -1) > 2) { - lua_rawgeti(L, -1, 3); + if (lua_objlen(L, index) > 2) { + lua_rawgeti(L, index, 3); flags = luaL_checknumber(L, -1); lua_pop(L, 1); }