New upstream version 18.0.1+dfsg1

This commit is contained in:
Sebastian Ramacher 2017-04-19 21:54:15 +02:00
parent 6efda2859e
commit f2cf6cce50
1337 changed files with 41178 additions and 84670 deletions

View file

@ -20,17 +20,19 @@ include_directories(${LIBSPEEXDSP_INCLUDE_DIRS}
set(obs-filters_SOURCES
obs-filters.c
color-filter.c
color-correction-filter.c
async-delay-filter.c
crop-filter.c
scale-filter.c
scroll-filter.c
chroma-key-filter.c
color-key-filter.c
color-grade-filter.c
sharpness-filter.c
gain-filter.c
noise-gate-filter.c
mask-filter.c)
mask-filter.c
compressor-filter.c)
add_library(obs-filters MODULE
${obs-filters_SOURCES}

View file

@ -0,0 +1,413 @@
/*****************************************************************************
Copyright (C) 2016 by c3r1c3 <c3r1c3@nevermindonline.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/
#include <obs-module.h>
#include <graphics/matrix4.h>
#include <graphics/quat.h>
#define SETTING_GAMMA "gamma"
#define SETTING_CONTRAST "contrast"
#define SETTING_BRIGHTNESS "brightness"
#define SETTING_SATURATION "saturation"
#define SETTING_HUESHIFT "hue_shift"
#define SETTING_OPACITY "opacity"
#define SETTING_COLOR "color"
#define TEXT_GAMMA obs_module_text("Gamma")
#define TEXT_CONTRAST obs_module_text("Contrast")
#define TEXT_BRIGHTNESS obs_module_text("Brightness")
#define TEXT_SATURATION obs_module_text("Saturation")
#define TEXT_HUESHIFT obs_module_text("HueShift")
#define TEXT_OPACITY obs_module_text("Opacity")
#define TEXT_COLOR obs_module_text("Color")
struct color_correction_filter_data {
obs_source_t *context;
gs_effect_t *effect;
gs_eparam_t *gamma_param;
gs_eparam_t *final_matrix_param;
struct vec3 gamma;
float contrast;
float brightness;
float saturation;
float hue_shift;
float opacity;
struct vec4 color;
/* Pre-Computes */
struct matrix4 con_matrix;
struct matrix4 bright_matrix;
struct matrix4 sat_matrix;
struct matrix4 hue_op_matrix;
struct matrix4 color_matrix;
struct matrix4 final_matrix;
struct vec3 rot_quaternion;
float rot_quaternion_w;
struct vec3 cross;
struct vec3 square;
struct vec3 wimag;
struct vec3 diag;
struct vec3 a_line;
struct vec3 b_line;
struct vec3 half_unit;
};
static const float root3 = 0.57735f;
static const float red_weight = 0.299f;
static const float green_weight = 0.587f;
static const float blue_weight = 0.114f;
/*
* As the functions' namesake, this provides the internal name of your Filter,
* which is then translated/referenced in the "data/locale" files.
*/
static const char *color_correction_filter_name(void *unused)
{
UNUSED_PARAMETER(unused);
return obs_module_text("ColorFilter");
}
/*
* This function is called (see bottom of this file for more details)
* whenever the OBS filter interface changes. So when the user is messing
* with a slider this function is called to update the internal settings
* in OBS, and hence the settings being passed to the CPU/GPU.
*/
static void color_correction_filter_update(void *data, obs_data_t *settings)
{
struct color_correction_filter_data *filter = data;
/* Build our Gamma numbers. */
double gamma = obs_data_get_double(settings, SETTING_GAMMA);
gamma = (gamma < 0.0) ? (-gamma + 1.0) : (1.0 / (gamma + 1.0));
vec3_set(&filter->gamma, (float)gamma, (float)gamma, (float)gamma);
/* Build our contrast number. */
filter->contrast = (float)obs_data_get_double(settings,
SETTING_CONTRAST) + 1.0f;
float one_minus_con = (1.0f - filter->contrast) / 2.0f;
/* Now let's build our Contrast matrix. */
filter->con_matrix = (struct matrix4)
{
filter->contrast, 0.0f, 0.0f, 0.0f,
0.0f, filter->contrast, 0.0f, 0.0f,
0.0f, 0.0f, filter->contrast, 0.0f,
one_minus_con, one_minus_con, one_minus_con, 1.0f
};
/* Build our brightness number. */
filter->brightness = (float)obs_data_get_double(settings,
SETTING_BRIGHTNESS);
/*
* Now let's build our Brightness matrix.
* Earlier (in the function color_correction_filter_create) we set
* this matrix to the identity matrix, so now we only need
* to set the 3 variables that have changed.
*/
filter->bright_matrix.t.x = filter->brightness;
filter->bright_matrix.t.y = filter->brightness;
filter->bright_matrix.t.z = filter->brightness;
/* Build our Saturation number. */
filter->saturation = (float)obs_data_get_double(settings,
SETTING_SATURATION) + 1.0f;
/* Factor in the selected color weights. */
float one_minus_sat_red = (1.0f - filter->saturation) * red_weight;
float one_minus_sat_green = (1.0f - filter->saturation) * green_weight;
float one_minus_sat_blue = (1.0f - filter->saturation) * blue_weight;
float sat_val_red = one_minus_sat_red + filter->saturation;
float sat_val_green = one_minus_sat_green + filter->saturation;
float sat_val_blue = one_minus_sat_blue + filter->saturation;
/* Now we build our Saturation matrix. */
filter->sat_matrix = (struct matrix4)
{
sat_val_red, one_minus_sat_red, one_minus_sat_red, 0.0f,
one_minus_sat_green, sat_val_green, one_minus_sat_green, 0.0f,
one_minus_sat_blue, one_minus_sat_blue, sat_val_blue, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f
};
/* Build our Hue number. */
filter->hue_shift = (float)obs_data_get_double(settings,
SETTING_HUESHIFT);
/* Build our Transparency number. */
filter->opacity = (float)obs_data_get_int(settings,
SETTING_OPACITY) * 0.01f;
/* Hue is the radian of 0 to 360 degrees. */
float half_angle = 0.5f * (float)(filter->hue_shift / (180.0f / M_PI));
/* Pseudo-Quaternion To Matrix. */
float rot_quad1 = root3 * (float)sin(half_angle);
vec3_set(&filter->rot_quaternion, rot_quad1, rot_quad1,
rot_quad1);
filter->rot_quaternion_w = (float)cos(half_angle);
vec3_mul(&filter->cross, &filter->rot_quaternion,
&filter->rot_quaternion);
vec3_mul(&filter->square, &filter->rot_quaternion,
&filter->rot_quaternion);
vec3_mulf(&filter->wimag, &filter->rot_quaternion,
filter->rot_quaternion_w);
vec3_mulf(&filter->square, &filter->square, 2.0f);
vec3_sub(&filter->diag, &filter->half_unit, &filter->square);
vec3_add(&filter->a_line, &filter->cross, &filter->wimag);
vec3_sub(&filter->b_line, &filter->cross, &filter->wimag);
/* Now we build our Hue and Opacity matrix. */
filter->hue_op_matrix = (struct matrix4)
{
filter->diag.x * 2.0f,
filter->b_line.z * 2.0f,
filter->a_line.y * 2.0f,
0.0f,
filter->a_line.z * 2.0f,
filter->diag.y * 2.0f,
filter->b_line.x * 2.0f,
0.0f,
filter->b_line.y * 2.0f,
filter->a_line.x * 2.0f,
filter->diag.z * 2.0f,
0.0f,
0.0f, 0.0f, 0.0f, filter->opacity
};
/* Now get the overlay color data. */
uint32_t color = (uint32_t)obs_data_get_int(settings,
SETTING_COLOR);
vec4_from_rgba(&filter->color, color);
/*
* Now let's build our Color 'overlay' matrix.
* Earlier (in the function color_correction_filter_create) we set
* this matrix to the identity matrix, so now we only need
* to set the 6 variables that have changed.
*/
filter->color_matrix.x.x = filter->color.x;
filter->color_matrix.y.y = filter->color.y;
filter->color_matrix.z.z = filter->color.z;
filter->color_matrix.t.x = filter->color.w *
filter->color.x;
filter->color_matrix.t.y = filter->color.w *
filter->color.y;
filter->color_matrix.t.z = filter->color.w *
filter->color.z;
/* First we apply the Contrast & Brightness matrix. */
matrix4_mul(&filter->final_matrix, &filter->bright_matrix,
&filter->con_matrix);
/* Now we apply the Saturation matrix. */
matrix4_mul(&filter->final_matrix, &filter->final_matrix,
&filter->sat_matrix);
/* Next we apply the Hue+Opacity matrix. */
matrix4_mul(&filter->final_matrix, &filter->final_matrix,
&filter->hue_op_matrix);
/* Lastly we apply the Color Wash matrix. */
matrix4_mul(&filter->final_matrix, &filter->final_matrix,
&filter->color_matrix);
}
/*
* Since this is C we have to be careful when destroying/removing items from
* OBS. Jim has added several useful functions to help keep memory leaks to
* a minimum, and handle the destruction and construction of these filters.
*/
static void color_correction_filter_destroy(void *data)
{
struct color_correction_filter_data *filter = data;
if (filter->effect) {
obs_enter_graphics();
gs_effect_destroy(filter->effect);
obs_leave_graphics();
}
bfree(data);
}
/*
* When you apply a filter OBS creates it, and adds it to the source. OBS also
* starts rendering it immediately. This function doesn't just 'create' the
* filter, it also calls the render function (farther below) that contains the
* actual rendering code.
*/
static void *color_correction_filter_create(obs_data_t *settings,
obs_source_t *context)
{
/*
* Because of limitations of pre-c99 compilers, you can't create an
* array that doesn't have a known size at compile time. The below
* function calculates the size needed and allocates memory to
* handle the source.
*/
struct color_correction_filter_data *filter =
bzalloc(sizeof(struct color_correction_filter_data));
/*
* By default the effect file is stored in the ./data directory that
* your filter resides in.
*/
char *effect_path = obs_module_file("color_correction_filter.effect");
filter->context = context;
/* Set/clear/assign for all necessary vectors. */
vec3_set(&filter->half_unit, 0.5f, 0.5f, 0.5f);
matrix4_identity(&filter->bright_matrix);
matrix4_identity(&filter->color_matrix);
/* Here we enter the GPU drawing/shader portion of our code. */
obs_enter_graphics();
/* Load the shader on the GPU. */
filter->effect = gs_effect_create_from_file(effect_path, NULL);
/* If the filter is active pass the parameters to the filter. */
if (filter->effect) {
filter->gamma_param = gs_effect_get_param_by_name(
filter->effect, SETTING_GAMMA);
filter->final_matrix_param = gs_effect_get_param_by_name(
filter->effect, "color_matrix");
}
obs_leave_graphics();
bfree(effect_path);
/*
* If the filter has been removed/deactivated, destroy the filter
* and exit out so we don't crash OBS by telling it to update
* values that don't exist anymore.
*/
if (!filter->effect) {
color_correction_filter_destroy(filter);
return NULL;
}
/*
* It's important to call the update function here. If we don't
* we could end up with the user controlled sliders and values
* updating, but the visuals not updating to match.
*/
color_correction_filter_update(filter, settings);
return filter;
}
/* This is where the actual rendering of the filter takes place. */
static void color_correction_filter_render(void *data, gs_effect_t *effect)
{
struct color_correction_filter_data *filter = data;
if (!obs_source_process_filter_begin(filter->context, GS_RGBA,
OBS_ALLOW_DIRECT_RENDERING))
return;
/* Now pass the interface variables to the .effect file. */
gs_effect_set_vec3(filter->gamma_param, &filter->gamma);
gs_effect_set_matrix4(filter->final_matrix_param, &filter->final_matrix);
obs_source_process_filter_end(filter->context, filter->effect, 0, 0);
UNUSED_PARAMETER(effect);
}
/*
* This function sets the interface. the types (add_*_Slider), the type of
* data collected (int), the internal name, user-facing name, minimum,
* maximum and step values. While a custom interface can be built, for a
* simple filter like this it's better to use the supplied functions.
*/
static obs_properties_t *color_correction_filter_properties(void *data)
{
obs_properties_t *props = obs_properties_create();
obs_properties_add_float_slider(props, SETTING_GAMMA,
TEXT_GAMMA, -3.0f, 3.0f, 0.01f);
obs_properties_add_float_slider(props, SETTING_CONTRAST,
TEXT_CONTRAST, -2.0f, 2.0f, 0.01f);
obs_properties_add_float_slider(props, SETTING_BRIGHTNESS,
TEXT_BRIGHTNESS, -1.0f, 1.0f, 0.01f);
obs_properties_add_float_slider(props, SETTING_SATURATION,
TEXT_SATURATION, -1.0f, 5.0f, 0.01f);
obs_properties_add_float_slider(props, SETTING_HUESHIFT,
TEXT_HUESHIFT, -180.0f, 180.0f, 0.01f);
obs_properties_add_int_slider(props, SETTING_OPACITY,
TEXT_OPACITY, 0, 100, 1);
obs_properties_add_color(props, SETTING_COLOR, TEXT_COLOR);
UNUSED_PARAMETER(data);
return props;
}
/*
* As the functions' namesake, this provides the default settings for any
* options you wish to provide a default for. Try to select defaults that
* make sense to the end user, or that don't effect the data.
* *NOTE* this function is completely optional, as is providing a default
* for any particular setting.
*/
static void color_correction_filter_defaults(obs_data_t *settings)
{
obs_data_set_default_double(settings, SETTING_GAMMA, 0.0);
obs_data_set_default_double(settings, SETTING_CONTRAST, 0.0);
obs_data_set_default_double(settings, SETTING_BRIGHTNESS, 0.0);
obs_data_set_default_double(settings,
SETTING_SATURATION, 0.0);
obs_data_set_default_double(settings, SETTING_HUESHIFT, 0.0);
obs_data_set_default_double(settings, SETTING_OPACITY, 100.0);
obs_data_set_default_int(settings, SETTING_COLOR, 0xFFFFFF);
}
/*
* So how does OBS keep track of all these plug-ins/filters? How does OBS know
* which function to call when it needs to update a setting? Or a source? Or
* what type of source this is?
*
* OBS does it through the obs_source_info_struct. Notice how variables are
* assigned the name of a function? Notice how the function name has the
* variable name in it? While not mandatory, it helps a ton for you (and those
* reading your code) to follow this convention.
*/
struct obs_source_info color_filter = {
.id = "color_filter",
.type = OBS_SOURCE_TYPE_FILTER,
.output_flags = OBS_SOURCE_VIDEO,
.get_name = color_correction_filter_name,
.create = color_correction_filter_create,
.destroy = color_correction_filter_destroy,
.video_render = color_correction_filter_render,
.update = color_correction_filter_update,
.get_properties = color_correction_filter_properties,
.get_defaults = color_correction_filter_defaults
};

