Skip to content

Commit 11bf94d

Browse files
committed
Merge branch 'feature/placebo-module' of https://github.com/D-Ogi/mlt into libplacebo
2 parents d26b3f3 + cc02961 commit 11bf94d

14 files changed

Lines changed: 1623 additions & 6 deletions

.github/workflows/build-distros.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,35 +34,36 @@ jobs:
3434
sed -i 's/^Types: deb/Types: deb deb-src/' /etc/apt/sources.list.d/ubuntu.sources
3535
DEBIAN_FRONTEND=noninteractive apt-get -qq update
3636
DEBIAN_FRONTEND=noninteractive apt-get -yqq build-dep mlt
37-
DEBIAN_FRONTEND=noninteractive apt-get -yqq install cmake qt6-base-dev libqt6svg6-dev
37+
DEBIAN_FRONTEND=noninteractive apt-get -yqq install cmake qt6-base-dev libqt6svg6-dev libplacebo-dev
3838
- name: ubuntu-22.04
3939
image: ubuntu:22.04
4040
setup_script: |
4141
sed -i '/^#\sdeb-src /s/^#//' "/etc/apt/sources.list"
4242
DEBIAN_FRONTEND=noninteractive apt-get -qq update
4343
DEBIAN_FRONTEND=noninteractive apt-get -yqq build-dep mlt
44-
DEBIAN_FRONTEND=noninteractive apt-get -yqq install cmake qt6-base-dev libqt6svg6-dev libqt6core5compat6-dev
44+
DEBIAN_FRONTEND=noninteractive apt-get -yqq install cmake qt6-base-dev libqt6svg6-dev libqt6core5compat6-dev libplacebo-dev
4545
- name: debian-unstable
4646
image: debian:unstable
4747
setup_script: |
4848
echo 'deb-src http://deb.debian.org/debian unstable main' >> /etc/apt/sources.list
4949
apt-get -qq update
5050
apt-get -yqq build-dep mlt
51+
apt-get -yqq install libplacebo-dev
5152
- name: debian-testing
5253
image: debian:testing
5354
setup_script: |
5455
echo 'deb-src http://deb.debian.org/debian testing main' >> /etc/apt/sources.list
5556
apt-get -qq update
5657
apt-get -yqq build-dep mlt
57-
apt-get -yqq install cmake qt6-base-dev libqt6svg6-dev
58+
apt-get -yqq install cmake qt6-base-dev libqt6svg6-dev libplacebo-dev
5859
- name: debian-stable
5960
image: debian:stable
6061
setup_script: |
6162
echo 'deb-src http://deb.debian.org/debian stable main\ndeb-src http://deb.debian.org/debian stable-updates main' >> /etc/apt/sources.list
6263
echo 'deb http://deb.debian.org/debian bookworm-backports main' >> /etc/apt/sources.list
6364
apt-get -qq update
6465
apt-get -yqq build-dep mlt
65-
apt-get -yqq install cmake qt6-base-dev libqt6svg6-dev
66+
apt-get -yqq install cmake qt6-base-dev libqt6svg6-dev libplacebo-dev
6667
- name: fedora-42
6768
image: fedora:42
6869
setup_script: |
@@ -75,7 +76,8 @@ jobs:
7576
libtheora-devel libvorbis-devel libvdpau-devel \
7677
libsoup-devel liboil-devel python-devel alsa-lib \
7778
pulseaudio-libs-devel gcc-c++ cmake ffmpeg-free-devel \
78-
movit-devel rubberband-devel vid.stab-devel
79+
movit-devel rubberband-devel vid.stab-devel \
80+
libplacebo-devel
7981
- name: fedora-38
8082
image: fedora:38
8183
setup_script: |

.github/workflows/build-linux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
sudo apt-get -qq update
4040
sudo apt-get -yqq build-dep mlt
4141
sudo apt-get -yqq install qt6-base-dev libqt6svg6-dev libqt6core5compat6-dev
42-
sudo apt-get -yqq install cmake ninja-build kwalify
42+
sudo apt-get -yqq install cmake ninja-build kwalify libplacebo-dev
4343
cmake -D CMAKE_BUILD_TYPE=Debug -D BUILD_TESTING=ON -D SWIG_PYTHON=ON -S . -B build -G Ninja
4444
cmake --build build
4545
sudo cmake --install build

