diff --git a/src/slic3r/GUI/AVVideoDecoder.cpp b/src/slic3r/GUI/AVVideoDecoder.cpp index a56579cca..184804054 100644 --- a/src/slic3r/GUI/AVVideoDecoder.cpp +++ b/src/slic3r/GUI/AVVideoDecoder.cpp @@ -76,8 +76,13 @@ bool AVVideoDecoder::toWxImage(wxImage &image, wxSize const &size2) if (!size1.IsFullySpecified()) size1 = {frame_->width, frame_->height }; auto size = size1; - if (size.GetWidth() & 0x0f) + if (size.GetWidth() & 0x0f) { size.SetWidth((size.GetWidth() & ~0x0f) + 0x10); + if (size.GetWidth() != width_) { + std::fill(bits_.begin(), bits_.end(), 0); + width_ = size.GetWidth(); + } + } AVPixelFormat wxFmt = AV_PIX_FMT_RGB24; sws_ctx_ = sws_getCachedContext(sws_ctx_, frame_->width, frame_->height, AVPixelFormat(frame_->format), @@ -112,8 +117,13 @@ bool AVVideoDecoder::toWxBitmap(wxBitmap &bitmap, wxSize const &size2) if (!size1.IsFullySpecified()) size1 = {frame_->width, frame_->height }; auto size = size1; - if (size.GetWidth() & 0x0f) + if (size.GetWidth() & 0x0f) { size.SetWidth((size.GetWidth() & ~0x0f) + 0x10); + if (size.GetWidth() != width_) { + std::fill(bits_.begin(), bits_.end(), 0); + width_ = size.GetWidth(); + } + } AVPixelFormat wxFmt = AV_PIX_FMT_RGB32; sws_ctx_ = sws_getCachedContext(sws_ctx_, frame_->width, frame_->height, AVPixelFormat(frame_->format), diff --git a/src/slic3r/GUI/AVVideoDecoder.hpp b/src/slic3r/GUI/AVVideoDecoder.hpp index 99a7349e5..239352aea 100644 --- a/src/slic3r/GUI/AVVideoDecoder.hpp +++ b/src/slic3r/GUI/AVVideoDecoder.hpp @@ -34,6 +34,7 @@ private: AVFrame * frame_ = nullptr; SwsContext * sws_ctx_ = nullptr; bool got_frame_ = false; + int width_ { 0 }; // scale result width std::vector bits_; };