From fbc5dbcfd4a807493b1c67d3a65409d00159aafc Mon Sep 17 00:00:00 2001 From: "chunmao.guo" Date: Tue, 16 Jul 2024 17:44:52 +0800 Subject: [PATCH] FIX: ffmpeg swscale & frame_size Change-Id: I9f4cb8c739b726f7e5cdbe0df7ed06b2eb2154d5 Jira: STUDIO-7624 (cherry picked from commit 5a2c75d835fb437667b590a803eef148baa30875) --- src/slic3r/GUI/AVVideoDecoder.cpp | 4 ++-- src/slic3r/GUI/wxMediaCtrl3.cpp | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/slic3r/GUI/AVVideoDecoder.cpp b/src/slic3r/GUI/AVVideoDecoder.cpp index 599b883818..ce9771be03 100644 --- a/src/slic3r/GUI/AVVideoDecoder.cpp +++ b/src/slic3r/GUI/AVVideoDecoder.cpp @@ -79,7 +79,7 @@ bool AVVideoDecoder::toWxImage(wxImage &image, wxSize const &size2) sws_ctx_ = sws_getCachedContext(sws_ctx_, frame_->width, frame_->height, AVPixelFormat(frame_->format), size.GetWidth(), size.GetHeight(), wxFmt, - SWS_POINT, // SWS_FAST_BILINEAR //SWS_BICUBIC + SWS_GAUSS, nullptr, nullptr, nullptr); int length = size.GetWidth() * size.GetHeight() * 3; if (bits_.size() < length) @@ -108,7 +108,7 @@ bool AVVideoDecoder::toWxBitmap(wxBitmap &bitmap, wxSize const &size2) sws_ctx_ = sws_getCachedContext(sws_ctx_, frame_->width, frame_->height, AVPixelFormat(frame_->format), size.GetWidth(), size.GetHeight(), wxFmt, - SWS_POINT, // SWS_FAST_BILINEAR //SWS_BICUBIC + SWS_GAUSS, nullptr, nullptr, nullptr); int length = size.GetWidth() * size.GetHeight() * 4; if (bits_.size() < length) diff --git a/src/slic3r/GUI/wxMediaCtrl3.cpp b/src/slic3r/GUI/wxMediaCtrl3.cpp index e326485bfe..a3b1d3efd3 100644 --- a/src/slic3r/GUI/wxMediaCtrl3.cpp +++ b/src/slic3r/GUI/wxMediaCtrl3.cpp @@ -139,6 +139,8 @@ void wxMediaCtrl3::DoSetSize(int x, int y, int width, int height, int sizeFlags) wxWindow::DoSetSize(x, y, width, height, sizeFlags); if (sizeFlags & wxSIZE_USE_EXISTING) return; wxMediaCtrl_OnSize(this, m_video_size, width, height); + std::unique_lock lk(m_mutex); + adjust_frame_size(m_frame_size, m_video_size, GetSize()); } void wxMediaCtrl3::bambu_log(void *ctx, int level, tchar const *msg2) @@ -232,10 +234,11 @@ void wxMediaCtrl3::PlayThread() error = 1; break; } + auto frame_size = m_frame_size; lk.unlock(); wxBitmap bm; decoder.decode(sample); - decoder.toWxBitmap(bm, m_frame_size); + decoder.toWxBitmap(bm, frame_size); lk.lock(); if (bm.IsOk()) m_frame = bm;