.github/workflows/build-msys2-mingw64.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ jobs:
5959
mingw-w64-x86_64-x264
6060
mingw-w64-x86_64-x265
6161
mingw-w64-x86_64-zimg
62+
mingw-w64-x86_64-libplacebo
6263
6364
- uses: actions/checkout@v4
6465

.github/workflows/static-code-analysis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ jobs:
1919
--library=cppcheck.cfg
2020
--suppress=ctuOneDefinitionRuleViolation
2121
--suppress=syntaxError:src/modules/xml/common.c
22+
--suppress=syntaxError:src/modules/placebo/filter_placebo_render.c
23+
--suppress=syntaxError:src/modules/placebo/filter_placebo_shader.c
24+
--suppress=syntaxError:src/modules/placebo/gpu_context.c
2225
steps:
2326
- uses: actions/checkout@v4
2427
- name: Install Cppcheck

CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ option(MOD_NORMALIZE "Enable Normalize module (GPL)" ON)
3434
option(MOD_OLDFILM "Enable Oldfilm module" ON)
3535
option(MOD_OPENCV "Enable OpenCV module" OFF)
3636
option(MOD_OPENFX "Enable OpenFX module (GPL)" ON)
37+
option(MOD_MOVIT "Enable OpenGL module" ON)
38+
option(MOD_PLACEBO "Enable libplacebo GPU module" ON)
3739
option(MOD_PLUS "Enable Plus module" ON)
3840
option(MOD_PLUSGPL "Enable PlusGPL module (GPL)" ON)
3941
option(MOD_QT6 "Enable Qt6 module (GPL)" ON)
@@ -309,6 +311,15 @@ if(MOD_OPENFX)
309311
pkg_check_modules(glib IMPORTED_TARGET glib-2.0)
310312
endif()
311313

314+
if(MOD_PLACEBO)
315+
pkg_check_modules(libplacebo IMPORTED_TARGET libplacebo)
316+
if(libplacebo_FOUND)
317+
list(APPEND MLT_SUPPORTED_COMPONENTS placebo)
318+
else()
319+
set(MOD_PLACEBO OFF)
320+
endif()
321+
endif()
322+
312323
if(MOD_PLUS)
313324
pkg_check_modules(libebur128 IMPORTED_TARGET libebur128)
314325
list(APPEND MLT_SUPPORTED_COMPONENTS plus)
@@ -583,6 +594,8 @@ add_feature_info("Module: Normalize" MOD_NORMALIZE "")
583594
add_feature_info("Module: Oldfilm" MOD_OLDFILM "")
584595
add_feature_info("Module: OpenCV" MOD_OPENCV "")
585596
add_feature_info("Module: OpenFX" MOD_OPENFX "")
597+
add_feature_info("Module: Movit" MOD_MOVIT "")
598+
add_feature_info("Module: Placebo" MOD_PLACEBO "")
586599
add_feature_info("Module: Plus" MOD_PLUS "")
587600
add_feature_info("Module: PlusGPL" MOD_PLUSGPL "")
588601
add_feature_info("Module: Qt6" MOD_QT6 "")

src/modules/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ if(MOD_MOVIT)
4848
add_subdirectory(movit)
4949
endif()
5050

51+
if(MOD_PLACEBO)
52+
add_subdirectory(placebo)
53+
endif()
54+
5155
if(MOD_PLUS)
5256
add_subdirectory(plus)
5357
endif()