View file

@ -1,174 +0,0 @@
#include <obs-module.h>
#include <graphics/vec4.h>
#define SETTING_COLOR "color"
#define SETTING_OPACITY "opacity"
#define SETTING_CONTRAST "contrast"
#define SETTING_BRIGHTNESS "brightness"
#define SETTING_GAMMA "gamma"
#define TEXT_COLOR obs_module_text("Color")
#define TEXT_OPACITY obs_module_text("Opacity")
#define TEXT_CONTRAST obs_module_text("Contrast")
#define TEXT_BRIGHTNESS obs_module_text("Brightness")
#define TEXT_GAMMA obs_module_text("Gamma")
#define MIN_CONTRAST 0.5f
#define MAX_CONTRAST 2.0f
#define MIN_BRIGHTNESS -1.0
#define MAX_BRIGHTNESS 1.0
struct color_filter_data {
obs_source_t *context;
gs_effect_t *effect;
gs_eparam_t *color_param;
gs_eparam_t *contrast_param;
gs_eparam_t *brightness_param;
gs_eparam_t *gamma_param;
struct vec4 color;
float contrast;
float brightness;
float gamma;
};
static const char *color_filter_name(void *unused)
{
UNUSED_PARAMETER(unused);
return obs_module_text("ColorFilter");
}
static void color_filter_update(void *data, obs_data_t *settings)
{
struct color_filter_data *filter = data;
uint32_t color = (uint32_t)obs_data_get_int(settings, SETTING_COLOR);
uint32_t opacity = (uint32_t)obs_data_get_int(settings,
SETTING_OPACITY);
double contrast = obs_data_get_double(settings, SETTING_CONTRAST);
double brightness = obs_data_get_double(settings, SETTING_BRIGHTNESS);
double gamma = obs_data_get_double(settings, SETTING_GAMMA);
color &= 0xFFFFFF;
color |= ((opacity * 255) / 100) << 24;
vec4_from_rgba(&filter->color, color);
contrast = (contrast < 0.0) ?
(1.0 / (-contrast + 1.0)) : (contrast + 1.0);
brightness *= 0.5;
gamma = (gamma < 0.0) ? (-gamma + 1.0) : (1.0 / (gamma + 1.0));
filter->contrast = (float)contrast;
filter->brightness = (float)brightness;
filter->gamma = (float)gamma;
}
static void color_filter_destroy(void *data)
{
struct color_filter_data *filter = data;
if (filter->effect) {
obs_enter_graphics();
gs_effect_destroy(filter->effect);
obs_leave_graphics();
}
bfree(data);
}
static void *color_filter_create(obs_data_t *settings, obs_source_t *context)
{
struct color_filter_data *filter =
bzalloc(sizeof(struct color_filter_data));
char *effect_path = obs_module_file("color_filter.effect");
filter->context = context;
obs_enter_graphics();
filter->effect = gs_effect_create_from_file(effect_path, NULL);
if (filter->effect) {
filter->color_param = gs_effect_get_param_by_name(
filter->effect, "color");
filter->contrast_param = gs_effect_get_param_by_name(
filter->effect, "contrast");
filter->brightness_param = gs_effect_get_param_by_name(
filter->effect, "brightness");
filter->gamma_param = gs_effect_get_param_by_name(
filter->effect, "gamma");
}
obs_leave_graphics();
bfree(effect_path);
if (!filter->effect) {
color_filter_destroy(filter);
return NULL;
}
color_filter_update(filter, settings);
return filter;
}
static void color_filter_render(void *data, gs_effect_t *effect)
{
struct color_filter_data *filter = data;
if (!obs_source_process_filter_begin(filter->context, GS_RGBA,
OBS_ALLOW_DIRECT_RENDERING))
return;
gs_effect_set_vec4(filter->color_param, &filter->color);
gs_effect_set_float(filter->contrast_param, filter->contrast);
gs_effect_set_float(filter->brightness_param, filter->brightness);
gs_effect_set_float(filter->gamma_param, filter->gamma);
obs_source_process_filter_end(filter->context, filter->effect, 0, 0);
UNUSED_PARAMETER(effect);
}
static obs_properties_t *color_filter_properties(void *data)
{
obs_properties_t *props = obs_properties_create();
obs_properties_add_color(props, SETTING_COLOR, TEXT_COLOR);
obs_properties_add_int(props, SETTING_OPACITY, TEXT_OPACITY,
0, 100, 1);
obs_properties_add_float_slider(props, SETTING_CONTRAST,
TEXT_CONTRAST, -1.0, 1.0, 0.01);
obs_properties_add_float_slider(props, SETTING_BRIGHTNESS,
TEXT_BRIGHTNESS, -1.0, 1.0, 0.01);
obs_properties_add_float_slider(props, SETTING_GAMMA,
TEXT_GAMMA, -1.0, 1.0, 0.01);
UNUSED_PARAMETER(data);
return props;
}
static void color_filter_defaults(obs_data_t *settings)
{
obs_data_set_default_int(settings, SETTING_COLOR, 0xFFFFFF);
obs_data_set_default_int(settings, SETTING_OPACITY, 100);
obs_data_set_default_double(settings, SETTING_CONTRAST, 0.0);
obs_data_set_default_double(settings, SETTING_BRIGHTNESS, 0.0);
obs_data_set_default_double(settings, SETTING_GAMMA, 0.0);
}
struct obs_source_info color_filter = {
.id = "color_filter",
.type = OBS_SOURCE_TYPE_FILTER,
.output_flags = OBS_SOURCE_VIDEO,
.get_name = color_filter_name,
.create = color_filter_create,
.destroy = color_filter_destroy,
.video_render = color_filter_render,
.update = color_filter_update,
.get_properties = color_filter_properties,
.get_defaults = color_filter_defaults
};

