FIX: ffmpeg swscale & frame_size

Change-Id: I9f4cb8c739b726f7e5cdbe0df7ed06b2eb2154d5
Jira: STUDIO-7624
This commit is contained in:
chunmao.guo 2024-07-16 17:44:52 +08:00 committed by Lane.Wei
parent b7f8fa1efd
commit 5a2c75d835
3 changed files with 7 additions and 4 deletions

View File

@ -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)

View File

@ -62,7 +62,7 @@ MediaPlayCtrl::MediaPlayCtrl(wxWindow *parent, wxMediaCtrl2 *media_ctrl, const w
m_media_ctrl->Bind(EVT_MEDIA_CTRL_STAT, [this](auto & e) {
#if !BBL_RELEASE_TO_PUBLIC
wxSize size = m_media_ctrl->GetVideoSize();
m_label_stat->SetLabel(e.GetString() + wxString::Format(" VS:%ix%i LD:%i", size.x, size.y, m_load_duration));
m_label_stat->SetLabel(e.GetString() + wxString::Format(" VS:%ix%i IDLE:%i", size.x, size.y, SecondsSinceLastInput()));
#endif
wxString str = e.GetString();
m_stat.clear();

View File

@ -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<std::mutex> 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;