src/modules/placebo/CMakeLists.txt

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
find_package(PkgConfig REQUIRED)
2+
pkg_check_modules(libplacebo IMPORTED_TARGET libplacebo>=5.229)
3+
if(NOT libplacebo_FOUND)
4+
return()
5+
endif()
6+
7+
add_library(mltplacebo MODULE
8+
factory.c
9+
gpu_context.c gpu_context.h
10+
filter_placebo_render.c
11+
filter_placebo_shader.c
12+
)
13+
14+
file(GLOB YML "*.yml")
15+
add_custom_target(Other_placebo_Files SOURCES
16+
${YML}
17+
)
18+
19+
include(GenerateExportHeader)
20+
generate_export_header(mltplacebo)
21+
target_compile_options(mltplacebo PRIVATE ${MLT_COMPILE_OPTIONS})
22+
target_include_directories(mltplacebo PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
23+
target_link_libraries(mltplacebo PRIVATE mlt PkgConfig::libplacebo)
24+
25+
# Only link D3D11 if libplacebo was built with D3D11 support
26+
include(CheckCSourceCompiles)
27+
set(CMAKE_REQUIRED_INCLUDES ${libplacebo_INCLUDE_DIRS})
28+
check_c_source_compiles("
29+
#include <libplacebo/config.h>
30+
#if !defined(PL_HAVE_D3D11) || !PL_HAVE_D3D11
31+
#error no d3d11
32+
#endif
33+
int main(void) { return 0; }
34+
" PLACEBO_HAS_D3D11)
35+
if(PLACEBO_HAS_D3D11)
36+
target_link_libraries(mltplacebo PRIVATE d3d11 dxgi)
37+
endif()
38+
if(WIN32)
39+
target_link_libraries(mltplacebo PRIVATE shell32 ole32)
40+
endif()
41+
42+
if(MSVC)
43+
target_link_libraries(mltplacebo PRIVATE PThreads4W::PThreads4W)
44+
endif()
45+
46+
set_target_properties(mltplacebo PROPERTIES
47+
LIBRARY_OUTPUT_DIRECTORY "${MLT_MODULE_OUTPUT_DIRECTORY}")
48+
49+
install(TARGETS mltplacebo LIBRARY DESTINATION ${MLT_INSTALL_MODULE_DIR})
50+
51+
install(FILES
52+
filter_placebo_render.yml
53+
filter_placebo_shader.yml
54+
DESTINATION ${MLT_INSTALL_DATA_DIR}/placebo
55+
)

src/modules/placebo/factory.c

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* factory.c -- module registration for libplacebo filters
3+
* Copyright (C) 2025 D-Ogi
4+
*
5+
* This library is free software; you can redistribute it and/or
6+
* modify it under the terms of the GNU Lesser General Public
7+
* License as published by the Free Software Foundation; either
8+
* version 2.1 of the License, or (at your option) any later version.
9+
*
10+
* This library is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
* Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Lesser General Public
16+
* License along with this library; if not, write to the Free Software
17+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18+
*/
19+
20+
#include "mltplacebo_export.h"
21+
#include <framework/mlt.h>
22+
#include <limits.h>
23+
#include <string.h>
24+
25+
extern mlt_filter filter_placebo_render_init(mlt_profile profile,
26+
mlt_service_type type,
27+
const char *id,
28+
char *arg);
29+
extern mlt_filter filter_placebo_shader_init(mlt_profile profile,
30+
mlt_service_type type,
31+
const char *id,
32+
char *arg);
33+
34+
static mlt_properties metadata(mlt_service_type type, const char *id, void *data)
35+
{
36+
char file[PATH_MAX];
37+
snprintf(file, PATH_MAX, "%s/placebo/%s", mlt_environment("MLT_DATA"), (char *) data);
38+
return mlt_properties_parse_yaml(file);
39+
}
40+
41+
MLTPLACEBO_EXPORT MLT_REPOSITORY
42+
{
43+
MLT_REGISTER(mlt_service_filter_type, "placebo.render", filter_placebo_render_init);
44+
MLT_REGISTER(mlt_service_filter_type, "placebo.shader", filter_placebo_shader_init);
45+
MLT_REGISTER_METADATA(mlt_service_filter_type,
46+
"placebo.render",
47+
metadata,
48+
"filter_placebo_render.yml");
49+
MLT_REGISTER_METADATA(mlt_service_filter_type,
50+
"placebo.shader",
51+
metadata,
52+
"filter_placebo_shader.yml");
53+
}

0 commit comments

Comments
 (0)