View file

@ -0,0 +1,159 @@
#include <obs-module.h>
#include <graphics/image-file.h>
#include <util/dstr.h>
#define SETTING_IMAGE_PATH "image_path"
#define SETTING_CLUT_AMOUNT "clut_amount"
#define TEXT_IMAGE_PATH obs_module_text("Path")
#define TEXT_AMOUNT obs_module_text("Amount")
struct lut_filter_data {
obs_source_t *context;
gs_effect_t *effect;
gs_texture_t *target;
gs_image_file_t image;
char *file;
float clut_amount;
};
static const char *color_grade_filter_get_name(void *unused)
{
UNUSED_PARAMETER(unused);
return obs_module_text("ColorGradeFilter");
}
static void color_grade_filter_update(void *data, obs_data_t *settings)
{
struct lut_filter_data *filter = data;
const char *path = obs_data_get_string(settings, SETTING_IMAGE_PATH);
double clut_amount = obs_data_get_double(settings, SETTING_CLUT_AMOUNT);
bfree(filter->file);
if (path)
filter->file = bstrdup(path);
obs_enter_graphics();
gs_image_file_free(&filter->image);
obs_leave_graphics();
gs_image_file_init(&filter->image, path);
obs_enter_graphics();
gs_image_file_init_texture(&filter->image);
filter->target = filter->image.texture;
filter->clut_amount = (float)clut_amount;
char *effect_path = obs_module_file("color_grade_filter.effect");
gs_effect_destroy(filter->effect);
filter->effect = gs_effect_create_from_file(effect_path, NULL);
bfree(effect_path);
obs_leave_graphics();
}
static void color_grade_filter_defaults(obs_data_t *settings)
{
obs_data_set_default_double(settings, SETTING_CLUT_AMOUNT, 1);
}
static obs_properties_t *color_grade_filter_properties(void *data)
{
struct lut_filter_data *s = data;
struct dstr path = {0};
const char *slash;
obs_properties_t *props = obs_properties_create();
struct dstr filter_str = {0};
dstr_cat(&filter_str, "(*.png)");
if (s && s->file && *s->file) {
dstr_copy(&path, s->file);
} else {
dstr_copy(&path, obs_module_file("LUTs"));
dstr_cat_ch(&path, '/');
}
dstr_replace(&path, "\\", "/");
slash = strrchr(path.array, '/');
if (slash)
dstr_resize(&path, slash - path.array + 1);
obs_properties_add_path(props, SETTING_IMAGE_PATH, TEXT_IMAGE_PATH,
OBS_PATH_FILE, filter_str.array, path.array);
obs_properties_add_float_slider(props, SETTING_CLUT_AMOUNT,
TEXT_AMOUNT, 0, 1, 0.01);
dstr_free(&filter_str);
UNUSED_PARAMETER(data);
return props;
}
static void *color_grade_filter_create(
obs_data_t *settings, obs_source_t *context)
{
struct lut_filter_data *filter =
bzalloc(sizeof(struct lut_filter_data));
filter->context = context;
obs_source_update(context, settings);
return filter;
}
static void color_grade_filter_destroy(void *data)
{
struct lut_filter_data *filter = data;
obs_enter_graphics();
gs_effect_destroy(filter->effect);
gs_image_file_free(&filter->image);
obs_leave_graphics();
bfree(filter->file);
bfree(filter);
}
static void color_grade_filter_render(void *data, gs_effect_t *effect)
{
struct lut_filter_data *filter = data;
obs_source_t *target = obs_filter_get_target(filter->context);
gs_eparam_t *param;
if (!target || !filter->target || !filter->effect) {
obs_source_skip_video_filter(filter->context);
return;
}
if (!obs_source_process_filter_begin(filter->context, GS_RGBA,
OBS_ALLOW_DIRECT_RENDERING))
return;
param = gs_effect_get_param_by_name(filter->effect, "clut");
gs_effect_set_texture(param, filter->target);
param = gs_effect_get_param_by_name(filter->effect, "clut_amount");
gs_effect_set_float(param, filter->clut_amount);
obs_source_process_filter_end(filter->context, filter->effect, 0, 0);
UNUSED_PARAMETER(effect);
}
struct obs_source_info color_grade_filter = {
.id = "clut_filter",
.type = OBS_SOURCE_TYPE_FILTER,
.output_flags = OBS_SOURCE_VIDEO,
.get_name = color_grade_filter_get_name,
.create = color_grade_filter_create,
.destroy = color_grade_filter_destroy,
.update = color_grade_filter_update,
.get_defaults = color_grade_filter_defaults,
.get_properties = color_grade_filter_properties,
.video_render = color_grade_filter_render
};

View file

