Skip to content

Commit

Permalink
Update mpv
Browse files Browse the repository at this point in the history
  • Loading branch information
xfangfang committed Jan 22, 2025
1 parent dc059a2 commit 8646e46
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 18 deletions.
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,6 @@ elseif (PLATFORM_PSV)
NAME ${PROJECT_NAME}
FILE ${PSV_ASSETS_FILES}
)
# TODO: Remove after mpv related code is done
list(APPEND APP_PLATFORM_LINK_OPTION "-Wl,--allow-multiple-definition")
elseif (PLATFORM_PS4)
add_self(${PROJECT_NAME})
add_pkg(${PROJECT_NAME}
Expand Down
4 changes: 2 additions & 2 deletions scripts/psv/mpv_gxm/VITABUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pkgname=mpv
pkgver=11c16a2aa7d1e985b4d494da0a2ca19cc73bb5c4
pkgver=a6f4a7e6c4b38626cf80e18987dd3bcfca78a4b5
pkgrel=3
url="https://mpv.io/"
source=("${pkgname}-${pkgver}.tar.gz::https://github.com/xfangfang/mpv/archive/${pkgver}.tar.gz")
Expand All @@ -24,7 +24,7 @@ build() {
-Dsdl2=enabled \
-Dlibmpv=true \
-Dgxm=enabled \
-Dvitashark=enabled \
-Dvitashark=disabled \
-Dcplayer=false

meson compile -C build
Expand Down
2 changes: 1 addition & 1 deletion wiliwili/include/utils/thread_helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#define THREAD_POOL_MAX_THREAD_NUM 4
#elif defined(__PSV__)
#define THREAD_POOL_MIN_THREAD_NUM 1
#define THREAD_POOL_MAX_THREAD_NUM 2
#define THREAD_POOL_MAX_THREAD_NUM 4
#elif defined(PS4)
#define THREAD_POOL_MIN_THREAD_NUM 1
#define THREAD_POOL_MAX_THREAD_NUM 4
Expand Down
9 changes: 6 additions & 3 deletions wiliwili/include/view/mpv_core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <mpv/render_dxgi.h>
#elif defined(BOREALIS_USE_GXM)
#include <mpv/render_gxm.h>
#include <nanovg_gxm_utils.h>
#elif defined(BOREALIS_USE_OPENGL)
#include <mpv/render_gl.h>
#if defined(__PSV__) || defined(PS4)
Expand Down Expand Up @@ -426,9 +427,11 @@ class MPVCore : public brls::Singleton<MPVCore> {
int nvg_image = 0;
bool redraw = false;
mpv_gxm_fbo mpv_fbo = {
.tex = nullptr,
.w = DISPLAY_WIDTH,
.h = DISPLAY_HEIGHT,
.render_target = nullptr,
.color_surface = nullptr,
.depth_stencil_surface = nullptr,
.w = DISPLAY_WIDTH,
.h = DISPLAY_HEIGHT,
.format = SCE_GXM_TEXTURE_FORMAT_U8U8U8U8_RGBA,
};
int flip_y{1};
Expand Down
15 changes: 5 additions & 10 deletions wiliwili/source/view/mpv_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ void MPVCore::init() {
{MPV_RENDER_PARAM_GXM_INIT_PARAMS, &gxm_params},
{MPV_RENDER_PARAM_INVALID, nullptr}};

if (mpv_fbo.tex == nullptr) {
if (mpv_fbo.render_target == nullptr) {
int texture_width = DISPLAY_WIDTH;
int texture_height = DISPLAY_HEIGHT;
int texture_stride = ALIGN(texture_width, 8);
Expand All @@ -462,7 +462,10 @@ void MPVCore::init() {
.display_height = texture_height,
.display_stride = texture_stride,
};
mpv_fbo.tex = gxmCreateFramebuffer(&framebufferOpts);
NVGXMframebuffer *fbo = gxmCreateFramebuffer(&framebufferOpts);
mpv_fbo.render_target = fbo->gxm_render_target;
mpv_fbo.color_surface = &fbo->gxm_color_surfaces[0].surface;
mpv_fbo.depth_stencil_surface = &fbo->gxm_depth_stencil_surface;
mpv_fbo.w = texture_width;
mpv_fbo.h = texture_height;
}
Expand Down Expand Up @@ -790,14 +793,6 @@ void MPVCore::draw(brls::Rect area, float alpha) {
#elif defined(BOREALIS_USE_GXM)
auto *vg = brls::Application::getNVGContext();

// TODO: 完全完成mpv后移除, 目前mpv调用nanovg内的 gxmClear 会导致视频画面闪烁
if (rect.getWidth() < brls::Application::contentWidth) {
nvgBeginPath(vg);
nvgFillColor(vg, brls::Application::getTheme().getColor("brls/background"));
nvgRect(vg, 0, 0, brls::Application::contentWidth, brls::Application::contentHeight);
nvgFill(vg);
}

NVGpaint img = nvgImagePattern(vg, 0, 0, mpv_fbo.w, mpv_fbo.h, 0, nvg_image, alpha);
nvgBeginPath(vg);
nvgRect(vg, area.getMinX(), area.getMinY(), area.getWidth(), area.getHeight());
Expand Down

0 comments on commit 8646e46

Please sign in to comment.