obs-ffmpeg: Add linear alpha setting

Allow proper linear treatment of alpha for authoring sanity.
This commit is contained in:
jpark37 2021-06-04 01:22:16 -07:00 committed by Jim
parent ce6f233e2d
commit 15e37f96d1
2 changed files with 12 additions and 3 deletions

View File

@ -41,6 +41,7 @@ ColorRange="YUV Color Range"
ColorRange.Auto="Auto"
ColorRange.Partial="Partial"
ColorRange.Full="Full"
LinearAlpha="Apply alpha in linear space"
RestartMedia="Restart"
SpeedPercentage="Speed"
Seekable="Seekable"

View File

@ -43,6 +43,7 @@ struct ffmpeg_source {
uint8_t *sws_data;
int sws_linesize;
enum video_range_type range;
bool is_linear_alpha;
obs_source_t *source;
obs_hotkey_id hotkey;
@ -109,6 +110,7 @@ static void ffmpeg_source_defaults(obs_data_t *settings)
obs_data_set_default_bool(settings, "looping", false);
obs_data_set_default_bool(settings, "clear_on_media_end", true);
obs_data_set_default_bool(settings, "restart_on_activate", true);
obs_data_set_default_bool(settings, "linear_alpha", false);
obs_data_set_default_int(settings, "reconnect_delay_sec", 10);
obs_data_set_default_int(settings, "buffering_mb", 2);
obs_data_set_default_int(settings, "speed_percent", 100);
@ -163,8 +165,7 @@ static obs_properties_t *ffmpeg_source_getproperties(void *data)
dstr_free(&filter);
dstr_free(&path);
prop = obs_properties_add_bool(props, "looping",
obs_module_text("Looping"));
obs_properties_add_bool(props, "looping", obs_module_text("Looping"));
obs_properties_add_bool(props, "restart_on_activate",
obs_module_text("RestartWhenActivated"));
@ -215,6 +216,9 @@ static obs_properties_t *ffmpeg_source_getproperties(void *data)
obs_property_list_add_int(prop, obs_module_text("ColorRange.Full"),
VIDEO_RANGE_FULL);
obs_properties_add_bool(props, "linear_alpha",
obs_module_text("LinearAlpha"));
obs_properties_add_bool(props, "seekable", obs_module_text("Seekable"));
return props;
@ -229,13 +233,15 @@ static void dump_source_info(struct ffmpeg_source *s, const char *input,
"\tinput_format: %s\n"
"\tspeed: %d\n"
"\tis_looping: %s\n"
"\tis_linear_alpha: %s\n"
"\tis_hw_decoding: %s\n"
"\tis_clear_on_media_end: %s\n"
"\trestart_on_activate: %s\n"
"\tclose_when_inactive: %s",
input ? input : "(null)",
input_format ? input_format : "(null)", s->speed_percent,
s->is_looping ? "yes" : "no", s->is_hw_decoding ? "yes" : "no",
s->is_looping ? "yes" : "no", s->is_linear_alpha ? "yes" : "no",
s->is_hw_decoding ? "yes" : "no",
s->is_clear_on_media_end ? "yes" : "no",
s->restart_on_activate ? "yes" : "no",
s->close_when_inactive ? "yes" : "no");
@ -304,6 +310,7 @@ static void ffmpeg_source_open(struct ffmpeg_source *s)
.buffering = s->buffering_mb * 1024 * 1024,
.speed = s->speed_percent,
.force_range = s->range,
.is_linear_alpha = s->is_linear_alpha,
.hardware_decoding = s->is_hw_decoding,
.is_local_file = s->is_local_file || s->seekable,
.reconnecting = s->reconnecting,
@ -425,6 +432,7 @@ static void ffmpeg_source_update(void *data, obs_data_t *settings)
obs_data_get_bool(settings, "restart_on_activate");
s->range = (enum video_range_type)obs_data_get_int(settings,
"color_range");
s->is_linear_alpha = obs_data_get_bool(settings, "linear_alpha");
s->buffering_mb = (int)obs_data_get_int(settings, "buffering_mb");
s->speed_percent = (int)obs_data_get_int(settings, "speed_percent");
s->is_local_file = is_local_file;