@ -0,0 +1,231 @@
#include <stdint.h>
#include <inttypes.h>
#include <math.h>
#include <obs-module.h>
#include <media-io/audio-math.h>
/* -------------------------------------------------------- */
#define do_log(level, format, ...) \
blog(level, "[compressor: '%s'] " format, \
obs_source_get_name(cd->context), ##__VA_ARGS__)
#define warn(format, ...) do_log(LOG_WARNING, format, ##__VA_ARGS__)
#define info(format, ...) do_log(LOG_INFO, format, ##__VA_ARGS__)
#ifdef _DEBUG
#define debug(format, ...) do_log(LOG_DEBUG, format, ##__VA_ARGS__)
#else
#define debug(format, ...)
#endif
/* -------------------------------------------------------- */
#define S_RATIO "ratio"
#define S_THRESHOLD "threshold"
#define S_ATTACK_TIME "attack_time"
#define S_RELEASE_TIME "release_time"
#define S_OUTPUT_GAIN "output_gain"
#define MT_ obs_module_text
#define TEXT_RATIO MT_("Compressor.Ratio")
#define TEXT_THRESHOLD MT_("Compressor.Threshold")
#define TEXT_ATTACK_TIME MT_("Compressor.AttackTime")
#define TEXT_RELEASE_TIME MT_("Compressor.ReleaseTime")
#define TEXT_OUTPUT_GAIN MT_("Compressor.OutputGain")
#define MIN_RATIO 1.0f
#define MAX_RATIO 32.0f
#define MIN_THRESHOLD_DB -60.0f
#define MAX_THRESHOLD_DB 0.0f
#define MIN_OUTPUT_GAIN_DB -32.0f
#define MAX_OUTPUT_GAIN_DB 32.0f
#define MIN_ATK_RLS_MS 1
#define MAX_RLS_MS 1000
#define MAX_ATK_MS 500
#define DEFAULT_AUDIO_BUF_MS 10
#define MS_IN_S 1000
#define MS_IN_S_F ((float)MS_IN_S)
/* -------------------------------------------------------- */
struct compressor_data {
obs_source_t *context;
float *envelope_buf;
size_t envelope_buf_len;
float ratio;
float threshold;
float attack_gain;
float release_gain;
float output_gain;
size_t num_channels;
float envelope;
float slope;
};
/* -------------------------------------------------------- */
static inline void resize_env_buffer(struct compressor_data *cd, size_t len)
{
cd->envelope_buf_len = len;
cd->envelope_buf = brealloc(cd->envelope_buf, len * sizeof(float));
}
static inline float gain_coefficient(uint32_t sample_rate, float time)
{
return (float)exp(-1.0f / (sample_rate * time));
}
static const char *compressor_name(void *unused)
{
UNUSED_PARAMETER(unused);
return obs_module_text("Compressor");
}
static void compressor_update(void *data, obs_data_t *s)
{
struct compressor_data *cd = data;
const uint32_t sample_rate =
audio_output_get_sample_rate(obs_get_audio());
const size_t num_channels =
audio_output_get_channels(obs_get_audio());
const float attack_time_ms =
(float)obs_data_get_int(s, S_ATTACK_TIME);
const float release_time_ms =
(float)obs_data_get_int(s, S_RELEASE_TIME);
const float output_gain_db =
(float)obs_data_get_double(s, S_OUTPUT_GAIN);
if (cd->envelope_buf_len <= 0) {
resize_env_buffer(cd,
sample_rate * DEFAULT_AUDIO_BUF_MS / MS_IN_S);
}
cd->ratio = (float)obs_data_get_double(s, S_RATIO);
cd->threshold = (float)obs_data_get_double(s, S_THRESHOLD);
cd->attack_gain = gain_coefficient(sample_rate,
attack_time_ms / MS_IN_S_F);
cd->release_gain = gain_coefficient(sample_rate,
release_time_ms / MS_IN_S_F);
cd->output_gain = db_to_mul(output_gain_db);
cd->num_channels = num_channels;
cd->slope = 1.0f - (1.0f / cd->ratio);
}
static void *compressor_create(obs_data_t *settings, obs_source_t *filter)
{
struct compressor_data *cd = bzalloc(sizeof(struct compressor_data));
cd->context = filter;
compressor_update(cd, settings);
return cd;
}
static void compressor_destroy(void *data)
{
struct compressor_data *cd = data;
bfree(cd->envelope_buf);
bfree(cd);
}
static inline void analyze_envelope(struct compressor_data *cd,
const float **samples, const uint32_t num_samples)
{
if (cd->envelope_buf_len < num_samples) {
resize_env_buffer(cd, num_samples);
}
memset(cd->envelope_buf, 0, num_samples * sizeof(cd->envelope_buf[0]));
for (size_t chan = 0; chan < cd->num_channels; ++chan) {
if (samples[chan]) {
float env = cd->envelope;
for (uint32_t i = 0; i < num_samples; ++i) {
const float env_in = fabsf(samples[chan][i]);
if (env < env_in) {
env = env_in + cd->attack_gain *
(env - env_in);
} else {
env = env_in + cd->release_gain *
(env - env_in);
}
cd->envelope_buf[i] = fmaxf(
cd->envelope_buf[i], env);
}
}
}
cd->envelope = cd->envelope_buf[num_samples - 1];
}
static inline void process_compression(const struct compressor_data *cd,
float **samples, uint32_t num_samples)
{
for (size_t i = 0; i < num_samples; ++i) {
const float env_db = mul_to_db(cd->envelope_buf[i]);
float gain = cd->slope * (cd->threshold - env_db);
gain = db_to_mul(fminf(0, gain));
for (size_t c = 0; c < cd->num_channels; ++c) {
if (samples[c]) {
samples[c][i] *= gain * cd->output_gain;
}
}
}
}
static struct obs_audio_data *compressor_filter_audio(void *data,
struct obs_audio_data *audio)
{
struct compressor_data *cd = data;
const uint32_t num_samples = audio->frames;
float **samples = (float**)audio->data;
analyze_envelope(cd, samples, num_samples);
process_compression(cd, samples, num_samples);
return audio;
}
static void compressor_defaults(obs_data_t *s)
{
obs_data_set_default_double(s, S_RATIO, 10.0f);
obs_data_set_default_double(s, S_THRESHOLD, -18.0f);
obs_data_set_default_int(s, S_ATTACK_TIME, 6);
obs_data_set_default_int(s, S_RELEASE_TIME, 60);
obs_data_set_default_double(s, S_OUTPUT_GAIN, 0.0f);
}
static obs_properties_t *compressor_properties(void *data)
{
obs_properties_t *props = obs_properties_create();
obs_properties_add_float_slider(props, S_RATIO,
TEXT_RATIO, MIN_RATIO, MAX_RATIO, 0.5f);
obs_properties_add_float_slider(props, S_THRESHOLD,
TEXT_THRESHOLD, MIN_THRESHOLD_DB, MAX_THRESHOLD_DB, 0.1f);
obs_properties_add_int_slider(props, S_ATTACK_TIME,
TEXT_ATTACK_TIME, MIN_ATK_RLS_MS, MAX_ATK_MS, 1);
obs_properties_add_int_slider(props, S_RELEASE_TIME,
TEXT_RELEASE_TIME, MIN_ATK_RLS_MS, MAX_RLS_MS, 1);
obs_properties_add_float_slider(props, S_OUTPUT_GAIN,
TEXT_OUTPUT_GAIN, MIN_OUTPUT_GAIN_DB, MAX_OUTPUT_GAIN_DB, 0.1f);
UNUSED_PARAMETER(data);
return props;
}
struct obs_source_info compressor_filter = {
.id = "compressor_filter",
.type = OBS_SOURCE_TYPE_FILTER,
.output_flags = OBS_SOURCE_AUDIO,
.get_name = compressor_name,
.create = compressor_create,
.destroy = compressor_destroy,
.update = compressor_update,
.filter_audio = compressor_filter_audio,
.get_defaults = compressor_defaults,
.get_properties = compressor_properties,
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 KiB

View file

@ -0,0 +1,71 @@
/*****************************************************************************
Copyright (C) 2016 by c3r1c3 <c3r1c3@nevermindonline.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/
uniform float4x4 ViewProj;
uniform texture2d image;
uniform float3 gamma;
/* Pre-Compute variables. */
uniform float4x4 color_matrix;
sampler_state textureSampler {
Filter = Linear;
AddressU = Clamp;
AddressV = Clamp;
};
struct VertData {
float4 pos : POSITION;
float2 uv : TEXCOORD0;
};
VertData VSDefault(VertData vert_in)
{
VertData vert_out;
vert_out.pos = mul(float4(vert_in.pos.xyz, 1.0), ViewProj);
vert_out.uv = vert_in.uv;
return vert_out;
}
float4 PSColorFilterRGBA(VertData vert_in) : TARGET
{
/* Grab the current pixel to perform operations on. */
float4 currentPixel = image.Sample(textureSampler, vert_in.uv);
/* Always address the gamma first. */
currentPixel.rgb = pow(currentPixel.rgb, gamma);
/* Much easier to manipulate pixels for these types of operations
* when in a matrix such as the below. See
* http://www.graficaobscura.com/matrix/index.html and
* https://docs.rainmeter.net/tips/colormatrix-guide/for more info.
*/
currentPixel = mul(color_matrix, currentPixel);
return currentPixel;
}
technique Draw
{
pass
{
vertex_shader = VSDefault(vert_in);
pixel_shader = PSColorFilterRGBA(vert_in);
}
}

View file

@ -1,46 +0,0 @@
uniform float4x4 ViewProj;
uniform texture2d image;
uniform float4 color;
uniform float contrast;
uniform float brightness;
uniform float gamma;
sampler_state textureSampler {
Filter = Linear;
AddressU = Clamp;
AddressV = Clamp;
};
struct VertData {
float4 pos : POSITION;
float2 uv : TEXCOORD0;
};
VertData VSDefault(VertData v_in)
{
VertData vert_out;
vert_out.pos = mul(float4(v_in.pos.xyz, 1.0), ViewProj);
vert_out.uv = v_in.uv;
return vert_out;
}
float4 CalcColor(float4 rgba)
{
return float4(pow(rgba.rgb, float3(gamma, gamma, gamma)) * contrast + brightness, rgba.a);
}
float4 PSColorFilterRGBA(VertData v_in) : TARGET
{
float4 rgba = image.Sample(textureSampler, v_in.uv) * color;
return CalcColor(rgba);
}
technique Draw
{
pass
{
vertex_shader = VSDefault(v_in);
pixel_shader = PSColorFilterRGBA(v_in);
}
}

View file

@ -0,0 +1,66 @@
uniform float4x4 ViewProj;
uniform texture2d image;
uniform texture2d clut;
uniform float clut_amount;
sampler_state textureSampler {
Filter = Linear;
AddressU = Clamp;
AddressV = Clamp;
};
struct VertDataIn {
float4 pos : POSITION;
float2 uv : TEXCOORD0;
};
struct VertDataOut {
float4 pos : POSITION;
float2 uv : TEXCOORD0;
};
VertDataOut VSDefault(VertDataIn v_in)
{
VertDataOut vert_out;
vert_out.uv = v_in.uv;
vert_out.pos = mul(float4(v_in.pos.xyz, 1.0), ViewProj);
return vert_out;
}
float4 LUT(VertDataOut v_in) : TARGET
{
float4 textureColor = image.Sample(textureSampler, v_in.uv);
float blueColor = textureColor.b * 63.0;
float2 quad1;
quad1.y = floor(floor(blueColor) / 8.0);
quad1.x = floor(blueColor) - (quad1.y * 8.0);
float2 quad2;
quad2.y = floor(ceil(blueColor) / 8.0);
quad2.x = ceil(blueColor) - (quad2.y * 8.0);
float2 texPos1;
texPos1.x = (quad1.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * textureColor.r);
texPos1.y = (quad1.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * textureColor.g);
float2 texPos2;
texPos2.x = (quad2.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * textureColor.r);
texPos2.y = (quad2.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * textureColor.g);
float4 newColor1 = clut.Sample(textureSampler, texPos1);
float4 newColor2 = clut.Sample(textureSampler, texPos2);
float4 luttedColor = lerp(newColor1, newColor2, frac(blueColor));
return lerp(textureColor, luttedColor, clut_amount);
}
technique Draw
{
pass
{
vertex_shader = VSDefault(v_in);
pixel_shader = LUT(v_in);
}
}

View file

@ -1,4 +1,5 @@
ColorFilter="Correcció de color"
ColorGradeFilter="Aplica LUT"
MaskFilter="Màscara d'imatge o barreja"
AsyncDelayFilter="Retard del vídeo (asíncron)"
CropFilter="Escapça/Encoixinar"
@ -7,6 +8,7 @@ ChromaKeyFilter="Clau croma"
ColorKeyFilter="Clau de color"
SharpnessFilter="Agudesa"
ScaleFilter="Escala/Relació d'Aspecte"
UndistortCenter="No distorsionis el centre de la imatge en escalar des d'una ultrapanoràmica"
NoiseGate="Porta de soroll"
NoiseSuppress="Supressió de soroll"
Gain="Guany"
@ -61,4 +63,13 @@ ScaleFiltering.Bilinear="Bilineal"
ScaleFiltering.Bicubic="Bicúbic"
ScaleFiltering.Lanczos="Lanczos"
NoiseSuppress.SuppressLevel="Nivell de supressió (dB)"
Saturation="Saturació"
HueShift="Cavi de tonalitat"
Amount="Quantitat"
Compressor="Compressor"
Compressor.Ratio="Proporció (X:1)"
Compressor.Threshold="Llindar (dB)"
Compressor.AttackTime="Atac (ms)"
Compressor.ReleaseTime="Llançament (ms)"
Compressor.OutputGain="Guany de sortida (dB)"

View file

@ -1,4 +1,5 @@
ColorFilter="Korekce barev"
ColorGradeFilter="Použít LUT"
MaskFilter="Maska obrazu/prolnutí"
AsyncDelayFilter="Zpoždění obrazu"
CropFilter="Oříznutí/odsazení"
@ -7,6 +8,7 @@ ChromaKeyFilter="Chroma Key"
ColorKeyFilter="Klíč barvy"
SharpnessFilter="Ostření"
ScaleFilter="Škálování/poměr stran"
UndistortCenter="Zlepší střed obrázku při škálování z ultra-širokého obrazu"
NoiseGate="Šumová brána"
NoiseSuppress="Potlačení šumu"
Gain="Zisk"
@ -61,4 +63,7 @@ ScaleFiltering.Bilinear="Bilineární"
ScaleFiltering.Bicubic="Bikubický"
ScaleFiltering.Lanczos="Lanczos"
NoiseSuppress.SuppressLevel="Úroveň potlačení (dB)"
Saturation="Saturace"
HueShift="Posun odstínu"
Amount="Množství"

View file

@ -1,11 +1,16 @@
ColorFilter="Farvekorrektion"
ColorGradeFilter="Anvend LUT"
MaskFilter="Billede maske/blanding"
AsyncDelayFilter="Video forsinkelse (asynkron)"
CropFilter="Beskæring/Polstring"
ScrollFilter="Rul"
ChromaKeyFilter="Chroma nøgle"
ColorKeyFilter="Farvenøgle"
SharpnessFilter="Skarphed"
ScaleFilter="Skalering/Formatforhold"
UndistortCenter="Fjern forvrængning af billedets midte ved skalering fra ultrabred"
NoiseGate="Noise Gate"
NoiseSuppress="Støjundertrykkelse"
Gain="Forstærkning"
DelayMs="Forsinkelse (millisekunder)"
Type="Type"
@ -43,6 +48,22 @@ Red="Rød"
Green="Grøn"
Blue="Blå"
Magenta="Magenta"
NoiseGate.OpenThreshold="Åbne-tærskel (dB)"
NoiseGate.CloseThreshold="Lukke-tærskel (dB)"
NoiseGate.AttackTime="Effektueringstid (millisek.)"
NoiseGate.HoldTime="Holdetid (millisek.)"
NoiseGate.ReleaseTime="Frigivelsestid (millisek.)"
Gain.GainDB="Forstærkning (dB)"
StretchImage="Stræk billedet (ignorer størrelsesforhold)"
Resolution="Opløsning"
None="Ingen"
ScaleFiltering="Skaleringsfilter"
ScaleFiltering.Point="Punkt"
ScaleFiltering.Bilinear="Bilineær"
ScaleFiltering.Bicubic="Bikubisk"
ScaleFiltering.Lanczos="Lanczos"
NoiseSuppress.SuppressLevel="Undertrykkelsesniveau (dB)"
Saturation="Mætning"
HueShift="Nuanceskift"
Amount="Værdi"

View file

@ -1,4 +1,5 @@
ColorFilter="Farbkorrektur"
ColorGradeFilter="LUT anwenden"
MaskFilter="Bild Maske/Blend"
AsyncDelayFilter="Videoverzögerung (Asynchron)"
CropFilter="Zuschneiden/Pad"
@ -7,6 +8,7 @@ ChromaKeyFilter="Chroma Key"
ColorKeyFilter="Color Key"
SharpnessFilter="Schärfen"
ScaleFilter="Skalierung/Seitenverhältnis"
UndistortCenter="Entzerre Mitte des Bildes bei der Skalierung von Ultraweitwinkel"
NoiseGate="Noise Gate"
NoiseSuppress="Rauschunterdrückung"
Gain="Gain"
@ -61,4 +63,13 @@ ScaleFiltering.Bilinear="Bilinear"
ScaleFiltering.Bicubic="Bicubic"
ScaleFiltering.Lanczos="Lanczos"
NoiseSuppress.SuppressLevel="Unterdrückungspegel (dB)"
Saturation="Sättigung"
HueShift="Farbtonverschiebung"
Amount="Betrag"
Compressor="Kompressor"
Compressor.Ratio="Verhältnis (X:1)"
Compressor.Threshold="Schwelle (dB)"
Compressor.AttackTime="Angriff (ms)"
Compressor.ReleaseTime="Freigabe (ms)"
Compressor.OutputGain="Ausgangspegel (dB)"

View file

@ -1,4 +1,5 @@
ColorFilter="Color Correction"
ColorGradeFilter="Apply LUT"
MaskFilter="Image Mask/Blend"
AsyncDelayFilter="Video Delay (Async)"
CropFilter="Crop/Pad"
@ -7,6 +8,7 @@ ChromaKeyFilter="Chroma Key"
ColorKeyFilter="Color Key"
SharpnessFilter="Sharpen"
ScaleFilter="Scaling/Aspect Ratio"
UndistortCenter="Undistort center of image when scaling from ultrawide"
NoiseGate="Noise Gate"
NoiseSuppress="Noise Suppression"
Gain="Gain"
@ -61,3 +63,12 @@ ScaleFiltering.Bilinear="Bilinear"
ScaleFiltering.Bicubic="Bicubic"
ScaleFiltering.Lanczos="Lanczos"
NoiseSuppress.SuppressLevel="Suppression Level (dB)"
Saturation="Saturation"
HueShift="Hue Shift"
Amount="Amount"
Compressor="Compressor"
Compressor.Ratio="Ratio (X:1)"
Compressor.Threshold="Threshold (dB)"
Compressor.AttackTime="Attack (ms)"
Compressor.ReleaseTime="Release (ms)"
Compressor.OutputGain="Output Gain (dB)"

View file

@ -1,4 +1,5 @@
ColorFilter="Corrección de color"
ColorGradeFilter="Aplicar LUT"
MaskFilter="Imagen máscara/mezcla"
AsyncDelayFilter="Demora de Video (asincróno)"
CropFilter="Recortar/Acolchar"
@ -7,6 +8,7 @@ ChromaKeyFilter="Fondro croma"
ColorKeyFilter="Filtro de color"
SharpnessFilter="Filtro de enfoque"
ScaleFilter="Escala/Relación de Aspecto"
UndistortCenter="No distorsionar el centro de la imagen en escalar des de una ultrapanorámica"
NoiseGate="Puerta anti-ruidos"
NoiseSuppress="Eliminación de ruido"
Gain="Ganancia"
@ -61,4 +63,13 @@ ScaleFiltering.Bilinear="Bilineal"
ScaleFiltering.Bicubic="Bicúbico"
ScaleFiltering.Lanczos="Lanczos"
NoiseSuppress.SuppressLevel="Nivel de eliminación de ruido (dB)"
Saturation="Saturación"
HueShift="Cambio de tonalidad"
Amount="Cantidad"
Compressor="Compresor"
Compressor.Ratio="Relación (X:1)"
Compressor.Threshold="Umbral (dB)"
Compressor.AttackTime="Ataque (ms)"
Compressor.ReleaseTime="Liberación (ms)"
Compressor.OutputGain="Ganancia de salida (dB)"

View file

@ -0,0 +1,16 @@
ColorFilter="Värvi korrektsioon"
ColorGradeFilter="Lisa LUT"
Gain="Võimendus"
Contrast="Kontrast"
Brightness="Heledus"
Gamma="Gamma"
BrowsePath.Images="Kõik pildifailid"
Crop.Left="Vasakult"
Crop.Right="Paremalt"
Crop.Top="Ülevalt"
Crop.Bottom="Alt"
Crop.Width="Laius"
Crop.Height="Kõrgus"
Crop.Relative="Suhteline"
Amount="Kogus"

View file

@ -1,4 +1,5 @@
ColorFilter="Kolore-zuzenketa"
ColorGradeFilter="Aplikatu LUT"
MaskFilter="Irudi maskara/nahasketa"
AsyncDelayFilter="Bideo atzerapena (Async)"
CropFilter="Moztu/Bete"
@ -7,6 +8,7 @@ ChromaKeyFilter="Kroma gakoa"
ColorKeyFilter="Kolore gakoa"
SharpnessFilter="Enfokea"
ScaleFilter="Eskala/Aspektu-erlazioa"
UndistortCenter="Ez distortsionatu irudiaren erdigunea ultra zabala eskalatzean"
NoiseGate="Zarata atalasea"
NoiseSuppress="Zarata kendu"
Gain="Irabazia"
@ -61,4 +63,13 @@ ScaleFiltering.Bilinear="Bilineala"
ScaleFiltering.Bicubic="Bikubikoa"
ScaleFiltering.Lanczos="Lanczos"
NoiseSuppress.SuppressLevel="Kenketaren maila (dB)"
Saturation="Margoasetasuna"
HueShift="Nabardura Aldaketa"
Amount="Zenbatekoa"
Compressor="Konprimitzailea"
Compressor.Ratio="Erlazioa (X:1)"
Compressor.Threshold="Atalasea (dB)"
Compressor.AttackTime="Erasoa (ms)"
Compressor.ReleaseTime="Askapena (ms)"
Compressor.OutputGain="Irteerako irabazia (dB)"

View file

@ -1,4 +1,5 @@
ColorFilter="Värinkorjaus"
ColorGradeFilter="Käytä LUT"
MaskFilter="Kuvamaski/Sekoitus"
AsyncDelayFilter="Kuvan viive (Async)"
CropFilter="Rajaa"
@ -7,6 +8,7 @@ ChromaKeyFilter="Läpinäkyvä tausta"
ColorKeyFilter="Väriavain"
SharpnessFilter="Terävöitä"
ScaleFilter="Skaalaus/Kuvasuhde"
UndistortCenter="Poista vääristymä keskeltä kuvaa skaalattaessa ultra-leveästä"
NoiseGate="Noise Gate"
NoiseSuppress="Melunvaimennus"
Gain="Vahvistus"
@ -61,4 +63,13 @@ ScaleFiltering.Bilinear="Bilinear"
ScaleFiltering.Bicubic="Bicubic"
ScaleFiltering.Lanczos="Lanczos"
NoiseSuppress.SuppressLevel="Vaimennustaso (dB)"
Saturation="Värikylläisyys"
HueShift="Värisävy"
Amount="Määrä"
Compressor="Kompressori"
Compressor.Ratio="Suhde (X:1)"
Compressor.Threshold="Kynnysarvo (dB)"
Compressor.AttackTime="Attack-aika (ms)"
Compressor.ReleaseTime="Vapautumisaika (ms)"
Compressor.OutputGain="Signaalin vahvistus (dB)"

View file

@ -1,4 +1,5 @@
ColorFilter="Corrections colorimétrique"
ColorGradeFilter="Appliquer LUT"
MaskFilter="Masque d'image/mélange"
AsyncDelayFilter="Retard vidéo (async.)"
CropFilter="Rogner / Encadrer"
@ -7,6 +8,7 @@ ChromaKeyFilter="Clé chromatique"
ColorKeyFilter="Couleur d'incrustation"
SharpnessFilter="Accentuer"
ScaleFilter="Mise à léchelle / Ratio d'affichage"
UndistortCenter="Ne pas déformer le centre de l'image lors d'une mise à l'échelle ultra large"
NoiseGate="Noise Gate"
NoiseSuppress="Suppression du bruit"
Gain="Gain"
@ -61,4 +63,13 @@ ScaleFiltering.Bilinear="Bilinéaire"
ScaleFiltering.Bicubic="Bicubique"
ScaleFiltering.Lanczos="Lanczos"
NoiseSuppress.SuppressLevel="Seuil de suppression (en dB)"
Saturation="Saturation"
HueShift="Décalage de teinte"
Amount="Quantité"
Compressor="Compresseur"
Compressor.Ratio="Ratio (X:1)"
Compressor.Threshold="Seuil (dB)"
Compressor.AttackTime="Attaque (ms)"
Compressor.ReleaseTime="Libération (ms)"
Compressor.OutputGain="Sortie Gain (dB)"

View file

@ -1,4 +1,5 @@
ColorFilter="Színkorrekció"
ColorGradeFilter="LUT alkalmazása"
MaskFilter="Képmaszk/Keverés"
AsyncDelayFilter="Videó késleltetés (Async)"
CropFilter="Vágás/Margó"
@ -7,6 +8,7 @@ ChromaKeyFilter="Chroma kulcs"
ColorKeyFilter="Színkulcs"
SharpnessFilter="Élesítés"
ScaleFilter="Méretezés/Képarány"
UndistortCenter="Kép közepének zavarosságának a csökkentése ultraszélesről való skálázás esetén"
NoiseGate="Zajgát"
NoiseSuppress="Zajcsökkentés"
Gain="Erősítés"
@ -61,4 +63,13 @@ ScaleFiltering.Bilinear="Bilineáris"
ScaleFiltering.Bicubic="Kettős köbös"
ScaleFiltering.Lanczos="Lanczos"
NoiseSuppress.SuppressLevel="Csökkentési szint (dB)"
Saturation="Telítettség"
HueShift="Színezet váltása"
Amount="Mennyiség"
Compressor="Kompresszor"
Compressor.Ratio="Arány (X:1)"
Compressor.Threshold="Küszöb (dB)"
Compressor.AttackTime="Aktiválás (ms)"
Compressor.ReleaseTime="Felengedés (ms)"
Compressor.OutputGain="Kimeneti erősítés (dB)"

View file

@ -1,4 +1,5 @@
ColorFilter="Correzione colore"
ColorGradeFilter="Applica LUT"
MaskFilter="Immagine maschera/miscela"
AsyncDelayFilter="Ritardo video (Asincrono)"
CropFilter="Crop/Pad"
@ -61,4 +62,6 @@ ScaleFiltering.Bilinear="Bilineare"
ScaleFiltering.Bicubic="Bicubico"
ScaleFiltering.Lanczos="Lanczos"
NoiseSuppress.SuppressLevel="Livello di soppressione (dB)"
Saturation="Saturazione"
HueShift="Cambio di tonalità"

View file

@ -1,4 +1,5 @@
ColorFilter="色補正"
ColorGradeFilter="LUT を適用"
MaskFilter="イメージ マスク/ブレンド"
AsyncDelayFilter="映像の遅延 (非同期)"
CropFilter="クロップ/パッド"
@ -7,6 +8,7 @@ ChromaKeyFilter="クロマキー"
ColorKeyFilter="カラーキー"
SharpnessFilter="シャープ"
ScaleFilter="スケーリング/アスペクト比"
UndistortCenter="超広角からスケーリングするときに画像の中心を歪めない"
NoiseGate="ノイズゲート"
NoiseSuppress="ノイズ抑制"
Gain="ゲイン"
@ -61,4 +63,13 @@ ScaleFiltering.Bilinear="バイリニア"
ScaleFiltering.Bicubic="バイキュービック"
ScaleFiltering.Lanczos="ランチョス"
NoiseSuppress.SuppressLevel="抑制レベル (dB)"
Saturation="彩度"
HueShift="色相シフト"
Amount="量"
Compressor="コンプレッサー"
Compressor.Ratio="比率 (X:1)"
Compressor.Threshold="閾値 (dB)"
Compressor.AttackTime="アタックタイム (ms)"
Compressor.ReleaseTime="リリースタイム (ms)"
Compressor.OutputGain="出力ゲイン (dB)"

View file

@ -1,4 +1,5 @@
ColorFilter="색상 보정"
ColorGradeFilter="LUT 적용"
MaskFilter="이미지 마스크/혼합"
AsyncDelayFilter="비디오 지연 (비동기)"
CropFilter="자르기/덧대기"
@ -7,6 +8,7 @@ ChromaKeyFilter="크로마 키"
ColorKeyFilter="색상 키"
SharpnessFilter="선명하게"
ScaleFilter="비례축소/가로세로 비율"
UndistortCenter="울트라와이드에서 크기조정 시 이미지 중앙의 왜곡을 수정"
NoiseGate="노이즈 게이트"
NoiseSuppress="소음 억제"
Gain="증폭"
@ -61,4 +63,13 @@ ScaleFiltering.Bilinear="이중선형"
ScaleFiltering.Bicubic="쌍삼차"
ScaleFiltering.Lanczos="란초스"
NoiseSuppress.SuppressLevel="억제 세기 (dB)"
Saturation="채도"
HueShift="색조 변화"
Amount="양"
Compressor="압축방식"
Compressor.Ratio="비율 (X:1)"
Compressor.Threshold="임계값 (dB)"
Compressor.AttackTime="신호 감지 후 반응까지 걸리는 시간 (ms)"
Compressor.ReleaseTime="신호 세기가 감퇴 이후 증폭이 회복하는 시간 (ms)"
Compressor.OutputGain="출력 증폭 (dB)"

View file

@ -6,7 +6,9 @@ ScrollFilter="Rull"
ChromaKeyFilter="Chromafilter"
ColorKeyFilter="Fargefilter"
SharpnessFilter="Skjerpe"
ScaleFilter="Skalering/Aspekt Forhold"
NoiseGate="Støyterskel"
NoiseSuppress="Lyddemping"
Gain="Forsterkning"
DelayMs="Forsinkelse (millisekunder)"
Type="Type"
@ -51,4 +53,11 @@ NoiseGate.HoldTime="Holdetid (millisekunder)"
NoiseGate.ReleaseTime="Løslatelsestid (millisekunder)"
Gain.GainDB="Forsterkning (dB)"
StretchImage="Strekk bilde (ignorer bildets sideforhold)"
Resolution="Oppløsning"
None="Ingen"
ScaleFiltering="Skala Filtrering"
ScaleFiltering.Point="Punkt"
NoiseSuppress.SuppressLevel="Dempelse Nivå (dB)"
Saturation="Metning"
HueShift="Fargetone Skifte"

View file

@ -1,4 +1,5 @@
ColorFilter="Kleurcorrectie"
ColorGradeFilter="LUT Toepassen"
MaskFilter="Afbeeldingsmasker/Mengen"
AsyncDelayFilter="Videovertraging (Async)"
CropFilter="Bijsnijden/Aanvullen"
@ -7,6 +8,7 @@ ChromaKeyFilter="Chroma Key"
ColorKeyFilter="Color Key"
SharpnessFilter="Verscherpen"
ScaleFilter="Schalen/Aspect Ratio"
UndistortCenter="Verbeter beeldverhouding in het midden van bij schalen vanaf ultrawide"
NoiseGate="Noise Gate"
NoiseSuppress="Ruisonderdrukking"
Gain="Gain"
@ -61,4 +63,7 @@ ScaleFiltering.Bilinear="Bilinear"
ScaleFiltering.Bicubic="Bicubic"
ScaleFiltering.Lanczos="Lanczos"
NoiseSuppress.SuppressLevel="Onderdrukkingsniveau (dB)"
Saturation="Verzadiging"
HueShift="Tintverschuiving"
Amount="Hoeveelheid"

View file

@ -1,4 +1,5 @@
ColorFilter="Korekcja Kolorów"
ColorGradeFilter="Look-Up Tables (LUT)"
MaskFilter="Maskowanie/nakładanie obrazu"
AsyncDelayFilter="Opóźnienie wideo (asynchronicznie)"
CropFilter="Przytnij/Uzupełnij"
@ -7,6 +8,7 @@ ChromaKeyFilter="Kluczowanie koloru (chroma key)"
ColorKeyFilter="Kluczowanie koloru (kolor)"
SharpnessFilter="Wyostrzanie"
ScaleFilter="Skalowanie/proporcje"
UndistortCenter="Usuń przekłamania przy skalowaniu źródeł o dużej szerokości"
NoiseGate="Bramka szumów"
NoiseSuppress="Tłumienie hałasu"
Gain="Poziom"
@ -61,4 +63,13 @@ ScaleFiltering.Bilinear="Dwuliniowe"
ScaleFiltering.Bicubic="Dwusześcienne"
ScaleFiltering.Lanczos="Lanczos"
NoiseSuppress.SuppressLevel="Poziom tłumienia (dB)"
Saturation="Nasycenie"
HueShift="Przesunięcie barwy"
Amount="Pozion"
Compressor="Kompresor"
Compressor.Ratio="Stosunek (X:1)"
Compressor.Threshold="Próg (dB)"
Compressor.AttackTime="Atak (ms)"
Compressor.ReleaseTime="Odpuszczenie (ms)"
Compressor.OutputGain="Zysk na wyjściu (dB)"

View file

@ -5,6 +5,7 @@ ScrollFilter="Derulare"
ChromaKeyFilter="Cheie chroma"
ColorKeyFilter="Culoare cheie"
SharpnessFilter="Accentuare"
ScaleFilter="Scalare/Rație Aspect"
NoiseGate="Poartă de zgomot"
Gain="Amplificare"
DelayMs="Întârziere (milisecunde)"
@ -50,4 +51,10 @@ NoiseGate.HoldTime="Timp de menținere (milisecunde)"
NoiseGate.ReleaseTime="Timp de eliberare (milisecunde)"
Gain.GainDB="Amplificare (dB)"
StretchImage="Întinde imaginea (renunță la raportul de aspect al imaginii)"
Resolution="Rezoluție"
None="Fără"
ScaleFiltering.Bilinear="Biliniar"
ScaleFiltering.Bicubic="Bicubic"
ScaleFiltering.Lanczos="Lanczos"
Saturation="Saturație"

View file

@ -1,4 +1,5 @@
ColorFilter="Коррекция цвета"
ColorGradeFilter="Применить LUT"
MaskFilter="Маска изображения/Смешивание"
AsyncDelayFilter="Задержка видео (асинхронность)"
CropFilter="Кадрировать"
@ -7,6 +8,7 @@ ChromaKeyFilter="Хромакей"
ColorKeyFilter="Цветовой ключ"
SharpnessFilter="Увеличить резкость"
ScaleFilter="Коэффициент Масштабирования/Аспект"
UndistortCenter="Не искривлять центр изображения при масштабировании Ultrawide разрешения"
NoiseGate="Подавление шума"
NoiseSuppress="Шумоподавление"
Gain="Усиление"
@ -61,4 +63,13 @@ ScaleFiltering.Bilinear="Билинейная"
ScaleFiltering.Bicubic="Бикубическая"
ScaleFiltering.Lanczos="Метод Ланцоша"
NoiseSuppress.SuppressLevel="Уровень подавления (дБ)"
Saturation="Насыщенность"
HueShift="Сдвиг оттенка"
Amount="Количество"
Compressor="Компрессор"
Compressor.Ratio="Степень сжатия (X:1)"
Compressor.Threshold="Порог срабатывания (дБ)"
Compressor.AttackTime="Атака (мс)"
Compressor.ReleaseTime="Спад (мс)"
Compressor.OutputGain="Выходное усиление (дБ)"

View file

@ -1,4 +1,5 @@
ColorFilter="Färgkorrigering"
ColorGradeFilter="Tillämpa LUT"
MaskFilter="Bild Mask/Blandning"
AsyncDelayFilter="Videofördröjning (Async)"
CropFilter="Beskär/Fyll ut"
@ -61,4 +62,13 @@ ScaleFiltering.Bilinear="Bilinjär"
ScaleFiltering.Bicubic="Bikubisk"
ScaleFiltering.Lanczos="Lanczos"
NoiseSuppress.SuppressLevel="Brusreduceringsnivå (dB)"
Saturation="Mättnad"
HueShift="Nyansväxling"
Amount="Mängd"
Compressor="Kompressor"
Compressor.Ratio="Förhållande (X:1)"
Compressor.Threshold="Tröskel (dB)"
Compressor.AttackTime="Attack (ms)"
Compressor.ReleaseTime="Frigör (ms)"
Compressor.OutputGain="Utmatningsförstärkning (dB)"

View file

@ -1,11 +1,16 @@
ColorFilter="Renk Düzeltme"
ColorGradeFilter="LUT Uygula"
MaskFilter="Görüntü Maskesi/Blend"
AsyncDelayFilter="Görüntü Gecikmesi (Async)"
CropFilter="Kes/Kaydır"
ScrollFilter="Kaydır"
ChromaKeyFilter="Chroma Anahtarı"
ColorKeyFilter="Renk Anahtarı"
SharpnessFilter="Keskinleştirme"
ScaleFilter="Ölçeklendirme/Boy Oranı"
UndistortCenter="Ultra genişten boyutlandırırken görüntü merkezindeki bozulmayı düzelt"
NoiseGate="Gürültü Filtresi"
NoiseSuppress="Gürültü Bastırma"
Gain="Kazanç"
DelayMs="Gecikme (milisaniye)"
Type="Türü"
@ -20,7 +25,7 @@ Opacity="Opaklık"
Contrast="Karşıtlık"
Brightness="Parlaklık"
Gamma="Gama"
BrowsePath.Images="Tüm Resim Dosyaları"
BrowsePath.Images="Tüm Görüntü Dosyaları"
BrowsePath.AllFiles="Tüm Dosyalar"
KeyColorType="Anahtar Renk Türü"
KeyColor="Anahtar Renk"
@ -49,4 +54,22 @@ NoiseGate.AttackTime="Atak Süresi (milisaniye)"
NoiseGate.HoldTime="Kavrama Süresi (milisaniye)"
NoiseGate.ReleaseTime="Bırakma Süresi (milisaniye)"
Gain.GainDB="Kazanç (dB)"
StretchImage="Görüntüyü Uzat (görüntü boy oranını görmezden gelir)"
Resolution="Çözünürlük"
None="Hiçbiri"
ScaleFiltering="Ölçek Filtreleme"
ScaleFiltering.Point="Nokta"
ScaleFiltering.Bilinear="Bilinear"
ScaleFiltering.Bicubic="Bicubic"
ScaleFiltering.Lanczos="Lanczos"
NoiseSuppress.SuppressLevel="Bastırma Düzeyi (dB)"
Saturation="Renk Doygunluğu"
HueShift="Ton Kayması"
Amount="Miktar"
Compressor="Sıkıştırma"
Compressor.Ratio="Oran (X:1)"
Compressor.Threshold="Eşik (dB)"
Compressor.AttackTime="Atak (ms)"
Compressor.ReleaseTime="Bırakma (ms)"
Compressor.OutputGain=ıkış Kazancı (dB)"

View file

@ -1,4 +1,5 @@
ColorFilter="Коригування кольору"
ColorGradeFilter="Таблиці підстановки кольору"
MaskFilter="Маска до зображення"
AsyncDelayFilter="Затримка відео (асинхронна)"
CropFilter="Кадрування"
@ -7,6 +8,7 @@ ChromaKeyFilter="Зелений екран"
ColorKeyFilter="Фільтрування за кольором"
SharpnessFilter="Різкість"
ScaleFilter="Масштабування/пропорції"
UndistortCenter="Зменшити викривлення у центрі, якщо масштабувати з надширокоформатного"
NoiseGate="Пороговий шумопонижувач"
NoiseSuppress="Подавлення шуму"
Gain="Підсилення"
@ -49,7 +51,7 @@ Magenta="Пурпуровий"
NoiseGate.OpenThreshold="Поріг відкриття (дБ)"
NoiseGate.CloseThreshold="Поріг закриття (дБ)"
NoiseGate.AttackTime="Тривалість фронту сигналу (мілісекунд)"
NoiseGate.HoldTime="Тривалість сигналу (мілісекунд)"
NoiseGate.HoldTime="Тривалість втримання сигналу (мілісекунд)"
NoiseGate.ReleaseTime="Тривалість спаду сигналу (мілісекунд)"
Gain.GainDB="Підсилення (дБ)"
StretchImage="Розтягнути зображення (ігнорувати пропорції зображення)"
@ -61,4 +63,13 @@ ScaleFiltering.Bilinear="Білінійний"
ScaleFiltering.Bicubic="Бікубічний"
ScaleFiltering.Lanczos="Ланцош"
NoiseSuppress.SuppressLevel="Рівень подавлення (дБ)"
Saturation="Насиченість"
HueShift="Відтінок"
Amount="Обсяг впливу"
Compressor="Компресор"
Compressor.Ratio="Відношення (X:1)"
Compressor.Threshold="Поріг (дБ)"
Compressor.AttackTime="Атака (мс)"
Compressor.ReleaseTime="Затухання (мс)"
Compressor.OutputGain="Підсилення виводу (dB)"

View file

@ -1,4 +1,5 @@
ColorFilter="色彩校正"
ColorGradeFilter="应用 LUT"
MaskFilter="图像掩码/混合"
AsyncDelayFilter="视频延迟(异步)"
CropFilter="裁剪/填充"
@ -7,6 +8,7 @@ ChromaKeyFilter="色度键"
ColorKeyFilter="色值"
SharpnessFilter="锐化"
ScaleFilter="缩放比例"
UndistortCenter="当从超宽扩展时, 让图片中心不失真"
NoiseGate="噪音阈值"
NoiseSuppress="噪声抑制"
Gain="增益"
@ -61,4 +63,13 @@ ScaleFiltering.Bilinear="双线性算法"
ScaleFiltering.Bicubic="双立方算法"
ScaleFiltering.Lanczos="兰索斯算法"
NoiseSuppress.SuppressLevel="抑制程度 (dB)"
Saturation="饱和度"
HueShift="色调偏移"
Amount="数值"
Compressor="压缩器"
Compressor.Ratio="比率 (X:1)"
Compressor.Threshold="阈值 (dB)"
Compressor.AttackTime="攻击 (ms)"
Compressor.ReleaseTime="释放 (ms)"
Compressor.OutputGain="输出增益 (dB)"

View file

@ -1,4 +1,5 @@
ColorFilter="色彩校正"
ColorGradeFilter="使用色彩對照表"
MaskFilter="影像遮罩/混合"
AsyncDelayFilter="視頻延遲 (非同步)"
CropFilter="剪裁/填充"
@ -7,6 +8,7 @@ ChromaKeyFilter="色度鍵"
ColorKeyFilter="色彩鍵"
SharpnessFilter="銳化"
ScaleFilter="縮放/長寬比"
UndistortCenter="從超寬影像縮放時彌補影像中心的畸變"
NoiseGate="噪音閾"
NoiseSuppress="雜訊抑制"
Gain="增益"
@ -61,4 +63,7 @@ ScaleFiltering.Bilinear="雙線性插值"
ScaleFiltering.Bicubic="雙三次插值"
ScaleFiltering.Lanczos="Lanczos"
NoiseSuppress.SuppressLevel="抑制標準 (dB)"
Saturation="飽合度"
HueShift="色調偏移"
Amount="影響總量"

View file

@ -12,6 +12,7 @@ extern struct obs_source_info color_filter;
extern struct obs_source_info scale_filter;
extern struct obs_source_info scroll_filter;
extern struct obs_source_info color_key_filter;
extern struct obs_source_info color_grade_filter;
extern struct obs_source_info sharpness_filter;
extern struct obs_source_info chroma_key_filter;
extern struct obs_source_info async_delay_filter;
@ -19,6 +20,7 @@ extern struct obs_source_info async_delay_filter;
extern struct obs_source_info noise_suppress_filter;
#endif
extern struct obs_source_info noise_gate_filter;
extern struct obs_source_info compressor_filter;
bool obs_module_load(void)
{
@ -29,6 +31,7 @@ bool obs_module_load(void)
obs_register_source(&scale_filter);
obs_register_source(&scroll_filter);
obs_register_source(&color_key_filter);
obs_register_source(&color_grade_filter);
obs_register_source(&sharpness_filter);
obs_register_source(&chroma_key_filter);
obs_register_source(&async_delay_filter);
@ -36,5 +39,6 @@ bool obs_module_load(void)
obs_register_source(&noise_suppress_filter);
#endif
obs_register_source(&noise_gate_filter);
obs_register_source(&compressor_filter);
return true;
}

View file

@ -8,6 +8,7 @@
#define S_RESOLUTION "resolution"
#define S_SAMPLING "sampling"
#define S_UNDISTORT "undistort"
#define T_RESOLUTION obs_module_text("Resolution")
#define T_NONE obs_module_text("None")
@ -16,6 +17,7 @@
#define T_SAMPLING_BILINEAR obs_module_text("ScaleFiltering.Bilinear")
#define T_SAMPLING_BICUBIC obs_module_text("ScaleFiltering.Bicubic")
#define T_SAMPLING_LANCZOS obs_module_text("ScaleFiltering.Lanczos")
#define T_UNDISTORT obs_module_text("UndistortCenter")
#define S_SAMPLING_POINT "point"
#define S_SAMPLING_BILINEAR "bilinear"
@ -27,7 +29,9 @@ struct scale_filter_data {
gs_effect_t *effect;
gs_eparam_t *image_param;
gs_eparam_t *dimension_param;
gs_eparam_t *undistort_factor_param;
struct vec2 dimension_i;
double undistort_factor;
int cx_in;
int cy_in;
int cx_out;
@ -37,6 +41,7 @@ struct scale_filter_data {
bool aspect_ratio_only : 1;
bool target_valid : 1;
bool valid : 1;
bool undistort : 1;
};
static const char *scale_filter_name(void *unused)
@ -80,6 +85,8 @@ static void scale_filter_update(void *data, obs_data_t *settings)
} else { /* S_SAMPLING_BICUBIC */
filter->sampling = OBS_SCALE_BICUBIC;
}
filter->undistort = obs_data_get_bool(settings, S_UNDISTORT);
}
static void scale_filter_destroy(void *data)
@ -146,11 +153,11 @@ static void scale_filter_tick(void *data, float seconds)
cx_f = (double)cx;
cy_f = (double)cy;
if (filter->aspect_ratio_only) {
double old_aspect = cx_f / cy_f;
double new_aspect =
(double)filter->cx_in / (double)filter->cy_in;
double old_aspect = cx_f / cy_f;
double new_aspect =
(double)filter->cx_in / (double)filter->cy_in;
if (filter->aspect_ratio_only) {
if (fabs(old_aspect - new_aspect) <= EPSILON) {
filter->target_valid = false;
return;
@ -172,6 +179,12 @@ static void scale_filter_tick(void *data, float seconds)
1.0f / (float)cx,
1.0f / (float)cy);
if (filter->undistort) {
filter->undistort_factor = new_aspect / old_aspect;
} else {
filter->undistort_factor = 1.0;
}
/* ------------------------- */
lower_than_2x = filter->cx_out < cx / 2 || filter->cy_out < cy / 2;
@ -199,12 +212,22 @@ static void scale_filter_tick(void *data, float seconds)
filter->dimension_param = NULL;
}
if (type == OBS_EFFECT_BICUBIC || type == OBS_EFFECT_LANCZOS) {
filter->undistort_factor_param = gs_effect_get_param_by_name(
filter->effect, "undistort_factor");
}
else {
filter->undistort_factor_param = NULL;
}
UNUSED_PARAMETER(seconds);
}
static void scale_filter_render(void *data, gs_effect_t *effect)
{
struct scale_filter_data *filter = data;
const char *technique = filter->undistort ?
"DrawUndistort" : "Draw";
if (!filter->valid || !filter->target_valid) {
obs_source_skip_video_filter(filter->context);
@ -219,12 +242,16 @@ static void scale_filter_render(void *data, gs_effect_t *effect)
gs_effect_set_vec2(filter->dimension_param,
&filter->dimension_i);
if (filter->undistort_factor_param)
gs_effect_set_float(filter->undistort_factor_param,
(float)filter->undistort_factor);
if (filter->sampling == OBS_SCALE_POINT)
gs_effect_set_next_sampler(filter->image_param,
filter->point_sampler);
obs_source_process_filter_end(filter->context, filter->effect,
filter->cx_out, filter->cy_out);
obs_source_process_filter_tech_end(filter->context, filter->effect,
filter->cx_out, filter->cy_out, technique);
UNUSED_PARAMETER(effect);
}
@ -254,6 +281,34 @@ static const char *aspects[] = {
#define NUM_ASPECTS (sizeof(aspects) / sizeof(const char *))
static bool sampling_modified(obs_properties_t *props, obs_property_t *p,
obs_data_t *settings)
{
const char *sampling = obs_data_get_string(settings, S_SAMPLING);
bool has_undistort;
if (astrcmpi(sampling, S_SAMPLING_POINT) == 0) {
has_undistort = false;
}
else if (astrcmpi(sampling, S_SAMPLING_BILINEAR) == 0) {
has_undistort = false;
}
else if (astrcmpi(sampling, S_SAMPLING_LANCZOS) == 0) {
has_undistort = true;
}
else { /* S_SAMPLING_BICUBIC */
has_undistort = true;
}
obs_property_set_visible(obs_properties_get(props, S_UNDISTORT), has_undistort);
UNUSED_PARAMETER(p);
return true;
}
static obs_properties_t *scale_filter_properties(void *data)
{
obs_properties_t *props = obs_properties_create();
@ -280,6 +335,7 @@ static obs_properties_t *scale_filter_properties(void *data)
p = obs_properties_add_list(props, S_SAMPLING, T_SAMPLING,
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING);
obs_property_set_modified_callback(p, sampling_modified);
obs_property_list_add_string(p, T_SAMPLING_POINT, S_SAMPLING_POINT);
obs_property_list_add_string(p, T_SAMPLING_BILINEAR, S_SAMPLING_BILINEAR);
obs_property_list_add_string(p, T_SAMPLING_BICUBIC, S_SAMPLING_BICUBIC);
@ -301,6 +357,8 @@ static obs_properties_t *scale_filter_properties(void *data)
obs_property_list_add_string(p, str, str);
}
obs_properties_add_bool(props, S_UNDISTORT, T_UNDISTORT);
/* ----------------- */
UNUSED_PARAMETER(data);
@ -311,6 +369,7 @@ static void scale_filter_defaults(obs_data_t *settings)
{
obs_data_set_default_string(settings, S_SAMPLING, S_SAMPLING_BICUBIC);
obs_data_set_default_string(settings, S_RESOLUTION, T_NONE);
obs_data_set_default_bool(settings, S_UNDISTORT, 0);
}
static uint32_t scale_filter_width(void *data)