Skip to content
Snippets Groups Projects
Commit 52e08249 authored by Jim's avatar Jim
Browse files

Only render async frames to texture once per frame

This prevents multiple needless calls to obs_source_get_frame and other
functions.  If the texture has already been processed, then just render
it as-is in any subsequent calls to obs_source_video_render.
parent 07c2d32a
No related branches found
No related tags found
No related merge requests found
...@@ -293,6 +293,7 @@ struct obs_source { ...@@ -293,6 +293,7 @@ struct obs_source {
uint64_t next_audio_ts_min; uint64_t next_audio_ts_min;
uint64_t last_frame_ts; uint64_t last_frame_ts;
uint64_t last_sys_timestamp; uint64_t last_sys_timestamp;
bool async_rendered;
/* audio */ /* audio */
bool audio_failed; bool audio_failed;
......
...@@ -503,6 +503,8 @@ void obs_source_video_tick(obs_source_t source, float seconds) ...@@ -503,6 +503,8 @@ void obs_source_video_tick(obs_source_t source, float seconds)
if (source->context.data && source->info.video_tick) if (source->context.data && source->info.video_tick)
source->info.video_tick(source->context.data, seconds); source->info.video_tick(source->context.data, seconds);
source->async_rendered = false;
} }
/* unless the value is 3+ hours worth of frames, this won't overflow */ /* unless the value is 3+ hours worth of frames, this won't overflow */
...@@ -1031,18 +1033,22 @@ static void obs_source_draw_async_texture(struct obs_source *source) ...@@ -1031,18 +1033,22 @@ static void obs_source_draw_async_texture(struct obs_source *source)
static void obs_source_render_async_video(obs_source_t source) static void obs_source_render_async_video(obs_source_t source)
{ {
struct obs_source_frame *frame = obs_source_get_frame(source); if (!source->async_rendered) {
if (frame) { struct obs_source_frame *frame = obs_source_get_frame(source);
if (!set_async_texture_size(source, frame))
return; source->async_rendered = true;
if (!update_async_texture(source, frame)) if (frame) {
return; if (!set_async_texture_size(source, frame))
return;
if (!update_async_texture(source, frame))
return;
}
obs_source_release_frame(source, frame);
} }
if (source->async_texture) if (source->async_texture)
obs_source_draw_async_texture(source); obs_source_draw_async_texture(source);
obs_source_release_frame(source, frame);
} }
static inline void obs_source_render_filters(obs_source_t source) static inline void obs_source_render_filters(obs_source_t source)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment