From 2cf386d45a25305536e753c016e770226b09006f Mon Sep 17 00:00:00 2001 From: PioLing <358353547@qq.com> Date: Thu, 27 Nov 2025 10:56:43 +0800 Subject: [PATCH] Add proportional scaling (720p) for the player at startup (#4567) --- player/AudioSRC.cpp | 2 +- player/YuvDisplayer.h | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/player/AudioSRC.cpp b/player/AudioSRC.cpp index 5fb7aa0e..8989a7dc 100644 --- a/player/AudioSRC.cpp +++ b/player/AudioSRC.cpp @@ -26,7 +26,7 @@ void AudioSRC::setOutputAudioConfig(const SDL_AudioSpec &cfg) { int format = _delegate->getPCMFormat(); int channels = _delegate->getPCMChannel(); if (-1 == SDL_BuildAudioCVT(&_audio_cvt, format, channels, freq, cfg.format, cfg.channels, cfg.freq)) { - throw std::runtime_error("the format conversion is not supported"); + throw std::runtime_error("the format conversion is not supported, " + string(SDL_GetError())); } InfoL << "audio cvt origin format, freq:" << freq << ", format:" << hex << format << dec << ", channels:" << channels; InfoL << "audio cvt info, " diff --git a/player/YuvDisplayer.h b/player/YuvDisplayer.h index 54702cec..318baa0f 100644 --- a/player/YuvDisplayer.h +++ b/player/YuvDisplayer.h @@ -135,16 +135,27 @@ public: } bool displayYUV(AVFrame *pFrame){ if (!_win) { + int w, h; + double hw = 0.0f; + w = pFrame->width; + h = pFrame->height; + hw = (double)h / (double)w; + w = 720; + h = w * hw; if (_hwnd) { _win = SDL_CreateWindowFrom(_hwnd); }else { _win = SDL_CreateWindow(_title.data(), SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, - pFrame->width, - pFrame->height, - SDL_WINDOW_OPENGL); + w, + h, + SDL_WINDOW_OPENGL |SDL_WINDOW_RESIZABLE | SDL_WINDOW_SHOWN); // 允许最大化 } + SDL_SetWindowInputFocus(_win); + SDL_RaiseWindow(_win); + // SDL_GL_SetSwapInterval(1); // 1 ,“开启垂直同步”就是让程序“等显示器”,以牺牲一点延迟换取画面完整无撕裂。 + } if (_win && ! _render){ #if 0