0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-20 04:42:18 +02:00

libobs: Plumb linear alpha flag

Use union for backwards compatibility.
This commit is contained in:
jpark37 2021-06-04 01:20:57 -07:00 committed by Jim
parent 5b25dec714
commit 1fa152092c
3 changed files with 24 additions and 10 deletions

View File

@ -685,6 +685,7 @@ struct obs_source {
int async_channel_count;
long async_rotation;
bool async_flip;
bool async_linear_alpha;
bool async_active;
bool async_update_texture;
bool async_unbuffered;

View File

@ -2019,7 +2019,9 @@ bool update_async_textures(struct obs_source *source,
{
enum convert_type type;
source->async_flip = frame->flip;
source->async_flip = (frame->flags & OBS_SOURCE_FRAME_FLIP) != 0;
source->async_linear_alpha =
(frame->flags & OBS_SOURCE_FRAME_LINEAR_ALPHA) != 0;
if (source->async_gpu_conversion && texrender)
return update_async_texrender(source, frame, tex, texrender);
@ -2070,9 +2072,11 @@ static void obs_source_draw_async_texture(struct obs_source *source)
if (def_draw) {
effect = obs_get_base_effect(OBS_EFFECT_DEFAULT);
const bool linear = gs_get_linear_srgb();
const char *tech_name = linear ? "DrawNonlinearAlpha" : "Draw";
premultiplied = linear;
const bool nonlinear_alpha = gs_get_linear_srgb() &&
!source->async_linear_alpha;
const char *tech_name = nonlinear_alpha ? "DrawNonlinearAlpha"
: "Draw";
premultiplied = nonlinear_alpha;
tech = gs_effect_get_technique(effect, tech_name);
gs_technique_begin(tech);
gs_technique_begin_pass(tech, 0);
@ -2720,7 +2724,7 @@ static inline void copy_frame_data_plane(struct obs_source_frame *dst,
static void copy_frame_data(struct obs_source_frame *dst,
const struct obs_source_frame *src)
{
dst->flip = src->flip;
dst->flags = src->flags;
dst->full_range = src->full_range;
dst->timestamp = src->timestamp;
memcpy(dst->color_matrix, src->color_matrix, sizeof(float) * 16);
@ -2951,7 +2955,7 @@ void obs_source_output_video2(obs_source_t *source,
new_frame.timestamp = frame->timestamp;
new_frame.format = frame->format;
new_frame.full_range = range == VIDEO_RANGE_FULL;
new_frame.flip = frame->flip;
new_frame.flags = frame->flags;
memcpy(&new_frame.color_matrix, &frame->color_matrix,
sizeof(frame->color_matrix));
@ -3082,7 +3086,7 @@ void obs_source_preload_video2(obs_source_t *source,
new_frame.timestamp = frame->timestamp;
new_frame.format = frame->format;
new_frame.full_range = range == VIDEO_RANGE_FULL;
new_frame.flip = frame->flip;
new_frame.flags = frame->flags;
memcpy(&new_frame.color_matrix, &frame->color_matrix,
sizeof(frame->color_matrix));
@ -3186,7 +3190,7 @@ void obs_source_set_video_frame2(obs_source_t *source,
new_frame.timestamp = frame->timestamp;
new_frame.format = frame->format;
new_frame.full_range = range == VIDEO_RANGE_FULL;
new_frame.flip = frame->flip;
new_frame.flags = frame->flags;
memcpy(&new_frame.color_matrix, &frame->color_matrix,
sizeof(frame->color_matrix));

View File

@ -219,6 +219,9 @@ struct obs_source_cea_708 {
uint64_t timestamp;
};
#define OBS_SOURCE_FRAME_FLIP (1 << 0)
#define OBS_SOURCE_FRAME_LINEAR_ALPHA (1 << 1)
/**
* Source asynchronous video output structure. Used with
* obs_source_output_video to output asynchronous video. Video is buffered as
@ -244,7 +247,10 @@ struct obs_source_frame {
bool full_range;
float color_range_min[3];
float color_range_max[3];
bool flip;
union {
uint8_t flip : 1; /* deprecated */
uint8_t flags;
};
/* used internally by libobs */
volatile long refs;
@ -263,7 +269,10 @@ struct obs_source_frame2 {
float color_matrix[16];
float color_range_min[3];
float color_range_max[3];
bool flip;
union {
uint8_t flip : 1; /* deprecated */
uint8_t flags;
};
};
/** Access to the argc/argv used to start OBS. What you see is what you get. */