libobs: Add ability for transitions to render sources directly
For specific types of transitions (stingers in this case), there is no blending done of the two targets, so wasting GPU resources rendering them to textures is unnecessary.master
parent
cb42f08d1e
commit
3a06cb25df
|
@ -747,6 +747,60 @@ void obs_transition_video_render(obs_source_t *transition,
|
|||
handle_stop(transition);
|
||||
}
|
||||
|
||||
bool obs_transition_video_render_direct(obs_source_t *transition,
|
||||
enum obs_transition_target target)
|
||||
{
|
||||
struct transition_state state;
|
||||
struct matrix4 matrices[2];
|
||||
bool stopped = false;
|
||||
bool video_stopped = false;
|
||||
bool render_b = target == OBS_TRANSITION_SOURCE_B;
|
||||
bool transitioning;
|
||||
float t;
|
||||
|
||||
if (!transition_valid(transition, "obs_transition_video_render"))
|
||||
return false;
|
||||
|
||||
t = get_video_time(transition);
|
||||
|
||||
lock_transition(transition);
|
||||
|
||||
if (t >= 1.0f && transition->transitioning_video) {
|
||||
transition->transitioning_video = false;
|
||||
video_stopped = true;
|
||||
|
||||
if (!transition->transitioning_audio) {
|
||||
obs_transition_stop(transition);
|
||||
stopped = true;
|
||||
}
|
||||
}
|
||||
copy_transition_state(transition, &state);
|
||||
transitioning = state.transitioning_audio || state.transitioning_video;
|
||||
matrices[0] = transition->transition_matrices[0];
|
||||
matrices[1] = transition->transition_matrices[1];
|
||||
|
||||
unlock_transition(transition);
|
||||
|
||||
int idx = (transitioning && render_b) ? 1 : 0;
|
||||
if (state.s[idx]) {
|
||||
gs_matrix_push();
|
||||
gs_matrix_mul(&matrices[idx]);
|
||||
obs_source_video_render(state.s[idx]);
|
||||
gs_matrix_pop();
|
||||
}
|
||||
|
||||
obs_source_release(state.s[0]);
|
||||
obs_source_release(state.s[1]);
|
||||
|
||||
if (video_stopped)
|
||||
obs_source_dosignal(transition, "source_transition_video_stop",
|
||||
"transition_video_stop");
|
||||
if (stopped)
|
||||
handle_stop(transition);
|
||||
|
||||
return transitioning;
|
||||
}
|
||||
|
||||
static inline float get_sample_time(obs_source_t *transition,
|
||||
size_t sample_rate, size_t sample, uint64_t ts)
|
||||
{
|
||||
|
|
|
@ -1170,6 +1170,11 @@ EXPORT float obs_transition_get_time(obs_source_t *transition);
|
|||
EXPORT void obs_transition_video_render(obs_source_t *transition,
|
||||
obs_transition_video_render_callback_t callback);
|
||||
|
||||
/** Directly renders its sub-source instead of to texture. Returns false if no
|
||||
* longer transitioning */
|
||||
EXPORT bool obs_transition_video_render_direct(obs_source_t *transition,
|
||||
enum obs_transition_target target);
|
||||
|
||||
EXPORT bool obs_transition_audio_render(obs_source_t *transition,
|
||||
uint64_t *ts_out, struct obs_source_audio_mix *audio,
|
||||
uint32_t mixers, size_t channels, size_t sample_rate,
|
||||
|
|
Loading…
Reference in New Issue