From 9b4d9c67881d13cb17ce3a9e610d89817223d022 Mon Sep 17 00:00:00 2001 From: wanhongqing Date: Tue, 6 Aug 2019 13:31:06 +0800 Subject: [PATCH] win-dshow: Fix format switching issue If the format was one encoded format and changes to another encoded format, it could cause it to continue to treat it as the old format. --- plugins/win-dshow/win-dshow.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/win-dshow/win-dshow.cpp b/plugins/win-dshow/win-dshow.cpp index 625093bd0..76418fedb 100644 --- a/plugins/win-dshow/win-dshow.cpp +++ b/plugins/win-dshow/win-dshow.cpp @@ -468,6 +468,12 @@ static inline enum speaker_layout convert_speaker_layout(uint8_t channels) void DShowInput::OnEncodedVideoData(enum AVCodecID id, unsigned char *data, size_t size, long long ts) { + /* If format changes, free and allow it to recreate the decoder */ + if (ffmpeg_decode_valid(video_decoder) && + video_decoder->codec->id != id) { + ffmpeg_decode_free(video_decoder); + } + if (!ffmpeg_decode_valid(video_decoder)) { /* Only use MJPEG hardware decoding on resolutions higher * than 1920x1080. The reason why is because we want to strike