diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..d7e326e --- /dev/null +++ b/.clang-format @@ -0,0 +1,2 @@ +BasedOnStyle: InheritParentConfig +ColumnLimit: 132 \ No newline at end of file diff --git a/audio-move.c b/audio-move.c index 989c6ff..fb89c7a 100644 --- a/audio-move.c +++ b/audio-move.c @@ -64,25 +64,20 @@ static const char *audio_move_get_name(void *type_data) return obs_module_text("AudioMoveFilter"); } -void audio_move_volmeter_updated(void *data, - const float magnitude[MAX_AUDIO_CHANNELS], - const float peak[MAX_AUDIO_CHANNELS], +void audio_move_volmeter_updated(void *data, const float magnitude[MAX_AUDIO_CHANNELS], const float peak[MAX_AUDIO_CHANNELS], const float input_peak[MAX_AUDIO_CHANNELS]) { struct audio_move_info *audio_move = data; float v = 0.0f; if (audio_move->meter_type == METER_TYPE_MAGNITUDE) { v = magnitude[0]; - } else if (audio_move->meter_type == METER_TYPE_INPUT_PEAK_SAMPLE || - audio_move->meter_type == METER_TYPE_INPUT_PEAK_TRUE) { + } else if (audio_move->meter_type == METER_TYPE_INPUT_PEAK_SAMPLE || audio_move->meter_type == METER_TYPE_INPUT_PEAK_TRUE) { v = input_peak[0]; - } else if (audio_move->meter_type == METER_TYPE_PEAK_SAMPLE || - audio_move->meter_type == METER_TYPE_PEAK_TRUE) { + } else if (audio_move->meter_type == METER_TYPE_PEAK_SAMPLE || audio_move->meter_type == METER_TYPE_PEAK_TRUE) { v = peak[0]; } v = obs_db_to_mul(v); - audio_move->audio_value = audio_move->easing * audio_move->audio_value + - (1.0 - audio_move->easing) * v; + audio_move->audio_value = audio_move->easing * audio_move->audio_value + (1.0 - audio_move->easing) * v; } void audio_move_source_destroy(void *data, calldata_t *call_data) @@ -99,57 +94,34 @@ void audio_move_source_remove(void *data, calldata_t *call_data) { UNUSED_PARAMETER(call_data); struct audio_move_info *audio_move = data; - obs_source_t *source = - (obs_source_t *)calldata_ptr(call_data, "source"); + obs_source_t *source = (obs_source_t *)calldata_ptr(call_data, "source"); signal_handler_t *sh = obs_source_get_signal_handler(source); - signal_handler_disconnect(sh, "remove", audio_move_source_remove, - audio_move); - signal_handler_disconnect(sh, "destroy", audio_move_source_destroy, - audio_move); + signal_handler_disconnect(sh, "remove", audio_move_source_remove, audio_move); + signal_handler_disconnect(sh, "destroy", audio_move_source_destroy, audio_move); if (audio_move->target_source) { - if (!obs_weak_source_references_source( - audio_move->target_source, source)) { - source = obs_weak_source_get_source( - audio_move->target_source); - signal_handler_t *sh = - obs_source_get_signal_handler(source); - signal_handler_disconnect(sh, "remove", - audio_move_source_remove, - audio_move); - signal_handler_disconnect(sh, "destroy", - audio_move_source_destroy, - audio_move); + if (!obs_weak_source_references_source(audio_move->target_source, source)) { + source = obs_weak_source_get_source(audio_move->target_source); + signal_handler_t *sh = obs_source_get_signal_handler(source); + signal_handler_disconnect(sh, "remove", audio_move_source_remove, audio_move); + signal_handler_disconnect(sh, "destroy", audio_move_source_destroy, audio_move); obs_source_release(source); } obs_weak_source_release(audio_move->target_source); } audio_move->target_source = NULL; if (audio_move->sceneitem) { - obs_scene_t *scene = - obs_sceneitem_get_scene(audio_move->sceneitem); - signal_handler_t *sh = obs_source_get_signal_handler( - obs_scene_get_source(scene)); + obs_scene_t *scene = obs_sceneitem_get_scene(audio_move->sceneitem); + signal_handler_t *sh = obs_source_get_signal_handler(obs_scene_get_source(scene)); if (sh) { - signal_handler_disconnect(sh, "item_remove", - audio_move_item_remove, - audio_move); - signal_handler_disconnect(sh, "remove", - audio_move_source_remove, - audio_move); - signal_handler_disconnect(sh, "destroy", - audio_move_source_destroy, - audio_move); + signal_handler_disconnect(sh, "item_remove", audio_move_item_remove, audio_move); + signal_handler_disconnect(sh, "remove", audio_move_source_remove, audio_move); + signal_handler_disconnect(sh, "destroy", audio_move_source_destroy, audio_move); } - obs_source_t *item_source = - obs_sceneitem_get_source(audio_move->sceneitem); + obs_source_t *item_source = obs_sceneitem_get_source(audio_move->sceneitem); if (item_source) { sh = obs_source_get_signal_handler(item_source); - signal_handler_disconnect(sh, "remove", - audio_move_source_remove, - audio_move); - signal_handler_disconnect(sh, "destroy", - audio_move_source_destroy, - audio_move); + signal_handler_disconnect(sh, "remove", audio_move_source_remove, audio_move); + signal_handler_disconnect(sh, "destroy", audio_move_source_destroy, audio_move); } } audio_move->sceneitem = NULL; @@ -166,18 +138,11 @@ void audio_move_item_remove(void *data, calldata_t *call_data) audio_move->sceneitem = NULL; obs_source_t *parent = obs_scene_get_source(scene); if (parent) { - signal_handler_t *sh = - obs_source_get_signal_handler(parent); + signal_handler_t *sh = obs_source_get_signal_handler(parent); if (sh) { - signal_handler_disconnect( - sh, "item_remove", - audio_move_item_remove, audio_move); - signal_handler_disconnect( - sh, "remove", audio_move_source_remove, - audio_move); - signal_handler_disconnect( - sh, "destroy", - audio_move_source_destroy, audio_move); + signal_handler_disconnect(sh, "item_remove", audio_move_item_remove, audio_move); + signal_handler_disconnect(sh, "remove", audio_move_source_remove, audio_move); + signal_handler_disconnect(sh, "destroy", audio_move_source_destroy, audio_move); } } } @@ -194,14 +159,10 @@ void audio_move_update(void *data, obs_data_t *settings) const long long meter_type = obs_data_get_int(settings, "meter_type"); if (meter_type != audio_move->meter_type) { audio_move->meter_type = meter_type; - if (meter_type == METER_TYPE_INPUT_PEAK_SAMPLE || - meter_type == METER_TYPE_PEAK_SAMPLE) { - obs_volmeter_set_peak_meter_type(audio_move->volmeter, - SAMPLE_PEAK_METER); - } else if (meter_type == METER_TYPE_INPUT_PEAK_TRUE || - meter_type == METER_TYPE_PEAK_TRUE) { - obs_volmeter_set_peak_meter_type(audio_move->volmeter, - TRUE_PEAK_METER); + if (meter_type == METER_TYPE_INPUT_PEAK_SAMPLE || meter_type == METER_TYPE_PEAK_SAMPLE) { + obs_volmeter_set_peak_meter_type(audio_move->volmeter, SAMPLE_PEAK_METER); + } else if (meter_type == METER_TYPE_INPUT_PEAK_TRUE || meter_type == METER_TYPE_PEAK_TRUE) { + obs_volmeter_set_peak_meter_type(audio_move->volmeter, TRUE_PEAK_METER); } } audio_move->easing = obs_data_get_double(settings, "easing") / 100.0; @@ -222,74 +183,43 @@ void audio_move_update(void *data, obs_data_t *settings) if (audio_move->sceneitem) { signal_handler_t *sh = obs_source_get_signal_handler(source); if (sh) { - signal_handler_disconnect(sh, "item_remove", - audio_move_item_remove, - audio_move); - signal_handler_disconnect(sh, "remove", - audio_move_source_remove, - audio_move); - signal_handler_disconnect(sh, "destroy", - audio_move_source_destroy, - audio_move); + signal_handler_disconnect(sh, "item_remove", audio_move_item_remove, audio_move); + signal_handler_disconnect(sh, "remove", audio_move_source_remove, audio_move); + signal_handler_disconnect(sh, "destroy", audio_move_source_destroy, audio_move); } - obs_source_t *item_source = - obs_sceneitem_get_source(audio_move->sceneitem); + obs_source_t *item_source = obs_sceneitem_get_source(audio_move->sceneitem); if (item_source) { sh = obs_source_get_signal_handler(item_source); - signal_handler_disconnect(sh, "remove", - audio_move_source_remove, - audio_move); - signal_handler_disconnect(sh, "destroy", - audio_move_source_destroy, - audio_move); + signal_handler_disconnect(sh, "remove", audio_move_source_remove, audio_move); + signal_handler_disconnect(sh, "destroy", audio_move_source_destroy, audio_move); } } - audio_move->sceneitem = - scene ? obs_scene_find_source_recursive(scene, sceneitem_name) - : NULL; - if (audio_move->sceneitem && - obs_source_removed( - obs_sceneitem_get_source(audio_move->sceneitem))) { + audio_move->sceneitem = scene ? obs_scene_find_source_recursive(scene, sceneitem_name) : NULL; + if (audio_move->sceneitem && obs_source_removed(obs_sceneitem_get_source(audio_move->sceneitem))) { audio_move->sceneitem = NULL; } if (audio_move->sceneitem && source) { signal_handler_t *sh = obs_source_get_signal_handler(source); if (sh) { - signal_handler_connect(sh, "item_remove", - audio_move_item_remove, - audio_move); - signal_handler_connect(sh, "remove", - audio_move_source_remove, - audio_move); - signal_handler_connect(sh, "destroy", - audio_move_source_destroy, - audio_move); + signal_handler_connect(sh, "item_remove", audio_move_item_remove, audio_move); + signal_handler_connect(sh, "remove", audio_move_source_remove, audio_move); + signal_handler_connect(sh, "destroy", audio_move_source_destroy, audio_move); } - obs_source_t *item_source = - obs_sceneitem_get_source(audio_move->sceneitem); + obs_source_t *item_source = obs_sceneitem_get_source(audio_move->sceneitem); if (item_source) { sh = obs_source_get_signal_handler(item_source); - signal_handler_connect(sh, "remove", - audio_move_source_remove, - audio_move); - signal_handler_connect(sh, "destroy", - audio_move_source_destroy, - audio_move); + signal_handler_connect(sh, "remove", audio_move_source_remove, audio_move); + signal_handler_connect(sh, "destroy", audio_move_source_destroy, audio_move); } } if (audio_move->target_source) { source = obs_weak_source_get_source(audio_move->target_source); if (source) { - signal_handler_t *sh = - obs_source_get_signal_handler(source); - signal_handler_disconnect(sh, "remove", - audio_move_source_remove, - audio_move); - signal_handler_disconnect(sh, "destroy", - audio_move_source_destroy, - audio_move); + signal_handler_t *sh = obs_source_get_signal_handler(source); + signal_handler_disconnect(sh, "remove", audio_move_source_remove, audio_move); + signal_handler_disconnect(sh, "destroy", audio_move_source_destroy, audio_move); obs_source_release(source); } obs_weak_source_release(audio_move->target_source); @@ -297,29 +227,21 @@ void audio_move_update(void *data, obs_data_t *settings) audio_move->target_source = NULL; obs_source_t *target_source = NULL; if (audio_move->action == VALUE_ACTION_FILTER_ENABLE) { - source = obs_get_source_by_name( - obs_data_get_string(settings, "source")); + source = obs_get_source_by_name(obs_data_get_string(settings, "source")); if (source) { - obs_source_t *filter = obs_source_get_filter_by_name( - source, - obs_data_get_string(settings, "filter")); + obs_source_t *filter = obs_source_get_filter_by_name(source, obs_data_get_string(settings, "filter")); if (filter) { target_source = filter; } obs_source_release(source); } } else if (audio_move->action == VALUE_ACTION_SETTING) { - source = obs_get_source_by_name( - obs_data_get_string(settings, "source")); + source = obs_get_source_by_name(obs_data_get_string(settings, "source")); if (source) { - const char *filter_name = - obs_data_get_string(settings, "filter"); + const char *filter_name = obs_data_get_string(settings, "filter"); obs_source_t *filter = - filter_name && strlen(filter_name) - ? obs_source_get_filter_by_name( - source, filter_name) - : NULL; + filter_name && strlen(filter_name) ? obs_source_get_filter_by_name(source, filter_name) : NULL; if (filter) { target_source = filter; obs_source_release(source); @@ -333,24 +255,17 @@ void audio_move_update(void *data, obs_data_t *settings) target_source = NULL; } if (target_source) { - audio_move->target_source = - obs_source_get_weak_source(target_source); + audio_move->target_source = obs_source_get_weak_source(target_source); - signal_handler_t *sh = - obs_source_get_signal_handler(target_source); - signal_handler_connect(sh, "remove", audio_move_source_remove, - audio_move); - signal_handler_connect(sh, "destroy", audio_move_source_destroy, - audio_move); + signal_handler_t *sh = obs_source_get_signal_handler(target_source); + signal_handler_connect(sh, "remove", audio_move_source_remove, audio_move); + signal_handler_connect(sh, "destroy", audio_move_source_destroy, audio_move); obs_source_release(target_source); } - audio_move->threshold_action = - obs_data_get_int(settings, "threshold_action"); - audio_move->threshold = - obs_data_get_double(settings, "threshold") / 100.0; + audio_move->threshold_action = obs_data_get_int(settings, "threshold_action"); + audio_move->threshold = obs_data_get_double(settings, "threshold") / 100.0; const char *setting_name = obs_data_get_string(settings, "setting"); - if (!audio_move->setting_name || - strcmp(audio_move->setting_name, setting_name) != 0) { + if (!audio_move->setting_name || strcmp(audio_move->setting_name, setting_name) != 0) { bfree(audio_move->setting_name); audio_move->setting_name = bstrdup(setting_name); } @@ -358,12 +273,10 @@ void audio_move_update(void *data, obs_data_t *settings) static void *audio_move_create(obs_data_t *settings, obs_source_t *source) { - struct audio_move_info *audio_move = - bzalloc(sizeof(struct audio_move_info)); + struct audio_move_info *audio_move = bzalloc(sizeof(struct audio_move_info)); audio_move->source = source; audio_move->volmeter = obs_volmeter_create(OBS_FADER_LOG); - obs_volmeter_add_callback(audio_move->volmeter, - audio_move_volmeter_updated, audio_move); + obs_volmeter_add_callback(audio_move->volmeter, audio_move_volmeter_updated, audio_move); audio_move_update(audio_move, settings); return audio_move; @@ -373,53 +286,33 @@ static void audio_move_destroy(void *data) { struct audio_move_info *audio_move = data; obs_volmeter_detach_source(audio_move->volmeter); - obs_volmeter_remove_callback(audio_move->volmeter, - audio_move_volmeter_updated, audio_move); + obs_volmeter_remove_callback(audio_move->volmeter, audio_move_volmeter_updated, audio_move); obs_volmeter_destroy(audio_move->volmeter); audio_move->volmeter = NULL; if (audio_move->target_source) { - obs_source_t *source = - obs_weak_source_get_source(audio_move->target_source); + obs_source_t *source = obs_weak_source_get_source(audio_move->target_source); if (source) { - signal_handler_t *sh = - obs_source_get_signal_handler(source); - signal_handler_disconnect(sh, "remove", - audio_move_source_remove, - audio_move); - signal_handler_disconnect(sh, "destroy", - audio_move_source_destroy, - audio_move); + signal_handler_t *sh = obs_source_get_signal_handler(source); + signal_handler_disconnect(sh, "remove", audio_move_source_remove, audio_move); + signal_handler_disconnect(sh, "destroy", audio_move_source_destroy, audio_move); obs_source_release(source); } obs_weak_source_release(audio_move->target_source); } audio_move->target_source = NULL; if (audio_move->sceneitem) { - obs_scene_t *scene = - obs_sceneitem_get_scene(audio_move->sceneitem); - signal_handler_t *sh = obs_source_get_signal_handler( - obs_scene_get_source(scene)); + obs_scene_t *scene = obs_sceneitem_get_scene(audio_move->sceneitem); + signal_handler_t *sh = obs_source_get_signal_handler(obs_scene_get_source(scene)); if (sh) { - signal_handler_disconnect(sh, "item_remove", - audio_move_item_remove, - audio_move); - signal_handler_disconnect(sh, "remove", - audio_move_source_remove, - audio_move); - signal_handler_disconnect(sh, "destroy", - audio_move_source_destroy, - audio_move); + signal_handler_disconnect(sh, "item_remove", audio_move_item_remove, audio_move); + signal_handler_disconnect(sh, "remove", audio_move_source_remove, audio_move); + signal_handler_disconnect(sh, "destroy", audio_move_source_destroy, audio_move); } - obs_source_t *item_source = - obs_sceneitem_get_source(audio_move->sceneitem); + obs_source_t *item_source = obs_sceneitem_get_source(audio_move->sceneitem); if (item_source) { sh = obs_source_get_signal_handler(item_source); - signal_handler_disconnect(sh, "remove", - audio_move_source_remove, - audio_move); - signal_handler_disconnect(sh, "destroy", - audio_move_source_destroy, - audio_move); + signal_handler_disconnect(sh, "remove", audio_move_source_remove, audio_move); + signal_handler_disconnect(sh, "destroy", audio_move_source_destroy, audio_move); } } audio_move->sceneitem = NULL; @@ -435,8 +328,7 @@ static bool add_source_to_prop_list(void *data, obs_source_t *source) return true; size_t count = obs_property_list_item_count(p); size_t idx = 0; - while (idx < count && - strcmp(name, obs_property_list_item_string(p, idx)) > 0) + while (idx < count && strcmp(name, obs_property_list_item_string(p, idx)) > 0) idx++; obs_property_list_insert_string(p, idx, name, name); return true; @@ -452,23 +344,19 @@ static bool add_group_to_prop_list(void *data, obs_source_t *source) return true; size_t count = obs_property_list_item_count(p); size_t idx = 0; - while (idx < count && - strcmp(name, obs_property_list_item_string(p, idx)) > 0) + while (idx < count && strcmp(name, obs_property_list_item_string(p, idx)) > 0) idx++; obs_property_list_insert_string(p, idx, name, name); return true; } -static bool audio_move_action_changed(obs_properties_t *props, - obs_property_t *property, - obs_data_t *settings) +static bool audio_move_action_changed(obs_properties_t *props, obs_property_t *property, obs_data_t *settings) { UNUSED_PARAMETER(property); long long action = obs_data_get_int(settings, "value_action"); obs_property_t *scene = obs_properties_get(props, "scene"); obs_property_t *sceneitem = obs_properties_get(props, "sceneitem"); - if (action == VALUE_ACTION_TRANSFORM || - action == VALUE_ACTION_SOURCE_VISIBILITY) { + if (action == VALUE_ACTION_TRANSFORM || action == VALUE_ACTION_SOURCE_VISIBILITY) { obs_property_list_clear(scene); obs_enum_scenes(add_source_to_prop_list, scene); obs_enum_sources(add_group_to_prop_list, scene); @@ -480,8 +368,7 @@ static bool audio_move_action_changed(obs_properties_t *props, } obs_property_t *source = obs_properties_get(props, "source"); obs_property_t *filter = obs_properties_get(props, "filter"); - if (action == VALUE_ACTION_SETTING || - action == VALUE_ACTION_FILTER_ENABLE) { + if (action == VALUE_ACTION_SETTING || action == VALUE_ACTION_FILTER_ENABLE) { obs_property_list_clear(source); obs_enum_sources(add_source_to_prop_list, source); obs_enum_scenes(add_source_to_prop_list, source); @@ -493,19 +380,16 @@ static bool audio_move_action_changed(obs_properties_t *props, } obs_property_t *base_value = obs_properties_get(props, "base_value"); obs_property_t *factor = obs_properties_get(props, "factor"); - if (action == VALUE_ACTION_SETTING || - action == VALUE_ACTION_TRANSFORM) { + if (action == VALUE_ACTION_SETTING || action == VALUE_ACTION_TRANSFORM) { obs_property_set_visible(base_value, true); obs_property_set_visible(factor, true); } else { obs_property_set_visible(base_value, false); obs_property_set_visible(factor, false); } - obs_property_t *threshold_action = - obs_properties_get(props, "threshold_action"); + obs_property_t *threshold_action = obs_properties_get(props, "threshold_action"); obs_property_t *threshold = obs_properties_get(props, "threshold"); - if (action == VALUE_ACTION_SOURCE_VISIBILITY || - action == VALUE_ACTION_FILTER_ENABLE) { + if (action == VALUE_ACTION_SOURCE_VISIBILITY || action == VALUE_ACTION_FILTER_ENABLE) { obs_property_set_visible(threshold_action, true); obs_property_set_visible(threshold, true); } else { @@ -527,8 +411,7 @@ static bool audio_move_action_changed(obs_properties_t *props, return true; } -static bool add_sceneitem_to_prop_list(obs_scene_t *scene, - obs_sceneitem_t *item, void *data) +static bool add_sceneitem_to_prop_list(obs_scene_t *scene, obs_sceneitem_t *item, void *data) { UNUSED_PARAMETER(scene); obs_property_t *p = (obs_property_t *)data; @@ -539,9 +422,7 @@ static bool add_sceneitem_to_prop_list(obs_scene_t *scene, return true; } -static bool audio_move_scene_changed(void *data, obs_properties_t *props, - obs_property_t *property, - obs_data_t *settings) +static bool audio_move_scene_changed(void *data, obs_properties_t *props, obs_property_t *property, obs_data_t *settings) { UNUSED_PARAMETER(data); UNUSED_PARAMETER(property); @@ -559,8 +440,7 @@ static bool audio_move_scene_changed(void *data, obs_properties_t *props, return true; } -static void add_filter_to_prop_list(obs_source_t *parent, obs_source_t *child, - void *data) +static void add_filter_to_prop_list(obs_source_t *parent, obs_source_t *child, void *data) { UNUSED_PARAMETER(parent); obs_property_t *p = (obs_property_t *)data; @@ -571,8 +451,7 @@ static void add_filter_to_prop_list(obs_source_t *parent, obs_source_t *child, obs_property_list_add_string(p, name, name); } -static void load_properties(obs_properties_t *props_from, - obs_property_t *setting_list) +static void load_properties(obs_properties_t *props_from, obs_property_t *setting_list) { obs_property_t *prop_from = obs_properties_first(props_from); for (; prop_from != NULL; obs_property_next(&prop_from)) { @@ -580,22 +459,16 @@ static void load_properties(obs_properties_t *props_from, const char *description = obs_property_description(prop_from); if (!obs_property_visible(prop_from)) continue; - const enum obs_property_type prop_type = - obs_property_get_type(prop_from); + const enum obs_property_type prop_type = obs_property_get_type(prop_from); if (prop_type == OBS_PROPERTY_GROUP) { - load_properties(obs_property_group_content(prop_from), - setting_list); - } else if (prop_type == OBS_PROPERTY_FLOAT || - prop_type == OBS_PROPERTY_INT) { - obs_property_list_add_string(setting_list, description, - name); + load_properties(obs_property_group_content(prop_from), setting_list); + } else if (prop_type == OBS_PROPERTY_FLOAT || prop_type == OBS_PROPERTY_INT) { + obs_property_list_add_string(setting_list, description, name); } } } -static bool audio_move_source_changed(void *data, obs_properties_t *props, - obs_property_t *property, - obs_data_t *settings) +static bool audio_move_source_changed(void *data, obs_properties_t *props, obs_property_t *property, obs_data_t *settings) { UNUSED_PARAMETER(property); UNUSED_PARAMETER(data); @@ -611,8 +484,7 @@ static bool audio_move_source_changed(void *data, obs_properties_t *props, obs_property_list_clear(setting); obs_properties_t *properties = NULL; if (filter_name && strlen(filter_name)) { - obs_source_t *f = - obs_source_get_filter_by_name(source, filter_name); + obs_source_t *f = obs_source_get_filter_by_name(source, filter_name); if (f) { properties = obs_source_properties(f); } @@ -631,131 +503,70 @@ static obs_properties_t *audio_move_properties(void *data) UNUSED_PARAMETER(data); obs_properties_t *ppts = obs_properties_create(); - obs_property_t *p = obs_properties_add_list( - ppts, "meter_type", obs_module_text("MeterType"), - OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); - obs_property_list_add_int(p, obs_module_text("MeterType.Magnitude"), - METER_TYPE_MAGNITUDE); - obs_property_list_add_int(p, obs_module_text("MeterType.PeakSample"), - METER_TYPE_PEAK_SAMPLE); - obs_property_list_add_int(p, obs_module_text("MeterType.PeakTrue"), - METER_TYPE_PEAK_TRUE); - obs_property_list_add_int(p, - obs_module_text("MeterType.InputPeakSample"), - METER_TYPE_INPUT_PEAK_SAMPLE); - obs_property_list_add_int(p, obs_module_text("MeterType.InputPeakTrue"), - METER_TYPE_INPUT_PEAK_TRUE); - - p = obs_properties_add_float_slider( - ppts, "easing", obs_module_text("Easing"), 0.0, 99.99, 0.01); - - p = obs_properties_add_list(ppts, "value_action", - obs_module_text("ValueAction"), - OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); - obs_property_list_add_int(p, obs_module_text("ValueAction.Transform"), - VALUE_ACTION_TRANSFORM); - obs_property_list_add_int(p, obs_module_text("ValueAction.Setting"), - VALUE_ACTION_SETTING); - obs_property_list_add_int( - p, obs_module_text("ValueAction.SourceVisibility"), - VALUE_ACTION_SOURCE_VISIBILITY); - obs_property_list_add_int(p, - obs_module_text("ValueAction.FilterEnable"), - VALUE_ACTION_FILTER_ENABLE); + obs_property_t *p = obs_properties_add_list(ppts, "meter_type", obs_module_text("MeterType"), OBS_COMBO_TYPE_LIST, + OBS_COMBO_FORMAT_INT); + obs_property_list_add_int(p, obs_module_text("MeterType.Magnitude"), METER_TYPE_MAGNITUDE); + obs_property_list_add_int(p, obs_module_text("MeterType.PeakSample"), METER_TYPE_PEAK_SAMPLE); + obs_property_list_add_int(p, obs_module_text("MeterType.PeakTrue"), METER_TYPE_PEAK_TRUE); + obs_property_list_add_int(p, obs_module_text("MeterType.InputPeakSample"), METER_TYPE_INPUT_PEAK_SAMPLE); + obs_property_list_add_int(p, obs_module_text("MeterType.InputPeakTrue"), METER_TYPE_INPUT_PEAK_TRUE); + + p = obs_properties_add_float_slider(ppts, "easing", obs_module_text("Easing"), 0.0, 99.99, 0.01); + + p = obs_properties_add_list(ppts, "value_action", obs_module_text("ValueAction"), OBS_COMBO_TYPE_LIST, + OBS_COMBO_FORMAT_INT); + obs_property_list_add_int(p, obs_module_text("ValueAction.Transform"), VALUE_ACTION_TRANSFORM); + obs_property_list_add_int(p, obs_module_text("ValueAction.Setting"), VALUE_ACTION_SETTING); + obs_property_list_add_int(p, obs_module_text("ValueAction.SourceVisibility"), VALUE_ACTION_SOURCE_VISIBILITY); + obs_property_list_add_int(p, obs_module_text("ValueAction.FilterEnable"), VALUE_ACTION_FILTER_ENABLE); obs_property_set_modified_callback(p, audio_move_action_changed); - p = obs_properties_add_list(ppts, "scene", obs_module_text("Scene"), - OBS_COMBO_TYPE_EDITABLE, - OBS_COMBO_FORMAT_STRING); + p = obs_properties_add_list(ppts, "scene", obs_module_text("Scene"), OBS_COMBO_TYPE_EDITABLE, OBS_COMBO_FORMAT_STRING); obs_property_set_modified_callback2(p, audio_move_scene_changed, data); - p = obs_properties_add_list(ppts, "sceneitem", - obs_module_text("Source"), - OBS_COMBO_TYPE_EDITABLE, - OBS_COMBO_FORMAT_STRING); + p = obs_properties_add_list(ppts, "sceneitem", obs_module_text("Source"), OBS_COMBO_TYPE_EDITABLE, OBS_COMBO_FORMAT_STRING); - p = obs_properties_add_list(ppts, "source", obs_module_text("Source"), - OBS_COMBO_TYPE_EDITABLE, - OBS_COMBO_FORMAT_STRING); + p = obs_properties_add_list(ppts, "source", obs_module_text("Source"), OBS_COMBO_TYPE_EDITABLE, OBS_COMBO_FORMAT_STRING); obs_property_set_modified_callback2(p, audio_move_source_changed, data); - p = obs_properties_add_list(ppts, "filter", obs_module_text("Filter"), - OBS_COMBO_TYPE_EDITABLE, - OBS_COMBO_FORMAT_STRING); + p = obs_properties_add_list(ppts, "filter", obs_module_text("Filter"), OBS_COMBO_TYPE_EDITABLE, OBS_COMBO_FORMAT_STRING); obs_property_set_modified_callback2(p, audio_move_source_changed, data); - p = obs_properties_add_list(ppts, "transform", - obs_module_text("Transform"), - OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); - obs_property_list_add_int(p, obs_module_text("Transform.PosX"), - TRANSFORM_POS_X); - obs_property_list_add_int(p, obs_module_text("Transform.PosY"), - TRANSFORM_POS_Y); - obs_property_list_add_int(p, obs_module_text("Transform.Rotation"), - TRANSFORM_ROT); - obs_property_list_add_int(p, obs_module_text("Transform.Scale"), - TRANSFORM_SCALE); - obs_property_list_add_int(p, obs_module_text("Transform.ScaleX"), - TRANSFORM_SCALE_X); - obs_property_list_add_int(p, obs_module_text("Transform.ScaleY"), - TRANSFORM_SCALE_Y); - obs_property_list_add_int(p, obs_module_text("Transform.BoundsX"), - TRANSFORM_BOUNDS_X); - obs_property_list_add_int(p, obs_module_text("Transform.BoundsY"), - TRANSFORM_BOUNDS_Y); - obs_property_list_add_int(p, obs_module_text("Transform.CropLeft"), - TRANSFORM_CROP_LEFT); - obs_property_list_add_int(p, obs_module_text("Transform.CropTop"), - TRANSFORM_CROP_TOP); - obs_property_list_add_int(p, obs_module_text("Transform.CropRight"), - TRANSFORM_CROP_RIGHT); - obs_property_list_add_int(p, obs_module_text("Transform.CropBottom"), - TRANSFORM_CROP_BOTTOM); - obs_property_list_add_int(p, - obs_module_text("Transform.CropHorizontal"), - TRANSFORM_CROP_HORIZONTAL); - obs_property_list_add_int(p, obs_module_text("Transform.CropVertical"), - TRANSFORM_CROP_VERTICAL); - - p = obs_properties_add_list(ppts, "setting", obs_module_text("Setting"), - OBS_COMBO_TYPE_LIST, - OBS_COMBO_FORMAT_STRING); - - p = obs_properties_add_float(ppts, "base_value", - obs_module_text("BaseValue"), -DBL_MAX, - DBL_MAX, 0.01); - p = obs_properties_add_float(ppts, "factor", obs_module_text("Factor"), - -DBL_MAX, DBL_MAX, 0.01); - p = obs_properties_add_list(ppts, "threshold_action", - obs_module_text("ThresholdAction"), - OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); - obs_property_list_add_int(p, obs_module_text("ThresholdAction.None"), - THRESHOLD_NONE); - obs_property_list_add_int(p, - obs_module_text("ThresholdAction.EnableOver"), - THRESHOLD_ENABLE_OVER); - obs_property_list_add_int( - p, obs_module_text("ThresholdAction.EnableUnder"), - THRESHOLD_ENABLE_UNDER); - obs_property_list_add_int( - p, obs_module_text("ThresholdAction.DisableOver"), - THRESHOLD_DISABLE_OVER); - obs_property_list_add_int( - p, obs_module_text("ThresholdAction.DisableUnder"), - THRESHOLD_DISABLE_UNDER); - obs_property_list_add_int( - p, obs_module_text("ThresholdAction.EnableOverDisableUnder"), - THRESHOLD_ENABLE_OVER_DISABLE_UNDER); - obs_property_list_add_int( - p, obs_module_text("ThresholdAction.EnableUnderDisableOver"), - THRESHOLD_ENABLE_UNDER_DISABLE_OVER); - p = obs_properties_add_float_slider(ppts, "threshold", - obs_module_text("Threshold"), 0.0, - 100.0, 0.01); - obs_properties_add_text(ppts, "plugin_info", PLUGIN_INFO, - OBS_TEXT_INFO); + p = obs_properties_add_list(ppts, "transform", obs_module_text("Transform"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); + obs_property_list_add_int(p, obs_module_text("Transform.PosX"), TRANSFORM_POS_X); + obs_property_list_add_int(p, obs_module_text("Transform.PosY"), TRANSFORM_POS_Y); + obs_property_list_add_int(p, obs_module_text("Transform.Rotation"), TRANSFORM_ROT); + obs_property_list_add_int(p, obs_module_text("Transform.Scale"), TRANSFORM_SCALE); + obs_property_list_add_int(p, obs_module_text("Transform.ScaleX"), TRANSFORM_SCALE_X); + obs_property_list_add_int(p, obs_module_text("Transform.ScaleY"), TRANSFORM_SCALE_Y); + obs_property_list_add_int(p, obs_module_text("Transform.BoundsX"), TRANSFORM_BOUNDS_X); + obs_property_list_add_int(p, obs_module_text("Transform.BoundsY"), TRANSFORM_BOUNDS_Y); + obs_property_list_add_int(p, obs_module_text("Transform.CropLeft"), TRANSFORM_CROP_LEFT); + obs_property_list_add_int(p, obs_module_text("Transform.CropTop"), TRANSFORM_CROP_TOP); + obs_property_list_add_int(p, obs_module_text("Transform.CropRight"), TRANSFORM_CROP_RIGHT); + obs_property_list_add_int(p, obs_module_text("Transform.CropBottom"), TRANSFORM_CROP_BOTTOM); + obs_property_list_add_int(p, obs_module_text("Transform.CropHorizontal"), TRANSFORM_CROP_HORIZONTAL); + obs_property_list_add_int(p, obs_module_text("Transform.CropVertical"), TRANSFORM_CROP_VERTICAL); + + p = obs_properties_add_list(ppts, "setting", obs_module_text("Setting"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING); + + p = obs_properties_add_float(ppts, "base_value", obs_module_text("BaseValue"), -DBL_MAX, DBL_MAX, 0.01); + p = obs_properties_add_float(ppts, "factor", obs_module_text("Factor"), -DBL_MAX, DBL_MAX, 0.01); + p = obs_properties_add_list(ppts, "threshold_action", obs_module_text("ThresholdAction"), OBS_COMBO_TYPE_LIST, + OBS_COMBO_FORMAT_INT); + obs_property_list_add_int(p, obs_module_text("ThresholdAction.None"), THRESHOLD_NONE); + obs_property_list_add_int(p, obs_module_text("ThresholdAction.EnableOver"), THRESHOLD_ENABLE_OVER); + obs_property_list_add_int(p, obs_module_text("ThresholdAction.EnableUnder"), THRESHOLD_ENABLE_UNDER); + obs_property_list_add_int(p, obs_module_text("ThresholdAction.DisableOver"), THRESHOLD_DISABLE_OVER); + obs_property_list_add_int(p, obs_module_text("ThresholdAction.DisableUnder"), THRESHOLD_DISABLE_UNDER); + obs_property_list_add_int(p, obs_module_text("ThresholdAction.EnableOverDisableUnder"), + THRESHOLD_ENABLE_OVER_DISABLE_UNDER); + obs_property_list_add_int(p, obs_module_text("ThresholdAction.EnableUnderDisableOver"), + THRESHOLD_ENABLE_UNDER_DISABLE_OVER); + p = obs_properties_add_float_slider(ppts, "threshold", obs_module_text("Threshold"), 0.0, 100.0, 0.01); + obs_properties_add_text(ppts, "plugin_info", PLUGIN_INFO, OBS_TEXT_INFO); return ppts; } @@ -772,8 +583,7 @@ void audio_move_tick(void *data, float seconds) return; if (filter->action == VALUE_ACTION_TRANSFORM) { if (!filter->sceneitem) { - obs_data_t *settings = - obs_source_get_settings(filter->source); + obs_data_t *settings = obs_source_get_settings(filter->source); audio_move_update(filter, settings); obs_data_release(settings); } @@ -782,192 +592,146 @@ void audio_move_tick(void *data, float seconds) if (filter->transform == TRANSFORM_POS_X) { struct vec2 pos; obs_sceneitem_get_pos(filter->sceneitem, &pos); - pos.x = (float)(filter->factor * filter->audio_value + - filter->base_value); + pos.x = (float)(filter->factor * filter->audio_value + filter->base_value); obs_sceneitem_set_pos(filter->sceneitem, &pos); } else if (filter->transform == TRANSFORM_POS_Y) { struct vec2 pos; obs_sceneitem_get_pos(filter->sceneitem, &pos); - pos.y = (float)(filter->factor * filter->audio_value + - filter->base_value); + pos.y = (float)(filter->factor * filter->audio_value + filter->base_value); obs_sceneitem_set_pos(filter->sceneitem, &pos); } else if (filter->transform == TRANSFORM_ROT) { - obs_sceneitem_set_rot( - filter->sceneitem, - (float)(filter->factor * filter->audio_value + - filter->base_value)); + obs_sceneitem_set_rot(filter->sceneitem, + (float)(filter->factor * filter->audio_value + filter->base_value)); } else if (filter->transform == TRANSFORM_SCALE) { struct vec2 scale; - scale.x = (float)(filter->factor * filter->audio_value + - filter->base_value); + scale.x = (float)(filter->factor * filter->audio_value + filter->base_value); scale.y = scale.x; obs_sceneitem_set_scale(filter->sceneitem, &scale); } else if (filter->transform == TRANSFORM_SCALE_X) { struct vec2 scale; obs_sceneitem_get_scale(filter->sceneitem, &scale); - scale.x = (float)(filter->factor * filter->audio_value + - filter->base_value); + scale.x = (float)(filter->factor * filter->audio_value + filter->base_value); obs_sceneitem_set_scale(filter->sceneitem, &scale); } else if (filter->transform == TRANSFORM_SCALE_Y) { struct vec2 scale; obs_sceneitem_get_scale(filter->sceneitem, &scale); - scale.y = (float)(filter->factor * filter->audio_value + - filter->base_value); + scale.y = (float)(filter->factor * filter->audio_value + filter->base_value); obs_sceneitem_set_scale(filter->sceneitem, &scale); } else if (filter->transform == TRANSFORM_BOUNDS_X) { struct vec2 bounds; obs_sceneitem_get_bounds(filter->sceneitem, &bounds); - bounds.x = - (float)(filter->factor * filter->audio_value + - filter->base_value); + bounds.x = (float)(filter->factor * filter->audio_value + filter->base_value); obs_sceneitem_set_bounds(filter->sceneitem, &bounds); } else if (filter->transform == TRANSFORM_BOUNDS_Y) { struct vec2 bounds; obs_sceneitem_get_bounds(filter->sceneitem, &bounds); - bounds.y = - (float)(filter->factor * filter->audio_value + - filter->base_value); + bounds.y = (float)(filter->factor * filter->audio_value + filter->base_value); obs_sceneitem_set_bounds(filter->sceneitem, &bounds); } else if (filter->transform == TRANSFORM_CROP_LEFT) { struct obs_sceneitem_crop crop; obs_sceneitem_get_crop(filter->sceneitem, &crop); - crop.left = (int)(filter->factor * filter->audio_value + - filter->base_value); + crop.left = (int)(filter->factor * filter->audio_value + filter->base_value); obs_sceneitem_set_crop(filter->sceneitem, &crop); } else if (filter->transform == TRANSFORM_CROP_TOP) { struct obs_sceneitem_crop crop; obs_sceneitem_get_crop(filter->sceneitem, &crop); - crop.top = (int)(filter->factor * filter->audio_value + - filter->base_value); + crop.top = (int)(filter->factor * filter->audio_value + filter->base_value); obs_sceneitem_set_crop(filter->sceneitem, &crop); } else if (filter->transform == TRANSFORM_CROP_RIGHT) { struct obs_sceneitem_crop crop; obs_sceneitem_get_crop(filter->sceneitem, &crop); - crop.right = - (int)(filter->factor * filter->audio_value + - filter->base_value); + crop.right = (int)(filter->factor * filter->audio_value + filter->base_value); obs_sceneitem_set_crop(filter->sceneitem, &crop); } else if (filter->transform == TRANSFORM_CROP_BOTTOM) { struct obs_sceneitem_crop crop; obs_sceneitem_get_crop(filter->sceneitem, &crop); - crop.bottom = - (int)(filter->factor * filter->audio_value + - filter->base_value); + crop.bottom = (int)(filter->factor * filter->audio_value + filter->base_value); obs_sceneitem_set_crop(filter->sceneitem, &crop); } else if (filter->transform == TRANSFORM_CROP_HORIZONTAL) { struct obs_sceneitem_crop crop; obs_sceneitem_get_crop(filter->sceneitem, &crop); - crop.left = (int)(filter->factor * filter->audio_value + - filter->base_value); + crop.left = (int)(filter->factor * filter->audio_value + filter->base_value); crop.right = crop.left; obs_sceneitem_set_crop(filter->sceneitem, &crop); } else if (filter->transform == TRANSFORM_CROP_VERTICAL) { struct obs_sceneitem_crop crop; obs_sceneitem_get_crop(filter->sceneitem, &crop); - crop.top = (int)(filter->factor * filter->audio_value + - filter->base_value); + crop.top = (int)(filter->factor * filter->audio_value + filter->base_value); crop.bottom = crop.top; obs_sceneitem_set_crop(filter->sceneitem, &crop); } } else if (filter->action == VALUE_ACTION_SOURCE_VISIBILITY) { if (!filter->sceneitem) { - obs_data_t *settings = - obs_source_get_settings(filter->source); + obs_data_t *settings = obs_source_get_settings(filter->source); audio_move_update(filter, settings); obs_data_release(settings); } if (!filter->sceneitem) return; if ((filter->threshold_action == THRESHOLD_ENABLE_OVER || - filter->threshold_action == - THRESHOLD_ENABLE_OVER_DISABLE_UNDER) && + filter->threshold_action == THRESHOLD_ENABLE_OVER_DISABLE_UNDER) && filter->audio_value >= filter->threshold) { obs_sceneitem_set_visible(filter->sceneitem, true); - } else if ((filter->threshold_action == - THRESHOLD_ENABLE_UNDER || - filter->threshold_action == - THRESHOLD_ENABLE_UNDER_DISABLE_OVER) && + } else if ((filter->threshold_action == THRESHOLD_ENABLE_UNDER || + filter->threshold_action == THRESHOLD_ENABLE_UNDER_DISABLE_OVER) && filter->audio_value < filter->threshold) { obs_sceneitem_set_visible(filter->sceneitem, true); - } else if ((filter->threshold_action == - THRESHOLD_DISABLE_OVER || - filter->threshold_action == - THRESHOLD_ENABLE_UNDER_DISABLE_OVER) && + } else if ((filter->threshold_action == THRESHOLD_DISABLE_OVER || + filter->threshold_action == THRESHOLD_ENABLE_UNDER_DISABLE_OVER) && filter->audio_value >= filter->threshold) { obs_sceneitem_set_visible(filter->sceneitem, false); - } else if ((filter->threshold_action == - THRESHOLD_DISABLE_UNDER || - filter->threshold_action == - THRESHOLD_ENABLE_OVER_DISABLE_UNDER) && + } else if ((filter->threshold_action == THRESHOLD_DISABLE_UNDER || + filter->threshold_action == THRESHOLD_ENABLE_OVER_DISABLE_UNDER) && filter->audio_value < filter->threshold) { obs_sceneitem_set_visible(filter->sceneitem, false); } } else if (filter->action == VALUE_ACTION_FILTER_ENABLE) { if (!filter->target_source) { - obs_data_t *settings = - obs_source_get_settings(filter->source); + obs_data_t *settings = obs_source_get_settings(filter->source); audio_move_update(filter, settings); obs_data_release(settings); } if (!filter->target_source) return; - obs_source_t *source = - obs_weak_source_get_source(filter->target_source); + obs_source_t *source = obs_weak_source_get_source(filter->target_source); if (!source) return; if ((filter->threshold_action == THRESHOLD_ENABLE_OVER || - filter->threshold_action == - THRESHOLD_ENABLE_OVER_DISABLE_UNDER) && - filter->audio_value >= filter->threshold && - !obs_source_enabled(source)) { + filter->threshold_action == THRESHOLD_ENABLE_OVER_DISABLE_UNDER) && + filter->audio_value >= filter->threshold && !obs_source_enabled(source)) { obs_source_set_enabled(source, true); - } else if ((filter->threshold_action == - THRESHOLD_ENABLE_UNDER || - filter->threshold_action == - THRESHOLD_ENABLE_UNDER_DISABLE_OVER) && - filter->audio_value < filter->threshold && - !obs_source_enabled(source)) { + } else if ((filter->threshold_action == THRESHOLD_ENABLE_UNDER || + filter->threshold_action == THRESHOLD_ENABLE_UNDER_DISABLE_OVER) && + filter->audio_value < filter->threshold && !obs_source_enabled(source)) { obs_source_set_enabled(source, true); - } else if ((filter->threshold_action == - THRESHOLD_DISABLE_OVER || - filter->threshold_action == - THRESHOLD_ENABLE_UNDER_DISABLE_OVER) && - filter->audio_value >= filter->threshold && - obs_source_enabled(source)) { + } else if ((filter->threshold_action == THRESHOLD_DISABLE_OVER || + filter->threshold_action == THRESHOLD_ENABLE_UNDER_DISABLE_OVER) && + filter->audio_value >= filter->threshold && obs_source_enabled(source)) { obs_source_set_enabled(source, false); - } else if ((filter->threshold_action == - THRESHOLD_DISABLE_UNDER || - filter->threshold_action == - THRESHOLD_ENABLE_OVER_DISABLE_UNDER) && - filter->audio_value < filter->threshold && - obs_source_enabled(source)) { + } else if ((filter->threshold_action == THRESHOLD_DISABLE_UNDER || + filter->threshold_action == THRESHOLD_ENABLE_OVER_DISABLE_UNDER) && + filter->audio_value < filter->threshold && obs_source_enabled(source)) { obs_source_set_enabled(source, false); } obs_source_release(source); - } else if (filter->action == VALUE_ACTION_SETTING && - filter->setting_name && strlen(filter->setting_name)) { + } else if (filter->action == VALUE_ACTION_SETTING && filter->setting_name && strlen(filter->setting_name)) { if (!filter->target_source) { - obs_data_t *settings = - obs_source_get_settings(filter->source); + obs_data_t *settings = obs_source_get_settings(filter->source); audio_move_update(filter, settings); obs_data_release(settings); } if (!filter->target_source) return; - obs_source_t *source = - obs_weak_source_get_source(filter->target_source); + obs_source_t *source = obs_weak_source_get_source(filter->target_source); if (!source) return; obs_data_t *settings = obs_source_get_settings(source); - const double val = filter->factor * filter->audio_value + - filter->base_value; - obs_data_item_t *setting = - obs_data_item_byname(settings, filter->setting_name); + const double val = filter->factor * filter->audio_value + filter->base_value; + obs_data_item_t *setting = obs_data_item_byname(settings, filter->setting_name); if (setting) { - const enum obs_data_number_type num_type = - obs_data_item_numtype(setting); + const enum obs_data_number_type num_type = obs_data_item_numtype(setting); if (num_type == OBS_DATA_NUM_INT) { obs_data_item_set_int(&setting, (long long)val); } else if (num_type == OBS_DATA_NUM_DOUBLE) { @@ -975,8 +739,7 @@ void audio_move_tick(void *data, float seconds) } obs_data_item_release(&setting); } else { - obs_data_set_double(settings, filter->setting_name, - val); + obs_data_set_double(settings, filter->setting_name, val); } obs_data_release(settings); obs_source_update(source, NULL); @@ -988,48 +751,30 @@ void audio_move_remove(void *data, obs_source_t *source) { struct audio_move_info *audio_move = data; signal_handler_t *sh = obs_source_get_signal_handler(source); - signal_handler_disconnect(sh, "remove", audio_move_source_remove, - audio_move); - signal_handler_disconnect(sh, "destroy", audio_move_source_destroy, - audio_move); + signal_handler_disconnect(sh, "remove", audio_move_source_remove, audio_move); + signal_handler_disconnect(sh, "destroy", audio_move_source_destroy, audio_move); if (audio_move->target_source) { - obs_source_t *source = - obs_weak_source_get_source(audio_move->target_source); + obs_source_t *source = obs_weak_source_get_source(audio_move->target_source); signal_handler_t *sh = obs_source_get_signal_handler(source); - signal_handler_disconnect(sh, "remove", - audio_move_source_remove, audio_move); - signal_handler_disconnect( - sh, "destroy", audio_move_source_destroy, audio_move); + signal_handler_disconnect(sh, "remove", audio_move_source_remove, audio_move); + signal_handler_disconnect(sh, "destroy", audio_move_source_destroy, audio_move); obs_source_release(source); obs_weak_source_release(audio_move->target_source); } audio_move->target_source = NULL; if (audio_move->sceneitem) { - obs_scene_t *scene = - obs_sceneitem_get_scene(audio_move->sceneitem); - signal_handler_t *sh = obs_source_get_signal_handler( - obs_scene_get_source(scene)); + obs_scene_t *scene = obs_sceneitem_get_scene(audio_move->sceneitem); + signal_handler_t *sh = obs_source_get_signal_handler(obs_scene_get_source(scene)); if (sh) { - signal_handler_disconnect(sh, "item_remove", - audio_move_item_remove, - audio_move); - signal_handler_disconnect(sh, "remove", - audio_move_source_remove, - audio_move); - signal_handler_disconnect(sh, "destroy", - audio_move_source_destroy, - audio_move); + signal_handler_disconnect(sh, "item_remove", audio_move_item_remove, audio_move); + signal_handler_disconnect(sh, "remove", audio_move_source_remove, audio_move); + signal_handler_disconnect(sh, "destroy", audio_move_source_destroy, audio_move); } - obs_source_t *item_source = - obs_sceneitem_get_source(audio_move->sceneitem); + obs_source_t *item_source = obs_sceneitem_get_source(audio_move->sceneitem); if (item_source) { sh = obs_source_get_signal_handler(item_source); - signal_handler_disconnect(sh, "remove", - audio_move_source_remove, - audio_move); - signal_handler_disconnect(sh, "destroy", - audio_move_source_destroy, - audio_move); + signal_handler_disconnect(sh, "remove", audio_move_source_remove, audio_move); + signal_handler_disconnect(sh, "destroy", audio_move_source_destroy, audio_move); } } audio_move->sceneitem = NULL; diff --git a/data/locale/en-US.ini b/data/locale/en-US.ini index 54b7576..0e5fd45 100644 --- a/data/locale/en-US.ini +++ b/data/locale/en-US.ini @@ -190,6 +190,16 @@ ValueAction.SourceVisibility="Source Visibility" ValueAction.FilterEnable="Filter Enable" SourceVisibility="Source Visibility" SourceMute="Source Mute" +SourceAudioTrack="Source Audio Track" +AudioTrack="Audio Track" +AudioTrack.None="None" +AudioTrack.All="All" +AudioTrack.Track1="Track 1" +AudioTrack.Track2="Track 2" +AudioTrack.Track3="Track 3" +AudioTrack.Track4="Track 4" +AudioTrack.Track5="Track 5" +AudioTrack.Track6="Track 6" FilterEnable="Filter Enable" Scene="Scene" Filter="Filter" diff --git a/easing.c b/easing.c index 29162fe..8bee07e 100644 --- a/easing.c +++ b/easing.c @@ -208,12 +208,9 @@ AHFloat ElasticEaseOut(AHFloat p) AHFloat ElasticEaseInOut(AHFloat p) { if (p < 0.5) { - return (AHFloat)(0.5 * sin(13 * M_PI_2 * (2 * p)) * - pow(2, 10 * ((2 * p) - 1))); + return (AHFloat)(0.5 * sin(13 * M_PI_2 * (2 * p)) * pow(2, 10 * ((2 * p) - 1))); } else { - return (AHFloat)(0.5 * (sin(-13 * M_PI_2 * ((2 * p - 1) + 1)) * - pow(2, -10 * (2 * p - 1)) + - 2)); + return (AHFloat)(0.5 * (sin(-13 * M_PI_2 * ((2 * p - 1) + 1)) * pow(2, -10 * (2 * p - 1)) + 2)); } } @@ -256,8 +253,7 @@ AHFloat BounceEaseOut(AHFloat p) } else if (p < 8 / 11.0) { return (363 / 40.0f * p * p) - (99 / 10.0f * p) + 17 / 5.0f; } else if (p < 9 / 10.0) { - return (4356 / 361.0f * p * p) - (35442 / 1805.0f * p) + - 16061 / 1805.0f; + return (4356 / 361.0f * p * p) - (35442 / 1805.0f * p) + 16061 / 1805.0f; } else { return (54 / 5.0f * p * p) - (513 / 25.0f * p) + 268 / 25.0f; } diff --git a/move-action-filter.c b/move-action-filter.c index a9b9fcc..e8cef9c 100644 --- a/move-action-filter.c +++ b/move-action-filter.c @@ -8,6 +8,7 @@ #define MOVE_ACTION_FILTER_ENABLE 4 #define MOVE_ACTION_FRONTEND_HOTKEY 5 #define MOVE_ACTION_SOURCE_MUTE 6 +#define MOVE_ACTION_SOURCE_AUDIO_TRACK 7 #define MOVE_ACTION_ENABLE 0 #define MOVE_ACTION_DISABLE 1 @@ -27,6 +28,7 @@ struct move_action_info { long long frontend_action; long long enable; + long long audio_track; bool start; }; @@ -37,22 +39,19 @@ bool move_action_load_hotkey(void *data, obs_hotkey_id id, obs_hotkey_t *key) if (strcmp(move_action->hotkey_name, obs_hotkey_get_name(key)) != 0) return true; obs_hotkey_registerer_t type = obs_hotkey_get_registerer_type(key); - if (type == OBS_HOTKEY_REGISTERER_SOURCE && - move_action->action == MOVE_ACTION_SOURCE_HOTKEY) { + if (type == OBS_HOTKEY_REGISTERER_SOURCE && move_action->action == MOVE_ACTION_SOURCE_HOTKEY) { obs_weak_source_t *s = obs_hotkey_get_registerer(key); obs_source_t *source = obs_weak_source_get_source(s); if (source) { - if (strcmp(obs_source_get_name(source), - move_action->source_name) == 0) { + if (strcmp(obs_source_get_name(source), move_action->source_name) == 0) { move_action->hotkey_id = id; obs_source_release(source); return false; } obs_source_release(source); } - } else if (type == OBS_HOTKEY_REGISTERER_FRONTEND && - move_action->action == MOVE_ACTION_FRONTEND_HOTKEY) { + } else if (type == OBS_HOTKEY_REGISTERER_FRONTEND && move_action->action == MOVE_ACTION_FRONTEND_HOTKEY) { move_action->hotkey_id = id; return false; } @@ -65,8 +64,8 @@ void move_action_update(void *data, obs_data_t *settings) move_filter_update(&move_action->move_filter, settings); bool changed = false; - move_action->frontend_action = - obs_data_get_int(settings, "frontend_action"); + move_action->frontend_action = obs_data_get_int(settings, "frontend_action"); + move_action->audio_track = obs_data_get_int(settings, "audio_track"); const char *hotkey_name = obs_data_get_string(settings, "hotkey"); long long action = obs_data_get_int(settings, "action"); if (action == MOVE_ACTION_NONE && move_action->frontend_action != 0) { @@ -83,13 +82,10 @@ void move_action_update(void *data, obs_data_t *settings) changed = true; } - if (action == MOVE_ACTION_SOURCE_HOTKEY || - action == MOVE_ACTION_FILTER_ENABLE || - action == MOVE_ACTION_SOURCE_MUTE) { - const char *source_name = - obs_data_get_string(settings, "source"); - if (!move_action->source_name || - strcmp(source_name, move_action->source_name) != 0) { + if (action == MOVE_ACTION_SOURCE_HOTKEY || action == MOVE_ACTION_FILTER_ENABLE || action == MOVE_ACTION_SOURCE_MUTE || + action == MOVE_ACTION_SOURCE_AUDIO_TRACK) { + const char *source_name = obs_data_get_string(settings, "source"); + if (!move_action->source_name || strcmp(source_name, move_action->source_name) != 0) { bfree(move_action->source_name); move_action->source_name = bstrdup(source_name); changed = true; @@ -100,10 +96,8 @@ void move_action_update(void *data, obs_data_t *settings) changed = true; } - if (action == MOVE_ACTION_SOURCE_HOTKEY || - action == MOVE_ACTION_FRONTEND_HOTKEY) { - if (!move_action->hotkey_name || - strcmp(hotkey_name, move_action->hotkey_name) != 0) { + if (action == MOVE_ACTION_SOURCE_HOTKEY || action == MOVE_ACTION_FRONTEND_HOTKEY) { + if (!move_action->hotkey_name || strcmp(hotkey_name, move_action->hotkey_name) != 0) { bfree(move_action->hotkey_name); move_action->hotkey_name = bstrdup(hotkey_name); changed = true; @@ -115,24 +109,18 @@ void move_action_update(void *data, obs_data_t *settings) } if (changed) { move_action->hotkey_id = OBS_INVALID_HOTKEY_ID; - if (move_action->hotkey_name && - strlen(move_action->hotkey_name)) { - if (move_action->action == MOVE_ACTION_SOURCE_HOTKEY && - move_action->source_name && + if (move_action->hotkey_name && strlen(move_action->hotkey_name)) { + if (move_action->action == MOVE_ACTION_SOURCE_HOTKEY && move_action->source_name && strlen(move_action->source_name)) - obs_enum_hotkeys(move_action_load_hotkey, - move_action); + obs_enum_hotkeys(move_action_load_hotkey, move_action); else if (action == MOVE_ACTION_FRONTEND_HOTKEY) - obs_enum_hotkeys(move_action_load_hotkey, - move_action); + obs_enum_hotkeys(move_action_load_hotkey, move_action); } } if (action == MOVE_ACTION_FILTER_ENABLE) { - const char *filter_name = - obs_data_get_string(settings, "filter"); - if (!move_action->filter_name || - strcmp(filter_name, move_action->filter_name) != 0) { + const char *filter_name = obs_data_get_string(settings, "filter"); + if (!move_action->filter_name || strcmp(filter_name, move_action->filter_name) != 0) { bfree(move_action->filter_name); move_action->filter_name = bstrdup(filter_name); } @@ -143,8 +131,7 @@ void move_action_update(void *data, obs_data_t *settings) if (action == MOVE_ACTION_SOURCE_VISIBILITY) { const char *scene_name = obs_data_get_string(settings, "scene"); - if (!move_action->scene_name || - strcmp(scene_name, move_action->scene_name) != 0) { + if (!move_action->scene_name || strcmp(scene_name, move_action->scene_name) != 0) { bfree(move_action->scene_name); move_action->scene_name = bstrdup(scene_name); } @@ -154,10 +141,8 @@ void move_action_update(void *data, obs_data_t *settings) } if (action == MOVE_ACTION_SOURCE_VISIBILITY) { - const char *sceneitem_name = - obs_data_get_string(settings, "sceneitem"); - if (!move_action->sceneitem_name || - strcmp(sceneitem_name, move_action->sceneitem_name) != 0) { + const char *sceneitem_name = obs_data_get_string(settings, "sceneitem"); + if (!move_action->sceneitem_name || strcmp(sceneitem_name, move_action->sceneitem_name) != 0) { bfree(move_action->sceneitem_name); move_action->sceneitem_name = bstrdup(sceneitem_name); } @@ -187,8 +172,7 @@ void move_action_start(void *data) static void *move_action_create(obs_data_t *settings, obs_source_t *source) { - struct move_action_info *move_action = - bzalloc(sizeof(struct move_action_info)); + struct move_action_info *move_action = bzalloc(sizeof(struct move_action_info)); move_filter_init(&move_action->move_filter, source, move_action_start); move_action->hotkey_id = OBS_INVALID_HOTKEY_ID; move_action_update(move_action, settings); @@ -224,10 +208,7 @@ static bool add_source_hotkeys(void *data, obs_hotkey_id id, obs_hotkey_t *key) if (type == OBS_HOTKEY_REGISTERER_SOURCE) { obs_weak_source_t *s = obs_hotkey_get_registerer(key); if (s == hd->source) { - obs_property_list_add_string( - hd->hotkey_prop, - obs_hotkey_get_description(key), - obs_hotkey_get_name(key)); + obs_property_list_add_string(hd->hotkey_prop, obs_hotkey_get_description(key), obs_hotkey_get_name(key)); } } return true; @@ -239,15 +220,12 @@ static bool add_global_hotkeys(void *data, obs_hotkey_id id, obs_hotkey_t *key) obs_property_t *prop = data; obs_hotkey_registerer_t type = obs_hotkey_get_registerer_type(key); if (type == OBS_HOTKEY_REGISTERER_FRONTEND) { - obs_property_list_add_string(prop, - obs_hotkey_get_description(key), - obs_hotkey_get_name(key)); + obs_property_list_add_string(prop, obs_hotkey_get_description(key), obs_hotkey_get_name(key)); } return true; } -static void add_filter_to_prop_list(obs_source_t *parent, obs_source_t *child, - void *data) +static void add_filter_to_prop_list(obs_source_t *parent, obs_source_t *child, void *data) { UNUSED_PARAMETER(parent); obs_property_t *p = (obs_property_t *)data; @@ -256,9 +234,7 @@ static void add_filter_to_prop_list(obs_source_t *parent, obs_source_t *child, obs_property_list_add_string(p, name, name); } -static bool move_action_source_changed(void *data, obs_properties_t *props, - obs_property_t *property, - obs_data_t *settings) +static bool move_action_source_changed(void *data, obs_properties_t *props, obs_property_t *property, obs_data_t *settings) { UNUSED_PARAMETER(data); UNUSED_PARAMETER(property); @@ -290,8 +266,7 @@ static bool add_source_to_prop_list(void *data, obs_source_t *source) return true; size_t count = obs_property_list_item_count(p); size_t idx = 0; - while (idx < count && - strcmp(name, obs_property_list_item_string(p, idx)) > 0) + while (idx < count && strcmp(name, obs_property_list_item_string(p, idx)) > 0) idx++; obs_property_list_insert_string(p, idx, name, name); return true; @@ -307,16 +282,13 @@ static bool add_group_to_prop_list(void *data, obs_source_t *source) return true; size_t count = obs_property_list_item_count(p); size_t idx = 0; - while (idx < count && - strcmp(name, obs_property_list_item_string(p, idx)) > 0) + while (idx < count && strcmp(name, obs_property_list_item_string(p, idx)) > 0) idx++; obs_property_list_insert_string(p, idx, name, name); return true; } -static bool move_action_action_changed(obs_properties_t *props, - obs_property_t *property, - obs_data_t *settings) +static bool move_action_action_changed(obs_properties_t *props, obs_property_t *property, obs_data_t *settings) { UNUSED_PARAMETER(property); long long action = obs_data_get_int(settings, "action"); @@ -335,45 +307,38 @@ static bool move_action_action_changed(obs_properties_t *props, obs_property_t *source = obs_properties_get(props, "source"); obs_property_t *filter = obs_properties_get(props, "filter"); obs_property_t *hotkey = obs_properties_get(props, "hotkey"); - if (action == MOVE_ACTION_FILTER_ENABLE || - action == MOVE_ACTION_SOURCE_HOTKEY || - action == MOVE_ACTION_SOURCE_MUTE) { + if (action == MOVE_ACTION_FILTER_ENABLE || action == MOVE_ACTION_SOURCE_HOTKEY || action == MOVE_ACTION_SOURCE_MUTE || + action == MOVE_ACTION_SOURCE_AUDIO_TRACK) { obs_property_list_clear(source); obs_enum_sources(add_source_to_prop_list, source); obs_enum_scenes(add_source_to_prop_list, source); obs_property_set_visible(source, true); - obs_property_set_visible(filter, - action == MOVE_ACTION_FILTER_ENABLE); - obs_property_set_visible(hotkey, - action == MOVE_ACTION_SOURCE_HOTKEY); + obs_property_set_visible(filter, action == MOVE_ACTION_FILTER_ENABLE); + obs_property_set_visible(hotkey, action == MOVE_ACTION_SOURCE_HOTKEY); } else { obs_property_set_visible(source, false); obs_property_set_visible(filter, false); - obs_property_set_visible(hotkey, - action == MOVE_ACTION_FRONTEND_HOTKEY); + obs_property_set_visible(hotkey, action == MOVE_ACTION_FRONTEND_HOTKEY); } + obs_property_t *audio_track = obs_properties_get(props, "audio_track"); + obs_property_set_visible(audio_track, action == MOVE_ACTION_SOURCE_AUDIO_TRACK); if (action == MOVE_ACTION_FRONTEND_HOTKEY) { obs_property_list_clear(hotkey); obs_property_list_add_string(hotkey, "", ""); obs_enum_hotkeys(add_global_hotkeys, hotkey); } - obs_property_t *frontend_action = - obs_properties_get(props, "frontend_action"); - obs_property_set_visible(frontend_action, - action == MOVE_ACTION_FRONTEND); + obs_property_t *frontend_action = obs_properties_get(props, "frontend_action"); + obs_property_set_visible(frontend_action, action == MOVE_ACTION_FRONTEND); obs_property_t *enable = obs_properties_get(props, "enable"); - obs_property_set_visible( - enable, action == MOVE_ACTION_FILTER_ENABLE || - action == MOVE_ACTION_SOURCE_VISIBILITY || - action == MOVE_ACTION_SOURCE_MUTE); + obs_property_set_visible(enable, action == MOVE_ACTION_FILTER_ENABLE || action == MOVE_ACTION_SOURCE_VISIBILITY || + action == MOVE_ACTION_SOURCE_MUTE || action == MOVE_ACTION_SOURCE_AUDIO_TRACK); return true; } -static bool add_sceneitem_to_prop_list(obs_scene_t *scene, - obs_sceneitem_t *item, void *data) +static bool add_sceneitem_to_prop_list(obs_scene_t *scene, obs_sceneitem_t *item, void *data) { UNUSED_PARAMETER(scene); obs_property_t *p = (obs_property_t *)data; @@ -384,9 +349,7 @@ static bool add_sceneitem_to_prop_list(obs_scene_t *scene, return true; } -static bool move_action_scene_changed(void *data, obs_properties_t *props, - obs_property_t *property, - obs_data_t *settings) +static bool move_action_scene_changed(void *data, obs_properties_t *props, obs_property_t *property, obs_data_t *settings) { UNUSED_PARAMETER(data); UNUSED_PARAMETER(property); @@ -408,94 +371,65 @@ static obs_properties_t *move_action_properties(void *data) { obs_properties_t *ppts = obs_properties_create(); - obs_property_t *p = obs_properties_add_list(ppts, "action", - obs_module_text("Action"), - OBS_COMBO_TYPE_LIST, - OBS_COMBO_FORMAT_INT); - obs_property_list_add_int(p, obs_module_text("FrontendAction"), - MOVE_ACTION_FRONTEND); - - obs_property_list_add_int(p, obs_module_text("SourceVisibility"), - MOVE_ACTION_SOURCE_VISIBILITY); - obs_property_list_add_int(p, obs_module_text("SourceMute"), - MOVE_ACTION_SOURCE_MUTE); - obs_property_list_add_int(p, obs_module_text("SourceHotkey"), - MOVE_ACTION_SOURCE_HOTKEY); - obs_property_list_add_int(p, obs_module_text("FilterEnable"), - MOVE_ACTION_FILTER_ENABLE); - obs_property_list_add_int(p, obs_module_text("FrontendHotkey"), - MOVE_ACTION_FRONTEND_HOTKEY); + obs_property_t *p = + obs_properties_add_list(ppts, "action", obs_module_text("Action"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); + obs_property_list_add_int(p, obs_module_text("FrontendAction"), MOVE_ACTION_FRONTEND); + + obs_property_list_add_int(p, obs_module_text("SourceVisibility"), MOVE_ACTION_SOURCE_VISIBILITY); + obs_property_list_add_int(p, obs_module_text("SourceMute"), MOVE_ACTION_SOURCE_MUTE); + obs_property_list_add_int(p, obs_module_text("SourceAudioTrack"), MOVE_ACTION_SOURCE_AUDIO_TRACK); + obs_property_list_add_int(p, obs_module_text("SourceHotkey"), MOVE_ACTION_SOURCE_HOTKEY); + obs_property_list_add_int(p, obs_module_text("FilterEnable"), MOVE_ACTION_FILTER_ENABLE); + obs_property_list_add_int(p, obs_module_text("FrontendHotkey"), MOVE_ACTION_FRONTEND_HOTKEY); obs_property_set_modified_callback(p, move_action_action_changed); - p = obs_properties_add_list(ppts, "scene", obs_module_text("Scene"), - OBS_COMBO_TYPE_EDITABLE, - OBS_COMBO_FORMAT_STRING); + p = obs_properties_add_list(ppts, "scene", obs_module_text("Scene"), OBS_COMBO_TYPE_EDITABLE, OBS_COMBO_FORMAT_STRING); obs_property_set_modified_callback2(p, move_action_scene_changed, data); - p = obs_properties_add_list(ppts, "sceneitem", - obs_module_text("Source"), - OBS_COMBO_TYPE_EDITABLE, - OBS_COMBO_FORMAT_STRING); - - p = obs_properties_add_list(ppts, "source", obs_module_text("Source"), - OBS_COMBO_TYPE_EDITABLE, - OBS_COMBO_FORMAT_STRING); - - obs_property_set_modified_callback2(p, move_action_source_changed, - data); - - p = obs_properties_add_list(ppts, "filter", obs_module_text("Filter"), - OBS_COMBO_TYPE_EDITABLE, - OBS_COMBO_FORMAT_STRING); - - obs_property_set_modified_callback2(p, move_action_source_changed, - data); - - p = obs_properties_add_list(ppts, "enable", obs_module_text("Enable"), - OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); - obs_property_list_add_int(p, obs_module_text("Enable"), - MOVE_ACTION_ENABLE); - obs_property_list_add_int(p, obs_module_text("Disable"), - MOVE_ACTION_DISABLE); - obs_property_list_add_int(p, obs_module_text("Toggle"), - MOVE_ACTION_TOGGLE); - - p = obs_properties_add_list(ppts, "hotkey", obs_module_text("Hotkey"), - OBS_COMBO_TYPE_LIST, - OBS_COMBO_FORMAT_STRING); - - p = obs_properties_add_list(ppts, "frontend_action", - obs_module_text("FrontendAction"), - OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); + p = obs_properties_add_list(ppts, "sceneitem", obs_module_text("Source"), OBS_COMBO_TYPE_EDITABLE, OBS_COMBO_FORMAT_STRING); + + p = obs_properties_add_list(ppts, "source", obs_module_text("Source"), OBS_COMBO_TYPE_EDITABLE, OBS_COMBO_FORMAT_STRING); + + obs_property_set_modified_callback2(p, move_action_source_changed, data); + + p = obs_properties_add_list(ppts, "filter", obs_module_text("Filter"), OBS_COMBO_TYPE_EDITABLE, OBS_COMBO_FORMAT_STRING); + + obs_property_set_modified_callback2(p, move_action_source_changed, data); + + p = obs_properties_add_list(ppts, "audio_track", obs_module_text("AudioTrack"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); + obs_property_list_add_int(p, obs_module_text("AudioTrack.None"), 0); + obs_property_list_add_int(p, obs_module_text("AudioTrack.All"), -1); + obs_property_list_add_int(p, obs_module_text("AudioTrack.Track1"), 1); + obs_property_list_add_int(p, obs_module_text("AudioTrack.Track2"), 2); + obs_property_list_add_int(p, obs_module_text("AudioTrack.Track3"), 3); + obs_property_list_add_int(p, obs_module_text("AudioTrack.Track4"), 4); + obs_property_list_add_int(p, obs_module_text("AudioTrack.Track5"), 5); + obs_property_list_add_int(p, obs_module_text("AudioTrack.Track6"), 6); + + p = obs_properties_add_list(ppts, "enable", obs_module_text("Enable"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); + obs_property_list_add_int(p, obs_module_text("Enable"), MOVE_ACTION_ENABLE); + obs_property_list_add_int(p, obs_module_text("Disable"), MOVE_ACTION_DISABLE); + obs_property_list_add_int(p, obs_module_text("Toggle"), MOVE_ACTION_TOGGLE); + + p = obs_properties_add_list(ppts, "hotkey", obs_module_text("Hotkey"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING); + + p = obs_properties_add_list(ppts, "frontend_action", obs_module_text("FrontendAction"), OBS_COMBO_TYPE_LIST, + OBS_COMBO_FORMAT_INT); obs_property_list_add_int(p, obs_module_text("FrontendAction.None"), 0); - obs_property_list_add_int( - p, obs_module_text("FrontendAction.StreamingStart"), 1); - obs_property_list_add_int( - p, obs_module_text("FrontendAction.StreamingStop"), 2); - obs_property_list_add_int( - p, obs_module_text("FrontendAction.RecordingStart"), 3); - obs_property_list_add_int( - p, obs_module_text("FrontendAction.RecordingStop"), 4); - obs_property_list_add_int( - p, obs_module_text("FrontendAction.RecordingPause"), 5); - obs_property_list_add_int( - p, obs_module_text("FrontendAction.RecordingUnpause"), 6); - obs_property_list_add_int( - p, obs_module_text("FrontendAction.VirtualCamStart"), 7); - obs_property_list_add_int( - p, obs_module_text("FrontendAction.VirtualCamStop"), 8); - obs_property_list_add_int( - p, obs_module_text("FrontendAction.ReplayBufferStart"), 9); - obs_property_list_add_int( - p, obs_module_text("FrontendAction.ReplayBufferStop"), 10); - obs_property_list_add_int( - p, obs_module_text("FrontendAction.ReplayBufferSave"), 11); - obs_property_list_add_int( - p, obs_module_text("FrontendAction.StudioModeEnable"), 12); - obs_property_list_add_int( - p, obs_module_text("FrontendAction.StudioModeDisable"), 13); - obs_property_list_add_int( - p, obs_module_text("FrontendAction.TakeScreenshot"), 14); + obs_property_list_add_int(p, obs_module_text("FrontendAction.StreamingStart"), 1); + obs_property_list_add_int(p, obs_module_text("FrontendAction.StreamingStop"), 2); + obs_property_list_add_int(p, obs_module_text("FrontendAction.RecordingStart"), 3); + obs_property_list_add_int(p, obs_module_text("FrontendAction.RecordingStop"), 4); + obs_property_list_add_int(p, obs_module_text("FrontendAction.RecordingPause"), 5); + obs_property_list_add_int(p, obs_module_text("FrontendAction.RecordingUnpause"), 6); + obs_property_list_add_int(p, obs_module_text("FrontendAction.VirtualCamStart"), 7); + obs_property_list_add_int(p, obs_module_text("FrontendAction.VirtualCamStop"), 8); + obs_property_list_add_int(p, obs_module_text("FrontendAction.ReplayBufferStart"), 9); + obs_property_list_add_int(p, obs_module_text("FrontendAction.ReplayBufferStop"), 10); + obs_property_list_add_int(p, obs_module_text("FrontendAction.ReplayBufferSave"), 11); + obs_property_list_add_int(p, obs_module_text("FrontendAction.StudioModeEnable"), 12); + obs_property_list_add_int(p, obs_module_text("FrontendAction.StudioModeDisable"), 13); + obs_property_list_add_int(p, obs_module_text("FrontendAction.TakeScreenshot"), 14); //obs_frontend_preview_program_trigger_transition @@ -511,27 +445,19 @@ void move_action_execute(void *data) { struct move_action_info *move_action = data; if (move_action->action == MOVE_ACTION_SOURCE_HOTKEY) { - if (move_action->hotkey_id == OBS_INVALID_HOTKEY_ID && - move_action->hotkey_name && - strlen(move_action->hotkey_name) && - move_action->source_name && - strlen(move_action->source_name)) { + if (move_action->hotkey_id == OBS_INVALID_HOTKEY_ID && move_action->hotkey_name && + strlen(move_action->hotkey_name) && move_action->source_name && strlen(move_action->source_name)) { obs_enum_hotkeys(move_action_load_hotkey, move_action); } if (move_action->hotkey_id != OBS_INVALID_HOTKEY_ID) - obs_hotkey_trigger_routed_callback( - move_action->hotkey_id, - !move_action->move_filter.reverse); + obs_hotkey_trigger_routed_callback(move_action->hotkey_id, !move_action->move_filter.reverse); } else if (move_action->action == MOVE_ACTION_FRONTEND_HOTKEY) { - if (move_action->hotkey_id == OBS_INVALID_HOTKEY_ID && - move_action->hotkey_name && + if (move_action->hotkey_id == OBS_INVALID_HOTKEY_ID && move_action->hotkey_name && strlen(move_action->hotkey_name)) { obs_enum_hotkeys(move_action_load_hotkey, move_action); } if (move_action->hotkey_id != OBS_INVALID_HOTKEY_ID) - obs_hotkey_trigger_routed_callback( - move_action->hotkey_id, - !move_action->move_filter.reverse); + obs_hotkey_trigger_routed_callback(move_action->hotkey_id, !move_action->move_filter.reverse); } else if (move_action->action == MOVE_ACTION_FRONTEND) { if (move_action->frontend_action == 1) { obs_frontend_streaming_start(); @@ -563,89 +489,104 @@ void move_action_execute(void *data) obs_frontend_take_screenshot(); } } else if (move_action->action == MOVE_ACTION_SOURCE_VISIBILITY) { - if (move_action->scene_name && move_action->sceneitem_name && - strlen(move_action->scene_name) && + if (move_action->scene_name && move_action->sceneitem_name && strlen(move_action->scene_name) && strlen(move_action->sceneitem_name)) { - obs_source_t *scene_source = - obs_get_source_by_name(move_action->scene_name); - obs_scene_t *scene = - obs_scene_from_source(scene_source); + obs_source_t *scene_source = obs_get_source_by_name(move_action->scene_name); + obs_scene_t *scene = obs_scene_from_source(scene_source); if (!scene) scene = obs_group_from_source(scene_source); - obs_sceneitem_t *item = obs_scene_find_source_recursive( - scene, move_action->sceneitem_name); + obs_sceneitem_t *item = obs_scene_find_source_recursive(scene, move_action->sceneitem_name); if (item) { if (move_action->enable == MOVE_ACTION_TOGGLE) { - obs_sceneitem_set_visible( - item, - !obs_sceneitem_visible(item)); - } else if (move_action->enable == - MOVE_ACTION_ENABLE) { + obs_sceneitem_set_visible(item, !obs_sceneitem_visible(item)); + } else if (move_action->enable == MOVE_ACTION_ENABLE) { if (!obs_sceneitem_visible(item)) - obs_sceneitem_set_visible(item, - true); - } else if (move_action->enable == - MOVE_ACTION_DISABLE) { + obs_sceneitem_set_visible(item, true); + } else if (move_action->enable == MOVE_ACTION_DISABLE) { if (obs_sceneitem_visible(item)) - obs_sceneitem_set_visible( - item, false); + obs_sceneitem_set_visible(item, false); } } obs_source_release(scene_source); } } else if (move_action->action == MOVE_ACTION_FILTER_ENABLE) { - if (move_action->source_name && move_action->filter_name && - strlen(move_action->source_name) && + if (move_action->source_name && move_action->filter_name && strlen(move_action->source_name) && strlen(move_action->filter_name)) { - obs_source_t *source = obs_get_source_by_name( - move_action->source_name); - obs_source_t *filter = - source ? obs_source_get_filter_by_name( - source, - move_action->filter_name) - : NULL; + obs_source_t *source = obs_get_source_by_name(move_action->source_name); + obs_source_t *filter = source ? obs_source_get_filter_by_name(source, move_action->filter_name) : NULL; if (filter) { if (move_action->enable == MOVE_ACTION_TOGGLE) { - obs_source_set_enabled( - filter, - !obs_source_enabled(filter)); - } else if (move_action->enable == - MOVE_ACTION_ENABLE) { + obs_source_set_enabled(filter, !obs_source_enabled(filter)); + } else if (move_action->enable == MOVE_ACTION_ENABLE) { if (!obs_source_enabled(filter)) - obs_source_set_enabled(filter, - true); - } else if (move_action->enable == - MOVE_ACTION_DISABLE) { + obs_source_set_enabled(filter, true); + } else if (move_action->enable == MOVE_ACTION_DISABLE) { if (obs_source_enabled(filter)) - obs_source_set_enabled(filter, - false); + obs_source_set_enabled(filter, false); } obs_source_release(filter); } obs_source_release(source); } } else if (move_action->action == MOVE_ACTION_SOURCE_MUTE) { - if (move_action->source_name && - strlen(move_action->source_name)) { - obs_source_t *source = obs_get_source_by_name( - move_action->source_name); + if (move_action->source_name && strlen(move_action->source_name)) { + obs_source_t *source = obs_get_source_by_name(move_action->source_name); if (source) { if (move_action->enable == MOVE_ACTION_TOGGLE) { - obs_source_set_muted( - source, - !obs_source_muted(source)); - } else if (move_action->enable == - MOVE_ACTION_ENABLE) { + obs_source_set_muted(source, !obs_source_muted(source)); + } else if (move_action->enable == MOVE_ACTION_ENABLE) { if (!obs_source_muted(source)) - obs_source_set_muted(source, - true); - } else if (move_action->enable == - MOVE_ACTION_DISABLE) { + obs_source_set_muted(source, true); + } else if (move_action->enable == MOVE_ACTION_DISABLE) { if (obs_source_muted(source)) - obs_source_set_muted(source, - false); + obs_source_set_muted(source, false); + } + obs_source_release(source); + } + } + } else if (move_action->action == MOVE_ACTION_SOURCE_AUDIO_TRACK) { + if (move_action->audio_track != 0 && move_action->source_name && strlen(move_action->source_name)) { + obs_source_t *source = obs_get_source_by_name(move_action->source_name); + if (source) { + uint32_t mixers = obs_source_get_audio_mixers(source); + if (move_action->audio_track < 0) { + uint32_t map = 0x3f; + if (move_action->enable == MOVE_ACTION_TOGGLE) { + mixers ^= map; + obs_source_set_audio_mixers(source, mixers); + } else if (move_action->enable == MOVE_ACTION_ENABLE) { + if (mixers != map) { + mixers = map; + obs_source_set_audio_mixers(source, mixers); + } + } else if (move_action->enable == MOVE_ACTION_DISABLE) { + if (mixers) { + mixers = 0; + obs_source_set_audio_mixers(source, mixers); + } + } + } else { + uint32_t map = (1 << (move_action->audio_track - 1)); + if (move_action->enable == MOVE_ACTION_TOGGLE) { + if (mixers & map) { + mixers -= map; + } else { + mixers += map; + } + obs_source_set_audio_mixers(source, mixers); + } else if (move_action->enable == MOVE_ACTION_ENABLE) { + if (!(mixers & map)) { + mixers += map; + obs_source_set_audio_mixers(source, mixers); + } + } else if (move_action->enable == MOVE_ACTION_DISABLE) { + if (mixers & map) { + mixers -= map; + obs_source_set_audio_mixers(source, mixers); + } + } } obs_source_release(source); } @@ -656,8 +597,7 @@ void move_action_execute(void *data) void move_action_hotkey_end(void *data) { struct move_action_info *move_action = data; - obs_hotkey_trigger_routed_callback(move_action->hotkey_id, - move_action->move_filter.reverse); + obs_hotkey_trigger_routed_callback(move_action->hotkey_id, move_action->move_filter.reverse); } void move_action_tick(void *data, float seconds) @@ -672,11 +612,9 @@ void move_action_tick(void *data, float seconds) } if (!move_action->move_filter.moving) { - if ((move_action->action == MOVE_ACTION_SOURCE_HOTKEY || - move_action->action == MOVE_ACTION_FRONTEND_HOTKEY) && + if ((move_action->action == MOVE_ACTION_SOURCE_HOTKEY || move_action->action == MOVE_ACTION_FRONTEND_HOTKEY) && move_action->hotkey_id != OBS_INVALID_HOTKEY_ID) - obs_queue_task(OBS_TASK_UI, move_action_hotkey_end, - data, false); + obs_queue_task(OBS_TASK_UI, move_action_hotkey_end, data, false); move_filter_ended(&move_action->move_filter); } } diff --git a/move-directshow-filter.cpp b/move-directshow-filter.cpp index 5d37fc9..0b75b41 100644 --- a/move-directshow-filter.cpp +++ b/move-directshow-filter.cpp @@ -70,17 +70,14 @@ void LoadDevice(struct move_directshow_info *move_directshow) return; ICreateDevEnum *deviceEnum; - HRESULT hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, - CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, - (void **)&deviceEnum); + HRESULT hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, (void **)&deviceEnum); if (FAILED(hr)) { //WarningHR(L"GetFilterByMedium: Failed to create device enum", hr); return; } IEnumMoniker *enumMoniker; - hr = deviceEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, - &enumMoniker, 0); + hr = deviceEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, &enumMoniker, 0); if (hr != S_OK) { deviceEnum->Release(); //WarningHR(L"GetFilterByMedium: Failed to create enum moniker", hr); @@ -91,8 +88,7 @@ void LoadDevice(struct move_directshow_info *move_directshow) while (enumMoniker->Next(1, &deviceInfo, &count) == S_OK) { IPropertyBag *propertyData; - hr = deviceInfo->BindToStorage(0, 0, IID_IPropertyBag, - (void **)&propertyData); + hr = deviceInfo->BindToStorage(0, 0, IID_IPropertyBag, (void **)&propertyData); if (hr == S_OK) { VARIANT deviceName, devicePath; deviceName.vt = VT_BSTR; @@ -100,14 +96,12 @@ void LoadDevice(struct move_directshow_info *move_directshow) devicePath.bstrVal = nullptr; DStr name; - hr = propertyData->Read(L"FriendlyName", &deviceName, - nullptr); + hr = propertyData->Read(L"FriendlyName", &deviceName, nullptr); if (hr == S_OK) { dstr_from_wcs(name, deviceName.bstrVal); } DStr path; - hr = propertyData->Read(L"DevicePath", &devicePath, - nullptr); + hr = propertyData->Read(L"DevicePath", &devicePath, nullptr); if (hr == S_OK && devicePath.bstrVal != nullptr) { dstr_from_wcs(path, devicePath.bstrVal); @@ -133,21 +127,17 @@ void LoadDevice(struct move_directshow_info *move_directshow) return; IBaseFilter *filter; - hr = deviceInfo->BindToObject(nullptr, 0, IID_IBaseFilter, - (void **)&filter); + hr = deviceInfo->BindToObject(nullptr, 0, IID_IBaseFilter, (void **)&filter); deviceInfo->Release(); if (hr != S_OK) return; - filter->QueryInterface(IID_IAMCameraControl, - (void **)&move_directshow->camControl); - filter->QueryInterface(IID_IAMVideoProcAmp, - (void **)&move_directshow->procAmp); + filter->QueryInterface(IID_IAMCameraControl, (void **)&move_directshow->camControl); + filter->QueryInterface(IID_IAMVideoProcAmp, (void **)&move_directshow->procAmp); filter->Release(); } -void LoadProperties(move_directshow_info *move_directshow, obs_data_t *settings, - bool overwrite) +void LoadProperties(move_directshow_info *move_directshow, obs_data_t *settings, bool overwrite) { pthread_mutex_lock(&move_directshow->mutex); if (move_directshow->camControl) { @@ -160,45 +150,32 @@ void LoadProperties(move_directshow_info *move_directshow, obs_data_t *settings, prop_enabled += "_enabled"; auto m = move_directshow->camControlProps->find(i); - if (!obs_data_get_bool(settings, - prop_enabled.c_str())) { - if (m != - move_directshow->camControlProps->end()) - move_directshow->camControlProps->erase( - m); + if (!obs_data_get_bool(settings, prop_enabled.c_str())) { + if (m != move_directshow->camControlProps->end()) + move_directshow->camControlProps->erase(m); continue; } long val, flags; - HRESULT hr = move_directshow->camControl->Get(i, &val, - &flags); + HRESULT hr = move_directshow->camControl->Get(i, &val, &flags); if (hr == S_OK) { - if (m == - move_directshow->camControlProps->end()) { + if (m == move_directshow->camControlProps->end()) { struct directshow_property p; p.int_from = val; if (settings) { - p.int_to = - (long)obs_data_get_int( - settings, - prop_id.c_str()); + p.int_to = (long)obs_data_get_int(settings, prop_id.c_str()); } else { p.int_to = val; } - move_directshow->camControlProps - ->emplace(i, p); + move_directshow->camControlProps->emplace(i, p); } else { if (overwrite) m->second.int_from = val; if (settings) { - m->second.int_to = - (long)obs_data_get_int( - settings, - prop_id.c_str()); + m->second.int_to = (long)obs_data_get_int(settings, prop_id.c_str()); } } - } else if (m != - move_directshow->camControlProps->end()) { + } else if (m != move_directshow->camControlProps->end()) { move_directshow->camControlProps->erase(m); } } @@ -214,40 +191,31 @@ void LoadProperties(move_directshow_info *move_directshow, obs_data_t *settings, auto m = move_directshow->procAmpProps->find(i); - if (!obs_data_get_bool(settings, - prop_enabled.c_str())) { + if (!obs_data_get_bool(settings, prop_enabled.c_str())) { if (m != move_directshow->procAmpProps->end()) move_directshow->procAmpProps->erase(m); continue; } long val, flags; - HRESULT hr = - move_directshow->procAmp->Get(i, &val, &flags); + HRESULT hr = move_directshow->procAmp->Get(i, &val, &flags); if (hr == S_OK) { if (m == move_directshow->procAmpProps->end()) { struct directshow_property p; p.int_from = val; if (settings) { - p.int_to = - (long)obs_data_get_int( - settings, - prop_id.c_str()); + p.int_to = (long)obs_data_get_int(settings, prop_id.c_str()); } else { p.int_to = val; } - move_directshow->procAmpProps->emplace( - i, p); + move_directshow->procAmpProps->emplace(i, p); } else { if (overwrite) m->second.int_from = val; if (settings) { - m->second.int_to = - (long)obs_data_get_int( - settings, - prop_id.c_str()); + m->second.int_to = (long)obs_data_get_int(settings, prop_id.c_str()); } } } else if (m != move_directshow->procAmpProps->end()) { @@ -260,35 +228,26 @@ void LoadProperties(move_directshow_info *move_directshow, obs_data_t *settings, void move_directshow_update(void *data, obs_data_t *settings) { - struct move_directshow_info *move_directshow = - (struct move_directshow_info *)data; + struct move_directshow_info *move_directshow = (struct move_directshow_info *)data; move_filter_update(&move_directshow->move_filter, settings); auto device = obs_data_get_string(settings, "device"); - if (!move_directshow->device || - strcmp(move_directshow->device, device) != 0) { + if (!move_directshow->device || strcmp(move_directshow->device, device) != 0) { bfree(move_directshow->device); move_directshow->device = bstrdup(device); LoadDevice(move_directshow); } - move_directshow->move_value_type = - (int)obs_data_get_int(settings, S_MOVE_VALUE_TYPE); + move_directshow->move_value_type = (int)obs_data_get_int(settings, S_MOVE_VALUE_TYPE); if (move_directshow->move_value_type == MOVE_VALUE_TYPE_SETTINGS) { LoadProperties(move_directshow, settings, false); } else { - move_directshow->int_value = - (long)obs_data_get_int(settings, S_SETTING_INT); - move_directshow->int_min = - (long)obs_data_get_int(settings, S_SETTING_INT_MIN); - move_directshow->int_max = - (long)obs_data_get_int(settings, S_SETTING_INT_MAX); - auto single_setting_name = - obs_data_get_string(settings, S_SETTING_NAME); + move_directshow->int_value = (long)obs_data_get_int(settings, S_SETTING_INT); + move_directshow->int_min = (long)obs_data_get_int(settings, S_SETTING_INT_MIN); + move_directshow->int_max = (long)obs_data_get_int(settings, S_SETTING_INT_MAX); + auto single_setting_name = obs_data_get_string(settings, S_SETTING_NAME); if (!move_directshow->single_setting_name || - strcmp(move_directshow->single_setting_name, - single_setting_name) != 0) { + strcmp(move_directshow->single_setting_name, single_setting_name) != 0) { bfree(move_directshow->single_setting_name); - move_directshow->single_setting_name = - bstrdup(single_setting_name); + move_directshow->single_setting_name = bstrdup(single_setting_name); } } } @@ -308,8 +267,7 @@ long rand_between(long a, long b) void move_directshow_start(void *data) { - struct move_directshow_info *move_directshow = - (struct move_directshow_info *)data; + struct move_directshow_info *move_directshow = (struct move_directshow_info *)data; if (!move_filter_start_internal(&move_directshow->move_filter)) return; @@ -317,82 +275,51 @@ void move_directshow_start(void *data) return; if (move_directshow->move_value_type == MOVE_VALUE_TYPE_SETTINGS) { - obs_data_t *settings = obs_source_get_settings( - move_directshow->move_filter.source); + obs_data_t *settings = obs_source_get_settings(move_directshow->move_filter.source); LoadProperties(move_directshow, settings, true); obs_data_release(settings); } else if (move_directshow->single_setting_name) { long i; pthread_mutex_lock(&move_directshow->mutex); - if (move_directshow->camControl && - 1 == sscanf(move_directshow->single_setting_name, - "camera_control_%i", &i)) { + if (move_directshow->camControl && 1 == sscanf(move_directshow->single_setting_name, "camera_control_%i", &i)) { long val, flags; - HRESULT hr = move_directshow->camControl->Get(i, &val, - &flags); + HRESULT hr = move_directshow->camControl->Get(i, &val, &flags); if (hr == S_OK) { move_directshow->int_from = val; - if (move_directshow->move_value_type == - MOVE_VALUE_TYPE_SETTING_ADD) { - move_directshow->int_to = - move_directshow->int_from + - move_directshow->int_value; + if (move_directshow->move_value_type == MOVE_VALUE_TYPE_SETTING_ADD) { + move_directshow->int_to = move_directshow->int_from + move_directshow->int_value; long min, max, delta, default_val, caps; - hr = move_directshow->camControl - ->GetRange(i, &min, &max, - &delta, - &default_val, - &caps); + hr = move_directshow->camControl->GetRange(i, &min, &max, &delta, &default_val, &caps); if (hr == S_OK) { - if (move_directshow->int_to < - min) - move_directshow->int_to = - min; - if (move_directshow->int_to > - max) - move_directshow->int_to = - max; + if (move_directshow->int_to < min) + move_directshow->int_to = min; + if (move_directshow->int_to > max) + move_directshow->int_to = max; } } } - } else if (move_directshow->procAmp && - 1 == sscanf(move_directshow->single_setting_name, - "video_proc_amp_%i", &i)) { + } else if (move_directshow->procAmp && 1 == sscanf(move_directshow->single_setting_name, "video_proc_amp_%i", &i)) { long val, flags; - HRESULT hr = - move_directshow->procAmp->Get(i, &val, &flags); + HRESULT hr = move_directshow->procAmp->Get(i, &val, &flags); if (hr == S_OK) { move_directshow->int_from = val; - if (move_directshow->move_value_type == - MOVE_VALUE_TYPE_SETTING_ADD) { - move_directshow->int_to = - move_directshow->int_from + - move_directshow->int_value; + if (move_directshow->move_value_type == MOVE_VALUE_TYPE_SETTING_ADD) { + move_directshow->int_to = move_directshow->int_from + move_directshow->int_value; long min, max, delta, default_val, caps; - hr = move_directshow->procAmp->GetRange( - i, &min, &max, &delta, - &default_val, &caps); + hr = move_directshow->procAmp->GetRange(i, &min, &max, &delta, &default_val, &caps); if (hr == S_OK) { - if (move_directshow->int_to < - min) - move_directshow->int_to = - min; - if (move_directshow->int_to > - max) - move_directshow->int_to = - max; + if (move_directshow->int_to < min) + move_directshow->int_to = min; + if (move_directshow->int_to > max) + move_directshow->int_to = max; } } } } pthread_mutex_unlock(&move_directshow->mutex); - if (move_directshow->move_value_type == - MOVE_VALUE_TYPE_RANDOM) { - move_directshow->int_to = - rand_between(move_directshow->int_min, - move_directshow->int_max); - } else if (move_directshow->move_value_type != - MOVE_VALUE_TYPE_SETTING_ADD) { + if (move_directshow->move_value_type == MOVE_VALUE_TYPE_RANDOM) { + move_directshow->int_to = rand_between(move_directshow->int_min, move_directshow->int_max); + } else if (move_directshow->move_value_type != MOVE_VALUE_TYPE_SETTING_ADD) { move_directshow->int_to = move_directshow->int_value; } } @@ -400,75 +327,49 @@ void move_directshow_start(void *data) os_event_signal(move_directshow->start_event); } -static void -move_directshow_to_time(struct move_directshow_info *move_directshow, float t) +static void move_directshow_to_time(struct move_directshow_info *move_directshow, float t) { pthread_mutex_lock(&move_directshow->mutex); if (move_directshow->move_value_type == MOVE_VALUE_TYPE_SETTINGS) { if (move_directshow->camControl) { - for (auto prop = - move_directshow->camControlProps->begin(); - prop != move_directshow->camControlProps->end(); + for (auto prop = move_directshow->camControlProps->begin(); prop != move_directshow->camControlProps->end(); ++prop) { const long value_int = - (long long)((1.0f - - t) * (float)(prop->second - .int_from) + - t * (float)prop->second - .int_to); + (long long)((1.0f - t) * (float)(prop->second.int_from) + t * (float)prop->second.int_to); long val, flags; - HRESULT hr = move_directshow->camControl->Get( - prop->first, &val, &flags); + HRESULT hr = move_directshow->camControl->Get(prop->first, &val, &flags); if (hr == S_OK && val != value_int) { - move_directshow->camControl->Set( - prop->first, value_int, flags); + move_directshow->camControl->Set(prop->first, value_int, flags); } } } if (move_directshow->procAmp) { - for (auto prop = move_directshow->procAmpProps->begin(); - prop != move_directshow->procAmpProps->end(); + for (auto prop = move_directshow->procAmpProps->begin(); prop != move_directshow->procAmpProps->end(); ++prop) { const long value_int = - (long long)((1.0f - - t) * (float)(prop->second - .int_from) + - t * (float)prop->second - .int_to); + (long long)((1.0f - t) * (float)(prop->second.int_from) + t * (float)prop->second.int_to); long val, flags; - HRESULT hr = move_directshow->procAmp->Get( - prop->first, &val, &flags); + HRESULT hr = move_directshow->procAmp->Get(prop->first, &val, &flags); if (hr == S_OK && val != value_int) { - move_directshow->procAmp->Set( - prop->first, value_int, flags); + move_directshow->procAmp->Set(prop->first, value_int, flags); } } } } else if (move_directshow->single_setting_name) { const long value_int = - (long long)((1.0f - t) * - (float)move_directshow->int_from + - t * (float)move_directshow->int_to); + (long long)((1.0f - t) * (float)move_directshow->int_from + t * (float)move_directshow->int_to); long i; - if (move_directshow->camControl && - 1 == sscanf(move_directshow->single_setting_name, - "camera_control_%i", &i)) { + if (move_directshow->camControl && 1 == sscanf(move_directshow->single_setting_name, "camera_control_%i", &i)) { long val, flags; - HRESULT hr = move_directshow->camControl->Get(i, &val, - &flags); + HRESULT hr = move_directshow->camControl->Get(i, &val, &flags); if (hr == S_OK && val != value_int) { - move_directshow->camControl->Set(i, value_int, - flags); + move_directshow->camControl->Set(i, value_int, flags); } - } else if (move_directshow->procAmp && - 1 == sscanf(move_directshow->single_setting_name, - "video_proc_amp_%i", &i)) { + } else if (move_directshow->procAmp && 1 == sscanf(move_directshow->single_setting_name, "video_proc_amp_%i", &i)) { long val, flags; - HRESULT hr = - move_directshow->procAmp->Get(i, &val, &flags); + HRESULT hr = move_directshow->procAmp->Get(i, &val, &flags); if (hr == S_OK && val != value_int) { - move_directshow->procAmp->Set(i, value_int, - flags); + move_directshow->procAmp->Set(i, value_int, flags); } } } @@ -481,8 +382,7 @@ float get_eased(float f, long long easing, long long easing_function); static void *move_directshow_thread(void *data) { - struct move_directshow_info *move_directshow = - (struct move_directshow_info *)data; + struct move_directshow_info *move_directshow = (struct move_directshow_info *)data; os_set_thread_name("move_directshow_thread"); @@ -492,26 +392,18 @@ static void *move_directshow_thread(void *data) if (!move_directshow->run) break; - while (move_directshow->run && - move_directshow->move_filter.moving) { - float t = - (move_directshow->move_filter.running_duration * - 1000.0f - - (float)(move_directshow->move_filter.reverse - ? move_directshow->move_filter - .end_delay - : move_directshow->move_filter - .start_delay)) / - (float)move_directshow->move_filter.duration; + while (move_directshow->run && move_directshow->move_filter.moving) { + float t = (move_directshow->move_filter.running_duration * 1000.0f - + (float)(move_directshow->move_filter.reverse ? move_directshow->move_filter.end_delay + : move_directshow->move_filter.start_delay)) / + (float)move_directshow->move_filter.duration; if (t >= 1.0f) { t = 1.0f; } if (move_directshow->move_filter.reverse) { t = 1.0f - t; } - t = get_eased( - t, move_directshow->move_filter.easing, - move_directshow->move_filter.easing_function); + t = get_eased(t, move_directshow->move_filter.easing, move_directshow->move_filter.easing_function); move_directshow_to_time(move_directshow, t); Sleep(0); } @@ -522,28 +414,21 @@ static void *move_directshow_thread(void *data) static void *move_directshow_create(obs_data_t *settings, obs_source_t *source) { - struct move_directshow_info *move_directshow = - (struct move_directshow_info *)bzalloc( - sizeof(struct move_directshow_info)); - move_filter_init(&move_directshow->move_filter, source, - move_directshow_start); - move_directshow->camControlProps = - new std::map(); - move_directshow->procAmpProps = - new std::map(); + struct move_directshow_info *move_directshow = (struct move_directshow_info *)bzalloc(sizeof(struct move_directshow_info)); + move_filter_init(&move_directshow->move_filter, source, move_directshow_start); + move_directshow->camControlProps = new std::map(); + move_directshow->procAmpProps = new std::map(); pthread_mutex_init(&move_directshow->mutex, nullptr); os_event_init(&move_directshow->start_event, OS_EVENT_TYPE_AUTO); move_directshow_update(move_directshow, settings); move_directshow->run = true; - pthread_create(&move_directshow->thread, NULL, move_directshow_thread, - move_directshow); + pthread_create(&move_directshow->thread, NULL, move_directshow_thread, move_directshow); return move_directshow; } static void move_directshow_destroy(void *data) { - struct move_directshow_info *move_directshow = - (struct move_directshow_info *)data; + struct move_directshow_info *move_directshow = (struct move_directshow_info *)data; move_directshow->run = false; os_event_signal(move_directshow->start_event); pthread_join(move_directshow->thread, NULL); @@ -568,23 +453,17 @@ static void move_directshow_destroy(void *data) bfree(move_directshow); } -static bool device_modified(void *priv, obs_properties_t *props, - obs_property_t *property, obs_data_t *settings) +static bool device_modified(void *priv, obs_properties_t *props, obs_property_t *property, obs_data_t *settings) { - struct move_directshow_info *move_directshow = - (struct move_directshow_info *)priv; + struct move_directshow_info *move_directshow = (struct move_directshow_info *)priv; auto device = obs_data_get_string(settings, "device"); bool changed = false; - auto single_setting_name = - obs_data_get_string(settings, S_SETTING_NAME); + auto single_setting_name = obs_data_get_string(settings, S_SETTING_NAME); bool single_setting_changed = false; - if (!move_directshow->single_setting_name || - strcmp(move_directshow->single_setting_name, single_setting_name) != - 0) { + if (!move_directshow->single_setting_name || strcmp(move_directshow->single_setting_name, single_setting_name) != 0) { bfree(move_directshow->single_setting_name); - move_directshow->single_setting_name = - bstrdup(single_setting_name); + move_directshow->single_setting_name = bstrdup(single_setting_name); single_setting_changed = true; } auto single = obs_properties_get(props, S_SETTING_NAME); @@ -658,8 +537,7 @@ static bool device_modified(void *priv, obs_properties_t *props, changed = true; } } - if (!move_directshow->device || - strcmp(move_directshow->device, device) != 0) { + if (!move_directshow->device || strcmp(move_directshow->device, device) != 0) { bfree(move_directshow->device); move_directshow->device = bstrdup(device); LoadDevice(move_directshow); @@ -691,15 +569,12 @@ static bool device_modified(void *priv, obs_properties_t *props, if (!camcontrolGroup) { camcontrolGroup = obs_properties_create(); - camcontrol_prop = obs_properties_add_group( - props, "camcontrol_group", - obs_module_text("CameraControl"), OBS_GROUP_NORMAL, - camcontrolGroup); + camcontrol_prop = obs_properties_add_group(props, "camcontrol_group", obs_module_text("CameraControl"), + OBS_GROUP_NORMAL, camcontrolGroup); } else { auto p = obs_properties_first(camcontrolGroup); while (p) { - obs_properties_remove_by_name(camcontrolGroup, - obs_property_name(p)); + obs_properties_remove_by_name(camcontrolGroup, obs_property_name(p)); p = obs_properties_first(camcontrolGroup); } } @@ -710,14 +585,12 @@ static bool device_modified(void *priv, obs_properties_t *props, if (!procAmpGroup) { procAmpGroup = obs_properties_create(); - procAmp_prop = obs_properties_add_group( - props, "procamp_group", obs_module_text("VideoProcAmp"), - OBS_GROUP_NORMAL, procAmpGroup); + procAmp_prop = obs_properties_add_group(props, "procamp_group", obs_module_text("VideoProcAmp"), OBS_GROUP_NORMAL, + procAmpGroup); } else { auto p = obs_properties_first(procAmpGroup); while (p) { - obs_properties_remove_by_name(procAmpGroup, - obs_property_name(p)); + obs_properties_remove_by_name(procAmpGroup, obs_property_name(p)); p = obs_properties_first(procAmpGroup); } } @@ -725,8 +598,7 @@ static bool device_modified(void *priv, obs_properties_t *props, if (move_directshow->camControl) { for (int i = 0; i < PROP_MAX; i++) { long min, max, delta, default_val, caps; - HRESULT hr = move_directshow->camControl->GetRange( - i, &min, &max, &delta, &default_val, &caps); + HRESULT hr = move_directshow->camControl->GetRange(i, &min, &max, &delta, &default_val, &caps); if (hr == S_OK) { char number[4]; snprintf(number, 4, "%i", i); @@ -753,53 +625,29 @@ static bool device_modified(void *priv, obs_properties_t *props, std::string prop_id = "camera_control_"; prop_id += number; if (single) { - std::string prop = obs_module_text( - "CameraControl"); + std::string prop = obs_module_text("CameraControl"); prop += " "; prop += name; - obs_property_list_add_string( - single, prop.c_str(), - prop_id.c_str()); - if (strcmp(single_setting_name, - prop_id.c_str()) == 0) { - auto p = obs_properties_get( - props, S_SETTING_INT); - if (move_type == - MOVE_VALUE_TYPE_SETTING_ADD) { - obs_property_int_set_limits( - p, -(max - min), - max - min, - delta); + obs_property_list_add_string(single, prop.c_str(), prop_id.c_str()); + if (strcmp(single_setting_name, prop_id.c_str()) == 0) { + auto p = obs_properties_get(props, S_SETTING_INT); + if (move_type == MOVE_VALUE_TYPE_SETTING_ADD) { + obs_property_int_set_limits(p, -(max - min), max - min, delta); } else { - obs_property_int_set_limits( - p, min, max, - delta); + obs_property_int_set_limits(p, min, max, delta); } - p = obs_properties_get( - props, - S_SETTING_INT_MIN); - obs_property_int_set_limits( - p, min, max, delta); - p = obs_properties_get( - props, - S_SETTING_INT_MAX); - obs_property_int_set_limits( - p, min, max, delta); + p = obs_properties_get(props, S_SETTING_INT_MIN); + obs_property_int_set_limits(p, min, max, delta); + p = obs_properties_get(props, S_SETTING_INT_MAX); + obs_property_int_set_limits(p, min, max, delta); } } else { std::string prop_enabled = prop_id; prop_enabled += "_enabled"; - obs_properties_t *prop_group = - obs_properties_create(); - obs_properties_add_int_slider( - prop_group, prop_id.c_str(), - name.c_str(), min, max, delta); - obs_properties_add_group( - camcontrolGroup, - prop_enabled.c_str(), - name.c_str(), - OBS_GROUP_CHECKABLE, - prop_group); + obs_properties_t *prop_group = obs_properties_create(); + obs_properties_add_int_slider(prop_group, prop_id.c_str(), name.c_str(), min, max, delta); + obs_properties_add_group(camcontrolGroup, prop_enabled.c_str(), name.c_str(), + OBS_GROUP_CHECKABLE, prop_group); } } } @@ -807,8 +655,7 @@ static bool device_modified(void *priv, obs_properties_t *props, if (move_directshow->procAmp) { for (int i = 0; i < PROP_MAX; i++) { long min, max, delta, default_val, caps; - HRESULT hr = move_directshow->procAmp->GetRange( - i, &min, &max, &delta, &default_val, &caps); + HRESULT hr = move_directshow->procAmp->GetRange(i, &min, &max, &delta, &default_val, &caps); if (hr == S_OK) { char number[4]; snprintf(number, 4, "%i", i); @@ -832,8 +679,7 @@ static bool device_modified(void *priv, obs_properties_t *props, } else if (i == 7) { name = obs_module_text("WhiteBalance"); } else if (i == 8) { - name = obs_module_text( - "BacklightCompensation"); + name = obs_module_text("BacklightCompensation"); } else if (i == 9) { name = obs_module_text("Gain"); } else { @@ -842,54 +688,30 @@ static bool device_modified(void *priv, obs_properties_t *props, std::string prop_id = "video_proc_amp_"; prop_id += number; if (single) { - std::string prop = - obs_module_text("VideoProcAmp"); + std::string prop = obs_module_text("VideoProcAmp"); prop += " "; prop += name; - obs_property_list_add_string( - single, prop.c_str(), - prop_id.c_str()); - if (strcmp(single_setting_name, - prop_id.c_str()) == 0) { - auto p = obs_properties_get( - props, S_SETTING_INT); - if (move_type == - MOVE_VALUE_TYPE_SETTING_ADD) { - obs_property_int_set_limits( - p, -(max - min), - max - min, - delta); + obs_property_list_add_string(single, prop.c_str(), prop_id.c_str()); + if (strcmp(single_setting_name, prop_id.c_str()) == 0) { + auto p = obs_properties_get(props, S_SETTING_INT); + if (move_type == MOVE_VALUE_TYPE_SETTING_ADD) { + obs_property_int_set_limits(p, -(max - min), max - min, delta); } else { - obs_property_int_set_limits( - p, min, max, - delta); + obs_property_int_set_limits(p, min, max, delta); } - p = obs_properties_get( - props, - S_SETTING_INT_MIN); - obs_property_int_set_limits( - p, min, max, delta); - p = obs_properties_get( - props, - S_SETTING_INT_MAX); - obs_property_int_set_limits( - p, min, max, delta); + p = obs_properties_get(props, S_SETTING_INT_MIN); + obs_property_int_set_limits(p, min, max, delta); + p = obs_properties_get(props, S_SETTING_INT_MAX); + obs_property_int_set_limits(p, min, max, delta); } } else { std::string prop_enabled = prop_id; prop_enabled += "_enabled"; - obs_properties_t *prop_group = - obs_properties_create(); - obs_properties_add_int_slider( - prop_group, prop_id.c_str(), - name.c_str(), min, max, delta); - - obs_properties_add_group( - procAmpGroup, - prop_enabled.c_str(), - name.c_str(), - OBS_GROUP_CHECKABLE, - prop_group); + obs_properties_t *prop_group = obs_properties_create(); + obs_properties_add_int_slider(prop_group, prop_id.c_str(), name.c_str(), min, max, delta); + + obs_properties_add_group(procAmpGroup, prop_enabled.c_str(), name.c_str(), + OBS_GROUP_CHECKABLE, prop_group); } } } @@ -914,98 +736,60 @@ static bool device_modified(void *priv, obs_properties_t *props, return true; } -bool move_directshow_get_value(obs_properties_t *props, - obs_property_t *property, void *data) +bool move_directshow_get_value(obs_properties_t *props, obs_property_t *property, void *data) { - struct move_directshow_info *move_directshow = - (struct move_directshow_info *)data; - const auto settings = - obs_source_get_settings(move_directshow->move_filter.source); + struct move_directshow_info *move_directshow = (struct move_directshow_info *)data; + const auto settings = obs_source_get_settings(move_directshow->move_filter.source); pthread_mutex_lock(&move_directshow->mutex); if (move_directshow->camControl) { for (int i = 0; i < PROP_MAX; i++) { long val, flags; - HRESULT hr = move_directshow->camControl->Get(i, &val, - &flags); + HRESULT hr = move_directshow->camControl->Get(i, &val, &flags); if (hr == S_OK) { char number[4]; snprintf(number, 4, "%i", i); std::string prop_id = "camera_control_"; prop_id += number; if (move_directshow->single_setting_name && - strcmp(move_directshow->single_setting_name, - prop_id.c_str()) == 0) { - obs_data_set_int(settings, - S_SETTING_INT, val); - if (move_directshow->move_value_type == - MOVE_VALUE_TYPE_RANDOM) { - long min, max, delta, - default_val, caps; - hr = move_directshow->camControl - ->GetRange( - i, &min, - &max, - &delta, - &default_val, - &caps); + strcmp(move_directshow->single_setting_name, prop_id.c_str()) == 0) { + obs_data_set_int(settings, S_SETTING_INT, val); + if (move_directshow->move_value_type == MOVE_VALUE_TYPE_RANDOM) { + long min, max, delta, default_val, caps; + hr = move_directshow->camControl->GetRange(i, &min, &max, &delta, &default_val, + &caps); if (hr == S_OK) { - obs_data_set_int( - settings, - S_SETTING_INT_MIN, - min); - obs_data_set_int( - settings, - S_SETTING_INT_MAX, - max); + obs_data_set_int(settings, S_SETTING_INT_MIN, min); + obs_data_set_int(settings, S_SETTING_INT_MAX, max); } } } - obs_data_set_int(settings, prop_id.c_str(), - val); + obs_data_set_int(settings, prop_id.c_str(), val); } } } if (move_directshow->procAmp) { for (int i = 0; i < PROP_MAX; i++) { long val, flags; - HRESULT hr = - move_directshow->procAmp->Get(i, &val, &flags); + HRESULT hr = move_directshow->procAmp->Get(i, &val, &flags); if (hr == S_OK) { char number[4]; snprintf(number, 4, "%i", i); std::string prop_id = "video_proc_amp_"; prop_id += number; if (move_directshow->single_setting_name && - strcmp(move_directshow->single_setting_name, - prop_id.c_str()) == 0) { - obs_data_set_int(settings, - S_SETTING_INT, val); - if (move_directshow->move_value_type == - MOVE_VALUE_TYPE_RANDOM) { - long min, max, delta, - default_val, caps; - hr = move_directshow->procAmp - ->GetRange( - i, &min, - &max, - &delta, - &default_val, - &caps); + strcmp(move_directshow->single_setting_name, prop_id.c_str()) == 0) { + obs_data_set_int(settings, S_SETTING_INT, val); + if (move_directshow->move_value_type == MOVE_VALUE_TYPE_RANDOM) { + long min, max, delta, default_val, caps; + hr = move_directshow->procAmp->GetRange(i, &min, &max, &delta, &default_val, &caps); if (hr == S_OK) { - obs_data_set_int( - settings, - S_SETTING_INT_MIN, - min); - obs_data_set_int( - settings, - S_SETTING_INT_MAX, - max); + obs_data_set_int(settings, S_SETTING_INT_MIN, min); + obs_data_set_int(settings, S_SETTING_INT_MAX, max); } } } - obs_data_set_int(settings, prop_id.c_str(), - val); + obs_data_set_int(settings, prop_id.c_str(), val); } } } @@ -1017,26 +801,20 @@ bool move_directshow_get_value(obs_properties_t *props, static obs_properties_t *move_directshow_properties(void *data) { - struct move_directshow_info *move_directshow = - (struct move_directshow_info *)data; + struct move_directshow_info *move_directshow = (struct move_directshow_info *)data; obs_properties_t *ppts = obs_properties_create(); - obs_property_t *p = obs_properties_add_list(ppts, "device", - obs_module_text("Device"), - OBS_COMBO_TYPE_LIST, - OBS_COMBO_FORMAT_STRING); + obs_property_t *p = + obs_properties_add_list(ppts, "device", obs_module_text("Device"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING); ICreateDevEnum *deviceEnum; - HRESULT hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, - CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, - (void **)&deviceEnum); + HRESULT hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, (void **)&deviceEnum); if (FAILED(hr)) { //WarningHR(L"GetFilterByMedium: Failed to create device enum", hr); return ppts; } IEnumMoniker *enumMoniker; - hr = deviceEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, - &enumMoniker, 0); + hr = deviceEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, &enumMoniker, 0); if (hr != S_OK) { deviceEnum->Release(); //WarningHR(L"GetFilterByMedium: Failed to create enum moniker", hr); @@ -1046,8 +824,7 @@ static obs_properties_t *move_directshow_properties(void *data) DWORD count = 0; while (enumMoniker->Next(1, &deviceInfo, &count) == S_OK) { IPropertyBag *propertyData; - hr = deviceInfo->BindToStorage(0, 0, IID_IPropertyBag, - (void **)&propertyData); + hr = deviceInfo->BindToStorage(0, 0, IID_IPropertyBag, (void **)&propertyData); if (hr == S_OK) { VARIANT deviceName, devicePath; deviceName.vt = VT_BSTR; @@ -1055,14 +832,12 @@ static obs_properties_t *move_directshow_properties(void *data) devicePath.bstrVal = nullptr; DStr name; - hr = propertyData->Read(L"FriendlyName", &deviceName, - nullptr); + hr = propertyData->Read(L"FriendlyName", &deviceName, nullptr); if (hr == S_OK) { dstr_from_wcs(name, deviceName.bstrVal); } DStr path; - hr = propertyData->Read(L"DevicePath", &devicePath, - nullptr); + hr = propertyData->Read(L"DevicePath", &devicePath, nullptr); if (hr == S_OK && devicePath.bstrVal != nullptr) { dstr_from_wcs(path, devicePath.bstrVal); @@ -1086,50 +861,32 @@ static obs_properties_t *move_directshow_properties(void *data) obs_property_set_modified_callback2(p, device_modified, data); - p = obs_properties_add_list(ppts, S_MOVE_VALUE_TYPE, - obs_module_text("MoveValueType"), - OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); - obs_property_list_add_int( - p, obs_module_text("MoveValueType.SingleSetting"), - MOVE_VALUE_TYPE_SINGLE_SETTING); - obs_property_list_add_int(p, obs_module_text("MoveValueType.Settings"), - MOVE_VALUE_TYPE_SETTINGS); - obs_property_list_add_int(p, obs_module_text("MoveValueType.Random"), - MOVE_VALUE_TYPE_RANDOM); - obs_property_list_add_int(p, - obs_module_text("MoveValueType.SettingAdd"), - MOVE_VALUE_TYPE_SETTING_ADD); + p = obs_properties_add_list(ppts, S_MOVE_VALUE_TYPE, obs_module_text("MoveValueType"), OBS_COMBO_TYPE_LIST, + OBS_COMBO_FORMAT_INT); + obs_property_list_add_int(p, obs_module_text("MoveValueType.SingleSetting"), MOVE_VALUE_TYPE_SINGLE_SETTING); + obs_property_list_add_int(p, obs_module_text("MoveValueType.Settings"), MOVE_VALUE_TYPE_SETTINGS); + obs_property_list_add_int(p, obs_module_text("MoveValueType.Random"), MOVE_VALUE_TYPE_RANDOM); + obs_property_list_add_int(p, obs_module_text("MoveValueType.SettingAdd"), MOVE_VALUE_TYPE_SETTING_ADD); obs_property_set_modified_callback2(p, device_modified, data); - p = obs_properties_add_list(ppts, S_SETTING_NAME, - obs_module_text("Setting"), - OBS_COMBO_TYPE_LIST, - OBS_COMBO_FORMAT_STRING); + p = obs_properties_add_list(ppts, S_SETTING_NAME, obs_module_text("Setting"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING); obs_property_set_modified_callback2(p, device_modified, data); - p = obs_properties_add_int_slider(ppts, S_SETTING_INT, - obs_module_text("Value"), 0, 0, 1); + p = obs_properties_add_int_slider(ppts, S_SETTING_INT, obs_module_text("Value"), 0, 0, 1); obs_property_set_visible(p, false); - p = obs_properties_add_int_slider(ppts, S_SETTING_INT_MIN, - obs_module_text("MinValue"), 0, 0, 1); + p = obs_properties_add_int_slider(ppts, S_SETTING_INT_MIN, obs_module_text("MinValue"), 0, 0, 1); obs_property_set_visible(p, false); - p = obs_properties_add_int_slider(ppts, S_SETTING_INT_MAX, - obs_module_text("MaxValue"), 0, 0, 1); + p = obs_properties_add_int_slider(ppts, S_SETTING_INT_MAX, obs_module_text("MaxValue"), 0, 0, 1); obs_property_set_visible(p, false); - obs_properties_add_group(ppts, "camcontrol_group", - obs_module_text("CameraControl"), - OBS_GROUP_NORMAL, obs_properties_create()); + obs_properties_add_group(ppts, "camcontrol_group", obs_module_text("CameraControl"), OBS_GROUP_NORMAL, + obs_properties_create()); - obs_properties_add_group(ppts, "procamp_group", - obs_module_text("VideoProcAmp"), - OBS_GROUP_NORMAL, obs_properties_create()); + obs_properties_add_group(ppts, "procamp_group", obs_module_text("VideoProcAmp"), OBS_GROUP_NORMAL, obs_properties_create()); - obs_properties_add_button(ppts, "value_get", - obs_module_text("GetValue"), - move_directshow_get_value); + obs_properties_add_button(ppts, "value_get", obs_module_text("GetValue"), move_directshow_get_value); move_filter_properties(&move_directshow->move_filter, ppts); @@ -1138,8 +895,7 @@ static obs_properties_t *move_directshow_properties(void *data) void move_directshow_tick(void *data, float seconds) { - struct move_directshow_info *move_directshow = - (struct move_directshow_info *)data; + struct move_directshow_info *move_directshow = (struct move_directshow_info *)data; float t; if (!move_filter_tick(&move_directshow->move_filter, seconds, &t)) return; diff --git a/move-filter.c b/move-filter.c index 1ca0cc3..f93f395 100644 --- a/move-filter.c +++ b/move-filter.c @@ -6,16 +6,12 @@ bool is_move_filter(const char *filter_id) { if (!filter_id) return false; - return strcmp(filter_id, MOVE_SOURCE_FILTER_ID) == 0 || - strcmp(filter_id, MOVE_VALUE_FILTER_ID) == 0 || - strcmp(filter_id, MOVE_AUDIO_VALUE_FILTER_ID) == 0 || - strcmp(filter_id, MOVE_ACTION_FILTER_ID) == 0 || - strcmp(filter_id, MOVE_AUDIO_ACTION_FILTER_ID) == 0 || - strcmp(filter_id, MOVE_DIRECTSHOW_FILTER_ID) == 0; + return strcmp(filter_id, MOVE_SOURCE_FILTER_ID) == 0 || strcmp(filter_id, MOVE_VALUE_FILTER_ID) == 0 || + strcmp(filter_id, MOVE_AUDIO_VALUE_FILTER_ID) == 0 || strcmp(filter_id, MOVE_ACTION_FILTER_ID) == 0 || + strcmp(filter_id, MOVE_AUDIO_ACTION_FILTER_ID) == 0 || strcmp(filter_id, MOVE_DIRECTSHOW_FILTER_ID) == 0; } -void move_filter_init(struct move_filter *move_filter, obs_source_t *source, - void (*move_start)(void *data)) +void move_filter_init(struct move_filter *move_filter, obs_source_t *source, void (*move_start)(void *data)) { move_filter->source = source; move_filter->move_start_hotkey = OBS_INVALID_HOTKEY_ID; @@ -35,8 +31,7 @@ void move_filter_destroy(struct move_filter *move_filter) obs_hotkey_unregister(move_filter->move_hold_hotkey); } -void move_filter_start_hotkey(void *data, obs_hotkey_id id, - obs_hotkey_t *hotkey, bool pressed) +void move_filter_start_hotkey(void *data, obs_hotkey_id id, obs_hotkey_t *hotkey, bool pressed) { UNUSED_PARAMETER(id); UNUSED_PARAMETER(hotkey); @@ -44,8 +39,7 @@ void move_filter_start_hotkey(void *data, obs_hotkey_id id, return; struct move_filter *move_filter = data; - if (move_filter->next_move_on != NEXT_MOVE_ON_HOTKEY || - !move_filter->next_move_name || + if (move_filter->next_move_on != NEXT_MOVE_ON_HOTKEY || !move_filter->next_move_name || !strlen(move_filter->next_move_name)) { move_filter_start(move_filter); return; @@ -56,8 +50,7 @@ void move_filter_start_hotkey(void *data, obs_hotkey_id id, return; } - if (move_filter->moving && obs_source_enabled(move_filter->source) && - move_filter->next_move_name && + if (move_filter->moving && obs_source_enabled(move_filter->source) && move_filter->next_move_name && strcmp(move_filter->next_move_name, NEXT_MOVE_REVERSE) != 0) { move_filter->moving = false; if (move_filter->enabled_match_moving) @@ -73,47 +66,33 @@ void move_filter_start_hotkey(void *data, obs_hotkey_id id, if (!next_move_name || !strlen(next_move_name)) { move_filter_start(move_filter); move_filter->filters_done.num = 0; - da_push_back(move_filter->filters_done, - &move_filter->source); + da_push_back(move_filter->filters_done, &move_filter->source); return; } if (next_move_on != NEXT_MOVE_ON_HOTKEY) { da_push_back(move_filter->filters_done, &filter); - } else if (strcmp(next_move_name, NEXT_MOVE_REVERSE) == 0 && - !obs_source_removed(filter) && - is_move_filter( - obs_source_get_unversioned_id(filter))) { + } else if (strcmp(next_move_name, NEXT_MOVE_REVERSE) == 0 && !obs_source_removed(filter) && + is_move_filter(obs_source_get_unversioned_id(filter))) { move_filter_start(obs_obj_get_data(filter)); move_filter->filters_done.num = 0; return; } filter = obs_source_get_filter_by_name(parent, next_move_name); if (!filter && move_filter->get_alternative_source) { - obs_source_t *alternative_source = - move_filter->get_alternative_source( - move_filter); + obs_source_t *alternative_source = move_filter->get_alternative_source(move_filter); if (alternative_source) - filter = obs_source_get_filter_by_name( - alternative_source, next_move_name); + filter = obs_source_get_filter_by_name(alternative_source, next_move_name); } if (filter) { - if (!obs_source_removed(filter) && - is_move_filter( - obs_source_get_unversioned_id(filter))) { - struct move_filter *filter_data = - obs_obj_get_data(filter); - if (filter_data->moving && - obs_source_enabled(filter_data->source) && - (filter_data->reverse || - !filter_data->next_move_name || - strcmp(filter_data->next_move_name, - NEXT_MOVE_REVERSE) != 0)) { + if (!obs_source_removed(filter) && is_move_filter(obs_source_get_unversioned_id(filter))) { + struct move_filter *filter_data = obs_obj_get_data(filter); + if (filter_data->moving && obs_source_enabled(filter_data->source) && + (filter_data->reverse || !filter_data->next_move_name || + strcmp(filter_data->next_move_name, NEXT_MOVE_REVERSE) != 0)) { filter_data->moving = false; if (filter_data->enabled_match_moving) - obs_source_set_enabled( - filter_data->source, - false); + obs_source_set_enabled(filter_data->source, false); } parent = obs_filter_get_parent(filter); next_move_name = filter_data->next_move_name; @@ -122,8 +101,7 @@ void move_filter_start_hotkey(void *data, obs_hotkey_id id, obs_source_release(filter); move_filter_start(move_filter); move_filter->filters_done.num = 0; - da_push_back(move_filter->filters_done, - &move_filter->source); + da_push_back(move_filter->filters_done, &move_filter->source); return; } obs_source_release(filter); @@ -135,20 +113,17 @@ void move_filter_start_hotkey(void *data, obs_hotkey_id id, if (move_filter->filters_done.array[i] == filter) { move_filter_start(move_filter); move_filter->filters_done.num = 0; - da_push_back(move_filter->filters_done, - &move_filter->source); + da_push_back(move_filter->filters_done, &move_filter->source); return; } } - if (!obs_source_removed(filter) && - is_move_filter(obs_source_get_unversioned_id(filter))) { + if (!obs_source_removed(filter) && is_move_filter(obs_source_get_unversioned_id(filter))) { move_filter_start(obs_obj_get_data(filter)); } da_push_back(move_filter->filters_done, &filter); } -void move_filter_hold_hotkey(void *data, obs_hotkey_id id, obs_hotkey_t *hotkey, - bool pressed) +void move_filter_hold_hotkey(void *data, obs_hotkey_id id, obs_hotkey_t *hotkey, bool pressed) { UNUSED_PARAMETER(id); UNUSED_PARAMETER(hotkey); @@ -158,9 +133,7 @@ void move_filter_hold_hotkey(void *data, obs_hotkey_id id, obs_hotkey_t *hotkey, move_filter->holding = true; return; } - move_filter->running_duration = - (float)(move_filter->start_delay + move_filter->duration) / - 1000.0f; + move_filter->running_duration = (float)(move_filter->start_delay + move_filter->duration) / 1000.0f; move_filter->holding = false; } @@ -168,8 +141,7 @@ void move_filter_hold_hotkey(void *data, obs_hotkey_id id, obs_hotkey_t *hotkey, void move_filter_update(struct move_filter *move_filter, obs_data_t *settings) { const char *filter_name = obs_source_get_name(move_filter->source); - if (!move_filter->filter_name || - strcmp(move_filter->filter_name, filter_name) != 0) { + if (!move_filter->filter_name || strcmp(move_filter->filter_name, filter_name) != 0) { bfree(move_filter->filter_name); move_filter->filter_name = bstrdup(filter_name); if (move_filter->move_start_hotkey != OBS_INVALID_HOTKEY_ID) { @@ -184,60 +156,43 @@ void move_filter_update(struct move_filter *move_filter, obs_data_t *settings) obs_source_t *parent = obs_filter_get_parent(move_filter->source); if (parent && move_filter->filter_name) { if (move_filter->move_start_hotkey == OBS_INVALID_HOTKEY_ID) { - move_filter->move_start_hotkey = - obs_hotkey_register_source( - parent, move_filter->filter_name, - move_filter->filter_name, - move_filter_start_hotkey, move_filter); + move_filter->move_start_hotkey = obs_hotkey_register_source( + parent, move_filter->filter_name, move_filter->filter_name, move_filter_start_hotkey, move_filter); } if (move_filter->move_hold_hotkey == OBS_INVALID_HOTKEY_ID) { struct dstr hotkey_name = {0}; dstr_init_copy(&hotkey_name, move_filter->filter_name); dstr_cat(&hotkey_name, " "); dstr_cat(&hotkey_name, obs_module_text("Hold")); - move_filter->move_hold_hotkey = - obs_hotkey_register_source( - parent, hotkey_name.array, - hotkey_name.array, - move_filter_hold_hotkey, move_filter); + move_filter->move_hold_hotkey = obs_hotkey_register_source(parent, hotkey_name.array, hotkey_name.array, + move_filter_hold_hotkey, move_filter); dstr_free(&hotkey_name); } } - move_filter->enabled_match_moving = - obs_data_get_bool(settings, S_ENABLED_MATCH_MOVING); - if (move_filter->enabled_match_moving && !move_filter->moving && - obs_source_enabled(move_filter->source)) + move_filter->enabled_match_moving = obs_data_get_bool(settings, S_ENABLED_MATCH_MOVING); + if (move_filter->enabled_match_moving && !move_filter->moving && obs_source_enabled(move_filter->source)) move_filter_start(move_filter); - move_filter->custom_duration = - obs_data_get_bool(settings, S_CUSTOM_DURATION); + move_filter->custom_duration = obs_data_get_bool(settings, S_CUSTOM_DURATION); if (move_filter->custom_duration) move_filter->duration = obs_data_get_int(settings, S_DURATION); move_filter->start_delay = obs_data_get_int(settings, S_START_DELAY); move_filter->end_delay = obs_data_get_int(settings, S_END_DELAY); move_filter->easing = obs_data_get_int(settings, S_EASING_MATCH); - move_filter->easing_function = - obs_data_get_int(settings, S_EASING_FUNCTION_MATCH); - - move_filter->start_trigger = - (uint32_t)obs_data_get_int(settings, S_START_TRIGGER); - move_filter->stop_trigger = - (uint32_t)obs_data_get_int(settings, S_STOP_TRIGGER); - - const char *simultaneous_move_name = - obs_data_get_string(settings, S_SIMULTANEOUS_MOVE); - if (!move_filter->simultaneous_move_name || - strcmp(move_filter->simultaneous_move_name, - simultaneous_move_name) != 0) { + move_filter->easing_function = obs_data_get_int(settings, S_EASING_FUNCTION_MATCH); + + move_filter->start_trigger = (uint32_t)obs_data_get_int(settings, S_START_TRIGGER); + move_filter->stop_trigger = (uint32_t)obs_data_get_int(settings, S_STOP_TRIGGER); + + const char *simultaneous_move_name = obs_data_get_string(settings, S_SIMULTANEOUS_MOVE); + if (!move_filter->simultaneous_move_name || strcmp(move_filter->simultaneous_move_name, simultaneous_move_name) != 0) { bfree(move_filter->simultaneous_move_name); - move_filter->simultaneous_move_name = - bstrdup(simultaneous_move_name); + move_filter->simultaneous_move_name = bstrdup(simultaneous_move_name); } const char *next_move_name = obs_data_get_string(settings, S_NEXT_MOVE); - if (!move_filter->next_move_name || - strcmp(move_filter->next_move_name, next_move_name) != 0) { + if (!move_filter->next_move_name || strcmp(move_filter->next_move_name, next_move_name) != 0) { bfree(move_filter->next_move_name); move_filter->next_move_name = bstrdup(next_move_name); move_filter->reverse = false; @@ -254,18 +209,12 @@ bool move_filter_start_internal(struct move_filter *move_filter) { if (!move_filter->custom_duration) move_filter->duration = obs_frontend_get_transition_duration(); - if (move_filter->moving && !move_filter->holding && - obs_source_enabled(move_filter->source)) { - if (move_filter->next_move_on == NEXT_MOVE_ON_HOTKEY && - move_filter->next_move_name && - strcmp(move_filter->next_move_name, NEXT_MOVE_REVERSE) == - 0) { + if (move_filter->moving && !move_filter->holding && obs_source_enabled(move_filter->source)) { + if (move_filter->next_move_on == NEXT_MOVE_ON_HOTKEY && move_filter->next_move_name && + strcmp(move_filter->next_move_name, NEXT_MOVE_REVERSE) == 0) { move_filter->reverse = !move_filter->reverse; move_filter->running_duration = - (float)(move_filter->duration + - move_filter->start_delay + - move_filter->end_delay) / - 1000.0f - + (float)(move_filter->duration + move_filter->start_delay + move_filter->end_delay) / 1000.0f - move_filter->running_duration; } return false; @@ -273,40 +222,26 @@ bool move_filter_start_internal(struct move_filter *move_filter) move_filter->running_duration = 0.0f; move_filter->moving = true; - if (move_filter->enabled_match_moving && - !obs_source_enabled(move_filter->source)) { + if (move_filter->enabled_match_moving && !obs_source_enabled(move_filter->source)) { move_filter->enabled = true; obs_source_set_enabled(move_filter->source, true); } - if (move_filter->simultaneous_move_name && - strlen(move_filter->simultaneous_move_name) && - (!move_filter->filter_name || - strcmp(move_filter->filter_name, - move_filter->simultaneous_move_name) != 0)) { - obs_source_t *parent = - obs_filter_get_parent(move_filter->source); + if (move_filter->simultaneous_move_name && strlen(move_filter->simultaneous_move_name) && + (!move_filter->filter_name || strcmp(move_filter->filter_name, move_filter->simultaneous_move_name) != 0)) { + obs_source_t *parent = obs_filter_get_parent(move_filter->source); if (parent) { - obs_source_t *filter = obs_source_get_filter_by_name( - parent, move_filter->simultaneous_move_name); + obs_source_t *filter = obs_source_get_filter_by_name(parent, move_filter->simultaneous_move_name); if (!filter && move_filter->get_alternative_source) { - obs_source_t *alternative_source = - move_filter->get_alternative_source( - move_filter); + obs_source_t *alternative_source = move_filter->get_alternative_source(move_filter); if (alternative_source) - filter = obs_source_get_filter_by_name( - alternative_source, - move_filter - ->simultaneous_move_name); + filter = obs_source_get_filter_by_name(alternative_source, + move_filter->simultaneous_move_name); } if (filter) { - if (!obs_source_removed(filter) && - is_move_filter( - obs_source_get_unversioned_id( - filter))) { - move_filter_start( - obs_obj_get_data(filter)); + if (!obs_source_removed(filter) && is_move_filter(obs_source_get_unversioned_id(filter))) { + move_filter_start(obs_obj_get_data(filter)); } obs_source_release(filter); } @@ -320,8 +255,7 @@ void move_filter_stop(struct move_filter *move_filter) if (move_filter->holding) return; move_filter->moving = false; - if (move_filter->enabled_match_moving && - obs_source_enabled(move_filter->source)) { + if (move_filter->enabled_match_moving && obs_source_enabled(move_filter->source)) { obs_source_set_enabled(move_filter->source, false); } } @@ -329,65 +263,41 @@ void move_filter_stop(struct move_filter *move_filter) extern void move_filter_ended(struct move_filter *move_filter) { if (move_filter->enabled_match_moving && - (move_filter->reverse || - move_filter->next_move_on == NEXT_MOVE_ON_HOTKEY || - !move_filter->next_move_name || + (move_filter->reverse || move_filter->next_move_on == NEXT_MOVE_ON_HOTKEY || !move_filter->next_move_name || strcmp(move_filter->next_move_name, NEXT_MOVE_REVERSE) != 0) && obs_source_enabled(move_filter->source)) { obs_source_set_enabled(move_filter->source, false); } - if (move_filter->next_move_on == NEXT_MOVE_ON_END && - move_filter->next_move_name && - strlen(move_filter->next_move_name) && - (!move_filter->filter_name || - strcmp(move_filter->filter_name, move_filter->next_move_name) != - 0)) { - if (strcmp(move_filter->next_move_name, NEXT_MOVE_REVERSE) == - 0) { + if (move_filter->next_move_on == NEXT_MOVE_ON_END && move_filter->next_move_name && strlen(move_filter->next_move_name) && + (!move_filter->filter_name || strcmp(move_filter->filter_name, move_filter->next_move_name) != 0)) { + if (strcmp(move_filter->next_move_name, NEXT_MOVE_REVERSE) == 0) { move_filter->reverse = !move_filter->reverse; if (move_filter->reverse) move_filter_start(move_filter); } else { - obs_source_t *parent = - obs_filter_get_parent(move_filter->source); + obs_source_t *parent = obs_filter_get_parent(move_filter->source); if (parent) { - obs_source_t *filter = - obs_source_get_filter_by_name( - parent, - move_filter->next_move_name); - - if (!filter && - move_filter->get_alternative_source) { - obs_source_t *alternative_source = - move_filter - ->get_alternative_source( - move_filter); + obs_source_t *filter = obs_source_get_filter_by_name(parent, move_filter->next_move_name); + + if (!filter && move_filter->get_alternative_source) { + obs_source_t *alternative_source = move_filter->get_alternative_source(move_filter); if (alternative_source) - filter = obs_source_get_filter_by_name( - alternative_source, - move_filter - ->next_move_name); + filter = obs_source_get_filter_by_name(alternative_source, + move_filter->next_move_name); } if (filter) { - if (!obs_source_removed(filter) && - is_move_filter( - obs_source_get_unversioned_id( - filter))) { - move_filter_start( - obs_obj_get_data( - filter)); + if (!obs_source_removed(filter) && is_move_filter(obs_source_get_unversioned_id(filter))) { + move_filter_start(obs_obj_get_data(filter)); } obs_source_release(filter); } } } - } else if (move_filter->next_move_on == NEXT_MOVE_ON_HOTKEY && - move_filter->next_move_name && - strcmp(move_filter->next_move_name, NEXT_MOVE_REVERSE) == - 0) { + } else if (move_filter->next_move_on == NEXT_MOVE_ON_HOTKEY && move_filter->next_move_name && + strcmp(move_filter->next_move_name, NEXT_MOVE_REVERSE) == 0) { move_filter->reverse = !move_filter->reverse; } } @@ -397,48 +307,34 @@ float get_eased(float f, long long easing, long long easing_function); bool move_filter_tick(struct move_filter *move_filter, float seconds, float *tp) { if (move_filter->filter_name && - (move_filter->move_start_hotkey == OBS_INVALID_HOTKEY_ID || - move_filter->move_hold_hotkey == OBS_INVALID_HOTKEY_ID)) { - obs_source_t *parent = - obs_filter_get_parent(move_filter->source); - if (parent && - move_filter->move_start_hotkey == OBS_INVALID_HOTKEY_ID) { - move_filter->move_start_hotkey = - obs_hotkey_register_source( - parent, move_filter->filter_name, - move_filter->filter_name, - move_filter_start_hotkey, move_filter); + (move_filter->move_start_hotkey == OBS_INVALID_HOTKEY_ID || move_filter->move_hold_hotkey == OBS_INVALID_HOTKEY_ID)) { + obs_source_t *parent = obs_filter_get_parent(move_filter->source); + if (parent && move_filter->move_start_hotkey == OBS_INVALID_HOTKEY_ID) { + move_filter->move_start_hotkey = obs_hotkey_register_source( + parent, move_filter->filter_name, move_filter->filter_name, move_filter_start_hotkey, move_filter); } - if (parent && - move_filter->move_hold_hotkey == OBS_INVALID_HOTKEY_ID) { + if (parent && move_filter->move_hold_hotkey == OBS_INVALID_HOTKEY_ID) { struct dstr hotkey_name = {0}; dstr_init_copy(&hotkey_name, move_filter->filter_name); dstr_cat(&hotkey_name, " "); dstr_cat(&hotkey_name, obs_module_text("Hold")); - move_filter->move_hold_hotkey = - obs_hotkey_register_source( - parent, hotkey_name.array, - hotkey_name.array, - move_filter_hold_hotkey, move_filter); + move_filter->move_hold_hotkey = obs_hotkey_register_source(parent, hotkey_name.array, hotkey_name.array, + move_filter_hold_hotkey, move_filter); dstr_free(&hotkey_name); } } const bool enabled = obs_source_enabled(move_filter->source); if (move_filter->enabled != enabled) { - if (enabled && - (move_filter->start_trigger == START_TRIGGER_ENABLE || - (move_filter->enabled_match_moving && - !move_filter->moving))) + if (enabled && (move_filter->start_trigger == START_TRIGGER_ENABLE || + (move_filter->enabled_match_moving && !move_filter->moving))) move_filter_start(move_filter); - if (enabled && - move_filter->stop_trigger == START_TRIGGER_ENABLE) + if (enabled && move_filter->stop_trigger == START_TRIGGER_ENABLE) move_filter_stop(move_filter); move_filter->enabled = enabled; } - if (move_filter->enabled_match_moving && - enabled != move_filter->moving) { + if (move_filter->enabled_match_moving && enabled != move_filter->moving) { if (enabled) { move_filter_start(move_filter); } else { @@ -449,25 +345,19 @@ bool move_filter_tick(struct move_filter *move_filter, float seconds, float *tp) return false; move_filter->running_duration += seconds; - if (move_filter->running_duration * 1000.0f < - (move_filter->reverse ? move_filter->end_delay - : move_filter->start_delay)) { + if (move_filter->running_duration * 1000.0f < (move_filter->reverse ? move_filter->end_delay : move_filter->start_delay)) { return false; } if (move_filter->holding) { move_filter_start(move_filter); - move_filter->running_duration = - (float)(move_filter->start_delay + - move_filter->duration) / - 1000.0f; + move_filter->running_duration = (float)(move_filter->start_delay + move_filter->duration) / 1000.0f; *tp = 1.0f; return true; } if (move_filter->running_duration * 1000.0f >= - (float)(move_filter->start_delay + move_filter->duration + - move_filter->end_delay)) { + (float)(move_filter->start_delay + move_filter->duration + move_filter->end_delay)) { move_filter->moving = false; } if (!move_filter->duration) { @@ -475,8 +365,7 @@ bool move_filter_tick(struct move_filter *move_filter, float seconds, float *tp) return true; } float t = (move_filter->running_duration * 1000.0f - - (float)(move_filter->reverse ? move_filter->end_delay - : move_filter->start_delay)) / + (float)(move_filter->reverse ? move_filter->end_delay : move_filter->start_delay)) / (float)move_filter->duration; if (t >= 1.0f) { t = 1.0f; @@ -489,8 +378,7 @@ bool move_filter_tick(struct move_filter *move_filter, float seconds, float *tp) return true; } -bool move_filter_start_button(obs_properties_t *props, obs_property_t *property, - void *data) +bool move_filter_start_button(obs_properties_t *props, obs_property_t *property, void *data) { struct move_filter *move_filter = data; move_filter_start(move_filter); @@ -499,8 +387,7 @@ bool move_filter_start_button(obs_properties_t *props, obs_property_t *property, return false; } -void prop_list_add_move_filter(obs_source_t *parent, obs_source_t *child, - void *data) +void prop_list_add_move_filter(obs_source_t *parent, obs_source_t *child, void *data) { UNUSED_PARAMETER(parent); if (!is_move_filter(obs_source_get_unversioned_id(child))) @@ -510,12 +397,9 @@ void prop_list_add_move_filter(obs_source_t *parent, obs_source_t *child, obs_property_list_add_string(p, name, name); } -void move_filter_properties(struct move_filter *move_filter, - obs_properties_t *ppts) +void move_filter_properties(struct move_filter *move_filter, obs_properties_t *ppts) { - obs_property_t *p = obs_properties_add_int( - ppts, S_START_DELAY, obs_module_text("StartDelay"), 0, 10000000, - 100); + obs_property_t *p = obs_properties_add_int(ppts, S_START_DELAY, obs_module_text("StartDelay"), 0, 10000000, 100); obs_property_int_set_suffix(p, "ms"); obs_properties_t *duration = obs_properties_create(); @@ -523,98 +407,61 @@ void move_filter_properties(struct move_filter *move_filter, p = obs_properties_add_int(duration, S_DURATION, "", 0, 10000000, 100); obs_property_int_set_suffix(p, "ms"); - p = obs_properties_add_group(ppts, S_CUSTOM_DURATION, - obs_module_text("CustomDuration"), - OBS_GROUP_CHECKABLE, duration); + p = obs_properties_add_group(ppts, S_CUSTOM_DURATION, obs_module_text("CustomDuration"), OBS_GROUP_CHECKABLE, duration); - p = obs_properties_add_int(ppts, S_END_DELAY, - obs_module_text("EndDelay"), 0, 10000000, - 100); + p = obs_properties_add_int(ppts, S_END_DELAY, obs_module_text("EndDelay"), 0, 10000000, 100); obs_property_int_set_suffix(p, "ms"); - p = obs_properties_add_list(ppts, S_EASING_MATCH, - obs_module_text("Easing"), - OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); + p = obs_properties_add_list(ppts, S_EASING_MATCH, obs_module_text("Easing"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); prop_list_add_easings(p); - p = obs_properties_add_list(ppts, S_EASING_FUNCTION_MATCH, - obs_module_text("EasingFunction"), - OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); + p = obs_properties_add_list(ppts, S_EASING_FUNCTION_MATCH, obs_module_text("EasingFunction"), OBS_COMBO_TYPE_LIST, + OBS_COMBO_FORMAT_INT); prop_list_add_easing_functions(p); - p = obs_properties_add_bool(ppts, S_ENABLED_MATCH_MOVING, - obs_module_text("EnabledMatchMoving")); - - p = obs_properties_add_list(ppts, S_START_TRIGGER, - obs_module_text("StartTrigger"), - OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); - - obs_property_list_add_int(p, obs_module_text("StartTrigger.None"), - START_TRIGGER_NONE); - obs_property_list_add_int(p, obs_module_text("StartTrigger.Activate"), - START_TRIGGER_ACTIVATE); - obs_property_list_add_int(p, obs_module_text("StartTrigger.Deactivate"), - START_TRIGGER_DEACTIVATE); - obs_property_list_add_int(p, obs_module_text("StartTrigger.Show"), - START_TRIGGER_SHOW); - obs_property_list_add_int(p, obs_module_text("StartTrigger.Hide"), - START_TRIGGER_HIDE); - obs_property_list_add_int(p, obs_module_text("StartTrigger.Enable"), - START_TRIGGER_ENABLE); - obs_property_list_add_int(p, obs_module_text("StartTrigger.Load"), - START_TRIGGER_LOAD); - - p = obs_properties_add_list(ppts, S_STOP_TRIGGER, - obs_module_text("StopTrigger"), - OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); - - obs_property_list_add_int(p, obs_module_text("StopTrigger.None"), - START_TRIGGER_NONE); - obs_property_list_add_int(p, obs_module_text("StartTrigger.Activate"), - START_TRIGGER_ACTIVATE); - obs_property_list_add_int(p, obs_module_text("StartTrigger.Deactivate"), - START_TRIGGER_DEACTIVATE); - obs_property_list_add_int(p, obs_module_text("StartTrigger.Show"), - START_TRIGGER_SHOW); - obs_property_list_add_int(p, obs_module_text("StartTrigger.Hide"), - START_TRIGGER_HIDE); - obs_property_list_add_int(p, obs_module_text("StartTrigger.Enable"), - START_TRIGGER_ENABLE); + p = obs_properties_add_bool(ppts, S_ENABLED_MATCH_MOVING, obs_module_text("EnabledMatchMoving")); + + p = obs_properties_add_list(ppts, S_START_TRIGGER, obs_module_text("StartTrigger"), OBS_COMBO_TYPE_LIST, + OBS_COMBO_FORMAT_INT); + + obs_property_list_add_int(p, obs_module_text("StartTrigger.None"), START_TRIGGER_NONE); + obs_property_list_add_int(p, obs_module_text("StartTrigger.Activate"), START_TRIGGER_ACTIVATE); + obs_property_list_add_int(p, obs_module_text("StartTrigger.Deactivate"), START_TRIGGER_DEACTIVATE); + obs_property_list_add_int(p, obs_module_text("StartTrigger.Show"), START_TRIGGER_SHOW); + obs_property_list_add_int(p, obs_module_text("StartTrigger.Hide"), START_TRIGGER_HIDE); + obs_property_list_add_int(p, obs_module_text("StartTrigger.Enable"), START_TRIGGER_ENABLE); + obs_property_list_add_int(p, obs_module_text("StartTrigger.Load"), START_TRIGGER_LOAD); + + p = obs_properties_add_list(ppts, S_STOP_TRIGGER, obs_module_text("StopTrigger"), OBS_COMBO_TYPE_LIST, + OBS_COMBO_FORMAT_INT); + + obs_property_list_add_int(p, obs_module_text("StopTrigger.None"), START_TRIGGER_NONE); + obs_property_list_add_int(p, obs_module_text("StartTrigger.Activate"), START_TRIGGER_ACTIVATE); + obs_property_list_add_int(p, obs_module_text("StartTrigger.Deactivate"), START_TRIGGER_DEACTIVATE); + obs_property_list_add_int(p, obs_module_text("StartTrigger.Show"), START_TRIGGER_SHOW); + obs_property_list_add_int(p, obs_module_text("StartTrigger.Hide"), START_TRIGGER_HIDE); + obs_property_list_add_int(p, obs_module_text("StartTrigger.Enable"), START_TRIGGER_ENABLE); obs_source_t *parent = obs_filter_get_parent(move_filter->source); - p = obs_properties_add_list(ppts, S_SIMULTANEOUS_MOVE, - obs_module_text("SimultaneousMove"), - OBS_COMBO_TYPE_LIST, + p = obs_properties_add_list(ppts, S_SIMULTANEOUS_MOVE, obs_module_text("SimultaneousMove"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING); - obs_property_list_add_string( - p, obs_module_text("SimultaneousMove.None"), ""); + obs_property_list_add_string(p, obs_module_text("SimultaneousMove.None"), ""); if (parent) obs_source_enum_filters(parent, prop_list_add_move_filter, p); - p = obs_properties_add_list(ppts, S_NEXT_MOVE, - obs_module_text("NextMove"), - OBS_COMBO_TYPE_LIST, - OBS_COMBO_FORMAT_STRING); + p = obs_properties_add_list(ppts, S_NEXT_MOVE, obs_module_text("NextMove"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING); obs_property_list_add_string(p, obs_module_text("NextMove.None"), ""); - obs_property_list_add_string(p, obs_module_text("NextMove.Reverse"), - NEXT_MOVE_REVERSE); + obs_property_list_add_string(p, obs_module_text("NextMove.Reverse"), NEXT_MOVE_REVERSE); if (parent) obs_source_enum_filters(parent, prop_list_add_move_filter, p); - p = obs_properties_add_list(ppts, S_NEXT_MOVE_ON, - obs_module_text("NextMoveOn"), - OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); - obs_property_list_add_int(p, obs_module_text("NextMoveOn.End"), - NEXT_MOVE_ON_END); - obs_property_list_add_int(p, obs_module_text("NextMoveOn.Hotkey"), - NEXT_MOVE_ON_HOTKEY); - - obs_properties_add_button(ppts, "move_filter_start", - obs_module_text("Start"), - move_filter_start_button); - obs_properties_add_text(ppts, "plugin_info", PLUGIN_INFO, - OBS_TEXT_INFO); + p = obs_properties_add_list(ppts, S_NEXT_MOVE_ON, obs_module_text("NextMoveOn"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); + obs_property_list_add_int(p, obs_module_text("NextMoveOn.End"), NEXT_MOVE_ON_END); + obs_property_list_add_int(p, obs_module_text("NextMoveOn.Hotkey"), NEXT_MOVE_ON_HOTKEY); + + obs_properties_add_button(ppts, "move_filter_start", obs_module_text("Start"), move_filter_start_button); + obs_properties_add_text(ppts, "plugin_info", PLUGIN_INFO, OBS_TEXT_INFO); } void move_filter_defaults(obs_data_t *settings) diff --git a/move-source-filter.c b/move-source-filter.c index 671aab5..9620d6b 100644 --- a/move-source-filter.c +++ b/move-source-filter.c @@ -66,36 +66,29 @@ void move_source_item_remove(void *data, calldata_t *call_data) signal_handler_t *sh = obs_source_get_signal_handler(parent); if (!sh) return; - signal_handler_disconnect(sh, "item_remove", move_source_item_remove, - move_source); - signal_handler_disconnect(sh, "remove", move_source_scene_remove, - move_source); - signal_handler_disconnect(sh, "destroy", move_source_scene_remove, - move_source); + signal_handler_disconnect(sh, "item_remove", move_source_item_remove, move_source); + signal_handler_disconnect(sh, "remove", move_source_scene_remove, move_source); + signal_handler_disconnect(sh, "destroy", move_source_scene_remove, move_source); } -void move_source_scene_remove(void *data, calldata_t *call_data) { +void move_source_scene_remove(void *data, calldata_t *call_data) +{ struct move_source_info *move_source = data; - obs_source_t *source = - (obs_source_t *)calldata_ptr(call_data, "source"); + obs_source_t *source = (obs_source_t *)calldata_ptr(call_data, "source"); signal_handler_t *sh = obs_source_get_signal_handler(source); if (!sh) return; - signal_handler_disconnect(sh, "item_remove", move_source_item_remove, - move_source); - signal_handler_disconnect(sh, "remove", move_source_scene_remove, - move_source); - signal_handler_disconnect(sh, "destroy", move_source_scene_remove, - move_source); + signal_handler_disconnect(sh, "item_remove", move_source_item_remove, move_source); + signal_handler_disconnect(sh, "remove", move_source_scene_remove, move_source); + signal_handler_disconnect(sh, "destroy", move_source_scene_remove, move_source); } bool find_sceneitem(obs_scene_t *scene, obs_sceneitem_t *scene_item, void *data) { UNUSED_PARAMETER(scene); struct move_source_info *move_source = data; - const char *name = - obs_source_get_name(obs_sceneitem_get_source(scene_item)); + const char *name = obs_source_get_name(obs_sceneitem_get_source(scene_item)); if (!name || strcmp(name, move_source->source_name) != 0) return true; move_source->scene_item = scene_item; @@ -105,12 +98,9 @@ bool find_sceneitem(obs_scene_t *scene, obs_sceneitem_t *scene_item, void *data) signal_handler_t *sh = obs_source_get_signal_handler(parent); if (sh) { - signal_handler_connect(sh, "item_remove", - move_source_item_remove, move_source); - signal_handler_connect(sh, "remove", move_source_scene_remove, - move_source); - signal_handler_connect(sh, "destroy", move_source_scene_remove, - move_source); + signal_handler_connect(sh, "item_remove", move_source_item_remove, move_source); + signal_handler_connect(sh, "remove", move_source_scene_remove, move_source); + signal_handler_connect(sh, "destroy", move_source_scene_remove, move_source); } return false; @@ -148,158 +138,96 @@ float calc_sign(char sign, float from, float to) void calc_relative_to(struct move_source_info *move_source) { - obs_data_t *settings = - obs_source_get_settings(move_source->move_filter.source); + obs_data_t *settings = obs_source_get_settings(move_source->move_filter.source); - move_source->rot_to = calc_sign( - obs_data_get_char(settings, "rot_sign"), move_source->rot_from, - (float)obs_data_get_double(settings, S_ROT)); + move_source->rot_to = calc_sign(obs_data_get_char(settings, "rot_sign"), move_source->rot_from, + (float)obs_data_get_double(settings, S_ROT)); obs_data_t *pos = obs_data_get_obj(settings, S_POS); - move_source->pos_to.x = calc_sign(obs_data_get_char(pos, "x_sign"), - move_source->pos_from.x, - (float)obs_data_get_double(pos, "x")); + move_source->pos_to.x = + calc_sign(obs_data_get_char(pos, "x_sign"), move_source->pos_from.x, (float)obs_data_get_double(pos, "x")); - move_source->pos_to.y = calc_sign(obs_data_get_char(pos, "y_sign"), - move_source->pos_from.y, - (float)obs_data_get_double(pos, "y")); + move_source->pos_to.y = + calc_sign(obs_data_get_char(pos, "y_sign"), move_source->pos_from.y, (float)obs_data_get_double(pos, "y")); obs_data_release(pos); obs_data_t *scale = obs_data_get_obj(settings, S_SCALE); - move_source->scale_to.x = calc_sign( - obs_data_get_char(scale, "x_sign"), move_source->scale_from.x, - (float)obs_data_get_double(scale, "x")); + move_source->scale_to.x = + calc_sign(obs_data_get_char(scale, "x_sign"), move_source->scale_from.x, (float)obs_data_get_double(scale, "x")); - move_source->scale_to.y = calc_sign( - obs_data_get_char(scale, "y_sign"), move_source->scale_from.y, - (float)obs_data_get_double(scale, "y")); + move_source->scale_to.y = + calc_sign(obs_data_get_char(scale, "y_sign"), move_source->scale_from.y, (float)obs_data_get_double(scale, "y")); obs_data_release(scale); obs_data_t *bounds = obs_data_get_obj(settings, S_BOUNDS); - move_source->bounds_to.x = calc_sign( - obs_data_get_char(bounds, "x_sign"), move_source->bounds_from.x, - (float)obs_data_get_double(bounds, "x")); + move_source->bounds_to.x = + calc_sign(obs_data_get_char(bounds, "x_sign"), move_source->bounds_from.x, (float)obs_data_get_double(bounds, "x")); - move_source->bounds_to.y = calc_sign( - obs_data_get_char(bounds, "y_sign"), move_source->bounds_from.y, - (float)obs_data_get_double(bounds, "y")); + move_source->bounds_to.y = + calc_sign(obs_data_get_char(bounds, "y_sign"), move_source->bounds_from.y, (float)obs_data_get_double(bounds, "y")); obs_data_release(bounds); obs_data_t *crop = obs_data_get_obj(settings, S_CROP); - move_source->crop_to.left = - (int)calc_sign(obs_data_get_char(crop, "left_sign"), - (float)move_source->crop_from.left, - (float)obs_data_get_int(crop, "left")); - move_source->crop_to.top = - (int)calc_sign(obs_data_get_char(crop, "top_sign"), - (float)move_source->crop_from.top, - (float)obs_data_get_int(crop, "top")); - move_source->crop_to.right = - (int)calc_sign(obs_data_get_char(crop, "right_sign"), - (float)move_source->crop_from.right, - (float)obs_data_get_int(crop, "right")); - move_source->crop_to.bottom = - (int)calc_sign(obs_data_get_char(crop, "bottom_sign"), - (float)move_source->crop_from.bottom, - (float)obs_data_get_int(crop, "bottom")); + move_source->crop_to.left = (int)calc_sign(obs_data_get_char(crop, "left_sign"), (float)move_source->crop_from.left, + (float)obs_data_get_int(crop, "left")); + move_source->crop_to.top = (int)calc_sign(obs_data_get_char(crop, "top_sign"), (float)move_source->crop_from.top, + (float)obs_data_get_int(crop, "top")); + move_source->crop_to.right = (int)calc_sign(obs_data_get_char(crop, "right_sign"), (float)move_source->crop_from.right, + (float)obs_data_get_int(crop, "right")); + move_source->crop_to.bottom = (int)calc_sign(obs_data_get_char(crop, "bottom_sign"), (float)move_source->crop_from.bottom, + (float)obs_data_get_int(crop, "bottom")); obs_data_release(crop); obs_data_release(settings); } -void move_source_media_action(struct move_source_info *move_source, - long long media_action, int64_t media_time) +void move_source_media_action(struct move_source_info *move_source, long long media_action, int64_t media_time) { if (media_action == MEDIA_ACTION_PLAY) { - const enum obs_media_state state = obs_source_media_get_state( - obs_sceneitem_get_source(move_source->scene_item)); + const enum obs_media_state state = obs_source_media_get_state(obs_sceneitem_get_source(move_source->scene_item)); if (state == OBS_MEDIA_STATE_PAUSED) { - obs_source_media_play_pause( - obs_sceneitem_get_source( - move_source->scene_item), - false); + obs_source_media_play_pause(obs_sceneitem_get_source(move_source->scene_item), false); } else if (state != OBS_MEDIA_STATE_PLAYING) { - obs_source_media_restart(obs_sceneitem_get_source( - move_source->scene_item)); + obs_source_media_restart(obs_sceneitem_get_source(move_source->scene_item)); } } else if (media_action == MEDIA_ACTION_PAUSE) { - obs_source_media_play_pause( - obs_sceneitem_get_source(move_source->scene_item), - true); + obs_source_media_play_pause(obs_sceneitem_get_source(move_source->scene_item), true); } else if (media_action == MEDIA_ACTION_STOP) { - obs_source_media_stop( - obs_sceneitem_get_source(move_source->scene_item)); + obs_source_media_stop(obs_sceneitem_get_source(move_source->scene_item)); } else if (media_action == MEDIA_ACTION_RESTART) { - obs_source_media_restart( - obs_sceneitem_get_source(move_source->scene_item)); + obs_source_media_restart(obs_sceneitem_get_source(move_source->scene_item)); } else if (media_action == MEDIA_ACTION_NEXT) { - obs_source_media_next( - obs_sceneitem_get_source(move_source->scene_item)); + obs_source_media_next(obs_sceneitem_get_source(move_source->scene_item)); } else if (media_action == MEDIA_ACTION_PREVIOUS) { - obs_source_media_previous( - obs_sceneitem_get_source(move_source->scene_item)); + obs_source_media_previous(obs_sceneitem_get_source(move_source->scene_item)); } else if (media_action == MEDIA_ACTION_PLAY_FROM) { - const int64_t duration = obs_source_media_get_duration( - obs_sceneitem_get_source(move_source->scene_item)); + const int64_t duration = obs_source_media_get_duration(obs_sceneitem_get_source(move_source->scene_item)); if (media_time < 0 && duration + media_time > 0) { const enum obs_media_state state = - obs_source_media_get_state( - obs_sceneitem_get_source( - move_source->scene_item)); + obs_source_media_get_state(obs_sceneitem_get_source(move_source->scene_item)); if (state == OBS_MEDIA_STATE_PAUSED) { - obs_source_media_play_pause( - obs_sceneitem_get_source( - move_source->scene_item), - false); + obs_source_media_play_pause(obs_sceneitem_get_source(move_source->scene_item), false); } else if (state != OBS_MEDIA_STATE_PLAYING) { - obs_source_media_restart( - obs_sceneitem_get_source( - move_source->scene_item)); + obs_source_media_restart(obs_sceneitem_get_source(move_source->scene_item)); } - obs_source_media_set_time( - obs_sceneitem_get_source( - move_source->scene_item), - duration + media_time); + obs_source_media_set_time(obs_sceneitem_get_source(move_source->scene_item), duration + media_time); } else if (media_time >= 0 && media_time <= duration) { const enum obs_media_state state = - obs_source_media_get_state( - obs_sceneitem_get_source( - move_source->scene_item)); + obs_source_media_get_state(obs_sceneitem_get_source(move_source->scene_item)); if (state == OBS_MEDIA_STATE_PAUSED) { - obs_source_media_play_pause( - obs_sceneitem_get_source( - move_source->scene_item), - false); + obs_source_media_play_pause(obs_sceneitem_get_source(move_source->scene_item), false); } else if (state != OBS_MEDIA_STATE_PLAYING) { - obs_source_media_restart( - obs_sceneitem_get_source( - move_source->scene_item)); + obs_source_media_restart(obs_sceneitem_get_source(move_source->scene_item)); } - obs_source_media_set_time( - obs_sceneitem_get_source( - move_source->scene_item), - media_time); + obs_source_media_set_time(obs_sceneitem_get_source(move_source->scene_item), media_time); } } else if (media_action == MEDIA_ACTION_PAUSE_AT) { - const int64_t duration = obs_source_media_get_duration( - obs_sceneitem_get_source(move_source->scene_item)); + const int64_t duration = obs_source_media_get_duration(obs_sceneitem_get_source(move_source->scene_item)); if (media_time < 0 && duration + media_time > 0) { - obs_source_media_set_time( - obs_sceneitem_get_source( - move_source->scene_item), - duration + media_time); - obs_source_media_play_pause( - obs_sceneitem_get_source( - move_source->scene_item), - true); + obs_source_media_set_time(obs_sceneitem_get_source(move_source->scene_item), duration + media_time); + obs_source_media_play_pause(obs_sceneitem_get_source(move_source->scene_item), true); } else if (media_time >= 0 && media_time <= duration) { - obs_source_media_set_time( - obs_sceneitem_get_source( - move_source->scene_item), - media_time); - obs_source_media_play_pause( - obs_sceneitem_get_source( - move_source->scene_item), - true); + obs_source_media_set_time(obs_sceneitem_get_source(move_source->scene_item), media_time); + obs_source_media_play_pause(obs_sceneitem_get_source(move_source->scene_item), true); } } } @@ -308,17 +236,14 @@ void move_source_ended(struct move_source_info *move_source); void move_source_start(struct move_source_info *move_source) { - if (!move_source->scene_item && move_source->source_name && - strlen(move_source->source_name)) { - obs_source_t *parent = - obs_filter_get_parent(move_source->move_filter.source); + if (!move_source->scene_item && move_source->source_name && strlen(move_source->source_name)) { + obs_source_t *parent = obs_filter_get_parent(move_source->move_filter.source); if (parent) { obs_scene_t *scene = obs_scene_from_source(parent); if (!scene) scene = obs_group_from_source(parent); if (scene) - obs_scene_enum_items(scene, find_sceneitem, - move_source); + obs_scene_enum_items(scene, find_sceneitem, move_source); } } if (!move_source->scene_item) @@ -326,33 +251,22 @@ void move_source_start(struct move_source_info *move_source) if (!move_filter_start_internal(&move_source->move_filter)) return; if ((move_source->change_order & CHANGE_ORDER_START) != 0) { - if ((move_source->change_order & CHANGE_ORDER_RELATIVE) != 0 && - move_source->order_position) { + if ((move_source->change_order & CHANGE_ORDER_RELATIVE) != 0 && move_source->order_position) { if (move_source->order_position > 0) { - for (int i = 0; i < move_source->order_position; - i++) { - obs_sceneitem_set_order( - move_source->scene_item, - OBS_ORDER_MOVE_UP); + for (int i = 0; i < move_source->order_position; i++) { + obs_sceneitem_set_order(move_source->scene_item, OBS_ORDER_MOVE_UP); } } else if (move_source->order_position < 0) { - for (int i = 0; i > move_source->order_position; - i--) { - obs_sceneitem_set_order( - move_source->scene_item, - OBS_ORDER_MOVE_DOWN); + for (int i = 0; i > move_source->order_position; i--) { + obs_sceneitem_set_order(move_source->scene_item, OBS_ORDER_MOVE_DOWN); } } - } else if ((move_source->change_order & - CHANGE_ORDER_ABSOLUTE) != 0) { - obs_sceneitem_set_order_position( - move_source->scene_item, - (int)move_source->order_position); + } else if ((move_source->change_order & CHANGE_ORDER_ABSOLUTE) != 0) { + obs_sceneitem_set_order_position(move_source->scene_item, (int)move_source->order_position); } } if ((move_source->change_visibility == CHANGE_VISIBILITY_SHOW_START || - move_source->change_visibility == - CHANGE_VISIBILITY_SHOW_START_END || + move_source->change_visibility == CHANGE_VISIBILITY_SHOW_START_END || move_source->change_visibility == CHANGE_VISIBILITY_TOGGLE) && !obs_sceneitem_visible(move_source->scene_item)) { obs_sceneitem_set_visible(move_source->scene_item, true); @@ -361,60 +275,39 @@ void move_source_start(struct move_source_info *move_source) move_source->visibility_toggled = false; } if (move_source->change_visibility == CHANGE_VISIBILITY_TOGGLE_START) { - obs_sceneitem_set_visible( - move_source->scene_item, - !obs_sceneitem_visible(move_source->scene_item)); - } else if (move_source->change_visibility == - CHANGE_VISIBILITY_HIDE_START || - move_source->change_visibility == - CHANGE_VISIBILITY_HIDE_START_END) { + obs_sceneitem_set_visible(move_source->scene_item, !obs_sceneitem_visible(move_source->scene_item)); + } else if (move_source->change_visibility == CHANGE_VISIBILITY_HIDE_START || + move_source->change_visibility == CHANGE_VISIBILITY_HIDE_START_END) { obs_sceneitem_set_visible(move_source->scene_item, false); } - move_source_media_action(move_source, move_source->media_action_start, - move_source->media_time_start); - - if ((move_source->mute_action == MUTE_ACTION_MUTE_START || - move_source->mute_action == MUTE_ACTION_MUTE_DURING) && - !obs_source_muted( - obs_sceneitem_get_source(move_source->scene_item))) { - obs_source_set_muted( - obs_sceneitem_get_source(move_source->scene_item), - true); + move_source_media_action(move_source, move_source->media_action_start, move_source->media_time_start); + + if ((move_source->mute_action == MUTE_ACTION_MUTE_START || move_source->mute_action == MUTE_ACTION_MUTE_DURING) && + !obs_source_muted(obs_sceneitem_get_source(move_source->scene_item))) { + obs_source_set_muted(obs_sceneitem_get_source(move_source->scene_item), true); } else if ((move_source->mute_action == MUTE_ACTION_UNMUTE_START || move_source->mute_action == MUTE_ACTION_UNMUTE_DURING) && - obs_source_muted( - obs_sceneitem_get_source(move_source->scene_item))) { - obs_source_set_muted( - obs_sceneitem_get_source(move_source->scene_item), - false); + obs_source_muted(obs_sceneitem_get_source(move_source->scene_item))) { + obs_source_set_muted(obs_sceneitem_get_source(move_source->scene_item), false); } if (!move_source->move_filter.reverse) { - move_source->rot_from = - obs_sceneitem_get_rot(move_source->scene_item); - obs_sceneitem_get_pos(move_source->scene_item, - &move_source->pos_from); - obs_sceneitem_get_scale(move_source->scene_item, - &move_source->scale_from); - obs_sceneitem_get_bounds(move_source->scene_item, - &move_source->bounds_from); - obs_sceneitem_get_crop(move_source->scene_item, - &move_source->crop_from); - obs_source_t *scene_source = obs_scene_get_source( - obs_sceneitem_get_scene(move_source->scene_item)); + move_source->rot_from = obs_sceneitem_get_rot(move_source->scene_item); + obs_sceneitem_get_pos(move_source->scene_item, &move_source->pos_from); + obs_sceneitem_get_scale(move_source->scene_item, &move_source->scale_from); + obs_sceneitem_get_bounds(move_source->scene_item, &move_source->bounds_from); + obs_sceneitem_get_crop(move_source->scene_item, &move_source->crop_from); + obs_source_t *scene_source = obs_scene_get_source(obs_sceneitem_get_scene(move_source->scene_item)); move_source->canvas_width = obs_source_get_width(scene_source); - move_source->canvas_height = - obs_source_get_height(scene_source); + move_source->canvas_height = obs_source_get_height(scene_source); calc_relative_to(move_source); - move_source->audio_fade_from = obs_source_get_volume( - obs_sceneitem_get_source(move_source->scene_item)); + move_source->audio_fade_from = obs_source_get_volume(obs_sceneitem_get_source(move_source->scene_item)); } } -bool move_source_start_button(obs_properties_t *props, obs_property_t *property, - void *data) +bool move_source_start_button(obs_properties_t *props, obs_property_t *property, void *data) { struct move_source_info *move_source = data; move_source_start(move_source); @@ -431,11 +324,9 @@ void move_source_stop(struct move_source_info *move_source) void move_source_source_activate(void *data, calldata_t *call_data) { struct move_source_info *move_source = data; - if (move_source->move_filter.start_trigger == - START_TRIGGER_SOURCE_ACTIVATE) + if (move_source->move_filter.start_trigger == START_TRIGGER_SOURCE_ACTIVATE) move_source_start(move_source); - if (move_source->move_filter.stop_trigger == - START_TRIGGER_SOURCE_ACTIVATE) + if (move_source->move_filter.stop_trigger == START_TRIGGER_SOURCE_ACTIVATE) move_source_stop(move_source); UNUSED_PARAMETER(call_data); } @@ -443,11 +334,9 @@ void move_source_source_activate(void *data, calldata_t *call_data) void move_source_source_deactivate(void *data, calldata_t *call_data) { struct move_source_info *move_source = data; - if (move_source->move_filter.start_trigger == - START_TRIGGER_SOURCE_DEACTIVATE) + if (move_source->move_filter.start_trigger == START_TRIGGER_SOURCE_DEACTIVATE) move_source_start(move_source); - if (move_source->move_filter.stop_trigger == - START_TRIGGER_SOURCE_DEACTIVATE) + if (move_source->move_filter.stop_trigger == START_TRIGGER_SOURCE_DEACTIVATE) move_source_stop(move_source); UNUSED_PARAMETER(call_data); } @@ -475,11 +364,9 @@ void move_source_source_hide(void *data, calldata_t *call_data) void move_source_source_media_started(void *data, calldata_t *call_data) { struct move_source_info *move_source = data; - if (move_source->move_filter.start_trigger == - START_TRIGGER_MEDIA_STARTED) + if (move_source->move_filter.start_trigger == START_TRIGGER_MEDIA_STARTED) move_source_start(move_source); - if (move_source->move_filter.stop_trigger == - START_TRIGGER_MEDIA_STARTED) + if (move_source->move_filter.stop_trigger == START_TRIGGER_MEDIA_STARTED) move_source_stop(move_source); UNUSED_PARAMETER(call_data); } @@ -501,38 +388,22 @@ void move_source_source_remove(void *data, calldata_t *call_data) UNUSED_PARAMETER(call_data); } -void move_source_source_changed(struct move_source_info *move_source, - const char *source_name) +void move_source_source_changed(struct move_source_info *move_source, const char *source_name) { - obs_source_t *source = - move_source->source_name && strlen(move_source->source_name) - ? obs_get_source_by_name(move_source->source_name) - : NULL; + obs_source_t *source = move_source->source_name && strlen(move_source->source_name) + ? obs_get_source_by_name(move_source->source_name) + : NULL; if (source) { signal_handler_t *sh = obs_source_get_signal_handler(source); if (sh) { - signal_handler_disconnect(sh, "activate", - move_source_source_activate, - move_source); - signal_handler_disconnect(sh, "deactivate", - move_source_source_deactivate, - move_source); - signal_handler_disconnect(sh, "show", - move_source_source_show, - move_source); - signal_handler_disconnect(sh, "hide", - move_source_source_hide, - move_source); - signal_handler_disconnect( - sh, "media_started", - move_source_source_media_started, move_source); - signal_handler_disconnect( - sh, "media_ended", - move_source_source_media_ended, move_source); - signal_handler_disconnect(sh, "remove", - move_source_source_remove, - move_source); + signal_handler_disconnect(sh, "activate", move_source_source_activate, move_source); + signal_handler_disconnect(sh, "deactivate", move_source_source_deactivate, move_source); + signal_handler_disconnect(sh, "show", move_source_source_show, move_source); + signal_handler_disconnect(sh, "hide", move_source_source_hide, move_source); + signal_handler_disconnect(sh, "media_started", move_source_source_media_started, move_source); + signal_handler_disconnect(sh, "media_ended", move_source_source_media_ended, move_source); + signal_handler_disconnect(sh, "remove", move_source_source_remove, move_source); } obs_source_release(source); } @@ -544,47 +415,26 @@ void move_source_source_changed(struct move_source_info *move_source, if (source) { signal_handler_t *sh = obs_source_get_signal_handler(source); if (sh) { - signal_handler_connect(sh, "activate", - move_source_source_activate, - move_source); - signal_handler_connect(sh, "deactivate", - move_source_source_deactivate, - move_source); - signal_handler_connect(sh, "show", - move_source_source_show, - move_source); - signal_handler_connect(sh, "hide", - move_source_source_hide, - move_source); - signal_handler_connect(sh, "media_started", - move_source_source_media_started, - move_source); - signal_handler_connect(sh, "media_ended", - move_source_source_media_ended, - move_source); - signal_handler_connect(sh, "remove", - move_source_source_remove, - move_source); + signal_handler_connect(sh, "activate", move_source_source_activate, move_source); + signal_handler_connect(sh, "deactivate", move_source_source_deactivate, move_source); + signal_handler_connect(sh, "show", move_source_source_show, move_source); + signal_handler_connect(sh, "hide", move_source_source_hide, move_source); + signal_handler_connect(sh, "media_started", move_source_source_media_started, move_source); + signal_handler_connect(sh, "media_ended", move_source_source_media_ended, move_source); + signal_handler_connect(sh, "remove", move_source_source_remove, move_source); move_source->source_name = bstrdup(source_name); } obs_source_release(source); } move_source->scene_item = NULL; - obs_source_t *parent = - obs_filter_get_parent(move_source->move_filter.source); + obs_source_t *parent = obs_filter_get_parent(move_source->move_filter.source); if (parent) { signal_handler_t *sh = obs_source_get_signal_handler(parent); if (sh) { - signal_handler_disconnect(sh, "item_remove", - move_source_item_remove, - move_source); - signal_handler_disconnect(sh, "remove", - move_source_scene_remove, - move_source); - signal_handler_disconnect(sh, "destroy", - move_source_scene_remove, - move_source); + signal_handler_disconnect(sh, "item_remove", move_source_item_remove, move_source); + signal_handler_disconnect(sh, "remove", move_source_scene_remove, move_source); + signal_handler_disconnect(sh, "destroy", move_source_scene_remove, move_source); } } obs_scene_t *scene = obs_scene_from_source(parent); @@ -594,8 +444,7 @@ void move_source_source_changed(struct move_source_info *move_source, obs_scene_enum_items(scene, find_sceneitem, move_source); } -static void obs_data_set_sign(obs_data_t *settings, const char *name, - const char *val) +static void obs_data_set_sign(obs_data_t *settings, const char *name, const char *val) { obs_data_t *obj = obs_data_get_obj(settings, name); if (obj) { @@ -610,35 +459,26 @@ void move_source_update(void *data, obs_data_t *settings) struct move_source_info *move_source = data; const char *source_name = obs_data_get_string(settings, S_SOURCE); - if (!move_source->source_name || - strcmp(move_source->source_name, source_name) != 0) { + if (!move_source->source_name || strcmp(move_source->source_name, source_name) != 0) { move_source_source_changed(move_source, source_name); } move_filter_update(&move_source->move_filter, settings); - move_source->change_visibility = - obs_data_get_int(settings, S_CHANGE_VISIBILITY); - move_source->curve = - (float)obs_data_get_double(settings, S_CURVE_MATCH); + move_source->change_visibility = obs_data_get_int(settings, S_CHANGE_VISIBILITY); + move_source->curve = (float)obs_data_get_double(settings, S_CURVE_MATCH); move_source->transform = obs_data_get_bool(settings, S_TRANSFORM); - if (obs_data_has_user_value(settings, "crop_left") || - obs_data_has_user_value(settings, "crop_top") || - obs_data_has_user_value(settings, "crop_right") || - obs_data_has_user_value(settings, "crop_bottom")) { + if (obs_data_has_user_value(settings, "crop_left") || obs_data_has_user_value(settings, "crop_top") || + obs_data_has_user_value(settings, "crop_right") || obs_data_has_user_value(settings, "crop_bottom")) { obs_data_t *obj = obs_data_get_obj(settings, S_CROP); if (!obj) { obj = obs_data_create(); obs_data_set_obj(settings, S_CROP, obj); } - obs_data_set_int(obj, "left", - obs_data_get_int(settings, "crop_left")); - obs_data_set_int(obj, "top", - obs_data_get_int(settings, "crop_top")); - obs_data_set_int(obj, "right", - obs_data_get_int(settings, "crop_right")); - obs_data_set_int(obj, "bottom", - obs_data_get_int(settings, "crop_bottom")); + obs_data_set_int(obj, "left", obs_data_get_int(settings, "crop_left")); + obs_data_set_int(obj, "top", obs_data_get_int(settings, "crop_top")); + obs_data_set_int(obj, "right", obs_data_get_int(settings, "crop_right")); + obs_data_set_int(obj, "bottom", obs_data_get_int(settings, "crop_bottom")); obs_data_release(obj); obs_data_unset_user_value(settings, "crop_left"); obs_data_unset_user_value(settings, "crop_top"); @@ -665,30 +505,22 @@ void move_source_update(void *data, obs_data_t *settings) calc_relative_to(move_source); move_source->change_order = obs_data_get_int(settings, S_CHANGE_ORDER); - move_source->order_position = - obs_data_get_int(settings, S_ORDER_POSITION); - - move_source->media_action_start = - obs_data_get_int(settings, S_MEDIA_ACTION_START); - move_source->media_time_start = - obs_data_get_int(settings, S_MEDIA_ACTION_START_TIME); - move_source->media_action_end = - obs_data_get_int(settings, S_MEDIA_ACTION_END); - move_source->media_time_end = - obs_data_get_int(settings, S_MEDIA_ACTION_END_TIME); + move_source->order_position = obs_data_get_int(settings, S_ORDER_POSITION); + + move_source->media_action_start = obs_data_get_int(settings, S_MEDIA_ACTION_START); + move_source->media_time_start = obs_data_get_int(settings, S_MEDIA_ACTION_START_TIME); + move_source->media_action_end = obs_data_get_int(settings, S_MEDIA_ACTION_END); + move_source->media_time_end = obs_data_get_int(settings, S_MEDIA_ACTION_END_TIME); move_source->mute_action = obs_data_get_int(settings, S_MUTE_ACTION); move_source->audio_fade = obs_data_get_bool(settings, S_AUDIO_FADE); - move_source->audio_fade_to = - (float)obs_data_get_double(settings, S_AUDIO_FADE_PERCENT) / - 100.0f; + move_source->audio_fade_to = (float)obs_data_get_double(settings, S_AUDIO_FADE_PERCENT) / 100.0f; if (move_source->move_filter.start_trigger == START_TRIGGER_LOAD) { move_source_start(move_source); } } -void update_transform_text(struct move_source_info *move_source, - obs_data_t *settings) +void update_transform_text(struct move_source_info *move_source, obs_data_t *settings) { obs_data_t *pos = obs_data_get_obj(settings, S_POS); obs_data_t *scale = obs_data_get_obj(settings, S_SCALE); @@ -697,78 +529,44 @@ void update_transform_text(struct move_source_info *move_source, char transform_text[500]; if (move_source->scene_item) { - if (obs_sceneitem_get_bounds_type(move_source->scene_item) == - OBS_BOUNDS_NONE) { - snprintf( - transform_text, 500, - "pos: x%c%.1f y%c%.1f rot:%c%.1f scale: x%c%.3f y%c%.3f crop: l%c%d t%c%d r%c%d b%c%d", - obs_data_get_char(pos, "x_sign"), - obs_data_get_double(pos, "x"), - obs_data_get_char(pos, "y_sign"), - obs_data_get_double(pos, "y"), - obs_data_get_char(settings, "rot_sign"), - obs_data_get_double(settings, S_ROT), - obs_data_get_char(scale, "x_sign"), - obs_data_get_double(scale, "x"), - obs_data_get_char(scale, "y_sign"), - obs_data_get_double(scale, "y"), - obs_data_get_char(crop, "left_sign"), - (int)obs_data_get_int(crop, "left"), - obs_data_get_char(crop, "top_sign"), - (int)obs_data_get_int(crop, "top"), - obs_data_get_char(crop, "right_sign"), - (int)obs_data_get_int(crop, "right"), - obs_data_get_char(crop, "bottom_sign"), - (int)obs_data_get_int(crop, "bottom")); + if (obs_sceneitem_get_bounds_type(move_source->scene_item) == OBS_BOUNDS_NONE) { + snprintf(transform_text, 500, + "pos: x%c%.1f y%c%.1f rot:%c%.1f scale: x%c%.3f y%c%.3f crop: l%c%d t%c%d r%c%d b%c%d", + obs_data_get_char(pos, "x_sign"), obs_data_get_double(pos, "x"), obs_data_get_char(pos, "y_sign"), + obs_data_get_double(pos, "y"), obs_data_get_char(settings, "rot_sign"), + obs_data_get_double(settings, S_ROT), obs_data_get_char(scale, "x_sign"), + obs_data_get_double(scale, "x"), obs_data_get_char(scale, "y_sign"), + obs_data_get_double(scale, "y"), obs_data_get_char(crop, "left_sign"), + (int)obs_data_get_int(crop, "left"), obs_data_get_char(crop, "top_sign"), + (int)obs_data_get_int(crop, "top"), obs_data_get_char(crop, "right_sign"), + (int)obs_data_get_int(crop, "right"), obs_data_get_char(crop, "bottom_sign"), + (int)obs_data_get_int(crop, "bottom")); } else { - snprintf( - transform_text, 500, - "pos: x%c%.1f y%c%.1f rot:%c%.1f bounds: x%c%.3f y%c%.3f crop: l%c%d t%c%d r%c%d b%c%d", - obs_data_get_char(pos, "x_sign"), - obs_data_get_double(pos, "x"), - obs_data_get_char(pos, "y_sign"), - obs_data_get_double(pos, "y"), - obs_data_get_char(settings, "rot_sign"), - obs_data_get_double(settings, S_ROT), - obs_data_get_char(bounds, "x_sign"), - obs_data_get_double(bounds, "x"), - obs_data_get_char(bounds, "y_sign"), - obs_data_get_double(bounds, "y"), - obs_data_get_char(crop, "left_sign"), - (int)obs_data_get_int(crop, "left"), - obs_data_get_char(crop, "top_sign"), - (int)obs_data_get_int(crop, "top"), - obs_data_get_char(crop, "right_sign"), - (int)obs_data_get_int(crop, "right"), - obs_data_get_char(crop, "bottom_sign"), - (int)obs_data_get_int(crop, "bottom")); + snprintf(transform_text, 500, + "pos: x%c%.1f y%c%.1f rot:%c%.1f bounds: x%c%.3f y%c%.3f crop: l%c%d t%c%d r%c%d b%c%d", + obs_data_get_char(pos, "x_sign"), obs_data_get_double(pos, "x"), obs_data_get_char(pos, "y_sign"), + obs_data_get_double(pos, "y"), obs_data_get_char(settings, "rot_sign"), + obs_data_get_double(settings, S_ROT), obs_data_get_char(bounds, "x_sign"), + obs_data_get_double(bounds, "x"), obs_data_get_char(bounds, "y_sign"), + obs_data_get_double(bounds, "y"), obs_data_get_char(crop, "left_sign"), + (int)obs_data_get_int(crop, "left"), obs_data_get_char(crop, "top_sign"), + (int)obs_data_get_int(crop, "top"), obs_data_get_char(crop, "right_sign"), + (int)obs_data_get_int(crop, "right"), obs_data_get_char(crop, "bottom_sign"), + (int)obs_data_get_int(crop, "bottom")); } } else { snprintf( transform_text, 500, "pos: x%c%.1f y%c%.1f rot:%c%.1f scale: x%c%.3f y%c%.3f bounds: x%c%.3f y%c%.3f crop: l%c%d t%c%d r%c%d b%c%d", - obs_data_get_char(pos, "x_sign"), - obs_data_get_double(pos, "x"), - obs_data_get_char(pos, "y_sign"), - obs_data_get_double(pos, "y"), - obs_data_get_char(settings, "rot_sign"), - obs_data_get_double(settings, S_ROT), - obs_data_get_char(scale, "x_sign"), - obs_data_get_double(scale, "x"), - obs_data_get_char(scale, "y_sign"), - obs_data_get_double(scale, "y"), - obs_data_get_char(bounds, "x_sign"), - obs_data_get_double(bounds, "x"), - obs_data_get_char(bounds, "y_sign"), - obs_data_get_double(bounds, "y"), - obs_data_get_char(crop, "left_sign"), - (int)obs_data_get_int(crop, "left"), - obs_data_get_char(crop, "top_sign"), - (int)obs_data_get_int(crop, "top"), - obs_data_get_char(crop, "right_sign"), - (int)obs_data_get_int(crop, "right"), - obs_data_get_char(crop, "bottom_sign"), - (int)obs_data_get_int(crop, "bottom")); + obs_data_get_char(pos, "x_sign"), obs_data_get_double(pos, "x"), obs_data_get_char(pos, "y_sign"), + obs_data_get_double(pos, "y"), obs_data_get_char(settings, "rot_sign"), + obs_data_get_double(settings, S_ROT), obs_data_get_char(scale, "x_sign"), obs_data_get_double(scale, "x"), + obs_data_get_char(scale, "y_sign"), obs_data_get_double(scale, "y"), obs_data_get_char(bounds, "x_sign"), + obs_data_get_double(bounds, "x"), obs_data_get_char(bounds, "y_sign"), obs_data_get_double(bounds, "y"), + obs_data_get_char(crop, "left_sign"), (int)obs_data_get_int(crop, "left"), + obs_data_get_char(crop, "top_sign"), (int)obs_data_get_int(crop, "top"), + obs_data_get_char(crop, "right_sign"), (int)obs_data_get_int(crop, "right"), + obs_data_get_char(crop, "bottom_sign"), (int)obs_data_get_int(crop, "bottom")); } obs_data_set_string(settings, S_TRANSFORM_TEXT, transform_text); @@ -790,13 +588,11 @@ void move_source_source_rename(void *data, calldata_t *call_data) struct move_source_info *move_source = data; const char *new_name = calldata_string(call_data, "new_name"); const char *prev_name = calldata_string(call_data, "prev_name"); - obs_data_t *settings = - obs_source_get_settings(move_source->move_filter.source); + obs_data_t *settings = obs_source_get_settings(move_source->move_filter.source); if (!settings || !new_name || !prev_name) return; const char *source_name = obs_data_get_string(settings, S_SOURCE); - if (source_name && strlen(source_name) && - strcmp(source_name, prev_name) == 0) { + if (source_name && strlen(source_name) && strcmp(source_name, prev_name) == 0) { obs_data_set_string(settings, S_SOURCE, new_name); } obs_data_release(settings); @@ -810,15 +606,11 @@ obs_source_t *move_source_get_source(void *data) static void *move_source_create(obs_data_t *settings, obs_source_t *source) { - struct move_source_info *move_source = - bzalloc(sizeof(struct move_source_info)); - move_filter_init(&move_source->move_filter, source, - (void (*)(void *))move_source_start); - move_source->move_filter.get_alternative_source = - move_source_get_source; + struct move_source_info *move_source = bzalloc(sizeof(struct move_source_info)); + move_filter_init(&move_source->move_filter, source, (void (*)(void *))move_source_start); + move_source->move_filter.get_alternative_source = move_source_get_source; move_source_update(move_source, settings); - signal_handler_connect(obs_get_signal_handler(), "source_rename", - move_source_source_rename, move_source); + signal_handler_connect(obs_get_signal_handler(), "source_rename", move_source_source_rename, move_source); return move_source; } @@ -826,51 +618,34 @@ static void *move_source_create(obs_data_t *settings, obs_source_t *source) static void move_source_destroy(void *data) { struct move_source_info *move_source = data; - signal_handler_disconnect(obs_get_signal_handler(), "source_rename", - move_source_source_rename, move_source); + signal_handler_disconnect(obs_get_signal_handler(), "source_rename", move_source_source_rename, move_source); - obs_source_t *parent = - obs_filter_get_parent(move_source->move_filter.source); + obs_source_t *parent = obs_filter_get_parent(move_source->move_filter.source); if (parent) { signal_handler_t *sh = obs_source_get_signal_handler(parent); - signal_handler_disconnect(sh, "item_remove", - move_source_item_remove, move_source); - signal_handler_disconnect(sh, "remove", move_source_scene_remove, - move_source); - signal_handler_disconnect(sh, "destroy", - move_source_scene_remove, move_source); + signal_handler_disconnect(sh, "item_remove", move_source_item_remove, move_source); + signal_handler_disconnect(sh, "remove", move_source_scene_remove, move_source); + signal_handler_disconnect(sh, "destroy", move_source_scene_remove, move_source); } obs_source_t *source = NULL; if (move_source->scene_item) { source = obs_sceneitem_get_source(move_source->scene_item); } - if (!source && move_source->source_name && - strlen(move_source->source_name)) { + if (!source && move_source->source_name && strlen(move_source->source_name)) { source = obs_get_source_by_name(move_source->source_name); obs_source_release(source); } if (source) { signal_handler_t *sh = obs_source_get_signal_handler(source); if (sh) { - signal_handler_disconnect(sh, "activate", - move_source_source_activate, - data); - signal_handler_disconnect(sh, "deactivate", - move_source_source_deactivate, - data); - signal_handler_disconnect( - sh, "show", move_source_source_show, data); - signal_handler_disconnect( - sh, "hide", move_source_source_hide, data); - signal_handler_disconnect( - sh, "media_started", - move_source_source_media_started, data); - signal_handler_disconnect( - sh, "media_ended", - move_source_source_media_ended, data); - signal_handler_disconnect( - sh, "remove", move_source_source_remove, data); + signal_handler_disconnect(sh, "activate", move_source_source_activate, data); + signal_handler_disconnect(sh, "deactivate", move_source_source_deactivate, data); + signal_handler_disconnect(sh, "show", move_source_source_show, data); + signal_handler_disconnect(sh, "hide", move_source_source_hide, data); + signal_handler_disconnect(sh, "media_started", move_source_source_media_started, data); + signal_handler_disconnect(sh, "media_ended", move_source_source_media_ended, data); + signal_handler_disconnect(sh, "remove", move_source_source_remove, data); } } move_source->scene_item = NULL; @@ -879,9 +654,7 @@ static void move_source_destroy(void *data) bfree(move_source); } -static void obs_data_set_vec2_sign(obs_data_t *data, const char *name, - const struct vec2 *val, char x_sign, - char y_sign) +static void obs_data_set_vec2_sign(obs_data_t *data, const char *name, const struct vec2 *val, char x_sign, char y_sign) { obs_data_t *obj = obs_data_create(); obs_data_set_double(obj, "x", val->x); @@ -892,10 +665,8 @@ static void obs_data_set_vec2_sign(obs_data_t *data, const char *name, obs_data_release(obj); } -static void obs_data_set_crop_sign(obs_data_t *settings, const char *name, - struct obs_sceneitem_crop *crop, - char crop_left_sign, char crop_top_sign, - char crop_right_sign, char crop_bottom_sign) +static void obs_data_set_crop_sign(obs_data_t *settings, const char *name, struct obs_sceneitem_crop *crop, char crop_left_sign, + char crop_top_sign, char crop_right_sign, char crop_bottom_sign) { obs_data_t *obj = obs_data_create(); obs_data_set_double(obj, "left", crop->left); @@ -910,31 +681,26 @@ static void obs_data_set_crop_sign(obs_data_t *settings, const char *name, obs_data_release(obj); } -bool move_source_get_transform(obs_properties_t *props, - obs_property_t *property, void *data) +bool move_source_get_transform(obs_properties_t *props, obs_property_t *property, void *data) { UNUSED_PARAMETER(props); UNUSED_PARAMETER(property); struct move_source_info *move_source = data; bool settings_changed = false; - if (!move_source->scene_item && move_source->source_name && - strlen(move_source->source_name)) { - obs_source_t *parent = - obs_filter_get_parent(move_source->move_filter.source); + if (!move_source->scene_item && move_source->source_name && strlen(move_source->source_name)) { + obs_source_t *parent = obs_filter_get_parent(move_source->move_filter.source); if (parent) { obs_scene_t *scene = obs_scene_from_source(parent); if (!scene) scene = obs_group_from_source(parent); if (scene) - obs_scene_enum_items(scene, find_sceneitem, - data); + obs_scene_enum_items(scene, find_sceneitem, data); } } if (!move_source->scene_item) return settings_changed; settings_changed = true; - obs_data_t *settings = - obs_source_get_settings(move_source->move_filter.source); + obs_data_t *settings = obs_source_get_settings(move_source->move_filter.source); struct vec2 pos; obs_sceneitem_get_pos(move_source->scene_item, &pos); struct vec2 scale; @@ -943,8 +709,7 @@ bool move_source_get_transform(obs_properties_t *props, obs_sceneitem_get_bounds(move_source->scene_item, &bounds); struct obs_sceneitem_crop crop; obs_sceneitem_get_crop(move_source->scene_item, &crop); - obs_data_set_double(settings, S_ROT, - obs_sceneitem_get_rot(move_source->scene_item)); + obs_data_set_double(settings, S_ROT, obs_sceneitem_get_rot(move_source->scene_item)); obs_data_set_char(settings, "rot_sign", ' '); obs_data_set_vec2_sign(settings, S_POS, &pos, ' ', ' '); obs_data_set_vec2_sign(settings, S_SCALE, &scale, ' ', ' '); @@ -958,15 +723,13 @@ bool move_source_get_transform(obs_properties_t *props, return settings_changed; } -bool move_source_relative(obs_properties_t *props, obs_property_t *property, - void *data) +bool move_source_relative(obs_properties_t *props, obs_property_t *property, void *data) { UNUSED_PARAMETER(props); UNUSED_PARAMETER(property); struct move_source_info *move_source = data; bool settings_changed = true; - obs_data_t *settings = - obs_source_get_settings(move_source->move_filter.source); + obs_data_t *settings = obs_source_get_settings(move_source->move_filter.source); struct vec2 pos; pos.x = 0.0f; pos.y = 0.0f; @@ -991,8 +754,7 @@ bool move_source_relative(obs_properties_t *props, obs_property_t *property, return settings_changed; } -void prop_list_add_move_source_filter(obs_source_t *parent, obs_source_t *child, - void *data) +void prop_list_add_move_source_filter(obs_source_t *parent, obs_source_t *child, void *data) { UNUSED_PARAMETER(parent); if (!is_move_filter(obs_source_get_unversioned_id(child))) @@ -1002,47 +764,34 @@ void prop_list_add_move_source_filter(obs_source_t *parent, obs_source_t *child, obs_property_list_add_string(p, name, name); } -bool move_source_changed(void *data, obs_properties_t *props, - obs_property_t *property, obs_data_t *settings) +bool move_source_changed(void *data, obs_properties_t *props, obs_property_t *property, obs_data_t *settings) { struct move_source_info *move_source = data; bool refresh = false; const char *source_name = obs_data_get_string(settings, S_SOURCE); - if (move_source->source_name && - strcmp(move_source->source_name, source_name) == 0) + if (move_source->source_name && strcmp(move_source->source_name, source_name) == 0) return refresh; move_source_source_changed(move_source, source_name); - obs_source_t *parent = - obs_filter_get_parent(move_source->move_filter.source); + obs_source_t *parent = obs_filter_get_parent(move_source->move_filter.source); obs_property_t *p = obs_properties_get(props, S_SIMULTANEOUS_MOVE); if (p) { obs_property_list_clear(p); - obs_property_list_add_string( - p, obs_module_text("SimultaneousMove.None"), ""); - obs_source_enum_filters(parent, - prop_list_add_move_source_filter, p); - obs_source_t *source = - obs_sceneitem_get_source(move_source->scene_item); + obs_property_list_add_string(p, obs_module_text("SimultaneousMove.None"), ""); + obs_source_enum_filters(parent, prop_list_add_move_source_filter, p); + obs_source_t *source = obs_sceneitem_get_source(move_source->scene_item); if (source) - obs_source_enum_filters( - source, prop_list_add_move_source_filter, p); + obs_source_enum_filters(source, prop_list_add_move_source_filter, p); } p = obs_properties_get(props, S_NEXT_MOVE); if (p) { obs_property_list_clear(p); - obs_property_list_add_string( - p, obs_module_text("NextMove.None"), ""); - obs_property_list_add_string( - p, obs_module_text("NextMove.Reverse"), - NEXT_MOVE_REVERSE); - obs_source_enum_filters(parent, - prop_list_add_move_source_filter, p); - obs_source_t *source = - obs_sceneitem_get_source(move_source->scene_item); + obs_property_list_add_string(p, obs_module_text("NextMove.None"), ""); + obs_property_list_add_string(p, obs_module_text("NextMove.Reverse"), NEXT_MOVE_REVERSE); + obs_source_enum_filters(parent, prop_list_add_move_source_filter, p); + obs_source_t *source = obs_sceneitem_get_source(move_source->scene_item); if (source) - obs_source_enum_filters( - source, prop_list_add_move_source_filter, p); + obs_source_enum_filters(source, prop_list_add_move_source_filter, p); } obs_source_t *source = obs_get_source_by_name(source_name); @@ -1065,427 +814,260 @@ bool move_source_changed(void *data, obs_properties_t *props, return refresh; } -bool prop_list_add_sceneitem(obs_scene_t *scene, obs_sceneitem_t *item, - void *data); +bool prop_list_add_sceneitem(obs_scene_t *scene, obs_sceneitem_t *item, void *data); -bool move_source_transform_text_changed(void *data, obs_properties_t *props, - obs_property_t *property, - obs_data_t *settings) +bool move_source_transform_text_changed(void *data, obs_properties_t *props, obs_property_t *property, obs_data_t *settings) { UNUSED_PARAMETER(props); UNUSED_PARAMETER(property); struct move_source_info *move_source = data; - const char *transform_text = - obs_data_get_string(settings, S_TRANSFORM_TEXT); + const char *transform_text = obs_data_get_string(settings, S_TRANSFORM_TEXT); struct vec2 pos; float rot; struct vec2 scale; struct vec2 bounds; struct obs_sceneitem_crop crop; - char pos_x_sign, pos_y_sign, rot_sign, scale_x_sign, scale_y_sign, - bounds_x_sign, bounds_y_sign, crop_left_sign, crop_top_sign, - crop_right_sign, crop_bottom_sign; + char pos_x_sign, pos_y_sign, rot_sign, scale_x_sign, scale_y_sign, bounds_x_sign, bounds_y_sign, crop_left_sign, + crop_top_sign, crop_right_sign, crop_bottom_sign; if (move_source->scene_item) { - if (obs_sceneitem_get_bounds_type(move_source->scene_item) == - OBS_BOUNDS_NONE) { - if (sscanf(transform_text, - "pos: x%c%f y%c%f rot:%c%f scale: x%c%f y%c%f crop: l%c%d t%c%d r%c%d b%c%d", - &pos_x_sign, &pos.x, &pos_y_sign, &pos.y, - &rot_sign, &rot, &scale_x_sign, &scale.x, - &scale_y_sign, &scale.y, &crop_left_sign, - &crop.left, &crop_top_sign, &crop.top, - &crop_right_sign, &crop.right, - &crop_bottom_sign, &crop.bottom) != 18) { + if (obs_sceneitem_get_bounds_type(move_source->scene_item) == OBS_BOUNDS_NONE) { + if (sscanf(transform_text, "pos: x%c%f y%c%f rot:%c%f scale: x%c%f y%c%f crop: l%c%d t%c%d r%c%d b%c%d", + &pos_x_sign, &pos.x, &pos_y_sign, &pos.y, &rot_sign, &rot, &scale_x_sign, &scale.x, + &scale_y_sign, &scale.y, &crop_left_sign, &crop.left, &crop_top_sign, &crop.top, + &crop_right_sign, &crop.right, &crop_bottom_sign, &crop.bottom) != 18) { update_transform_text(move_source, settings); return true; } - obs_data_set_vec2_sign(settings, S_SCALE, &scale, - scale_x_sign, scale_y_sign); + obs_data_set_vec2_sign(settings, S_SCALE, &scale, scale_x_sign, scale_y_sign); } else { - if (sscanf(transform_text, - "pos: x%c%f y%c%f rot:%c%f bounds: x%c%f y%c%f crop: l%c%d t%c%d r%c%d b%c%d", - &pos_x_sign, &pos.x, &pos_y_sign, &pos.y, - &rot_sign, &rot, &bounds_x_sign, &bounds.x, - &bounds_y_sign, &bounds.y, &crop_left_sign, - &crop.left, &crop_top_sign, &crop.top, - &crop_right_sign, &crop.right, - &crop_bottom_sign, &crop.bottom) != 18) { + if (sscanf(transform_text, "pos: x%c%f y%c%f rot:%c%f bounds: x%c%f y%c%f crop: l%c%d t%c%d r%c%d b%c%d", + &pos_x_sign, &pos.x, &pos_y_sign, &pos.y, &rot_sign, &rot, &bounds_x_sign, &bounds.x, + &bounds_y_sign, &bounds.y, &crop_left_sign, &crop.left, &crop_top_sign, &crop.top, + &crop_right_sign, &crop.right, &crop_bottom_sign, &crop.bottom) != 18) { update_transform_text(move_source, settings); return true; } - obs_data_set_vec2_sign(settings, S_BOUNDS, &bounds, - bounds_x_sign, bounds_y_sign); + obs_data_set_vec2_sign(settings, S_BOUNDS, &bounds, bounds_x_sign, bounds_y_sign); } } else { if (sscanf(transform_text, "pos: x%c%f y%c%f rot:%c%f scale: x%c%f y%c%f bounds: x%c%f y%c%f crop: l%c%d t%c%d r%c%d b%c%d", - &pos_x_sign, &pos.x, &pos_y_sign, &pos.y, &rot_sign, - &rot, &scale_x_sign, &scale.x, &scale_y_sign, - &scale.y, &bounds_x_sign, &bounds.x, &bounds_y_sign, - &bounds.y, &crop_left_sign, &crop.left, - &crop_top_sign, &crop.top, &crop_right_sign, - &crop.right, &crop_bottom_sign, - &crop.bottom) != 22) { + &pos_x_sign, &pos.x, &pos_y_sign, &pos.y, &rot_sign, &rot, &scale_x_sign, &scale.x, &scale_y_sign, + &scale.y, &bounds_x_sign, &bounds.x, &bounds_y_sign, &bounds.y, &crop_left_sign, &crop.left, + &crop_top_sign, &crop.top, &crop_right_sign, &crop.right, &crop_bottom_sign, &crop.bottom) != 22) { update_transform_text(move_source, settings); return true; } - obs_data_set_vec2_sign(settings, S_SCALE, &scale, scale_x_sign, - scale_y_sign); - obs_data_set_vec2_sign(settings, S_BOUNDS, &bounds, - bounds_x_sign, bounds_y_sign); + obs_data_set_vec2_sign(settings, S_SCALE, &scale, scale_x_sign, scale_y_sign); + obs_data_set_vec2_sign(settings, S_BOUNDS, &bounds, bounds_x_sign, bounds_y_sign); } obs_data_set_vec2_sign(settings, S_POS, &pos, pos_x_sign, pos_y_sign); obs_data_set_double(settings, S_ROT, rot); obs_data_set_char(settings, "rot_sign", rot_sign); - obs_data_set_crop_sign(settings, S_CROP, &crop, crop_left_sign, - crop_top_sign, crop_right_sign, - crop_bottom_sign); + obs_data_set_crop_sign(settings, S_CROP, &crop, crop_left_sign, crop_top_sign, crop_right_sign, crop_bottom_sign); return false; } static void prop_list_add_media_actions(obs_property_t *p) { - obs_property_list_add_int(p, obs_module_text("MediaAction.None"), - MEDIA_ACTION_NONE); - obs_property_list_add_int(p, obs_module_text("MediaAction.Play"), - MEDIA_ACTION_PLAY); - obs_property_list_add_int(p, obs_module_text("MediaAction.Pause"), - MEDIA_ACTION_PAUSE); - obs_property_list_add_int(p, obs_module_text("MediaAction.Stop"), - MEDIA_ACTION_STOP); - obs_property_list_add_int(p, obs_module_text("MediaAction.Restart"), - MEDIA_ACTION_RESTART); - obs_property_list_add_int(p, obs_module_text("MediaAction.Next"), - MEDIA_ACTION_NEXT); - obs_property_list_add_int(p, obs_module_text("MediaAction.Previous"), - MEDIA_ACTION_PREVIOUS); - obs_property_list_add_int(p, obs_module_text("MediaAction.PlayFrom"), - MEDIA_ACTION_PLAY_FROM); - obs_property_list_add_int(p, obs_module_text("MediaAction.PauseAt"), - MEDIA_ACTION_PAUSE_AT); + obs_property_list_add_int(p, obs_module_text("MediaAction.None"), MEDIA_ACTION_NONE); + obs_property_list_add_int(p, obs_module_text("MediaAction.Play"), MEDIA_ACTION_PLAY); + obs_property_list_add_int(p, obs_module_text("MediaAction.Pause"), MEDIA_ACTION_PAUSE); + obs_property_list_add_int(p, obs_module_text("MediaAction.Stop"), MEDIA_ACTION_STOP); + obs_property_list_add_int(p, obs_module_text("MediaAction.Restart"), MEDIA_ACTION_RESTART); + obs_property_list_add_int(p, obs_module_text("MediaAction.Next"), MEDIA_ACTION_NEXT); + obs_property_list_add_int(p, obs_module_text("MediaAction.Previous"), MEDIA_ACTION_PREVIOUS); + obs_property_list_add_int(p, obs_module_text("MediaAction.PlayFrom"), MEDIA_ACTION_PLAY_FROM); + obs_property_list_add_int(p, obs_module_text("MediaAction.PauseAt"), MEDIA_ACTION_PAUSE_AT); } static obs_properties_t *move_source_properties(void *data) { obs_properties_t *ppts = obs_properties_create(); struct move_source_info *move_source = data; - obs_source_t *parent = - obs_filter_get_parent(move_source->move_filter.source); + obs_source_t *parent = obs_filter_get_parent(move_source->move_filter.source); obs_scene_t *scene = obs_scene_from_source(parent); if (!scene) scene = obs_group_from_source(parent); if (!scene) { - obs_property_t *w = obs_properties_add_text( - ppts, "warning", obs_module_text("ScenesOnlyFilter"), - OBS_TEXT_INFO); + obs_property_t *w = obs_properties_add_text(ppts, "warning", obs_module_text("ScenesOnlyFilter"), OBS_TEXT_INFO); obs_property_text_set_info_type(w, OBS_TEXT_INFO_WARNING); - obs_properties_add_text(ppts, "plugin_info", PLUGIN_INFO, - OBS_TEXT_INFO); + obs_properties_add_text(ppts, "plugin_info", PLUGIN_INFO, OBS_TEXT_INFO); return ppts; } - if (!move_source->scene_item && move_source->source_name && - strlen(move_source->source_name)) { + if (!move_source->scene_item && move_source->source_name && strlen(move_source->source_name)) { obs_scene_enum_items(scene, find_sceneitem, move_source); } obs_properties_t *group = obs_properties_create(); - obs_property_t *p = obs_properties_add_list(group, S_SOURCE, - obs_module_text("Source"), - OBS_COMBO_TYPE_LIST, - OBS_COMBO_FORMAT_STRING); + obs_property_t *p = + obs_properties_add_list(group, S_SOURCE, obs_module_text("Source"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING); obs_scene_enum_items(scene, prop_list_add_sceneitem, p); obs_property_set_modified_callback2(p, move_source_changed, data); - p = obs_properties_add_int(group, S_START_DELAY, - obs_module_text("StartDelay"), 0, 10000000, - 100); + p = obs_properties_add_int(group, S_START_DELAY, obs_module_text("StartDelay"), 0, 10000000, 100); obs_property_int_set_suffix(p, "ms"); obs_properties_t *duration = obs_properties_create(); p = obs_properties_add_int(duration, S_DURATION, "", 0, 10000000, 100); obs_property_int_set_suffix(p, "ms"); - p = obs_properties_add_group(group, S_CUSTOM_DURATION, - obs_module_text("CustomDuration"), - OBS_GROUP_CHECKABLE, duration); + p = obs_properties_add_group(group, S_CUSTOM_DURATION, obs_module_text("CustomDuration"), OBS_GROUP_CHECKABLE, duration); - p = obs_properties_add_int(group, S_END_DELAY, - obs_module_text("EndDelay"), 0, 10000000, - 100); + p = obs_properties_add_int(group, S_END_DELAY, obs_module_text("EndDelay"), 0, 10000000, 100); obs_property_int_set_suffix(p, "ms"); - p = obs_properties_add_list(group, S_EASING_MATCH, - obs_module_text("Easing"), - OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); + p = obs_properties_add_list(group, S_EASING_MATCH, obs_module_text("Easing"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); prop_list_add_easings(p); - p = obs_properties_add_list(group, S_EASING_FUNCTION_MATCH, - obs_module_text("EasingFunction"), - OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); + p = obs_properties_add_list(group, S_EASING_FUNCTION_MATCH, obs_module_text("EasingFunction"), OBS_COMBO_TYPE_LIST, + OBS_COMBO_FORMAT_INT); prop_list_add_easing_functions(p); - p = obs_properties_add_group(ppts, S_GENERAL, - obs_module_text("General"), - OBS_GROUP_NORMAL, group); + p = obs_properties_add_group(ppts, S_GENERAL, obs_module_text("General"), OBS_GROUP_NORMAL, group); group = obs_properties_create(); - p = obs_properties_add_text(group, S_TRANSFORM_TEXT, - obs_module_text("Transform"), - OBS_TEXT_DEFAULT); - obs_property_set_modified_callback2( - p, move_source_transform_text_changed, data); - obs_properties_add_button(group, "transform_get", - obs_module_text("GetTransform"), - move_source_get_transform); - obs_properties_add_button(group, "switch_to_relative", - obs_module_text("TransformRelative"), - move_source_relative); - - obs_properties_add_float_slider(group, S_CURVE_MATCH, - obs_module_text("Curve"), -2.0, 2.0, - 0.01); - - p = obs_properties_add_group(ppts, S_TRANSFORM, - obs_module_text("Transform"), - OBS_GROUP_CHECKABLE, group); + p = obs_properties_add_text(group, S_TRANSFORM_TEXT, obs_module_text("Transform"), OBS_TEXT_DEFAULT); + obs_property_set_modified_callback2(p, move_source_transform_text_changed, data); + obs_properties_add_button(group, "transform_get", obs_module_text("GetTransform"), move_source_get_transform); + obs_properties_add_button(group, "switch_to_relative", obs_module_text("TransformRelative"), move_source_relative); + + obs_properties_add_float_slider(group, S_CURVE_MATCH, obs_module_text("Curve"), -2.0, 2.0, 0.01); + + p = obs_properties_add_group(ppts, S_TRANSFORM, obs_module_text("Transform"), OBS_GROUP_CHECKABLE, group); group = obs_properties_create(); - p = obs_properties_add_list(group, S_CHANGE_VISIBILITY, - obs_module_text("ChangeVisibility"), - OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); - obs_property_list_add_int(p, obs_module_text("ChangeVisibility.No"), - CHANGE_VISIBILITY_NONE); - obs_property_list_add_int(p, - obs_module_text("ChangeVisibility.ShowStart"), - CHANGE_VISIBILITY_SHOW_START); - obs_property_list_add_int(p, - obs_module_text("ChangeVisibility.ShowEnd"), - CHANGE_VISIBILITY_SHOW_END); - obs_property_list_add_int( - p, obs_module_text("ChangeVisibility.ShowStartEnd"), - CHANGE_VISIBILITY_SHOW_START_END); - obs_property_list_add_int(p, - obs_module_text("ChangeVisibility.HideStart"), - CHANGE_VISIBILITY_HIDE_START); - obs_property_list_add_int(p, - obs_module_text("ChangeVisibility.HideEnd"), - CHANGE_VISIBILITY_HIDE_END); - obs_property_list_add_int( - p, obs_module_text("ChangeVisibility.HideStartEnd"), - CHANGE_VISIBILITY_HIDE_START_END); - obs_property_list_add_int(p, obs_module_text("ChangeVisibility.Toggle"), - CHANGE_VISIBILITY_TOGGLE); - obs_property_list_add_int( - p, obs_module_text("ChangeVisibility.ToggleStart"), - CHANGE_VISIBILITY_TOGGLE_START); - obs_property_list_add_int(p, - obs_module_text("ChangeVisibility.ToggleEnd"), - CHANGE_VISIBILITY_TOGGLE_END); - - p = obs_properties_add_list(group, S_CHANGE_ORDER, - obs_module_text("ChangeOrder"), - OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); - obs_property_list_add_int(p, obs_module_text("ChangeOrder.No"), - CHANGE_ORDER_NONE); - obs_property_list_add_int(p, - obs_module_text("ChangeOrder.StartAbsolute"), - CHANGE_ORDER_START | CHANGE_ORDER_ABSOLUTE); - obs_property_list_add_int(p, obs_module_text("ChangeOrder.EndAbsolute"), - CHANGE_ORDER_END | CHANGE_ORDER_ABSOLUTE); - obs_property_list_add_int(p, - obs_module_text("ChangeOrder.StartRelative"), - CHANGE_ORDER_START | CHANGE_ORDER_RELATIVE); - obs_property_list_add_int(p, obs_module_text("ChangeOrder.EndRelative"), - CHANGE_ORDER_END | CHANGE_ORDER_RELATIVE); - p = obs_properties_add_int(group, S_ORDER_POSITION, - obs_module_text("OrderPosition"), -1000, - 1000, 1); - - p = obs_properties_add_group(ppts, S_VISIBILITY_ORDER, - obs_module_text("VisibilityOrder"), - OBS_GROUP_NORMAL, group); - - obs_source_t *source = - obs_sceneitem_get_source(move_source->scene_item); + p = obs_properties_add_list(group, S_CHANGE_VISIBILITY, obs_module_text("ChangeVisibility"), OBS_COMBO_TYPE_LIST, + OBS_COMBO_FORMAT_INT); + obs_property_list_add_int(p, obs_module_text("ChangeVisibility.No"), CHANGE_VISIBILITY_NONE); + obs_property_list_add_int(p, obs_module_text("ChangeVisibility.ShowStart"), CHANGE_VISIBILITY_SHOW_START); + obs_property_list_add_int(p, obs_module_text("ChangeVisibility.ShowEnd"), CHANGE_VISIBILITY_SHOW_END); + obs_property_list_add_int(p, obs_module_text("ChangeVisibility.ShowStartEnd"), CHANGE_VISIBILITY_SHOW_START_END); + obs_property_list_add_int(p, obs_module_text("ChangeVisibility.HideStart"), CHANGE_VISIBILITY_HIDE_START); + obs_property_list_add_int(p, obs_module_text("ChangeVisibility.HideEnd"), CHANGE_VISIBILITY_HIDE_END); + obs_property_list_add_int(p, obs_module_text("ChangeVisibility.HideStartEnd"), CHANGE_VISIBILITY_HIDE_START_END); + obs_property_list_add_int(p, obs_module_text("ChangeVisibility.Toggle"), CHANGE_VISIBILITY_TOGGLE); + obs_property_list_add_int(p, obs_module_text("ChangeVisibility.ToggleStart"), CHANGE_VISIBILITY_TOGGLE_START); + obs_property_list_add_int(p, obs_module_text("ChangeVisibility.ToggleEnd"), CHANGE_VISIBILITY_TOGGLE_END); + + p = obs_properties_add_list(group, S_CHANGE_ORDER, obs_module_text("ChangeOrder"), OBS_COMBO_TYPE_LIST, + OBS_COMBO_FORMAT_INT); + obs_property_list_add_int(p, obs_module_text("ChangeOrder.No"), CHANGE_ORDER_NONE); + obs_property_list_add_int(p, obs_module_text("ChangeOrder.StartAbsolute"), CHANGE_ORDER_START | CHANGE_ORDER_ABSOLUTE); + obs_property_list_add_int(p, obs_module_text("ChangeOrder.EndAbsolute"), CHANGE_ORDER_END | CHANGE_ORDER_ABSOLUTE); + obs_property_list_add_int(p, obs_module_text("ChangeOrder.StartRelative"), CHANGE_ORDER_START | CHANGE_ORDER_RELATIVE); + obs_property_list_add_int(p, obs_module_text("ChangeOrder.EndRelative"), CHANGE_ORDER_END | CHANGE_ORDER_RELATIVE); + p = obs_properties_add_int(group, S_ORDER_POSITION, obs_module_text("OrderPosition"), -1000, 1000, 1); + + p = obs_properties_add_group(ppts, S_VISIBILITY_ORDER, obs_module_text("VisibilityOrder"), OBS_GROUP_NORMAL, group); + + obs_source_t *source = obs_sceneitem_get_source(move_source->scene_item); group = obs_properties_create(); const uint32_t flags = source ? obs_source_get_output_flags(source) : 0; const bool media = flags & OBS_SOURCE_CONTROLLABLE_MEDIA; - p = obs_properties_add_list(group, S_MEDIA_ACTION_START, - obs_module_text("MediaAction.Start"), - OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); + p = obs_properties_add_list(group, S_MEDIA_ACTION_START, obs_module_text("MediaAction.Start"), OBS_COMBO_TYPE_LIST, + OBS_COMBO_FORMAT_INT); prop_list_add_media_actions(p); - p = obs_properties_add_int(group, S_MEDIA_ACTION_START_TIME, - obs_module_text("MediaAction.Time"), - -1000000, 1000000, 100); + p = obs_properties_add_int(group, S_MEDIA_ACTION_START_TIME, obs_module_text("MediaAction.Time"), -1000000, 1000000, 100); obs_property_int_set_suffix(p, "ms"); - p = obs_properties_add_list(group, S_MEDIA_ACTION_END, - obs_module_text("MediaAction.End"), - OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); + p = obs_properties_add_list(group, S_MEDIA_ACTION_END, obs_module_text("MediaAction.End"), OBS_COMBO_TYPE_LIST, + OBS_COMBO_FORMAT_INT); prop_list_add_media_actions(p); - p = obs_properties_add_int(group, S_MEDIA_ACTION_END_TIME, - obs_module_text("MediaAction.Time"), - -1000000, 1000000, 100); + p = obs_properties_add_int(group, S_MEDIA_ACTION_END_TIME, obs_module_text("MediaAction.Time"), -1000000, 1000000, 100); obs_property_int_set_suffix(p, "ms"); - p = obs_properties_add_group(ppts, S_MEDIA_ACTION, - obs_module_text("MediaAction"), - OBS_GROUP_NORMAL, group); + p = obs_properties_add_group(ppts, S_MEDIA_ACTION, obs_module_text("MediaAction"), OBS_GROUP_NORMAL, group); obs_property_set_visible(p, media); const bool audio = flags & OBS_SOURCE_AUDIO; group = obs_properties_create(); - p = obs_properties_add_list(group, S_MUTE_ACTION, - obs_module_text("MuteAction"), - OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); - - obs_property_list_add_int(p, obs_module_text("MuteAction.None"), - MUTE_ACTION_NONE); - obs_property_list_add_int(p, obs_module_text("MuteAction.MuteStart"), - MUTE_ACTION_MUTE_START); - obs_property_list_add_int(p, obs_module_text("MuteAction.MuteEnd"), - MUTE_ACTION_MUTE_END); - obs_property_list_add_int(p, obs_module_text("MuteAction.UnmuteStart"), - MUTE_ACTION_UNMUTE_START); - obs_property_list_add_int(p, obs_module_text("MuteAction.UnmuteEnd"), - MUTE_ACTION_UNMUTE_END); - obs_property_list_add_int(p, obs_module_text("MuteAction.MuteDuring"), - MUTE_ACTION_MUTE_DURING); - obs_property_list_add_int(p, obs_module_text("MuteAction.UnmuteDuring"), - MUTE_ACTION_UNMUTE_DURING); + p = obs_properties_add_list(group, S_MUTE_ACTION, obs_module_text("MuteAction"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); + + obs_property_list_add_int(p, obs_module_text("MuteAction.None"), MUTE_ACTION_NONE); + obs_property_list_add_int(p, obs_module_text("MuteAction.MuteStart"), MUTE_ACTION_MUTE_START); + obs_property_list_add_int(p, obs_module_text("MuteAction.MuteEnd"), MUTE_ACTION_MUTE_END); + obs_property_list_add_int(p, obs_module_text("MuteAction.UnmuteStart"), MUTE_ACTION_UNMUTE_START); + obs_property_list_add_int(p, obs_module_text("MuteAction.UnmuteEnd"), MUTE_ACTION_UNMUTE_END); + obs_property_list_add_int(p, obs_module_text("MuteAction.MuteDuring"), MUTE_ACTION_MUTE_DURING); + obs_property_list_add_int(p, obs_module_text("MuteAction.UnmuteDuring"), MUTE_ACTION_UNMUTE_DURING); obs_properties_t *fade = obs_properties_create(); - p = obs_properties_add_float_slider(fade, S_AUDIO_FADE_PERCENT, "", 0.0, - 100.0, 1.0); + p = obs_properties_add_float_slider(fade, S_AUDIO_FADE_PERCENT, "", 0.0, 100.0, 1.0); obs_property_float_set_suffix(p, "%"); - p = obs_properties_add_group(group, S_AUDIO_FADE, - obs_module_text("AudioFade"), - OBS_GROUP_CHECKABLE, fade); - p = obs_properties_add_group(ppts, S_AUDIO_ACTION, - obs_module_text("AudioAction"), - OBS_GROUP_NORMAL, group); + p = obs_properties_add_group(group, S_AUDIO_FADE, obs_module_text("AudioFade"), OBS_GROUP_CHECKABLE, fade); + p = obs_properties_add_group(ppts, S_AUDIO_ACTION, obs_module_text("AudioAction"), OBS_GROUP_NORMAL, group); obs_property_set_visible(p, audio); group = obs_properties_create(); - p = obs_properties_add_bool(group, S_ENABLED_MATCH_MOVING, - obs_module_text("EnabledMatchMoving")); - - p = obs_properties_add_list(group, S_START_TRIGGER, - obs_module_text("StartTrigger"), - OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); - - obs_property_list_add_int(p, obs_module_text("StartTrigger.None"), - START_TRIGGER_NONE); - obs_property_list_add_int(p, obs_module_text("StartTrigger.Activate"), - START_TRIGGER_ACTIVATE); - obs_property_list_add_int(p, obs_module_text("StartTrigger.Deactivate"), - START_TRIGGER_DEACTIVATE); - obs_property_list_add_int(p, obs_module_text("StartTrigger.Show"), - START_TRIGGER_SHOW); - obs_property_list_add_int(p, obs_module_text("StartTrigger.Hide"), - START_TRIGGER_HIDE); - obs_property_list_add_int(p, obs_module_text("StartTrigger.Enable"), - START_TRIGGER_ENABLE); - obs_property_list_add_int( - p, obs_module_text("StartTrigger.SourceActivate"), - START_TRIGGER_SOURCE_ACTIVATE); - obs_property_list_add_int( - p, obs_module_text("StartTrigger.SourceDeactivate"), - START_TRIGGER_SOURCE_DEACTIVATE); - obs_property_list_add_int(p, obs_module_text("StartTrigger.SourceShow"), - START_TRIGGER_SOURCE_SHOW); - obs_property_list_add_int(p, obs_module_text("StartTrigger.SourceHide"), - START_TRIGGER_SOURCE_HIDE); - obs_property_list_add_int(p, - obs_module_text("StartTrigger.MediaStarted"), - START_TRIGGER_MEDIA_STARTED); - obs_property_list_add_int(p, obs_module_text("StartTrigger.MediaEnded"), - START_TRIGGER_MEDIA_ENDED); - obs_property_list_add_int(p, obs_module_text("StartTrigger.Load"), - START_TRIGGER_LOAD); - - p = obs_properties_add_list(group, S_STOP_TRIGGER, - obs_module_text("StopTrigger"), - OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); - - obs_property_list_add_int(p, obs_module_text("StopTrigger.None"), - START_TRIGGER_NONE); - obs_property_list_add_int(p, obs_module_text("StartTrigger.Activate"), - START_TRIGGER_ACTIVATE); - obs_property_list_add_int(p, obs_module_text("StartTrigger.Deactivate"), - START_TRIGGER_DEACTIVATE); - obs_property_list_add_int(p, obs_module_text("StartTrigger.Show"), - START_TRIGGER_SHOW); - obs_property_list_add_int(p, obs_module_text("StartTrigger.Hide"), - START_TRIGGER_HIDE); - obs_property_list_add_int(p, obs_module_text("StartTrigger.Enable"), - START_TRIGGER_ENABLE); - obs_property_list_add_int( - p, obs_module_text("StartTrigger.SourceActivate"), - START_TRIGGER_SOURCE_ACTIVATE); - obs_property_list_add_int( - p, obs_module_text("StartTrigger.SourceDeactivate"), - START_TRIGGER_SOURCE_DEACTIVATE); - obs_property_list_add_int(p, obs_module_text("StartTrigger.SourceShow"), - START_TRIGGER_SOURCE_SHOW); - obs_property_list_add_int(p, obs_module_text("StartTrigger.SourceHide"), - START_TRIGGER_SOURCE_HIDE); - obs_property_list_add_int(p, - obs_module_text("StartTrigger.MediaStarted"), - START_TRIGGER_MEDIA_STARTED); - obs_property_list_add_int(p, obs_module_text("StartTrigger.MediaEnded"), - START_TRIGGER_MEDIA_ENDED); - - p = obs_properties_add_list(group, S_SIMULTANEOUS_MOVE, - obs_module_text("SimultaneousMove"), - OBS_COMBO_TYPE_LIST, + p = obs_properties_add_bool(group, S_ENABLED_MATCH_MOVING, obs_module_text("EnabledMatchMoving")); + + p = obs_properties_add_list(group, S_START_TRIGGER, obs_module_text("StartTrigger"), OBS_COMBO_TYPE_LIST, + OBS_COMBO_FORMAT_INT); + + obs_property_list_add_int(p, obs_module_text("StartTrigger.None"), START_TRIGGER_NONE); + obs_property_list_add_int(p, obs_module_text("StartTrigger.Activate"), START_TRIGGER_ACTIVATE); + obs_property_list_add_int(p, obs_module_text("StartTrigger.Deactivate"), START_TRIGGER_DEACTIVATE); + obs_property_list_add_int(p, obs_module_text("StartTrigger.Show"), START_TRIGGER_SHOW); + obs_property_list_add_int(p, obs_module_text("StartTrigger.Hide"), START_TRIGGER_HIDE); + obs_property_list_add_int(p, obs_module_text("StartTrigger.Enable"), START_TRIGGER_ENABLE); + obs_property_list_add_int(p, obs_module_text("StartTrigger.SourceActivate"), START_TRIGGER_SOURCE_ACTIVATE); + obs_property_list_add_int(p, obs_module_text("StartTrigger.SourceDeactivate"), START_TRIGGER_SOURCE_DEACTIVATE); + obs_property_list_add_int(p, obs_module_text("StartTrigger.SourceShow"), START_TRIGGER_SOURCE_SHOW); + obs_property_list_add_int(p, obs_module_text("StartTrigger.SourceHide"), START_TRIGGER_SOURCE_HIDE); + obs_property_list_add_int(p, obs_module_text("StartTrigger.MediaStarted"), START_TRIGGER_MEDIA_STARTED); + obs_property_list_add_int(p, obs_module_text("StartTrigger.MediaEnded"), START_TRIGGER_MEDIA_ENDED); + obs_property_list_add_int(p, obs_module_text("StartTrigger.Load"), START_TRIGGER_LOAD); + + p = obs_properties_add_list(group, S_STOP_TRIGGER, obs_module_text("StopTrigger"), OBS_COMBO_TYPE_LIST, + OBS_COMBO_FORMAT_INT); + + obs_property_list_add_int(p, obs_module_text("StopTrigger.None"), START_TRIGGER_NONE); + obs_property_list_add_int(p, obs_module_text("StartTrigger.Activate"), START_TRIGGER_ACTIVATE); + obs_property_list_add_int(p, obs_module_text("StartTrigger.Deactivate"), START_TRIGGER_DEACTIVATE); + obs_property_list_add_int(p, obs_module_text("StartTrigger.Show"), START_TRIGGER_SHOW); + obs_property_list_add_int(p, obs_module_text("StartTrigger.Hide"), START_TRIGGER_HIDE); + obs_property_list_add_int(p, obs_module_text("StartTrigger.Enable"), START_TRIGGER_ENABLE); + obs_property_list_add_int(p, obs_module_text("StartTrigger.SourceActivate"), START_TRIGGER_SOURCE_ACTIVATE); + obs_property_list_add_int(p, obs_module_text("StartTrigger.SourceDeactivate"), START_TRIGGER_SOURCE_DEACTIVATE); + obs_property_list_add_int(p, obs_module_text("StartTrigger.SourceShow"), START_TRIGGER_SOURCE_SHOW); + obs_property_list_add_int(p, obs_module_text("StartTrigger.SourceHide"), START_TRIGGER_SOURCE_HIDE); + obs_property_list_add_int(p, obs_module_text("StartTrigger.MediaStarted"), START_TRIGGER_MEDIA_STARTED); + obs_property_list_add_int(p, obs_module_text("StartTrigger.MediaEnded"), START_TRIGGER_MEDIA_ENDED); + + p = obs_properties_add_list(group, S_SIMULTANEOUS_MOVE, obs_module_text("SimultaneousMove"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING); - obs_property_list_add_string( - p, obs_module_text("SimultaneousMove.None"), ""); + obs_property_list_add_string(p, obs_module_text("SimultaneousMove.None"), ""); obs_source_enum_filters(parent, prop_list_add_move_source_filter, p); if (source) - obs_source_enum_filters(source, - prop_list_add_move_source_filter, p); + obs_source_enum_filters(source, prop_list_add_move_source_filter, p); - p = obs_properties_add_list(group, S_NEXT_MOVE, - obs_module_text("NextMove"), - OBS_COMBO_TYPE_LIST, - OBS_COMBO_FORMAT_STRING); + p = obs_properties_add_list(group, S_NEXT_MOVE, obs_module_text("NextMove"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING); obs_property_list_add_string(p, obs_module_text("NextMove.None"), ""); - obs_property_list_add_string(p, obs_module_text("NextMove.Reverse"), - NEXT_MOVE_REVERSE); + obs_property_list_add_string(p, obs_module_text("NextMove.Reverse"), NEXT_MOVE_REVERSE); obs_source_enum_filters(parent, prop_list_add_move_source_filter, p); if (source) - obs_source_enum_filters(source, - prop_list_add_move_source_filter, p); - - p = obs_properties_add_list(group, S_NEXT_MOVE_ON, - obs_module_text("NextMoveOn"), - OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); - obs_property_list_add_int(p, obs_module_text("NextMoveOn.End"), - NEXT_MOVE_ON_END); - obs_property_list_add_int(p, obs_module_text("NextMoveOn.Hotkey"), - NEXT_MOVE_ON_HOTKEY); - - obs_properties_add_button(group, "move_source_start", - obs_module_text("Start"), - move_source_start_button); - - p = obs_properties_add_group(ppts, S_ACTIONS, - obs_module_text("Actions"), - OBS_GROUP_NORMAL, group); - obs_properties_add_text(ppts, "plugin_info", PLUGIN_INFO, - OBS_TEXT_INFO); + obs_source_enum_filters(source, prop_list_add_move_source_filter, p); + + p = obs_properties_add_list(group, S_NEXT_MOVE_ON, obs_module_text("NextMoveOn"), OBS_COMBO_TYPE_LIST, + OBS_COMBO_FORMAT_INT); + obs_property_list_add_int(p, obs_module_text("NextMoveOn.End"), NEXT_MOVE_ON_END); + obs_property_list_add_int(p, obs_module_text("NextMoveOn.Hotkey"), NEXT_MOVE_ON_HOTKEY); + + obs_properties_add_button(group, "move_source_start", obs_module_text("Start"), move_source_start_button); + + p = obs_properties_add_group(ppts, S_ACTIONS, obs_module_text("Actions"), OBS_GROUP_NORMAL, group); + obs_properties_add_text(ppts, "plugin_info", PLUGIN_INFO, OBS_TEXT_INFO); return ppts; } @@ -1495,8 +1077,7 @@ void move_source_defaults(obs_data_t *settings) obs_data_set_default_bool(settings, S_CUSTOM_DURATION, true); obs_data_set_default_bool(settings, S_TRANSFORM, true); obs_data_set_default_int(settings, S_EASING_MATCH, EASE_IN_OUT); - obs_data_set_default_int(settings, S_EASING_FUNCTION_MATCH, - EASING_CUBIC); + obs_data_set_default_int(settings, S_EASING_FUNCTION_MATCH, EASING_CUBIC); obs_data_set_default_double(settings, S_CURVE_MATCH, 0.0); } @@ -1513,71 +1094,44 @@ static const char *move_source_get_name(void *type_data) return obs_module_text("MoveSourceFilter"); } -void vec2_bezier(struct vec2 *dst, struct vec2 *begin, struct vec2 *control, - struct vec2 *end, const float t); +void vec2_bezier(struct vec2 *dst, struct vec2 *begin, struct vec2 *control, struct vec2 *end, const float t); void move_source_ended(struct move_source_info *move_source) { move_filter_ended(&move_source->move_filter); if (move_source->change_visibility == CHANGE_VISIBILITY_HIDE_END || - move_source->change_visibility == - CHANGE_VISIBILITY_SHOW_START_END) { + move_source->change_visibility == CHANGE_VISIBILITY_SHOW_START_END) { obs_sceneitem_set_visible(move_source->scene_item, false); - } else if (move_source->change_visibility == - CHANGE_VISIBILITY_SHOW_END || - move_source->change_visibility == - CHANGE_VISIBILITY_HIDE_START_END) { + } else if (move_source->change_visibility == CHANGE_VISIBILITY_SHOW_END || + move_source->change_visibility == CHANGE_VISIBILITY_HIDE_START_END) { obs_sceneitem_set_visible(move_source->scene_item, true); - } else if (move_source->change_visibility == - CHANGE_VISIBILITY_TOGGLE_END) { - obs_sceneitem_set_visible( - move_source->scene_item, - !obs_sceneitem_visible(move_source->scene_item)); - } else if (move_source->change_visibility == CHANGE_VISIBILITY_TOGGLE && - !move_source->visibility_toggled) { + } else if (move_source->change_visibility == CHANGE_VISIBILITY_TOGGLE_END) { + obs_sceneitem_set_visible(move_source->scene_item, !obs_sceneitem_visible(move_source->scene_item)); + } else if (move_source->change_visibility == CHANGE_VISIBILITY_TOGGLE && !move_source->visibility_toggled) { obs_sceneitem_set_visible(move_source->scene_item, false); } - move_source_media_action(move_source, move_source->media_action_end, - move_source->media_time_end); - if ((move_source->mute_action == MUTE_ACTION_MUTE_END || - move_source->mute_action == MUTE_ACTION_UNMUTE_DURING) && - !obs_source_muted( - obs_sceneitem_get_source(move_source->scene_item))) { - obs_source_set_muted( - obs_sceneitem_get_source(move_source->scene_item), - true); - } else if ((move_source->mute_action == MUTE_ACTION_UNMUTE_END || - move_source->mute_action == MUTE_ACTION_MUTE_DURING) && - obs_source_muted( - obs_sceneitem_get_source(move_source->scene_item))) { - obs_source_set_muted( - obs_sceneitem_get_source(move_source->scene_item), - false); + move_source_media_action(move_source, move_source->media_action_end, move_source->media_time_end); + if ((move_source->mute_action == MUTE_ACTION_MUTE_END || move_source->mute_action == MUTE_ACTION_UNMUTE_DURING) && + !obs_source_muted(obs_sceneitem_get_source(move_source->scene_item))) { + obs_source_set_muted(obs_sceneitem_get_source(move_source->scene_item), true); + } else if ((move_source->mute_action == MUTE_ACTION_UNMUTE_END || move_source->mute_action == MUTE_ACTION_MUTE_DURING) && + obs_source_muted(obs_sceneitem_get_source(move_source->scene_item))) { + obs_source_set_muted(obs_sceneitem_get_source(move_source->scene_item), false); } if ((move_source->change_order & CHANGE_ORDER_END) != 0) { - if ((move_source->change_order & CHANGE_ORDER_RELATIVE) != 0 && - move_source->order_position) { + if ((move_source->change_order & CHANGE_ORDER_RELATIVE) != 0 && move_source->order_position) { if (move_source->order_position > 0) { - for (int i = 0; i < move_source->order_position; - i++) { - obs_sceneitem_set_order( - move_source->scene_item, - OBS_ORDER_MOVE_UP); + for (int i = 0; i < move_source->order_position; i++) { + obs_sceneitem_set_order(move_source->scene_item, OBS_ORDER_MOVE_UP); } } else if (move_source->order_position < 0) { - for (int i = 0; i > move_source->order_position; - i--) { - obs_sceneitem_set_order( - move_source->scene_item, - OBS_ORDER_MOVE_DOWN); + for (int i = 0; i > move_source->order_position; i--) { + obs_sceneitem_set_order(move_source->scene_item, OBS_ORDER_MOVE_DOWN); } } - } else if ((move_source->change_order & - CHANGE_ORDER_ABSOLUTE) != 0) { - obs_sceneitem_set_order_position( - move_source->scene_item, - (int)move_source->order_position); + } else if ((move_source->change_order & CHANGE_ORDER_ABSOLUTE) != 0) { + obs_sceneitem_set_order_position(move_source->scene_item, (int)move_source->order_position); } } } @@ -1601,77 +1155,51 @@ void move_source_tick(void *data, float seconds) ot = 0.0f; if (move_source->audio_fade) { - obs_source_set_volume( - obs_sceneitem_get_source(move_source->scene_item), - (1.0f - ot) * move_source->audio_fade_from + - ot * move_source->audio_fade_to); + obs_source_set_volume(obs_sceneitem_get_source(move_source->scene_item), + (1.0f - ot) * move_source->audio_fade_from + ot * move_source->audio_fade_to); } if (move_source->transform) { struct vec2 pos; if (move_source->curve != 0.0f) { - const float diff_x = fabsf(move_source->pos_from.x - - move_source->pos_to.x); - const float diff_y = fabsf(move_source->pos_from.y - - move_source->pos_to.y); + const float diff_x = fabsf(move_source->pos_from.x - move_source->pos_to.x); + const float diff_y = fabsf(move_source->pos_from.y - move_source->pos_to.y); struct vec2 control_pos; - vec2_set(&control_pos, - 0.5f * move_source->pos_from.x + - 0.5f * move_source->pos_to.x, - 0.5f * move_source->pos_from.y + - 0.5f * move_source->pos_to.y); + vec2_set(&control_pos, 0.5f * move_source->pos_from.x + 0.5f * move_source->pos_to.x, + 0.5f * move_source->pos_from.y + 0.5f * move_source->pos_to.y); if (control_pos.x >= (move_source->canvas_width >> 1)) { control_pos.x += diff_y * move_source->curve; } else { control_pos.x -= diff_y * move_source->curve; } - if (control_pos.y >= - (move_source->canvas_height >> 1)) { + if (control_pos.y >= (move_source->canvas_height >> 1)) { control_pos.y += diff_x * move_source->curve; } else { control_pos.y -= diff_x * move_source->curve; } - vec2_bezier(&pos, &move_source->pos_from, &control_pos, - &move_source->pos_to, t); + vec2_bezier(&pos, &move_source->pos_from, &control_pos, &move_source->pos_to, t); } else { - vec2_set(&pos, - (1.0f - t) * move_source->pos_from.x + - t * move_source->pos_to.x, - (1.0f - t) * move_source->pos_from.y + - t * move_source->pos_to.y); + vec2_set(&pos, (1.0f - t) * move_source->pos_from.x + t * move_source->pos_to.x, + (1.0f - t) * move_source->pos_from.y + t * move_source->pos_to.y); } obs_sceneitem_defer_update_begin(move_source->scene_item); obs_sceneitem_set_pos(move_source->scene_item, &pos); - const float rot = (1.0f - t) * move_source->rot_from + - t * move_source->rot_to; + const float rot = (1.0f - t) * move_source->rot_from + t * move_source->rot_to; obs_sceneitem_set_rot(move_source->scene_item, rot); struct vec2 scale; - vec2_set(&scale, - (1.0f - t) * move_source->scale_from.x + - t * move_source->scale_to.x, - (1.0f - t) * move_source->scale_from.y + - t * move_source->scale_to.y); + vec2_set(&scale, (1.0f - t) * move_source->scale_from.x + t * move_source->scale_to.x, + (1.0f - t) * move_source->scale_from.y + t * move_source->scale_to.y); obs_sceneitem_set_scale(move_source->scene_item, &scale); struct vec2 bounds; - vec2_set(&bounds, - (1.0f - t) * move_source->bounds_from.x + - t * move_source->bounds_to.x, - (1.0f - t) * move_source->bounds_from.y + - t * move_source->bounds_to.y); + vec2_set(&bounds, (1.0f - t) * move_source->bounds_from.x + t * move_source->bounds_to.x, + (1.0f - t) * move_source->bounds_from.y + t * move_source->bounds_to.y); obs_sceneitem_set_bounds(move_source->scene_item, &bounds); struct obs_sceneitem_crop crop; - crop.left = (int)((float)(1.0f - ot) * - (float)move_source->crop_from.left + - ot * (float)move_source->crop_to.left); - crop.top = (int)((float)(1.0f - ot) * - (float)move_source->crop_from.top + - ot * (float)move_source->crop_to.top); - crop.right = (int)((float)(1.0f - ot) * - (float)move_source->crop_from.right + - ot * (float)move_source->crop_to.right); + crop.left = (int)((float)(1.0f - ot) * (float)move_source->crop_from.left + ot * (float)move_source->crop_to.left); + crop.top = (int)((float)(1.0f - ot) * (float)move_source->crop_from.top + ot * (float)move_source->crop_to.top); + crop.right = + (int)((float)(1.0f - ot) * (float)move_source->crop_from.right + ot * (float)move_source->crop_to.right); crop.bottom = - (int)((float)(1.0f - ot) * - (float)move_source->crop_from.bottom + - ot * (float)move_source->crop_to.bottom); + (int)((float)(1.0f - ot) * (float)move_source->crop_from.bottom + ot * (float)move_source->crop_to.bottom); obs_sceneitem_set_crop(move_source->scene_item, &crop); obs_sceneitem_defer_update_end(move_source->scene_item); } diff --git a/move-transition-override-filter.c b/move-transition-override-filter.c index 812c38d..aec163b 100644 --- a/move-transition-override-filter.c +++ b/move-transition-override-filter.c @@ -14,21 +14,17 @@ void move_filter_source_rename(void *data, calldata_t *call_data) if (!settings || !new_name || !prev_name) return; const char *source_name = obs_data_get_string(settings, S_SOURCE); - if (source_name && strlen(source_name) && - strcmp(source_name, prev_name) == 0) { + if (source_name && strlen(source_name) && strcmp(source_name, prev_name) == 0) { obs_data_set_string(settings, S_SOURCE, new_name); } obs_data_release(settings); } -static void *move_override_filter_create(obs_data_t *settings, - obs_source_t *source) +static void *move_override_filter_create(obs_data_t *settings, obs_source_t *source) { - struct move_filter_info *move_filter = - bzalloc(sizeof(struct move_filter_info)); + struct move_filter_info *move_filter = bzalloc(sizeof(struct move_filter_info)); move_filter->source = source; - signal_handler_connect(obs_get_signal_handler(), "source_rename", - move_filter_source_rename, move_filter); + signal_handler_connect(obs_get_signal_handler(), "source_rename", move_filter_source_rename, move_filter); UNUSED_PARAMETER(settings); return move_filter; } @@ -36,8 +32,7 @@ static void *move_override_filter_create(obs_data_t *settings, static void move_override_filter_destroy(void *data) { struct move_filter_info *move_filter = data; - signal_handler_disconnect(obs_get_signal_handler(), "source_rename", - move_filter_source_rename, move_filter); + signal_handler_disconnect(obs_get_signal_handler(), "source_rename", move_filter_source_rename, move_filter); bfree(move_filter); } @@ -47,8 +42,7 @@ void prop_list_add_positions(obs_property_t *p); void prop_list_add_transitions(obs_property_t *p); void prop_list_add_scales(obs_property_t *p); -bool prop_list_add_sceneitem(obs_scene_t *scene, obs_sceneitem_t *item, - void *data) +bool prop_list_add_sceneitem(obs_scene_t *scene, obs_sceneitem_t *item, void *data) { UNUSED_PARAMETER(scene); obs_property_t *p = data; @@ -75,17 +69,12 @@ static obs_properties_t *move_override_filter_properties(void *data) obs_scene_t *scene = obs_scene_from_source(parent); obs_source_t *source = NULL; if (scene) { - p = obs_properties_add_list(ppts, S_SOURCE, - obs_module_text("Source"), - OBS_COMBO_TYPE_LIST, + p = obs_properties_add_list(ppts, S_SOURCE, obs_module_text("Source"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING); obs_scene_enum_items(scene, prop_list_add_sceneitem, p); - obs_data_t *settings = - obs_source_get_settings(move_filter->source); + obs_data_t *settings = obs_source_get_settings(move_filter->source); if (settings) { - source = obs_sceneitem_get_source(obs_scene_find_source( - scene, - obs_data_get_string(settings, S_SOURCE))); + source = obs_sceneitem_get_source(obs_scene_find_source(scene, obs_data_get_string(settings, S_SOURCE))); obs_data_release(settings); } } @@ -93,231 +82,151 @@ static obs_properties_t *move_override_filter_properties(void *data) //Matched items obs_properties_t *group = obs_properties_create(); - p = obs_properties_add_list(group, S_MATCH_SOURCE, - obs_module_text("MatchSource"), - OBS_COMBO_TYPE_EDITABLE, + p = obs_properties_add_list(group, S_MATCH_SOURCE, obs_module_text("MatchSource"), OBS_COMBO_TYPE_EDITABLE, OBS_COMBO_FORMAT_STRING); obs_property_list_add_string(p, "", ""); obs_enum_sources(prop_list_add_source, p); obs_enum_scenes(prop_list_add_source, p); - p = obs_properties_add_int_slider(group, S_START_DELAY_MATCH_TO, - obs_module_text("StartDelayTo"), -1, - 100, 1); + p = obs_properties_add_int_slider(group, S_START_DELAY_MATCH_TO, obs_module_text("StartDelayTo"), -1, 100, 1); obs_property_int_set_suffix(p, "%"); - p = obs_properties_add_int_slider(group, S_END_DELAY_MATCH_TO, - obs_module_text("EndDelayTo"), -1, - 100, 1); + p = obs_properties_add_int_slider(group, S_END_DELAY_MATCH_TO, obs_module_text("EndDelayTo"), -1, 100, 1); obs_property_int_set_suffix(p, "%"); - p = obs_properties_add_int_slider(group, S_START_DELAY_MATCH_FROM, - obs_module_text("StartDelayFrom"), -1, - 100, 1); + p = obs_properties_add_int_slider(group, S_START_DELAY_MATCH_FROM, obs_module_text("StartDelayFrom"), -1, 100, 1); obs_property_int_set_suffix(p, "%"); - p = obs_properties_add_int_slider(group, S_END_DELAY_MATCH_FROM, - obs_module_text("EndDelayFrom"), -1, - 100, 1); + p = obs_properties_add_int_slider(group, S_END_DELAY_MATCH_FROM, obs_module_text("EndDelayFrom"), -1, 100, 1); obs_property_int_set_suffix(p, "%"); - p = obs_properties_add_list(group, S_EASING_MATCH, - obs_module_text("Easing"), - OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); - obs_property_list_add_int(p, obs_module_text("NoOverride"), - NO_OVERRIDE); + p = obs_properties_add_list(group, S_EASING_MATCH, obs_module_text("Easing"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); + obs_property_list_add_int(p, obs_module_text("NoOverride"), NO_OVERRIDE); prop_list_add_easings(p); - p = obs_properties_add_list(group, S_EASING_FUNCTION_MATCH, - obs_module_text("EasingFunction"), - OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); - obs_property_list_add_int(p, obs_module_text("NoOverride"), - NO_OVERRIDE); + p = obs_properties_add_list(group, S_EASING_FUNCTION_MATCH, obs_module_text("EasingFunction"), OBS_COMBO_TYPE_LIST, + OBS_COMBO_FORMAT_INT); + obs_property_list_add_int(p, obs_module_text("NoOverride"), NO_OVERRIDE); prop_list_add_easing_functions(p); - p = obs_properties_add_list(group, S_TRANSITION_MATCH, - obs_module_text("Transition"), - OBS_COMBO_TYPE_LIST, + p = obs_properties_add_list(group, S_TRANSITION_MATCH, obs_module_text("Transition"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING); obs_property_list_add_string(p, obs_module_text("NoOverride"), NULL); prop_list_add_transitions(p); - p = obs_properties_add_list(group, S_TRANSITION_SCALE, - obs_module_text("TransitionScaleType"), - OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); - obs_property_list_add_int(p, obs_module_text("NoOverride"), - NO_OVERRIDE); + p = obs_properties_add_list(group, S_TRANSITION_SCALE, obs_module_text("TransitionScaleType"), OBS_COMBO_TYPE_LIST, + OBS_COMBO_FORMAT_INT); + obs_property_list_add_int(p, obs_module_text("NoOverride"), NO_OVERRIDE); prop_list_add_scales(p); obs_properties_t *curve_group = obs_properties_create(); - obs_properties_add_float_slider(curve_group, S_CURVE_MATCH, - obs_module_text("Curve"), -2.0, 2.0, - 0.01); - obs_properties_add_group(group, S_CURVE_OVERRIDE_MATCH, - obs_module_text("CurveOverride"), - OBS_GROUP_CHECKABLE, curve_group); + obs_properties_add_float_slider(curve_group, S_CURVE_MATCH, obs_module_text("Curve"), -2.0, 2.0, 0.01); + obs_properties_add_group(group, S_CURVE_OVERRIDE_MATCH, obs_module_text("CurveOverride"), OBS_GROUP_CHECKABLE, curve_group); - p = obs_properties_add_list(group, S_START_MOVE_MATCH_FROM, - obs_module_text("StartMoveMatchFrom"), - OBS_COMBO_TYPE_EDITABLE, + p = obs_properties_add_list(group, S_START_MOVE_MATCH_FROM, obs_module_text("StartMoveMatchFrom"), OBS_COMBO_TYPE_EDITABLE, OBS_COMBO_FORMAT_STRING); obs_property_list_add_string(p, "", ""); obs_source_enum_filters(parent, prop_list_add_move_source_filter, p); if (source) - obs_source_enum_filters(source, - prop_list_add_move_source_filter, p); + obs_source_enum_filters(source, prop_list_add_move_source_filter, p); - p = obs_properties_add_list(group, S_START_MOVE_MATCH_TO, - obs_module_text("StartMoveMatchTo"), - OBS_COMBO_TYPE_EDITABLE, + p = obs_properties_add_list(group, S_START_MOVE_MATCH_TO, obs_module_text("StartMoveMatchTo"), OBS_COMBO_TYPE_EDITABLE, OBS_COMBO_FORMAT_STRING); obs_property_list_add_string(p, "", ""); obs_source_enum_filters(parent, prop_list_add_move_source_filter, p); if (source) - obs_source_enum_filters(source, - prop_list_add_move_source_filter, p); + obs_source_enum_filters(source, prop_list_add_move_source_filter, p); - obs_properties_add_group(ppts, S_MOVE_MATCH, - obs_module_text("MoveMatch"), OBS_GROUP_NORMAL, - group); + obs_properties_add_group(ppts, S_MOVE_MATCH, obs_module_text("MoveMatch"), OBS_GROUP_NORMAL, group); //Move in group = obs_properties_create(); - p = obs_properties_add_int_slider(group, S_START_DELAY_IN, - obs_module_text("StartDelay"), -1, - 100, 1); + p = obs_properties_add_int_slider(group, S_START_DELAY_IN, obs_module_text("StartDelay"), -1, 100, 1); obs_property_int_set_suffix(p, "%"); - p = obs_properties_add_int_slider( - group, S_END_DELAY_IN, obs_module_text("EndDelay"), -1, 100, 1); + p = obs_properties_add_int_slider(group, S_END_DELAY_IN, obs_module_text("EndDelay"), -1, 100, 1); obs_property_int_set_suffix(p, "%"); - p = obs_properties_add_list(group, S_EASING_IN, - obs_module_text("Easing"), - OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); - obs_property_list_add_int(p, obs_module_text("NoOverride"), - NO_OVERRIDE); + p = obs_properties_add_list(group, S_EASING_IN, obs_module_text("Easing"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); + obs_property_list_add_int(p, obs_module_text("NoOverride"), NO_OVERRIDE); prop_list_add_easings(p); - p = obs_properties_add_list(group, S_EASING_FUNCTION_IN, - obs_module_text("EasingFunction"), - OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); - obs_property_list_add_int(p, obs_module_text("NoOverride"), - NO_OVERRIDE); + p = obs_properties_add_list(group, S_EASING_FUNCTION_IN, obs_module_text("EasingFunction"), OBS_COMBO_TYPE_LIST, + OBS_COMBO_FORMAT_INT); + obs_property_list_add_int(p, obs_module_text("NoOverride"), NO_OVERRIDE); prop_list_add_easing_functions(p); - p = obs_properties_add_list(group, S_ZOOM_IN, obs_module_text("Zoom"), - OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); - obs_property_list_add_int(p, obs_module_text("NoOverride"), - NO_OVERRIDE); + p = obs_properties_add_list(group, S_ZOOM_IN, obs_module_text("Zoom"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); + obs_property_list_add_int(p, obs_module_text("NoOverride"), NO_OVERRIDE); obs_property_list_add_int(p, obs_module_text("No"), ZOOM_NO); obs_property_list_add_int(p, obs_module_text("Yes"), ZOOM_YES); - p = obs_properties_add_list(group, S_POSITION_IN, - obs_module_text("Position"), - OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); - obs_property_list_add_int(p, obs_module_text("NoOverride"), - NO_OVERRIDE); + p = obs_properties_add_list(group, S_POSITION_IN, obs_module_text("Position"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); + obs_property_list_add_int(p, obs_module_text("NoOverride"), NO_OVERRIDE); prop_list_add_positions(p); - p = obs_properties_add_list(group, S_TRANSITION_IN, - obs_module_text("Transition"), - OBS_COMBO_TYPE_LIST, + p = obs_properties_add_list(group, S_TRANSITION_IN, obs_module_text("Transition"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING); obs_property_list_add_string(p, obs_module_text("NoOverride"), NULL); prop_list_add_transitions(p); curve_group = obs_properties_create(); - obs_properties_add_float_slider(curve_group, S_CURVE_IN, - obs_module_text("Curve"), -2.0, 2.0, - 0.01); - obs_properties_add_group(group, S_CURVE_OVERRIDE_IN, - obs_module_text("CurveOverride"), - OBS_GROUP_CHECKABLE, curve_group); + obs_properties_add_float_slider(curve_group, S_CURVE_IN, obs_module_text("Curve"), -2.0, 2.0, 0.01); + obs_properties_add_group(group, S_CURVE_OVERRIDE_IN, obs_module_text("CurveOverride"), OBS_GROUP_CHECKABLE, curve_group); - p = obs_properties_add_list(group, S_START_MOVE_IN, - obs_module_text("StartMove"), - OBS_COMBO_TYPE_EDITABLE, + p = obs_properties_add_list(group, S_START_MOVE_IN, obs_module_text("StartMove"), OBS_COMBO_TYPE_EDITABLE, OBS_COMBO_FORMAT_STRING); obs_property_list_add_string(p, "", ""); obs_source_enum_filters(parent, prop_list_add_move_source_filter, p); if (source) - obs_source_enum_filters(source, - prop_list_add_move_source_filter, p); + obs_source_enum_filters(source, prop_list_add_move_source_filter, p); - obs_properties_add_group(ppts, S_MOVE_IN, obs_module_text("MoveIn"), - OBS_GROUP_NORMAL, group); + obs_properties_add_group(ppts, S_MOVE_IN, obs_module_text("MoveIn"), OBS_GROUP_NORMAL, group); //Move out group = obs_properties_create(); - p = obs_properties_add_int_slider(group, S_START_DELAY_OUT, - obs_module_text("StartDelay"), -1, - 100, 1); + p = obs_properties_add_int_slider(group, S_START_DELAY_OUT, obs_module_text("StartDelay"), -1, 100, 1); obs_property_int_set_suffix(p, "%"); - p = obs_properties_add_int_slider(group, S_END_DELAY_OUT, - obs_module_text("EndDelay"), -1, 100, - 1); + p = obs_properties_add_int_slider(group, S_END_DELAY_OUT, obs_module_text("EndDelay"), -1, 100, 1); obs_property_int_set_suffix(p, "%"); - p = obs_properties_add_list(group, S_EASING_OUT, - obs_module_text("Easing"), - OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); - obs_property_list_add_int(p, obs_module_text("NoOverride"), - NO_OVERRIDE); + p = obs_properties_add_list(group, S_EASING_OUT, obs_module_text("Easing"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); + obs_property_list_add_int(p, obs_module_text("NoOverride"), NO_OVERRIDE); prop_list_add_easings(p); - p = obs_properties_add_list(group, S_EASING_FUNCTION_OUT, - obs_module_text("EasingFunction"), - OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); - obs_property_list_add_int(p, obs_module_text("NoOverride"), - NO_OVERRIDE); + p = obs_properties_add_list(group, S_EASING_FUNCTION_OUT, obs_module_text("EasingFunction"), OBS_COMBO_TYPE_LIST, + OBS_COMBO_FORMAT_INT); + obs_property_list_add_int(p, obs_module_text("NoOverride"), NO_OVERRIDE); prop_list_add_easing_functions(p); - p = obs_properties_add_list(group, S_ZOOM_OUT, obs_module_text("Zoom"), - OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); - obs_property_list_add_int(p, obs_module_text("NoOverride"), - NO_OVERRIDE); + p = obs_properties_add_list(group, S_ZOOM_OUT, obs_module_text("Zoom"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); + obs_property_list_add_int(p, obs_module_text("NoOverride"), NO_OVERRIDE); obs_property_list_add_int(p, obs_module_text("No"), ZOOM_NO); obs_property_list_add_int(p, obs_module_text("Yes"), ZOOM_YES); - p = obs_properties_add_list(group, S_POSITION_OUT, - obs_module_text("Position"), - OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); - obs_property_list_add_int(p, obs_module_text("NoOverride"), - NO_OVERRIDE); + p = obs_properties_add_list(group, S_POSITION_OUT, obs_module_text("Position"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); + obs_property_list_add_int(p, obs_module_text("NoOverride"), NO_OVERRIDE); prop_list_add_positions(p); - p = obs_properties_add_list(group, S_TRANSITION_OUT, - obs_module_text("Transition"), - OBS_COMBO_TYPE_LIST, + p = obs_properties_add_list(group, S_TRANSITION_OUT, obs_module_text("Transition"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING); obs_property_list_add_string(p, obs_module_text("NoOverride"), NULL); prop_list_add_transitions(p); curve_group = obs_properties_create(); - obs_properties_add_float_slider(curve_group, S_CURVE_OUT, - obs_module_text("Curve"), -2.0, 2.0, - 0.01); - obs_properties_add_group(group, S_CURVE_OVERRIDE_OUT, - obs_module_text("CurveOverride"), - OBS_GROUP_CHECKABLE, curve_group); + obs_properties_add_float_slider(curve_group, S_CURVE_OUT, obs_module_text("Curve"), -2.0, 2.0, 0.01); + obs_properties_add_group(group, S_CURVE_OVERRIDE_OUT, obs_module_text("CurveOverride"), OBS_GROUP_CHECKABLE, curve_group); - p = obs_properties_add_list(group, S_START_MOVE_OUT, - obs_module_text("StartMove"), - OBS_COMBO_TYPE_EDITABLE, + p = obs_properties_add_list(group, S_START_MOVE_OUT, obs_module_text("StartMove"), OBS_COMBO_TYPE_EDITABLE, OBS_COMBO_FORMAT_STRING); obs_property_list_add_string(p, "", ""); obs_source_enum_filters(parent, prop_list_add_move_source_filter, p); if (source) - obs_source_enum_filters(source, - prop_list_add_move_source_filter, p); + obs_source_enum_filters(source, prop_list_add_move_source_filter, p); - obs_properties_add_group(ppts, S_MOVE_OUT, obs_module_text("MoveOut"), - OBS_GROUP_NORMAL, group); - obs_properties_add_text(ppts, "plugin_info", PLUGIN_INFO, - OBS_TEXT_INFO); + obs_properties_add_group(ppts, S_MOVE_OUT, obs_module_text("MoveOut"), OBS_GROUP_NORMAL, group); + obs_properties_add_text(ppts, "plugin_info", PLUGIN_INFO, OBS_TEXT_INFO); return ppts; } void move_override_filter_defaults(obs_data_t *settings) { obs_data_set_default_int(settings, S_START_DELAY_MATCH_TO, NO_OVERRIDE); - obs_data_set_default_int(settings, S_START_DELAY_MATCH_FROM, - NO_OVERRIDE); + obs_data_set_default_int(settings, S_START_DELAY_MATCH_FROM, NO_OVERRIDE); obs_data_set_default_int(settings, S_START_DELAY_IN, NO_OVERRIDE); obs_data_set_default_int(settings, S_START_DELAY_OUT, NO_OVERRIDE); obs_data_set_default_int(settings, S_END_DELAY_MATCH_TO, NO_OVERRIDE); @@ -327,8 +236,7 @@ void move_override_filter_defaults(obs_data_t *settings) obs_data_set_default_int(settings, S_EASING_MATCH, NO_OVERRIDE); obs_data_set_default_int(settings, S_EASING_IN, NO_OVERRIDE); obs_data_set_default_int(settings, S_EASING_OUT, NO_OVERRIDE); - obs_data_set_default_int(settings, S_EASING_FUNCTION_MATCH, - NO_OVERRIDE); + obs_data_set_default_int(settings, S_EASING_FUNCTION_MATCH, NO_OVERRIDE); obs_data_set_default_int(settings, S_EASING_FUNCTION_IN, NO_OVERRIDE); obs_data_set_default_int(settings, S_EASING_FUNCTION_OUT, NO_OVERRIDE); obs_data_set_default_int(settings, S_POSITION_IN, NO_OVERRIDE); @@ -351,13 +259,12 @@ static const char *move_override_filter_get_name(void *type_data) return obs_module_text("MoveTransitionOverrideFilter"); } -struct obs_source_info move_transition_override_filter = { - .id = "move_transition_override_filter", - .type = OBS_SOURCE_TYPE_FILTER, - .output_flags = OBS_SOURCE_VIDEO, - .get_name = move_override_filter_get_name, - .create = move_override_filter_create, - .destroy = move_override_filter_destroy, - .get_properties = move_override_filter_properties, - .get_defaults = move_override_filter_defaults, - .video_render = move_override_filter_video_render}; +struct obs_source_info move_transition_override_filter = {.id = "move_transition_override_filter", + .type = OBS_SOURCE_TYPE_FILTER, + .output_flags = OBS_SOURCE_VIDEO, + .get_name = move_override_filter_get_name, + .create = move_override_filter_create, + .destroy = move_override_filter_destroy, + .get_properties = move_override_filter_properties, + .get_defaults = move_override_filter_defaults, + .video_render = move_override_filter_video_render}; diff --git a/move-transition.c b/move-transition.c index 5c2ed55..4edef22 100644 --- a/move-transition.c +++ b/move-transition.c @@ -249,12 +249,9 @@ static void move_update(void *data, obs_data_t *settings) move->easing_move = obs_data_get_int(settings, S_EASING_MATCH); move->easing_in = obs_data_get_int(settings, S_EASING_IN); move->easing_out = obs_data_get_int(settings, S_EASING_OUT); - move->easing_function_move = - obs_data_get_int(settings, S_EASING_FUNCTION_MATCH); - move->easing_function_in = - obs_data_get_int(settings, S_EASING_FUNCTION_IN); - move->easing_function_out = - obs_data_get_int(settings, S_EASING_FUNCTION_OUT); + move->easing_function_move = obs_data_get_int(settings, S_EASING_FUNCTION_MATCH); + move->easing_function_in = obs_data_get_int(settings, S_EASING_FUNCTION_IN); + move->easing_function_out = obs_data_get_int(settings, S_EASING_FUNCTION_OUT); move->position_in = obs_data_get_int(settings, S_POSITION_IN); move->zoom_in = obs_data_get_bool(settings, S_ZOOM_IN); move->position_out = obs_data_get_int(settings, S_POSITION_OUT); @@ -263,42 +260,29 @@ static void move_update(void *data, obs_data_t *settings) move->curve_in = (float)obs_data_get_double(settings, S_CURVE_IN); move->curve_out = (float)obs_data_get_double(settings, S_CURVE_OUT); bfree(move->transition_in); - move->transition_in = - bstrdup(obs_data_get_string(settings, S_TRANSITION_IN)); - if (move->transition_in && strlen(move->transition_in) && - move->transition_pool_in.num && - strcmp(obs_source_get_name(move->transition_pool_in.array[0]), - move->transition_in) != 0) { + move->transition_in = bstrdup(obs_data_get_string(settings, S_TRANSITION_IN)); + if (move->transition_in && strlen(move->transition_in) && move->transition_pool_in.num && + strcmp(obs_source_get_name(move->transition_pool_in.array[0]), move->transition_in) != 0) { clear_transition_pool(&move->transition_pool_in); } bfree(move->transition_out); - move->transition_out = - bstrdup(obs_data_get_string(settings, S_TRANSITION_OUT)); - if (move->transition_out && strlen(move->transition_out) && - move->transition_pool_out.num && - strcmp(obs_source_get_name(move->transition_pool_out.array[0]), - move->transition_out) != 0) { + move->transition_out = bstrdup(obs_data_get_string(settings, S_TRANSITION_OUT)); + if (move->transition_out && strlen(move->transition_out) && move->transition_pool_out.num && + strcmp(obs_source_get_name(move->transition_pool_out.array[0]), move->transition_out) != 0) { clear_transition_pool(&move->transition_pool_out); } move->part_match = obs_data_get_bool(settings, S_NAME_PART_MATCH); move->number_match = obs_data_get_bool(settings, S_NAME_NUMBER_MATCH); - move->last_word_match = - obs_data_get_bool(settings, S_NAME_LAST_WORD_MATCH); + move->last_word_match = obs_data_get_bool(settings, S_NAME_LAST_WORD_MATCH); bfree(move->transition_move); - move->transition_move = - bstrdup(obs_data_get_string(settings, S_TRANSITION_MATCH)); - if (move->transition_move && strlen(move->transition_move) && - move->transition_pool_move.num && - strcmp(obs_source_get_name(move->transition_pool_move.array[0]), - move->transition_move) != 0) { + move->transition_move = bstrdup(obs_data_get_string(settings, S_TRANSITION_MATCH)); + if (move->transition_move && strlen(move->transition_move) && move->transition_pool_move.num && + strcmp(obs_source_get_name(move->transition_pool_move.array[0]), move->transition_move) != 0) { clear_transition_pool(&move->transition_pool_move); } - move->transition_move_scale = - obs_data_get_int(settings, S_TRANSITION_SCALE); - move->item_order_switch_percentage = - (uint32_t)obs_data_get_int(settings, S_SWITCH_PERCENTAGE); - move->cache_transitions = - obs_data_get_bool(settings, S_CACHE_TRANSITIONS); + move->transition_move_scale = obs_data_get_int(settings, S_TRANSITION_SCALE); + move->item_order_switch_percentage = (uint32_t)obs_data_get_int(settings, S_SWITCH_PERCENTAGE); + move->cache_transitions = obs_data_get_bool(settings, S_CACHE_TRANSITIONS); move->nested_scenes = obs_data_get_bool(settings, S_NESTED_SCENES); } @@ -315,8 +299,7 @@ void add_alignment(struct vec2 *v, uint32_t align, int32_t cx, int32_t cy) v->y += (float)(cy >> 1); } -void add_move_alignment(struct vec2 *v, uint32_t align_a, uint32_t align_b, - float t, int32_t cx, int32_t cy) +void add_move_alignment(struct vec2 *v, uint32_t align_a, uint32_t align_b, float t, int32_t cx, int32_t cy) { if (align_a & OBS_ALIGN_RIGHT) v->x += (float)cx * (1.0f - t); @@ -341,8 +324,7 @@ void add_move_alignment(struct vec2 *v, uint32_t align_a, uint32_t align_b, static bool crop_to_bounds(const obs_sceneitem_t *item, enum obs_bounds_type bt) { - if (bt != OBS_BOUNDS_SCALE_OUTER && bt != OBS_BOUNDS_SCALE_TO_HEIGHT && - bt != OBS_BOUNDS_SCALE_TO_WIDTH) + if (bt != OBS_BOUNDS_SCALE_OUTER && bt != OBS_BOUNDS_SCALE_TO_HEIGHT && bt != OBS_BOUNDS_SCALE_TO_WIDTH) return false; #if LIBOBS_API_VER >= MAKE_SEMANTIC_VERSION(30, 1, 0) return obs_sceneitem_get_bounds_crop(item); @@ -365,12 +347,9 @@ static bool crop_to_bounds(const obs_sceneitem_t *item, enum obs_bounds_type bt) bool crop_to_bounds = false; for (size_t i = 0; i < count; i++) { obs_data_t *item_data = obs_data_array_item(items, i); - if (obs_sceneitem_get_id(item) == - obs_data_get_int(item_data, "id") && - strcmp(obs_data_get_string(item_data, "name"), - obs_source_get_name(item_source)) == 0) { - crop_to_bounds = - obs_data_get_bool(item_data, "bounds_crop"); + if (obs_sceneitem_get_id(item) == obs_data_get_int(item_data, "id") && + strcmp(obs_data_get_string(item_data, "name"), obs_source_get_name(item_source)) == 0) { + crop_to_bounds = obs_data_get_bool(item_data, "bounds_crop"); obs_data_release(item_data); break; } @@ -381,9 +360,8 @@ static bool crop_to_bounds(const obs_sceneitem_t *item, enum obs_bounds_type bt) #endif } -static void calculate_bounds_data(struct obs_scene_item *item, - struct vec2 *origin, struct vec2 *scale, - int32_t *cx, int32_t *cy, struct vec2 *bounds) +static void calculate_bounds_data(struct obs_scene_item *item, struct vec2 *origin, struct vec2 *scale, int32_t *cx, int32_t *cy, + struct vec2 *bounds) { float width = (float)(*cx) * fabsf(scale->x); float height = (float)(*cy) * fabsf(scale->y); @@ -395,15 +373,13 @@ static void calculate_bounds_data(struct obs_scene_item *item, if (width > bounds->x || height > bounds->y) bounds_type = OBS_BOUNDS_SCALE_INNER; - if (bounds_type == OBS_BOUNDS_SCALE_INNER || - bounds_type == OBS_BOUNDS_SCALE_OUTER) { + if (bounds_type == OBS_BOUNDS_SCALE_INNER || bounds_type == OBS_BOUNDS_SCALE_OUTER) { bool use_width = (bounds_aspect < item_aspect); if (bounds_type == OBS_BOUNDS_SCALE_OUTER) use_width = !use_width; - const float mul = use_width ? bounds->x / width - : bounds->y / height; + const float mul = use_width ? bounds->x / width : bounds->y / height; vec2_mulf(scale, scale, mul); @@ -427,13 +403,11 @@ static void calculate_bounds_data(struct obs_scene_item *item, *cx = (uint32_t)bounds->x; *cy = (uint32_t)bounds->y; - add_alignment(origin, obs_sceneitem_get_bounds_alignment(item), - (int32_t)-roundf(width_diff), + add_alignment(origin, obs_sceneitem_get_bounds_alignment(item), (int32_t)-roundf(width_diff), (int32_t)-roundf(height_diff)); /* Set cropping if enabled and large enough size difference exists */ - if (crop_to_bounds(item, bounds_type) && - (width_diff < -0.1 || height_diff < -0.1)) { + if (crop_to_bounds(item, bounds_type) && (width_diff < -0.1 || height_diff < -0.1)) { bool crop_width = width_diff < -0.1; bool crop_flipped = crop_width ? width < 0.0f : height < 0.0f; @@ -441,11 +415,8 @@ static void calculate_bounds_data(struct obs_scene_item *item, float crop_origin = crop_width ? origin->x : origin->y; /* Only get alignment for relevant axis */ - uint32_t crop_align_mask = - crop_width ? OBS_ALIGN_LEFT | OBS_ALIGN_RIGHT - : OBS_ALIGN_TOP | OBS_ALIGN_BOTTOM; - uint32_t crop_align = obs_sceneitem_get_bounds_alignment(item) & - crop_align_mask; + uint32_t crop_align_mask = crop_width ? OBS_ALIGN_LEFT | OBS_ALIGN_RIGHT : OBS_ALIGN_TOP | OBS_ALIGN_BOTTOM; + uint32_t crop_align = obs_sceneitem_get_bounds_alignment(item) & crop_align_mask; if (crop_flipped) { /* Adjust origin for flips */ @@ -469,11 +440,8 @@ static void calculate_bounds_data(struct obs_scene_item *item, origin->y += (height < 0.0f) ? height : 0.0f; } -static void calculate_move_bounds_data(struct obs_scene_item *item_a, - struct obs_scene_item *item_b, float t, - struct vec2 *origin, struct vec2 *scale, - int32_t *cx, int32_t *cy, - struct vec2 *bounds) +static void calculate_move_bounds_data(struct obs_scene_item *item_a, struct obs_scene_item *item_b, float t, struct vec2 *origin, + struct vec2 *scale, int32_t *cx, int32_t *cy, struct vec2 *bounds) { struct vec2 origin_a; vec2_set(&origin_a, origin->x, origin->y); @@ -490,10 +458,8 @@ static void calculate_move_bounds_data(struct obs_scene_item *item_a, int32_t cyb = *cy; calculate_bounds_data(item_a, &origin_a, &scale_a, &cxa, &cya, bounds); calculate_bounds_data(item_b, &origin_b, &scale_b, &cxb, &cyb, bounds); - vec2_set(origin, origin_a.x * (1.0f - t) + origin_b.x * t, - origin_a.y * (1.0f - t) + origin_b.y * t); - vec2_set(scale, scale_a.x * (1.0f - t) + scale_b.x * t, - scale_a.y * (1.0f - t) + scale_b.y * t); + vec2_set(origin, origin_a.x * (1.0f - t) + origin_b.x * t, origin_a.y * (1.0f - t) + origin_b.y * t); + vec2_set(scale, scale_a.x * (1.0f - t) + scale_b.x * t, scale_a.y * (1.0f - t) + scale_b.y * t); *cx = (int32_t)roundf((float)cxa * (1.0f - t) + (float)cxb * t); *cy = (int32_t)roundf((float)cya * (1.0f - t) + (float)cyb * t); } @@ -519,20 +485,17 @@ static inline bool default_blending_enabled(struct obs_scene_item *item) return obs_sceneitem_get_blending_mode(item) == OBS_BLEND_NORMAL; } -static inline bool item_texture_enabled(struct obs_scene_item *item, - struct obs_sceneitem_crop *bounds_crop) +static inline bool item_texture_enabled(struct obs_scene_item *item, struct obs_sceneitem_crop *bounds_crop) { if (!item) false; struct obs_sceneitem_crop crop; obs_sceneitem_get_crop(item, &crop); - return crop_enabled(&crop) || crop_enabled(bounds_crop) || - scale_filter_enabled(item) || !default_blending_enabled(item) || + return crop_enabled(&crop) || crop_enabled(bounds_crop) || scale_filter_enabled(item) || !default_blending_enabled(item) || (item_is_scene(item) && !obs_sceneitem_is_group(item)); } -void pos_add_center(struct vec2 *pos, uint32_t alignment, uint32_t cx, - uint32_t cy) +void pos_add_center(struct vec2 *pos, uint32_t alignment, uint32_t cx, uint32_t cy) { if (alignment & OBS_ALIGN_LEFT) { pos->x -= cx >> 1; @@ -546,8 +509,7 @@ void pos_add_center(struct vec2 *pos, uint32_t alignment, uint32_t cx, } } -void pos_subtract_center(struct vec2 *pos, uint32_t alignment, int32_t cx, - int32_t cy) +void pos_subtract_center(struct vec2 *pos, uint32_t alignment, int32_t cx, int32_t cy) { if (alignment & OBS_ALIGN_LEFT) { pos->x += cx >> 1; @@ -561,9 +523,8 @@ void pos_subtract_center(struct vec2 *pos, uint32_t alignment, int32_t cx, } } -void calc_edge_position(struct vec2 *pos, long long position, - uint32_t canvas_width, uint32_t canvas_height, - uint32_t alignment, int32_t cx, int32_t cy, bool zoom) +void calc_edge_position(struct vec2 *pos, long long position, uint32_t canvas_width, uint32_t canvas_height, uint32_t alignment, + int32_t cx, int32_t cy, bool zoom) { int32_t cx2 = abs(cx >> 1); int32_t cy2 = abs(cy >> 1); @@ -596,37 +557,25 @@ void calc_edge_position(struct vec2 *pos, long long position, if (diff_x < 0.0f) { //left edge const float move_x = -(pos->x + cx2); - const float move_y = - diff_y * (diff_x + move_x) / diff_x; - vec2_set(pos, -(float)cx2, - (float)(canvas_height >> 1) + move_y); + const float move_y = diff_y * (diff_x + move_x) / diff_x; + vec2_set(pos, -(float)cx2, (float)(canvas_height >> 1) + move_y); } else { //right edge - const float move_x = - (canvas_width - pos->x) + cx2; - const float move_y = - diff_y * (diff_x + move_x) / diff_x; - vec2_set(pos, (float)canvas_width + cx2, - (float)(canvas_height >> 1) + move_y); + const float move_x = (canvas_width - pos->x) + cx2; + const float move_y = diff_y * (diff_x + move_x) / diff_x; + vec2_set(pos, (float)canvas_width + cx2, (float)(canvas_height >> 1) + move_y); } } else { if (diff_y < 0.0f) { //top edge const float move_y = -(pos->y + cy2); - const float move_x = - diff_x * (diff_y + move_y) / diff_y; - vec2_set(pos, - (float)(canvas_width >> 1) + move_x, - -(float)cy2); + const float move_x = diff_x * (diff_y + move_y) / diff_y; + vec2_set(pos, (float)(canvas_width >> 1) + move_x, -(float)cy2); } else { //bottom edge - const float move_y = - (canvas_height - pos->y) + cy2; - const float move_x = - diff_x * (diff_y + move_y) / diff_y; - vec2_set(pos, - (float)(canvas_width >> 1) + move_x, - (float)canvas_height + cy2); + const float move_y = (canvas_height - pos->y) + cy2; + const float move_x = diff_x * (diff_y + move_y) / diff_y; + vec2_set(pos, (float)(canvas_width >> 1) + move_x, (float)canvas_height + cy2); } } @@ -725,12 +674,10 @@ float bezier(float point[], float t, int order) return point[0]; if (order == 1) return p * point[0] + t * point[1]; - return p * bezier(point, t, order - 1) + - t * bezier(&point[1], t, order - 1); + return p * bezier(point, t, order - 1) + t * bezier(&point[1], t, order - 1); } -void vec2_bezier(struct vec2 *dst, struct vec2 *begin, struct vec2 *control, - struct vec2 *end, const float t) +void vec2_bezier(struct vec2 *dst, struct vec2 *begin, struct vec2 *control, struct vec2 *end, const float t) { float x[3] = {begin->x, control->x, end->x}; float y[3] = {begin->y, control->y, end->y}; @@ -745,11 +692,9 @@ static obs_source_t *obs_frontend_get_transition(const char *name) struct obs_frontend_source_list transitions = {0}; obs_frontend_get_transitions(&transitions); for (size_t i = 0; i < transitions.sources.num; i++) { - const char *n = - obs_source_get_name(transitions.sources.array[i]); + const char *n = obs_source_get_name(transitions.sources.array[i]); if (n && strcmp(n, name) == 0) { - obs_source_t *transition = obs_source_get_ref( - transitions.sources.array[i]); + obs_source_t *transition = obs_source_get_ref(transitions.sources.array[i]); obs_frontend_source_list_free(&transitions); return transition; } @@ -868,32 +813,26 @@ float get_eased(float f, long long easing, long long easing_function) return t; } -obs_source_t *get_transition(const char *transition_name, void *pool_data, - size_t *index, bool cache) +obs_source_t *get_transition(const char *transition_name, void *pool_data, size_t *index, bool cache) { - if (!transition_name || strlen(transition_name) == 0 || - strcmp(transition_name, "None") == 0) + if (!transition_name || strlen(transition_name) == 0 || strcmp(transition_name, "None") == 0) return NULL; DARRAY(obs_source_t *) *transition_pool = pool_data; const size_t i = *index; if (cache && transition_pool->num && *index < transition_pool->num) { - obs_source_t *transition = - obs_source_get_ref(transition_pool->array[i]); + obs_source_t *transition = obs_source_get_ref(transition_pool->array[i]); *index = i + 1; return transition; } - obs_source_t *frontend_transition = - obs_frontend_get_transition(transition_name); + obs_source_t *frontend_transition = obs_frontend_get_transition(transition_name); if (!frontend_transition) return NULL; - obs_source_t *transition = obs_source_duplicate(frontend_transition, - transition_name, true); + obs_source_t *transition = obs_source_duplicate(frontend_transition, transition_name, true); obs_source_release(frontend_transition); if (cache) { transition = obs_source_get_ref(transition); - darray_push_back(sizeof(obs_source_t *), &transition_pool->da, - &transition); + darray_push_back(sizeof(obs_source_t *), &transition_pool->da, &transition); *index = i + 1; } return transition; @@ -909,11 +848,8 @@ float rot_diff(float rot_a, float rot_b) return diff; } -static void calculate_bounds_item(const obs_sceneitem_t *item, - struct vec2 *origin, struct vec2 *scale, - uint32_t *cx, uint32_t *cy, float *calc_width, - float *calc_height, - struct obs_sceneitem_crop *bounds_crop, +static void calculate_bounds_item(const obs_sceneitem_t *item, struct vec2 *origin, struct vec2 *scale, uint32_t *cx, uint32_t *cy, + float *calc_width, float *calc_height, struct obs_sceneitem_crop *bounds_crop, enum obs_bounds_type bt) { float width = (float)(*cx) * fabsf(scale->x); @@ -963,12 +899,10 @@ static void calculate_bounds_item(const obs_sceneitem_t *item, *cx = (uint32_t)bounds.x; *cy = (uint32_t)bounds.y; - add_alignment(origin, obs_sceneitem_get_bounds_alignment(item), - (int)-width_diff, (int)-height_diff); + add_alignment(origin, obs_sceneitem_get_bounds_alignment(item), (int)-width_diff, (int)-height_diff); /* Set cropping if enabled and large enough size difference exists */ - if (crop_to_bounds(item, bt) && - (width_diff < -0.1 || height_diff < -0.1)) { + if (crop_to_bounds(item, bt) && (width_diff < -0.1 || height_diff < -0.1)) { bool crop_width = width_diff < -0.1; bool crop_flipped = crop_width ? width < 0.0f : height < 0.0f; @@ -977,11 +911,8 @@ static void calculate_bounds_item(const obs_sceneitem_t *item, float crop_origin = crop_width ? origin->x : origin->y; /* Only get alignment for relevant axis */ - uint32_t crop_align_mask = - crop_width ? OBS_ALIGN_LEFT | OBS_ALIGN_RIGHT - : OBS_ALIGN_TOP | OBS_ALIGN_BOTTOM; - uint32_t crop_align = obs_sceneitem_get_bounds_alignment(item) & - crop_align_mask; + uint32_t crop_align_mask = crop_width ? OBS_ALIGN_LEFT | OBS_ALIGN_RIGHT : OBS_ALIGN_TOP | OBS_ALIGN_BOTTOM; + uint32_t crop_align = obs_sceneitem_get_bounds_alignment(item) & crop_align_mask; /* Cropping values need to scaled to input source */ float overdraw = fabsf(crop_diff / crop_scale); @@ -1030,8 +961,7 @@ static void calculate_bounds_item(const obs_sceneitem_t *item, origin->y += (height < 0.0f) ? height : 0.0f; } -void move_get_draw_transform(const obs_sceneitem_t *item, bool flip_horizontal, - bool flip_vertical, struct matrix4 *transform, +void move_get_draw_transform(const obs_sceneitem_t *item, bool flip_horizontal, bool flip_vertical, struct matrix4 *transform, struct obs_sceneitem_crop *bounds_crop) { uint32_t width = obs_source_get_width(obs_sceneitem_get_source(item)); @@ -1049,21 +979,17 @@ void move_get_draw_transform(const obs_sceneitem_t *item, bool flip_horizontal, struct obs_sceneitem_crop crop; obs_sceneitem_get_crop(item, &crop); - uint32_t crop_cx = - crop.left + crop.right + bounds_crop->left + bounds_crop->right; + uint32_t crop_cx = crop.left + crop.right + bounds_crop->left + bounds_crop->right; cx = (crop_cx > width) ? 2 : (width - crop_cx); - uint32_t crop_cy = - crop.top + crop.bottom + bounds_crop->top + bounds_crop->bottom; + uint32_t crop_cy = crop.top + crop.bottom + bounds_crop->top + bounds_crop->bottom; cy = (crop_cy > height) ? 2 : (height - crop_cy); enum obs_bounds_type bt = obs_sceneitem_get_bounds_type(item); float width_diff, height_diff = 0.0f; if (bt != OBS_BOUNDS_NONE) { - calculate_bounds_item(item, &origin, &scale, &cx, &cy, - &width_diff, &height_diff, bounds_crop, - bt); + calculate_bounds_item(item, &origin, &scale, &cx, &cy, &width_diff, &height_diff, bounds_crop, bt); } else { cx = (uint32_t)((float)cx * fabs(scale.x)); @@ -1099,8 +1025,7 @@ void move_get_draw_transform(const obs_sceneitem_t *item, bool flip_horizontal, matrix4_identity(transform); matrix4_scale3f(transform, transform, scale.x, scale.y, 1.0f); matrix4_translate3f(transform, transform, -origin.x, -origin.y, 0.0f); - matrix4_rotate_aa4f(transform, transform, 0.0f, 0.0f, 1.0f, - RAD(obs_sceneitem_get_rot(item))); + matrix4_rotate_aa4f(transform, transform, 0.0f, 0.0f, 1.0f, RAD(obs_sceneitem_get_rot(item))); matrix4_translate3f(transform, transform, pos.x, pos.y, 0.0f); } @@ -1126,124 +1051,77 @@ bool render2_item(struct move_info *move, struct move_item *item) if (item->item_a && item->item_b) { if (!item->transition) { if (item->move_scene) { - item->transition = get_transition( - obs_source_get_name(move->source), - &move->transition_pool_move, - &move->transition_pool_move_index, - move->cache_transitions); - struct move_info *mt = - (struct move_info *)obs_obj_get_data( - item->transition); + item->transition = get_transition(obs_source_get_name(move->source), &move->transition_pool_move, + &move->transition_pool_move_index, move->cache_transitions); + struct move_info *mt = (struct move_info *)obs_obj_get_data(item->transition); if (mt) { - mt->scene_flip_horizontal = - item->scene_flip_horizontal; - mt->scene_flip_vertical = - item->scene_flip_vertical; + mt->scene_flip_horizontal = item->scene_flip_horizontal; + mt->scene_flip_vertical = item->scene_flip_vertical; } } else { - item->transition = get_transition( - item->transition_name, - &move->transition_pool_move, - &move->transition_pool_move_index, - move->cache_transitions); + item->transition = get_transition(item->transition_name, &move->transition_pool_move, + &move->transition_pool_move_index, move->cache_transitions); } if (item->transition) { - obs_transition_set_size(item->transition, width, - height); - obs_transition_set_alignment(item->transition, - OBS_ALIGN_CENTER); - obs_transition_set_scale_type( - item->transition, - item->transition_scale); - obs_transition_set( - item->transition, - obs_sceneitem_get_source(item->item_a)); - obs_transition_start( - item->transition, - obs_transition_fixed(item->transition) - ? OBS_TRANSITION_MODE_AUTO - : OBS_TRANSITION_MODE_MANUAL, - obs_frontend_get_transition_duration(), - obs_sceneitem_get_source(item->item_b)); + obs_transition_set_size(item->transition, width, height); + obs_transition_set_alignment(item->transition, OBS_ALIGN_CENTER); + obs_transition_set_scale_type(item->transition, item->transition_scale); + obs_transition_set(item->transition, obs_sceneitem_get_source(item->item_a)); + obs_transition_start(item->transition, + obs_transition_fixed(item->transition) ? OBS_TRANSITION_MODE_AUTO + : OBS_TRANSITION_MODE_MANUAL, + obs_frontend_get_transition_duration(), + obs_sceneitem_get_source(item->item_b)); } } } else if (item->move_scene) { if (item->transition_name && !item->transition) { - item->transition = get_transition( - item->transition_name, - &move->transition_pool_move, - &move->transition_pool_move_index, - move->cache_transitions); + item->transition = get_transition(item->transition_name, &move->transition_pool_move, + &move->transition_pool_move_index, move->cache_transitions); if (item->transition) { - obs_transition_set_size(item->transition, width, - height); - obs_transition_set_alignment(item->transition, - OBS_ALIGN_CENTER); - obs_transition_set_scale_type( - item->transition, - item->transition_scale); - obs_transition_set( - item->transition, - obs_sceneitem_get_source(scene_item)); - obs_transition_start( - item->transition, - obs_transition_fixed(item->transition) - ? OBS_TRANSITION_MODE_AUTO - : OBS_TRANSITION_MODE_MANUAL, - obs_frontend_get_transition_duration(), - obs_sceneitem_get_source(scene_item)); + obs_transition_set_size(item->transition, width, height); + obs_transition_set_alignment(item->transition, OBS_ALIGN_CENTER); + obs_transition_set_scale_type(item->transition, item->transition_scale); + obs_transition_set(item->transition, obs_sceneitem_get_source(scene_item)); + obs_transition_start(item->transition, + obs_transition_fixed(item->transition) ? OBS_TRANSITION_MODE_AUTO + : OBS_TRANSITION_MODE_MANUAL, + obs_frontend_get_transition_duration(), obs_sceneitem_get_source(scene_item)); } } } else if (move_out && item->transition_name && !item->transition) { - item->transition = get_transition( - item->transition_name, &move->transition_pool_out, - &move->transition_pool_out_index, - move->cache_transitions); + item->transition = get_transition(item->transition_name, &move->transition_pool_out, + &move->transition_pool_out_index, move->cache_transitions); if (item->transition) { - obs_transition_set_size(item->transition, width, - height); - obs_transition_set_alignment(item->transition, - OBS_ALIGN_CENTER); - obs_transition_set_scale_type( - item->transition, OBS_TRANSITION_SCALE_ASPECT); + obs_transition_set_size(item->transition, width, height); + obs_transition_set_alignment(item->transition, OBS_ALIGN_CENTER); + obs_transition_set_scale_type(item->transition, OBS_TRANSITION_SCALE_ASPECT); obs_transition_set(item->transition, source); - obs_transition_start( - item->transition, - obs_transition_fixed(item->transition) - ? OBS_TRANSITION_MODE_AUTO - : OBS_TRANSITION_MODE_MANUAL, - obs_frontend_get_transition_duration(), NULL); + obs_transition_start(item->transition, + obs_transition_fixed(item->transition) ? OBS_TRANSITION_MODE_AUTO + : OBS_TRANSITION_MODE_MANUAL, + obs_frontend_get_transition_duration(), NULL); } } else if (!move_out && item->transition_name && !item->transition) { - item->transition = get_transition( - item->transition_name, &move->transition_pool_in, - &move->transition_pool_in_index, - move->cache_transitions); + item->transition = get_transition(item->transition_name, &move->transition_pool_in, &move->transition_pool_in_index, + move->cache_transitions); if (item->transition) { - obs_transition_set_size(item->transition, width, - height); - obs_transition_set_alignment(item->transition, - OBS_ALIGN_CENTER); - obs_transition_set_scale_type( - item->transition, OBS_TRANSITION_SCALE_ASPECT); + obs_transition_set_size(item->transition, width, height); + obs_transition_set_alignment(item->transition, OBS_ALIGN_CENTER); + obs_transition_set_scale_type(item->transition, OBS_TRANSITION_SCALE_ASPECT); obs_transition_set(item->transition, NULL); - obs_transition_start( - item->transition, - obs_transition_fixed(item->transition) - ? OBS_TRANSITION_MODE_AUTO - : OBS_TRANSITION_MODE_MANUAL, - obs_frontend_get_transition_duration(), source); + obs_transition_start(item->transition, + obs_transition_fixed(item->transition) ? OBS_TRANSITION_MODE_AUTO + : OBS_TRANSITION_MODE_MANUAL, + obs_frontend_get_transition_duration(), source); } } float t = 0.0f; if (item->start_percentage > 0 || item->end_percentage < 100) { if (item->start_percentage > item->end_percentage) { - float avg_switch_point = - (float)(item->start_percentage + - item->end_percentage) / - 200.0f; + float avg_switch_point = (float)(item->start_percentage + item->end_percentage) / 200.0f; if (move->t > avg_switch_point) { t = 1.0f; } @@ -1252,8 +1130,7 @@ bool render2_item(struct move_info *move, struct move_item *item) } else if (move->t * 100.0 > item->end_percentage) { t = 1.0f; } else { - int duration_percentage = - item->end_percentage - item->start_percentage; + int duration_percentage = item->end_percentage - item->start_percentage; t = move->t - (float)item->start_percentage / 100.0f; t = t / (float)duration_percentage * 100.0f; t = get_eased(t, item->easing, item->easing_function); @@ -1268,25 +1145,17 @@ bool render2_item(struct move_info *move, struct move_item *item) ot = 0.0f; if (item->item_a && item->item_b && item->transition && - (!move->first_frame || item->scene_flip_horizontal || - item->scene_flip_vertical)) { - uint32_t width_a = obs_source_get_width( - obs_sceneitem_get_source(item->item_a)); - uint32_t width_b = obs_source_get_width( - obs_sceneitem_get_source(item->item_b)); - uint32_t height_a = obs_source_get_height( - obs_sceneitem_get_source(item->item_a)); - uint32_t height_b = obs_source_get_height( - obs_sceneitem_get_source(item->item_b)); + (!move->first_frame || item->scene_flip_horizontal || item->scene_flip_vertical)) { + uint32_t width_a = obs_source_get_width(obs_sceneitem_get_source(item->item_a)); + uint32_t width_b = obs_source_get_width(obs_sceneitem_get_source(item->item_b)); + uint32_t height_a = obs_source_get_height(obs_sceneitem_get_source(item->item_a)); + uint32_t height_b = obs_source_get_height(obs_sceneitem_get_source(item->item_b)); if (width_a != width_b) - width = (uint32_t)roundf((1.0f - t) * width_a + - t * width_b); + width = (uint32_t)roundf((1.0f - t) * width_a + t * width_b); if (height_a != height_b) - height = (uint32_t)roundf((1.0f - t) * height_a + - t * height_b); + height = (uint32_t)roundf((1.0f - t) * height_a + t * height_b); if (height_a != height_b || width_a != width_b) - obs_transition_set_size(item->transition, width, - height); + obs_transition_set_size(item->transition, width, height); } uint32_t original_width = width; @@ -1334,34 +1203,22 @@ bool render2_item(struct move_info *move, struct move_item *item) obs_sceneitem_get_crop(item->item_a, &crop_a); obs_sceneitem_get_crop(item->item_b, &crop_b); } - crop.left = - (int)roundf((float)(1.0f - ot) * (float)crop_a.left + - ot * (float)crop_b.left); - crop.top = (int)roundf((float)(1.0f - ot) * (float)crop_a.top + - ot * (float)crop_b.top); - crop.right = - (int)roundf((float)(1.0f - ot) * (float)crop_a.right + - ot * (float)crop_b.right); - crop.bottom = - (int)roundf((float)(1.0f - ot) * (float)crop_a.bottom + - ot * (float)crop_b.bottom); + crop.left = (int)roundf((float)(1.0f - ot) * (float)crop_a.left + ot * (float)crop_b.left); + crop.top = (int)roundf((float)(1.0f - ot) * (float)crop_a.top + ot * (float)crop_b.top); + crop.right = (int)roundf((float)(1.0f - ot) * (float)crop_a.right + ot * (float)crop_b.right); + crop.bottom = (int)roundf((float)(1.0f - ot) * (float)crop_a.bottom + ot * (float)crop_b.bottom); } else if (item->move_scene) { obs_sceneitem_get_crop(scene_item, &crop); if (item->item_a) { - crop.left = (int)roundf((float)(1.0f - ot) * - (float)crop.left); - crop.top = (int)roundf((float)(1.0f - ot) * - (float)crop.top); - crop.right = (int)roundf((float)(1.0f - ot) * - (float)crop.right); - crop.bottom = (int)roundf((float)(1.0f - ot) * - (float)crop.bottom); + crop.left = (int)roundf((float)(1.0f - ot) * (float)crop.left); + crop.top = (int)roundf((float)(1.0f - ot) * (float)crop.top); + crop.right = (int)roundf((float)(1.0f - ot) * (float)crop.right); + crop.bottom = (int)roundf((float)(1.0f - ot) * (float)crop.bottom); } else if (item->item_b) { crop.left = (int)roundf((float)ot * (float)crop.left); crop.top = (int)roundf((float)ot * (float)crop.top); crop.right = (int)roundf((float)ot * (float)crop.right); - crop.bottom = - (int)roundf((float)ot * (float)crop.bottom); + crop.bottom = (int)roundf((float)ot * (float)crop.bottom); } } else { obs_sceneitem_get_crop(scene_item, &crop); @@ -1378,29 +1235,22 @@ bool render2_item(struct move_info *move, struct move_item *item) obs_sceneitem_get_scale(item->item_a, &scale_a); struct vec2 scale_b; obs_sceneitem_get_scale(item->item_b, &scale_b); - vec2_set(&scale, (1.0f - t) * scale_a.x + t * scale_b.x, - (1.0f - t) * scale_a.y + t * scale_b.y); + vec2_set(&scale, (1.0f - t) * scale_a.x + t * scale_b.x, (1.0f - t) * scale_a.y + t * scale_b.y); } else { - if (obs_sceneitem_get_bounds_type(scene_item) != - OBS_BOUNDS_NONE) { + if (obs_sceneitem_get_bounds_type(scene_item) != OBS_BOUNDS_NONE) { obs_sceneitem_get_scale(scene_item, &scale); } else { obs_sceneitem_get_scale(scene_item, &scale); if (item->move_scene) { if (item->item_a) { - vec2_set(&scale, - (1.0f - t) * scale.x + t, - (1.0f - t) * scale.y + t); + vec2_set(&scale, (1.0f - t) * scale.x + t, (1.0f - t) * scale.y + t); } else if (item->item_b) { - vec2_set(&scale, - (1.0f - t) + t * scale.x, - (1.0f - t) + t * scale.y); + vec2_set(&scale, (1.0f - t) + t * scale.x, (1.0f - t) + t * scale.y); } } else if (!move_out && item->zoom) { vec2_set(&scale, t * scale.x, t * scale.y); } else if (move_out && item->zoom) { - vec2_set(&scale, (1.0f - t) * scale.x, - (1.0f - t) * scale.y); + vec2_set(&scale, (1.0f - t) * scale.x, (1.0f - t) * scale.y); } } } @@ -1429,50 +1279,35 @@ bool render2_item(struct move_info *move, struct move_item *item) obs_sceneitem_get_bounds(item->item_a, &bounds_a); struct vec2 bounds_b; obs_sceneitem_get_bounds(item->item_b, &bounds_b); - vec2_set(&bounds, - (1.0f - t) * bounds_a.x + t * bounds_b.x, - (1.0f - t) * bounds_a.y + t * bounds_b.y); + vec2_set(&bounds, (1.0f - t) * bounds_a.x + t * bounds_b.x, (1.0f - t) * bounds_a.y + t * bounds_b.y); } else if (item->move_scene) { obs_sceneitem_get_bounds(scene_item, &bounds); if (item->item_a) { - vec2_set(&bounds, - (1.0f - t) * bounds.x + - t * canvas_width, - (1.0f - t) * bounds.y + - t * canvas_height); + vec2_set(&bounds, (1.0f - t) * bounds.x + t * canvas_width, + (1.0f - t) * bounds.y + t * canvas_height); } else if (item->item_b) { - vec2_set(&bounds, - (1.0f - t) * canvas_width + - t * bounds.x, - (1.0f - t) * canvas_height + - t * bounds.y); + vec2_set(&bounds, (1.0f - t) * canvas_width + t * bounds.x, + (1.0f - t) * canvas_height + t * bounds.y); } } else { obs_sceneitem_get_bounds(scene_item, &bounds); if (!move_out && item->zoom) { vec2_set(&bounds, t * bounds.x, t * bounds.y); } else if (move_out && item->zoom) { - vec2_set(&bounds, (1.0f - t) * bounds.x, - (1.0f - t) * bounds.y); + vec2_set(&bounds, (1.0f - t) * bounds.x, (1.0f - t) * bounds.y); } } if (item->item_a && item->item_b && - (obs_sceneitem_get_bounds_alignment(item->item_a) != - obs_sceneitem_get_bounds_alignment(item->item_b) || + (obs_sceneitem_get_bounds_alignment(item->item_a) != obs_sceneitem_get_bounds_alignment(item->item_b) || bt_a != bt_b)) { - calculate_move_bounds_data(item->item_a, item->item_b, - t, &origin, &scale, &cx, &cy, - &bounds); + calculate_move_bounds_data(item->item_a, item->item_b, t, &origin, &scale, &cx, &cy, &bounds); } else { - calculate_bounds_data(scene_item, &origin, &scale, &cx, - &cy, &bounds); + calculate_bounds_data(scene_item, &origin, &scale, &cx, &cy, &bounds); } struct vec2 original_bounds; obs_sceneitem_get_bounds(scene_item, &original_bounds); - calculate_bounds_data(scene_item, &origin2, &original_scale, - &original_cx, &original_cy, - &original_bounds); + calculate_bounds_data(scene_item, &origin2, &original_scale, &original_cx, &original_cy, &original_bounds); } else { original_cx = (int32_t)roundf((float)cx * original_scale.x); original_cy = (int32_t)roundf((float)cy * original_scale.y); @@ -1480,23 +1315,17 @@ bool render2_item(struct move_info *move, struct move_item *item) cy = (int32_t)roundf((float)cy * scale.y); } if (item->item_a && item->item_b && - obs_sceneitem_get_alignment(item->item_a) != - obs_sceneitem_get_alignment(item->item_b)) { - add_move_alignment(&origin, - obs_sceneitem_get_alignment(item->item_a), - obs_sceneitem_get_alignment(item->item_b), t, + obs_sceneitem_get_alignment(item->item_a) != obs_sceneitem_get_alignment(item->item_b)) { + add_move_alignment(&origin, obs_sceneitem_get_alignment(item->item_a), obs_sceneitem_get_alignment(item->item_b), t, cx, cy); } else { - add_alignment(&origin, obs_sceneitem_get_alignment(scene_item), - cx, cy); + add_alignment(&origin, obs_sceneitem_get_alignment(scene_item), cx, cy); } struct matrix4 draw_transform; matrix4_identity(&draw_transform); - matrix4_scale3f(&draw_transform, &draw_transform, scale.x, scale.y, - 1.0f); - matrix4_translate3f(&draw_transform, &draw_transform, -origin.x, - -origin.y, 0.0f); + matrix4_scale3f(&draw_transform, &draw_transform, scale.x, scale.y, 1.0f); + matrix4_translate3f(&draw_transform, &draw_transform, -origin.x, -origin.y, 0.0f); float rot; float rd = 0.0f; if (item->item_a && item->item_b) { @@ -1515,8 +1344,7 @@ bool render2_item(struct move_info *move, struct move_item *item) } else { rot = obs_sceneitem_get_rot(scene_item); } - matrix4_rotate_aa4f(&draw_transform, &draw_transform, 0.0f, 0.0f, 1.0f, - RAD(rot)); + matrix4_rotate_aa4f(&draw_transform, &draw_transform, 0.0f, 0.0f, 1.0f, RAD(rot)); struct vec2 pos_a; if (item->item_a) { @@ -1541,23 +1369,18 @@ bool render2_item(struct move_info *move, struct move_item *item) } else { uint32_t alignment = obs_sceneitem_get_alignment(scene_item); if (item->position & POS_CENTER) { - vec2_set(&pos_a, (float)(canvas_width >> 1), - (float)(canvas_height >> 1)); + vec2_set(&pos_a, (float)(canvas_width >> 1), (float)(canvas_height >> 1)); if (!item->zoom) pos_add_center(&pos_a, alignment, cx, cy); - } else if (item->position & POS_EDGE || - item->position & POS_SWIPE) { + } else if (item->position & POS_EDGE || item->position & POS_SWIPE) { obs_sceneitem_get_pos(item->item_b, &pos_a); - calc_edge_position(&pos_a, item->position, canvas_width, - canvas_height, alignment, - original_cx, original_cy, + calc_edge_position(&pos_a, item->position, canvas_width, canvas_height, alignment, original_cx, original_cy, item->zoom); } else { obs_sceneitem_get_pos(item->item_b, &pos_a); if (item->zoom) - pos_subtract_center(&pos_a, alignment, - original_cx, original_cy); + pos_subtract_center(&pos_a, alignment, original_cx, original_cy); } } struct vec2 pos_b; @@ -1583,23 +1406,18 @@ bool render2_item(struct move_info *move, struct move_item *item) } else { uint32_t alignment = obs_sceneitem_get_alignment(scene_item); if (item->position & POS_CENTER) { - vec2_set(&pos_b, (float)(canvas_width >> 1), - (float)(canvas_height >> 1)); + vec2_set(&pos_b, (float)(canvas_width >> 1), (float)(canvas_height >> 1)); if (!item->zoom) pos_add_center(&pos_b, alignment, cx, cy); - } else if (item->position & POS_EDGE || - item->position & POS_SWIPE) { + } else if (item->position & POS_EDGE || item->position & POS_SWIPE) { obs_sceneitem_get_pos(item->item_a, &pos_b); - calc_edge_position(&pos_b, item->position, canvas_width, - canvas_height, alignment, - original_cx, original_cy, + calc_edge_position(&pos_b, item->position, canvas_width, canvas_height, alignment, original_cx, original_cy, item->zoom); } else { obs_sceneitem_get_pos(item->item_a, &pos_b); if (item->zoom) - pos_subtract_center(&pos_b, alignment, - original_cx, original_cy); + pos_subtract_center(&pos_b, alignment, original_cx, original_cy); } } struct vec2 pos; @@ -1607,8 +1425,7 @@ bool render2_item(struct move_info *move, struct move_item *item) float diff_x = fabsf(pos_a.x - pos_b.x); float diff_y = fabsf(pos_a.y - pos_b.y); struct vec2 control_pos; - vec2_set(&control_pos, 0.5f * pos_a.x + 0.5f * pos_b.x, - 0.5f * pos_a.y + 0.5f * pos_b.y); + vec2_set(&control_pos, 0.5f * pos_a.x + 0.5f * pos_b.x, 0.5f * pos_a.y + 0.5f * pos_b.y); if (control_pos.x >= (canvas_width >> 1)) { control_pos.x += diff_y * item->curve; } else { @@ -1621,26 +1438,19 @@ bool render2_item(struct move_info *move, struct move_item *item) } vec2_bezier(&pos, &pos_a, &control_pos, &pos_b, t); } else { - vec2_set(&pos, (1.0f - t) * pos_a.x + t * pos_b.x, - (1.0f - t) * pos_a.y + t * pos_b.y); + vec2_set(&pos, (1.0f - t) * pos_a.x + t * pos_b.x, (1.0f - t) * pos_a.y + t * pos_b.y); } - matrix4_translate3f(&draw_transform, &draw_transform, pos.x, pos.y, - 0.0f); + matrix4_translate3f(&draw_transform, &draw_transform, pos.x, pos.y, 0.0f); struct vec2 output_scale = scale; - if (item->item_render && - !item_texture_enabled(item->item_a, &item->bounds_crop_a) && + if (item->item_render && !item_texture_enabled(item->item_a, &item->bounds_crop_a) && !item_texture_enabled(item->item_b, &item->bounds_crop_b)) { gs_texrender_destroy(item->item_render); item->item_render = NULL; - } else if (!item->item_render && - ((item->item_a && - item_texture_enabled(item->item_a, &item->bounds_crop_a)) || - (item->item_b && - item_texture_enabled(item->item_b, - &item->bounds_crop_b)))) { + } else if (!item->item_render && ((item->item_a && item_texture_enabled(item->item_a, &item->bounds_crop_a)) || + (item->item_b && item_texture_enabled(item->item_b, &item->bounds_crop_b)))) { item->item_render = gs_texrender_create(GS_RGBA, GS_ZS_NONE); } else if (item->item_render) { gs_texrender_reset(item->item_render); @@ -1648,40 +1458,29 @@ bool render2_item(struct move_info *move, struct move_item *item) if (!move->point_sampler) { struct gs_sampler_info point_sampler_info = {0}; point_sampler_info.max_anisotropy = 1; - move->point_sampler = - gs_samplerstate_create(&point_sampler_info); + move->point_sampler = gs_samplerstate_create(&point_sampler_info); } if (!item->has_transform) { if (item->item_a) { - move_get_draw_transform(item->item_a, - item->scene_flip_horizontal, - item->scene_flip_vertical, - &item->transform_a, - &item->bounds_crop_a); + move_get_draw_transform(item->item_a, item->scene_flip_horizontal, item->scene_flip_vertical, + &item->transform_a, &item->bounds_crop_a); } if (item->item_b) { - move_get_draw_transform(item->item_b, - item->scene_flip_horizontal, - item->scene_flip_vertical, - &item->transform_b, - &item->bounds_crop_b); + move_get_draw_transform(item->item_b, item->scene_flip_horizontal, item->scene_flip_vertical, + &item->transform_b, &item->bounds_crop_b); } item->has_transform = true; } struct obs_sceneitem_crop bounds_crop = {0}; if ((item->item_a && item->item_b) || item->move_scene) { - bounds_crop.left = (int)roundf( - (float)(1.0f - ot) * (float)item->bounds_crop_a.left + - ot * (float)item->bounds_crop_b.left); - bounds_crop.top = (int)roundf( - (float)(1.0f - ot) * (float)item->bounds_crop_a.top + - ot * (float)item->bounds_crop_b.top); - bounds_crop.right = (int)roundf( - (float)(1.0f - ot) * (float)item->bounds_crop_a.right + - ot * (float)item->bounds_crop_b.right); - bounds_crop.bottom = (int)roundf( - (float)(1.0f - ot) * (float)item->bounds_crop_a.bottom + - ot * (float)item->bounds_crop_b.bottom); + bounds_crop.left = + (int)roundf((float)(1.0f - ot) * (float)item->bounds_crop_a.left + ot * (float)item->bounds_crop_b.left); + bounds_crop.top = + (int)roundf((float)(1.0f - ot) * (float)item->bounds_crop_a.top + ot * (float)item->bounds_crop_b.top); + bounds_crop.right = + (int)roundf((float)(1.0f - ot) * (float)item->bounds_crop_a.right + ot * (float)item->bounds_crop_b.right); + bounds_crop.bottom = (int)roundf((float)(1.0f - ot) * (float)item->bounds_crop_a.bottom + + ot * (float)item->bounds_crop_b.bottom); } else if (item->item_a) { bounds_crop.left = item->bounds_crop_a.left; bounds_crop.top = item->bounds_crop_a.top; @@ -1696,36 +1495,23 @@ bool render2_item(struct move_info *move, struct move_item *item) if (item->item_render) { if (width && height && - gs_texrender_begin( - item->item_render, - width - (bounds_crop.left + bounds_crop.right), - height - (bounds_crop.top + bounds_crop.bottom))) { - float cx_scale = (float)original_width / - (float)(width - (bounds_crop.left + - bounds_crop.right)); - float cy_scale = (float)original_height / - (float)(height - (bounds_crop.top + - bounds_crop.bottom)); + gs_texrender_begin(item->item_render, width - (bounds_crop.left + bounds_crop.right), + height - (bounds_crop.top + bounds_crop.bottom))) { + float cx_scale = (float)original_width / (float)(width - (bounds_crop.left + bounds_crop.right)); + float cy_scale = (float)original_height / (float)(height - (bounds_crop.top + bounds_crop.bottom)); struct vec4 clear_color; vec4_zero(&clear_color); gs_clear(GS_CLEAR_COLOR, &clear_color, 0.0f, 0); - gs_ortho(0.0f, (float)original_width, 0.0f, - (float)original_height, -100.0f, 100.0f); + gs_ortho(0.0f, (float)original_width, 0.0f, (float)original_height, -100.0f, 100.0f); gs_matrix_scale3f(cx_scale, cy_scale, 1.0f); - gs_matrix_translate3f( - -(float)(crop.left + bounds_crop.left), - -(float)(crop.top + bounds_crop.top), 0.0f); + gs_matrix_translate3f(-(float)(crop.left + bounds_crop.left), -(float)(crop.top + bounds_crop.top), 0.0f); if (item->transition) { - obs_transition_set_manual_time(item->transition, - ot); - if (!move->first_frame || - item->scene_flip_horizontal || - item->scene_flip_vertical) { - obs_source_video_render( - item->transition); + obs_transition_set_manual_time(item->transition, ot); + if (!move->first_frame || item->scene_flip_horizontal || item->scene_flip_vertical) { + obs_source_video_render(item->transition); } else if (item->item_a || item->move_scene) { obs_source_video_render(source); } @@ -1737,42 +1523,24 @@ bool render2_item(struct move_info *move, struct move_item *item) } } if (item->item_a && item->item_b && - (fabs((double)rd) <= 90.0 || item->scene_flip_horizontal || - item->scene_flip_vertical || - (bt_a == OBS_BOUNDS_NONE && bt_b != OBS_BOUNDS_NONE) || - (bt_a != OBS_BOUNDS_NONE && bt_b == OBS_BOUNDS_NONE))) { - draw_transform.x.x = (1.0f - t) * item->transform_a.x.x + - t * item->transform_b.x.x; - draw_transform.x.y = (1.0f - t) * item->transform_a.x.y + - t * item->transform_b.x.y; - draw_transform.x.z = (1.0f - t) * item->transform_a.x.z + - t * item->transform_b.x.z; - draw_transform.x.w = (1.0f - t) * item->transform_a.x.w + - t * item->transform_b.x.w; - draw_transform.y.x = (1.0f - t) * item->transform_a.y.x + - t * item->transform_b.y.x; - draw_transform.y.y = (1.0f - t) * item->transform_a.y.y + - t * item->transform_b.y.y; - draw_transform.y.z = (1.0f - t) * item->transform_a.y.z + - t * item->transform_b.y.z; - draw_transform.y.w = (1.0f - t) * item->transform_a.y.w + - t * item->transform_b.y.w; - draw_transform.z.x = (1.0f - t) * item->transform_a.z.x + - t * item->transform_b.z.x; - draw_transform.z.y = (1.0f - t) * item->transform_a.z.y + - t * item->transform_b.z.y; - draw_transform.z.z = (1.0f - t) * item->transform_a.z.z + - t * item->transform_b.z.z; - draw_transform.z.w = (1.0f - t) * item->transform_a.z.w + - t * item->transform_b.z.w; - draw_transform.t.x = (1.0f - t) * item->transform_a.t.x + - t * item->transform_b.t.x; - draw_transform.t.y = (1.0f - t) * item->transform_a.t.y + - t * item->transform_b.t.y; - draw_transform.t.z = (1.0f - t) * item->transform_a.t.z + - t * item->transform_b.t.z; - draw_transform.t.w = (1.0f - t) * item->transform_a.t.w + - t * item->transform_b.t.w; + (fabs((double)rd) <= 90.0 || item->scene_flip_horizontal || item->scene_flip_vertical || + (bt_a == OBS_BOUNDS_NONE && bt_b != OBS_BOUNDS_NONE) || (bt_a != OBS_BOUNDS_NONE && bt_b == OBS_BOUNDS_NONE))) { + draw_transform.x.x = (1.0f - t) * item->transform_a.x.x + t * item->transform_b.x.x; + draw_transform.x.y = (1.0f - t) * item->transform_a.x.y + t * item->transform_b.x.y; + draw_transform.x.z = (1.0f - t) * item->transform_a.x.z + t * item->transform_b.x.z; + draw_transform.x.w = (1.0f - t) * item->transform_a.x.w + t * item->transform_b.x.w; + draw_transform.y.x = (1.0f - t) * item->transform_a.y.x + t * item->transform_b.y.x; + draw_transform.y.y = (1.0f - t) * item->transform_a.y.y + t * item->transform_b.y.y; + draw_transform.y.z = (1.0f - t) * item->transform_a.y.z + t * item->transform_b.y.z; + draw_transform.y.w = (1.0f - t) * item->transform_a.y.w + t * item->transform_b.y.w; + draw_transform.z.x = (1.0f - t) * item->transform_a.z.x + t * item->transform_b.z.x; + draw_transform.z.y = (1.0f - t) * item->transform_a.z.y + t * item->transform_b.z.y; + draw_transform.z.z = (1.0f - t) * item->transform_a.z.z + t * item->transform_b.z.z; + draw_transform.z.w = (1.0f - t) * item->transform_a.z.w + t * item->transform_b.z.w; + draw_transform.t.x = (1.0f - t) * item->transform_a.t.x + t * item->transform_b.t.x; + draw_transform.t.y = (1.0f - t) * item->transform_a.t.y + t * item->transform_b.t.y; + draw_transform.t.z = (1.0f - t) * item->transform_a.t.z + t * item->transform_b.t.z; + draw_transform.t.w = (1.0f - t) * item->transform_a.t.w + t * item->transform_b.t.w; } gs_matrix_push(); @@ -1789,75 +1557,55 @@ bool render2_item(struct move_info *move, struct move_item *item) gs_effect_t *effect = obs_get_base_effect(OBS_EFFECT_DEFAULT); - enum obs_scale_type type = - obs_sceneitem_get_scale_filter(scene_item); + enum obs_scale_type type = obs_sceneitem_get_scale_filter(scene_item); cx = gs_texture_get_width(tex); cy = gs_texture_get_height(tex); const char *tech = "Draw"; if (type != OBS_SCALE_DISABLE) { if (type == OBS_SCALE_POINT) { - gs_eparam_t *image = - gs_effect_get_param_by_name(effect, - "image"); - gs_effect_set_next_sampler(image, - move->point_sampler); - } else if (!close_float(output_scale.x, 1.0f, - EPSILON) || - !close_float(output_scale.y, 1.0f, - EPSILON)) { + gs_eparam_t *image = gs_effect_get_param_by_name(effect, "image"); + gs_effect_set_next_sampler(image, move->point_sampler); + } else if (!close_float(output_scale.x, 1.0f, EPSILON) || !close_float(output_scale.y, 1.0f, EPSILON)) { gs_eparam_t *scale_param; gs_eparam_t *scale_i_param; - if (output_scale.x < 0.5f || - output_scale.y < 0.5f) { - effect = obs_get_base_effect( - OBS_EFFECT_BILINEAR_LOWRES); + if (output_scale.x < 0.5f || output_scale.y < 0.5f) { + effect = obs_get_base_effect(OBS_EFFECT_BILINEAR_LOWRES); } else if (type == OBS_SCALE_BICUBIC) { - effect = obs_get_base_effect( - OBS_EFFECT_BICUBIC); + effect = obs_get_base_effect(OBS_EFFECT_BICUBIC); } else if (type == OBS_SCALE_LANCZOS) { - effect = obs_get_base_effect( - OBS_EFFECT_LANCZOS); + effect = obs_get_base_effect(OBS_EFFECT_LANCZOS); } else if (type == OBS_SCALE_AREA) { - effect = obs_get_base_effect( - OBS_EFFECT_AREA); - if ((output_scale.x >= 1.0f) && - (output_scale.y >= 1.0f)) + effect = obs_get_base_effect(OBS_EFFECT_AREA); + if ((output_scale.x >= 1.0f) && (output_scale.y >= 1.0f)) tech = "DrawUpscale"; } - scale_param = gs_effect_get_param_by_name( - effect, "base_dimension"); + scale_param = gs_effect_get_param_by_name(effect, "base_dimension"); if (scale_param) { struct vec2 base_res; base_res.x = (float)cx; base_res.y = (float)cy; - gs_effect_set_vec2(scale_param, - &base_res); + gs_effect_set_vec2(scale_param, &base_res); } - scale_i_param = gs_effect_get_param_by_name( - effect, "base_dimension_i"); + scale_i_param = gs_effect_get_param_by_name(effect, "base_dimension_i"); if (scale_i_param) { struct vec2 base_res_i; base_res_i.x = 1.0f / (float)cx; base_res_i.y = 1.0f / (float)cy; - gs_effect_set_vec2(scale_i_param, - &base_res_i); + gs_effect_set_vec2(scale_i_param, &base_res_i); } } } gs_blend_state_push(); - enum obs_blending_type blend_type = - obs_sceneitem_get_blending_mode(scene_item); - gs_blend_function_separate( - obs_blend_mode_params[blend_type].src_color, - obs_blend_mode_params[blend_type].dst_color, - obs_blend_mode_params[blend_type].src_alpha, - obs_blend_mode_params[blend_type].dst_alpha); + enum obs_blending_type blend_type = obs_sceneitem_get_blending_mode(scene_item); + gs_blend_function_separate(obs_blend_mode_params[blend_type].src_color, obs_blend_mode_params[blend_type].dst_color, + obs_blend_mode_params[blend_type].src_alpha, + obs_blend_mode_params[blend_type].dst_alpha); gs_blend_op(obs_blend_mode_params[blend_type].op); while (gs_effect_loop(effect, tech)) @@ -1867,8 +1615,7 @@ bool render2_item(struct move_info *move, struct move_item *item) } else { if (item->transition) { obs_transition_set_manual_time(item->transition, ot); - if (!move->first_frame || item->scene_flip_horizontal || - item->scene_flip_vertical) { + if (!move->first_frame || item->scene_flip_horizontal || item->scene_flip_vertical) { obs_source_video_render(item->transition); } else if (item->item_a) { obs_source_video_render(source); @@ -1882,14 +1629,12 @@ bool render2_item(struct move_info *move, struct move_item *item) return true; } -void get_override_filter(obs_source_t *source, obs_source_t *filter, - void *param) +void get_override_filter(obs_source_t *source, obs_source_t *filter, void *param) { UNUSED_PARAMETER(source); if (!obs_source_enabled(filter)) return; - if (strcmp(obs_source_get_unversioned_id(filter), - "move_transition_override_filter") != 0) + if (strcmp(obs_source_get_unversioned_id(filter), "move_transition_override_filter") != 0) return; obs_source_t *target = *(obs_source_t **)param; if (!target) { @@ -1919,8 +1664,7 @@ obs_data_t *get_override_filter_settings(obs_sceneitem_t *item) obs_scene_t *scene = obs_sceneitem_get_scene(item); if (scene) { obs_source_t *scene_source = obs_scene_get_source(scene); - obs_source_enum_filters(scene_source, get_override_filter, - &filter); + obs_source_enum_filters(scene_source, get_override_filter, &filter); } obs_source_t *source = obs_sceneitem_get_source(item); @@ -1937,53 +1681,41 @@ obs_data_t *get_override_filter_settings(obs_sceneitem_t *item) return NULL; } -bool same_transform_type(struct obs_transform_info *info_a, - struct obs_transform_info *info_b) +bool same_transform_type(struct obs_transform_info *info_a, struct obs_transform_info *info_b) { if (!info_a || !info_b) return false; - return info_a->alignment == info_b->alignment && - info_a->bounds_type == info_b->bounds_type && + return info_a->alignment == info_b->alignment && info_a->bounds_type == info_b->bounds_type && info_a->bounds_alignment == info_b->bounds_alignment; } -struct move_item *match_item_by_override(struct move_info *move, - obs_sceneitem_t *scene_item, - size_t *found_pos) +struct move_item *match_item_by_override(struct move_info *move, obs_sceneitem_t *scene_item, size_t *found_pos) { struct move_item *item = NULL; obs_source_t *source = obs_sceneitem_get_source(scene_item); const char *name_b = obs_source_get_name(source); - obs_data_t *override_filter_b = - get_override_filter_settings(scene_item); - const char *override_name_b = - override_filter_b - ? obs_data_get_string(override_filter_b, S_MATCH_SOURCE) - : NULL; + obs_data_t *override_filter_b = get_override_filter_settings(scene_item); + const char *override_name_b = override_filter_b ? obs_data_get_string(override_filter_b, S_MATCH_SOURCE) : NULL; obs_data_release(override_filter_b); for (size_t i = 0; i < move->items_a.num; i++) { struct move_item *check_item = move->items_a.array[i]; if (check_item->item_b) continue; - obs_source_t *check_source = - obs_sceneitem_get_source(check_item->item_a); + obs_source_t *check_source = obs_sceneitem_get_source(check_item->item_a); if (!check_source) continue; const char *name_a = obs_source_get_name(check_source); - if (name_a && strlen(name_a) && override_name_b && - strcmp(name_a, override_name_b) == 0) { + if (name_a && strlen(name_a) && override_name_b && strcmp(name_a, override_name_b) == 0) { item = check_item; *found_pos = i; break; } if (!name_b || !strlen(name_b)) continue; - obs_data_t *override_filter_a = - get_override_filter_settings(check_item->item_a); + obs_data_t *override_filter_a = get_override_filter_settings(check_item->item_a); if (override_filter_a) { - const char *override_name_a = obs_data_get_string( - override_filter_a, S_MATCH_SOURCE); + const char *override_name_a = obs_data_get_string(override_filter_a, S_MATCH_SOURCE); obs_data_release(override_filter_a); if (strcmp(override_name_a, name_b) == 0) { item = check_item; @@ -2004,9 +1736,7 @@ bool is_number_match(const char c) return false; } -struct move_item *match_item_by_name(struct move_info *move, - obs_sceneitem_t *scene_item, - size_t *found_pos) +struct move_item *match_item_by_name(struct move_info *move, obs_sceneitem_t *scene_item, size_t *found_pos) { struct move_item *item = NULL; obs_source_t *source = obs_sceneitem_get_source(scene_item); @@ -2018,8 +1748,7 @@ struct move_item *match_item_by_name(struct move_info *move, if (check_item->item_b) continue; - obs_source_t *check_source = - obs_sceneitem_get_source(check_item->item_a); + obs_source_t *check_source = obs_sceneitem_get_source(check_item->item_a); if (!check_source) continue; if (check_source == source) { @@ -2039,9 +1768,7 @@ struct move_item *match_item_by_name(struct move_info *move, return item; } -struct move_item *match_item_by_type_and_settings(struct move_info *move, - obs_sceneitem_t *scene_item, - size_t *found_pos) +struct move_item *match_item_by_type_and_settings(struct move_info *move, obs_sceneitem_t *scene_item, size_t *found_pos) { struct move_item *item = NULL; @@ -2053,24 +1780,18 @@ struct move_item *match_item_by_type_and_settings(struct move_info *move, if (check_item->item_b) continue; - obs_source_t *check_source = - obs_sceneitem_get_source(check_item->item_a); + obs_source_t *check_source = obs_sceneitem_get_source(check_item->item_a); if (!check_source) continue; - if (obs_source_get_type(check_source) != - obs_source_get_type(source)) + if (obs_source_get_type(check_source) != obs_source_get_type(source)) continue; - if (strcmp(obs_source_get_unversioned_id(check_source), - obs_source_get_unversioned_id(source)) != 0) + if (strcmp(obs_source_get_unversioned_id(check_source), obs_source_get_unversioned_id(source)) != 0) continue; obs_data_t *settings = obs_source_get_settings(source); - obs_data_t *check_settings = - obs_source_get_settings(check_source); - if (settings && check_settings && - strcmp(obs_data_get_json(settings), - obs_data_get_json(check_settings)) == 0) { + obs_data_t *check_settings = obs_source_get_settings(check_source); + if (settings && check_settings && strcmp(obs_data_get_json(settings), obs_data_get_json(check_settings)) == 0) { item = check_item; *found_pos = i; obs_data_release(check_settings); @@ -2083,9 +1804,7 @@ struct move_item *match_item_by_type_and_settings(struct move_info *move, return item; } -struct move_item *match_item_clone(struct move_info *move, - obs_sceneitem_t *scene_item, - size_t *found_pos) +struct move_item *match_item_clone(struct move_info *move, obs_sceneitem_t *scene_item, size_t *found_pos) { struct move_item *item = NULL; obs_source_t *source = obs_sceneitem_get_source(scene_item); @@ -2096,8 +1815,7 @@ struct move_item *match_item_clone(struct move_info *move, struct move_item *check_item = move->items_a.array[i]; if (check_item->item_b) continue; - obs_source_t *check_source = - obs_sceneitem_get_source(check_item->item_a); + obs_source_t *check_source = obs_sceneitem_get_source(check_item->item_a); if (!check_source) continue; const char *name_a = obs_source_get_name(check_source); @@ -2113,8 +1831,7 @@ struct move_item *match_item_clone(struct move_info *move, obs_data_release(s); } else if (strcmp(id_a, "streamfx-source-mirror") == 0) { obs_data_t *s = obs_source_get_settings(check_source); - clone_a = - obs_data_get_string(s, "Source.Mirror.Source"); + clone_a = obs_data_get_string(s, "Source.Mirror.Source"); obs_data_release(s); } @@ -2124,12 +1841,10 @@ struct move_item *match_item_clone(struct move_info *move, obs_data_release(s); } else if (strcmp(id_b, "streamfx-source-mirror") == 0) { obs_data_t *s = obs_source_get_settings(check_source); - clone_b = - obs_data_get_string(s, "Source.Mirror.Source"); + clone_b = obs_data_get_string(s, "Source.Mirror.Source"); obs_data_release(s); } - if ((clone_a && clone_b && strcmp(clone_a, clone_b) == 0) || - (clone_a && strcmp(clone_a, name_b) == 0) || + if ((clone_a && clone_b && strcmp(clone_a, clone_b) == 0) || (clone_a && strcmp(clone_a, name_b) == 0) || (clone_b && strcmp(clone_b, name_a) == 0)) { item = check_item; *found_pos = i; @@ -2139,9 +1854,7 @@ struct move_item *match_item_clone(struct move_info *move, return item; } -struct move_item *match_item_name_part(struct move_info *move, - obs_sceneitem_t *scene_item, - size_t *found_pos) +struct move_item *match_item_name_part(struct move_info *move, obs_sceneitem_t *scene_item, size_t *found_pos) { struct move_item *item = NULL; @@ -2157,8 +1870,7 @@ struct move_item *match_item_name_part(struct move_info *move, if (check_item->item_b) continue; - obs_source_t *check_source = - obs_sceneitem_get_source(check_item->item_a); + obs_source_t *check_source = obs_sceneitem_get_source(check_item->item_a); if (!check_source) continue; const char *name_a = obs_source_get_name(check_source); @@ -2177,14 +1889,11 @@ struct move_item *match_item_name_part(struct move_info *move, len_b = last_space - name_b; } } - while (len_b > 0 && move->number_match && - is_number_match(name_b[len_b - 1])) + while (len_b > 0 && move->number_match && is_number_match(name_b[len_b - 1])) len_b--; if (len_b > 0 && move->part_match) { - for (size_t pos = 0; pos <= len_a - len_b; - pos++) { - if (memcmp(name_a + pos, name_b, - len_b) == 0) { + for (size_t pos = 0; pos <= len_a - len_b; pos++) { + if (memcmp(name_a + pos, name_b, len_b) == 0) { item = check_item; *found_pos = i; break; @@ -2192,8 +1901,7 @@ struct move_item *match_item_name_part(struct move_info *move, } if (item) break; - } else if (len_b > 0 && - memcmp(name_a, name_b, len_b) == 0) { + } else if (len_b > 0 && memcmp(name_a, name_b, len_b) == 0) { item = check_item; *found_pos = i; break; @@ -2206,14 +1914,11 @@ struct move_item *match_item_name_part(struct move_info *move, len_a = last_space - name_a; } } - while (len_a > 0 && move->number_match && - is_number_match(name_a[len_a - 1])) + while (len_a > 0 && move->number_match && is_number_match(name_a[len_a - 1])) len_a--; if (len_a > 0 && move->part_match) { - for (size_t pos = 0; pos <= len_b - len_a; - pos++) { - if (memcmp(name_a, name_b + pos, - len_a) == 0) { + for (size_t pos = 0; pos <= len_b - len_a; pos++) { + if (memcmp(name_a, name_b + pos, len_a) == 0) { item = check_item; *found_pos = i; break; @@ -2221,8 +1926,7 @@ struct move_item *match_item_name_part(struct move_info *move, } if (item) break; - } else if (len_a > 0 && - memcmp(name_a, name_b, len_a) == 0) { + } else if (len_a > 0 && memcmp(name_a, name_b, len_a) == 0) { item = check_item; *found_pos = i; break; @@ -2239,8 +1943,7 @@ struct match_item_nested_match { bool scene_flip_vertical; }; -bool match_item_nested_all_match(obs_scene_t *obs_scene, - obs_sceneitem_t *sceneitem, void *p) +bool match_item_nested_all_match(obs_scene_t *obs_scene, obs_sceneitem_t *sceneitem, void *p) { UNUSED_PARAMETER(obs_scene); if (!obs_sceneitem_visible(sceneitem)) @@ -2261,9 +1964,7 @@ bool match_item_nested_all_match(obs_scene_t *obs_scene, return true; } -struct move_item *match_item_scene_same(struct move_info *move, - obs_sceneitem_t *scene_item, - size_t *found_pos) +struct move_item *match_item_scene_same(struct move_info *move, obs_sceneitem_t *scene_item, size_t *found_pos) { struct move_item *item = NULL; if (!move->nested_scenes) @@ -2280,13 +1981,11 @@ struct move_item *match_item_scene_same(struct move_info *move, if (check_item->item_b || check_item->move_scene) continue; - obs_source_t *check_source = - obs_sceneitem_get_source(check_item->item_a); + obs_source_t *check_source = obs_sceneitem_get_source(check_item->item_a); if (!check_source) continue; - if (!obs_source_is_scene(check_source) && - !obs_source_is_group(check_source)) + if (!obs_source_is_scene(check_source) && !obs_source_is_group(check_source)) continue; obs_scene_t *check_scene = obs_scene_from_source(check_source); @@ -2298,8 +1997,7 @@ struct move_item *match_item_scene_same(struct move_info *move, mi.matched = true; obs_scene_enum_items(scene, match_item_nested_all_match, &mi); mi.check_source = source; - obs_scene_enum_items(check_scene, match_item_nested_all_match, - &mi); + obs_scene_enum_items(check_scene, match_item_nested_all_match, &mi); if (mi.matched) { item = check_item; item->move_scene = true; @@ -2310,8 +2008,7 @@ struct move_item *match_item_scene_same(struct move_info *move, return item; } -bool match_item_nested_match(obs_scene_t *obs_scene, obs_sceneitem_t *sceneitem, - void *p) +bool match_item_nested_match(obs_scene_t *obs_scene, obs_sceneitem_t *sceneitem, void *p) { UNUSED_PARAMETER(obs_scene); struct match_item_nested_match *mi = p; @@ -2322,31 +2019,24 @@ bool match_item_nested_match(obs_scene_t *obs_scene, obs_sceneitem_t *sceneitem, mi->matched = true; struct vec2 scale; obs_sceneitem_get_scale(sceneitem, &scale); - mi->scene_flip_horizontal = mi->scene_flip_horizontal && - scale.x < 0.0f; - mi->scene_flip_vertical = mi->scene_flip_vertical && - scale.y < 0.0f; + mi->scene_flip_horizontal = mi->scene_flip_horizontal && scale.x < 0.0f; + mi->scene_flip_vertical = mi->scene_flip_vertical && scale.y < 0.0f; return false; } const char *name_a = obs_source_get_name(mi->check_source); const char *name_b = obs_source_get_name(source); - if (name_a && name_b && strlen(name_a) && strlen(name_b) && - strcmp(name_a, name_b) == 0) { + if (name_a && name_b && strlen(name_a) && strlen(name_b) && strcmp(name_a, name_b) == 0) { mi->matched = true; struct vec2 scale; obs_sceneitem_get_scale(sceneitem, &scale); - mi->scene_flip_horizontal = mi->scene_flip_horizontal && - scale.x < 0.0f; - mi->scene_flip_vertical = mi->scene_flip_vertical && - scale.y < 0.0f; + mi->scene_flip_horizontal = mi->scene_flip_horizontal && scale.x < 0.0f; + mi->scene_flip_vertical = mi->scene_flip_vertical && scale.y < 0.0f; return false; } return true; } -struct move_item *match_item_nested(struct move_info *move, - obs_sceneitem_t *scene_item, - size_t *found_pos) +struct move_item *match_item_nested(struct move_info *move, obs_sceneitem_t *scene_item, size_t *found_pos) { struct move_item *item = NULL; if (!move->nested_scenes) @@ -2358,8 +2048,7 @@ struct move_item *match_item_nested(struct move_info *move, if (check_item->item_b || check_item->move_scene) continue; - obs_source_t *check_source = - obs_sceneitem_get_source(check_item->item_a); + obs_source_t *check_source = obs_sceneitem_get_source(check_item->item_a); if (!check_source) continue; if (obs_source_is_scene(source)) { @@ -2371,15 +2060,12 @@ struct move_item *match_item_nested(struct move_info *move, obs_sceneitem_get_scale(check_item->item_a, &scale); mi.scene_flip_horizontal = scale.x < 0.0f; mi.scene_flip_vertical = scale.y < 0.0f; - obs_scene_enum_items(scene, match_item_nested_match, - &mi); + obs_scene_enum_items(scene, match_item_nested_match, &mi); if (mi.matched) { item = check_item; item->move_scene = true; - item->scene_flip_horizontal = - mi.scene_flip_horizontal; - item->scene_flip_vertical = - mi.scene_flip_vertical; + item->scene_flip_horizontal = mi.scene_flip_horizontal; + item->scene_flip_vertical = mi.scene_flip_vertical; *found_pos = i; break; } @@ -2392,22 +2078,18 @@ struct move_item *match_item_nested(struct move_info *move, obs_sceneitem_get_scale(check_item->item_a, &scale); mi.scene_flip_horizontal = scale.x < 0.0f; mi.scene_flip_vertical = scale.y < 0.0f; - obs_scene_enum_items(scene, match_item_nested_match, - &mi); + obs_scene_enum_items(scene, match_item_nested_match, &mi); if (mi.matched) { item = check_item; item->move_scene = true; - item->scene_flip_horizontal = - mi.scene_flip_horizontal; - item->scene_flip_vertical = - mi.scene_flip_vertical; + item->scene_flip_horizontal = mi.scene_flip_horizontal; + item->scene_flip_vertical = mi.scene_flip_vertical; *found_pos = i; break; } } if (obs_source_is_scene(check_source)) { - obs_scene_t *scene = - obs_scene_from_source(check_source); + obs_scene_t *scene = obs_scene_from_source(check_source); struct match_item_nested_match mi; mi.check_source = source; mi.matched = false; @@ -2415,21 +2097,17 @@ struct move_item *match_item_nested(struct move_info *move, obs_sceneitem_get_scale(scene_item, &scale); mi.scene_flip_horizontal = scale.x < 0.0f; mi.scene_flip_vertical = scale.y < 0.0f; - obs_scene_enum_items(scene, match_item_nested_match, - &mi); + obs_scene_enum_items(scene, match_item_nested_match, &mi); if (mi.matched) { item = check_item; item->move_scene = true; - item->scene_flip_horizontal = - mi.scene_flip_horizontal; - item->scene_flip_vertical = - mi.scene_flip_vertical; + item->scene_flip_horizontal = mi.scene_flip_horizontal; + item->scene_flip_vertical = mi.scene_flip_vertical; *found_pos = i; break; } } else if (obs_source_is_group(check_source)) { - obs_scene_t *scene = - obs_group_from_source(check_source); + obs_scene_t *scene = obs_group_from_source(check_source); struct match_item_nested_match mi; mi.check_source = source; mi.matched = false; @@ -2437,15 +2115,12 @@ struct move_item *match_item_nested(struct move_info *move, obs_sceneitem_get_scale(scene_item, &scale); mi.scene_flip_horizontal = scale.x < 0.0f; mi.scene_flip_vertical = scale.y < 0.0f; - obs_scene_enum_items(scene, match_item_nested_match, - &mi); + obs_scene_enum_items(scene, match_item_nested_match, &mi); if (mi.matched) { item = check_item; item->move_scene = true; - item->scene_flip_horizontal = - mi.scene_flip_horizontal; - item->scene_flip_vertical = - mi.scene_flip_vertical; + item->scene_flip_horizontal = mi.scene_flip_horizontal; + item->scene_flip_vertical = mi.scene_flip_vertical; *found_pos = i; break; } @@ -2454,8 +2129,7 @@ struct move_item *match_item_nested(struct move_info *move, return item; } -bool match_item_nested_any_match(obs_scene_t *obs_scene, - obs_sceneitem_t *sceneitem, void *p) +bool match_item_nested_any_match(obs_scene_t *obs_scene, obs_sceneitem_t *sceneitem, void *p) { UNUSED_PARAMETER(obs_scene); if (!obs_sceneitem_visible(sceneitem)) @@ -2476,9 +2150,7 @@ bool match_item_nested_any_match(obs_scene_t *obs_scene, return true; } -struct move_item *match_item_scene_match(struct move_info *move, - obs_sceneitem_t *scene_item, - size_t *found_pos) +struct move_item *match_item_scene_match(struct move_info *move, obs_sceneitem_t *scene_item, size_t *found_pos) { struct move_item *item = NULL; if (!move->nested_scenes) @@ -2495,12 +2167,10 @@ struct move_item *match_item_scene_match(struct move_info *move, if (check_item->item_b || check_item->move_scene) continue; - obs_source_t *check_source = - obs_sceneitem_get_source(check_item->item_a); + obs_source_t *check_source = obs_sceneitem_get_source(check_item->item_a); if (!check_source) continue; - if (!obs_source_is_scene(check_source) && - !obs_source_is_group(check_source)) + if (!obs_source_is_scene(check_source) && !obs_source_is_group(check_source)) continue; obs_scene_t *check_scene = obs_scene_from_source(check_source); @@ -2512,8 +2182,7 @@ struct move_item *match_item_scene_match(struct move_info *move, mi.matched = false; obs_scene_enum_items(scene, match_item_nested_any_match, &mi); mi.check_source = source; - obs_scene_enum_items(check_scene, match_item_nested_any_match, - &mi); + obs_scene_enum_items(check_scene, match_item_nested_any_match, &mi); if (mi.matched) { item = check_item; item->move_scene = true; @@ -2524,20 +2193,12 @@ struct move_item *match_item_scene_match(struct move_info *move, return item; } -typedef struct move_item *(*match_function)(struct move_info *move, - obs_sceneitem_t *scene_item, - size_t *found_pos); +typedef struct move_item *(*match_function)(struct move_info *move, obs_sceneitem_t *scene_item, size_t *found_pos); #define MATCH_FUNCTION_COUNT 8 match_function match_functions[MATCH_FUNCTION_COUNT] = { - match_item_by_override, - match_item_by_name, - match_item_clone, - match_item_name_part, - match_item_by_type_and_settings, - match_item_scene_same, - match_item_nested, - match_item_scene_match}; + match_item_by_override, match_item_by_name, match_item_clone, match_item_name_part, + match_item_by_type_and_settings, match_item_scene_same, match_item_nested, match_item_scene_match}; struct move_item *create_move_item() { @@ -2557,8 +2218,7 @@ bool add_item(obs_scene_t *scene, obs_sceneitem_t *scene_item, void *data) da_push_back(move->items_a, &item); obs_sceneitem_addref(scene_item); item->item_a = scene_item; - item->move_scene = obs_sceneitem_get_source(scene_item) == - move->scene_source_b; + item->move_scene = obs_sceneitem_get_source(scene_item) == move->scene_source_b; if (item->move_scene) move->matched_scene_b = true; return true; @@ -2608,8 +2268,7 @@ void sceneitem_start_move(obs_sceneitem_t *item, const char *start_move) obs_source_t *scene_source = obs_scene_get_source(scene); if (obs_source_removed(scene_source)) return; - obs_source_t *filter = - obs_source_get_filter_by_name(scene_source, start_move); + obs_source_t *filter = obs_source_get_filter_by_name(scene_source, start_move); if (!filter) { obs_source_t *source = obs_sceneitem_get_source(item); if (obs_source_removed(source)) @@ -2625,8 +2284,7 @@ void sceneitem_start_move(obs_sceneitem_t *item, const char *start_move) move_filter_start(obs_obj_get_data(filter)); } -static bool darray_sceneitem_push_back(obs_scene_t *scene, - obs_sceneitem_t *item, void *data) +static bool darray_sceneitem_push_back(obs_scene_t *scene, obs_sceneitem_t *item, void *data) { UNUSED_PARAMETER(scene); struct darray *array = data; @@ -2647,11 +2305,9 @@ static void move_start_init(struct move_info *move, bool in_graphics) obs_sceneitem_t *scene_flip_sceneitem = NULL; obs_source_t *old_scene_a = move->scene_source_a; - move->scene_source_a = obs_transition_get_source( - move->source, OBS_TRANSITION_SOURCE_A); + move->scene_source_a = obs_transition_get_source(move->source, OBS_TRANSITION_SOURCE_A); obs_source_t *old_scene_b = move->scene_source_b; - move->scene_source_b = obs_transition_get_source( - move->source, OBS_TRANSITION_SOURCE_B); + move->scene_source_b = obs_transition_get_source(move->source, OBS_TRANSITION_SOURCE_B); obs_source_release(old_scene_a); obs_source_release(old_scene_b); @@ -2673,16 +2329,13 @@ static void move_start_init(struct move_info *move, bool in_graphics) const char *n = obs_source_get_name(move->scene_source_a); obs_data_t *sd = obs_data_create(); obs_data_set_bool(sd, "custom_size", true); - obs_data_set_int(sd, "cx", - obs_source_get_width(move->scene_source_a)); - obs_data_set_int(sd, "cy", - obs_source_get_height(move->scene_source_a)); + obs_data_set_int(sd, "cx", obs_source_get_width(move->scene_source_a)); + obs_data_set_int(sd, "cy", obs_source_get_height(move->scene_source_a)); obs_source_t *ss = obs_source_create_private("scene", n, sd); obs_source_load(ss); obs_data_release(sd); scene_a = obs_scene_from_source(ss); - obs_sceneitem_t *scene_item = - obs_scene_add(scene_a, move->scene_source_a); + obs_sceneitem_t *scene_item = obs_scene_add(scene_a, move->scene_source_a); struct move_item *item = create_move_item(); scene_flip_item = item; scene_flip_sceneitem = scene_item; @@ -2700,20 +2353,16 @@ static void move_start_init(struct move_info *move, bool in_graphics) //put items in todo array DARRAY(obs_sceneitem_t *) items; da_init(items); - obs_scene_enum_items(scene_b, darray_sceneitem_push_back, - &items); + obs_scene_enum_items(scene_b, darray_sceneitem_push_back, &items); struct move_item *item = NULL; for (size_t i = items.num; i > 0; i--) { obs_sceneitem_t *scene_item = items.array[i - 1]; - if (obs_sceneitem_get_source(scene_item) == - move->scene_source_a) { + if (obs_sceneitem_get_source(scene_item) == move->scene_source_a) { struct move_item *item = NULL; - for (size_t i = 0; i < MATCH_FUNCTION_COUNT; - i++) { + for (size_t i = 0; i < MATCH_FUNCTION_COUNT; i++) { size_t old_pos = 0; - item = match_functions[i]( - move, scene_item, &old_pos); + item = match_functions[i](move, scene_item, &old_pos); if (item) break; } @@ -2735,18 +2384,15 @@ static void move_start_init(struct move_info *move, bool in_graphics) if (!move->matched_scene_a) { for (size_t i = 0; i < MATCH_FUNCTION_COUNT; i++) { for (size_t j = items.num; j > 0; j--) { - obs_sceneitem_t *scene_item = - items.array[j - 1]; + obs_sceneitem_t *scene_item = items.array[j - 1]; size_t old_pos = 0; - item = match_functions[i]( - move, scene_item, &old_pos); + item = match_functions[i](move, scene_item, &old_pos); if (item) { move->matched_items++; da_erase(items, j - 1); - obs_sceneitem_addref( - scene_item); + obs_sceneitem_addref(scene_item); item->item_b = scene_item; } } @@ -2760,12 +2406,9 @@ static void move_start_init(struct move_info *move, bool in_graphics) item->item_b = scene_item; size_t insert = 0; - int order = - obs_sceneitem_get_order_position(scene_item); + int order = obs_sceneitem_get_order_position(scene_item); while (insert < move->items_b.num && - order > obs_sceneitem_get_order_position( - move->items_b.array[insert] - ->item_b)) { + order > obs_sceneitem_get_order_position(move->items_b.array[insert]->item_b)) { insert++; } da_insert(move->items_b, insert, &item); @@ -2776,13 +2419,9 @@ static void move_start_init(struct move_info *move, bool in_graphics) struct move_item *item = move->items_a.array[i]; if (item->item_b) { size_t insert = 0; - int order = obs_sceneitem_get_order_position( - item->item_b); + int order = obs_sceneitem_get_order_position(item->item_b); while (insert < move->items_b.num && - order > obs_sceneitem_get_order_position( - move->items_b - .array[insert] - ->item_b)) { + order > obs_sceneitem_get_order_position(move->items_b.array[insert]->item_b)) { insert++; } da_insert(move->items_b, insert, &item); @@ -2796,8 +2435,7 @@ static void move_start_init(struct move_info *move, bool in_graphics) da_insert(move->items_a, move->item_pos, &item); move->item_pos++; } else { - for (size_t j = move->item_pos; - j < move->items_a.num; j++) { + for (size_t j = move->item_pos; j < move->items_a.num; j++) { if (item == move->items_a.array[j]) { move->item_pos = j + 1; break; @@ -2809,16 +2447,13 @@ static void move_start_init(struct move_info *move, bool in_graphics) const char *n = obs_source_get_name(move->scene_source_b); obs_data_t *sd = obs_data_create(); obs_data_set_bool(sd, "custom_size", true); - obs_data_set_int(sd, "cx", - obs_source_get_width(move->scene_source_b)); - obs_data_set_int(sd, "cy", - obs_source_get_height(move->scene_source_b)); + obs_data_set_int(sd, "cx", obs_source_get_width(move->scene_source_b)); + obs_data_set_int(sd, "cy", obs_source_get_height(move->scene_source_b)); obs_source_t *ss = obs_source_create_private("scene", n, sd); obs_source_load(ss); obs_data_release(sd); scene_b = obs_scene_from_source(ss); - obs_sceneitem_t *scene_item = - obs_scene_add(scene_b, move->scene_source_b); + obs_sceneitem_t *scene_item = obs_scene_add(scene_b, move->scene_source_b); size_t old_pos = 0; struct move_item *item = NULL; for (size_t i = 0; i < MATCH_FUNCTION_COUNT; i++) { @@ -2843,30 +2478,25 @@ static void move_start_init(struct move_info *move, bool in_graphics) da_push_back(move->items_b, &item); } //only a matched scene - if (!move->matched_items && - (move->matched_scene_a || move->matched_scene_b)) { + if (!move->matched_items && (move->matched_scene_a || move->matched_scene_b)) { size_t i = 0; while (i < move->items_a.num) { struct move_item *item = move->items_a.array[i]; if (move->matched_scene_a && item->item_a) { obs_sceneitem_release(item->item_a); if (item->release_scene_a) - obs_scene_release( - item->release_scene_a); + obs_scene_release(item->release_scene_a); if (item->release_scene_b) - obs_scene_release( - item->release_scene_b); + obs_scene_release(item->release_scene_b); da_erase(move->items_a, i); bfree(item->transition_name); bfree(item); } else if (move->matched_scene_b && item->item_b) { obs_sceneitem_release(item->item_b); if (item->release_scene_a) - obs_scene_release( - item->release_scene_a); + obs_scene_release(item->release_scene_a); if (item->release_scene_b) - obs_scene_release( - item->release_scene_b); + obs_scene_release(item->release_scene_b); da_erase(move->items_a, i); bfree(item->transition_name); bfree(item); @@ -2886,8 +2516,7 @@ static void move_start_init(struct move_info *move, bool in_graphics) da_insert(move->items_b, move->item_pos, &item); move->item_pos++; } else { - for (size_t j = move->item_pos; j < move->items_b.num; - j++) { + for (size_t j = move->item_pos; j < move->items_b.num; j++) { if (item == move->items_b.array[j]) { move->item_pos = j + 1; break; @@ -2904,15 +2533,12 @@ static void move_start_init(struct move_info *move, bool in_graphics) other_sceneitem = scene_flip_item->item_a; } - enum obs_bounds_type bt = - obs_sceneitem_get_bounds_type(other_sceneitem); + enum obs_bounds_type bt = obs_sceneitem_get_bounds_type(other_sceneitem); obs_sceneitem_set_bounds_type(scene_flip_sceneitem, bt); - float width = (float)obs_source_get_width( - obs_sceneitem_get_source(scene_flip_sceneitem)); - float height = (float)obs_source_get_height( - obs_sceneitem_get_source(scene_flip_sceneitem)); + float width = (float)obs_source_get_width(obs_sceneitem_get_source(scene_flip_sceneitem)); + float height = (float)obs_source_get_height(obs_sceneitem_get_source(scene_flip_sceneitem)); struct obs_sceneitem_crop crop; obs_sceneitem_get_crop(scene_flip_sceneitem, &crop); @@ -2974,36 +2600,27 @@ static void move_start_init(struct move_info *move, bool in_graphics) item->curve = move->curve_out; } - obs_data_t *settings_a = - get_override_filter_settings(item->item_a); - obs_data_t *settings_b = - get_override_filter_settings(item->item_b); + obs_data_t *settings_a = get_override_filter_settings(item->item_a); + obs_data_t *settings_b = get_override_filter_settings(item->item_b); if (settings_a && settings_b) { - long long val_a = - obs_data_get_int(settings_a, S_EASING_MATCH); - long long val_b = - obs_data_get_int(settings_b, S_EASING_MATCH); + long long val_a = obs_data_get_int(settings_a, S_EASING_MATCH); + long long val_b = obs_data_get_int(settings_b, S_EASING_MATCH); if (val_a != NO_OVERRIDE && val_b != NO_OVERRIDE) { - item->easing = (val_a & EASE_IN) | - (val_b & EASE_OUT); + item->easing = (val_a & EASE_IN) | (val_b & EASE_OUT); } else if (val_a != NO_OVERRIDE) { item->easing = val_a; } else if (val_b != NO_OVERRIDE) { item->easing = val_b; } - val_a = obs_data_get_int(settings_a, - S_EASING_FUNCTION_MATCH); - val_b = obs_data_get_int(settings_b, - S_EASING_FUNCTION_MATCH); + val_a = obs_data_get_int(settings_a, S_EASING_FUNCTION_MATCH); + val_b = obs_data_get_int(settings_b, S_EASING_FUNCTION_MATCH); if (val_a != NO_OVERRIDE) { item->easing_function = val_a; } else if (val_b != NO_OVERRIDE) { item->easing_function = val_b; } - const char *cv_a = obs_data_get_string( - settings_a, S_TRANSITION_MATCH); - const char *cv_b = obs_data_get_string( - settings_b, S_TRANSITION_MATCH); + const char *cv_a = obs_data_get_string(settings_a, S_TRANSITION_MATCH); + const char *cv_b = obs_data_get_string(settings_b, S_TRANSITION_MATCH); if (cv_a && strlen(cv_a)) { bfree(item->transition_name); item->transition_name = bstrdup(cv_a); @@ -3011,78 +2628,58 @@ static void move_start_init(struct move_info *move, bool in_graphics) bfree(item->transition_name); item->transition_name = bstrdup(cv_b); } - val_a = obs_data_get_int(settings_a, - S_TRANSITION_SCALE); - val_b = obs_data_get_int(settings_b, - S_TRANSITION_SCALE); + val_a = obs_data_get_int(settings_a, S_TRANSITION_SCALE); + val_b = obs_data_get_int(settings_b, S_TRANSITION_SCALE); if (val_a != NO_OVERRIDE) { item->transition_scale = val_a; } else if (val_b != NO_OVERRIDE) { item->transition_scale = val_b; } - if (obs_data_get_bool(settings_a, - S_CURVE_OVERRIDE_MATCH)) { - item->curve = (float)obs_data_get_double( - settings_a, S_CURVE_MATCH); - } else if (obs_data_get_bool(settings_b, - S_CURVE_OVERRIDE_MATCH)) { - item->curve = (float)obs_data_get_double( - settings_b, S_CURVE_MATCH); + if (obs_data_get_bool(settings_a, S_CURVE_OVERRIDE_MATCH)) { + item->curve = (float)obs_data_get_double(settings_a, S_CURVE_MATCH); + } else if (obs_data_get_bool(settings_b, S_CURVE_OVERRIDE_MATCH)) { + item->curve = (float)obs_data_get_double(settings_b, S_CURVE_MATCH); } - val_a = obs_data_get_int(settings_a, - S_START_DELAY_MATCH_FROM); - val_b = obs_data_get_int(settings_b, - S_START_DELAY_MATCH_TO); + val_a = obs_data_get_int(settings_a, S_START_DELAY_MATCH_FROM); + val_b = obs_data_get_int(settings_b, S_START_DELAY_MATCH_TO); if (val_a != NO_OVERRIDE && val_b != NO_OVERRIDE) { - item->start_percentage = (int)(val_a + val_b) >> - 1; + item->start_percentage = (int)(val_a + val_b) >> 1; } else if (val_a != NO_OVERRIDE) { item->start_percentage = (int)val_a; } else if (val_b != NO_OVERRIDE) { item->start_percentage = (int)val_b; } - val_a = obs_data_get_int(settings_a, - S_END_DELAY_MATCH_FROM); - val_b = obs_data_get_int(settings_b, - S_END_DELAY_MATCH_TO); + val_a = obs_data_get_int(settings_a, S_END_DELAY_MATCH_FROM); + val_b = obs_data_get_int(settings_b, S_END_DELAY_MATCH_TO); if (val_a != NO_OVERRIDE && val_b != NO_OVERRIDE) { - item->end_percentage = - 100 - ((int)(val_a + val_b) >> 1); + item->end_percentage = 100 - ((int)(val_a + val_b) >> 1); } else if (val_a != NO_OVERRIDE) { item->end_percentage = 100 - (int)val_a; } else if (val_b != NO_OVERRIDE) { item->end_percentage = 100 - (int)val_b; } - const char *start_move_a = obs_data_get_string( - settings_a, S_START_MOVE_MATCH_FROM); + const char *start_move_a = obs_data_get_string(settings_a, S_START_MOVE_MATCH_FROM); if (start_move_a && strlen(start_move_a)) { - sceneitem_start_move(item->item_a, - start_move_a); + sceneitem_start_move(item->item_a, start_move_a); } - const char *start_move_b = obs_data_get_string( - settings_b, S_START_MOVE_MATCH_TO); + const char *start_move_b = obs_data_get_string(settings_b, S_START_MOVE_MATCH_TO); if (start_move_b && strlen(start_move_b)) { - sceneitem_start_move(item->item_b, - start_move_b); + sceneitem_start_move(item->item_b, start_move_b); } } else if (settings_a) { long long val; if ((item->item_a && item->item_b) || item->move_scene) - val = obs_data_get_int(settings_a, - S_EASING_MATCH); + val = obs_data_get_int(settings_a, S_EASING_MATCH); else - val = obs_data_get_int(settings_a, - S_EASING_OUT); + val = obs_data_get_int(settings_a, S_EASING_OUT); if (val != NO_OVERRIDE) { item->easing = val; } if ((item->item_a && item->item_b) || item->move_scene) - val = obs_data_get_int(settings_a, - S_EASING_FUNCTION_MATCH); + val = obs_data_get_int(settings_a, S_EASING_FUNCTION_MATCH); else - val = obs_data_get_int(settings_a, - S_EASING_FUNCTION_OUT); + val = obs_data_get_int(settings_a, S_EASING_FUNCTION_OUT); if (val != NO_OVERRIDE) { item->easing_function = val; } @@ -3098,60 +2695,40 @@ static void move_start_init(struct move_info *move, bool in_graphics) if (val != NO_OVERRIDE) { item->transition_scale = val; } - const char *ti = obs_data_get_string(settings_a, - S_TRANSITION_OUT); - if (!item->move_scene && ti && strlen(ti) && - item->item_a && !item->item_b) { + const char *ti = obs_data_get_string(settings_a, S_TRANSITION_OUT); + if (!item->move_scene && ti && strlen(ti) && item->item_a && !item->item_b) { bfree(item->transition_name); item->transition_name = bstrdup(ti); } - const char *tm = obs_data_get_string( - settings_a, S_TRANSITION_MATCH); - if (tm && strlen(tm) && - ((item->item_a && item->item_b) || - item->move_scene)) { + const char *tm = obs_data_get_string(settings_a, S_TRANSITION_MATCH); + if (tm && strlen(tm) && ((item->item_a && item->item_b) || item->move_scene)) { bfree(item->transition_name); item->transition_name = bstrdup(tm); } - if (((item->item_a && item->item_b) || - item->move_scene) && - obs_data_get_bool(settings_a, - S_CURVE_OVERRIDE_MATCH)) { - item->curve = (float)obs_data_get_double( - settings_a, S_CURVE_MATCH); - } else if (!item->move_scene && item->item_a && - !item->item_b && - obs_data_get_bool(settings_a, - S_CURVE_OVERRIDE_OUT)) { - item->curve = (float)obs_data_get_double( - settings_a, S_CURVE_OUT); + if (((item->item_a && item->item_b) || item->move_scene) && + obs_data_get_bool(settings_a, S_CURVE_OVERRIDE_MATCH)) { + item->curve = (float)obs_data_get_double(settings_a, S_CURVE_MATCH); + } else if (!item->move_scene && item->item_a && !item->item_b && + obs_data_get_bool(settings_a, S_CURVE_OVERRIDE_OUT)) { + item->curve = (float)obs_data_get_double(settings_a, S_CURVE_OUT); } if ((item->item_a && item->item_b) || item->move_scene) - val = obs_data_get_int( - settings_a, S_START_DELAY_MATCH_FROM); + val = obs_data_get_int(settings_a, S_START_DELAY_MATCH_FROM); else - val = obs_data_get_int(settings_a, - S_START_DELAY_OUT); + val = obs_data_get_int(settings_a, S_START_DELAY_OUT); if (val != NO_OVERRIDE) { item->start_percentage = (int)val; } if ((item->item_a && item->item_b) || item->move_scene) - val = obs_data_get_int(settings_a, - S_END_DELAY_MATCH_FROM); + val = obs_data_get_int(settings_a, S_END_DELAY_MATCH_FROM); else - val = obs_data_get_int(settings_a, - S_END_DELAY_OUT); + val = obs_data_get_int(settings_a, S_END_DELAY_OUT); if (val != NO_OVERRIDE) { item->end_percentage = 100 - (int)val; } - const char *move_start = - ((item->item_a && item->item_b) || - item->move_scene) - ? obs_data_get_string( - settings_a, - S_START_MOVE_MATCH_FROM) - : obs_data_get_string(settings_a, - S_START_MOVE_OUT); + const char *move_start = ((item->item_a && item->item_b) || item->move_scene) + ? obs_data_get_string(settings_a, S_START_MOVE_MATCH_FROM) + : obs_data_get_string(settings_a, S_START_MOVE_OUT); if (move_start && strlen(move_start)) { sceneitem_start_move(item->item_a, move_start); } @@ -3159,19 +2736,16 @@ static void move_start_init(struct move_info *move, bool in_graphics) } else if (settings_b) { long long val; if ((item->item_a && item->item_b) || item->move_scene) - val = obs_data_get_int(settings_b, - S_EASING_MATCH); + val = obs_data_get_int(settings_b, S_EASING_MATCH); else val = obs_data_get_int(settings_b, S_EASING_IN); if (val != NO_OVERRIDE) { item->easing = val; } if ((item->item_a && item->item_b) || item->move_scene) - val = obs_data_get_int(settings_b, - S_EASING_FUNCTION_MATCH); + val = obs_data_get_int(settings_b, S_EASING_FUNCTION_MATCH); else - val = obs_data_get_int(settings_b, - S_EASING_FUNCTION_IN); + val = obs_data_get_int(settings_b, S_EASING_FUNCTION_IN); if (val != NO_OVERRIDE) { item->easing_function = val; } @@ -3187,82 +2761,59 @@ static void move_start_init(struct move_info *move, bool in_graphics) if (val != NO_OVERRIDE) { item->transition_scale = val; } - const char *to = obs_data_get_string(settings_b, - S_TRANSITION_IN); - if (!item->move_scene && to && strlen(to) && - !item->item_a && item->item_b) { + const char *to = obs_data_get_string(settings_b, S_TRANSITION_IN); + if (!item->move_scene && to && strlen(to) && !item->item_a && item->item_b) { bfree(item->transition_name); item->transition_name = bstrdup(to); } - const char *tm = obs_data_get_string( - settings_b, S_TRANSITION_MATCH); - if (tm && strlen(tm) && - ((item->item_a && item->item_b) || - item->move_scene)) { + const char *tm = obs_data_get_string(settings_b, S_TRANSITION_MATCH); + if (tm && strlen(tm) && ((item->item_a && item->item_b) || item->move_scene)) { bfree(item->transition_name); item->transition_name = bstrdup(tm); } - if (((item->item_a && item->item_b) || - item->move_scene) && - obs_data_get_bool(settings_b, - S_CURVE_OVERRIDE_MATCH)) { - item->curve = (float)obs_data_get_double( - settings_b, S_CURVE_MATCH); - } else if (!item->move_scene && !item->item_a && - item->item_b && - obs_data_get_bool(settings_b, - S_CURVE_OVERRIDE_IN)) { - item->curve = (float)obs_data_get_double( - settings_b, S_CURVE_IN); + if (((item->item_a && item->item_b) || item->move_scene) && + obs_data_get_bool(settings_b, S_CURVE_OVERRIDE_MATCH)) { + item->curve = (float)obs_data_get_double(settings_b, S_CURVE_MATCH); + } else if (!item->move_scene && !item->item_a && item->item_b && + obs_data_get_bool(settings_b, S_CURVE_OVERRIDE_IN)) { + item->curve = (float)obs_data_get_double(settings_b, S_CURVE_IN); } if ((item->item_a && item->item_b) || item->move_scene) - val = obs_data_get_int(settings_b, - S_START_DELAY_MATCH_TO); + val = obs_data_get_int(settings_b, S_START_DELAY_MATCH_TO); else - val = obs_data_get_int(settings_b, - S_START_DELAY_IN); + val = obs_data_get_int(settings_b, S_START_DELAY_IN); if (val != NO_OVERRIDE) { item->start_percentage = (int)val; } if ((item->item_a && item->item_b) || item->move_scene) - val = obs_data_get_int(settings_b, - S_END_DELAY_MATCH_TO); + val = obs_data_get_int(settings_b, S_END_DELAY_MATCH_TO); else - val = obs_data_get_int(settings_b, - S_END_DELAY_IN); + val = obs_data_get_int(settings_b, S_END_DELAY_IN); if (val != NO_OVERRIDE) { item->end_percentage = 100 - (int)val; } - const char *move_start = - ((item->item_a && item->item_b) || - item->move_scene) - ? obs_data_get_string( - settings_b, - S_START_MOVE_MATCH_TO) - : obs_data_get_string(settings_a, - S_START_MOVE_IN); + const char *move_start = ((item->item_a && item->item_b) || item->move_scene) + ? obs_data_get_string(settings_b, S_START_MOVE_MATCH_TO) + : obs_data_get_string(settings_a, S_START_MOVE_IN); if (move_start && strlen(move_start)) { sceneitem_start_move(item->item_b, move_start); } } obs_data_release(settings_a); obs_data_release(settings_b); - if (!item->transition_name && !item->move_scene && - !item->item_a && item->item_b && move->transition_in && + if (!item->transition_name && !item->move_scene && !item->item_a && item->item_b && move->transition_in && strlen(move->transition_in)) { bfree(item->transition_name); item->transition_name = bstrdup(move->transition_in); } - if (!item->transition_name && !item->move_scene && - item->item_a && !item->item_b && move->transition_out && + if (!item->transition_name && !item->move_scene && item->item_a && !item->item_b && move->transition_out && strlen(move->transition_out)) { bfree(item->transition_name); item->transition_name = bstrdup(move->transition_out); } - if (!item->transition_name && - ((item->item_a && item->item_b) || item->move_scene) && - move->transition_move && strlen(move->transition_move)) { + if (!item->transition_name && ((item->item_a && item->item_b) || item->move_scene) && move->transition_move && + strlen(move->transition_move)) { bfree(item->transition_name); item->transition_name = bstrdup(move->transition_move); } @@ -3284,11 +2835,9 @@ static void move_video_render(void *data, gs_effect_t *effect) if (move->t >= 0.0f && move->t < 1.0f) { if (!move->scene_source_a) - move->scene_source_a = obs_transition_get_source( - move->source, OBS_TRANSITION_SOURCE_A); + move->scene_source_a = obs_transition_get_source(move->source, OBS_TRANSITION_SOURCE_A); if (!move->scene_source_b) - move->scene_source_b = obs_transition_get_source( - move->source, OBS_TRANSITION_SOURCE_B); + move->scene_source_b = obs_transition_get_source(move->source, OBS_TRANSITION_SOURCE_B); gs_matrix_push(); gs_blend_state_push(); @@ -3320,11 +2869,9 @@ static void move_video_render(void *data, gs_effect_t *effect) move->scene_source_b = NULL; } if (move->t <= 0.5f) { - obs_transition_video_render_direct( - move->source, OBS_TRANSITION_SOURCE_A); + obs_transition_video_render_direct(move->source, OBS_TRANSITION_SOURCE_A); } else { - obs_transition_video_render_direct( - move->source, OBS_TRANSITION_SOURCE_B); + obs_transition_video_render_direct(move->source, OBS_TRANSITION_SOURCE_B); } } move->first_frame = false; @@ -3344,48 +2891,30 @@ static float mix_b(void *data, float t) return CubicEaseInOut(t); } -static bool move_audio_render(void *data, uint64_t *ts_out, - struct obs_source_audio_mix *audio, - uint32_t mixers, size_t channels, +static bool move_audio_render(void *data, uint64_t *ts_out, struct obs_source_audio_mix *audio, uint32_t mixers, size_t channels, size_t sample_rate) { struct move_info *move = data; - return obs_transition_audio_render(move->source, ts_out, audio, mixers, - channels, sample_rate, mix_a, mix_b); + return obs_transition_audio_render(move->source, ts_out, audio, mixers, channels, sample_rate, mix_a, mix_b); } void prop_list_add_positions(obs_property_t *p) { - obs_property_list_add_int(p, obs_module_text("Position.None"), - POS_NONE); - obs_property_list_add_int(p, obs_module_text("Position.Center"), - POS_CENTER); - obs_property_list_add_int(p, obs_module_text("Position.CenterInverse"), - POS_EDGE); - obs_property_list_add_int(p, obs_module_text("Position.TopLeft"), - POS_EDGE | POS_TOP | POS_LEFT); - obs_property_list_add_int(p, obs_module_text("Position.TopCenter"), - POS_EDGE | POS_TOP); - obs_property_list_add_int(p, obs_module_text("Position.TopRight"), - POS_EDGE | POS_TOP | POS_RIGHT); - obs_property_list_add_int(p, obs_module_text("Position.CenterRight"), - POS_EDGE | POS_RIGHT); - obs_property_list_add_int(p, obs_module_text("Position.BottomRight"), - POS_EDGE | POS_BOTTOM | POS_RIGHT); - obs_property_list_add_int(p, obs_module_text("Position.BottomCenter"), - POS_EDGE | POS_BOTTOM); - obs_property_list_add_int(p, obs_module_text("Position.BottomLeft"), - POS_EDGE | POS_BOTTOM | POS_LEFT); - obs_property_list_add_int(p, obs_module_text("Position.CenterLeft"), - POS_EDGE | POS_LEFT); - obs_property_list_add_int(p, obs_module_text("Position.Left"), - POS_SWIPE | POS_LEFT); - obs_property_list_add_int(p, obs_module_text("Position.Top"), - POS_SWIPE | POS_TOP); - obs_property_list_add_int(p, obs_module_text("Position.Right"), - POS_SWIPE | POS_RIGHT); - obs_property_list_add_int(p, obs_module_text("Position.Bottom"), - POS_SWIPE | POS_BOTTOM); + obs_property_list_add_int(p, obs_module_text("Position.None"), POS_NONE); + obs_property_list_add_int(p, obs_module_text("Position.Center"), POS_CENTER); + obs_property_list_add_int(p, obs_module_text("Position.CenterInverse"), POS_EDGE); + obs_property_list_add_int(p, obs_module_text("Position.TopLeft"), POS_EDGE | POS_TOP | POS_LEFT); + obs_property_list_add_int(p, obs_module_text("Position.TopCenter"), POS_EDGE | POS_TOP); + obs_property_list_add_int(p, obs_module_text("Position.TopRight"), POS_EDGE | POS_TOP | POS_RIGHT); + obs_property_list_add_int(p, obs_module_text("Position.CenterRight"), POS_EDGE | POS_RIGHT); + obs_property_list_add_int(p, obs_module_text("Position.BottomRight"), POS_EDGE | POS_BOTTOM | POS_RIGHT); + obs_property_list_add_int(p, obs_module_text("Position.BottomCenter"), POS_EDGE | POS_BOTTOM); + obs_property_list_add_int(p, obs_module_text("Position.BottomLeft"), POS_EDGE | POS_BOTTOM | POS_LEFT); + obs_property_list_add_int(p, obs_module_text("Position.CenterLeft"), POS_EDGE | POS_LEFT); + obs_property_list_add_int(p, obs_module_text("Position.Left"), POS_SWIPE | POS_LEFT); + obs_property_list_add_int(p, obs_module_text("Position.Top"), POS_SWIPE | POS_TOP); + obs_property_list_add_int(p, obs_module_text("Position.Right"), POS_SWIPE | POS_RIGHT); + obs_property_list_add_int(p, obs_module_text("Position.Bottom"), POS_SWIPE | POS_BOTTOM); } void prop_list_add_easings(obs_property_t *p) @@ -3393,45 +2922,30 @@ void prop_list_add_easings(obs_property_t *p) obs_property_list_add_int(p, obs_module_text("Easing.None"), EASE_NONE); obs_property_list_add_int(p, obs_module_text("Easing.In"), EASE_IN); obs_property_list_add_int(p, obs_module_text("Easing.Out"), EASE_OUT); - obs_property_list_add_int(p, obs_module_text("Easing.InOut"), - EASE_IN_OUT); + obs_property_list_add_int(p, obs_module_text("Easing.InOut"), EASE_IN_OUT); } void prop_list_add_easing_functions(obs_property_t *p) { - obs_property_list_add_int(p, - obs_module_text("EasingFunction.Quadratic"), - EASING_QUADRATIC); - obs_property_list_add_int(p, obs_module_text("EasingFunction.Cubic"), - EASING_CUBIC); - obs_property_list_add_int(p, obs_module_text("EasingFunction.Quartic"), - EASING_QUARTIC); - obs_property_list_add_int(p, obs_module_text("EasingFunction.Quintic"), - EASING_QUINTIC); - obs_property_list_add_int(p, obs_module_text("EasingFunction.Sine"), - EASING_SINE); - obs_property_list_add_int(p, obs_module_text("EasingFunction.Circular"), - EASING_CIRCULAR); - obs_property_list_add_int(p, - obs_module_text("EasingFunction.Exponential"), - EASING_EXPONENTIAL); - obs_property_list_add_int(p, obs_module_text("EasingFunction.Elastic"), - EASING_ELASTIC); - obs_property_list_add_int(p, obs_module_text("EasingFunction.Bounce"), - EASING_BOUNCE); - obs_property_list_add_int(p, obs_module_text("EasingFunction.Back"), - EASING_BACK); + obs_property_list_add_int(p, obs_module_text("EasingFunction.Quadratic"), EASING_QUADRATIC); + obs_property_list_add_int(p, obs_module_text("EasingFunction.Cubic"), EASING_CUBIC); + obs_property_list_add_int(p, obs_module_text("EasingFunction.Quartic"), EASING_QUARTIC); + obs_property_list_add_int(p, obs_module_text("EasingFunction.Quintic"), EASING_QUINTIC); + obs_property_list_add_int(p, obs_module_text("EasingFunction.Sine"), EASING_SINE); + obs_property_list_add_int(p, obs_module_text("EasingFunction.Circular"), EASING_CIRCULAR); + obs_property_list_add_int(p, obs_module_text("EasingFunction.Exponential"), EASING_EXPONENTIAL); + obs_property_list_add_int(p, obs_module_text("EasingFunction.Elastic"), EASING_ELASTIC); + obs_property_list_add_int(p, obs_module_text("EasingFunction.Bounce"), EASING_BOUNCE); + obs_property_list_add_int(p, obs_module_text("EasingFunction.Back"), EASING_BACK); } void prop_list_add_transitions(obs_property_t *p) { struct obs_frontend_source_list transitions = {0}; - obs_property_list_add_string(p, obs_module_text("Transition.None"), - "None"); + obs_property_list_add_string(p, obs_module_text("Transition.None"), "None"); obs_frontend_get_transitions(&transitions); for (size_t i = 0; i < transitions.sources.num; i++) { - const char *name = - obs_source_get_name(transitions.sources.array[i]); + const char *name = obs_source_get_name(transitions.sources.array[i]); obs_property_list_add_string(p, name, name); } obs_frontend_source_list_free(&transitions); @@ -3439,12 +2953,9 @@ void prop_list_add_transitions(obs_property_t *p) void prop_list_add_scales(obs_property_t *p) { - obs_property_list_add_int(p, obs_module_text("TransitionScale.MaxOnly"), - OBS_TRANSITION_SCALE_MAX_ONLY); - obs_property_list_add_int(p, obs_module_text("TransitionScale.Aspect"), - OBS_TRANSITION_SCALE_ASPECT); - obs_property_list_add_int(p, obs_module_text("TransitionScale.Stretch"), - OBS_TRANSITION_SCALE_STRETCH); + obs_property_list_add_int(p, obs_module_text("TransitionScale.MaxOnly"), OBS_TRANSITION_SCALE_MAX_ONLY); + obs_property_list_add_int(p, obs_module_text("TransitionScale.Aspect"), OBS_TRANSITION_SCALE_ASPECT); + obs_property_list_add_int(p, obs_module_text("TransitionScale.Stretch"), OBS_TRANSITION_SCALE_STRETCH); } static obs_properties_t *move_properties(void *data) @@ -3452,125 +2963,87 @@ static obs_properties_t *move_properties(void *data) obs_property_t *p; obs_properties_t *ppts = obs_properties_create(); obs_properties_t *group = obs_properties_create(); - obs_properties_add_bool(group, S_NAME_PART_MATCH, - obs_module_text("NamePartMatch")); - obs_properties_add_bool(group, S_NAME_NUMBER_MATCH, - obs_module_text("NameNumberMatch")); - obs_properties_add_bool(group, S_NAME_LAST_WORD_MATCH, - obs_module_text("NameLastWordMatch")); + obs_properties_add_bool(group, S_NAME_PART_MATCH, obs_module_text("NamePartMatch")); + obs_properties_add_bool(group, S_NAME_NUMBER_MATCH, obs_module_text("NameNumberMatch")); + obs_properties_add_bool(group, S_NAME_LAST_WORD_MATCH, obs_module_text("NameLastWordMatch")); - obs_properties_add_group(ppts, S_MATCH, obs_module_text("MatchName"), - OBS_GROUP_NORMAL, group); + obs_properties_add_group(ppts, S_MATCH, obs_module_text("MatchName"), OBS_GROUP_NORMAL, group); group = obs_properties_create(); - obs_properties_add_bool(group, S_NESTED_SCENES, - obs_module_text("NestedScenes")); - obs_properties_add_bool(group, S_CACHE_TRANSITIONS, - obs_module_text("CacheTransitions")); + obs_properties_add_bool(group, S_NESTED_SCENES, obs_module_text("NestedScenes")); + obs_properties_add_bool(group, S_CACHE_TRANSITIONS, obs_module_text("CacheTransitions")); - p = obs_properties_add_int_slider(group, S_SWITCH_PERCENTAGE, - obs_module_text("SwitchPoint"), 0, - 100, 1); + p = obs_properties_add_int_slider(group, S_SWITCH_PERCENTAGE, obs_module_text("SwitchPoint"), 0, 100, 1); obs_property_int_set_suffix(p, "%"); - obs_properties_add_group(ppts, S_MOVE_ALL, obs_module_text("MoveAll"), - OBS_GROUP_NORMAL, group); + obs_properties_add_group(ppts, S_MOVE_ALL, obs_module_text("MoveAll"), OBS_GROUP_NORMAL, group); //Matched items group = obs_properties_create(); - p = obs_properties_add_list(group, S_EASING_MATCH, - obs_module_text("Easing"), - OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); + p = obs_properties_add_list(group, S_EASING_MATCH, obs_module_text("Easing"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); prop_list_add_easings(p); - p = obs_properties_add_list(group, S_EASING_FUNCTION_MATCH, - obs_module_text("EasingFunction"), - OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); + p = obs_properties_add_list(group, S_EASING_FUNCTION_MATCH, obs_module_text("EasingFunction"), OBS_COMBO_TYPE_LIST, + OBS_COMBO_FORMAT_INT); prop_list_add_easing_functions(p); - p = obs_properties_add_list(group, S_TRANSITION_MATCH, - obs_module_text("Transition"), - OBS_COMBO_TYPE_LIST, + p = obs_properties_add_list(group, S_TRANSITION_MATCH, obs_module_text("Transition"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING); prop_list_add_transitions(p); - p = obs_properties_add_list(group, S_TRANSITION_SCALE, - obs_module_text("TransitionScaleType"), - OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); + p = obs_properties_add_list(group, S_TRANSITION_SCALE, obs_module_text("TransitionScaleType"), OBS_COMBO_TYPE_LIST, + OBS_COMBO_FORMAT_INT); prop_list_add_scales(p); - obs_properties_add_float_slider(group, S_CURVE_MATCH, - obs_module_text("Curve"), -2.0, 2.0, - 0.01); + obs_properties_add_float_slider(group, S_CURVE_MATCH, obs_module_text("Curve"), -2.0, 2.0, 0.01); - obs_properties_add_group(ppts, S_MOVE_MATCH, - obs_module_text("MoveMatch"), OBS_GROUP_NORMAL, - group); + obs_properties_add_group(ppts, S_MOVE_MATCH, obs_module_text("MoveMatch"), OBS_GROUP_NORMAL, group); //Move in group = obs_properties_create(); - p = obs_properties_add_list(group, S_EASING_IN, - obs_module_text("Easing"), - OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); + p = obs_properties_add_list(group, S_EASING_IN, obs_module_text("Easing"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); prop_list_add_easings(p); - p = obs_properties_add_list(group, S_EASING_FUNCTION_IN, - obs_module_text("EasingFunction"), - OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); + p = obs_properties_add_list(group, S_EASING_FUNCTION_IN, obs_module_text("EasingFunction"), OBS_COMBO_TYPE_LIST, + OBS_COMBO_FORMAT_INT); prop_list_add_easing_functions(p); obs_properties_add_bool(group, S_ZOOM_IN, obs_module_text("Zoom")); - p = obs_properties_add_list(group, S_POSITION_IN, - obs_module_text("Position"), - OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); + p = obs_properties_add_list(group, S_POSITION_IN, obs_module_text("Position"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); prop_list_add_positions(p); - p = obs_properties_add_list(group, S_TRANSITION_IN, - obs_module_text("Transition"), - OBS_COMBO_TYPE_LIST, + p = obs_properties_add_list(group, S_TRANSITION_IN, obs_module_text("Transition"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING); prop_list_add_transitions(p); - obs_properties_add_float_slider( - group, S_CURVE_IN, obs_module_text("Curve"), -2.0, 2.0, 0.01); + obs_properties_add_float_slider(group, S_CURVE_IN, obs_module_text("Curve"), -2.0, 2.0, 0.01); - obs_properties_add_group(ppts, S_MOVE_IN, obs_module_text("MoveIn"), - OBS_GROUP_NORMAL, group); + obs_properties_add_group(ppts, S_MOVE_IN, obs_module_text("MoveIn"), OBS_GROUP_NORMAL, group); //Move out group = obs_properties_create(); - p = obs_properties_add_list(group, S_EASING_OUT, - obs_module_text("Easing"), - OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); + p = obs_properties_add_list(group, S_EASING_OUT, obs_module_text("Easing"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); prop_list_add_easings(p); - p = obs_properties_add_list(group, S_EASING_FUNCTION_OUT, - obs_module_text("EasingFunction"), - OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); + p = obs_properties_add_list(group, S_EASING_FUNCTION_OUT, obs_module_text("EasingFunction"), OBS_COMBO_TYPE_LIST, + OBS_COMBO_FORMAT_INT); prop_list_add_easing_functions(p); obs_properties_add_bool(group, S_ZOOM_OUT, obs_module_text("Zoom")); - p = obs_properties_add_list(group, S_POSITION_OUT, - obs_module_text("Position"), - OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); + p = obs_properties_add_list(group, S_POSITION_OUT, obs_module_text("Position"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); prop_list_add_positions(p); - p = obs_properties_add_list(group, S_TRANSITION_OUT, - obs_module_text("Transition"), - OBS_COMBO_TYPE_LIST, + p = obs_properties_add_list(group, S_TRANSITION_OUT, obs_module_text("Transition"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING); prop_list_add_transitions(p); - obs_properties_add_float_slider( - group, S_CURVE_OUT, obs_module_text("Curve"), -2.0, 2.0, 0.01); + obs_properties_add_float_slider(group, S_CURVE_OUT, obs_module_text("Curve"), -2.0, 2.0, 0.01); - obs_properties_add_group(ppts, S_MOVE_OUT, obs_module_text("MoveOut"), - OBS_GROUP_NORMAL, group); - obs_properties_add_text(ppts, "plugin_info", PLUGIN_INFO, - OBS_TEXT_INFO); + obs_properties_add_group(ppts, S_MOVE_OUT, obs_module_text("MoveOut"), OBS_GROUP_NORMAL, group); + obs_properties_add_text(ppts, "plugin_info", PLUGIN_INFO, OBS_TEXT_INFO); UNUSED_PARAMETER(data); return ppts; } @@ -3580,14 +3053,12 @@ void move_defaults(obs_data_t *settings) obs_data_set_default_int(settings, S_EASING_MATCH, EASE_IN_OUT); obs_data_set_default_int(settings, S_EASING_IN, EASE_IN_OUT); obs_data_set_default_int(settings, S_EASING_OUT, EASE_IN_OUT); - obs_data_set_default_int(settings, S_EASING_FUNCTION_MATCH, - EASING_CUBIC); + obs_data_set_default_int(settings, S_EASING_FUNCTION_MATCH, EASING_CUBIC); obs_data_set_default_int(settings, S_EASING_FUNCTION_IN, EASING_CUBIC); obs_data_set_default_int(settings, S_EASING_FUNCTION_OUT, EASING_CUBIC); obs_data_set_default_int(settings, S_POSITION_IN, POS_EDGE | POS_LEFT); obs_data_set_default_bool(settings, S_ZOOM_IN, true); - obs_data_set_default_int(settings, S_POSITION_OUT, - POS_EDGE | POS_RIGHT); + obs_data_set_default_int(settings, S_POSITION_OUT, POS_EDGE | POS_RIGHT); obs_data_set_default_bool(settings, S_ZOOM_OUT, true); obs_data_set_default_double(settings, S_CURVE_MATCH, 0.0); obs_data_set_default_double(settings, S_CURVE_IN, 0.0); diff --git a/move-transition.h b/move-transition.h index 1b5d000..bc77ca7 100644 --- a/move-transition.h +++ b/move-transition.h @@ -257,8 +257,7 @@ struct move_filter { }; bool is_move_filter(const char *filter_id); -void move_filter_init(struct move_filter *move_filter, obs_source_t *source, - void (*move_start)(void *data)); +void move_filter_init(struct move_filter *move_filter, obs_source_t *source, void (*move_start)(void *data)); void move_filter_destroy(struct move_filter *move_filter); void move_filter_update(struct move_filter *move_filter, obs_data_t *settings); void move_filter_start(struct move_filter *move_filter); @@ -266,8 +265,7 @@ bool move_filter_start_internal(struct move_filter *move_filter); void move_filter_stop(struct move_filter *move_filter); void move_filter_ended(struct move_filter *move_filter); bool move_filter_tick(struct move_filter *move_filter, float seconds, float *t); -void move_filter_properties(struct move_filter *move_filter, - obs_properties_t *ppts); +void move_filter_properties(struct move_filter *move_filter, obs_properties_t *ppts); void move_filter_defaults(obs_data_t *settings); void move_filter_activate(void *data); void move_filter_deactivate(void *data); @@ -276,5 +274,4 @@ void move_filter_hide(void *data); void prop_list_add_easings(obs_property_t *p); void prop_list_add_easing_functions(obs_property_t *p); -void prop_list_add_move_source_filter(obs_source_t *parent, obs_source_t *child, - void *data); +void prop_list_add_move_source_filter(obs_source_t *parent, obs_source_t *child, void *data); diff --git a/move-value-filter.c b/move-value-filter.c index 644532d..7367eb2 100644 --- a/move-value-filter.c +++ b/move-value-filter.c @@ -60,8 +60,7 @@ struct move_value_info { char *format; }; -static void load_properties(obs_properties_t *props_from, - obs_data_array_t *array, obs_data_t *settings_to, +static void load_properties(obs_properties_t *props_from, obs_data_array_t *array, obs_data_t *settings_to, obs_data_t *settings_from) { obs_property_t *prop_from = obs_properties_first(props_from); @@ -74,97 +73,68 @@ static void load_properties(obs_properties_t *props_from, const size_t count = obs_data_array_count(array); for (size_t i = 0; i < count; i++) { obs_data_t *item2 = obs_data_array_item(array, i); - const char *setting_name2 = - obs_data_get_string(item2, S_SETTING_NAME); + const char *setting_name2 = obs_data_get_string(item2, S_SETTING_NAME); if (strcmp(setting_name2, name) == 0) { setting = item2; } } - const enum obs_property_type prop_type = - obs_property_get_type(prop_from); + const enum obs_property_type prop_type = obs_property_get_type(prop_from); if (prop_type == OBS_PROPERTY_GROUP) { - load_properties(obs_property_group_content(prop_from), - array, settings_to, settings_from); + load_properties(obs_property_group_content(prop_from), array, settings_to, settings_from); } else if (prop_type == OBS_PROPERTY_INT) { if (!setting) { setting = obs_data_create(); - obs_data_set_string(setting, S_SETTING_NAME, - name); + obs_data_set_string(setting, S_SETTING_NAME, name); obs_data_array_push_back(array, setting); } obs_data_set_int(setting, S_VALUE_TYPE, MOVE_VALUE_INT); if (obs_data_has_default_value(settings_from, name)) - obs_data_set_default_int( - settings_to, name, - obs_data_get_default_int(settings_from, - name)); - const long long to = - obs_data_get_int(settings_to, name); + obs_data_set_default_int(settings_to, name, obs_data_get_default_int(settings_from, name)); + const long long to = obs_data_get_int(settings_to, name); obs_data_set_int(setting, S_SETTING_TO, to); - const long long from = - obs_data_get_int(settings_from, name); + const long long from = obs_data_get_int(settings_from, name); obs_data_set_int(setting, S_SETTING_FROM, from); } else if (prop_type == OBS_PROPERTY_FLOAT) { if (!setting) { setting = obs_data_create(); - obs_data_set_string(setting, S_SETTING_NAME, - name); + obs_data_set_string(setting, S_SETTING_NAME, name); obs_data_array_push_back(array, setting); } - obs_data_set_int(setting, S_VALUE_TYPE, - MOVE_VALUE_FLOAT); + obs_data_set_int(setting, S_VALUE_TYPE, MOVE_VALUE_FLOAT); if (obs_data_has_default_value(settings_from, name)) - obs_data_set_default_double( - settings_to, name, - obs_data_get_default_double( - settings_from, name)); - const double to = - obs_data_get_double(settings_to, name); + obs_data_set_default_double(settings_to, name, obs_data_get_default_double(settings_from, name)); + const double to = obs_data_get_double(settings_to, name); obs_data_set_double(setting, S_SETTING_TO, to); - const double from = - obs_data_get_double(settings_from, name); + const double from = obs_data_get_double(settings_from, name); obs_data_set_double(setting, S_SETTING_FROM, from); - } else if (prop_type == OBS_PROPERTY_COLOR || - prop_type == OBS_PROPERTY_COLOR_ALPHA) { + } else if (prop_type == OBS_PROPERTY_COLOR || prop_type == OBS_PROPERTY_COLOR_ALPHA) { if (!setting) { setting = obs_data_create(); - obs_data_set_string(setting, S_SETTING_NAME, - name); + obs_data_set_string(setting, S_SETTING_NAME, name); obs_data_array_push_back(array, setting); } obs_data_set_int(setting, S_VALUE_TYPE, - prop_type == OBS_PROPERTY_COLOR - ? MOVE_VALUE_COLOR - : MOVE_VALUE_COLOR_ALPHA); + prop_type == OBS_PROPERTY_COLOR ? MOVE_VALUE_COLOR : MOVE_VALUE_COLOR_ALPHA); if (obs_data_has_default_value(settings_from, name)) - obs_data_set_default_int( - settings_to, name, - obs_data_get_default_int(settings_from, - name)); - obs_data_set_int(setting, S_SETTING_TO, - obs_data_get_int(settings_to, name)); - const long long from = - obs_data_get_int(settings_from, name); + obs_data_set_default_int(settings_to, name, obs_data_get_default_int(settings_from, name)); + obs_data_set_int(setting, S_SETTING_TO, obs_data_get_int(settings_to, name)); + const long long from = obs_data_get_int(settings_from, name); obs_data_set_int(setting, S_SETTING_FROM, from); } } } -void move_values_load_properties(struct move_value_info *move_value, - obs_source_t *source, obs_data_t *settings) +void move_values_load_properties(struct move_value_info *move_value, obs_source_t *source, obs_data_t *settings) { if (source && source != move_value->move_filter.source) { obs_properties_t *sps = obs_source_properties(source); size_t index = 0; while (index < obs_data_array_count(move_value->settings)) { - obs_data_t *item = obs_data_array_item( - move_value->settings, index); - const char *setting_name = - obs_data_get_string(item, S_SETTING_NAME); + obs_data_t *item = obs_data_array_item(move_value->settings, index); + const char *setting_name = obs_data_get_string(item, S_SETTING_NAME); if (obs_properties_get(sps, setting_name) == NULL) { - obs_data_array_erase(move_value->settings, - index); + obs_data_array_erase(move_value->settings, index); } else { index++; } @@ -189,13 +159,11 @@ long long rand_between(long long a, long long b) float rand_between_float(float a, float b) { - return b > a ? a + (b - a) * (float)rand() / (float)RAND_MAX - : b + (a - b) * (float)rand() / (float)RAND_MAX; + return b > a ? a + (b - a) * (float)rand() / (float)RAND_MAX : b + (a - b) * (float)rand() / (float)RAND_MAX; } double rand_between_double(double a, double b) { - return b > a ? a + (b - a) * (double)rand() / (double)RAND_MAX - : b + (a - b) * (double)rand() / (double)RAND_MAX; + return b > a ? a + (b - a) * (double)rand() / (double)RAND_MAX : b + (a - b) * (double)rand() / (double)RAND_MAX; } double parse_text(long long format_type, const char *format, const char *text) @@ -209,20 +177,15 @@ double parse_text(long long format_type, const char *format, const char *text) unsigned int sec = 0; unsigned int min = 0; unsigned int hour = 0; - if (((pos = strstr(format, "%X"))) || - ((pos = strstr(format, "%H:%M:%S")))) { + if (((pos = strstr(format, "%X"))) || ((pos = strstr(format, "%H:%M:%S")))) { if ((size_t)(pos - format) < strlen(text)) - sscanf(text + (pos - format), "%u:%u:%u", &hour, - &min, &sec); - } else if (((pos = strstr(format, "%R"))) || - ((pos = strstr(format, "%H:%M")))) { + sscanf(text + (pos - format), "%u:%u:%u", &hour, &min, &sec); + } else if (((pos = strstr(format, "%R"))) || ((pos = strstr(format, "%H:%M")))) { if ((size_t)(pos - format) < strlen(text)) - sscanf(text + (pos - format), "%u:%u", &hour, - &min); + sscanf(text + (pos - format), "%u:%u", &hour, &min); } else if ((pos = strstr(format, "%M:%S"))) { if ((size_t)(pos - format) < strlen(text)) - sscanf(text + (pos - format), "%u:%u", &min, - &sec); + sscanf(text + (pos - format), "%u:%u", &min, &sec); } else { if ((pos = strstr(format, "%S"))) { sscanf(text + (pos - format), "%u", &sec); @@ -243,13 +206,10 @@ double parse_text(long long format_type, const char *format, const char *text) void move_value_start(struct move_value_info *move_value) { - if (!move_value->filter && move_value->setting_filter_name && - strlen(move_value->setting_filter_name)) { - obs_source_t *parent = - obs_filter_get_parent(move_value->move_filter.source); + if (!move_value->filter && move_value->setting_filter_name && strlen(move_value->setting_filter_name)) { + obs_source_t *parent = obs_filter_get_parent(move_value->move_filter.source); if (parent) { - obs_source_t *filter = obs_source_get_filter_by_name( - parent, move_value->setting_filter_name); + obs_source_t *filter = obs_source_get_filter_by_name(parent, move_value->setting_filter_name); move_value->filter = obs_source_get_weak_source(filter); obs_source_release(filter); } else { @@ -265,8 +225,7 @@ void move_value_start(struct move_value_info *move_value) if (move_value->move_filter.reverse) return; obs_source_t *source = NULL; - if (move_value->setting_filter_name && - strlen(move_value->setting_filter_name)) { + if (move_value->setting_filter_name && strlen(move_value->setting_filter_name)) { source = obs_weak_source_get_source(move_value->filter); obs_source_release(source); } else { @@ -275,151 +234,90 @@ void move_value_start(struct move_value_info *move_value) obs_data_t *ss = obs_source_get_settings(source); if (move_value->settings) { - obs_data_t *settings = - obs_source_get_settings(move_value->move_filter.source); + obs_data_t *settings = obs_source_get_settings(move_value->move_filter.source); move_values_load_properties(move_value, source, settings); obs_data_release(settings); } else if (move_value->value_type == MOVE_VALUE_INT) { if (strcmp(move_value->setting_name, VOLUME_SETTING) == 0) { - move_value->int_from = - (long long)(obs_source_get_volume(source) * - 100.0f); - } else if (strcmp(move_value->setting_name, BALANCE_SETTING) == - 0) { - move_value->int_from = - (long long)(obs_source_get_balance_value( - source) * - 100.0f); + move_value->int_from = (long long)(obs_source_get_volume(source) * 100.0f); + } else if (strcmp(move_value->setting_name, BALANCE_SETTING) == 0) { + move_value->int_from = (long long)(obs_source_get_balance_value(source) * 100.0f); } else { - move_value->int_from = - obs_data_get_int(ss, move_value->setting_name); + move_value->int_from = obs_data_get_int(ss, move_value->setting_name); } if (move_value->move_value_type == MOVE_VALUE_TYPE_RANDOM) { - move_value->int_to = rand_between(move_value->int_min, - move_value->int_max); - } else if (move_value->move_value_type == - MOVE_VALUE_TYPE_SETTING_ADD) { - move_value->int_to = - move_value->int_from + move_value->int_value; + move_value->int_to = rand_between(move_value->int_min, move_value->int_max); + } else if (move_value->move_value_type == MOVE_VALUE_TYPE_SETTING_ADD) { + move_value->int_to = move_value->int_from + move_value->int_value; } else { move_value->int_to = move_value->int_value; } } else if (move_value->value_type == MOVE_VALUE_FLOAT) { if (strcmp(move_value->setting_name, VOLUME_SETTING) == 0) { - move_value->double_from = - (double)obs_source_get_volume(source) * 100.0; - } else if (strcmp(move_value->setting_name, BALANCE_SETTING) == - 0) { - move_value->double_from = - (double)obs_source_get_balance_value(source) * - 100.0; + move_value->double_from = (double)obs_source_get_volume(source) * 100.0; + } else if (strcmp(move_value->setting_name, BALANCE_SETTING) == 0) { + move_value->double_from = (double)obs_source_get_balance_value(source) * 100.0; } else { - move_value->double_from = obs_data_get_double( - ss, move_value->setting_name); + move_value->double_from = obs_data_get_double(ss, move_value->setting_name); } if (move_value->move_value_type == MOVE_VALUE_TYPE_RANDOM) { - move_value->double_to = rand_between_double( - move_value->double_min, move_value->double_max); - } else if (move_value->move_value_type == - MOVE_VALUE_TYPE_SETTING_ADD) { - move_value->double_to = move_value->double_from + - move_value->double_value; + move_value->double_to = rand_between_double(move_value->double_min, move_value->double_max); + } else if (move_value->move_value_type == MOVE_VALUE_TYPE_SETTING_ADD) { + move_value->double_to = move_value->double_from + move_value->double_value; } else { move_value->double_to = move_value->double_value; } - } else if (move_value->value_type == MOVE_VALUE_COLOR || - move_value->value_type == MOVE_VALUE_COLOR_ALPHA) { - vec4_from_rgba(&move_value->color_from, - (uint32_t)obs_data_get_int( - ss, move_value->setting_name)); + } else if (move_value->value_type == MOVE_VALUE_COLOR || move_value->value_type == MOVE_VALUE_COLOR_ALPHA) { + vec4_from_rgba(&move_value->color_from, (uint32_t)obs_data_get_int(ss, move_value->setting_name)); gs_float3_srgb_nonlinear_to_linear(move_value->color_from.ptr); if (move_value->move_value_type == MOVE_VALUE_TYPE_RANDOM) { - move_value->color_to.w = - rand_between_float(move_value->color_min.w, - move_value->color_max.w); - move_value->color_to.x = - rand_between_float(move_value->color_min.x, - move_value->color_max.x); - move_value->color_to.y = - rand_between_float(move_value->color_min.y, - move_value->color_max.y); - move_value->color_to.z = - rand_between_float(move_value->color_min.z, - move_value->color_max.z); - } else if (move_value->move_value_type == - MOVE_VALUE_TYPE_SETTING_ADD) { - move_value->color_to.w = move_value->color_from.w + - move_value->color_value.w; - move_value->color_to.x = move_value->color_from.x + - move_value->color_value.x; - move_value->color_to.y = move_value->color_from.y + - move_value->color_value.y; - move_value->color_to.z = move_value->color_from.z + - move_value->color_value.z; + move_value->color_to.w = rand_between_float(move_value->color_min.w, move_value->color_max.w); + move_value->color_to.x = rand_between_float(move_value->color_min.x, move_value->color_max.x); + move_value->color_to.y = rand_between_float(move_value->color_min.y, move_value->color_max.y); + move_value->color_to.z = rand_between_float(move_value->color_min.z, move_value->color_max.z); + } else if (move_value->move_value_type == MOVE_VALUE_TYPE_SETTING_ADD) { + move_value->color_to.w = move_value->color_from.w + move_value->color_value.w; + move_value->color_to.x = move_value->color_from.x + move_value->color_value.x; + move_value->color_to.y = move_value->color_from.y + move_value->color_value.y; + move_value->color_to.z = move_value->color_from.z + move_value->color_value.z; } else { - vec4_copy(&move_value->color_to, - &move_value->color_value); + vec4_copy(&move_value->color_to, &move_value->color_value); } gs_float3_srgb_nonlinear_to_linear(move_value->color_to.ptr); } else if (move_value->value_type == MOVE_VALUE_TEXT) { - const char *text_from = - obs_data_get_string(ss, move_value->setting_name); - move_value->double_from = parse_text( - move_value->format_type, move_value->format, text_from); + const char *text_from = obs_data_get_string(ss, move_value->setting_name); + move_value->double_from = parse_text(move_value->format_type, move_value->format, text_from); if (move_value->move_value_type == MOVE_VALUE_TYPE_RANDOM) { - move_value->double_to = rand_between_double( - move_value->double_min, move_value->double_max); - } else if (move_value->move_value_type == - MOVE_VALUE_TYPE_SETTING_ADD) { - move_value->double_to = move_value->double_from + - move_value->double_value; - } else if (move_value->move_value_type == - MOVE_VALUE_TYPE_TYPING) { + move_value->double_to = rand_between_double(move_value->double_min, move_value->double_max); + } else if (move_value->move_value_type == MOVE_VALUE_TYPE_SETTING_ADD) { + move_value->double_to = move_value->double_from + move_value->double_value; + } else if (move_value->move_value_type == MOVE_VALUE_TYPE_TYPING) { bfree(move_value->text_from); - move_value->text_from_len = - os_utf8_to_wcs_ptr(text_from, strlen(text_from), - &move_value->text_from); + move_value->text_from_len = os_utf8_to_wcs_ptr(text_from, strlen(text_from), &move_value->text_from); move_value->text_step = 0; move_value->text_same = 0; - while (move_value->text_same < - move_value->text_from_len && - move_value->text_same < - move_value->text_to_len && - move_value->text_from[move_value->text_same] == - move_value - ->text_to[move_value->text_same]) + while (move_value->text_same < move_value->text_from_len && + move_value->text_same < move_value->text_to_len && + move_value->text_from[move_value->text_same] == move_value->text_to[move_value->text_same]) move_value->text_same++; - move_value->text_steps = (move_value->text_from_len - - move_value->text_same) + - (move_value->text_to_len - - move_value->text_same); + move_value->text_steps = (move_value->text_from_len - move_value->text_same) + + (move_value->text_to_len - move_value->text_same); } else { move_value->double_to = move_value->double_value; } } else { if (strcmp(move_value->setting_name, VOLUME_SETTING) == 0) { - move_value->int_from = - (long long)(obs_source_get_volume(source) * - 100.0f); - move_value->double_from = - (double)obs_source_get_volume(source) * 100.0; - } else if (strcmp(move_value->setting_name, BALANCE_SETTING) == - 0) { - move_value->int_from = - (long long)(obs_source_get_balance_value( - source) * - 100.0f); - move_value->double_from = - (double)obs_source_get_balance_value(source) * - 100.0; + move_value->int_from = (long long)(obs_source_get_volume(source) * 100.0f); + move_value->double_from = (double)obs_source_get_volume(source) * 100.0; + } else if (strcmp(move_value->setting_name, BALANCE_SETTING) == 0) { + move_value->int_from = (long long)(obs_source_get_balance_value(source) * 100.0f); + move_value->double_from = (double)obs_source_get_balance_value(source) * 100.0; } else { - move_value->int_from = - obs_data_get_int(ss, move_value->setting_name); - move_value->double_from = obs_data_get_double( - ss, move_value->setting_name); + move_value->int_from = obs_data_get_int(ss, move_value->setting_name); + move_value->double_from = obs_data_get_double(ss, move_value->setting_name); } move_value->int_to = move_value->int_value; @@ -428,8 +326,7 @@ void move_value_start(struct move_value_info *move_value) obs_data_release(ss); } -bool move_value_start_button(obs_properties_t *props, obs_property_t *property, - void *data) +bool move_value_start_button(obs_properties_t *props, obs_property_t *property, void *data) { struct move_value_info *move_value = data; move_value_start(move_value); @@ -443,30 +340,23 @@ void move_value_update(void *data, obs_data_t *settings) struct move_value_info *move_value = data; move_filter_update(&move_value->move_filter, settings); - obs_source_t *parent = - obs_filter_get_parent(move_value->move_filter.source); + obs_source_t *parent = obs_filter_get_parent(move_value->move_filter.source); - const char *setting_filter_name = - obs_data_get_string(settings, S_FILTER); - if (!move_value->setting_filter_name || - strcmp(move_value->setting_filter_name, setting_filter_name) != 0) { + const char *setting_filter_name = obs_data_get_string(settings, S_FILTER); + if (!move_value->setting_filter_name || strcmp(move_value->setting_filter_name, setting_filter_name) != 0) { obs_weak_source_release(move_value->filter); move_value->filter = NULL; if (parent) { bfree(move_value->setting_filter_name); - move_value->setting_filter_name = - bstrdup(setting_filter_name); - obs_source_t *filter = obs_source_get_filter_by_name( - parent, move_value->setting_filter_name); + move_value->setting_filter_name = bstrdup(setting_filter_name); + obs_source_t *filter = obs_source_get_filter_by_name(parent, move_value->setting_filter_name); move_value->filter = obs_source_get_weak_source(filter); obs_source_release(filter); } } - const char *setting_name = - obs_data_get_string(settings, S_SETTING_NAME); - if (!move_value->setting_name || - strcmp(move_value->setting_name, setting_name) != 0) { + const char *setting_name = obs_data_get_string(settings, S_SETTING_NAME); + if (!move_value->setting_name || strcmp(move_value->setting_name, setting_name) != 0) { bfree(move_value->setting_name); move_value->setting_name = bstrdup(setting_name); @@ -474,22 +364,19 @@ void move_value_update(void *data, obs_data_t *settings) if (obs_data_has_user_value(settings, S_SINGLE_SETTING)) { obs_data_set_int(settings, S_MOVE_VALUE_TYPE, - obs_data_get_bool(settings, S_SINGLE_SETTING) - ? MOVE_VALUE_TYPE_SINGLE_SETTING - : MOVE_VALUE_TYPE_SETTINGS); + obs_data_get_bool(settings, S_SINGLE_SETTING) ? MOVE_VALUE_TYPE_SINGLE_SETTING + : MOVE_VALUE_TYPE_SETTINGS); obs_data_unset_user_value(settings, S_SINGLE_SETTING); } - if (obs_data_get_int(settings, S_MOVE_VALUE_TYPE) != - MOVE_VALUE_TYPE_SETTINGS) { + if (obs_data_get_int(settings, S_MOVE_VALUE_TYPE) != MOVE_VALUE_TYPE_SETTINGS) { obs_data_array_release(move_value->settings); move_value->settings = NULL; } else if (parent) { if (!move_value->settings) move_value->settings = obs_data_array_create(); obs_source_t *source = NULL; - if (move_value->setting_filter_name && - strlen(move_value->setting_filter_name)) { + if (move_value->setting_filter_name && strlen(move_value->setting_filter_name)) { source = obs_weak_source_get_source(move_value->filter); obs_source_release(source); } else { @@ -498,19 +385,15 @@ void move_value_update(void *data, obs_data_t *settings) move_values_load_properties(move_value, source, settings); } - move_value->move_value_type = - obs_data_get_int(settings, S_MOVE_VALUE_TYPE); + move_value->move_value_type = obs_data_get_int(settings, S_MOVE_VALUE_TYPE); move_value->value_type = obs_data_get_int(settings, S_VALUE_TYPE); - move_value->format_type = - obs_data_get_int(settings, S_SETTING_FORMAT_TYPE); + move_value->format_type = obs_data_get_int(settings, S_SETTING_FORMAT_TYPE); char *format = (char *)obs_data_get_string(settings, S_SETTING_FORMAT); - if (move_value->format_type == MOVE_VALUE_FORMAT_FLOAT && - strlen(format) == 0) { + if (move_value->format_type == MOVE_VALUE_FORMAT_FLOAT && strlen(format) == 0) { format = "%f"; obs_data_set_string(settings, S_SETTING_FORMAT, format); } - if (move_value->format_type == MOVE_VALUE_FORMAT_TIME && - strlen(format) == 0) { + if (move_value->format_type == MOVE_VALUE_FORMAT_TIME && strlen(format) == 0) { format = "%X"; obs_data_set_string(settings, S_SETTING_FORMAT, format); } @@ -519,44 +402,27 @@ void move_value_update(void *data, obs_data_t *settings) move_value->format = bstrdup(format); } - move_value->decimals = - (int)obs_data_get_int(settings, S_SETTING_DECIMALS); + move_value->decimals = (int)obs_data_get_int(settings, S_SETTING_DECIMALS); move_value->int_value = obs_data_get_int(settings, S_SETTING_INT); move_value->int_min = obs_data_get_int(settings, S_SETTING_INT_MIN); move_value->int_max = obs_data_get_int(settings, S_SETTING_INT_MAX); - move_value->double_value = - obs_data_get_double(settings, S_SETTING_FLOAT); - move_value->double_min = - obs_data_get_double(settings, S_SETTING_FLOAT_MIN); - move_value->double_max = - obs_data_get_double(settings, S_SETTING_FLOAT_MAX); + move_value->double_value = obs_data_get_double(settings, S_SETTING_FLOAT); + move_value->double_min = obs_data_get_double(settings, S_SETTING_FLOAT_MIN); + move_value->double_max = obs_data_get_double(settings, S_SETTING_FLOAT_MAX); if (move_value->value_type == MOVE_VALUE_COLOR) { - vec4_from_rgba(&move_value->color_value, - (uint32_t)obs_data_get_int(settings, - S_SETTING_COLOR)); - vec4_from_rgba(&move_value->color_min, - (uint32_t)obs_data_get_int(settings, - S_SETTING_COLOR_MIN)); - vec4_from_rgba(&move_value->color_max, - (uint32_t)obs_data_get_int(settings, - S_SETTING_COLOR_MAX)); + vec4_from_rgba(&move_value->color_value, (uint32_t)obs_data_get_int(settings, S_SETTING_COLOR)); + vec4_from_rgba(&move_value->color_min, (uint32_t)obs_data_get_int(settings, S_SETTING_COLOR_MIN)); + vec4_from_rgba(&move_value->color_max, (uint32_t)obs_data_get_int(settings, S_SETTING_COLOR_MAX)); } else if (move_value->value_type == MOVE_VALUE_COLOR_ALPHA) { - vec4_from_rgba(&move_value->color_value, - (uint32_t)obs_data_get_int( - settings, S_SETTING_COLOR_ALPHA)); - vec4_from_rgba(&move_value->color_min, - (uint32_t)obs_data_get_int( - settings, S_SETTING_COLOR_ALPHA_MIN)); - vec4_from_rgba(&move_value->color_max, - (uint32_t)obs_data_get_int( - settings, S_SETTING_COLOR_ALPHA_MAX)); + vec4_from_rgba(&move_value->color_value, (uint32_t)obs_data_get_int(settings, S_SETTING_COLOR_ALPHA)); + vec4_from_rgba(&move_value->color_min, (uint32_t)obs_data_get_int(settings, S_SETTING_COLOR_ALPHA_MIN)); + vec4_from_rgba(&move_value->color_max, (uint32_t)obs_data_get_int(settings, S_SETTING_COLOR_ALPHA_MAX)); } const char *text_to = obs_data_get_string(settings, S_SETTING_TEXT); wchar_t *wtext_to = NULL; size_t wlen = os_utf8_to_wcs_ptr(text_to, strlen(text_to), &wtext_to); - if (!move_value->text_to || - wcscmp(move_value->text_to, wtext_to) != 0) { + if (!move_value->text_to || wcscmp(move_value->text_to, wtext_to) != 0) { bfree(move_value->text_to); move_value->text_to = wtext_to; move_value->text_to_len = wlen; @@ -571,10 +437,8 @@ void move_value_update(void *data, obs_data_t *settings) static void *move_value_create(obs_data_t *settings, obs_source_t *source) { - struct move_value_info *move_value = - bzalloc(sizeof(struct move_value_info)); - move_filter_init(&move_value->move_filter, source, - (void (*)(void *))move_value_start); + struct move_value_info *move_value = bzalloc(sizeof(struct move_value_info)); + move_filter_init(&move_value->move_filter, source, (void (*)(void *))move_value_start); move_value_update(move_value, settings); return move_value; } @@ -603,22 +467,18 @@ void prop_list_add_filter(obs_source_t *parent, obs_source_t *child, void *data) obs_property_list_add_string(p, name, name); } -void prop_list_add_move_value_filter(obs_source_t *parent, obs_source_t *child, - void *data) +void prop_list_add_move_value_filter(obs_source_t *parent, obs_source_t *child, void *data) { UNUSED_PARAMETER(parent); - if (strcmp(obs_source_get_unversioned_id(child), - MOVE_VALUE_FILTER_ID) != 0 && - strcmp(obs_source_get_unversioned_id(child), - MOVE_AUDIO_VALUE_FILTER_ID) != 0) + if (strcmp(obs_source_get_unversioned_id(child), MOVE_VALUE_FILTER_ID) != 0 && + strcmp(obs_source_get_unversioned_id(child), MOVE_AUDIO_VALUE_FILTER_ID) != 0) return; obs_property_t *p = data; const char *name = obs_source_get_name(child); obs_property_list_add_string(p, name, name); } -bool move_value_get_value(obs_properties_t *props, obs_property_t *property, - void *data) +bool move_value_get_value(obs_properties_t *props, obs_property_t *property, void *data) { UNUSED_PARAMETER(props); UNUSED_PARAMETER(property); @@ -634,11 +494,9 @@ bool move_value_get_value(obs_properties_t *props, obs_property_t *property, if (source == NULL || source == move_value->move_filter.source) return settings_changed; - obs_data_t *settings = - obs_source_get_settings(move_value->move_filter.source); + obs_data_t *settings = obs_source_get_settings(move_value->move_filter.source); if (strcmp(move_value->setting_name, VOLUME_SETTING) == 0) { - const double value = - (double)obs_source_get_volume(source) * 100.0; + const double value = (double)obs_source_get_volume(source) * 100.0; obs_data_set_double(settings, S_SETTING_FLOAT, value); obs_data_set_double(settings, S_SETTING_FLOAT_MIN, value); obs_data_set_double(settings, S_SETTING_FLOAT_MAX, value); @@ -646,8 +504,7 @@ bool move_value_get_value(obs_properties_t *props, obs_property_t *property, return true; } if (strcmp(move_value->setting_name, BALANCE_SETTING) == 0) { - const double value = - (double)obs_source_get_balance_value(source) * 100.0; + const double value = (double)obs_source_get_balance_value(source) * 100.0; obs_data_set_double(settings, S_SETTING_FLOAT, value); obs_data_set_double(settings, S_SETTING_FLOAT_MIN, value); obs_data_set_double(settings, S_SETTING_FLOAT_MAX, value); @@ -662,47 +519,38 @@ bool move_value_get_value(obs_properties_t *props, obs_property_t *property, const enum obs_property_type prop_type = obs_property_get_type(sp); if (prop_type == OBS_PROPERTY_INT) { - const long long value = - obs_data_get_int(ss, move_value->setting_name); + const long long value = obs_data_get_int(ss, move_value->setting_name); obs_data_set_int(settings, S_SETTING_INT, value); obs_data_set_int(settings, S_SETTING_INT_MIN, value); obs_data_set_int(settings, S_SETTING_INT_MAX, value); settings_changed = true; } else if (prop_type == OBS_PROPERTY_FLOAT) { - const double value = - obs_data_get_double(ss, move_value->setting_name); + const double value = obs_data_get_double(ss, move_value->setting_name); obs_data_set_double(settings, S_SETTING_FLOAT, value); obs_data_set_double(settings, S_SETTING_FLOAT_MIN, value); obs_data_set_double(settings, S_SETTING_FLOAT_MAX, value); settings_changed = true; } else if (prop_type == OBS_PROPERTY_COLOR) { - const long long color = - obs_data_get_int(ss, move_value->setting_name); + const long long color = obs_data_get_int(ss, move_value->setting_name); obs_data_set_int(settings, S_SETTING_COLOR, color); obs_data_set_int(settings, S_SETTING_COLOR_MIN, color); obs_data_set_int(settings, S_SETTING_COLOR_MAX, color); settings_changed = true; } else if (prop_type == OBS_PROPERTY_COLOR_ALPHA) { - const long long color = - obs_data_get_int(ss, move_value->setting_name); + const long long color = obs_data_get_int(ss, move_value->setting_name); obs_data_set_int(settings, S_SETTING_COLOR_ALPHA, color); obs_data_set_int(settings, S_SETTING_COLOR_ALPHA_MIN, color); obs_data_set_int(settings, S_SETTING_COLOR_ALPHA_MAX, color); settings_changed = true; } else if (prop_type == OBS_PROPERTY_TEXT) { - const char *text = - obs_data_get_string(ss, move_value->setting_name); + const char *text = obs_data_get_string(ss, move_value->setting_name); if (move_value->move_value_type == MOVE_VALUE_TYPE_TYPING) { obs_data_set_string(settings, S_SETTING_TEXT, text); } else { - const double value = parse_text(move_value->format_type, - move_value->format, - text); + const double value = parse_text(move_value->format_type, move_value->format, text); obs_data_set_double(settings, S_SETTING_FLOAT, value); - obs_data_set_double(settings, S_SETTING_FLOAT_MIN, - value); - obs_data_set_double(settings, S_SETTING_FLOAT_MAX, - value); + obs_data_set_double(settings, S_SETTING_FLOAT_MIN, value); + obs_data_set_double(settings, S_SETTING_FLOAT_MAX, value); } settings_changed = true; } @@ -711,8 +559,7 @@ bool move_value_get_value(obs_properties_t *props, obs_property_t *property, return settings_changed; } -bool move_value_get_values(obs_properties_t *props, obs_property_t *property, - void *data) +bool move_value_get_values(obs_properties_t *props, obs_property_t *property, void *data) { UNUSED_PARAMETER(props); UNUSED_PARAMETER(property); @@ -727,31 +574,26 @@ bool move_value_get_values(obs_properties_t *props, obs_property_t *property, if (source == NULL || source == move_value->move_filter.source) return false; - obs_data_t *settings = - obs_source_get_settings(move_value->move_filter.source); + obs_data_t *settings = obs_source_get_settings(move_value->move_filter.source); obs_data_t *ss = obs_source_get_settings(source); const size_t count = obs_data_array_count(move_value->settings); for (size_t i = 0; i < count; i++) { obs_data_t *item = obs_data_array_item(move_value->settings, i); const char *name = obs_data_get_string(item, S_SETTING_NAME); - const long long value_type = - obs_data_get_int(item, S_VALUE_TYPE); + const long long value_type = obs_data_get_int(item, S_VALUE_TYPE); if (value_type == MOVE_VALUE_INT) { const long long value = obs_data_get_int(ss, name); obs_data_set_int(settings, name, value); } else if (value_type == MOVE_VALUE_FLOAT) { const double value = obs_data_get_double(ss, name); obs_data_set_double(settings, name, value); - } else if (value_type == MOVE_VALUE_COLOR || - value_type == MOVE_VALUE_COLOR_ALPHA) { + } else if (value_type == MOVE_VALUE_COLOR || value_type == MOVE_VALUE_COLOR_ALPHA) { const long long color = obs_data_get_int(ss, name); obs_data_set_int(settings, name, color); } else if (value_type == MOVE_VALUE_TEXT) { const char *text = obs_data_get_string(ss, name); - const double value = parse_text(move_value->format_type, - move_value->format, - text); + const double value = parse_text(move_value->format_type, move_value->format, text); obs_data_set_double(settings, name, value); } } @@ -766,8 +608,7 @@ bool move_value_get_values(obs_properties_t *props, obs_property_t *property, return count > 0; } -void copy_properties(obs_properties_t *props_from, obs_properties_t *props_to, - obs_data_t *data_from, obs_data_t *data_to, +void copy_properties(obs_properties_t *props_from, obs_properties_t *props_to, obs_data_t *data_from, obs_data_t *data_to, obs_property_t *setting_list) { obs_property_t *prop_from = obs_properties_first(props_from); @@ -777,118 +618,79 @@ void copy_properties(obs_properties_t *props_from, obs_properties_t *props_to, if (!obs_property_visible(prop_from)) continue; obs_property_t *prop_to = NULL; - const enum obs_property_type prop_type = - obs_property_get_type(prop_from); + const enum obs_property_type prop_type = obs_property_get_type(prop_from); if (prop_type == OBS_PROPERTY_GROUP) { obs_properties_t *group_to = obs_properties_create(); - copy_properties(obs_property_group_content(prop_from), - group_to, data_from, data_to, - setting_list); + copy_properties(obs_property_group_content(prop_from), group_to, data_from, data_to, setting_list); if (obs_properties_first(group_to) == NULL) { obs_properties_destroy(group_to); } else { - prop_to = obs_properties_add_group( - props_to, name, description, - obs_property_group_type(prop_from), - group_to); + prop_to = obs_properties_add_group(props_to, name, description, obs_property_group_type(prop_from), + group_to); } } else if (prop_type == OBS_PROPERTY_INT) { - obs_property_list_add_string(setting_list, description, - name); - if (obs_property_int_type(prop_from) == - OBS_NUMBER_SLIDER) { - prop_to = obs_properties_add_int_slider( - props_to, name, description, - obs_property_int_min(prop_from), - obs_property_int_max(prop_from), - obs_property_int_step(prop_from)); + obs_property_list_add_string(setting_list, description, name); + if (obs_property_int_type(prop_from) == OBS_NUMBER_SLIDER) { + prop_to = obs_properties_add_int_slider(props_to, name, description, + obs_property_int_min(prop_from), + obs_property_int_max(prop_from), + obs_property_int_step(prop_from)); } else { - prop_to = obs_properties_add_int( - props_to, name, description, - obs_property_int_min(prop_from), - obs_property_int_max(prop_from), - obs_property_int_step(prop_from)); + prop_to = obs_properties_add_int(props_to, name, description, obs_property_int_min(prop_from), + obs_property_int_max(prop_from), obs_property_int_step(prop_from)); } if (obs_data_has_default_value(data_from, name)) - obs_data_set_default_int( - data_to, name, - obs_data_get_default_int(data_from, - name)); - obs_property_int_set_suffix( - prop_to, obs_property_int_suffix(prop_from)); + obs_data_set_default_int(data_to, name, obs_data_get_default_int(data_from, name)); + obs_property_int_set_suffix(prop_to, obs_property_int_suffix(prop_from)); } else if (prop_type == OBS_PROPERTY_FLOAT) { - obs_property_list_add_string(setting_list, description, - name); - if (obs_property_float_type(prop_from) == - OBS_NUMBER_SLIDER) { - prop_to = obs_properties_add_float_slider( - props_to, name, description, - obs_property_float_min(prop_from), - obs_property_float_max(prop_from), - obs_property_float_step(prop_from)); + obs_property_list_add_string(setting_list, description, name); + if (obs_property_float_type(prop_from) == OBS_NUMBER_SLIDER) { + prop_to = obs_properties_add_float_slider(props_to, name, description, + obs_property_float_min(prop_from), + obs_property_float_max(prop_from), + obs_property_float_step(prop_from)); } else { - prop_to = obs_properties_add_float( - props_to, name, description, - obs_property_float_min(prop_from), - obs_property_float_max(prop_from), - obs_property_float_step(prop_from)); + prop_to = obs_properties_add_float(props_to, name, description, obs_property_float_min(prop_from), + obs_property_float_max(prop_from), + obs_property_float_step(prop_from)); } if (obs_data_has_default_value(data_from, name)) - obs_data_set_default_double( - data_to, name, - obs_data_get_default_double(data_from, - name)); - obs_property_float_set_suffix( - prop_to, obs_property_float_suffix(prop_from)); + obs_data_set_default_double(data_to, name, obs_data_get_default_double(data_from, name)); + obs_property_float_set_suffix(prop_to, obs_property_float_suffix(prop_from)); } else if (prop_type == OBS_PROPERTY_COLOR) { - obs_property_list_add_string(setting_list, description, - name); - prop_to = obs_properties_add_color(props_to, name, - description); + obs_property_list_add_string(setting_list, description, name); + prop_to = obs_properties_add_color(props_to, name, description); if (obs_data_has_default_value(data_from, name)) - obs_data_set_default_int( - data_to, name, - obs_data_get_default_int(data_from, - name)); + obs_data_set_default_int(data_to, name, obs_data_get_default_int(data_from, name)); } else if (prop_type == OBS_PROPERTY_COLOR_ALPHA) { - obs_property_list_add_string(setting_list, description, - name); - prop_to = obs_properties_add_color_alpha(props_to, name, - description); + obs_property_list_add_string(setting_list, description, name); + prop_to = obs_properties_add_color_alpha(props_to, name, description); if (obs_data_has_default_value(data_from, name)) - obs_data_set_default_int( - data_to, name, - obs_data_get_default_int(data_from, - name)); + obs_data_set_default_int(data_to, name, obs_data_get_default_int(data_from, name)); } else if (prop_type == OBS_PROPERTY_TEXT) { if (obs_property_text_type(prop_from) != OBS_TEXT_INFO) - obs_property_list_add_string(setting_list, - description, name); + obs_property_list_add_string(setting_list, description, name); } } } -bool move_value_filter_changed(void *data, obs_properties_t *props, - obs_property_t *property, obs_data_t *settings) +bool move_value_filter_changed(void *data, obs_properties_t *props, obs_property_t *property, obs_data_t *settings) { UNUSED_PARAMETER(property); struct move_value_info *move_value = data; bool refresh = false; - obs_source_t *parent = - obs_filter_get_parent(move_value->move_filter.source); + obs_source_t *parent = obs_filter_get_parent(move_value->move_filter.source); const char *filter_name = obs_data_get_string(settings, S_FILTER); - if (!move_value->setting_filter_name || - strcmp(move_value->setting_filter_name, filter_name) != 0 || + if (!move_value->setting_filter_name || strcmp(move_value->setting_filter_name, filter_name) != 0 || (!move_value->filter && strlen(filter_name))) { bfree(move_value->setting_filter_name); move_value->setting_filter_name = bstrdup(filter_name); obs_weak_source_release(move_value->filter); - obs_source_t *filter = - obs_source_get_filter_by_name(parent, filter_name); + obs_source_t *filter = obs_source_get_filter_by_name(parent, filter_name); move_value->filter = obs_source_get_weak_source(filter); obs_source_release(filter); } @@ -920,12 +722,9 @@ bool move_value_filter_changed(void *data, obs_properties_t *props, if (!s || source == move_value->move_filter.source) return refresh; - if (obs_source_get_type(source) == OBS_SOURCE_TYPE_INPUT && - (obs_source_get_output_flags(source) & OBS_SOURCE_AUDIO)) { - obs_property_list_add_string( - p, obs_module_text("Setting.Volume"), VOLUME_SETTING); - obs_property_list_add_string( - p, obs_module_text("Setting.Balance"), BALANCE_SETTING); + if (obs_source_get_type(source) == OBS_SOURCE_TYPE_INPUT && (obs_source_get_output_flags(source) & OBS_SOURCE_AUDIO)) { + obs_property_list_add_string(p, obs_module_text("Setting.Volume"), VOLUME_SETTING); + obs_property_list_add_string(p, obs_module_text("Setting.Balance"), BALANCE_SETTING); } obs_properties_t *sps = obs_source_properties(source); @@ -936,23 +735,17 @@ bool move_value_filter_changed(void *data, obs_properties_t *props, return refresh; } -bool move_value_format_type_changed(void *data, obs_properties_t *props, - obs_property_t *property, - obs_data_t *settings) +bool move_value_format_type_changed(void *data, obs_properties_t *props, obs_property_t *property, obs_data_t *settings) { UNUSED_PARAMETER(data); UNUSED_PARAMETER(property); - obs_property_t *prop_format = - obs_properties_get(props, S_SETTING_FORMAT); - obs_property_t *prop_decimals = - obs_properties_get(props, S_SETTING_DECIMALS); + obs_property_t *prop_format = obs_properties_get(props, S_SETTING_FORMAT); + obs_property_t *prop_decimals = obs_properties_get(props, S_SETTING_DECIMALS); obs_property_set_visible(prop_format, false); obs_property_set_visible(prop_decimals, false); if (obs_data_get_int(settings, S_VALUE_TYPE) == MOVE_VALUE_TEXT && - obs_data_get_int(settings, S_MOVE_VALUE_TYPE) != - MOVE_VALUE_TYPE_TYPING) { - const long long format_type = - obs_data_get_int(settings, S_SETTING_FORMAT_TYPE); + obs_data_get_int(settings, S_MOVE_VALUE_TYPE) != MOVE_VALUE_TYPE_TYPING) { + const long long format_type = obs_data_get_int(settings, S_SETTING_FORMAT_TYPE); if (format_type == MOVE_VALUE_FORMAT_DECIMALS) { obs_property_set_visible(prop_decimals, true); } else { @@ -962,16 +755,13 @@ bool move_value_format_type_changed(void *data, obs_properties_t *props, return true; } -bool move_value_setting_changed(void *data, obs_properties_t *props, - obs_property_t *property, obs_data_t *settings) +bool move_value_setting_changed(void *data, obs_properties_t *props, obs_property_t *property, obs_data_t *settings) { UNUSED_PARAMETER(property); struct move_value_info *move_value = data; bool refresh = false; - const char *setting_name = - obs_data_get_string(settings, S_SETTING_NAME); - if (!move_value->setting_name || - strcmp(move_value->setting_name, setting_name) != 0) { + const char *setting_name = obs_data_get_string(settings, S_SETTING_NAME); + if (!move_value->setting_name || strcmp(move_value->setting_name, setting_name) != 0) { refresh = true; bfree(move_value->setting_name); @@ -989,29 +779,19 @@ bool move_value_setting_changed(void *data, obs_properties_t *props, return refresh; obs_property_t *prop_int = obs_properties_get(props, S_SETTING_INT); - obs_property_t *prop_int_min = - obs_properties_get(props, S_SETTING_INT_MIN); - obs_property_t *prop_int_max = - obs_properties_get(props, S_SETTING_INT_MAX); + obs_property_t *prop_int_min = obs_properties_get(props, S_SETTING_INT_MIN); + obs_property_t *prop_int_max = obs_properties_get(props, S_SETTING_INT_MAX); obs_property_t *prop_float = obs_properties_get(props, S_SETTING_FLOAT); - obs_property_t *prop_float_min = - obs_properties_get(props, S_SETTING_FLOAT_MIN); - obs_property_t *prop_float_max = - obs_properties_get(props, S_SETTING_FLOAT_MAX); - obs_property_t *prop_format_type = - obs_properties_get(props, S_SETTING_FORMAT_TYPE); + obs_property_t *prop_float_min = obs_properties_get(props, S_SETTING_FLOAT_MIN); + obs_property_t *prop_float_max = obs_properties_get(props, S_SETTING_FLOAT_MAX); + obs_property_t *prop_format_type = obs_properties_get(props, S_SETTING_FORMAT_TYPE); obs_property_t *prop_color = obs_properties_get(props, S_SETTING_COLOR); - obs_property_t *prop_color_min = - obs_properties_get(props, S_SETTING_COLOR_MIN); - obs_property_t *prop_color_max = - obs_properties_get(props, S_SETTING_COLOR_MAX); - obs_property_t *prop_color_alpha = - obs_properties_get(props, S_SETTING_COLOR_ALPHA); - obs_property_t *prop_color_alpha_min = - obs_properties_get(props, S_SETTING_COLOR_ALPHA_MIN); - obs_property_t *prop_color_alpha_max = - obs_properties_get(props, S_SETTING_COLOR_ALPHA_MAX); + obs_property_t *prop_color_min = obs_properties_get(props, S_SETTING_COLOR_MIN); + obs_property_t *prop_color_max = obs_properties_get(props, S_SETTING_COLOR_MAX); + obs_property_t *prop_color_alpha = obs_properties_get(props, S_SETTING_COLOR_ALPHA); + obs_property_t *prop_color_alpha_min = obs_properties_get(props, S_SETTING_COLOR_ALPHA_MIN); + obs_property_t *prop_color_alpha_max = obs_properties_get(props, S_SETTING_COLOR_ALPHA_MAX); obs_property_t *prop_text = obs_properties_get(props, S_SETTING_TEXT); obs_property_set_visible(prop_int, false); obs_property_set_visible(prop_int_min, false); @@ -1027,42 +807,29 @@ bool move_value_setting_changed(void *data, obs_properties_t *props, obs_property_set_visible(prop_color_alpha_min, false); obs_property_set_visible(prop_color_alpha_max, false); obs_property_set_visible(prop_text, false); - const long long move_value_type = - obs_data_get_int(settings, S_MOVE_VALUE_TYPE); + const long long move_value_type = obs_data_get_int(settings, S_MOVE_VALUE_TYPE); if (strcmp(move_value->setting_name, VOLUME_SETTING) == 0) { if (move_value_type == MOVE_VALUE_TYPE_SINGLE_SETTING) { obs_property_set_visible(prop_float, true); - obs_property_float_set_limits(prop_float, VOLUME_MIN, - VOLUME_MAX, VOLUME_STEP); + obs_property_float_set_limits(prop_float, VOLUME_MIN, VOLUME_MAX, VOLUME_STEP); obs_property_float_set_suffix(prop_float, "%"); if (refresh) - obs_data_set_double( - settings, S_SETTING_FLOAT, - obs_source_get_volume(source) * 100.0); + obs_data_set_double(settings, S_SETTING_FLOAT, obs_source_get_volume(source) * 100.0); } else if (move_value_type == MOVE_VALUE_TYPE_SETTING_ADD) { obs_property_set_visible(prop_float, true); - obs_property_float_set_limits(prop_float, -VOLUME_MAX, - VOLUME_MAX, VOLUME_STEP); + obs_property_float_set_limits(prop_float, -VOLUME_MAX, VOLUME_MAX, VOLUME_STEP); obs_property_float_set_suffix(prop_float, "%"); } else if (move_value_type == MOVE_VALUE_TYPE_RANDOM) { obs_property_set_visible(prop_float_min, true); obs_property_set_visible(prop_float_max, true); - obs_property_float_set_limits(prop_float_min, - VOLUME_MIN, VOLUME_MAX, - VOLUME_STEP); - obs_property_float_set_limits(prop_float_max, - VOLUME_MIN, VOLUME_MAX, - VOLUME_STEP); + obs_property_float_set_limits(prop_float_min, VOLUME_MIN, VOLUME_MAX, VOLUME_STEP); + obs_property_float_set_limits(prop_float_max, VOLUME_MIN, VOLUME_MAX, VOLUME_STEP); obs_property_float_set_suffix(prop_float_min, "%"); obs_property_float_set_suffix(prop_float_max, "%"); if (refresh) { - obs_data_set_double( - settings, S_SETTING_FLOAT_MIN, - obs_source_get_volume(source) * 100.0); - obs_data_set_double( - settings, S_SETTING_FLOAT_MAX, - obs_source_get_volume(source) * 100.0); + obs_data_set_double(settings, S_SETTING_FLOAT_MIN, obs_source_get_volume(source) * 100.0); + obs_data_set_double(settings, S_SETTING_FLOAT_MAX, obs_source_get_volume(source) * 100.0); } } obs_data_set_int(settings, S_VALUE_TYPE, MOVE_VALUE_FLOAT); @@ -1071,44 +838,27 @@ bool move_value_setting_changed(void *data, obs_properties_t *props, if (strcmp(move_value->setting_name, BALANCE_SETTING) == 0) { if (move_value_type == MOVE_VALUE_TYPE_SINGLE_SETTING) { obs_property_set_visible(prop_float, true); - obs_property_float_set_limits(prop_float, BALANCE_MIN, - BALANCE_MAX, - BALANCE_STEP); + obs_property_float_set_limits(prop_float, BALANCE_MIN, BALANCE_MAX, BALANCE_STEP); obs_property_float_set_suffix(prop_float, "%"); if (refresh) - obs_data_set_double( - settings, S_SETTING_FLOAT, - (double)obs_source_get_balance_value( - source) * - 100.0); + obs_data_set_double(settings, S_SETTING_FLOAT, + (double)obs_source_get_balance_value(source) * 100.0); } else if (move_value_type == MOVE_VALUE_TYPE_SETTING_ADD) { obs_property_set_visible(prop_float, true); - obs_property_float_set_limits(prop_float, -BALANCE_MAX, - BALANCE_MAX, - BALANCE_STEP); + obs_property_float_set_limits(prop_float, -BALANCE_MAX, BALANCE_MAX, BALANCE_STEP); obs_property_float_set_suffix(prop_float, "%"); } else if (move_value_type == MOVE_VALUE_TYPE_RANDOM) { obs_property_set_visible(prop_float_min, true); obs_property_set_visible(prop_float_max, true); - obs_property_float_set_limits(prop_float_min, - BALANCE_MIN, BALANCE_MAX, - BALANCE_STEP); - obs_property_float_set_limits(prop_float_max, - BALANCE_MIN, BALANCE_MAX, - BALANCE_STEP); + obs_property_float_set_limits(prop_float_min, BALANCE_MIN, BALANCE_MAX, BALANCE_STEP); + obs_property_float_set_limits(prop_float_max, BALANCE_MIN, BALANCE_MAX, BALANCE_STEP); obs_property_float_set_suffix(prop_float_min, "%"); obs_property_float_set_suffix(prop_float_max, "%"); if (refresh) { - obs_data_set_double( - settings, S_SETTING_FLOAT_MIN, - (double)obs_source_get_balance_value( - source) * - 100.0); - obs_data_set_double( - settings, S_SETTING_FLOAT_MAX, - (double)obs_source_get_balance_value( - source) * - 100.0); + obs_data_set_double(settings, S_SETTING_FLOAT_MIN, + (double)obs_source_get_balance_value(source) * 100.0); + obs_data_set_double(settings, S_SETTING_FLOAT_MAX, + (double)obs_source_get_balance_value(source) * 100.0); } } obs_data_set_int(settings, S_VALUE_TYPE, MOVE_VALUE_FLOAT); @@ -1121,182 +871,109 @@ bool move_value_setting_changed(void *data, obs_properties_t *props, if (prop_type == OBS_PROPERTY_INT) { if (move_value_type == MOVE_VALUE_TYPE_SINGLE_SETTING) { obs_property_set_visible(prop_int, true); - obs_property_int_set_limits(prop_int, - obs_property_int_min(sp), - obs_property_int_max(sp), + obs_property_int_set_limits(prop_int, obs_property_int_min(sp), obs_property_int_max(sp), obs_property_int_step(sp)); - obs_property_int_set_suffix( - prop_int, obs_property_int_suffix(sp)); + obs_property_int_set_suffix(prop_int, obs_property_int_suffix(sp)); if (refresh) - obs_data_set_int( - settings, S_SETTING_INT, - obs_data_get_int(ss, setting_name)); + obs_data_set_int(settings, S_SETTING_INT, obs_data_get_int(ss, setting_name)); } else if (move_value_type == MOVE_VALUE_TYPE_SETTING_ADD) { obs_property_set_visible(prop_int, true); - obs_property_int_set_limits(prop_int, -1000, 1000, - obs_property_int_step(sp)); - obs_property_int_set_suffix( - prop_int, obs_property_int_suffix(sp)); + obs_property_int_set_limits(prop_int, -1000, 1000, obs_property_int_step(sp)); + obs_property_int_set_suffix(prop_int, obs_property_int_suffix(sp)); } else if (move_value_type == MOVE_VALUE_TYPE_RANDOM) { obs_property_set_visible(prop_int_min, true); obs_property_set_visible(prop_int_max, true); - obs_property_int_set_limits(prop_int_min, - obs_property_int_min(sp), - obs_property_int_max(sp), + obs_property_int_set_limits(prop_int_min, obs_property_int_min(sp), obs_property_int_max(sp), obs_property_int_step(sp)); - obs_property_int_set_limits(prop_int_max, - obs_property_int_min(sp), - obs_property_int_max(sp), + obs_property_int_set_limits(prop_int_max, obs_property_int_min(sp), obs_property_int_max(sp), obs_property_int_step(sp)); - obs_property_int_set_suffix( - prop_int_min, obs_property_int_suffix(sp)); - obs_property_int_set_suffix( - prop_int_max, obs_property_int_suffix(sp)); + obs_property_int_set_suffix(prop_int_min, obs_property_int_suffix(sp)); + obs_property_int_set_suffix(prop_int_max, obs_property_int_suffix(sp)); if (refresh) { - obs_data_set_int( - settings, S_SETTING_INT_MIN, - obs_data_get_int(ss, setting_name)); - obs_data_set_int( - settings, S_SETTING_INT_MAX, - obs_data_get_int(ss, setting_name)); + obs_data_set_int(settings, S_SETTING_INT_MIN, obs_data_get_int(ss, setting_name)); + obs_data_set_int(settings, S_SETTING_INT_MAX, obs_data_get_int(ss, setting_name)); } } obs_data_set_int(settings, S_VALUE_TYPE, MOVE_VALUE_INT); } else if (prop_type == OBS_PROPERTY_FLOAT) { if (move_value_type == MOVE_VALUE_TYPE_SINGLE_SETTING) { obs_property_set_visible(prop_float, true); - obs_property_float_set_limits( - prop_float, obs_property_float_min(sp), - obs_property_float_max(sp), - obs_property_float_step(sp)); - obs_property_float_set_suffix( - prop_float, obs_property_float_suffix(sp)); + obs_property_float_set_limits(prop_float, obs_property_float_min(sp), obs_property_float_max(sp), + obs_property_float_step(sp)); + obs_property_float_set_suffix(prop_float, obs_property_float_suffix(sp)); if (refresh) - obs_data_set_double( - settings, S_SETTING_FLOAT, - obs_data_get_double(ss, setting_name)); + obs_data_set_double(settings, S_SETTING_FLOAT, obs_data_get_double(ss, setting_name)); } else if (move_value_type == MOVE_VALUE_TYPE_SETTING_ADD) { obs_property_set_visible(prop_float, true); - obs_property_float_set_limits( - prop_float, -1000.0, 1000.0, - obs_property_float_step(sp)); - obs_property_float_set_suffix( - prop_float, obs_property_float_suffix(sp)); + obs_property_float_set_limits(prop_float, -1000.0, 1000.0, obs_property_float_step(sp)); + obs_property_float_set_suffix(prop_float, obs_property_float_suffix(sp)); } else if (move_value_type == MOVE_VALUE_TYPE_RANDOM) { obs_property_set_visible(prop_float_min, true); obs_property_set_visible(prop_float_max, true); - obs_property_float_set_limits( - prop_float_min, obs_property_float_min(sp), - obs_property_float_max(sp), - obs_property_float_step(sp)); - obs_property_float_set_limits( - prop_float_max, obs_property_float_min(sp), - obs_property_float_max(sp), - obs_property_float_step(sp)); - obs_property_float_set_suffix( - prop_float_min, obs_property_float_suffix(sp)); - obs_property_float_set_suffix( - prop_float_max, obs_property_float_suffix(sp)); + obs_property_float_set_limits(prop_float_min, obs_property_float_min(sp), obs_property_float_max(sp), + obs_property_float_step(sp)); + obs_property_float_set_limits(prop_float_max, obs_property_float_min(sp), obs_property_float_max(sp), + obs_property_float_step(sp)); + obs_property_float_set_suffix(prop_float_min, obs_property_float_suffix(sp)); + obs_property_float_set_suffix(prop_float_max, obs_property_float_suffix(sp)); if (refresh) { - obs_data_set_double( - settings, S_SETTING_FLOAT_MIN, - obs_data_get_double(ss, setting_name)); - obs_data_set_double( - settings, S_SETTING_FLOAT_MAX, - obs_data_get_double(ss, setting_name)); + obs_data_set_double(settings, S_SETTING_FLOAT_MIN, obs_data_get_double(ss, setting_name)); + obs_data_set_double(settings, S_SETTING_FLOAT_MAX, obs_data_get_double(ss, setting_name)); } } obs_data_set_int(settings, S_VALUE_TYPE, MOVE_VALUE_FLOAT); - } else if (prop_type == OBS_PROPERTY_COLOR || - prop_type == OBS_PROPERTY_COLOR_ALPHA) { - - const char *color_name = prop_type == OBS_PROPERTY_COLOR - ? S_SETTING_COLOR - : S_SETTING_COLOR_ALPHA; - const char *color_min_name = - prop_type == OBS_PROPERTY_COLOR - ? S_SETTING_COLOR_MIN - : S_SETTING_COLOR_ALPHA_MIN; - const char *color_max_name = - prop_type == OBS_PROPERTY_COLOR - ? S_SETTING_COLOR_MAX - : S_SETTING_COLOR_ALPHA_MAX; + } else if (prop_type == OBS_PROPERTY_COLOR || prop_type == OBS_PROPERTY_COLOR_ALPHA) { + + const char *color_name = prop_type == OBS_PROPERTY_COLOR ? S_SETTING_COLOR : S_SETTING_COLOR_ALPHA; + const char *color_min_name = prop_type == OBS_PROPERTY_COLOR ? S_SETTING_COLOR_MIN : S_SETTING_COLOR_ALPHA_MIN; + const char *color_max_name = prop_type == OBS_PROPERTY_COLOR ? S_SETTING_COLOR_MAX : S_SETTING_COLOR_ALPHA_MAX; if (move_value_type == MOVE_VALUE_TYPE_SINGLE_SETTING) { - obs_property_set_visible(prop_type == OBS_PROPERTY_COLOR - ? prop_color - : prop_color_alpha, - true); + obs_property_set_visible(prop_type == OBS_PROPERTY_COLOR ? prop_color : prop_color_alpha, true); if (refresh) - obs_data_set_int( - settings, color_name, - obs_data_get_int(ss, setting_name)); + obs_data_set_int(settings, color_name, obs_data_get_int(ss, setting_name)); } else if (move_value_type == MOVE_VALUE_TYPE_SETTING_ADD) { - obs_property_set_visible(prop_type == OBS_PROPERTY_COLOR - ? prop_color - : prop_color_alpha, - true); + obs_property_set_visible(prop_type == OBS_PROPERTY_COLOR ? prop_color : prop_color_alpha, true); } else if (move_value_type == MOVE_VALUE_TYPE_RANDOM) { - obs_property_set_visible(prop_type == OBS_PROPERTY_COLOR - ? prop_color_min - : prop_color_alpha_min, - true); - obs_property_set_visible(prop_type == OBS_PROPERTY_COLOR - ? prop_color_max - : prop_color_alpha_max, - true); + obs_property_set_visible(prop_type == OBS_PROPERTY_COLOR ? prop_color_min : prop_color_alpha_min, true); + obs_property_set_visible(prop_type == OBS_PROPERTY_COLOR ? prop_color_max : prop_color_alpha_max, true); if (refresh) { - obs_data_set_int( - settings, color_min_name, - obs_data_get_int(ss, setting_name)); - obs_data_set_int( - settings, color_max_name, - obs_data_get_int(ss, setting_name)); + obs_data_set_int(settings, color_min_name, obs_data_get_int(ss, setting_name)); + obs_data_set_int(settings, color_max_name, obs_data_get_int(ss, setting_name)); } } obs_data_set_int(settings, S_VALUE_TYPE, - prop_type == OBS_PROPERTY_COLOR - ? MOVE_VALUE_COLOR - : MOVE_VALUE_COLOR_ALPHA); + prop_type == OBS_PROPERTY_COLOR ? MOVE_VALUE_COLOR : MOVE_VALUE_COLOR_ALPHA); } else if (prop_type == OBS_PROPERTY_TEXT) { if (move_value_type == MOVE_VALUE_TYPE_SINGLE_SETTING) { obs_property_set_visible(prop_format_type, true); obs_property_set_visible(prop_float, true); - obs_property_float_set_limits(prop_float, -DBL_MAX, - DBL_MAX, 1.0); + obs_property_float_set_limits(prop_float, -DBL_MAX, DBL_MAX, 1.0); obs_property_float_set_suffix(prop_float, NULL); if (refresh) { - const char *text_val = - obs_data_get_string(ss, setting_name); + const char *text_val = obs_data_get_string(ss, setting_name); const double val = strtod(text_val, NULL); - obs_data_set_double(settings, S_SETTING_FLOAT, - val); + obs_data_set_double(settings, S_SETTING_FLOAT, val); } } else if (move_value_type == MOVE_VALUE_TYPE_SETTING_ADD) { obs_property_set_visible(prop_format_type, true); obs_property_set_visible(prop_float, true); - obs_property_float_set_limits(prop_float, -DBL_MAX, - DBL_MAX, 1.0); + obs_property_float_set_limits(prop_float, -DBL_MAX, DBL_MAX, 1.0); obs_property_float_set_suffix(prop_float, NULL); } else if (move_value_type == MOVE_VALUE_TYPE_RANDOM) { obs_property_set_visible(prop_format_type, true); obs_property_set_visible(prop_float_min, true); obs_property_set_visible(prop_float_max, true); - obs_property_float_set_limits(prop_float_min, -DBL_MAX, - DBL_MAX, 1.0); - obs_property_float_set_limits(prop_float_max, -DBL_MAX, - DBL_MAX, 1.0); + obs_property_float_set_limits(prop_float_min, -DBL_MAX, DBL_MAX, 1.0); + obs_property_float_set_limits(prop_float_max, -DBL_MAX, DBL_MAX, 1.0); obs_property_float_set_suffix(prop_float_min, NULL); obs_property_float_set_suffix(prop_float_max, NULL); if (refresh) { - const char *text_val = - obs_data_get_string(ss, setting_name); + const char *text_val = obs_data_get_string(ss, setting_name); const double val = strtod(text_val, NULL); - obs_data_set_double(settings, - S_SETTING_FLOAT_MIN, val); - obs_data_set_double(settings, - S_SETTING_FLOAT_MAX, val); + obs_data_set_double(settings, S_SETTING_FLOAT_MIN, val); + obs_data_set_double(settings, S_SETTING_FLOAT_MAX, val); } } else if (move_value_type == MOVE_VALUE_TYPE_TYPING) { obs_property_set_visible(prop_text, true); @@ -1311,44 +988,33 @@ bool move_value_setting_changed(void *data, obs_properties_t *props, return true; } -bool move_value_type_changed(void *data, obs_properties_t *props, - obs_property_t *property, obs_data_t *settings) +bool move_value_type_changed(void *data, obs_properties_t *props, obs_property_t *property, obs_data_t *settings) { bool refresh = false; - const long long move_value_type = - obs_data_get_int(settings, S_MOVE_VALUE_TYPE); + const long long move_value_type = obs_data_get_int(settings, S_MOVE_VALUE_TYPE); obs_property_t *p = obs_properties_get(props, S_SETTING_VALUE); - if (obs_property_visible(p) != - (move_value_type != MOVE_VALUE_TYPE_SETTINGS)) { - obs_property_set_visible(p, move_value_type != - MOVE_VALUE_TYPE_SETTINGS); + if (obs_property_visible(p) != (move_value_type != MOVE_VALUE_TYPE_SETTINGS)) { + obs_property_set_visible(p, move_value_type != MOVE_VALUE_TYPE_SETTINGS); refresh = true; } p = obs_properties_get(props, S_SETTINGS); - if (obs_property_visible(p) != - (move_value_type == MOVE_VALUE_TYPE_SETTINGS)) { - obs_property_set_visible(p, move_value_type == - MOVE_VALUE_TYPE_SETTINGS); + if (obs_property_visible(p) != (move_value_type == MOVE_VALUE_TYPE_SETTINGS)) { + obs_property_set_visible(p, move_value_type == MOVE_VALUE_TYPE_SETTINGS); refresh = true; } - return move_value_setting_changed(data, props, property, settings) || - refresh; + return move_value_setting_changed(data, props, property, settings) || refresh; } -bool move_value_decimals_changed(void *data, obs_properties_t *props, - obs_property_t *property, obs_data_t *settings) +bool move_value_decimals_changed(void *data, obs_properties_t *props, obs_property_t *property, obs_data_t *settings) { UNUSED_PARAMETER(data); UNUSED_PARAMETER(property); - const int decimals = - (int)obs_data_get_int(settings, S_SETTING_DECIMALS); + const int decimals = (int)obs_data_get_int(settings, S_SETTING_DECIMALS); const double step = pow(10.0, -1.0 * (double)decimals); obs_property_t *prop_float = obs_properties_get(props, S_SETTING_FLOAT); - obs_property_t *prop_float_min = - obs_properties_get(props, S_SETTING_FLOAT_MIN); - obs_property_t *prop_float_max = - obs_properties_get(props, S_SETTING_FLOAT_MAX); + obs_property_t *prop_float_min = obs_properties_get(props, S_SETTING_FLOAT_MIN); + obs_property_t *prop_float_max = obs_properties_get(props, S_SETTING_FLOAT_MAX); obs_property_float_set_limits(prop_float, -DBL_MAX, DBL_MAX, step); obs_property_float_set_limits(prop_float_min, -DBL_MAX, DBL_MAX, step); @@ -1361,128 +1027,82 @@ static obs_properties_t *move_value_properties(void *data) { obs_properties_t *ppts = obs_properties_create(); struct move_value_info *move_value = data; - obs_source_t *parent = - obs_filter_get_parent(move_value->move_filter.source); - obs_property_t *p = obs_properties_add_list(ppts, S_FILTER, - obs_module_text("Filter"), - OBS_COMBO_TYPE_LIST, - OBS_COMBO_FORMAT_STRING); + obs_source_t *parent = obs_filter_get_parent(move_value->move_filter.source); + obs_property_t *p = + obs_properties_add_list(ppts, S_FILTER, obs_module_text("Filter"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING); obs_property_list_add_string(p, obs_module_text("Filter.None"), ""); obs_source_enum_filters(parent, prop_list_add_filter, p); obs_property_set_modified_callback2(p, move_value_filter_changed, data); - p = obs_properties_add_list(ppts, S_MOVE_VALUE_TYPE, - obs_module_text("MoveValueType"), - OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); - obs_property_list_add_int( - p, obs_module_text("MoveValueType.SingleSetting"), - MOVE_VALUE_TYPE_SINGLE_SETTING); - obs_property_list_add_int(p, obs_module_text("MoveValueType.Settings"), - MOVE_VALUE_TYPE_SETTINGS); - obs_property_list_add_int(p, obs_module_text("MoveValueType.Random"), - MOVE_VALUE_TYPE_RANDOM); - obs_property_list_add_int(p, - obs_module_text("MoveValueType.SettingAdd"), - MOVE_VALUE_TYPE_SETTING_ADD); - obs_property_list_add_int(p, obs_module_text("MoveValueType.Type"), - MOVE_VALUE_TYPE_TYPING); + p = obs_properties_add_list(ppts, S_MOVE_VALUE_TYPE, obs_module_text("MoveValueType"), OBS_COMBO_TYPE_LIST, + OBS_COMBO_FORMAT_INT); + obs_property_list_add_int(p, obs_module_text("MoveValueType.SingleSetting"), MOVE_VALUE_TYPE_SINGLE_SETTING); + obs_property_list_add_int(p, obs_module_text("MoveValueType.Settings"), MOVE_VALUE_TYPE_SETTINGS); + obs_property_list_add_int(p, obs_module_text("MoveValueType.Random"), MOVE_VALUE_TYPE_RANDOM); + obs_property_list_add_int(p, obs_module_text("MoveValueType.SettingAdd"), MOVE_VALUE_TYPE_SETTING_ADD); + obs_property_list_add_int(p, obs_module_text("MoveValueType.Type"), MOVE_VALUE_TYPE_TYPING); obs_property_set_modified_callback2(p, move_value_type_changed, data); obs_properties_t *setting_value = obs_properties_create(); - p = obs_properties_add_list(setting_value, S_SETTING_NAME, - obs_module_text("Setting"), - OBS_COMBO_TYPE_LIST, + p = obs_properties_add_list(setting_value, S_SETTING_NAME, obs_module_text("Setting"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING); obs_property_list_add_string(p, obs_module_text("Setting.None"), ""); - obs_property_set_modified_callback2(p, move_value_setting_changed, - data); - - p = obs_properties_add_list(setting_value, S_SETTING_FORMAT_TYPE, - obs_module_text("FormatType"), - OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); - obs_property_list_add_int(p, obs_module_text("FormatType.Decimals"), - MOVE_VALUE_FORMAT_DECIMALS); - obs_property_list_add_int(p, obs_module_text("FormatType.Float"), - MOVE_VALUE_FORMAT_FLOAT); - obs_property_list_add_int(p, obs_module_text("FormatType.Time"), - MOVE_VALUE_FORMAT_TIME); + obs_property_set_modified_callback2(p, move_value_setting_changed, data); + + p = obs_properties_add_list(setting_value, S_SETTING_FORMAT_TYPE, obs_module_text("FormatType"), OBS_COMBO_TYPE_LIST, + OBS_COMBO_FORMAT_INT); + obs_property_list_add_int(p, obs_module_text("FormatType.Decimals"), MOVE_VALUE_FORMAT_DECIMALS); + obs_property_list_add_int(p, obs_module_text("FormatType.Float"), MOVE_VALUE_FORMAT_FLOAT); + obs_property_list_add_int(p, obs_module_text("FormatType.Time"), MOVE_VALUE_FORMAT_TIME); obs_property_set_visible(p, false); - obs_property_set_modified_callback2(p, move_value_format_type_changed, - data); + obs_property_set_modified_callback2(p, move_value_format_type_changed, data); - p = obs_properties_add_text(setting_value, S_SETTING_FORMAT, - obs_module_text("Format"), - OBS_TEXT_DEFAULT); + p = obs_properties_add_text(setting_value, S_SETTING_FORMAT, obs_module_text("Format"), OBS_TEXT_DEFAULT); obs_property_set_visible(p, false); - p = obs_properties_add_int(setting_value, S_SETTING_DECIMALS, - obs_module_text("Decimals"), -10, 10, 1); + p = obs_properties_add_int(setting_value, S_SETTING_DECIMALS, obs_module_text("Decimals"), -10, 10, 1); obs_property_set_visible(p, false); - obs_property_set_modified_callback2(p, move_value_decimals_changed, - data); + obs_property_set_modified_callback2(p, move_value_decimals_changed, data); - p = obs_properties_add_int(setting_value, S_SETTING_INT, - obs_module_text("Value"), 0, 0, 0); + p = obs_properties_add_int(setting_value, S_SETTING_INT, obs_module_text("Value"), 0, 0, 0); obs_property_set_visible(p, false); - p = obs_properties_add_int(setting_value, S_SETTING_INT_MIN, - obs_module_text("MinValue"), 0, 0, 0); + p = obs_properties_add_int(setting_value, S_SETTING_INT_MIN, obs_module_text("MinValue"), 0, 0, 0); obs_property_set_visible(p, false); - p = obs_properties_add_int(setting_value, S_SETTING_INT_MAX, - obs_module_text("MaxValue"), 0, 0, 0); + p = obs_properties_add_int(setting_value, S_SETTING_INT_MAX, obs_module_text("MaxValue"), 0, 0, 0); obs_property_set_visible(p, false); - p = obs_properties_add_float(setting_value, S_SETTING_FLOAT, - obs_module_text("Value"), 0, 0, 0); + p = obs_properties_add_float(setting_value, S_SETTING_FLOAT, obs_module_text("Value"), 0, 0, 0); obs_property_set_visible(p, false); - p = obs_properties_add_float(setting_value, S_SETTING_FLOAT_MIN, - obs_module_text("MinValue"), 0, 0, 0); + p = obs_properties_add_float(setting_value, S_SETTING_FLOAT_MIN, obs_module_text("MinValue"), 0, 0, 0); obs_property_set_visible(p, false); - p = obs_properties_add_float(setting_value, S_SETTING_FLOAT_MAX, - obs_module_text("MaxValue"), 0, 0, 0); + p = obs_properties_add_float(setting_value, S_SETTING_FLOAT_MAX, obs_module_text("MaxValue"), 0, 0, 0); obs_property_set_visible(p, false); - p = obs_properties_add_color(setting_value, S_SETTING_COLOR, - obs_module_text("Value")); + p = obs_properties_add_color(setting_value, S_SETTING_COLOR, obs_module_text("Value")); obs_property_set_visible(p, false); - p = obs_properties_add_color(setting_value, S_SETTING_COLOR_MIN, - obs_module_text("MinValue")); + p = obs_properties_add_color(setting_value, S_SETTING_COLOR_MIN, obs_module_text("MinValue")); obs_property_set_visible(p, false); - p = obs_properties_add_color(setting_value, S_SETTING_COLOR_MAX, - obs_module_text("MaxValue")); + p = obs_properties_add_color(setting_value, S_SETTING_COLOR_MAX, obs_module_text("MaxValue")); obs_property_set_visible(p, false); - p = obs_properties_add_color_alpha(setting_value, S_SETTING_COLOR_ALPHA, - obs_module_text("Value")); + p = obs_properties_add_color_alpha(setting_value, S_SETTING_COLOR_ALPHA, obs_module_text("Value")); obs_property_set_visible(p, false); - p = obs_properties_add_color_alpha(setting_value, - S_SETTING_COLOR_ALPHA_MIN, - obs_module_text("MinValue")); + p = obs_properties_add_color_alpha(setting_value, S_SETTING_COLOR_ALPHA_MIN, obs_module_text("MinValue")); obs_property_set_visible(p, false); - p = obs_properties_add_color_alpha(setting_value, - S_SETTING_COLOR_ALPHA_MIN, - obs_module_text("MaxValue")); + p = obs_properties_add_color_alpha(setting_value, S_SETTING_COLOR_ALPHA_MIN, obs_module_text("MaxValue")); obs_property_set_visible(p, false); - p = obs_properties_add_text(setting_value, S_SETTING_TEXT, - obs_module_text("Text"), - OBS_TEXT_MULTILINE); + p = obs_properties_add_text(setting_value, S_SETTING_TEXT, obs_module_text("Text"), OBS_TEXT_MULTILINE); obs_property_set_visible(p, false); - obs_properties_add_button(setting_value, "value_get", - obs_module_text("GetValue"), - move_value_get_value); + obs_properties_add_button(setting_value, "value_get", obs_module_text("GetValue"), move_value_get_value); - obs_properties_add_group(ppts, S_SETTING_VALUE, - obs_module_text("Setting"), OBS_GROUP_NORMAL, - setting_value); + obs_properties_add_group(ppts, S_SETTING_VALUE, obs_module_text("Setting"), OBS_GROUP_NORMAL, setting_value); obs_properties_t *settings = obs_properties_create(); - obs_properties_add_button(settings, "values_get", - obs_module_text("GetValues"), - move_value_get_values); - obs_properties_add_group(ppts, S_SETTINGS, obs_module_text("Settings"), - OBS_GROUP_NORMAL, settings); + obs_properties_add_button(settings, "values_get", obs_module_text("GetValues"), move_value_get_values); + obs_properties_add_group(ppts, S_SETTINGS, obs_module_text("Settings"), OBS_GROUP_NORMAL, settings); move_filter_properties(&move_value->move_filter, ppts); @@ -1495,8 +1115,7 @@ void move_value_defaults(obs_data_t *settings) obs_data_set_default_bool(settings, S_SINGLE_SETTING, true); obs_data_set_default_bool(settings, S_CUSTOM_DURATION, true); obs_data_set_default_int(settings, S_EASING_MATCH, EASE_IN_OUT); - obs_data_set_default_int(settings, S_EASING_FUNCTION_MATCH, - EASING_CUBIC); + obs_data_set_default_int(settings, S_EASING_FUNCTION_MATCH, EASING_CUBIC); } void move_value_video_render(void *data, gs_effect_t *effect) @@ -1513,8 +1132,7 @@ static const char *move_value_get_name(void *type_data) } float get_eased(float f, long long easing, long long easing_function); -void vec2_bezier(struct vec2 *dst, struct vec2 *begin, struct vec2 *control, - struct vec2 *end, const float t); +void vec2_bezier(struct vec2 *dst, struct vec2 *begin, struct vec2 *control, struct vec2 *end, const float t); void move_value_stop(struct move_value_info *move_value) { @@ -1542,138 +1160,84 @@ void move_value_tick(void *data, float seconds) if (move_value->settings) { const size_t count = obs_data_array_count(move_value->settings); for (size_t i = 0; i < count; i++) { - obs_data_t *item = - obs_data_array_item(move_value->settings, i); - const char *setting_name = - obs_data_get_string(item, S_SETTING_NAME); - const long long value_type = - obs_data_get_int(item, S_VALUE_TYPE); + obs_data_t *item = obs_data_array_item(move_value->settings, i); + const char *setting_name = obs_data_get_string(item, S_SETTING_NAME); + const long long value_type = obs_data_get_int(item, S_VALUE_TYPE); if (value_type == MOVE_VALUE_INT) { - const long long int_from = - obs_data_get_int(item, S_SETTING_FROM); - const long long int_to = - obs_data_get_int(item, S_SETTING_TO); - const long long value_int = - (long long)((1.0 - t) * - (double)int_from + - t * (double)int_to); + const long long int_from = obs_data_get_int(item, S_SETTING_FROM); + const long long int_to = obs_data_get_int(item, S_SETTING_TO); + const long long value_int = (long long)((1.0 - t) * (double)int_from + t * (double)int_to); obs_data_set_int(ss, setting_name, value_int); } else if (value_type == MOVE_VALUE_FLOAT) { - const double double_from = obs_data_get_double( - item, S_SETTING_FROM); - const double double_to = - obs_data_get_double(item, S_SETTING_TO); - const double value_double = - ((1.0 - t) * double_from + - t * double_to); - obs_data_set_double(ss, setting_name, - value_double); - } else if (value_type == MOVE_VALUE_COLOR || - value_type == MOVE_VALUE_COLOR_ALPHA) { + const double double_from = obs_data_get_double(item, S_SETTING_FROM); + const double double_to = obs_data_get_double(item, S_SETTING_TO); + const double value_double = ((1.0 - t) * double_from + t * double_to); + obs_data_set_double(ss, setting_name, value_double); + } else if (value_type == MOVE_VALUE_COLOR || value_type == MOVE_VALUE_COLOR_ALPHA) { struct vec4 color_from; - vec4_from_rgba(&color_from, - (uint32_t)obs_data_get_int( - item, S_SETTING_FROM)); - gs_float3_srgb_nonlinear_to_linear( - color_from.ptr); + vec4_from_rgba(&color_from, (uint32_t)obs_data_get_int(item, S_SETTING_FROM)); + gs_float3_srgb_nonlinear_to_linear(color_from.ptr); struct vec4 color_to; - vec4_from_rgba(&color_to, - (uint32_t)obs_data_get_int( - item, S_SETTING_TO)); - gs_float3_srgb_nonlinear_to_linear( - color_to.ptr); + vec4_from_rgba(&color_to, (uint32_t)obs_data_get_int(item, S_SETTING_TO)); + gs_float3_srgb_nonlinear_to_linear(color_to.ptr); struct vec4 color; - color.w = (1.0f - t) * color_from.w + - t * color_to.w; - color.x = (1.0f - t) * color_from.x + - t * color_to.x; - color.y = (1.0f - t) * color_from.y + - t * color_to.y; - color.z = (1.0f - t) * color_from.z + - t * color_to.z; + color.w = (1.0f - t) * color_from.w + t * color_to.w; + color.x = (1.0f - t) * color_from.x + t * color_to.x; + color.y = (1.0f - t) * color_from.y + t * color_to.y; + color.z = (1.0f - t) * color_from.z + t * color_to.z; gs_float3_srgb_linear_to_nonlinear(color.ptr); - const long long value_int = - vec4_to_rgba(&color); + const long long value_int = vec4_to_rgba(&color); obs_data_set_int(ss, setting_name, value_int); } } } else if (move_value->value_type == MOVE_VALUE_INT) { - const long long value_int = - (long long)((1.0 - t) * (double)move_value->int_from + - t * (double)move_value->int_to); + const long long value_int = (long long)((1.0 - t) * (double)move_value->int_from + t * (double)move_value->int_to); if (strcmp(move_value->setting_name, VOLUME_SETTING) == 0) { - obs_source_set_volume(source, - (float)value_int / 100.0f); + obs_source_set_volume(source, (float)value_int / 100.0f); update = false; - } else if (strcmp(move_value->setting_name, BALANCE_SETTING) == - 0) { - obs_source_set_balance_value(source, - (float)value_int / 100.0f); + } else if (strcmp(move_value->setting_name, BALANCE_SETTING) == 0) { + obs_source_set_balance_value(source, (float)value_int / 100.0f); update = false; } else { - obs_data_set_int(ss, move_value->setting_name, - value_int); + obs_data_set_int(ss, move_value->setting_name, value_int); } } else if (move_value->value_type == MOVE_VALUE_FLOAT) { - const double value_double = - (1.0 - t) * move_value->double_from + - t * move_value->double_to; + const double value_double = (1.0 - t) * move_value->double_from + t * move_value->double_to; if (strcmp(move_value->setting_name, VOLUME_SETTING) == 0) { - obs_source_set_volume(source, - (float)(value_double / 100.0)); + obs_source_set_volume(source, (float)(value_double / 100.0)); update = false; - } else if (strcmp(move_value->setting_name, BALANCE_SETTING) == - 0) { - obs_source_set_balance_value( - source, (float)(value_double / 100.0)); + } else if (strcmp(move_value->setting_name, BALANCE_SETTING) == 0) { + obs_source_set_balance_value(source, (float)(value_double / 100.0)); update = false; } else { - obs_data_set_double(ss, move_value->setting_name, - value_double); + obs_data_set_double(ss, move_value->setting_name, value_double); } - } else if (move_value->value_type == MOVE_VALUE_COLOR || - move_value->value_type == MOVE_VALUE_COLOR_ALPHA) { + } else if (move_value->value_type == MOVE_VALUE_COLOR || move_value->value_type == MOVE_VALUE_COLOR_ALPHA) { struct vec4 color; - color.w = (1.0f - t) * move_value->color_from.w + - t * move_value->color_to.w; - color.x = (1.0f - t) * move_value->color_from.x + - t * move_value->color_to.x; - color.y = (1.0f - t) * move_value->color_from.y + - t * move_value->color_to.y; - color.z = (1.0f - t) * move_value->color_from.z + - t * move_value->color_to.z; + color.w = (1.0f - t) * move_value->color_from.w + t * move_value->color_to.w; + color.x = (1.0f - t) * move_value->color_from.x + t * move_value->color_to.x; + color.y = (1.0f - t) * move_value->color_from.y + t * move_value->color_to.y; + color.z = (1.0f - t) * move_value->color_from.z + t * move_value->color_to.z; gs_float3_srgb_linear_to_nonlinear(color.ptr); const long long value_int = vec4_to_rgba(&color); obs_data_set_int(ss, move_value->setting_name, value_int); - } else if (move_value->value_type == MOVE_VALUE_TEXT && - move_value->move_value_type == MOVE_VALUE_TYPE_TYPING) { - if (t * move_value->text_steps <= move_value->text_step && - move_value->move_filter.moving) { + } else if (move_value->value_type == MOVE_VALUE_TEXT && move_value->move_value_type == MOVE_VALUE_TYPE_TYPING) { + if (t * move_value->text_steps <= move_value->text_step && move_value->move_filter.moving) { obs_data_release(ss); return; } - move_value->text_step = - (size_t)(t * (float)move_value->text_steps); + move_value->text_step = (size_t)(t * (float)move_value->text_steps); char *text = NULL; - if (move_value->text_step < - move_value->text_from_len - move_value->text_same) { - os_wcs_to_utf8_ptr(move_value->text_from, - move_value->text_from_len - - move_value->text_step, - &text); + if (move_value->text_step < move_value->text_from_len - move_value->text_same) { + os_wcs_to_utf8_ptr(move_value->text_from, move_value->text_from_len - move_value->text_step, &text); } else { - size_t len = move_value->text_same + - move_value->text_step - - (move_value->text_from_len - - move_value->text_same); + size_t len = + move_value->text_same + move_value->text_step - (move_value->text_from_len - move_value->text_same); if (len) { - os_wcs_to_utf8_ptr( - move_value->text_to, - move_value->text_same + - move_value->text_step - - (move_value->text_from_len - - move_value->text_same), - &text); + os_wcs_to_utf8_ptr(move_value->text_to, + move_value->text_same + move_value->text_step - + (move_value->text_from_len - move_value->text_same), + &text); } else { text = bstrdup(""); } @@ -1681,80 +1245,54 @@ void move_value_tick(void *data, float seconds) obs_data_set_string(ss, move_value->setting_name, text); bfree(text); } else if (move_value->value_type == MOVE_VALUE_TEXT) { - double value_double = (1.0 - t) * move_value->double_from + - t * move_value->double_to; + double value_double = (1.0 - t) * move_value->double_from + t * move_value->double_to; char text[TEXT_BUFFER_SIZE]; if (move_value->format_type == MOVE_VALUE_FORMAT_FLOAT) { - if (snprintf(text, TEXT_BUFFER_SIZE, move_value->format, - value_double) == 0) + if (snprintf(text, TEXT_BUFFER_SIZE, move_value->format, value_double) == 0) text[0] = '\0'; } else if (move_value->format_type == MOVE_VALUE_FORMAT_TIME) { long long t = (long long)value_double; struct tm *tm_info = gmtime((const time_t *)&t); - if (strftime(text, TEXT_BUFFER_SIZE, move_value->format, - tm_info) == 0) + if (strftime(text, TEXT_BUFFER_SIZE, move_value->format, tm_info) == 0) text[0] = '\0'; } else { if (move_value->decimals >= 0) { char format[20]; - snprintf(format, 20, "%%.%df", - move_value->decimals); - snprintf(text, TEXT_BUFFER_SIZE, format, - value_double); + snprintf(format, 20, "%%.%df", move_value->decimals); + snprintf(text, TEXT_BUFFER_SIZE, format, value_double); } else { - double factor = pow( - 10, - -1.0 * (double)move_value->decimals); - value_double = - floor(value_double / factor) * factor; - snprintf(text, TEXT_BUFFER_SIZE, "%.0f", - value_double); + double factor = pow(10, -1.0 * (double)move_value->decimals); + value_double = floor(value_double / factor) * factor; + snprintf(text, TEXT_BUFFER_SIZE, "%.0f", value_double); } } obs_data_set_string(ss, move_value->setting_name, text); } else { - obs_data_item_t *item = - obs_data_item_byname(ss, move_value->setting_name); - const enum obs_data_number_type item_type = - obs_data_item_numtype(item); + obs_data_item_t *item = obs_data_item_byname(ss, move_value->setting_name); + const enum obs_data_number_type item_type = obs_data_item_numtype(item); if (item_type == OBS_DATA_NUM_INT) { const long long value_int = - (long long)((1.0 - - t) * (double)move_value->int_from + - t * (double)move_value->int_to); - if (strcmp(move_value->setting_name, VOLUME_SETTING) == - 0) { - obs_source_set_volume(source, (float)value_int / - 100.0f); + (long long)((1.0 - t) * (double)move_value->int_from + t * (double)move_value->int_to); + if (strcmp(move_value->setting_name, VOLUME_SETTING) == 0) { + obs_source_set_volume(source, (float)value_int / 100.0f); update = false; - } else if (strcmp(move_value->setting_name, - BALANCE_SETTING) == 0) { - obs_source_set_balance_value( - source, (float)value_int / 100.0f); + } else if (strcmp(move_value->setting_name, BALANCE_SETTING) == 0) { + obs_source_set_balance_value(source, (float)value_int / 100.0f); update = false; } else { - obs_data_set_int(ss, move_value->setting_name, - value_int); + obs_data_set_int(ss, move_value->setting_name, value_int); } } else if (item_type == OBS_DATA_NUM_DOUBLE) { - const double value_double = - (1.0 - t) * move_value->double_from + - t * move_value->double_to; - if (strcmp(move_value->setting_name, VOLUME_SETTING) == - 0) { - obs_source_set_volume( - source, (float)value_double / 100.0f); + const double value_double = (1.0 - t) * move_value->double_from + t * move_value->double_to; + if (strcmp(move_value->setting_name, VOLUME_SETTING) == 0) { + obs_source_set_volume(source, (float)value_double / 100.0f); update = false; - } else if (strcmp(move_value->setting_name, - BALANCE_SETTING) == 0) { - obs_source_set_balance_value( - source, (float)value_double / 100.0f); + } else if (strcmp(move_value->setting_name, BALANCE_SETTING) == 0) { + obs_source_set_balance_value(source, (float)value_double / 100.0f); update = false; } else { - obs_data_set_double(ss, - move_value->setting_name, - value_double); + obs_data_set_double(ss, move_value->setting_name, value_double); } } obs_data_item_release(&item); diff --git a/nvidia-move-filter.c b/nvidia-move-filter.c index a09b28b..293149b 100644 --- a/nvidia-move-filter.c +++ b/nvidia-move-filter.c @@ -220,89 +220,66 @@ static const char *nv_move_name(void *unused) return obs_module_text("NvidiaMoveFilter"); } -static bool nv_move_log_error(struct nvidia_move_info *filter, - NvCV_Status nvErr, const char *function) +static bool nv_move_log_error(struct nvidia_move_info *filter, NvCV_Status nvErr, const char *function) { if (nvErr == NVCV_SUCCESS) return false; const char *errString = NvCV_GetErrorStringFromCode(nvErr); if (filter->last_error && strcmp(errString, filter->last_error) == 0) return true; - blog(LOG_ERROR, "[Move Transition] Error in %s; error %i: %s", function, - nvErr, errString); + blog(LOG_ERROR, "[Move Transition] Error in %s; error %i: %s", function, nvErr, errString); bfree(filter->last_error); filter->last_error = bstrdup(errString); return true; } -static void nv_move_feature_handle(struct nvidia_move_info *filter, - NvAR_FeatureHandle handle) +static void nv_move_feature_handle(struct nvidia_move_info *filter, NvAR_FeatureHandle handle) { - if (nv_move_log_error( - filter, - NvAR_SetString(handle, NvAR_Parameter_Config(ModelDir), ""), - "Set ModelDir")) + if (nv_move_log_error(filter, NvAR_SetString(handle, NvAR_Parameter_Config(ModelDir), ""), "Set ModelDir")) return; - if (nv_move_log_error(filter, - NvAR_SetCudaStream( - handle, NvAR_Parameter_Config(CUDAStream), - filter->stream), + if (nv_move_log_error(filter, NvAR_SetCudaStream(handle, NvAR_Parameter_Config(CUDAStream), filter->stream), "Set CUDAStream")) return; if (filter->BGR_src_img) { - if (nv_move_log_error( - filter, - NvAR_SetObject(handle, NvAR_Parameter_Input(Image), - filter->BGR_src_img, - sizeof(NvCVImage)), - "Set Image")) + if (nv_move_log_error(filter, + NvAR_SetObject(handle, NvAR_Parameter_Input(Image), filter->BGR_src_img, sizeof(NvCVImage)), + "Set Image")) return; } if (!filter->bboxes.max_boxes) { - filter->bboxes.boxes = (struct NvAR_Rect *)bzalloc( - sizeof(struct NvAR_Rect) * BBOXES_COUNT); + filter->bboxes.boxes = (struct NvAR_Rect *)bzalloc(sizeof(struct NvAR_Rect) * BBOXES_COUNT); filter->bboxes.max_boxes = BBOXES_COUNT; filter->bboxes.num_boxes = 0; } - NvAR_SetObject(handle, NvAR_Parameter_Output(BoundingBoxes), - &filter->bboxes, sizeof(NvAR_BBoxes)); + NvAR_SetObject(handle, NvAR_Parameter_Output(BoundingBoxes), &filter->bboxes, sizeof(NvAR_BBoxes)); } -static void nv_move_landmarks(struct nvidia_move_info *filter, - NvAR_FeatureHandle handle) +static void nv_move_landmarks(struct nvidia_move_info *filter, NvAR_FeatureHandle handle) { unsigned int OUTPUT_SIZE_KPTS = 0; - NvCV_Status nvErr = NvAR_GetU32(handle, - NvAR_Parameter_Config(Landmarks_Size), - &OUTPUT_SIZE_KPTS); + NvCV_Status nvErr = NvAR_GetU32(handle, NvAR_Parameter_Config(Landmarks_Size), &OUTPUT_SIZE_KPTS); if (nvErr != NVCV_SUCCESS) return; da_resize(filter->landmarks, OUTPUT_SIZE_KPTS); - nvErr = NvAR_SetObject(handle, NvAR_Parameter_Output(Landmarks), - filter->landmarks.array, sizeof(NvAR_Point2f)); + nvErr = NvAR_SetObject(handle, NvAR_Parameter_Output(Landmarks), filter->landmarks.array, sizeof(NvAR_Point2f)); unsigned int OUTPUT_SIZE_KPTS_CONF = 0; - nvErr = NvAR_GetU32(handle, - NvAR_Parameter_Config(LandmarksConfidence_Size), - &OUTPUT_SIZE_KPTS_CONF); + nvErr = NvAR_GetU32(handle, NvAR_Parameter_Config(LandmarksConfidence_Size), &OUTPUT_SIZE_KPTS_CONF); if (nvErr == NVCV_SUCCESS) da_resize(filter->landmarks_confidence, OUTPUT_SIZE_KPTS_CONF); else da_resize(filter->landmarks_confidence, OUTPUT_SIZE_KPTS); - nvErr = NvAR_SetF32Array(handle, - NvAR_Parameter_Output(LandmarksConfidence), - filter->landmarks_confidence.array, + nvErr = NvAR_SetF32Array(handle, NvAR_Parameter_Output(LandmarksConfidence), filter->landmarks_confidence.array, (int)filter->landmarks_confidence.num); } -static bool get_expression_value(struct nvidia_move_info *filter, - int32_t expression, float *value) +static bool get_expression_value(struct nvidia_move_info *filter, int32_t expression, float *value) { if (expression >= 0) { *value = filter->expressions.array[expression]; @@ -310,15 +287,11 @@ static bool get_expression_value(struct nvidia_move_info *filter, return false; } else if (expression > -14) { int p = expression * -2 - 4; - *value = (filter->expressions.array[p] + - filter->expressions.array[p + 1]) / - 2.0f; + *value = (filter->expressions.array[p] + filter->expressions.array[p + 1]) / 2.0f; } else if (expression == -14) { // jawSideways - *value = filter->expressions.array[25] - - filter->expressions.array[27]; + *value = filter->expressions.array[25] - filter->expressions.array[27]; } else if (expression == -15) { // mouthSideways - *value = filter->expressions.array[34] - - filter->expressions.array[40]; + *value = filter->expressions.array[34] - filter->expressions.array[40]; } else if (expression == -18) { // eyeLookLeft *value = filter->expressions.array[16] + // eyeLookOut_L filter->expressions.array[15]; // eyeLookIn_R @@ -327,9 +300,7 @@ static bool get_expression_value(struct nvidia_move_info *filter, filter->expressions.array[14]; // eyeLookIn_L } else if (expression > -28) { int p = expression * -2 - 3; - *value = (filter->expressions.array[p] + - filter->expressions.array[p + 1]) / - 2.0f; + *value = (filter->expressions.array[p] + filter->expressions.array[p + 1]) / 2.0f; } else if (expression == -28) { // eyeLookSideways *value = (filter->expressions.array[16] + // eyeLookOut_L filter->expressions.array[15]) - // eyeLookIn_R @@ -358,128 +329,72 @@ static bool get_expression_value(struct nvidia_move_info *filter, return true; } -static bool nv_move_action_get_float(struct nvidia_move_info *filter, - struct nvidia_move_action *action, - bool easing, float *v) +static bool nv_move_action_get_float(struct nvidia_move_info *filter, struct nvidia_move_action *action, bool easing, float *v) { float value = 0.0f; bool success = false; - if (action->feature == FEATURE_BOUNDINGBOX && - filter->bboxes.max_boxes && filter->bboxes.num_boxes) { - if (filter->bboxes_confidence.array && - filter->bboxes_confidence.array[0] < - action->required_confidence) { - } else if (action->feature_property == - FEATURE_BOUNDINGBOX_LEFT) { + if (action->feature == FEATURE_BOUNDINGBOX && filter->bboxes.max_boxes && filter->bboxes.num_boxes) { + if (filter->bboxes_confidence.array && filter->bboxes_confidence.array[0] < action->required_confidence) { + } else if (action->feature_property == FEATURE_BOUNDINGBOX_LEFT) { value = filter->bboxes.boxes[0].x; success = true; - } else if (action->feature_property == - FEATURE_BOUNDINGBOX_HORIZONTAL_CENTER) { - value = filter->bboxes.boxes[0].x + - filter->bboxes.boxes[0].width / 2.0f; + } else if (action->feature_property == FEATURE_BOUNDINGBOX_HORIZONTAL_CENTER) { + value = filter->bboxes.boxes[0].x + filter->bboxes.boxes[0].width / 2.0f; success = true; - } else if (action->feature_property == - FEATURE_BOUNDINGBOX_RIGHT) { - value = filter->bboxes.boxes[0].x + - filter->bboxes.boxes[0].width; + } else if (action->feature_property == FEATURE_BOUNDINGBOX_RIGHT) { + value = filter->bboxes.boxes[0].x + filter->bboxes.boxes[0].width; success = true; - } else if (action->feature_property == - FEATURE_BOUNDINGBOX_WIDTH) { + } else if (action->feature_property == FEATURE_BOUNDINGBOX_WIDTH) { value = filter->bboxes.boxes[0].width; success = true; - } else if (action->feature_property == - FEATURE_BOUNDINGBOX_TOP) { + } else if (action->feature_property == FEATURE_BOUNDINGBOX_TOP) { value = filter->bboxes.boxes[0].y; success = true; - } else if (action->feature_property == - FEATURE_BOUNDINGBOX_VERTICAL_CENTER) { - value = filter->bboxes.boxes[0].y + - filter->bboxes.boxes[0].height / 2.0f; + } else if (action->feature_property == FEATURE_BOUNDINGBOX_VERTICAL_CENTER) { + value = filter->bboxes.boxes[0].y + filter->bboxes.boxes[0].height / 2.0f; success = true; - } else if (action->feature_property == - FEATURE_BOUNDINGBOX_BOTOM) { - value = filter->bboxes.boxes[0].y + - filter->bboxes.boxes[0].height; + } else if (action->feature_property == FEATURE_BOUNDINGBOX_BOTOM) { + value = filter->bboxes.boxes[0].y + filter->bboxes.boxes[0].height; success = true; - } else if (action->feature_property == - FEATURE_BOUNDINGBOX_HEIGHT) { + } else if (action->feature_property == FEATURE_BOUNDINGBOX_HEIGHT) { value = filter->bboxes.boxes[0].height; success = true; } else { success = false; } - } else if (action->feature == FEATURE_LANDMARK && - filter->landmarks.num) { - if (action->feature_number[0] >= - (int32_t)filter->landmarks.num) { - } else if (filter->landmarks_confidence - .array[action->feature_number[0]] < - action->required_confidence) { + } else if (action->feature == FEATURE_LANDMARK && filter->landmarks.num) { + if (action->feature_number[0] >= (int32_t)filter->landmarks.num) { + } else if (filter->landmarks_confidence.array[action->feature_number[0]] < action->required_confidence) { } else if (action->feature_property == FEATURE_LANDMARK_X) { - value = filter->landmarks - .array[action->feature_number[0]] - .x; + value = filter->landmarks.array[action->feature_number[0]].x; success = true; } else if (action->feature_property == FEATURE_LANDMARK_Y) { - value = filter->landmarks - .array[action->feature_number[0]] - .y; + value = filter->landmarks.array[action->feature_number[0]].y; success = true; - } else if (action->feature_property == - FEATURE_LANDMARK_CONFIDENCE) { - value = filter->landmarks_confidence - .array[action->feature_number[0]]; + } else if (action->feature_property == FEATURE_LANDMARK_CONFIDENCE) { + value = filter->landmarks_confidence.array[action->feature_number[0]]; success = true; - } else if (action->feature_number[1] >= - (int32_t)filter->landmarks.num) { - } else if (action->feature_property == - FEATURE_LANDMARK_DISTANCE) { - float x = filter->landmarks - .array[action->feature_number[0]] - .x - - filter->landmarks - .array[action->feature_number[1]] - .x; - float y = filter->landmarks - .array[action->feature_number[0]] - .y - - filter->landmarks - .array[action->feature_number[1]] - .y; + } else if (action->feature_number[1] >= (int32_t)filter->landmarks.num) { + } else if (action->feature_property == FEATURE_LANDMARK_DISTANCE) { + float x = filter->landmarks.array[action->feature_number[0]].x - + filter->landmarks.array[action->feature_number[1]].x; + float y = filter->landmarks.array[action->feature_number[0]].y - + filter->landmarks.array[action->feature_number[1]].y; value = sqrtf(x * x + y * y); success = true; - } else if (action->feature_property == - FEATURE_LANDMARK_DIFF_X) { - value = filter->landmarks - .array[action->feature_number[1]] - .x - - filter->landmarks - .array[action->feature_number[0]] - .x; + } else if (action->feature_property == FEATURE_LANDMARK_DIFF_X) { + value = filter->landmarks.array[action->feature_number[1]].x - + filter->landmarks.array[action->feature_number[0]].x; success = true; - } else if (action->feature_property == - FEATURE_LANDMARK_DIFF_Y) { - value = filter->landmarks - .array[action->feature_number[1]] - .y - - filter->landmarks - .array[action->feature_number[0]] - .y; + } else if (action->feature_property == FEATURE_LANDMARK_DIFF_Y) { + value = filter->landmarks.array[action->feature_number[1]].y - + filter->landmarks.array[action->feature_number[0]].y; success = true; } else if (action->feature_property == FEATURE_LANDMARK_ROT) { - value = DEG(atan2f( - (filter->landmarks - .array[action->feature_number[1]] - .y - - filter->landmarks - .array[action->feature_number[0]] - .y), - (filter->landmarks - .array[action->feature_number[1]] - .x - - filter->landmarks - .array[action->feature_number[0]] - .x))); + value = DEG(atan2f((filter->landmarks.array[action->feature_number[1]].y - + filter->landmarks.array[action->feature_number[0]].y), + (filter->landmarks.array[action->feature_number[1]].x - + filter->landmarks.array[action->feature_number[0]].x))); success = true; } } else if (action->feature == FEATURE_POSE) { @@ -496,37 +411,26 @@ static bool nv_move_action_get_float(struct nvidia_move_info *filter, value = filter->pose.w; success = true; } - } else if (action->feature == FEATURE_EXPRESSION && - filter->expressions.num) { + } else if (action->feature == FEATURE_EXPRESSION && filter->expressions.num) { if (action->feature_property == FEATURE_EXPRESSION_SINGLE) { - success = get_expression_value( - filter, action->feature_number[0], &value); + success = get_expression_value(filter, action->feature_number[0], &value); if (success) value *= action->factor; - } else if (action->feature_property != - FEATURE_EXPRESSION_VECTOR) { + } else if (action->feature_property != FEATURE_EXPRESSION_VECTOR) { float a = 0.0f; float b = 0.0f; - success = - get_expression_value(filter, - action->feature_number[0], - &a) && - get_expression_value( - filter, action->feature_number[1], &b); + success = get_expression_value(filter, action->feature_number[0], &a) && + get_expression_value(filter, action->feature_number[1], &b); if (success) { a *= action->factor; b *= action->factor2; - if (action->feature_property == - FEATURE_EXPRESSION_ADD) { + if (action->feature_property == FEATURE_EXPRESSION_ADD) { value = a + b; - } else if (action->feature_property == - FEATURE_EXPRESSION_SUBSTRACT) { + } else if (action->feature_property == FEATURE_EXPRESSION_SUBSTRACT) { value = a - b; - } else if (action->feature_property == - FEATURE_EXPRESSION_DISTANCE) { + } else if (action->feature_property == FEATURE_EXPRESSION_DISTANCE) { value = fabsf(a - b); - } else if (action->feature_property == - FEATURE_EXPRESSION_AVG) { + } else if (action->feature_property == FEATURE_EXPRESSION_AVG) { value = (a + b) / 2.0f; } } @@ -535,81 +439,57 @@ static bool nv_move_action_get_float(struct nvidia_move_info *filter, if (action->feature_property == FEATURE_GAZE_VECTOR_PITCH) { value = DEG(filter->gaze_angles_vector[0]); success = true; - } else if (action->feature_property == - FEATURE_GAZE_VECTOR_YAW) { + } else if (action->feature_property == FEATURE_GAZE_VECTOR_YAW) { value = DEG(filter->gaze_angles_vector[1]); success = true; - } else if (action->feature_property == - FEATURE_GAZE_HEADTRANSLATION_X) { + } else if (action->feature_property == FEATURE_GAZE_HEADTRANSLATION_X) { value = filter->head_translation[0]; success = true; - } else if (action->feature_property == - FEATURE_GAZE_HEADTRANSLATION_Y) { + } else if (action->feature_property == FEATURE_GAZE_HEADTRANSLATION_Y) { value = filter->head_translation[1]; success = true; - } else if (action->feature_property == - FEATURE_GAZE_HEADTRANSLATION_Z) { + } else if (action->feature_property == FEATURE_GAZE_HEADTRANSLATION_Z) { value = filter->head_translation[2]; success = true; - } else if (action->feature_property == - FEATURE_GAZE_DIRECTION_CENTER_POINT_X) { + } else if (action->feature_property == FEATURE_GAZE_DIRECTION_CENTER_POINT_X) { value = filter->gaze_direction[0].x; success = true; - } else if (action->feature_property == - FEATURE_GAZE_DIRECTION_CENTER_POINT_Y) { + } else if (action->feature_property == FEATURE_GAZE_DIRECTION_CENTER_POINT_Y) { value = filter->gaze_direction[0].y; success = true; - } else if (action->feature_property == - FEATURE_GAZE_DIRECTION_CENTER_POINT_Z) { + } else if (action->feature_property == FEATURE_GAZE_DIRECTION_CENTER_POINT_Z) { value = filter->gaze_direction[0].z; success = true; - } else if (action->feature_property == - FEATURE_GAZE_DIRECTION_VECTOR_X) { + } else if (action->feature_property == FEATURE_GAZE_DIRECTION_VECTOR_X) { value = filter->gaze_direction[1].x; success = true; - } else if (action->feature_property == - FEATURE_GAZE_DIRECTION_VECTOR_Y) { + } else if (action->feature_property == FEATURE_GAZE_DIRECTION_VECTOR_Y) { value = filter->gaze_direction[1].y; success = true; - } else if (action->feature_property == - FEATURE_GAZE_DIRECTION_VECTOR_Z) { + } else if (action->feature_property == FEATURE_GAZE_DIRECTION_VECTOR_Z) { value = filter->gaze_direction[1].z; success = true; } } else if (action->feature == FEATURE_BODY && filter->keypoints.num) { - if (action->feature_number[0] >= - (int32_t)filter->keypoints.num) { - } else if (filter->keypoints_confidence - .array[action->feature_number[0]] < - action->required_confidence) { + if (action->feature_number[0] >= (int32_t)filter->keypoints.num) { + } else if (filter->keypoints_confidence.array[action->feature_number[0]] < action->required_confidence) { } else if (action->feature_property == BODY_CONFIDENCE) { - value = filter->keypoints_confidence - .array[action->feature_number[0]]; + value = filter->keypoints_confidence.array[action->feature_number[0]]; success = true; } else if (action->feature_property == BODY_2D_POSX) { - value = filter->keypoints - .array[action->feature_number[0]] - .x; + value = filter->keypoints.array[action->feature_number[0]].x; success = true; } else if (action->feature_property == BODY_2D_POSY) { - value = filter->keypoints - .array[action->feature_number[0]] - .y; + value = filter->keypoints.array[action->feature_number[0]].y; success = true; } else if (action->feature_property == BODY_3D_POSX) { - value = filter->keypoints3D - .array[action->feature_number[0]] - .x; + value = filter->keypoints3D.array[action->feature_number[0]].x; success = true; } else if (action->feature_property == BODY_3D_POSY) { - value = filter->keypoints3D - .array[action->feature_number[0]] - .y; + value = filter->keypoints3D.array[action->feature_number[0]].y; success = true; } else if (action->feature_property == BODY_3D_POSZ) { - value = filter->keypoints3D - .array[action->feature_number[0]] - .z; + value = filter->keypoints3D.array[action->feature_number[0]].z; success = true; } else if (action->feature_property == BODY_ANGLE_X) { filter->joint_angles.array[action->feature_number[0]].x; @@ -620,99 +500,49 @@ static bool nv_move_action_get_float(struct nvidia_move_info *filter, } else if (action->feature_property == BODY_ANGLE_Z) { filter->joint_angles.array[action->feature_number[0]].z; success = true; - } else if (action->feature_number[1] >= - (int32_t)filter->keypoints.num) { + } else if (action->feature_number[1] >= (int32_t)filter->keypoints.num) { } else if (action->feature_property == BODY_2D_DISTANCE) { - float x = filter->keypoints - .array[action->feature_number[0]] - .x - - filter->keypoints - .array[action->feature_number[1]] - .x; - float y = filter->keypoints - .array[action->feature_number[0]] - .y - - filter->keypoints - .array[action->feature_number[1]] - .y; + float x = filter->keypoints.array[action->feature_number[0]].x - + filter->keypoints.array[action->feature_number[1]].x; + float y = filter->keypoints.array[action->feature_number[0]].y - + filter->keypoints.array[action->feature_number[1]].y; value = sqrtf(x * x + y * y); success = true; } else if (action->feature_property == BODY_2D_ROT) { - value = DEG(atan2f( - (filter->keypoints - .array[action->feature_number[1]] - .y - - filter->keypoints - .array[action->feature_number[0]] - .y), - (filter->keypoints - .array[action->feature_number[1]] - .x - - filter->keypoints - .array[action->feature_number[0]] - .x))); + value = DEG(atan2f((filter->keypoints.array[action->feature_number[1]].y - + filter->keypoints.array[action->feature_number[0]].y), + (filter->keypoints.array[action->feature_number[1]].x - + filter->keypoints.array[action->feature_number[0]].x))); success = true; } else if (action->feature_property == BODY_2D_DIFF_X) { - value = filter->keypoints - .array[action->feature_number[1]] - .x - - filter->keypoints - .array[action->feature_number[0]] - .x; + value = filter->keypoints.array[action->feature_number[1]].x - + filter->keypoints.array[action->feature_number[0]].x; success = true; } else if (action->feature_property == BODY_2D_DIFF_Y) { - value = filter->keypoints - .array[action->feature_number[1]] - .y - - filter->keypoints - .array[action->feature_number[0]] - .y; + value = filter->keypoints.array[action->feature_number[1]].y - + filter->keypoints.array[action->feature_number[0]].y; success = true; } else if (action->feature_property == BODY_3D_DISTANCE) { - float x = filter->keypoints3D - .array[action->feature_number[0]] - .x - - filter->keypoints3D - .array[action->feature_number[1]] - .x; - float y = filter->keypoints3D - .array[action->feature_number[0]] - .y - - filter->keypoints3D - .array[action->feature_number[1]] - .y; - float z = filter->keypoints3D - .array[action->feature_number[0]] - .z - - filter->keypoints3D - .array[action->feature_number[1]] - .z; + float x = filter->keypoints3D.array[action->feature_number[0]].x - + filter->keypoints3D.array[action->feature_number[1]].x; + float y = filter->keypoints3D.array[action->feature_number[0]].y - + filter->keypoints3D.array[action->feature_number[1]].y; + float z = filter->keypoints3D.array[action->feature_number[0]].z - + filter->keypoints3D.array[action->feature_number[1]].z; value = sqrtf(x * x + y * y); value = sqrtf(value * value + z * z); success = true; } else if (action->feature_property == BODY_3D_DIFF_X) { - value = filter->keypoints3D - .array[action->feature_number[1]] - .x - - filter->keypoints3D - .array[action->feature_number[0]] - .x; + value = filter->keypoints3D.array[action->feature_number[1]].x - + filter->keypoints3D.array[action->feature_number[0]].x; success = true; } else if (action->feature_property == BODY_3D_DIFF_Y) { - value = filter->keypoints3D - .array[action->feature_number[1]] - .y - - filter->keypoints3D - .array[action->feature_number[0]] - .y; + value = filter->keypoints3D.array[action->feature_number[1]].y - + filter->keypoints3D.array[action->feature_number[0]].y; success = true; } else if (action->feature_property == BODY_3D_DIFF_Z) { - value = filter->keypoints3D - .array[action->feature_number[1]] - .z - - filter->keypoints3D - .array[action->feature_number[0]] - .z; + value = filter->keypoints3D.array[action->feature_number[1]].z - + filter->keypoints3D.array[action->feature_number[0]].z; success = true; } } @@ -720,119 +550,75 @@ static bool nv_move_action_get_float(struct nvidia_move_info *filter, value *= action->factor; value += action->diff; if (success && easing) { - value = action->previous_float * action->easing + - value * (1.0f - action->easing); + value = action->previous_float * action->easing + value * (1.0f - action->easing); action->previous_float = value; } *v = value; return success; } -static bool nv_move_action_get_vec2(struct nvidia_move_info *filter, - struct nvidia_move_action *action, - bool easing, struct vec2 *value) +static bool nv_move_action_get_vec2(struct nvidia_move_info *filter, struct nvidia_move_action *action, bool easing, + struct vec2 *value) { bool success = false; value->x = 0.0f; value->y = 0.0f; - if (action->feature == FEATURE_BOUNDINGBOX && - filter->bboxes.max_boxes && filter->bboxes.num_boxes) { - if (filter->bboxes_confidence.array && - filter->bboxes_confidence.array[0] < - action->required_confidence) { - } else if (action->feature_property == - FEATURE_BOUNDINGBOX_TOP_LEFT) { + if (action->feature == FEATURE_BOUNDINGBOX && filter->bboxes.max_boxes && filter->bboxes.num_boxes) { + if (filter->bboxes_confidence.array && filter->bboxes_confidence.array[0] < action->required_confidence) { + } else if (action->feature_property == FEATURE_BOUNDINGBOX_TOP_LEFT) { value->x = filter->bboxes.boxes[0].x; value->y = filter->bboxes.boxes[0].y; success = true; - } else if (action->feature_property == - FEATURE_BOUNDINGBOX_TOP_CENTER) { - value->x = filter->bboxes.boxes[0].x + - filter->bboxes.boxes[0].width / 2.0f; + } else if (action->feature_property == FEATURE_BOUNDINGBOX_TOP_CENTER) { + value->x = filter->bboxes.boxes[0].x + filter->bboxes.boxes[0].width / 2.0f; value->y = filter->bboxes.boxes[0].y; success = true; - } else if (action->feature_property == - FEATURE_BOUNDINGBOX_TOP_RIGHT) { - value->x = filter->bboxes.boxes[0].x + - filter->bboxes.boxes[0].width; + } else if (action->feature_property == FEATURE_BOUNDINGBOX_TOP_RIGHT) { + value->x = filter->bboxes.boxes[0].x + filter->bboxes.boxes[0].width; value->y = filter->bboxes.boxes[0].y; success = true; - } else if (action->feature_property == - FEATURE_BOUNDINGBOX_CENTER_RIGHT) { - value->x = filter->bboxes.boxes[0].x + - filter->bboxes.boxes[0].width; - value->y = filter->bboxes.boxes[0].y + - filter->bboxes.boxes[0].height / 2.0f; + } else if (action->feature_property == FEATURE_BOUNDINGBOX_CENTER_RIGHT) { + value->x = filter->bboxes.boxes[0].x + filter->bboxes.boxes[0].width; + value->y = filter->bboxes.boxes[0].y + filter->bboxes.boxes[0].height / 2.0f; success = true; - } else if (action->feature_property == - FEATURE_BOUNDINGBOX_BOTTOM_RIGHT) { - value->x = filter->bboxes.boxes[0].x + - filter->bboxes.boxes[0].width; - value->y = filter->bboxes.boxes[0].y + - filter->bboxes.boxes[0].height; + } else if (action->feature_property == FEATURE_BOUNDINGBOX_BOTTOM_RIGHT) { + value->x = filter->bboxes.boxes[0].x + filter->bboxes.boxes[0].width; + value->y = filter->bboxes.boxes[0].y + filter->bboxes.boxes[0].height; success = true; - } else if (action->feature_property == - FEATURE_BOUNDINGBOX_BOTTOM_CENTER) { - value->x = filter->bboxes.boxes[0].x + - filter->bboxes.boxes[0].width / 2.0f; - value->y = filter->bboxes.boxes[0].y + - filter->bboxes.boxes[0].height; + } else if (action->feature_property == FEATURE_BOUNDINGBOX_BOTTOM_CENTER) { + value->x = filter->bboxes.boxes[0].x + filter->bboxes.boxes[0].width / 2.0f; + value->y = filter->bboxes.boxes[0].y + filter->bboxes.boxes[0].height; success = true; - } else if (action->feature_property == - FEATURE_BOUNDINGBOX_BOTTOM_LEFT) { + } else if (action->feature_property == FEATURE_BOUNDINGBOX_BOTTOM_LEFT) { value->x = filter->bboxes.boxes[0].x; - value->y = filter->bboxes.boxes[0].y + - filter->bboxes.boxes[0].height; + value->y = filter->bboxes.boxes[0].y + filter->bboxes.boxes[0].height; success = true; - } else if (action->feature_property == - FEATURE_BOUNDINGBOX_CENTER_LEFT) { + } else if (action->feature_property == FEATURE_BOUNDINGBOX_CENTER_LEFT) { value->x = filter->bboxes.boxes[0].x; - value->y = filter->bboxes.boxes[0].y + - filter->bboxes.boxes[0].height / 2.0f; + value->y = filter->bboxes.boxes[0].y + filter->bboxes.boxes[0].height / 2.0f; success = true; - } else if (action->feature_property == - FEATURE_BOUNDINGBOX_CENTER) { - value->x = filter->bboxes.boxes[0].x + - filter->bboxes.boxes[0].width / 2.0f; - value->y = filter->bboxes.boxes[0].y + - filter->bboxes.boxes[0].height / 2.0f; + } else if (action->feature_property == FEATURE_BOUNDINGBOX_CENTER) { + value->x = filter->bboxes.boxes[0].x + filter->bboxes.boxes[0].width / 2.0f; + value->y = filter->bboxes.boxes[0].y + filter->bboxes.boxes[0].height / 2.0f; success = true; - } else if (action->feature_property == - FEATURE_BOUNDINGBOX_SIZE) { + } else if (action->feature_property == FEATURE_BOUNDINGBOX_SIZE) { value->x = filter->bboxes.boxes[0].width; value->y = filter->bboxes.boxes[0].height; success = true; } - } else if (action->feature == FEATURE_LANDMARK && - filter->landmarks.num) { - if (action->feature_number[0] >= - (int32_t)filter->landmarks.num) { - } else if (filter->landmarks_confidence - .array[action->feature_number[0]] < - action->required_confidence) { + } else if (action->feature == FEATURE_LANDMARK && filter->landmarks.num) { + if (action->feature_number[0] >= (int32_t)filter->landmarks.num) { + } else if (filter->landmarks_confidence.array[action->feature_number[0]] < action->required_confidence) { } else if (action->feature_property == FEATURE_LANDMARK_POS) { - value->x = filter->landmarks - .array[action->feature_number[0]] - .x; - value->y = filter->landmarks - .array[action->feature_number[0]] - .y; + value->x = filter->landmarks.array[action->feature_number[0]].x; + value->y = filter->landmarks.array[action->feature_number[0]].y; success = true; - } else if (action->feature_number[1] >= - (int32_t)filter->landmarks.num) { + } else if (action->feature_number[1] >= (int32_t)filter->landmarks.num) { } else if (action->feature_property == FEATURE_LANDMARK_DIFF) { - value->x = filter->landmarks - .array[action->feature_number[1]] - .x - - filter->landmarks - .array[action->feature_number[0]] - .x; - value->y = filter->landmarks - .array[action->feature_number[1]] - .y - - filter->landmarks - .array[action->feature_number[0]] - .y; + value->x = filter->landmarks.array[action->feature_number[1]].x - + filter->landmarks.array[action->feature_number[0]].x; + value->y = filter->landmarks.array[action->feature_number[1]].y - + filter->landmarks.array[action->feature_number[0]].y; success = true; } } else if (action->feature == FEATURE_GAZE) { @@ -841,49 +627,25 @@ static bool nv_move_action_get_vec2(struct nvidia_move_info *filter, value->y = DEG(filter->gaze_angles_vector[1]); success = true; } - } else if (action->feature == FEATURE_EXPRESSION && - filter->expressions.num) { + } else if (action->feature == FEATURE_EXPRESSION && filter->expressions.num) { if (action->feature_property == FEATURE_EXPRESSION_VECTOR) { - success = - get_expression_value(filter, - action->feature_number[0], - &value->x) && - get_expression_value(filter, - action->feature_number[1], - &value->y); + success = get_expression_value(filter, action->feature_number[0], &value->x) && + get_expression_value(filter, action->feature_number[1], &value->y); } } else if (action->feature == FEATURE_BODY && filter->keypoints.num) { - if (action->feature_number[0] >= - (int32_t)filter->keypoints.num) { - } else if (filter->keypoints_confidence - .array[action->feature_number[0]] < - action->required_confidence) { + if (action->feature_number[0] >= (int32_t)filter->keypoints.num) { + } else if (filter->keypoints_confidence.array[action->feature_number[0]] < action->required_confidence) { } else if (action->feature_property == BODY_2D_POS) { - value->x = filter->keypoints - .array[action->feature_number[0]] - .x; - value->y = filter->keypoints - .array[action->feature_number[0]] - .y; + value->x = filter->keypoints.array[action->feature_number[0]].x; + value->y = filter->keypoints.array[action->feature_number[0]].y; success = true; - } else if (action->feature_number[1] >= - (int32_t)filter->keypoints.num) { - } else if (filter->keypoints_confidence - .array[action->feature_number[1]] < - action->required_confidence) { + } else if (action->feature_number[1] >= (int32_t)filter->keypoints.num) { + } else if (filter->keypoints_confidence.array[action->feature_number[1]] < action->required_confidence) { } else if (action->feature_property == BODY_2D_DIFF) { - value->x = filter->keypoints - .array[action->feature_number[1]] - .x - - filter->keypoints - .array[action->feature_number[0]] - .x; - value->y = filter->keypoints - .array[action->feature_number[1]] - .y - - filter->keypoints - .array[action->feature_number[0]] - .y; + value->x = filter->keypoints.array[action->feature_number[1]].x - + filter->keypoints.array[action->feature_number[0]].x; + value->y = filter->keypoints.array[action->feature_number[1]].y - + filter->keypoints.array[action->feature_number[0]].y; success = true; } } @@ -893,11 +655,9 @@ static bool nv_move_action_get_vec2(struct nvidia_move_info *filter, value->y += action->diff2; if (success && easing) { - value->x = action->previous_vec2.x * action->easing + - value->x * (1.0f - action->easing); + value->x = action->previous_vec2.x * action->easing + value->x * (1.0f - action->easing); action->previous_vec2.x = value->x; - value->y = action->previous_vec2.y * action->easing + - value->y * (1.0f - action->easing); + value->y = action->previous_vec2.y * action->easing + value->y * (1.0f - action->easing); action->previous_vec2.y = value->y; } return success; @@ -910,8 +670,7 @@ static void nv_move_update(void *data, obs_data_t *settings) size_t actions = (size_t)obs_data_get_int(settings, "actions"); if (actions < filter->actions.num) { for (size_t i = actions; i < filter->actions.num; i++) { - struct nvidia_move_action *action = - filter->actions.array + i; + struct nvidia_move_action *action = filter->actions.array + i; obs_weak_source_release(action->target); action->target = NULL; bfree(action->name); @@ -923,90 +682,62 @@ static void nv_move_update(void *data, obs_data_t *settings) uint64_t feature_flags = 0; struct dstr name = {0}; for (size_t i = 1; i <= actions; i++) { - struct nvidia_move_action *action = - filter->actions.array + i - 1; + struct nvidia_move_action *action = filter->actions.array + i - 1; dstr_printf(&name, "action_%lld_disabled", i); action->disabled = obs_data_get_bool(settings, name.array); dstr_printf(&name, "action_%lld_action", i); - action->action = - (uint32_t)obs_data_get_int(settings, name.array); + action->action = (uint32_t)obs_data_get_int(settings, name.array); obs_weak_source_release(action->target); action->target = NULL; bfree(action->name); action->name = NULL; - if (action->action == ACTION_MOVE_SOURCE || - action->action == ACTION_SOURCE_VISIBILITY || + if (action->action == ACTION_MOVE_SOURCE || action->action == ACTION_SOURCE_VISIBILITY || action->action == ACTION_ATTACH_SOURCE) { dstr_printf(&name, "action_%lld_scene", i); - const char *scene_name = - obs_data_get_string(settings, name.array); - obs_source_t *source = - obs_get_source_by_name(scene_name); + const char *scene_name = obs_data_get_string(settings, name.array); + obs_source_t *source = obs_get_source_by_name(scene_name); if (source) { - if (obs_source_is_scene(source) || - obs_source_is_group(source)) - action->target = - obs_source_get_weak_source( - source); + if (obs_source_is_scene(source) || obs_source_is_group(source)) + action->target = obs_source_get_weak_source(source); obs_source_release(source); } dstr_printf(&name, "action_%lld_sceneitem", i); - action->name = bstrdup( - obs_data_get_string(settings, name.array)); + action->name = bstrdup(obs_data_get_string(settings, name.array)); } if (action->action == ACTION_MOVE_SOURCE) { dstr_printf(&name, "action_%lld_sceneitem_property", i); - action->property = (uint32_t)obs_data_get_int( - settings, name.array); - } else if (action->action == ACTION_ENABLE_FILTER || - action->action == ACTION_SOURCE_VISIBILITY) { + action->property = (uint32_t)obs_data_get_int(settings, name.array); + } else if (action->action == ACTION_ENABLE_FILTER || action->action == ACTION_SOURCE_VISIBILITY) { dstr_printf(&name, "action_%lld_enable", i); - action->property = (uint32_t)obs_data_get_int( - settings, name.array); + action->property = (uint32_t)obs_data_get_int(settings, name.array); dstr_printf(&name, "action_%lld_threshold", i); - action->threshold = (float)obs_data_get_double( - settings, name.array); + action->threshold = (float)obs_data_get_double(settings, name.array); } else if (action->action == ACTION_ATTACH_SOURCE) { dstr_printf(&name, "action_%lld_attach", i); - action->property = (uint32_t)obs_data_get_int( - settings, name.array); + action->property = (uint32_t)obs_data_get_int(settings, name.array); } - if (action->action == ACTION_MOVE_VALUE || - action->action == ACTION_ENABLE_FILTER) { + if (action->action == ACTION_MOVE_VALUE || action->action == ACTION_ENABLE_FILTER) { dstr_printf(&name, "action_%lld_source", i); - const char *source_name = - obs_data_get_string(settings, name.array); - obs_source_t *source = - obs_get_source_by_name(source_name); + const char *source_name = obs_data_get_string(settings, name.array); + obs_source_t *source = obs_get_source_by_name(source_name); if (source) { dstr_printf(&name, "action_%lld_filter", i); - const char *filter_name = obs_data_get_string( - settings, name.array); - obs_source_t *f = obs_source_get_filter_by_name( - source, filter_name); - if (f || - action->action == ACTION_ENABLE_FILTER) { + const char *filter_name = obs_data_get_string(settings, name.array); + obs_source_t *f = obs_source_get_filter_by_name(source, filter_name); + if (f || action->action == ACTION_ENABLE_FILTER) { obs_source_release(source); source = f; } - action->target = - obs_source_get_weak_source(source); + action->target = obs_source_get_weak_source(source); if (action->action == ACTION_MOVE_VALUE) { - dstr_printf(&name, - "action_%lld_property", i); - action->name = - bstrdup(obs_data_get_string( - settings, name.array)); - - obs_properties_t *sp = - obs_source_properties(source); - obs_property_t *p = obs_properties_get( - sp, action->name); - action->is_int = - (obs_property_get_type(p) == - OBS_PROPERTY_INT); + dstr_printf(&name, "action_%lld_property", i); + action->name = bstrdup(obs_data_get_string(settings, name.array)); + + obs_properties_t *sp = obs_source_properties(source); + obs_property_t *p = obs_properties_get(sp, action->name); + action->is_int = (obs_property_get_type(p) == OBS_PROPERTY_INT); obs_properties_destroy(sp); } @@ -1019,119 +750,78 @@ static void nv_move_update(void *data, obs_data_t *settings) action->feature = FEATURE_LANDMARK; } else { dstr_printf(&name, "action_%lld_feature", i); - action->feature = (uint32_t)obs_data_get_int( - settings, name.array); + action->feature = (uint32_t)obs_data_get_int(settings, name.array); } feature_flags |= (1ull << action->feature); if (action->feature == FEATURE_BOUNDINGBOX) { dstr_printf(&name, "action_%lld_bounding_box", i); - action->feature_property = (uint32_t)obs_data_get_int( - settings, name.array); - dstr_printf(&name, "action_%lld_required_confidence", - i); - action->required_confidence = - (float)obs_data_get_double(settings, - name.array); + action->feature_property = (uint32_t)obs_data_get_int(settings, name.array); + dstr_printf(&name, "action_%lld_required_confidence", i); + action->required_confidence = (float)obs_data_get_double(settings, name.array); } else if (action->feature == FEATURE_LANDMARK) { dstr_printf(&name, "action_%lld_landmark", i); - action->feature_property = (uint32_t)obs_data_get_int( - settings, name.array); + action->feature_property = (uint32_t)obs_data_get_int(settings, name.array); dstr_printf(&name, "action_%lld_landmark_1", i); if (obs_data_get_int(settings, name.array)) - action->feature_number[0] = - (int32_t)obs_data_get_int(settings, - name.array) - - 1; + action->feature_number[0] = (int32_t)obs_data_get_int(settings, name.array) - 1; dstr_printf(&name, "action_%lld_landmark_2", i); if (obs_data_get_int(settings, name.array)) - action->feature_number[1] = - (int32_t)obs_data_get_int(settings, - name.array) - - 1; - dstr_printf(&name, "action_%lld_required_confidence", - i); - action->required_confidence = - (float)obs_data_get_double(settings, - name.array); + action->feature_number[1] = (int32_t)obs_data_get_int(settings, name.array) - 1; + dstr_printf(&name, "action_%lld_required_confidence", i); + action->required_confidence = (float)obs_data_get_double(settings, name.array); } else if (action->feature == FEATURE_POSE) { dstr_printf(&name, "action_%lld_pose", i); - action->feature_property = (uint32_t)obs_data_get_int( - settings, name.array); + action->feature_property = (uint32_t)obs_data_get_int(settings, name.array); } else if (action->feature == FEATURE_EXPRESSION) { - dstr_printf(&name, "action_%lld_expression_property", - i); - action->feature_property = (uint32_t)obs_data_get_int( - settings, name.array); + dstr_printf(&name, "action_%lld_expression_property", i); + action->feature_property = (uint32_t)obs_data_get_int(settings, name.array); dstr_printf(&name, "action_%lld_expression", i); long long old = obs_data_get_int(settings, name.array); if (old) { obs_data_unset_user_value(settings, name.array); - dstr_printf(&name, "action_%lld_expression_1", - i); + dstr_printf(&name, "action_%lld_expression_1", i); obs_data_set_int(settings, name.array, old); } dstr_printf(&name, "action_%lld_expression_1", i); - action->feature_number[0] = - (int32_t)obs_data_get_int(settings, - name.array) - - 1; + action->feature_number[0] = (int32_t)obs_data_get_int(settings, name.array) - 1; dstr_printf(&name, "action_%lld_expression_2", i); - action->feature_number[1] = - (int32_t)obs_data_get_int(settings, - name.array) - - 1; + action->feature_number[1] = (int32_t)obs_data_get_int(settings, name.array) - 1; } else if (action->feature == FEATURE_GAZE) { dstr_printf(&name, "action_%lld_gaze", i); - action->feature_property = - (int32_t)obs_data_get_int(settings, name.array); + action->feature_property = (int32_t)obs_data_get_int(settings, name.array); } else if (action->feature == FEATURE_BODY) { dstr_printf(&name, "action_%lld_body", i); - action->feature_property = - (int32_t)obs_data_get_int(settings, name.array); + action->feature_property = (int32_t)obs_data_get_int(settings, name.array); dstr_printf(&name, "action_%lld_body_1", i); - action->feature_number[0] = - (int32_t)obs_data_get_int(settings, name.array); + action->feature_number[0] = (int32_t)obs_data_get_int(settings, name.array); dstr_printf(&name, "action_%lld_body_2", i); - action->feature_number[1] = - (int32_t)obs_data_get_int(settings, name.array); - dstr_printf(&name, "action_%lld_required_confidence", - i); - action->required_confidence = - (float)obs_data_get_double(settings, - name.array); + action->feature_number[1] = (int32_t)obs_data_get_int(settings, name.array); + dstr_printf(&name, "action_%lld_required_confidence", i); + action->required_confidence = (float)obs_data_get_double(settings, name.array); } dstr_printf(&name, "action_%lld_factor2", i); obs_data_set_default_double(settings, name.array, 100.0f); dstr_printf(&name, "action_%lld_factor", i); obs_data_set_default_double(settings, name.array, 100.0f); - action->factor = - (float)obs_data_get_double(settings, name.array) / - 100.0f; + action->factor = (float)obs_data_get_double(settings, name.array) / 100.0f; dstr_printf(&name, "action_%lld_factor2", i); - action->factor2 = - (float)obs_data_get_double(settings, name.array) / - 100.0f; + action->factor2 = (float)obs_data_get_double(settings, name.array) / 100.0f; dstr_printf(&name, "action_%lld_diff", i); action->diff = (float)obs_data_get_double(settings, name.array); dstr_printf(&name, "action_%lld_diff2", i); - action->diff2 = - (float)obs_data_get_double(settings, name.array); + action->diff2 = (float)obs_data_get_double(settings, name.array); dstr_printf(&name, "action_%lld_easing", i); - action->easing = ExponentialEaseOut( - (float)obs_data_get_double(settings, name.array) / - 100.0f); + action->easing = ExponentialEaseOut((float)obs_data_get_double(settings, name.array) / 100.0f); if (action->action != ACTION_ATTACH_SOURCE) { - nv_move_action_get_float(filter, action, false, - &action->previous_float); - nv_move_action_get_vec2(filter, action, false, - &action->previous_vec2); + nv_move_action_get_float(filter, action, false, &action->previous_float); + nv_move_action_get_vec2(filter, action, false, &action->previous_vec2); } } dstr_free(&name); @@ -1141,166 +831,104 @@ static void nv_move_update(void *data, obs_data_t *settings) if (feature_flags & (1ull << FEATURE_BODY)) { if (!filter->bodyHandle) { - if (nv_move_log_error( - filter, - NvAR_Create(NvAR_Feature_BodyPoseEstimation, - &filter->bodyHandle), - "Create body")) + if (nv_move_log_error(filter, NvAR_Create(NvAR_Feature_BodyPoseEstimation, &filter->bodyHandle), + "Create body")) return; nv_move_feature_handle(filter, filter->bodyHandle); unsigned int numKeyPoints = 0; - NvCV_Status nvErr = - NvAR_GetU32(filter->bodyHandle, - NvAR_Parameter_Config(NumKeyPoints), - &numKeyPoints); + NvCV_Status nvErr = NvAR_GetU32(filter->bodyHandle, NvAR_Parameter_Config(NumKeyPoints), &numKeyPoints); if (nvErr == NVCV_SUCCESS) { da_resize(filter->keypoints, numKeyPoints); - nvErr = NvAR_SetObject( - filter->bodyHandle, - NvAR_Parameter_Output(KeyPoints), - filter->keypoints.array, - sizeof(NvAR_Point2f)); + nvErr = NvAR_SetObject(filter->bodyHandle, NvAR_Parameter_Output(KeyPoints), + filter->keypoints.array, sizeof(NvAR_Point2f)); da_resize(filter->keypoints3D, numKeyPoints); - nvErr = NvAR_SetObject( - filter->bodyHandle, - NvAR_Parameter_Output(KeyPoints3D), - filter->keypoints3D.array, - sizeof(NvAR_Point3f)); + nvErr = NvAR_SetObject(filter->bodyHandle, NvAR_Parameter_Output(KeyPoints3D), + filter->keypoints3D.array, sizeof(NvAR_Point3f)); da_resize(filter->joint_angles, numKeyPoints); - nvErr = NvAR_SetObject( - filter->bodyHandle, - NvAR_Parameter_Output(JointAngles), - filter->joint_angles.array, - sizeof(NvAR_Quaternion)); - - da_resize(filter->keypoints_confidence, - numKeyPoints); - - nvErr = NvAR_SetF32Array( - filter->bodyHandle, - NvAR_Parameter_Output( - KeyPointsConfidence), - filter->keypoints_confidence.array, - sizeof(float)); + nvErr = NvAR_SetObject(filter->bodyHandle, NvAR_Parameter_Output(JointAngles), + filter->joint_angles.array, sizeof(NvAR_Quaternion)); + + da_resize(filter->keypoints_confidence, numKeyPoints); + + nvErr = NvAR_SetF32Array(filter->bodyHandle, NvAR_Parameter_Output(KeyPointsConfidence), + filter->keypoints_confidence.array, sizeof(float)); } else { - nv_move_log_error(filter, nvErr, - "NumKeyPoints"); + nv_move_log_error(filter, nvErr, "NumKeyPoints"); } - if (nv_move_log_error(filter, - NvAR_Load(filter->bodyHandle), - "Load body")) + if (nv_move_log_error(filter, NvAR_Load(filter->bodyHandle), "Load body")) return; } } else if (filter->bodyHandle) { - nv_move_log_error(filter, NvAR_Destroy(filter->bodyHandle), - "Destroy body"); + nv_move_log_error(filter, NvAR_Destroy(filter->bodyHandle), "Destroy body"); filter->bodyHandle = NULL; } if (feature_flags & (1ull << FEATURE_GAZE)) { if (!filter->gazeHandle) { - if (nv_move_log_error( - filter, - NvAR_Create(NvAR_Feature_GazeRedirection, - &filter->gazeHandle), - "Create gaze")) + if (nv_move_log_error(filter, NvAR_Create(NvAR_Feature_GazeRedirection, &filter->gazeHandle), + "Create gaze")) return; nv_move_feature_handle(filter, filter->gazeHandle); nv_move_landmarks(filter, filter->gazeHandle); - NvAR_SetObject(filter->gazeHandle, - NvAR_Parameter_Output(HeadPose), - &filter->pose, sizeof(NvAR_Quaternion)); - NvAR_SetF32Array( - filter->gazeHandle, - NvAR_Parameter_Output(OutputGazeVector), - filter->gaze_angles_vector, 2); - - NvAR_SetF32Array( - filter->gazeHandle, - NvAR_Parameter_Output(OutputHeadTranslation), - filter->head_translation, 3); - - NvAR_SetObject(filter->gazeHandle, - NvAR_Parameter_Output(GazeDirection), - &filter->gaze_direction, + NvAR_SetObject(filter->gazeHandle, NvAR_Parameter_Output(HeadPose), &filter->pose, sizeof(NvAR_Quaternion)); + NvAR_SetF32Array(filter->gazeHandle, NvAR_Parameter_Output(OutputGazeVector), filter->gaze_angles_vector, + 2); + + NvAR_SetF32Array(filter->gazeHandle, NvAR_Parameter_Output(OutputHeadTranslation), filter->head_translation, + 3); + + NvAR_SetObject(filter->gazeHandle, NvAR_Parameter_Output(GazeDirection), &filter->gaze_direction, sizeof(NvAR_Point3f)); - da_resize(filter->gaze_output_landmarks, - filter->landmarks.num); + da_resize(filter->gaze_output_landmarks, filter->landmarks.num); - NvAR_SetObject( - filter->gazeHandle, - NvAR_Parameter_Output(GazeOutputLandmarks), - filter->gaze_output_landmarks.array, - sizeof(NvAR_Point2f)); + NvAR_SetObject(filter->gazeHandle, NvAR_Parameter_Output(GazeOutputLandmarks), + filter->gaze_output_landmarks.array, sizeof(NvAR_Point2f)); - NvAR_SetU32(filter->gazeHandle, - NvAR_Parameter_Config(Temporal), -1); + NvAR_SetU32(filter->gazeHandle, NvAR_Parameter_Config(Temporal), -1); - NvAR_SetU32(filter->gazeHandle, - NvAR_Parameter_Config(GazeRedirect), false); + NvAR_SetU32(filter->gazeHandle, NvAR_Parameter_Config(GazeRedirect), false); - NvAR_SetU32(filter->gazeHandle, - NvAR_Parameter_Config(UseCudaGraph), true); + NvAR_SetU32(filter->gazeHandle, NvAR_Parameter_Config(UseCudaGraph), true); - NvAR_SetU32(filter->gazeHandle, - NvAR_Parameter_Config(EyeSizeSensitivity), - 3); + NvAR_SetU32(filter->gazeHandle, NvAR_Parameter_Config(EyeSizeSensitivity), 3); - if (nv_move_log_error(filter, - NvAR_Load(filter->gazeHandle), - "Load gaze")) + if (nv_move_log_error(filter, NvAR_Load(filter->gazeHandle), "Load gaze")) return; } } else if (filter->gazeHandle) { - nv_move_log_error(filter, NvAR_Destroy(filter->gazeHandle), - "Destroy gaze"); + nv_move_log_error(filter, NvAR_Destroy(filter->gazeHandle), "Destroy gaze"); filter->gazeHandle = NULL; } if (feature_flags & (1ull << FEATURE_EXPRESSION)) { if (!filter->expressionHandle) { - if (nv_move_log_error( - filter, - NvAR_Create(NvAR_Feature_FaceExpressions, - &filter->expressionHandle), - "Create expression")) + if (nv_move_log_error(filter, NvAR_Create(NvAR_Feature_FaceExpressions, &filter->expressionHandle), + "Create expression")) return; - nv_move_feature_handle(filter, - filter->expressionHandle); + nv_move_feature_handle(filter, filter->expressionHandle); nv_move_landmarks(filter, filter->expressionHandle); - NvAR_SetObject(filter->expressionHandle, - NvAR_Parameter_Output(Pose), - &filter->pose, sizeof(NvAR_Quaternion)); + NvAR_SetObject(filter->expressionHandle, NvAR_Parameter_Output(Pose), &filter->pose, + sizeof(NvAR_Quaternion)); uint32_t expressionCount = 0; - NvCV_Status nvErr = NvAR_GetU32( - filter->expressionHandle, - NvAR_Parameter_Config(ExpressionCount), - &expressionCount); + NvCV_Status nvErr = + NvAR_GetU32(filter->expressionHandle, NvAR_Parameter_Config(ExpressionCount), &expressionCount); if (nvErr == NVCV_SUCCESS) { da_resize(filter->expressions, expressionCount); - nvErr = NvAR_SetF32Array( - filter->expressionHandle, - NvAR_Parameter_Output( - ExpressionCoefficients), - filter->expressions.array, - expressionCount); + nvErr = NvAR_SetF32Array(filter->expressionHandle, NvAR_Parameter_Output(ExpressionCoefficients), + filter->expressions.array, expressionCount); } - if (nv_move_log_error( - filter, NvAR_Load(filter->expressionHandle), - "Load expression")) + if (nv_move_log_error(filter, NvAR_Load(filter->expressionHandle), "Load expression")) return; } } else if (filter->expressionHandle) { - nv_move_log_error(filter, - NvAR_Destroy(filter->expressionHandle), - "Destroy expression"); + nv_move_log_error(filter, NvAR_Destroy(filter->expressionHandle), "Destroy expression"); filter->expressionHandle = NULL; } @@ -1308,76 +936,47 @@ static void nv_move_update(void *data, obs_data_t *settings) if (!filter->bboxes_confidence.num) da_resize(filter->bboxes_confidence, BBOXES_COUNT); if (filter->bodyHandle) { - NvAR_SetF32Array( - filter->bodyHandle, - NvAR_Parameter_Output(BoundingBoxesConfidence), - filter->bboxes_confidence.array, BBOXES_COUNT); + NvAR_SetF32Array(filter->bodyHandle, NvAR_Parameter_Output(BoundingBoxesConfidence), + filter->bboxes_confidence.array, BBOXES_COUNT); } else if (filter->gazeHandle) { - NvAR_SetF32Array( - filter->gazeHandle, - NvAR_Parameter_Output(BoundingBoxesConfidence), - filter->bboxes_confidence.array, BBOXES_COUNT); + NvAR_SetF32Array(filter->gazeHandle, NvAR_Parameter_Output(BoundingBoxesConfidence), + filter->bboxes_confidence.array, BBOXES_COUNT); } else if (filter->expressionHandle) { - NvAR_SetF32Array( - filter->expressionHandle, - NvAR_Parameter_Output(BoundingBoxesConfidence), - filter->bboxes_confidence.array, BBOXES_COUNT); + NvAR_SetF32Array(filter->expressionHandle, NvAR_Parameter_Output(BoundingBoxesConfidence), + filter->bboxes_confidence.array, BBOXES_COUNT); } else { if (!filter->faceDetectHandle) { - if (nv_move_log_error( - filter, - NvAR_Create( - NvAR_Feature_FaceBoxDetection, - &filter->faceDetectHandle), - "Create faceDetect")) + if (nv_move_log_error(filter, NvAR_Create(NvAR_Feature_FaceBoxDetection, &filter->faceDetectHandle), + "Create faceDetect")) return; - nv_move_feature_handle( - filter, filter->faceDetectHandle); - NvAR_SetF32Array( - filter->faceDetectHandle, - NvAR_Parameter_Output( - BoundingBoxesConfidence), - filter->bboxes_confidence.array, - BBOXES_COUNT); - - if (nv_move_log_error( - filter, - NvAR_Load(filter->faceDetectHandle), - "Load faceDetect")) + nv_move_feature_handle(filter, filter->faceDetectHandle); + NvAR_SetF32Array(filter->faceDetectHandle, NvAR_Parameter_Output(BoundingBoxesConfidence), + filter->bboxes_confidence.array, BBOXES_COUNT); + + if (nv_move_log_error(filter, NvAR_Load(filter->faceDetectHandle), "Load faceDetect")) return; } } } else if (filter->faceDetectHandle) { - nv_move_log_error(filter, - NvAR_Destroy(filter->faceDetectHandle), - "Destroy faceDetect"); + nv_move_log_error(filter, NvAR_Destroy(filter->faceDetectHandle), "Destroy faceDetect"); filter->faceDetectHandle = NULL; } - if ((((feature_flags & (1ull << FEATURE_LANDMARK)) || - (feature_flags & (1ull << FEATURE_POSE))) && - !filter->gazeHandle && !filter->expressionHandle)) { + if ((((feature_flags & (1ull << FEATURE_LANDMARK)) || (feature_flags & (1ull << FEATURE_POSE))) && !filter->gazeHandle && + !filter->expressionHandle)) { if (!filter->landmarkHandle) { - if (nv_move_log_error( - filter, - NvAR_Create(NvAR_Feature_LandmarkDetection, - &filter->landmarkHandle), - "Create landmark")) + if (nv_move_log_error(filter, NvAR_Create(NvAR_Feature_LandmarkDetection, &filter->landmarkHandle), + "Create landmark")) return; nv_move_feature_handle(filter, filter->landmarkHandle); nv_move_landmarks(filter, filter->landmarkHandle); - NvAR_SetObject(filter->landmarkHandle, - NvAR_Parameter_Output(Pose), - &filter->pose, sizeof(NvAR_Quaternion)); - if (nv_move_log_error(filter, - NvAR_Load(filter->landmarkHandle), - "Load expression")) + NvAR_SetObject(filter->landmarkHandle, NvAR_Parameter_Output(Pose), &filter->pose, sizeof(NvAR_Quaternion)); + if (nv_move_log_error(filter, NvAR_Load(filter->landmarkHandle), "Load expression")) return; } } else if (filter->landmarkHandle) { - nv_move_log_error(filter, NvAR_Destroy(filter->landmarkHandle), - "Destroy landmark"); + nv_move_log_error(filter, NvAR_Destroy(filter->landmarkHandle), "Destroy landmark"); filter->landmarkHandle = NULL; } } @@ -1386,27 +985,18 @@ static void nv_move_actual_destroy(void *data) { struct nvidia_move_info *filter = (struct nvidia_move_info *)data; if (filter->faceDetectHandle) - nv_move_log_error(filter, - NvAR_Destroy(filter->faceDetectHandle), - "Destroy faceDetect"); + nv_move_log_error(filter, NvAR_Destroy(filter->faceDetectHandle), "Destroy faceDetect"); if (filter->landmarkHandle) - nv_move_log_error(filter, NvAR_Destroy(filter->landmarkHandle), - "Destroy landmark"); + nv_move_log_error(filter, NvAR_Destroy(filter->landmarkHandle), "Destroy landmark"); if (filter->expressionHandle) - nv_move_log_error(filter, - NvAR_Destroy(filter->expressionHandle), - "Destroy expression"); + nv_move_log_error(filter, NvAR_Destroy(filter->expressionHandle), "Destroy expression"); if (filter->gazeHandle) - nv_move_log_error(filter, NvAR_Destroy(filter->gazeHandle), - "Destroy gaze"); + nv_move_log_error(filter, NvAR_Destroy(filter->gazeHandle), "Destroy gaze"); if (filter->bodyHandle) - nv_move_log_error(filter, NvAR_Destroy(filter->bodyHandle), - "Destroy body"); + nv_move_log_error(filter, NvAR_Destroy(filter->bodyHandle), "Destroy body"); if (filter->stream) - nv_move_log_error(filter, - NvAR_CudaStreamDestroy(filter->stream), - "Destroy Cuda Stream"); + nv_move_log_error(filter, NvAR_CudaStreamDestroy(filter->stream), "Destroy Cuda Stream"); bfree(filter->bboxes.boxes); @@ -1452,14 +1042,12 @@ static void *nv_move_create(obs_data_t *settings, obs_source_t *context) { if (!nvar_loaded) return NULL; - struct nvidia_move_info *filter = - (struct nvidia_move_info *)bzalloc(sizeof(*filter)); + struct nvidia_move_info *filter = (struct nvidia_move_info *)bzalloc(sizeof(*filter)); filter->source = context; //NvCV_Status nvErr = NvVFX_CudaStreamCreate(&filter->stream); - if (nv_move_log_error(filter, NvAR_CudaStreamCreate(&filter->stream), - "Create Cuda Stream")) + if (nv_move_log_error(filter, NvAR_CudaStreamCreate(&filter->stream), "Create Cuda Stream")) return NULL; /* 3. Load alpha mask effect. */ @@ -1470,11 +1058,9 @@ static void *nv_move_create(obs_data_t *settings, obs_source_t *context) bfree(effect_path); if (filter->effect) { //filter->mask_param = gs_effect_get_param_by_name(filter->effect, "mask"); - filter->image_param = - gs_effect_get_param_by_name(filter->effect, "image"); + filter->image_param = gs_effect_get_param_by_name(filter->effect, "image"); //filter->threshold_param = gs_effect_get_param_by_name(filter->effect, "threshold"); - filter->multiplier_param = gs_effect_get_param_by_name( - filter->effect, "multiplier"); + filter->multiplier_param = gs_effect_get_param_by_name(filter->effect, "multiplier"); } obs_leave_graphics(); @@ -1498,21 +1084,17 @@ bool list_add_scene(void *data, obs_source_t *source) return true; } -bool nv_move_expression_changed(void *priv, obs_properties_t *props, - obs_property_t *property, obs_data_t *settings) +bool nv_move_expression_changed(void *priv, obs_properties_t *props, obs_property_t *property, obs_data_t *settings) { struct nvidia_move_info *filter = (struct nvidia_move_info *)priv; const char *action_prop = obs_property_name(property); long long expression = obs_data_get_int(settings, action_prop); long long action_number = 0; - if (sscanf(action_prop, "action_%lld_expression_property", - &action_number) != 1 || - !action_number) + if (sscanf(action_prop, "action_%lld_expression_property", &action_number) != 1 || !action_number) return false; struct dstr name = {0}; dstr_printf(&name, "action_%lld_feature", action_number); - bool visible = obs_data_get_int(settings, name.array) == - FEATURE_EXPRESSION; + bool visible = obs_data_get_int(settings, name.array) == FEATURE_EXPRESSION; bool changed = false; dstr_printf(&name, "action_%lld_expression_1", action_number); obs_property_t *expression1 = obs_properties_get(props, name.array); @@ -1523,33 +1105,26 @@ bool nv_move_expression_changed(void *priv, obs_properties_t *props, dstr_printf(&name, "action_%lld_expression_2", action_number); obs_property_t *expression2 = obs_properties_get(props, name.array); - if (obs_property_visible(expression2) != - (visible && expression != FEATURE_EXPRESSION_SINGLE)) { - obs_property_set_visible( - expression2, - visible && expression != FEATURE_EXPRESSION_SINGLE); + if (obs_property_visible(expression2) != (visible && expression != FEATURE_EXPRESSION_SINGLE)) { + obs_property_set_visible(expression2, visible && expression != FEATURE_EXPRESSION_SINGLE); changed = true; } return changed; } -bool nv_move_landmark_changed(void *priv, obs_properties_t *props, - obs_property_t *property, obs_data_t *settings) +bool nv_move_landmark_changed(void *priv, obs_properties_t *props, obs_property_t *property, obs_data_t *settings) { struct nvidia_move_info *filter = (struct nvidia_move_info *)priv; const char *action_prop = obs_property_name(property); long long landmark = obs_data_get_int(settings, action_prop); long long action_number = 0; - if (sscanf(action_prop, "action_%lld_landmark", &action_number) != 1 || - !action_number) + if (sscanf(action_prop, "action_%lld_landmark", &action_number) != 1 || !action_number) return false; struct dstr name = {0}; dstr_printf(&name, "action_%lld_action", action_number); long long action = obs_data_get_int(settings, name.array); dstr_printf(&name, "action_%lld_feature", action_number); - bool visible = - (obs_data_get_int(settings, name.array) == FEATURE_LANDMARK && - action != ACTION_ATTACH_SOURCE); + bool visible = (obs_data_get_int(settings, name.array) == FEATURE_LANDMARK && action != ACTION_ATTACH_SOURCE); bool changed = false; @@ -1559,33 +1134,26 @@ bool nv_move_landmark_changed(void *priv, obs_properties_t *props, obs_property_set_visible(landmark1, visible); changed = true; } - obs_property_int_set_limits(landmark1, 1, (int)filter->landmarks.num, - 1); + obs_property_int_set_limits(landmark1, 1, (int)filter->landmarks.num, 1); dstr_printf(&name, "action_%lld_landmark_2", action_number); obs_property_t *landmark2 = obs_properties_get(props, name.array); if (obs_property_visible(landmark2) != - (visible && landmark != FEATURE_LANDMARK_POS && - landmark >= FEATURE_LANDMARK_DISTANCE)) { - obs_property_set_visible( - landmark2, - visible && landmark != FEATURE_LANDMARK_POS && - landmark >= FEATURE_LANDMARK_DISTANCE); + (visible && landmark != FEATURE_LANDMARK_POS && landmark >= FEATURE_LANDMARK_DISTANCE)) { + obs_property_set_visible(landmark2, + visible && landmark != FEATURE_LANDMARK_POS && landmark >= FEATURE_LANDMARK_DISTANCE); changed = true; } - obs_property_int_set_limits(landmark2, 1, (int)filter->landmarks.num, - 1); + obs_property_int_set_limits(landmark2, 1, (int)filter->landmarks.num, 1); dstr_free(&name); return changed; } -bool nv_move_body_changed(void *priv, obs_properties_t *props, - obs_property_t *property, obs_data_t *settings) +bool nv_move_body_changed(void *priv, obs_properties_t *props, obs_property_t *property, obs_data_t *settings) { const char *action_prop = obs_property_name(property); long long body = obs_data_get_int(settings, action_prop); long long action_number = 0; - if (sscanf(action_prop, "action_%lld_body", &action_number) != 1 || - !action_number) + if (sscanf(action_prop, "action_%lld_body", &action_number) != 1 || !action_number) return false; struct dstr name = {0}; dstr_printf(&name, "action_%lld_feature", action_number); @@ -1599,12 +1167,9 @@ bool nv_move_body_changed(void *priv, obs_properties_t *props, } dstr_printf(&name, "action_%lld_body_2", action_number); obs_property_t *body2 = obs_properties_get(props, name.array); - bool v2 = (visible && - (body == BODY_2D_DIFF || body == BODY_2D_DISTANCE || - body == BODY_2D_ROT || body == BODY_2D_DIFF_X || - body == BODY_2D_DIFF_Y || body == BODY_3D_DISTANCE || - body == BODY_3D_DIFF_X || body == BODY_3D_DIFF_Y || - body == BODY_3D_DIFF_Z || body == BODY_3D_DIFF)); + bool v2 = (visible && (body == BODY_2D_DIFF || body == BODY_2D_DISTANCE || body == BODY_2D_ROT || body == BODY_2D_DIFF_X || + body == BODY_2D_DIFF_Y || body == BODY_3D_DISTANCE || body == BODY_3D_DIFF_X || + body == BODY_3D_DIFF_Y || body == BODY_3D_DIFF_Z || body == BODY_3D_DIFF)); if (obs_property_visible(body2) != v2) { obs_property_set_visible(body2, v2); changed = true; @@ -1613,14 +1178,12 @@ bool nv_move_body_changed(void *priv, obs_properties_t *props, return changed; } -bool nv_move_feature_changed(void *priv, obs_properties_t *props, - obs_property_t *property, obs_data_t *settings) +bool nv_move_feature_changed(void *priv, obs_properties_t *props, obs_property_t *property, obs_data_t *settings) { const char *prop_name = obs_property_name(property); long long feature = obs_data_get_int(settings, prop_name); long long action_number = 0; - if (sscanf(prop_name, "action_%lld_feature", &action_number) != 1 || - !action_number) + if (sscanf(prop_name, "action_%lld_feature", &action_number) != 1 || !action_number) return false; struct dstr name = {0}; dstr_printf(&name, "action_%lld_action", action_number); @@ -1664,8 +1227,7 @@ bool nv_move_feature_changed(void *priv, obs_properties_t *props, obs_property_t *body2 = obs_properties_get(props, name.array); obs_property_set_visible(body2, false); dstr_printf(&name, "action_%lld_required_confidence", action_number); - obs_property_t *required_confidence = - obs_properties_get(props, name.array); + obs_property_t *required_confidence = obs_properties_get(props, name.array); obs_property_set_visible(required_confidence, false); if (action == ACTION_ATTACH_SOURCE) { @@ -1693,8 +1255,7 @@ bool nv_move_feature_changed(void *priv, obs_properties_t *props, return true; } -bool nv_move_actions_changed(void *priv, obs_properties_t *props, - obs_property_t *property, obs_data_t *settings) +bool nv_move_actions_changed(void *priv, obs_properties_t *props, obs_property_t *property, obs_data_t *settings) { struct dstr name = {0}; long long actions = obs_data_get_int(settings, "actions"); @@ -1713,18 +1274,15 @@ bool nv_move_actions_changed(void *priv, obs_properties_t *props, if (i > actions) { obs_property_list_item_remove(show, (size_t)i); } else { - const char *od = - obs_property_list_item_name(show, (size_t)i); + const char *od = obs_property_list_item_name(show, (size_t)i); dstr_printf(&name, "action_%lld_disabled", i); bool disabled = obs_data_get_bool(settings, name.array); dstr_printf(&name, "action_%lld_description", i); - const char *nd = - obs_data_get_string(settings, name.array); + const char *nd = obs_data_get_string(settings, name.array); if (strlen(nd)) { dstr_copy(&name, nd); } else { - dstr_printf(&name, "%s %lld", - obs_module_text("Action"), i); + dstr_printf(&name, "%s %lld", obs_module_text("Action"), i); } if (disabled) { dstr_cat(&name, " ("); @@ -1733,8 +1291,7 @@ bool nv_move_actions_changed(void *priv, obs_properties_t *props, } if (!od || strcmp(od, name.array) != 0) { obs_property_list_item_remove(show, (size_t)i); - obs_property_list_insert_int(show, (size_t)i, - name.array, i); + obs_property_list_insert_int(show, (size_t)i, name.array, i); changed = true; } } @@ -1748,8 +1305,7 @@ bool nv_move_actions_changed(void *priv, obs_properties_t *props, return changed; } -static void nv_move_prop_number_floats(uint32_t number, long long action_number, - obs_properties_t *props) +static void nv_move_prop_number_floats(uint32_t number, long long action_number, obs_properties_t *props) { struct dstr name = {0}; dstr_printf(&name, "action_%lld_landmark", action_number); @@ -1764,27 +1320,19 @@ static void nv_move_prop_number_floats(uint32_t number, long long action_number, dstr_printf(&name, "action_%lld_expression_property", action_number); obs_property_t *expression = obs_properties_get(props, name.array); - obs_property_list_item_disable(expression, FEATURE_EXPRESSION_SINGLE, - number != 1); - obs_property_list_item_disable(expression, FEATURE_EXPRESSION_VECTOR, - number != 2); - obs_property_list_item_disable(expression, FEATURE_EXPRESSION_ADD, - number != 1); - obs_property_list_item_disable(expression, FEATURE_EXPRESSION_SUBSTRACT, - number != 1); - obs_property_list_item_disable(expression, FEATURE_EXPRESSION_DISTANCE, - number != 1); - obs_property_list_item_disable(expression, FEATURE_EXPRESSION_AVG, - number != 1); + obs_property_list_item_disable(expression, FEATURE_EXPRESSION_SINGLE, number != 1); + obs_property_list_item_disable(expression, FEATURE_EXPRESSION_VECTOR, number != 2); + obs_property_list_item_disable(expression, FEATURE_EXPRESSION_ADD, number != 1); + obs_property_list_item_disable(expression, FEATURE_EXPRESSION_SUBSTRACT, number != 1); + obs_property_list_item_disable(expression, FEATURE_EXPRESSION_DISTANCE, number != 1); + obs_property_list_item_disable(expression, FEATURE_EXPRESSION_AVG, number != 1); dstr_printf(&name, "action_%lld_bounding_box", action_number); obs_property_t *bbox = obs_properties_get(props, name.array); - for (size_t i = FEATURE_BOUNDINGBOX_LEFT; - i <= FEATURE_BOUNDINGBOX_HEIGHT; i++) { + for (size_t i = FEATURE_BOUNDINGBOX_LEFT; i <= FEATURE_BOUNDINGBOX_HEIGHT; i++) { obs_property_list_item_disable(bbox, i, number != 1); } - for (size_t i = FEATURE_BOUNDINGBOX_TOP_LEFT; - i <= FEATURE_BOUNDINGBOX_SIZE; i++) { + for (size_t i = FEATURE_BOUNDINGBOX_TOP_LEFT; i <= FEATURE_BOUNDINGBOX_SIZE; i++) { obs_property_list_item_disable(bbox, i, number != 2); } dstr_printf(&name, "action_%lld_pose", action_number); @@ -1797,34 +1345,20 @@ static void nv_move_prop_number_floats(uint32_t number, long long action_number, obs_property_t *gaze = obs_properties_get(props, name.array); obs_property_list_item_disable(gaze, FEATURE_GAZE_VECTOR, number != 2); - obs_property_list_item_disable(gaze, FEATURE_GAZE_VECTOR_PITCH, - number != 1); - obs_property_list_item_disable(gaze, FEATURE_GAZE_VECTOR_YAW, - number != 1); - obs_property_list_item_disable(gaze, FEATURE_GAZE_HEADTRANSLATION, - number != 3); - obs_property_list_item_disable(gaze, FEATURE_GAZE_HEADTRANSLATION_X, - number != 1); - obs_property_list_item_disable(gaze, FEATURE_GAZE_HEADTRANSLATION_Y, - number != 1); - obs_property_list_item_disable(gaze, FEATURE_GAZE_HEADTRANSLATION_Z, - number != 1); - obs_property_list_item_disable( - gaze, FEATURE_GAZE_DIRECTION_CENTER_POINT, number != 3); - obs_property_list_item_disable( - gaze, FEATURE_GAZE_DIRECTION_CENTER_POINT_X, number != 1); - obs_property_list_item_disable( - gaze, FEATURE_GAZE_DIRECTION_CENTER_POINT_Y, number != 1); - obs_property_list_item_disable( - gaze, FEATURE_GAZE_DIRECTION_CENTER_POINT_Z, number != 1); - obs_property_list_item_disable(gaze, FEATURE_GAZE_DIRECTION_VECTOR, - number != 3); - obs_property_list_item_disable(gaze, FEATURE_GAZE_DIRECTION_VECTOR_X, - number != 1); - obs_property_list_item_disable(gaze, FEATURE_GAZE_DIRECTION_VECTOR_Y, - number != 1); - obs_property_list_item_disable(gaze, FEATURE_GAZE_DIRECTION_VECTOR_Z, - number != 1); + obs_property_list_item_disable(gaze, FEATURE_GAZE_VECTOR_PITCH, number != 1); + obs_property_list_item_disable(gaze, FEATURE_GAZE_VECTOR_YAW, number != 1); + obs_property_list_item_disable(gaze, FEATURE_GAZE_HEADTRANSLATION, number != 3); + obs_property_list_item_disable(gaze, FEATURE_GAZE_HEADTRANSLATION_X, number != 1); + obs_property_list_item_disable(gaze, FEATURE_GAZE_HEADTRANSLATION_Y, number != 1); + obs_property_list_item_disable(gaze, FEATURE_GAZE_HEADTRANSLATION_Z, number != 1); + obs_property_list_item_disable(gaze, FEATURE_GAZE_DIRECTION_CENTER_POINT, number != 3); + obs_property_list_item_disable(gaze, FEATURE_GAZE_DIRECTION_CENTER_POINT_X, number != 1); + obs_property_list_item_disable(gaze, FEATURE_GAZE_DIRECTION_CENTER_POINT_Y, number != 1); + obs_property_list_item_disable(gaze, FEATURE_GAZE_DIRECTION_CENTER_POINT_Z, number != 1); + obs_property_list_item_disable(gaze, FEATURE_GAZE_DIRECTION_VECTOR, number != 3); + obs_property_list_item_disable(gaze, FEATURE_GAZE_DIRECTION_VECTOR_X, number != 1); + obs_property_list_item_disable(gaze, FEATURE_GAZE_DIRECTION_VECTOR_Y, number != 1); + obs_property_list_item_disable(gaze, FEATURE_GAZE_DIRECTION_VECTOR_Z, number != 1); dstr_printf(&name, "action_%lld_body", action_number); obs_property_t *body = obs_properties_get(props, name.array); @@ -1845,14 +1379,12 @@ static void nv_move_prop_number_floats(uint32_t number, long long action_number, dstr_free(&name); } -bool nv_move_action_changed(void *priv, obs_properties_t *props, - obs_property_t *property, obs_data_t *settings) +bool nv_move_action_changed(void *priv, obs_properties_t *props, obs_property_t *property, obs_data_t *settings) { const char *action_prop = obs_property_name(property); long long action = obs_data_get_int(settings, action_prop); long long action_number = 0; - if (sscanf(action_prop, "action_%lld_action", &action_number) != 1 || - !action_number) + if (sscanf(action_prop, "action_%lld_action", &action_number) != 1 || !action_number) return false; struct dstr name = {0}; //dstr_printf(&name, "action_%lld_group", action_number); @@ -1866,8 +1398,7 @@ bool nv_move_action_changed(void *priv, obs_properties_t *props, dstr_printf(&name, "action_%lld_filter", action_number); obs_property_t *filter = obs_properties_get(props, name.array); dstr_printf(&name, "action_%lld_sceneitem_property", action_number); - obs_property_t *sceneitem_property = - obs_properties_get(props, name.array); + obs_property_t *sceneitem_property = obs_properties_get(props, name.array); dstr_printf(&name, "action_%lld_attach", action_number); obs_property_t *attach = obs_properties_get(props, name.array); dstr_printf(&name, "action_%lld_enable", action_number); @@ -1918,20 +1449,16 @@ bool nv_move_action_changed(void *priv, obs_properties_t *props, obs_property_set_visible(feature, false); obs_property_set_visible(get_value, false); dstr_printf(&name, "action_%lld_feature", action_number); - if (obs_data_get_int(settings, name.array) != - FEATURE_LANDMARK) { - obs_data_set_int(settings, name.array, - FEATURE_LANDMARK); + if (obs_data_get_int(settings, name.array) != FEATURE_LANDMARK) { + obs_data_set_int(settings, name.array, FEATURE_LANDMARK); nv_move_feature_changed(priv, props, feature, settings); } } - if (obs_property_visible(scene) && - !obs_property_list_item_count(scene)) { + if (obs_property_visible(scene) && !obs_property_list_item_count(scene)) { obs_property_list_add_string(scene, "", ""); obs_enum_scenes(list_add_scene, scene); } - if (obs_property_visible(source) && - !obs_property_list_item_count(source)) { + if (obs_property_visible(source) && !obs_property_list_item_count(source)) { obs_property_list_add_string(source, "", ""); obs_enum_scenes(list_add_scene, source); obs_enum_sources(list_add_scene, source); @@ -1940,14 +1467,12 @@ bool nv_move_action_changed(void *priv, obs_properties_t *props, return true; } -bool nv_move_attach_changed(void *priv, obs_properties_t *props, - obs_property_t *property, obs_data_t *settings) +bool nv_move_attach_changed(void *priv, obs_properties_t *props, obs_property_t *property, obs_data_t *settings) { const char *action_prop = obs_property_name(property); long long attach = obs_data_get_int(settings, action_prop); long long action_number = 0; - if (sscanf(action_prop, "action_%lld_attach", &action_number) != 1 || - !action_number) + if (sscanf(action_prop, "action_%lld_attach", &action_number) != 1 || !action_number) return false; struct dstr name = {0}; dstr_printf(&name, "action_%lld_action", action_number); @@ -1957,8 +1482,7 @@ bool nv_move_attach_changed(void *priv, obs_properties_t *props, } dstr_printf(&name, "action_%lld_scene", action_number); - obs_source_t *scene_source = obs_get_source_by_name( - obs_data_get_string(settings, name.array)); + obs_source_t *scene_source = obs_get_source_by_name(obs_data_get_string(settings, name.array)); if (!scene_source) { dstr_free(&name); return false; @@ -1973,8 +1497,7 @@ bool nv_move_attach_changed(void *priv, obs_properties_t *props, } dstr_printf(&name, "action_%lld_sceneitem", action_number); - obs_sceneitem_t *item = obs_scene_find_source( - scene, obs_data_get_string(settings, name.array)); + obs_sceneitem_t *item = obs_scene_find_source(scene, obs_data_get_string(settings, name.array)); dstr_free(&name); if (!item) return false; @@ -1983,8 +1506,7 @@ bool nv_move_attach_changed(void *priv, obs_properties_t *props, obs_sceneitem_set_alignment(item, OBS_ALIGN_LEFT); } else if (attach == ATTACH_RIGHT_EAR) { obs_sceneitem_set_alignment(item, OBS_ALIGN_RIGHT); - } else if (attach == ATTACH_NOSE || attach == ATTACH_UPPER_LIP || - attach == ATTACH_FOREHEAD) { + } else if (attach == ATTACH_NOSE || attach == ATTACH_UPPER_LIP || attach == ATTACH_FOREHEAD) { obs_sceneitem_set_alignment(item, OBS_ALIGN_BOTTOM); } else if (attach == ATTACH_LOWER_LIP || attach == ATTACH_JAW) { obs_sceneitem_set_alignment(item, OBS_ALIGN_TOP); @@ -1994,24 +1516,20 @@ bool nv_move_attach_changed(void *priv, obs_properties_t *props, return false; } -bool nv_move_add_sceneitems(obs_scene_t *scene, obs_sceneitem_t *sceneitem, - void *data) +bool nv_move_add_sceneitems(obs_scene_t *scene, obs_sceneitem_t *sceneitem, void *data) { obs_property_t *p = data; - const char *source_name = - obs_source_get_name(obs_sceneitem_get_source(sceneitem)); + const char *source_name = obs_source_get_name(obs_sceneitem_get_source(sceneitem)); obs_property_list_add_string(p, source_name, source_name); return true; } -bool nv_move_scene_changed(void *priv, obs_properties_t *props, - obs_property_t *property, obs_data_t *settings) +bool nv_move_scene_changed(void *priv, obs_properties_t *props, obs_property_t *property, obs_data_t *settings) { const char *action_prop = obs_property_name(property); const char *scene_name = obs_data_get_string(settings, action_prop); long long action_number = 0; - if (sscanf(action_prop, "action_%lld_scene", &action_number) != 1 || - !action_number) + if (sscanf(action_prop, "action_%lld_scene", &action_number) != 1 || !action_number) return false; struct dstr name = {0}; @@ -2042,20 +1560,15 @@ void nv_move_add_filter(obs_source_t *parent, obs_source_t *child, void *data) obs_property_list_add_string(p, source_name, source_name); } -bool nv_move_sceneitem_property_changed(void *priv, obs_properties_t *props, - obs_property_t *property, - obs_data_t *settings) +bool nv_move_sceneitem_property_changed(void *priv, obs_properties_t *props, obs_property_t *property, obs_data_t *settings) { const char *action_prop = obs_property_name(property); long long sceneitem_prop = obs_data_get_int(settings, action_prop); long long action_number = 0; - if (sscanf(action_prop, "action_%lld_sceneitem_property", - &action_number) != 1 || - !action_number) + if (sscanf(action_prop, "action_%lld_sceneitem_property", &action_number) != 1 || !action_number) return false; - bool dualprop = (sceneitem_prop == SCENEITEM_PROPERTY_POS || - sceneitem_prop == SCENEITEM_PROPERTY_SCALE); + bool dualprop = (sceneitem_prop == SCENEITEM_PROPERTY_POS || sceneitem_prop == SCENEITEM_PROPERTY_SCALE); nv_move_prop_number_floats(dualprop ? 2 : 1, action_number, props); return true; @@ -2066,28 +1579,23 @@ static void add_number_props_to_list(obs_properties_t *sp, obs_property_t *list) for (; p != NULL; obs_property_next(&p)) { if (!obs_property_visible(p)) continue; - const enum obs_property_type prop_type = - obs_property_get_type(p); - if (prop_type == OBS_PROPERTY_INT || - prop_type == OBS_PROPERTY_FLOAT) { + const enum obs_property_type prop_type = obs_property_get_type(p); + if (prop_type == OBS_PROPERTY_INT || prop_type == OBS_PROPERTY_FLOAT) { const char *n = obs_property_name(p); const char *d = obs_property_description(p); obs_property_list_add_string(list, d, n); } else if (prop_type == OBS_PROPERTY_GROUP) { - add_number_props_to_list(obs_property_group_content(p), - list); + add_number_props_to_list(obs_property_group_content(p), list); } } } -bool nv_move_filter_changed(void *priv, obs_properties_t *props, - obs_property_t *property, obs_data_t *settings) +bool nv_move_filter_changed(void *priv, obs_properties_t *props, obs_property_t *property, obs_data_t *settings) { const char *action_prop = obs_property_name(property); const char *filter_name = obs_data_get_string(settings, action_prop); long long action_number = 0; - if (sscanf(action_prop, "action_%lld_filter", &action_number) != 1 || - !action_number) + if (sscanf(action_prop, "action_%lld_filter", &action_number) != 1 || !action_number) return false; struct dstr name = {0}; @@ -2123,14 +1631,12 @@ bool nv_move_filter_changed(void *priv, obs_properties_t *props, return true; } -bool nv_move_source_changed(void *priv, obs_properties_t *props, - obs_property_t *property, obs_data_t *settings) +bool nv_move_source_changed(void *priv, obs_properties_t *props, obs_property_t *property, obs_data_t *settings) { const char *action_prop = obs_property_name(property); const char *source_name = obs_data_get_string(settings, action_prop); long long action_number = 0; - if (sscanf(action_prop, "action_%lld_source", &action_number) != 1 || - !action_number) + if (sscanf(action_prop, "action_%lld_source", &action_number) != 1 || !action_number) return false; struct dstr name = {0}; @@ -2202,28 +1708,23 @@ static void swap_setting(obs_data_t *settings, char *setting1, char *setting2) enum obs_data_type t = obs_data_item_gettype(item); if (t == OBS_DATA_STRING) { char *temp = bstrdup(obs_data_get_string(settings, setting1)); - obs_data_set_string(settings, setting1, - obs_data_get_string(settings, setting2)); + obs_data_set_string(settings, setting1, obs_data_get_string(settings, setting2)); obs_data_set_string(settings, setting2, temp); bfree(temp); } else if (t == OBS_DATA_NUMBER) { enum obs_data_number_type nt = obs_data_item_numtype(item); if (nt == OBS_DATA_NUM_INT) { long long temp = obs_data_get_int(settings, setting1); - obs_data_set_int(settings, setting1, - obs_data_get_int(settings, setting2)); + obs_data_set_int(settings, setting1, obs_data_get_int(settings, setting2)); obs_data_set_int(settings, setting2, temp); } else if (nt == OBS_DATA_NUM_DOUBLE) { double temp = obs_data_get_double(settings, setting1); - obs_data_set_double(settings, setting1, - obs_data_get_double(settings, - setting2)); + obs_data_set_double(settings, setting1, obs_data_get_double(settings, setting2)); obs_data_set_double(settings, setting2, temp); } } else if (t == OBS_DATA_BOOLEAN) { bool temp = obs_data_get_bool(settings, setting1); - obs_data_set_bool(settings, setting1, - obs_data_get_bool(settings, setting2)); + obs_data_set_bool(settings, setting1, obs_data_get_bool(settings, setting2)); obs_data_set_bool(settings, setting2, temp); } obs_data_item_release(&item); @@ -2273,14 +1774,12 @@ static void swap_action(obs_data_t *settings, long long a, long long b) dstr_free(&name2); } -static bool nv_move_move_up_clicked(obs_properties_t *props, - obs_property_t *property, void *data) +static bool nv_move_move_up_clicked(obs_properties_t *props, obs_property_t *property, void *data) { struct nvidia_move_info *filter = (struct nvidia_move_info *)data; const char *action_prop = obs_property_name(property); long long action_number = 0; - if (sscanf(action_prop, "action_%lld_move_up", &action_number) != 1 || - action_number <= 1) + if (sscanf(action_prop, "action_%lld_move_up", &action_number) != 1 || action_number <= 1) return false; obs_data_t *settings = obs_source_get_settings(filter->source); swap_action(settings, action_number, action_number - 1); @@ -2288,20 +1787,18 @@ static bool nv_move_move_up_clicked(obs_properties_t *props, if (show == action_number) { obs_data_set_int(settings, "show", show - 1); } - nv_move_actions_changed(data, props, - obs_properties_get(props, "actions"), settings); + nv_move_actions_changed(data, props, obs_properties_get(props, "actions"), settings); obs_data_release(settings); return true; } -static bool nv_move_move_down_clicked(obs_properties_t *props, - obs_property_t *property, void *data) +static bool nv_move_move_down_clicked(obs_properties_t *props, obs_property_t *property, void *data) { struct nvidia_move_info *filter = (struct nvidia_move_info *)data; const char *action_prop = obs_property_name(property); long long action_number = 0; - if (sscanf(action_prop, "action_%lld_move_down", &action_number) != 1 || - !action_number || action_number >= (long long)filter->actions.num) + if (sscanf(action_prop, "action_%lld_move_down", &action_number) != 1 || !action_number || + action_number >= (long long)filter->actions.num) return false; obs_data_t *settings = obs_source_get_settings(filter->source); @@ -2310,31 +1807,24 @@ static bool nv_move_move_down_clicked(obs_properties_t *props, if (show == action_number) { obs_data_set_int(settings, "show", show + 1); } - nv_move_actions_changed(data, props, - obs_properties_get(props, "actions"), settings); + nv_move_actions_changed(data, props, obs_properties_get(props, "actions"), settings); obs_data_release(settings); return true; } -static bool nv_move_get_value_clicked(obs_properties_t *props, - obs_property_t *property, void *data) +static bool nv_move_get_value_clicked(obs_properties_t *props, obs_property_t *property, void *data) { struct nvidia_move_info *filter = (struct nvidia_move_info *)data; const char *action_prop = obs_property_name(property); long long action_number = 0; - if (sscanf(action_prop, "action_%lld_get_value", &action_number) != 1 || - !action_number) + if (sscanf(action_prop, "action_%lld_get_value", &action_number) != 1 || !action_number) return false; float value; struct vec2 vec2; struct dstr description = {0}; - if (nv_move_action_get_vec2(filter, - filter->actions.array + action_number - 1, - false, &vec2)) { + if (nv_move_action_get_vec2(filter, filter->actions.array + action_number - 1, false, &vec2)) { dstr_printf(&description, "%f : %f", vec2.x, vec2.y); - } else if (nv_move_action_get_float( - filter, filter->actions.array + action_number - 1, - false, &value)) { + } else if (nv_move_action_get_float(filter, filter->actions.array + action_number - 1, false, &value)) { dstr_printf(&description, "%f", value); } else { dstr_copy(&description, obs_module_text("Error")); @@ -2442,21 +1932,15 @@ static obs_properties_t *nv_move_properties(void *data) obs_properties_t *props = obs_properties_create(); if (filter && filter->last_error) { - obs_property_text_set_info_type( - obs_properties_add_text(props, "last_error", - filter->last_error, - OBS_TEXT_INFO), - OBS_TEXT_INFO_WARNING); + obs_property_text_set_info_type(obs_properties_add_text(props, "last_error", filter->last_error, OBS_TEXT_INFO), + OBS_TEXT_INFO_WARNING); } - obs_property_t *p = obs_properties_add_int(props, "actions", - obs_module_text("Actions"), - 1, MAX_ACTIONS, 1); + obs_property_t *p = obs_properties_add_int(props, "actions", obs_module_text("Actions"), 1, MAX_ACTIONS, 1); obs_property_set_modified_callback2(p, nv_move_actions_changed, data); - p = obs_properties_add_list(props, "show", obs_module_text("Show"), - OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); + p = obs_properties_add_list(props, "show", obs_module_text("Show"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); obs_property_list_add_int(p, obs_module_text("All"), 0); @@ -2467,511 +1951,287 @@ static obs_properties_t *nv_move_properties(void *data) for (long long i = 1; i <= MAX_ACTIONS; i++) { obs_properties_t *group = obs_properties_create(); dstr_printf(&name, "action_%lld_disabled", i); - obs_properties_add_bool(group, name.array, - obs_module_text("Disabled")); + obs_properties_add_bool(group, name.array, obs_module_text("Disabled")); dstr_printf(&name, "action_%lld_description", i); - obs_properties_add_text(group, name.array, - obs_module_text("ActionDescription"), - OBS_TEXT_DEFAULT); + obs_properties_add_text(group, name.array, obs_module_text("ActionDescription"), OBS_TEXT_DEFAULT); dstr_printf(&name, "action_%lld_action", i); - p = obs_properties_add_list(group, name.array, - obs_module_text("Action"), - OBS_COMBO_TYPE_LIST, + p = obs_properties_add_list(group, name.array, obs_module_text("Action"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); - obs_property_list_add_int(p, obs_module_text("MoveSource"), - ACTION_MOVE_SOURCE); - obs_property_list_add_int(p, obs_module_text("MoveValue"), - ACTION_MOVE_VALUE); - obs_property_list_add_int(p, obs_module_text("FilterEnable"), - ACTION_ENABLE_FILTER); - obs_property_list_add_int(p, - obs_module_text("SourceVisibility"), - ACTION_SOURCE_VISIBILITY); - obs_property_list_add_int(p, obs_module_text("AttachSource"), - ACTION_ATTACH_SOURCE); - - obs_property_set_modified_callback2(p, nv_move_action_changed, - data); + obs_property_list_add_int(p, obs_module_text("MoveSource"), ACTION_MOVE_SOURCE); + obs_property_list_add_int(p, obs_module_text("MoveValue"), ACTION_MOVE_VALUE); + obs_property_list_add_int(p, obs_module_text("FilterEnable"), ACTION_ENABLE_FILTER); + obs_property_list_add_int(p, obs_module_text("SourceVisibility"), ACTION_SOURCE_VISIBILITY); + obs_property_list_add_int(p, obs_module_text("AttachSource"), ACTION_ATTACH_SOURCE); + + obs_property_set_modified_callback2(p, nv_move_action_changed, data); dstr_printf(&name, "action_%lld_attach", i); - p = obs_properties_add_list(group, name.array, - obs_module_text("Attach"), - OBS_COMBO_TYPE_LIST, + p = obs_properties_add_list(group, name.array, obs_module_text("Attach"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); - obs_property_list_add_int(p, obs_module_text("Eyes"), - ATTACH_EYES); - obs_property_list_add_int(p, obs_module_text("LeftEye"), - ATTACH_LEFT_EYE); - obs_property_list_add_int(p, obs_module_text("RightEye"), - ATTACH_RIGHT_EYE); - obs_property_list_add_int(p, obs_module_text("Eyebrows"), - ATTACH_EYEBROWS); - obs_property_list_add_int(p, obs_module_text("LeftEyebrow"), - ATTACH_LEFT_EYEBROW); - obs_property_list_add_int(p, obs_module_text("RightEyebrow"), - ATTACH_RIGHT_EYEBROW); - obs_property_list_add_int(p, obs_module_text("Ears"), - ATTACH_EARS); - obs_property_list_add_int(p, obs_module_text("LeftEar"), - ATTACH_LEFT_EAR); - obs_property_list_add_int(p, obs_module_text("RightEar"), - ATTACH_RIGHT_EAR); - obs_property_list_add_int(p, obs_module_text("Nose"), - ATTACH_NOSE); - obs_property_list_add_int(p, obs_module_text("Mouth"), - ATTACH_MOUTH); - obs_property_list_add_int(p, obs_module_text("UpperLip"), - ATTACH_UPPER_LIP); - obs_property_list_add_int(p, obs_module_text("LowerLip"), - ATTACH_LOWER_LIP); - obs_property_list_add_int(p, obs_module_text("Chin"), - ATTACH_CHIN); - obs_property_list_add_int(p, obs_module_text("Jaw"), - ATTACH_JAW); - obs_property_list_add_int(p, obs_module_text("Forehead"), - ATTACH_FOREHEAD); - - obs_property_set_modified_callback2(p, nv_move_attach_changed, - data); + obs_property_list_add_int(p, obs_module_text("Eyes"), ATTACH_EYES); + obs_property_list_add_int(p, obs_module_text("LeftEye"), ATTACH_LEFT_EYE); + obs_property_list_add_int(p, obs_module_text("RightEye"), ATTACH_RIGHT_EYE); + obs_property_list_add_int(p, obs_module_text("Eyebrows"), ATTACH_EYEBROWS); + obs_property_list_add_int(p, obs_module_text("LeftEyebrow"), ATTACH_LEFT_EYEBROW); + obs_property_list_add_int(p, obs_module_text("RightEyebrow"), ATTACH_RIGHT_EYEBROW); + obs_property_list_add_int(p, obs_module_text("Ears"), ATTACH_EARS); + obs_property_list_add_int(p, obs_module_text("LeftEar"), ATTACH_LEFT_EAR); + obs_property_list_add_int(p, obs_module_text("RightEar"), ATTACH_RIGHT_EAR); + obs_property_list_add_int(p, obs_module_text("Nose"), ATTACH_NOSE); + obs_property_list_add_int(p, obs_module_text("Mouth"), ATTACH_MOUTH); + obs_property_list_add_int(p, obs_module_text("UpperLip"), ATTACH_UPPER_LIP); + obs_property_list_add_int(p, obs_module_text("LowerLip"), ATTACH_LOWER_LIP); + obs_property_list_add_int(p, obs_module_text("Chin"), ATTACH_CHIN); + obs_property_list_add_int(p, obs_module_text("Jaw"), ATTACH_JAW); + obs_property_list_add_int(p, obs_module_text("Forehead"), ATTACH_FOREHEAD); + + obs_property_set_modified_callback2(p, nv_move_attach_changed, data); dstr_printf(&name, "action_%lld_scene", i); - p = obs_properties_add_list(group, name.array, - obs_module_text("Scene"), - OBS_COMBO_TYPE_EDITABLE, + p = obs_properties_add_list(group, name.array, obs_module_text("Scene"), OBS_COMBO_TYPE_EDITABLE, OBS_COMBO_FORMAT_STRING); - obs_property_set_modified_callback2(p, nv_move_scene_changed, - data); + obs_property_set_modified_callback2(p, nv_move_scene_changed, data); dstr_printf(&name, "action_%lld_sceneitem", i); - p = obs_properties_add_list(group, name.array, - obs_module_text("Source"), - OBS_COMBO_TYPE_EDITABLE, + p = obs_properties_add_list(group, name.array, obs_module_text("Source"), OBS_COMBO_TYPE_EDITABLE, OBS_COMBO_FORMAT_STRING); dstr_printf(&name, "action_%lld_source", i); - p = obs_properties_add_list(group, name.array, - obs_module_text("Source"), - OBS_COMBO_TYPE_EDITABLE, + p = obs_properties_add_list(group, name.array, obs_module_text("Source"), OBS_COMBO_TYPE_EDITABLE, OBS_COMBO_FORMAT_STRING); - obs_property_set_modified_callback2(p, nv_move_source_changed, - data); + obs_property_set_modified_callback2(p, nv_move_source_changed, data); dstr_printf(&name, "action_%lld_filter", i); - p = obs_properties_add_list(group, name.array, - obs_module_text("Filter"), - OBS_COMBO_TYPE_EDITABLE, + p = obs_properties_add_list(group, name.array, obs_module_text("Filter"), OBS_COMBO_TYPE_EDITABLE, OBS_COMBO_FORMAT_STRING); - obs_property_set_modified_callback2(p, nv_move_filter_changed, - data); + obs_property_set_modified_callback2(p, nv_move_filter_changed, data); dstr_printf(&name, "action_%lld_property", i); - p = obs_properties_add_list(group, name.array, - obs_module_text("Property"), - OBS_COMBO_TYPE_LIST, + p = obs_properties_add_list(group, name.array, obs_module_text("Property"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING); dstr_printf(&name, "action_%lld_sceneitem_property", i); - p = obs_properties_add_list(group, name.array, - obs_module_text("Property"), - OBS_COMBO_TYPE_LIST, + p = obs_properties_add_list(group, name.array, obs_module_text("Property"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); - obs_property_list_item_disable( - p, - obs_property_list_add_int(p, obs_module_text("All"), - SCENEITEM_PROPERTY_ALL), - true); - - obs_property_list_add_int(p, obs_module_text("Pos"), - SCENEITEM_PROPERTY_POS); - obs_property_list_add_int(p, obs_module_text("PosX"), - SCENEITEM_PROPERTY_POSX); - obs_property_list_add_int(p, obs_module_text("PosY"), - SCENEITEM_PROPERTY_POSY); - obs_property_list_add_int(p, obs_module_text("Scale"), - SCENEITEM_PROPERTY_SCALE); - obs_property_list_add_int(p, obs_module_text("ScaleX"), - SCENEITEM_PROPERTY_SCALEX); - obs_property_list_add_int(p, obs_module_text("ScaleY"), - SCENEITEM_PROPERTY_SCALEY); - obs_property_list_add_int(p, obs_module_text("Rotation"), - SCENEITEM_PROPERTY_ROT); - obs_property_list_add_int(p, obs_module_text("CropLeft"), - SCENEITEM_PROPERTY_CROP_LEFT); - obs_property_list_add_int(p, obs_module_text("CropTop"), - SCENEITEM_PROPERTY_CROP_TOP); - obs_property_list_add_int(p, obs_module_text("CropRight"), - SCENEITEM_PROPERTY_CROP_RIGHT); - obs_property_list_add_int(p, obs_module_text("CropBottom"), - SCENEITEM_PROPERTY_CROP_BOTTOM); - - obs_property_set_modified_callback2( - p, nv_move_sceneitem_property_changed, data); + obs_property_list_item_disable(p, obs_property_list_add_int(p, obs_module_text("All"), SCENEITEM_PROPERTY_ALL), + true); + + obs_property_list_add_int(p, obs_module_text("Pos"), SCENEITEM_PROPERTY_POS); + obs_property_list_add_int(p, obs_module_text("PosX"), SCENEITEM_PROPERTY_POSX); + obs_property_list_add_int(p, obs_module_text("PosY"), SCENEITEM_PROPERTY_POSY); + obs_property_list_add_int(p, obs_module_text("Scale"), SCENEITEM_PROPERTY_SCALE); + obs_property_list_add_int(p, obs_module_text("ScaleX"), SCENEITEM_PROPERTY_SCALEX); + obs_property_list_add_int(p, obs_module_text("ScaleY"), SCENEITEM_PROPERTY_SCALEY); + obs_property_list_add_int(p, obs_module_text("Rotation"), SCENEITEM_PROPERTY_ROT); + obs_property_list_add_int(p, obs_module_text("CropLeft"), SCENEITEM_PROPERTY_CROP_LEFT); + obs_property_list_add_int(p, obs_module_text("CropTop"), SCENEITEM_PROPERTY_CROP_TOP); + obs_property_list_add_int(p, obs_module_text("CropRight"), SCENEITEM_PROPERTY_CROP_RIGHT); + obs_property_list_add_int(p, obs_module_text("CropBottom"), SCENEITEM_PROPERTY_CROP_BOTTOM); + + obs_property_set_modified_callback2(p, nv_move_sceneitem_property_changed, data); dstr_printf(&name, "action_%lld_enable", i); - p = obs_properties_add_list(group, name.array, - obs_module_text("Enable"), - OBS_COMBO_TYPE_LIST, + p = obs_properties_add_list(group, name.array, obs_module_text("Enable"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); obs_property_list_item_disable( - p, - obs_property_list_add_int( - p, obs_module_text("ThresholdAction.None"), - FEATURE_THRESHOLD_NONE), - true); - obs_property_list_add_int( - p, obs_module_text("ThresholdAction.EnableOver"), - FEATURE_THRESHOLD_ENABLE_OVER); - obs_property_list_add_int( - p, obs_module_text("ThresholdAction.EnableUnder"), - FEATURE_THRESHOLD_ENABLE_UNDER); - obs_property_list_add_int( - p, obs_module_text("ThresholdAction.DisableOver"), - FEATURE_THRESHOLD_DISABLE_OVER); - obs_property_list_add_int( - p, obs_module_text("ThresholdAction.DisableUnder"), - FEATURE_THRESHOLD_DISABLE_UNDER); - obs_property_list_add_int( - p, - obs_module_text( - "ThresholdAction.EnableOverDisableUnder"), - FEATURE_THRESHOLD_ENABLE_OVER_DISABLE_UNDER); - obs_property_list_add_int( - p, - obs_module_text( - "ThresholdAction.EnableUnderDisableOver"), - FEATURE_THRESHOLD_ENABLE_UNDER_DISABLE_OVER); + p, obs_property_list_add_int(p, obs_module_text("ThresholdAction.None"), FEATURE_THRESHOLD_NONE), true); + obs_property_list_add_int(p, obs_module_text("ThresholdAction.EnableOver"), FEATURE_THRESHOLD_ENABLE_OVER); + obs_property_list_add_int(p, obs_module_text("ThresholdAction.EnableUnder"), FEATURE_THRESHOLD_ENABLE_UNDER); + obs_property_list_add_int(p, obs_module_text("ThresholdAction.DisableOver"), FEATURE_THRESHOLD_DISABLE_OVER); + obs_property_list_add_int(p, obs_module_text("ThresholdAction.DisableUnder"), FEATURE_THRESHOLD_DISABLE_UNDER); + obs_property_list_add_int(p, obs_module_text("ThresholdAction.EnableOverDisableUnder"), + FEATURE_THRESHOLD_ENABLE_OVER_DISABLE_UNDER); + obs_property_list_add_int(p, obs_module_text("ThresholdAction.EnableUnderDisableOver"), + FEATURE_THRESHOLD_ENABLE_UNDER_DISABLE_OVER); dstr_printf(&name, "action_%lld_feature", i); - p = obs_properties_add_list(group, name.array, - obs_module_text("Feature"), - OBS_COMBO_TYPE_LIST, + p = obs_properties_add_list(group, name.array, obs_module_text("Feature"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); - obs_property_list_add_int(p, obs_module_text("BoundingBox"), - FEATURE_BOUNDINGBOX); - obs_property_list_add_int(p, obs_module_text("Landmark"), - FEATURE_LANDMARK); - obs_property_list_add_int(p, obs_module_text("Pose"), - FEATURE_POSE); - obs_property_list_add_int(p, obs_module_text("Expression"), - FEATURE_EXPRESSION); - obs_property_list_add_int(p, obs_module_text("Gaze"), - FEATURE_GAZE); - obs_property_list_add_int(p, obs_module_text("Body"), - FEATURE_BODY); - - obs_property_set_modified_callback2(p, nv_move_feature_changed, - data); + obs_property_list_add_int(p, obs_module_text("BoundingBox"), FEATURE_BOUNDINGBOX); + obs_property_list_add_int(p, obs_module_text("Landmark"), FEATURE_LANDMARK); + obs_property_list_add_int(p, obs_module_text("Pose"), FEATURE_POSE); + obs_property_list_add_int(p, obs_module_text("Expression"), FEATURE_EXPRESSION); + obs_property_list_add_int(p, obs_module_text("Gaze"), FEATURE_GAZE); + obs_property_list_add_int(p, obs_module_text("Body"), FEATURE_BODY); + + obs_property_set_modified_callback2(p, nv_move_feature_changed, data); dstr_printf(&name, "action_%lld_bounding_box", i); - p = obs_properties_add_list( - group, name.array, - obs_module_text("BoundingBoxProperty"), - OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); - obs_property_list_add_int(p, obs_module_text("Left"), - FEATURE_BOUNDINGBOX_LEFT); - obs_property_list_add_int( - p, obs_module_text("HorizontalCenter"), - FEATURE_BOUNDINGBOX_HORIZONTAL_CENTER); - obs_property_list_add_int(p, obs_module_text("Right"), - FEATURE_BOUNDINGBOX_RIGHT); - obs_property_list_add_int(p, obs_module_text("Width"), - FEATURE_BOUNDINGBOX_WIDTH); - obs_property_list_add_int(p, obs_module_text("Top"), - FEATURE_BOUNDINGBOX_TOP); - obs_property_list_add_int(p, obs_module_text("VerticalCenter"), - FEATURE_BOUNDINGBOX_VERTICAL_CENTER); - obs_property_list_add_int(p, obs_module_text("Bottom"), - FEATURE_BOUNDINGBOX_BOTOM); - obs_property_list_add_int(p, obs_module_text("Height"), - FEATURE_BOUNDINGBOX_HEIGHT); - obs_property_list_add_int(p, obs_module_text("TopLeft"), - FEATURE_BOUNDINGBOX_TOP_LEFT); - obs_property_list_add_int(p, obs_module_text("TopCenter"), - FEATURE_BOUNDINGBOX_TOP_CENTER); - obs_property_list_add_int(p, obs_module_text("TopRight"), - FEATURE_BOUNDINGBOX_TOP_RIGHT); - obs_property_list_add_int(p, obs_module_text("CenterRight"), - FEATURE_BOUNDINGBOX_CENTER_RIGHT); - obs_property_list_add_int(p, obs_module_text("BottomRight"), - FEATURE_BOUNDINGBOX_BOTTOM_RIGHT); - obs_property_list_add_int(p, obs_module_text("BottomCenter"), - FEATURE_BOUNDINGBOX_BOTTOM_CENTER); - obs_property_list_add_int(p, obs_module_text("BottomLeft"), - FEATURE_BOUNDINGBOX_BOTTOM_LEFT); - obs_property_list_add_int(p, obs_module_text("CenterLeft"), - FEATURE_BOUNDINGBOX_CENTER_LEFT); - obs_property_list_add_int(p, obs_module_text("Center"), - FEATURE_BOUNDINGBOX_CENTER); - obs_property_list_add_int(p, obs_module_text("Size"), - FEATURE_BOUNDINGBOX_SIZE); + p = obs_properties_add_list(group, name.array, obs_module_text("BoundingBoxProperty"), OBS_COMBO_TYPE_LIST, + OBS_COMBO_FORMAT_INT); + obs_property_list_add_int(p, obs_module_text("Left"), FEATURE_BOUNDINGBOX_LEFT); + obs_property_list_add_int(p, obs_module_text("HorizontalCenter"), FEATURE_BOUNDINGBOX_HORIZONTAL_CENTER); + obs_property_list_add_int(p, obs_module_text("Right"), FEATURE_BOUNDINGBOX_RIGHT); + obs_property_list_add_int(p, obs_module_text("Width"), FEATURE_BOUNDINGBOX_WIDTH); + obs_property_list_add_int(p, obs_module_text("Top"), FEATURE_BOUNDINGBOX_TOP); + obs_property_list_add_int(p, obs_module_text("VerticalCenter"), FEATURE_BOUNDINGBOX_VERTICAL_CENTER); + obs_property_list_add_int(p, obs_module_text("Bottom"), FEATURE_BOUNDINGBOX_BOTOM); + obs_property_list_add_int(p, obs_module_text("Height"), FEATURE_BOUNDINGBOX_HEIGHT); + obs_property_list_add_int(p, obs_module_text("TopLeft"), FEATURE_BOUNDINGBOX_TOP_LEFT); + obs_property_list_add_int(p, obs_module_text("TopCenter"), FEATURE_BOUNDINGBOX_TOP_CENTER); + obs_property_list_add_int(p, obs_module_text("TopRight"), FEATURE_BOUNDINGBOX_TOP_RIGHT); + obs_property_list_add_int(p, obs_module_text("CenterRight"), FEATURE_BOUNDINGBOX_CENTER_RIGHT); + obs_property_list_add_int(p, obs_module_text("BottomRight"), FEATURE_BOUNDINGBOX_BOTTOM_RIGHT); + obs_property_list_add_int(p, obs_module_text("BottomCenter"), FEATURE_BOUNDINGBOX_BOTTOM_CENTER); + obs_property_list_add_int(p, obs_module_text("BottomLeft"), FEATURE_BOUNDINGBOX_BOTTOM_LEFT); + obs_property_list_add_int(p, obs_module_text("CenterLeft"), FEATURE_BOUNDINGBOX_CENTER_LEFT); + obs_property_list_add_int(p, obs_module_text("Center"), FEATURE_BOUNDINGBOX_CENTER); + obs_property_list_add_int(p, obs_module_text("Size"), FEATURE_BOUNDINGBOX_SIZE); dstr_printf(&name, "action_%lld_landmark", i); - p = obs_properties_add_list(group, name.array, - obs_module_text("LandmarkProperty"), - OBS_COMBO_TYPE_LIST, + p = obs_properties_add_list(group, name.array, obs_module_text("LandmarkProperty"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); - obs_property_list_add_int(p, obs_module_text("PosX"), - FEATURE_LANDMARK_X); - obs_property_list_add_int(p, obs_module_text("PosY"), - FEATURE_LANDMARK_Y); - obs_property_list_add_int(p, obs_module_text("Confidence"), - FEATURE_LANDMARK_CONFIDENCE); - obs_property_list_add_int(p, obs_module_text("Distance"), - FEATURE_LANDMARK_DISTANCE); - obs_property_list_add_int(p, obs_module_text("DiffX"), - FEATURE_LANDMARK_DIFF_X); - obs_property_list_add_int(p, obs_module_text("DiffY"), - FEATURE_LANDMARK_DIFF_Y); - obs_property_list_add_int(p, obs_module_text("Rotation"), - FEATURE_LANDMARK_ROT); - obs_property_list_add_int(p, obs_module_text("Difference"), - FEATURE_LANDMARK_DIFF); - obs_property_list_add_int(p, obs_module_text("Position"), - FEATURE_LANDMARK_POS); - - obs_property_set_modified_callback2(p, nv_move_landmark_changed, - data); + obs_property_list_add_int(p, obs_module_text("PosX"), FEATURE_LANDMARK_X); + obs_property_list_add_int(p, obs_module_text("PosY"), FEATURE_LANDMARK_Y); + obs_property_list_add_int(p, obs_module_text("Confidence"), FEATURE_LANDMARK_CONFIDENCE); + obs_property_list_add_int(p, obs_module_text("Distance"), FEATURE_LANDMARK_DISTANCE); + obs_property_list_add_int(p, obs_module_text("DiffX"), FEATURE_LANDMARK_DIFF_X); + obs_property_list_add_int(p, obs_module_text("DiffY"), FEATURE_LANDMARK_DIFF_Y); + obs_property_list_add_int(p, obs_module_text("Rotation"), FEATURE_LANDMARK_ROT); + obs_property_list_add_int(p, obs_module_text("Difference"), FEATURE_LANDMARK_DIFF); + obs_property_list_add_int(p, obs_module_text("Position"), FEATURE_LANDMARK_POS); + + obs_property_set_modified_callback2(p, nv_move_landmark_changed, data); dstr_printf(&name, "action_%lld_landmark_1", i); - obs_properties_add_int_slider(group, name.array, - obs_module_text("Landmark"), 1, - (int)filter->landmarks.num, 1); + obs_properties_add_int_slider(group, name.array, obs_module_text("Landmark"), 1, (int)filter->landmarks.num, 1); dstr_printf(&name, "action_%lld_landmark_2", i); - obs_properties_add_int_slider(group, name.array, - obs_module_text("Landmark"), 1, - (int)filter->landmarks.num, 1); + obs_properties_add_int_slider(group, name.array, obs_module_text("Landmark"), 1, (int)filter->landmarks.num, 1); dstr_printf(&name, "action_%lld_pose", i); - p = obs_properties_add_list(group, name.array, - obs_module_text("PoseProperty"), - OBS_COMBO_TYPE_LIST, + p = obs_properties_add_list(group, name.array, obs_module_text("PoseProperty"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); - obs_property_list_add_int(p, obs_module_text("PoseX"), - FEATURE_POSE_X); - obs_property_list_add_int(p, obs_module_text("PoseY"), - FEATURE_POSE_Y); - obs_property_list_add_int(p, obs_module_text("PoseZ"), - FEATURE_POSE_Z); - obs_property_list_add_int(p, obs_module_text("PoseW"), - FEATURE_POSE_W); + obs_property_list_add_int(p, obs_module_text("PoseX"), FEATURE_POSE_X); + obs_property_list_add_int(p, obs_module_text("PoseY"), FEATURE_POSE_Y); + obs_property_list_add_int(p, obs_module_text("PoseZ"), FEATURE_POSE_Z); + obs_property_list_add_int(p, obs_module_text("PoseW"), FEATURE_POSE_W); dstr_printf(&name, "action_%lld_expression_property", i); - p = obs_properties_add_list( - group, name.array, - obs_module_text("ExpressionProperty"), - OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); - obs_property_list_add_int(p, obs_module_text("Single"), - FEATURE_EXPRESSION_SINGLE); - obs_property_list_add_int(p, obs_module_text("Vector"), - FEATURE_EXPRESSION_VECTOR); - obs_property_list_add_int(p, obs_module_text("Add"), - FEATURE_EXPRESSION_ADD); - obs_property_list_add_int(p, obs_module_text("Substract"), - FEATURE_EXPRESSION_SUBSTRACT); - obs_property_list_add_int(p, obs_module_text("Distance"), - FEATURE_EXPRESSION_DISTANCE); - obs_property_list_add_int(p, obs_module_text("Average"), - FEATURE_EXPRESSION_AVG); - - obs_property_set_modified_callback2( - p, nv_move_expression_changed, data); + p = obs_properties_add_list(group, name.array, obs_module_text("ExpressionProperty"), OBS_COMBO_TYPE_LIST, + OBS_COMBO_FORMAT_INT); + obs_property_list_add_int(p, obs_module_text("Single"), FEATURE_EXPRESSION_SINGLE); + obs_property_list_add_int(p, obs_module_text("Vector"), FEATURE_EXPRESSION_VECTOR); + obs_property_list_add_int(p, obs_module_text("Add"), FEATURE_EXPRESSION_ADD); + obs_property_list_add_int(p, obs_module_text("Substract"), FEATURE_EXPRESSION_SUBSTRACT); + obs_property_list_add_int(p, obs_module_text("Distance"), FEATURE_EXPRESSION_DISTANCE); + obs_property_list_add_int(p, obs_module_text("Average"), FEATURE_EXPRESSION_AVG); + + obs_property_set_modified_callback2(p, nv_move_expression_changed, data); dstr_printf(&name, "action_%lld_expression_1", i); - p = obs_properties_add_list(group, name.array, - obs_module_text("Expression"), - OBS_COMBO_TYPE_LIST, + p = obs_properties_add_list(group, name.array, obs_module_text("Expression"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); add_expressions_to_list(p); dstr_printf(&name, "action_%lld_expression_2", i); - p = obs_properties_add_list(group, name.array, - obs_module_text("Expression"), - OBS_COMBO_TYPE_LIST, + p = obs_properties_add_list(group, name.array, obs_module_text("Expression"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); add_expressions_to_list(p); dstr_printf(&name, "action_%lld_gaze", i); - p = obs_properties_add_list(group, name.array, - obs_module_text("GazeProperty"), - OBS_COMBO_TYPE_LIST, + p = obs_properties_add_list(group, name.array, obs_module_text("GazeProperty"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); - obs_property_list_add_int(p, obs_module_text("Vector"), - FEATURE_GAZE_VECTOR); - obs_property_list_add_int(p, obs_module_text("VectorPitch"), - FEATURE_GAZE_VECTOR_PITCH); - obs_property_list_add_int(p, obs_module_text("VectorYaw"), - FEATURE_GAZE_VECTOR_YAW); - obs_property_list_add_int(p, obs_module_text("HeadTranslation"), - FEATURE_GAZE_HEADTRANSLATION); - obs_property_list_add_int(p, - obs_module_text("HeadTranslationX"), - FEATURE_GAZE_HEADTRANSLATION_X); - obs_property_list_add_int(p, - obs_module_text("HeadTranslationY"), - FEATURE_GAZE_HEADTRANSLATION_Y); - obs_property_list_add_int(p, - obs_module_text("HeadTranslationZ"), - FEATURE_GAZE_HEADTRANSLATION_Z); - obs_property_list_add_int(p, obs_module_text("CenterPoint"), - FEATURE_GAZE_DIRECTION_CENTER_POINT); - obs_property_list_add_int( - p, obs_module_text("CenterPointX"), - FEATURE_GAZE_DIRECTION_CENTER_POINT_X); - obs_property_list_add_int( - p, obs_module_text("CenterPointY"), - FEATURE_GAZE_DIRECTION_CENTER_POINT_Y); - obs_property_list_add_int( - p, obs_module_text("CenterPointZ"), - FEATURE_GAZE_DIRECTION_CENTER_POINT_Z); - obs_property_list_add_int(p, obs_module_text("DirectionVector"), - FEATURE_GAZE_DIRECTION_VECTOR); - obs_property_list_add_int(p, - obs_module_text("DirectionVectorX"), - FEATURE_GAZE_DIRECTION_VECTOR_X); - obs_property_list_add_int(p, - obs_module_text("DirectionVectorY"), - FEATURE_GAZE_DIRECTION_VECTOR_Y); - obs_property_list_add_int(p, - obs_module_text("DirectionVectorZ"), - FEATURE_GAZE_DIRECTION_VECTOR_Z); + obs_property_list_add_int(p, obs_module_text("Vector"), FEATURE_GAZE_VECTOR); + obs_property_list_add_int(p, obs_module_text("VectorPitch"), FEATURE_GAZE_VECTOR_PITCH); + obs_property_list_add_int(p, obs_module_text("VectorYaw"), FEATURE_GAZE_VECTOR_YAW); + obs_property_list_add_int(p, obs_module_text("HeadTranslation"), FEATURE_GAZE_HEADTRANSLATION); + obs_property_list_add_int(p, obs_module_text("HeadTranslationX"), FEATURE_GAZE_HEADTRANSLATION_X); + obs_property_list_add_int(p, obs_module_text("HeadTranslationY"), FEATURE_GAZE_HEADTRANSLATION_Y); + obs_property_list_add_int(p, obs_module_text("HeadTranslationZ"), FEATURE_GAZE_HEADTRANSLATION_Z); + obs_property_list_add_int(p, obs_module_text("CenterPoint"), FEATURE_GAZE_DIRECTION_CENTER_POINT); + obs_property_list_add_int(p, obs_module_text("CenterPointX"), FEATURE_GAZE_DIRECTION_CENTER_POINT_X); + obs_property_list_add_int(p, obs_module_text("CenterPointY"), FEATURE_GAZE_DIRECTION_CENTER_POINT_Y); + obs_property_list_add_int(p, obs_module_text("CenterPointZ"), FEATURE_GAZE_DIRECTION_CENTER_POINT_Z); + obs_property_list_add_int(p, obs_module_text("DirectionVector"), FEATURE_GAZE_DIRECTION_VECTOR); + obs_property_list_add_int(p, obs_module_text("DirectionVectorX"), FEATURE_GAZE_DIRECTION_VECTOR_X); + obs_property_list_add_int(p, obs_module_text("DirectionVectorY"), FEATURE_GAZE_DIRECTION_VECTOR_Y); + obs_property_list_add_int(p, obs_module_text("DirectionVectorZ"), FEATURE_GAZE_DIRECTION_VECTOR_Z); dstr_printf(&name, "action_%lld_body", i); - p = obs_properties_add_list(group, name.array, - obs_module_text("BodyProperty"), - OBS_COMBO_TYPE_LIST, + p = obs_properties_add_list(group, name.array, obs_module_text("BodyProperty"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); - obs_property_list_add_int(p, obs_module_text("Confidence"), - BODY_CONFIDENCE); - obs_property_list_add_int(p, obs_module_text("Body2DPosX"), - BODY_2D_POSX); - obs_property_list_add_int(p, obs_module_text("Body2DPosY"), - BODY_2D_POSY); - obs_property_list_add_int(p, obs_module_text("Body2DDistance"), - BODY_2D_DISTANCE); - obs_property_list_add_int(p, obs_module_text("Body2DRotation"), - BODY_2D_ROT); - obs_property_list_add_int(p, obs_module_text("Body2DDiffX"), - BODY_2D_DIFF_X); - obs_property_list_add_int(p, obs_module_text("Body2DDiffY"), - BODY_2D_DIFF_Y); - obs_property_list_add_int(p, obs_module_text("Body2DDiff"), - BODY_2D_DIFF); - obs_property_list_add_int(p, obs_module_text("Body2DPos"), - BODY_2D_POS); - obs_property_list_add_int(p, obs_module_text("Body3DPosX"), - BODY_3D_POSX); - obs_property_list_add_int(p, obs_module_text("Body3DPosY"), - BODY_3D_POSY); - obs_property_list_add_int(p, obs_module_text("Body3DPosZ"), - BODY_3D_POSZ); - obs_property_list_add_int(p, obs_module_text("Body3DDistance"), - BODY_3D_DISTANCE); - obs_property_list_add_int(p, obs_module_text("Body3DDiffX"), - BODY_3D_DIFF_X); - obs_property_list_add_int(p, obs_module_text("Body3DDiffY"), - BODY_3D_DIFF_Y); - obs_property_list_add_int(p, obs_module_text("Body3DDiffZ"), - BODY_3D_DIFF_Z); - obs_property_list_add_int(p, obs_module_text("Body3DPos"), - BODY_3D_POS); - obs_property_list_add_int(p, obs_module_text("Body3DDiff"), - BODY_3D_DIFF); - obs_property_list_add_int(p, obs_module_text("BodyAngleX"), - BODY_ANGLE_X); - obs_property_list_add_int(p, obs_module_text("BodyAngleY"), - BODY_ANGLE_Y); - obs_property_list_add_int(p, obs_module_text("BodyAngleZ"), - BODY_ANGLE_Z); - obs_property_list_add_int(p, obs_module_text("BodyAngle"), - BODY_ANGLE); - - obs_property_set_modified_callback2(p, nv_move_body_changed, - data); + obs_property_list_add_int(p, obs_module_text("Confidence"), BODY_CONFIDENCE); + obs_property_list_add_int(p, obs_module_text("Body2DPosX"), BODY_2D_POSX); + obs_property_list_add_int(p, obs_module_text("Body2DPosY"), BODY_2D_POSY); + obs_property_list_add_int(p, obs_module_text("Body2DDistance"), BODY_2D_DISTANCE); + obs_property_list_add_int(p, obs_module_text("Body2DRotation"), BODY_2D_ROT); + obs_property_list_add_int(p, obs_module_text("Body2DDiffX"), BODY_2D_DIFF_X); + obs_property_list_add_int(p, obs_module_text("Body2DDiffY"), BODY_2D_DIFF_Y); + obs_property_list_add_int(p, obs_module_text("Body2DDiff"), BODY_2D_DIFF); + obs_property_list_add_int(p, obs_module_text("Body2DPos"), BODY_2D_POS); + obs_property_list_add_int(p, obs_module_text("Body3DPosX"), BODY_3D_POSX); + obs_property_list_add_int(p, obs_module_text("Body3DPosY"), BODY_3D_POSY); + obs_property_list_add_int(p, obs_module_text("Body3DPosZ"), BODY_3D_POSZ); + obs_property_list_add_int(p, obs_module_text("Body3DDistance"), BODY_3D_DISTANCE); + obs_property_list_add_int(p, obs_module_text("Body3DDiffX"), BODY_3D_DIFF_X); + obs_property_list_add_int(p, obs_module_text("Body3DDiffY"), BODY_3D_DIFF_Y); + obs_property_list_add_int(p, obs_module_text("Body3DDiffZ"), BODY_3D_DIFF_Z); + obs_property_list_add_int(p, obs_module_text("Body3DPos"), BODY_3D_POS); + obs_property_list_add_int(p, obs_module_text("Body3DDiff"), BODY_3D_DIFF); + obs_property_list_add_int(p, obs_module_text("BodyAngleX"), BODY_ANGLE_X); + obs_property_list_add_int(p, obs_module_text("BodyAngleY"), BODY_ANGLE_Y); + obs_property_list_add_int(p, obs_module_text("BodyAngleZ"), BODY_ANGLE_Z); + obs_property_list_add_int(p, obs_module_text("BodyAngle"), BODY_ANGLE); + + obs_property_set_modified_callback2(p, nv_move_body_changed, data); dstr_printf(&name, "action_%lld_body_1", i); - p = obs_properties_add_list(group, name.array, - obs_module_text("Keypoint"), - OBS_COMBO_TYPE_LIST, + p = obs_properties_add_list(group, name.array, obs_module_text("Keypoint"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); nv_move_fill_body_list(p); dstr_printf(&name, "action_%lld_body_2", i); - p = obs_properties_add_list(group, name.array, - obs_module_text("Keypoint"), - OBS_COMBO_TYPE_LIST, + p = obs_properties_add_list(group, name.array, obs_module_text("Keypoint"), OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); nv_move_fill_body_list(p); dstr_printf(&name, "action_%lld_required_confidence", i); - p = obs_properties_add_float_slider( - group, name.array, obs_module_text("Confidence"), 0.0, - 25.0, 0.001); + p = obs_properties_add_float_slider(group, name.array, obs_module_text("Confidence"), 0.0, 25.0, 0.001); dstr_printf(&name, "action_%lld_factor", i); - p = obs_properties_add_float(group, name.array, - obs_module_text("Factor"), - -1000000.0, 1000000.0, 0.001); + p = obs_properties_add_float(group, name.array, obs_module_text("Factor"), -1000000.0, 1000000.0, 0.001); obs_property_float_set_suffix(p, "%"); dstr_printf(&name, "action_%lld_factor2", i); - p = obs_properties_add_float(group, name.array, - obs_module_text("Factor"), - -1000000.0, 1000000.0, 0.001); + p = obs_properties_add_float(group, name.array, obs_module_text("Factor"), -1000000.0, 1000000.0, 0.001); obs_property_float_set_suffix(p, "%"); dstr_printf(&name, "action_%lld_diff", i); - p = obs_properties_add_float(group, name.array, - obs_module_text("Difference"), - -1000000.0, 1000000.0, 0.001); + p = obs_properties_add_float(group, name.array, obs_module_text("Difference"), -1000000.0, 1000000.0, 0.001); dstr_printf(&name, "action_%lld_diff2", i); - p = obs_properties_add_float(group, name.array, - obs_module_text("Difference"), - -1000000.0, 1000000.0, 0.001); + p = obs_properties_add_float(group, name.array, obs_module_text("Difference"), -1000000.0, 1000000.0, 0.001); dstr_printf(&name, "action_%lld_threshold", i); - p = obs_properties_add_float(group, name.array, - obs_module_text("Threshold"), - -1000000.0, 1000000, 0.001); + p = obs_properties_add_float(group, name.array, obs_module_text("Threshold"), -1000000.0, 1000000, 0.001); dstr_printf(&name, "action_%lld_get_value", i); - obs_properties_add_button2(group, name.array, - obs_module_text("GetValue"), - nv_move_get_value_clicked, filter); + obs_properties_add_button2(group, name.array, obs_module_text("GetValue"), nv_move_get_value_clicked, filter); dstr_printf(&name, "action_%lld_easing", i); - p = obs_properties_add_float_slider(group, name.array, - obs_module_text("Easing"), - 0.0, 99.0, 0.001); + p = obs_properties_add_float_slider(group, name.array, obs_module_text("Easing"), 0.0, 99.0, 0.001); obs_property_float_set_suffix(p, "%"); dstr_printf(&name, "action_%lld_move_up", i); - obs_properties_add_button2(group, name.array, - obs_module_text("MoveUp"), - nv_move_move_up_clicked, filter); + obs_properties_add_button2(group, name.array, obs_module_text("MoveUp"), nv_move_move_up_clicked, filter); dstr_printf(&name, "action_%lld_move_down", i); - obs_properties_add_button2(group, name.array, - obs_module_text("MoveDown"), - nv_move_move_down_clicked, filter); + obs_properties_add_button2(group, name.array, obs_module_text("MoveDown"), nv_move_move_down_clicked, filter); dstr_printf(&name, "action_%lld_group", i); - dstr_printf(&description, "%s %lld", obs_module_text("Action"), - i); + dstr_printf(&description, "%s %lld", obs_module_text("Action"), i); - obs_properties_add_group(props, name.array, description.array, - OBS_GROUP_NORMAL, group); + obs_properties_add_group(props, name.array, description.array, OBS_GROUP_NORMAL, group); } dstr_free(&name); dstr_free(&description); - obs_properties_add_text(props, "plugin_info", PLUGIN_INFO, - OBS_TEXT_INFO); + obs_properties_add_text(props, "plugin_info", PLUGIN_INFO, OBS_TEXT_INFO); return props; } @@ -2981,18 +2241,15 @@ static void nv_move_defaults(obs_data_t *settings) obs_data_set_default_int(settings, "actions", 1); } -static struct obs_source_frame *nv_move_video(void *data, - struct obs_source_frame *frame) +static struct obs_source_frame *nv_move_video(void *data, struct obs_source_frame *frame) { struct nvidia_move_info *filter = (struct nvidia_move_info *)data; filter->got_new_frame = true; return frame; } -static const char * -get_tech_name_and_multiplier(enum gs_color_space current_space, - enum gs_color_space source_space, - float *multiplier) +static const char *get_tech_name_and_multiplier(enum gs_color_space current_space, enum gs_color_space source_space, + float *multiplier) { const char *tech_name = "Draw"; *multiplier = 1.f; @@ -3038,13 +2295,11 @@ get_tech_name_and_multiplier(enum gs_color_space current_space, return tech_name; } -void nv_move_draw_frame(struct nvidia_move_info *context, uint32_t w, - uint32_t h) +void nv_move_draw_frame(struct nvidia_move_info *context, uint32_t w, uint32_t h) { const enum gs_color_space current_space = gs_get_color_space(); float multiplier; - const char *technique = get_tech_name_and_multiplier( - current_space, context->space, &multiplier); + const char *technique = get_tech_name_and_multiplier(current_space, context->space, &multiplier); gs_effect_t *effect = obs_get_base_effect(OBS_EFFECT_DEFAULT); gs_texture_t *tex = gs_texrender_get_texture(context->render); @@ -3057,10 +2312,8 @@ void nv_move_draw_frame(struct nvidia_move_info *context, uint32_t w, const bool previous = gs_framebuffer_srgb_enabled(); gs_enable_framebuffer_srgb(true); - gs_effect_set_texture_srgb(gs_effect_get_param_by_name(effect, "image"), - tex); - gs_effect_set_float(gs_effect_get_param_by_name(effect, "multiplier"), - multiplier); + gs_effect_set_texture_srgb(gs_effect_get_param_by_name(effect, "image"), tex); + gs_effect_set_float(gs_effect_get_param_by_name(effect, "multiplier"), multiplier); while (gs_effect_loop(effect, technique)) gs_draw_sprite(tex, 0, w, h); @@ -3094,16 +2347,14 @@ static void nv_move_render(void *data, gs_effect_t *effect) GS_CS_SRGB_16F, GS_CS_709_EXTENDED, }; - const enum gs_color_space space = obs_source_get_color_space( - target, OBS_COUNTOF(preferred_spaces), preferred_spaces); + const enum gs_color_space space = obs_source_get_color_space(target, OBS_COUNTOF(preferred_spaces), preferred_spaces); if (filter->space != space) { filter->space = space; //init_images_greenscreen(filter); filter->initial_render = false; } const enum gs_color_format format = gs_get_format_from_space(space); - if (!filter->render || - gs_texrender_get_format(filter->render) != format) { + if (!filter->render || gs_texrender_get_format(filter->render) != format) { gs_texrender_destroy(filter->render); filter->render = gs_texrender_create(format, GS_ZS_NONE); } else { @@ -3117,8 +2368,7 @@ static void nv_move_render(void *data, gs_effect_t *effect) gs_blend_state_push(); gs_blend_function(GS_BLEND_ONE, GS_BLEND_ZERO); - if (gs_texrender_begin_with_color_space(filter->render, base_width, - base_height, space)) { + if (gs_texrender_begin_with_color_space(filter->render, base_width, base_height, space)) { const float w = (float)base_width; const float h = (float)base_height; uint32_t parent_flags = obs_source_get_output_flags(target); @@ -3138,21 +2388,17 @@ static void nv_move_render(void *data, gs_effect_t *effect) //filter->space = space; } if (!filter->render_unorm) { - filter->render_unorm = - gs_texrender_create(GS_BGRA_UNORM, GS_ZS_NONE); + filter->render_unorm = gs_texrender_create(GS_BGRA_UNORM, GS_ZS_NONE); } else { gs_texrender_reset(filter->render_unorm); } - if (gs_texrender_begin_with_color_space(filter->render_unorm, - base_width, base_height, - GS_CS_SRGB)) { + if (gs_texrender_begin_with_color_space(filter->render_unorm, base_width, base_height, GS_CS_SRGB)) { const bool previous = gs_framebuffer_srgb_enabled(); gs_enable_framebuffer_srgb(true); gs_enable_blending(false); - gs_ortho(0.0f, (float)filter->width, 0.0f, - (float)filter->height, -100.0f, 100.0f); + gs_ortho(0.0f, (float)filter->width, 0.0f, (float)filter->height, -100.0f, 100.0f); const char *tech_name = "ConvertUnorm"; float multiplier = 1.f; @@ -3165,9 +2411,7 @@ static void nv_move_render(void *data, gs_effect_t *effect) multiplier = 80.0f / obs_get_video_sdr_white_level(); } - gs_effect_set_texture_srgb( - filter->image_param, - gs_texrender_get_texture(filter->render)); + gs_effect_set_texture_srgb(filter->image_param, gs_texrender_get_texture(filter->render)); gs_effect_set_float(filter->multiplier_param, multiplier); while (gs_effect_loop(filter->effect, tech_name)) { @@ -3183,145 +2427,102 @@ static void nv_move_render(void *data, gs_effect_t *effect) if (!filter->src_img) { if (nv_move_log_error(filter, - NvCVImage_Create(base_width, base_height, - NVCV_BGRA, NVCV_U8, - NVCV_CHUNKY, NVCV_GPU, 1, + NvCVImage_Create(base_width, base_height, NVCV_BGRA, NVCV_U8, NVCV_CHUNKY, NVCV_GPU, 1, &filter->src_img), "Image Create")) os_atomic_set_bool(&filter->processing_stop, true); struct ID3D11Texture2D *d11texture2 = - (struct ID3D11Texture2D *)gs_texture_get_obj( - gs_texrender_get_texture(filter->render_unorm)); + (struct ID3D11Texture2D *)gs_texture_get_obj(gs_texrender_get_texture(filter->render_unorm)); if (d11texture2) { - if (nv_move_log_error(filter, - NvCVImage_InitFromD3D11Texture( - filter->src_img, - d11texture2), + if (nv_move_log_error(filter, NvCVImage_InitFromD3D11Texture(filter->src_img, d11texture2), "ID3D11Texture")) - os_atomic_set_bool(&filter->processing_stop, - true); + os_atomic_set_bool(&filter->processing_stop, true); filter->initial_render = true; } } if (!filter->BGR_src_img) { - if (NvCVImage_Create(base_width, base_height, NVCV_BGR, NVCV_U8, - NVCV_CHUNKY, NVCV_GPU, 1, - &filter->BGR_src_img) != NVCV_SUCCESS) { + if (NvCVImage_Create(base_width, base_height, NVCV_BGR, NVCV_U8, NVCV_CHUNKY, NVCV_GPU, 1, &filter->BGR_src_img) != + NVCV_SUCCESS) { //goto fail; } - if (NvCVImage_Alloc(filter->BGR_src_img, base_width, - base_height, NVCV_BGR, NVCV_U8, NVCV_CHUNKY, - NVCV_GPU, 1) != NVCV_SUCCESS) { + if (NvCVImage_Alloc(filter->BGR_src_img, base_width, base_height, NVCV_BGR, NVCV_U8, NVCV_CHUNKY, NVCV_GPU, 1) != + NVCV_SUCCESS) { //goto fail; } if (filter->faceDetectHandle) - nv_move_log_error( - filter, - NvAR_SetObject(filter->faceDetectHandle, - NvAR_Parameter_Input(Image), - filter->BGR_src_img, - sizeof(NvCVImage)), - "Set Image"); + nv_move_log_error(filter, + NvAR_SetObject(filter->faceDetectHandle, NvAR_Parameter_Input(Image), filter->BGR_src_img, + sizeof(NvCVImage)), + "Set Image"); if (filter->landmarkHandle) - nv_move_log_error( - filter, - NvAR_SetObject(filter->landmarkHandle, - NvAR_Parameter_Input(Image), - filter->BGR_src_img, - sizeof(NvCVImage)), - "Set Image"); + nv_move_log_error(filter, + NvAR_SetObject(filter->landmarkHandle, NvAR_Parameter_Input(Image), filter->BGR_src_img, + sizeof(NvCVImage)), + "Set Image"); if (filter->expressionHandle) - nv_move_log_error( - filter, - NvAR_SetObject(filter->expressionHandle, - NvAR_Parameter_Input(Image), - filter->BGR_src_img, - sizeof(NvCVImage)), - "Set Image"); + nv_move_log_error(filter, + NvAR_SetObject(filter->expressionHandle, NvAR_Parameter_Input(Image), filter->BGR_src_img, + sizeof(NvCVImage)), + "Set Image"); if (filter->gazeHandle) - nv_move_log_error( - filter, - NvAR_SetObject(filter->gazeHandle, - NvAR_Parameter_Input(Image), - filter->BGR_src_img, - sizeof(NvCVImage)), - "Set Image"); + nv_move_log_error(filter, + NvAR_SetObject(filter->gazeHandle, NvAR_Parameter_Input(Image), filter->BGR_src_img, + sizeof(NvCVImage)), + "Set Image"); if (filter->bodyHandle) - nv_move_log_error( - filter, - NvAR_SetObject(filter->bodyHandle, - NvAR_Parameter_Input(Image), - filter->BGR_src_img, - sizeof(NvCVImage)), - "Set Image"); + nv_move_log_error(filter, + NvAR_SetObject(filter->bodyHandle, NvAR_Parameter_Input(Image), filter->BGR_src_img, + sizeof(NvCVImage)), + "Set Image"); } if (!filter->stage) { - if (NvCVImage_Create(base_width, base_height, NVCV_RGBA, - NVCV_U8, NVCV_PLANAR, NVCV_GPU, 1, - &filter->stage) != NVCV_SUCCESS) { + if (NvCVImage_Create(base_width, base_height, NVCV_RGBA, NVCV_U8, NVCV_PLANAR, NVCV_GPU, 1, &filter->stage) != + NVCV_SUCCESS) { //goto fail; } - if (NvCVImage_Alloc(filter->stage, base_width, base_height, - NVCV_RGBA, NVCV_U8, NVCV_PLANAR, NVCV_GPU, - 1) != NVCV_SUCCESS) { + if (NvCVImage_Alloc(filter->stage, base_width, base_height, NVCV_RGBA, NVCV_U8, NVCV_PLANAR, NVCV_GPU, 1) != + NVCV_SUCCESS) { //goto fail; } } - nv_move_log_error( - filter, NvCVImage_MapResource(filter->src_img, filter->stream), - "Map Resource"); + nv_move_log_error(filter, NvCVImage_MapResource(filter->src_img, filter->stream), "Map Resource"); /* 2. Convert to BGR. */ - nv_move_log_error(filter, - NvCVImage_Transfer(filter->src_img, - filter->BGR_src_img, 1.0f, - filter->stream, filter->stage), + nv_move_log_error(filter, NvCVImage_Transfer(filter->src_img, filter->BGR_src_img, 1.0f, filter->stream, filter->stage), "Transfer"); - nv_move_log_error(filter, - NvCVImage_UnmapResource(filter->src_img, - filter->stream), - "Unmap Resource"); + nv_move_log_error(filter, NvCVImage_UnmapResource(filter->src_img, filter->stream), "Unmap Resource"); if (filter->faceDetectHandle) - nv_move_log_error(filter, NvAR_Run(filter->faceDetectHandle), - "Run faceDetect"); + nv_move_log_error(filter, NvAR_Run(filter->faceDetectHandle), "Run faceDetect"); if (filter->landmarkHandle) - nv_move_log_error(filter, NvAR_Run(filter->landmarkHandle), - "Run landmark"); + nv_move_log_error(filter, NvAR_Run(filter->landmarkHandle), "Run landmark"); if (filter->expressionHandle) - nv_move_log_error(filter, NvAR_Run(filter->expressionHandle), - "Run expression"); + nv_move_log_error(filter, NvAR_Run(filter->expressionHandle), "Run expression"); if (filter->gazeHandle) - nv_move_log_error(filter, NvAR_Run(filter->gazeHandle), - "Run gaze"); + nv_move_log_error(filter, NvAR_Run(filter->gazeHandle), "Run gaze"); if (filter->bodyHandle) - nv_move_log_error(filter, NvAR_Run(filter->bodyHandle), - "Run body"); + nv_move_log_error(filter, NvAR_Run(filter->bodyHandle), "Run body"); for (size_t i = 0; i < filter->actions.num; i++) { struct nvidia_move_action *action = filter->actions.array + i; if (action->disabled) continue; - if (action->action == ACTION_MOVE_SOURCE || - action->action == ACTION_ATTACH_SOURCE) { + if (action->action == ACTION_MOVE_SOURCE || action->action == ACTION_ATTACH_SOURCE) { if (!action->name) continue; - obs_source_t *scene_source = - obs_weak_source_get_source(action->target); + obs_source_t *scene_source = obs_weak_source_get_source(action->target); if (!scene_source) continue; - obs_scene_t *scene = - obs_scene_from_source(scene_source); + obs_scene_t *scene = obs_scene_from_source(scene_source); if (!scene) scene = obs_group_from_source(scene_source); obs_source_release(scene_source); if (!scene) continue; - obs_sceneitem_t *item = - obs_scene_find_source(scene, action->name); + obs_sceneitem_t *item = obs_scene_find_source(scene, action->name); if (!item) continue; @@ -3329,8 +2530,7 @@ static void nv_move_render(void *data, gs_effect_t *effect) if (action->action == ACTION_ATTACH_SOURCE) { if (!filter->bboxes.num_boxes) { if (obs_sceneitem_visible(item)) { - obs_sceneitem_set_visible( - item, false); + obs_sceneitem_set_visible(item, false); } continue; } @@ -3339,495 +2539,279 @@ static void nv_move_render(void *data, gs_effect_t *effect) bool height_to_pos = false; if (action->property == ATTACH_EYES) { if (filter->landmarks.num == 126) { - action->feature_number[0] = - 65 - 1; - action->feature_number[1] = - 86 - 1; - action->feature_number[2] = - 83 - 1; - action->feature_number[3] = - 68 - 1; + action->feature_number[0] = 65 - 1; + action->feature_number[1] = 86 - 1; + action->feature_number[2] = 83 - 1; + action->feature_number[3] = 68 - 1; } else { - action->feature_number[0] = - 37 - 1; - action->feature_number[1] = - 46 - 1; - action->feature_number[2] = - 44 - 1; - action->feature_number[3] = - 39 - 1; + action->feature_number[0] = 37 - 1; + action->feature_number[1] = 46 - 1; + action->feature_number[2] = 44 - 1; + action->feature_number[3] = 39 - 1; } height_to_pos = true; - } else if (action->property == - ATTACH_RIGHT_EYE) { + } else if (action->property == ATTACH_RIGHT_EYE) { if (filter->landmarks.num == 126) { - action->feature_number[0] = - 65 - 1; - action->feature_number[1] = - 69 - 1; - action->feature_number[2] = - 68 - 1; - action->feature_number[3] = - 70 - 1; + action->feature_number[0] = 65 - 1; + action->feature_number[1] = 69 - 1; + action->feature_number[2] = 68 - 1; + action->feature_number[3] = 70 - 1; } else { - action->feature_number[0] = - 37 - 1; - action->feature_number[1] = - 40 - 1; - action->feature_number[2] = - 39 - 1; - action->feature_number[3] = - 41 - 1; + action->feature_number[0] = 37 - 1; + action->feature_number[1] = 40 - 1; + action->feature_number[2] = 39 - 1; + action->feature_number[3] = 41 - 1; } - } else if (action->property == - ATTACH_LEFT_EYE) { + } else if (action->property == ATTACH_LEFT_EYE) { if (filter->landmarks.num == 126) { - action->feature_number[0] = - 82 - 1; - action->feature_number[1] = - 86 - 1; - action->feature_number[2] = - 84 - 1; - action->feature_number[3] = - 88 - 1; + action->feature_number[0] = 82 - 1; + action->feature_number[1] = 86 - 1; + action->feature_number[2] = 84 - 1; + action->feature_number[3] = 88 - 1; } else { - action->feature_number[0] = - 43 - 1; - action->feature_number[1] = - 46 - 1; - action->feature_number[2] = - 44 - 1; - action->feature_number[3] = - 48 - 1; + action->feature_number[0] = 43 - 1; + action->feature_number[1] = 46 - 1; + action->feature_number[2] = 44 - 1; + action->feature_number[3] = 48 - 1; } - } else if (action->property == - ATTACH_EYEBROWS) { + } else if (action->property == ATTACH_EYEBROWS) { if (filter->landmarks.num == 126) { - action->feature_number[0] = - 34 - 1; - action->feature_number[1] = - 47 - 1; - action->feature_number[2] = - 36 - 1; - action->feature_number[3] = - 45 - 1; + action->feature_number[0] = 34 - 1; + action->feature_number[1] = 47 - 1; + action->feature_number[2] = 36 - 1; + action->feature_number[3] = 45 - 1; } else { - action->feature_number[0] = - 18 - 1; - action->feature_number[1] = - 27 - 1; - action->feature_number[2] = - 20 - 1; - action->feature_number[3] = - 25 - 1; + action->feature_number[0] = 18 - 1; + action->feature_number[1] = 27 - 1; + action->feature_number[2] = 20 - 1; + action->feature_number[3] = 25 - 1; } height_to_pos = true; - } else if (action->property == - ATTACH_RIGHT_EYEBROW) { + } else if (action->property == ATTACH_RIGHT_EYEBROW) { if (filter->landmarks.num == 126) { - action->feature_number[0] = - 34 - 1; - action->feature_number[1] = - 38 - 1; - action->feature_number[2] = - 36 - 1; - action->feature_number[3] = - 36 - 1; + action->feature_number[0] = 34 - 1; + action->feature_number[1] = 38 - 1; + action->feature_number[2] = 36 - 1; + action->feature_number[3] = 36 - 1; } else { - action->feature_number[0] = - 18 - 1; - action->feature_number[1] = - 22 - 1; - action->feature_number[2] = - 20 - 1; - action->feature_number[3] = - 20 - 1; + action->feature_number[0] = 18 - 1; + action->feature_number[1] = 22 - 1; + action->feature_number[2] = 20 - 1; + action->feature_number[3] = 20 - 1; } height_to_pos = true; - } else if (action->property == - ATTACH_LEFT_EYEBROW) { + } else if (action->property == ATTACH_LEFT_EYEBROW) { if (filter->landmarks.num == 126) { - action->feature_number[0] = - 43 - 1; - action->feature_number[1] = - 47 - 1; - action->feature_number[2] = - 45 - 1; - action->feature_number[3] = - 45 - 1; + action->feature_number[0] = 43 - 1; + action->feature_number[1] = 47 - 1; + action->feature_number[2] = 45 - 1; + action->feature_number[3] = 45 - 1; } else { - action->feature_number[0] = - 23 - 1; - action->feature_number[1] = - 27 - 1; - action->feature_number[2] = - 25 - 1; - action->feature_number[3] = - 25 - 1; + action->feature_number[0] = 23 - 1; + action->feature_number[1] = 27 - 1; + action->feature_number[2] = 25 - 1; + action->feature_number[3] = 25 - 1; } height_to_pos = true; } else if (action->property == ATTACH_EARS) { if (filter->landmarks.num == 126) { - action->feature_number[0] = - 1 - 1; - action->feature_number[1] = - 33 - 1; - action->feature_number[2] = - 1 - 1; - action->feature_number[3] = - 2 - 1; + action->feature_number[0] = 1 - 1; + action->feature_number[1] = 33 - 1; + action->feature_number[2] = 1 - 1; + action->feature_number[3] = 2 - 1; } else { - action->feature_number[0] = - 1 - 1; - action->feature_number[1] = - 17 - 1; - action->feature_number[2] = - 1 - 1; - action->feature_number[3] = - 2 - 1; + action->feature_number[0] = 1 - 1; + action->feature_number[1] = 17 - 1; + action->feature_number[2] = 1 - 1; + action->feature_number[3] = 2 - 1; } height_to_pos = true; - } else if (action->property == - ATTACH_RIGHT_EAR) { + } else if (action->property == ATTACH_RIGHT_EAR) { if (filter->landmarks.num == 126) { - action->feature_number[0] = - 1 - 1; - action->feature_number[1] = - 2 - 1; - action->feature_number[2] = - 1 - 1; - action->feature_number[3] = - 2 - 1; + action->feature_number[0] = 1 - 1; + action->feature_number[1] = 2 - 1; + action->feature_number[2] = 1 - 1; + action->feature_number[3] = 2 - 1; } else { - action->feature_number[0] = - 1 - 1; - action->feature_number[1] = - 2 - 1; - action->feature_number[2] = - 1 - 1; - action->feature_number[3] = - 2 - 1; + action->feature_number[0] = 1 - 1; + action->feature_number[1] = 2 - 1; + action->feature_number[2] = 1 - 1; + action->feature_number[3] = 2 - 1; } vert = true; - } else if (action->property == - ATTACH_LEFT_EAR) { + } else if (action->property == ATTACH_LEFT_EAR) { if (filter->landmarks.num == 126) { - action->feature_number[0] = - 33 - 1; - action->feature_number[1] = - 32 - 1; - action->feature_number[2] = - 33 - 1; - action->feature_number[3] = - 32 - 1; + action->feature_number[0] = 33 - 1; + action->feature_number[1] = 32 - 1; + action->feature_number[2] = 33 - 1; + action->feature_number[3] = 32 - 1; } else { - action->feature_number[0] = - 17 - 1; - action->feature_number[1] = - 16 - 1; - action->feature_number[2] = - 17 - 1; - action->feature_number[3] = - 16 - 1; + action->feature_number[0] = 17 - 1; + action->feature_number[1] = 16 - 1; + action->feature_number[2] = 17 - 1; + action->feature_number[3] = 16 - 1; } vert = true; } else if (action->property == ATTACH_NOSE) { if (filter->landmarks.num == 126) { - action->feature_number[0] = - 58 - 1; - action->feature_number[1] = - 62 - 1; - action->feature_number[2] = - 52 - 1; - action->feature_number[3] = - 60 - 1; + action->feature_number[0] = 58 - 1; + action->feature_number[1] = 62 - 1; + action->feature_number[2] = 52 - 1; + action->feature_number[3] = 60 - 1; } else { - action->feature_number[0] = - 32 - 1; - action->feature_number[1] = - 36 - 1; - action->feature_number[2] = - 28 - 1; - action->feature_number[3] = - 34 - 1; + action->feature_number[0] = 32 - 1; + action->feature_number[1] = 36 - 1; + action->feature_number[2] = 28 - 1; + action->feature_number[3] = 34 - 1; } } else if (action->property == ATTACH_MOUTH) { if (filter->landmarks.num == 126) { - action->feature_number[0] = - 99 - 1; - action->feature_number[1] = - 105 - 1; - action->feature_number[2] = - 102 - 1; - action->feature_number[3] = - 108 - 1; + action->feature_number[0] = 99 - 1; + action->feature_number[1] = 105 - 1; + action->feature_number[2] = 102 - 1; + action->feature_number[3] = 108 - 1; } else { - action->feature_number[0] = - 49 - 1; - action->feature_number[1] = - 55 - 1; - action->feature_number[2] = - 52 - 1; - action->feature_number[3] = - 58 - 1; + action->feature_number[0] = 49 - 1; + action->feature_number[1] = 55 - 1; + action->feature_number[2] = 52 - 1; + action->feature_number[3] = 58 - 1; } - } else if (action->property == - ATTACH_UPPER_LIP) { + } else if (action->property == ATTACH_UPPER_LIP) { if (filter->landmarks.num == 126) { - action->feature_number[0] = - 99 - 1; - action->feature_number[1] = - 105 - 1; - action->feature_number[2] = - 101 - 1; - action->feature_number[3] = - 103 - 1; + action->feature_number[0] = 99 - 1; + action->feature_number[1] = 105 - 1; + action->feature_number[2] = 101 - 1; + action->feature_number[3] = 103 - 1; } else { - action->feature_number[0] = - 49 - 1; - action->feature_number[1] = - 55 - 1; - action->feature_number[2] = - 51 - 1; - action->feature_number[3] = - 53 - 1; + action->feature_number[0] = 49 - 1; + action->feature_number[1] = 55 - 1; + action->feature_number[2] = 51 - 1; + action->feature_number[3] = 53 - 1; } height_to_pos = true; - } else if (action->property == - ATTACH_LOWER_LIP) { + } else if (action->property == ATTACH_LOWER_LIP) { if (filter->landmarks.num == 126) { - action->feature_number[0] = - 99 - 1; - action->feature_number[1] = - 105 - 1; - action->feature_number[2] = - 108 - 1; - action->feature_number[3] = - 108 - 1; + action->feature_number[0] = 99 - 1; + action->feature_number[1] = 105 - 1; + action->feature_number[2] = 108 - 1; + action->feature_number[3] = 108 - 1; } else { - action->feature_number[0] = - 49 - 1; - action->feature_number[1] = - 55 - 1; - action->feature_number[2] = - 58 - 1; - action->feature_number[3] = - 58 - 1; + action->feature_number[0] = 49 - 1; + action->feature_number[1] = 55 - 1; + action->feature_number[2] = 58 - 1; + action->feature_number[3] = 58 - 1; } height_to_pos = true; } else if (action->property == ATTACH_CHIN) { if (filter->landmarks.num == 126) { - action->feature_number[0] = - 15 - 1; - action->feature_number[1] = - 19 - 1; - action->feature_number[2] = - 17 - 1; - action->feature_number[3] = - 17 - 1; + action->feature_number[0] = 15 - 1; + action->feature_number[1] = 19 - 1; + action->feature_number[2] = 17 - 1; + action->feature_number[3] = 17 - 1; } else { - action->feature_number[0] = - 8 - 1; - action->feature_number[1] = - 10 - 1; - action->feature_number[2] = - 9 - 1; - action->feature_number[3] = - 9 - 1; + action->feature_number[0] = 8 - 1; + action->feature_number[1] = 10 - 1; + action->feature_number[2] = 9 - 1; + action->feature_number[3] = 9 - 1; } height_to_pos = true; } else if (action->property == ATTACH_JAW) { if (filter->landmarks.num == 126) { - action->feature_number[0] = - 1 - 1; - action->feature_number[1] = - 33 - 1; - action->feature_number[2] = - 17 - 1; - action->feature_number[3] = - 17 - 1; + action->feature_number[0] = 1 - 1; + action->feature_number[1] = 33 - 1; + action->feature_number[2] = 17 - 1; + action->feature_number[3] = 17 - 1; } else { - action->feature_number[0] = - 1 - 1; - action->feature_number[1] = - 17 - 1; - action->feature_number[2] = - 9 - 1; - action->feature_number[3] = - 9 - 1; + action->feature_number[0] = 1 - 1; + action->feature_number[1] = 17 - 1; + action->feature_number[2] = 9 - 1; + action->feature_number[3] = 9 - 1; } height_to_pos = true; - } else if (action->property == - ATTACH_FOREHEAD) { + } else if (action->property == ATTACH_FOREHEAD) { if (filter->landmarks.num == 126) { - action->feature_number[0] = - 1 - 1; - action->feature_number[1] = - 33 - 1; - action->feature_number[2] = - 52 - 1; - action->feature_number[3] = - 60 - 1; + action->feature_number[0] = 1 - 1; + action->feature_number[1] = 33 - 1; + action->feature_number[2] = 52 - 1; + action->feature_number[3] = 60 - 1; } else { - action->feature_number[0] = - 1 - 1; - action->feature_number[1] = - 17 - 1; - action->feature_number[2] = - 28 - 1; - action->feature_number[3] = - 34 - 1; + action->feature_number[0] = 1 - 1; + action->feature_number[1] = 17 - 1; + action->feature_number[2] = 28 - 1; + action->feature_number[3] = 34 - 1; } //height_to_pos = true; } else { continue; } - if (action->feature_number[0] >= - (int32_t)filter->landmarks.num || - action->feature_number[1] >= - (int32_t)filter->landmarks.num) { + if (action->feature_number[0] >= (int32_t)filter->landmarks.num || + action->feature_number[1] >= (int32_t)filter->landmarks.num) { continue; } - if (filter->landmarks_confidence.array - [action->feature_number[0]] < - action->required_confidence || - filter->landmarks_confidence.array - [action->feature_number[1]] < - action->required_confidence) { + if (filter->landmarks_confidence.array[action->feature_number[0]] < action->required_confidence || + filter->landmarks_confidence.array[action->feature_number[1]] < action->required_confidence) { if (obs_sceneitem_visible(item)) { - obs_sceneitem_set_visible( - item, false); + obs_sceneitem_set_visible(item, false); } continue; } struct vec2 pos; if (vert) { - pos.x = filter->landmarks - .array[action->feature_number - [0]] - .x; - pos.y = filter->landmarks - .array[action->feature_number - [0]] - .y; + pos.x = filter->landmarks.array[action->feature_number[0]].x; + pos.y = filter->landmarks.array[action->feature_number[0]].y; } else { - pos.x = (filter->landmarks - .array[action->feature_number - [1]] - .x + - filter->landmarks - .array[action->feature_number - [0]] - .x) / + pos.x = (filter->landmarks.array[action->feature_number[1]].x + + filter->landmarks.array[action->feature_number[0]].x) / 2.0f; - pos.y = (filter->landmarks - .array[action->feature_number - [1]] - .y + - filter->landmarks - .array[action->feature_number - [0]] - .y) / + pos.y = (filter->landmarks.array[action->feature_number[1]].y + + filter->landmarks.array[action->feature_number[0]].y) / 2.0f; } obs_sceneitem_set_pos(item, &pos); - float rot = DEG(atan2f( - (filter->landmarks - .array[action->feature_number[1]] - .y - - filter->landmarks - .array[action->feature_number[0]] - .y), - (filter->landmarks - .array[action->feature_number[1]] - .x - - filter->landmarks - .array[action->feature_number[0]] - .x))); + float rot = DEG(atan2f((filter->landmarks.array[action->feature_number[1]].y - + filter->landmarks.array[action->feature_number[0]].y), + (filter->landmarks.array[action->feature_number[1]].x - + filter->landmarks.array[action->feature_number[0]].x))); if (vert) rot -= 90.0f; obs_sceneitem_set_rot(item, rot); - obs_source_t *s = - obs_sceneitem_get_source(item); + obs_source_t *s = obs_sceneitem_get_source(item); float w = (float)obs_source_get_width(s); float h = (float)obs_source_get_height(s); if (w > 0.0f && h > 0.0f) { - float x = - filter->landmarks - .array[action->feature_number - [0]] - .x - - filter->landmarks - .array[action->feature_number - [1]] - .x; - float y = - filter->landmarks - .array[action->feature_number - [0]] - .y - - filter->landmarks - .array[action->feature_number - [1]] - .y; + float x = filter->landmarks.array[action->feature_number[0]].x - + filter->landmarks.array[action->feature_number[1]].x; + float y = filter->landmarks.array[action->feature_number[0]].y - + filter->landmarks.array[action->feature_number[1]].y; float dist = sqrtf(x * x + y * y); dist *= action->factor; if (height_to_pos) { - x = (filter->landmarks - .array[action->feature_number - [3]] - .x + - filter->landmarks - .array[action->feature_number - [2]] - .x) / + x = (filter->landmarks.array[action->feature_number[3]].x + + filter->landmarks.array[action->feature_number[2]].x) / 2.0f - pos.x; - y = (filter->landmarks - .array[action->feature_number - [3]] - .y + - filter->landmarks - .array[action->feature_number - [2]] - .y) / + y = (filter->landmarks.array[action->feature_number[3]].y + + filter->landmarks.array[action->feature_number[2]].y) / 2.0f - pos.y; } else { - x = filter->landmarks - .array[action->feature_number - [3]] - .x - - filter->landmarks - .array[action->feature_number - [2]] - .x; - y = filter->landmarks - .array[action->feature_number - [3]] - .y - - filter->landmarks - .array[action->feature_number - [2]] - .y; + x = filter->landmarks.array[action->feature_number[3]].x - + filter->landmarks.array[action->feature_number[2]].x; + y = filter->landmarks.array[action->feature_number[3]].y - + filter->landmarks.array[action->feature_number[2]].y; } float dist2 = sqrtf(x * x + y * y); dist2 *= action->factor2; - dist = action->previous_vec2.x * - action->easing + - dist * (1.0f - action->easing); + dist = action->previous_vec2.x * action->easing + dist * (1.0f - action->easing); action->previous_vec2.x = dist; - dist2 = action->previous_vec2.y * - action->easing + - dist2 * (1.0f - action->easing); + dist2 = action->previous_vec2.y * action->easing + dist2 * (1.0f - action->easing); action->previous_vec2.y = dist2; - if (obs_sceneitem_get_bounds_type( - item) == OBS_BOUNDS_NONE) { + if (obs_sceneitem_get_bounds_type(item) == OBS_BOUNDS_NONE) { struct vec2 scale = {0}; if (vert) { scale.y = dist / h; @@ -3836,8 +2820,7 @@ static void nv_move_render(void *data, gs_effect_t *effect) scale.x = dist / w; scale.y = dist2 / h; } - obs_sceneitem_set_scale(item, - &scale); + obs_sceneitem_set_scale(item, &scale); } else { struct vec2 bounds = {0}; if (vert) { @@ -3847,8 +2830,7 @@ static void nv_move_render(void *data, gs_effect_t *effect) bounds.x = dist; bounds.y = dist2; } - obs_sceneitem_set_bounds( - item, &bounds); + obs_sceneitem_set_bounds(item, &bounds); } } if (!obs_sceneitem_visible(item)) { @@ -3856,132 +2838,89 @@ static void nv_move_render(void *data, gs_effect_t *effect) } } else if (action->property == SCENEITEM_PROPERTY_POS) { struct vec2 pos; - if (nv_move_action_get_vec2(filter, action, - true, &pos)) + if (nv_move_action_get_vec2(filter, action, true, &pos)) obs_sceneitem_set_pos(item, &pos); - } else if (action->property == - SCENEITEM_PROPERTY_POSX) { + } else if (action->property == SCENEITEM_PROPERTY_POSX) { struct vec2 pos; obs_sceneitem_get_pos(item, &pos); - if (nv_move_action_get_float(filter, action, - true, &pos.x)) + if (nv_move_action_get_float(filter, action, true, &pos.x)) obs_sceneitem_set_pos(item, &pos); - } else if (action->property == - SCENEITEM_PROPERTY_POSY) { + } else if (action->property == SCENEITEM_PROPERTY_POSY) { struct vec2 pos; obs_sceneitem_get_pos(item, &pos); - if (nv_move_action_get_float(filter, action, - true, &pos.y)) + if (nv_move_action_get_float(filter, action, true, &pos.y)) obs_sceneitem_set_pos(item, &pos); - } else if (action->property == - SCENEITEM_PROPERTY_SCALE) { + } else if (action->property == SCENEITEM_PROPERTY_SCALE) { struct vec2 scale; - if (nv_move_action_get_vec2(filter, action, - true, &scale)) { - if (obs_sceneitem_get_bounds_type( - item) == OBS_BOUNDS_NONE) { - scale.x /= (float)obs_source_get_width( - obs_sceneitem_get_source( - item)); - scale.y /= (float)obs_source_get_height( - obs_sceneitem_get_source( - item)); - obs_sceneitem_set_scale(item, - &scale); + if (nv_move_action_get_vec2(filter, action, true, &scale)) { + if (obs_sceneitem_get_bounds_type(item) == OBS_BOUNDS_NONE) { + scale.x /= (float)obs_source_get_width(obs_sceneitem_get_source(item)); + scale.y /= (float)obs_source_get_height(obs_sceneitem_get_source(item)); + obs_sceneitem_set_scale(item, &scale); } else { - obs_sceneitem_set_bounds( - item, &scale); + obs_sceneitem_set_bounds(item, &scale); } } - } else if (action->property == - SCENEITEM_PROPERTY_SCALEX) { + } else if (action->property == SCENEITEM_PROPERTY_SCALEX) { struct vec2 scale; - if (obs_sceneitem_get_bounds_type(item) == - OBS_BOUNDS_NONE) { + if (obs_sceneitem_get_bounds_type(item) == OBS_BOUNDS_NONE) { obs_sceneitem_get_scale(item, &scale); - if (nv_move_action_get_float( - filter, action, true, - &scale.x)) { - scale.x /= (float)obs_source_get_width( - obs_sceneitem_get_source( - item)); - obs_sceneitem_set_scale(item, - &scale); + if (nv_move_action_get_float(filter, action, true, &scale.x)) { + scale.x /= (float)obs_source_get_width(obs_sceneitem_get_source(item)); + obs_sceneitem_set_scale(item, &scale); } } else { obs_sceneitem_get_bounds(item, &scale); - if (nv_move_action_get_float( - filter, action, true, - &scale.x)) - obs_sceneitem_set_bounds( - item, &scale); + if (nv_move_action_get_float(filter, action, true, &scale.x)) + obs_sceneitem_set_bounds(item, &scale); } - } else if (action->property == - SCENEITEM_PROPERTY_SCALEY) { + } else if (action->property == SCENEITEM_PROPERTY_SCALEY) { struct vec2 scale; - if (obs_sceneitem_get_bounds_type(item) == - OBS_BOUNDS_NONE) { + if (obs_sceneitem_get_bounds_type(item) == OBS_BOUNDS_NONE) { obs_sceneitem_get_scale(item, &scale); - if (nv_move_action_get_float( - filter, action, true, - &scale.y)) { - scale.y /= (float)obs_source_get_height( - obs_sceneitem_get_source( - item)); - obs_sceneitem_set_scale(item, - &scale); + if (nv_move_action_get_float(filter, action, true, &scale.y)) { + scale.y /= (float)obs_source_get_height(obs_sceneitem_get_source(item)); + obs_sceneitem_set_scale(item, &scale); } } else { obs_sceneitem_get_bounds(item, &scale); - if (nv_move_action_get_float( - filter, action, true, - &scale.y)) - obs_sceneitem_set_bounds( - item, &scale); + if (nv_move_action_get_float(filter, action, true, &scale.y)) + obs_sceneitem_set_bounds(item, &scale); } } else if (action->property == SCENEITEM_PROPERTY_ROT) { float rot; - if (nv_move_action_get_float(filter, action, - true, &rot)) + if (nv_move_action_get_float(filter, action, true, &rot)) obs_sceneitem_set_rot(item, rot); - } else if (action->property == - SCENEITEM_PROPERTY_CROP_LEFT) { + } else if (action->property == SCENEITEM_PROPERTY_CROP_LEFT) { struct obs_sceneitem_crop crop; obs_sceneitem_get_crop(item, &crop); float value; - if (nv_move_action_get_float(filter, action, - true, &value)) { + if (nv_move_action_get_float(filter, action, true, &value)) { crop.left = (int)value; obs_sceneitem_set_crop(item, &crop); } - } else if (action->property == - SCENEITEM_PROPERTY_CROP_RIGHT) { + } else if (action->property == SCENEITEM_PROPERTY_CROP_RIGHT) { struct obs_sceneitem_crop crop; obs_sceneitem_get_crop(item, &crop); float value; - if (nv_move_action_get_float(filter, action, - true, &value)) { + if (nv_move_action_get_float(filter, action, true, &value)) { crop.right = (int)value; obs_sceneitem_set_crop(item, &crop); } obs_sceneitem_set_crop(item, &crop); - } else if (action->property == - SCENEITEM_PROPERTY_CROP_TOP) { + } else if (action->property == SCENEITEM_PROPERTY_CROP_TOP) { struct obs_sceneitem_crop crop; obs_sceneitem_get_crop(item, &crop); float value; - if (nv_move_action_get_float(filter, action, - true, &value)) { + if (nv_move_action_get_float(filter, action, true, &value)) { crop.top = (int)value; obs_sceneitem_set_crop(item, &crop); } - } else if (action->property == - SCENEITEM_PROPERTY_CROP_BOTTOM) { + } else if (action->property == SCENEITEM_PROPERTY_CROP_BOTTOM) { struct obs_sceneitem_crop crop; obs_sceneitem_get_crop(item, &crop); float value; - if (nv_move_action_get_float(filter, action, - true, &value)) { + if (nv_move_action_get_float(filter, action, true, &value)) { crop.bottom = (int)value; obs_sceneitem_set_crop(item, &crop); } @@ -3990,11 +2929,9 @@ static void nv_move_render(void *data, gs_effect_t *effect) if (!action->name || !strlen(action->name)) continue; float value; - if (!nv_move_action_get_float(filter, action, true, - &value)) + if (!nv_move_action_get_float(filter, action, true, &value)) continue; - obs_source_t *source = - obs_weak_source_get_source(action->target); + obs_source_t *source = obs_weak_source_get_source(action->target); if (!source) { if (action->target) { obs_weak_source_release(action->target); @@ -4004,98 +2941,70 @@ static void nv_move_render(void *data, gs_effect_t *effect) } obs_data_t *d = obs_data_create(); if (action->is_int) { - obs_data_set_int(d, action->name, - (long long)value); + obs_data_set_int(d, action->name, (long long)value); } else { - obs_data_set_double(d, action->name, - (double)value); + obs_data_set_double(d, action->name, (double)value); } obs_source_update(source, d); obs_data_release(d); obs_source_release(source); } else if (action->action == ACTION_ENABLE_FILTER) { float value; - if (!nv_move_action_get_float(filter, action, true, - &value)) + if (!nv_move_action_get_float(filter, action, true, &value)) continue; - obs_source_t *source = - obs_weak_source_get_source(action->target); + obs_source_t *source = obs_weak_source_get_source(action->target); if (!source) continue; - if ((action->property == - FEATURE_THRESHOLD_ENABLE_OVER || - action->property == - FEATURE_THRESHOLD_ENABLE_OVER_DISABLE_UNDER) && - value >= action->threshold && - !obs_source_enabled(source)) { + if ((action->property == FEATURE_THRESHOLD_ENABLE_OVER || + action->property == FEATURE_THRESHOLD_ENABLE_OVER_DISABLE_UNDER) && + value >= action->threshold && !obs_source_enabled(source)) { obs_source_set_enabled(source, true); - } else if ((action->property == - FEATURE_THRESHOLD_ENABLE_UNDER || - action->property == - FEATURE_THRESHOLD_ENABLE_UNDER_DISABLE_OVER) && - value < action->threshold && - !obs_source_enabled(source)) { + } else if ((action->property == FEATURE_THRESHOLD_ENABLE_UNDER || + action->property == FEATURE_THRESHOLD_ENABLE_UNDER_DISABLE_OVER) && + value < action->threshold && !obs_source_enabled(source)) { obs_source_set_enabled(source, true); - } else if ((action->property == - FEATURE_THRESHOLD_DISABLE_OVER || - action->property == - FEATURE_THRESHOLD_ENABLE_UNDER_DISABLE_OVER) && - value >= action->threshold && - obs_source_enabled(source)) { + } else if ((action->property == FEATURE_THRESHOLD_DISABLE_OVER || + action->property == FEATURE_THRESHOLD_ENABLE_UNDER_DISABLE_OVER) && + value >= action->threshold && obs_source_enabled(source)) { obs_source_set_enabled(source, false); - } else if ((action->property == - FEATURE_THRESHOLD_DISABLE_UNDER || - action->property == - FEATURE_THRESHOLD_ENABLE_OVER_DISABLE_UNDER) && - value < action->threshold && - obs_source_enabled(source)) { + } else if ((action->property == FEATURE_THRESHOLD_DISABLE_UNDER || + action->property == FEATURE_THRESHOLD_ENABLE_OVER_DISABLE_UNDER) && + value < action->threshold && obs_source_enabled(source)) { obs_source_set_enabled(source, false); } obs_source_release(source); } else if (action->action == ACTION_SOURCE_VISIBILITY) { float value; - if (!nv_move_action_get_float(filter, action, true, - &value)) + if (!nv_move_action_get_float(filter, action, true, &value)) continue; if (!action->name) continue; - obs_source_t *scene_source = - obs_weak_source_get_source(action->target); + obs_source_t *scene_source = obs_weak_source_get_source(action->target); if (!scene_source) continue; - obs_scene_t *scene = - obs_scene_from_source(scene_source); + obs_scene_t *scene = obs_scene_from_source(scene_source); if (!scene) scene = obs_group_from_source(scene_source); obs_source_release(scene_source); if (!scene) continue; - obs_sceneitem_t *item = - obs_scene_find_source(scene, action->name); + obs_sceneitem_t *item = obs_scene_find_source(scene, action->name); if (!item) continue; - if ((action->property == - FEATURE_THRESHOLD_ENABLE_OVER || - action->property == - FEATURE_THRESHOLD_ENABLE_OVER_DISABLE_UNDER) && + if ((action->property == FEATURE_THRESHOLD_ENABLE_OVER || + action->property == FEATURE_THRESHOLD_ENABLE_OVER_DISABLE_UNDER) && value >= action->threshold) { obs_sceneitem_set_visible(item, true); - } else if ((action->property == - FEATURE_THRESHOLD_ENABLE_UNDER || - action->property == - FEATURE_THRESHOLD_ENABLE_UNDER_DISABLE_OVER) && + } else if ((action->property == FEATURE_THRESHOLD_ENABLE_UNDER || + action->property == FEATURE_THRESHOLD_ENABLE_UNDER_DISABLE_OVER) && value < action->threshold) { obs_sceneitem_set_visible(item, true); - } else if ((action->property == - FEATURE_THRESHOLD_DISABLE_OVER || - action->property == - FEATURE_THRESHOLD_ENABLE_UNDER_DISABLE_OVER) && + } else if ((action->property == FEATURE_THRESHOLD_DISABLE_OVER || + action->property == FEATURE_THRESHOLD_ENABLE_UNDER_DISABLE_OVER) && value >= action->threshold) { obs_sceneitem_set_visible(item, false); - } else if ((action->property == - FEATURE_THRESHOLD_DISABLE_UNDER || - action->property == - FEATURE_THRESHOLD_ENABLE_OVER_DISABLE_UNDER) && + } else if ((action->property == FEATURE_THRESHOLD_DISABLE_UNDER || + action->property == FEATURE_THRESHOLD_ENABLE_OVER_DISABLE_UNDER) && value < action->threshold) { obs_sceneitem_set_visible(item, false); } @@ -4143,9 +3052,7 @@ static void nv_move_tick(void *data, float t) filter->processed_frame = false; } -static enum gs_color_space -nv_move_get_color_space(void *data, size_t count, - const enum gs_color_space *preferred_spaces) +static enum gs_color_space nv_move_get_color_space(void *data, size_t count, const enum gs_color_space *preferred_spaces) { const enum gs_color_space potential_spaces[] = { GS_CS_SRGB, @@ -4154,9 +3061,8 @@ nv_move_get_color_space(void *data, size_t count, }; struct nvidia_move_info *filter = (struct nvidia_move_info *)data; - const enum gs_color_space source_space = obs_source_get_color_space( - obs_filter_get_target(filter->source), - OBS_COUNTOF(potential_spaces), potential_spaces); + const enum gs_color_space source_space = + obs_source_get_color_space(obs_filter_get_target(filter->source), OBS_COUNTOF(potential_spaces), potential_spaces); enum gs_color_space space = source_space; for (size_t i = 0; i < count; ++i) { @@ -4177,34 +3083,28 @@ bool load_nvar(void) uint8_t build = (version >> 8) & 0x0000ff; uint8_t revision = (version >> 0) & 0x000000ff; if (version) { - blog(LOG_INFO, - "[Move Transition]: NVIDIA AR version: %i.%i.%i.%i", major, - minor, build, revision); + blog(LOG_INFO, "[Move Transition]: NVIDIA AR version: %i.%i.%i.%i", major, minor, build, revision); } if (!load_nv_ar_libs()) { //blog(LOG_INFO, "[NVIDIA VIDEO FX]: FX disabled, redistributable not found or could not be loaded."); return false; } -#define LOAD_SYM_FROM_LIB(sym, lib, dll) \ - if (!(sym = (sym##_t)GetProcAddress(lib, #sym))) { \ - DWORD err = GetLastError(); \ - printf("[NVIDIA VIDEO FX]: Couldn't load " #sym " from " dll \ - ": %lu (0x%lx)", \ - err, err); \ - release_nv_ar(); \ - goto unload_everything; \ +#define LOAD_SYM_FROM_LIB(sym, lib, dll) \ + if (!(sym = (sym##_t)GetProcAddress(lib, #sym))) { \ + DWORD err = GetLastError(); \ + printf("[NVIDIA VIDEO FX]: Couldn't load " #sym " from " dll ": %lu (0x%lx)", err, err); \ + release_nv_ar(); \ + goto unload_everything; \ } -#define LOAD_SYM_FROM_LIB2(sym, lib, dll) \ - if (!(sym = (sym##_t)GetProcAddress(lib, #sym))) { \ - DWORD err = GetLastError(); \ - printf("[NVIDIA VIDEO FX]: Couldn't load " #sym " from " dll \ - ": %lu (0x%lx)", \ - err, err); \ - nvvfx_new_sdk = false; \ - } else { \ - nvvfx_new_sdk = true; \ +#define LOAD_SYM_FROM_LIB2(sym, lib, dll) \ + if (!(sym = (sym##_t)GetProcAddress(lib, #sym))) { \ + DWORD err = GetLastError(); \ + printf("[NVIDIA VIDEO FX]: Couldn't load " #sym " from " dll ": %lu (0x%lx)", err, err); \ + nvvfx_new_sdk = false; \ + } else { \ + nvvfx_new_sdk = true; \ } #define LOAD_SYM(sym) LOAD_SYM_FROM_LIB(sym, nv_ar, "nvARPose.dll")