From b0e7c5d0d3aaed12b92901df93a92487696f07bc Mon Sep 17 00:00:00 2001 From: jpark37 Date: Wed, 7 Aug 2019 06:47:27 -0700 Subject: [PATCH] libobs: Fix stale format in async frame cache The video format is not updated if switching between cache-compatible formats, e.g. YUY2 and YVYU, resulting in the wrong conversion technique being used. This change ensures the format is always up-to-date. --- libobs/obs-source.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libobs/obs-source.c b/libobs/obs-source.c index a9f05c575..fa603d809 100644 --- a/libobs/obs-source.c +++ b/libobs/obs-source.c @@ -2426,14 +2426,17 @@ cache_video(struct obs_source *source, const struct obs_source_frame *frame) free_async_cache(source); source->async_cache_width = frame->width; source->async_cache_height = frame->height; - source->async_cache_format = frame->format; - source->async_cache_full_range = frame->full_range; } + const enum video_format format = frame->format; + source->async_cache_format = format; + source->async_cache_full_range = frame->full_range; + for (size_t i = 0; i < source->async_cache.num; i++) { struct async_frame *af = &source->async_cache.array[i]; if (!af->used) { new_frame = af->frame; + new_frame->format = format; af->used = true; af->unused_count = 0; break; @@ -2444,7 +2447,6 @@ cache_video(struct obs_source *source, const struct obs_source_frame *frame) if (!new_frame) { struct async_frame new_af; - enum video_format format = frame->format; new_frame = obs_source_frame_create(format, frame->width, frame->height);