克隆时必须加 --recursive,否则缺少 bundled 的 3rdparty 依赖;Vulkan 后端构建需要 python3-Jinja2,且通常要用 -Dvulkan-registry 指定 vk.xml 路径;默认不启用任何后端,需显式开启 opengl、vulkan 或 d3d11 才有实际功能。
git clone --recursive https://code.videolan.org/videolan/libplacebo
meson ./build
ninja -C./build支持 Vulkan(含 MoltenVK)1.2、OpenGL(GLSL >= 130,GL/GL ES >= 3.0)、Direct3D 11(特性级别 >= 9_1);README 未给出显存要求。
mpv 核心渲染算法抽成的独立 GPU 视频处理库,做高质量缩放、HDR 与色彩管理
GPU 加速的视频渲染与色彩管理库,为 mpv、FFmpeg 等播放器提供高质量缩放、HDR 色调映射和着色器处理。
核心能力
- 提供 Jinc 极坐标滤波的高质量缩放,含抗锯齿与抗振铃
- 动态 HDR 色调映射,实时统计场景直方图并检测场景切换
- 原生支持 Dolby Vision,可将 Profile 5 转为 HDR/PQ 或 SDR
- 可插拔自定义着色器系统,可加载 RAVU、FSRCNNX、Anime4K
- GPU 端合成 AV1/H.274 胶片颗粒,减轻 CPU 解码负担
容易踩的坑
- v7.387.0最新正式版2026-10-25 · 2026-10-25 20:33 UTC
v7.387.0
This release introduces a new compositor API with support for multiple video inputs, JSON-based scene descriptions and animation, alongside support for Dolby Vision Profile 7 FEL. It also includes significant improvements to color management, HDR tone mapping, frame interpolation, deinterlacing and GPU backends, as well as numerous bug fixes.
Additions:
- add PL_COLOR_TRC_SCRGB and PL_COLOR_SCRGB_WHITE
- add pl_frame.pixel_aspect_ratio and populate it from FFmpeg metadata
- add pl_vulkan_queue.flags
- add pl_dovi_metadata.nlq, .nlq_active, and pl_dovi_nlq_data.hdr_in_max
- add pl_frame.enhancement_layer
- add pl_shader_decode_color_ex and pl_color_decode
- add pl_color_decode_args.enhancement_layer and .primaries
- add pl_color_repr_limits
- add pl_color_map_params.film_strength and .mastering_clip
- add pl_color_repr_decode_ex and pl_shader_encode_color_ex
- add pl_frame_size
- add pl_vec2d(f), pl_vec3d(f) and matrix/transform vector helpers
- add pl_compositor API for multi-input video compositing
- add pl_render_params.transparency
- add pl_renderer_reset
- add PL_OPT_STRUCT and pl_opt_data.path for nested options
- add pl_scene API for JSON-based scene graphs with animated parameters
- add pl_compositor and pl_input colorspace and chroma loc overrides
- add pl_queue_set_status and pl_queue_get_status
- add support for Dolby Vision Profile 7 FEL merging
- support VK_COLOR_SPACE_PASS_THROUGH_EXT in Vulkan swapchain colorspace hints
- support VK_KHR_internally_synchronized_queues when explicitly requested
Changes:
- deprecate pl_shader_decode_color in favor of pl_shader_decode_color_ex
- deprecate pl_avdovi_metadata_supported and pl_avframe_params.map_dovi_force
- change frame queue timing parameters and estimates from float to double
- change the units of pl_dovi_metadata.comp.pivots
- preserve full-range signal bit depth during color representation normalization
- increase MAX_SHEXP_SIZE from 32 to 64 for custom shaders
- fall back to MaxCLL when mastering display peak luminance is unavailable
- blend frames in linear light, while overlays remain blended in the target transfer function
- respect signaled black level metadata for PQ sources instead of always forcing zero nits
- re-enable linear-light downscaling for HDR sources
- fix luminance handling for input frames with ICC profiles
- mark the AMD proprietary Vulkan driver as host_ptr_slow
Fixes and enhancements:
- workaround broken timeline semaphore support on MoltenVK
- fix AV1 film grain at 1:1 output on D3D11
- fix flashing artifacts with certain temporal scaling filter kernels
- fix background blur edge cases and simplify blurred background rendering
- fix attempting to merge failed shaders
- fix AV1 film grain vertical flip on flipped targets
- fix non-multiplane format bit_shift not being set in pl_map_avframe*
- fix FBO format fallback for narrower component counts
- workaround rendering artifacts on Nvidia Vulkan drivers
- workaround rendering artifacts on Nvidia OpenGL drivers
- disable broken glInvalidateFramebuffer on Nvidia OpenGL
- improve Vulkan Host Image Copy compatibility and handling
- fix alpha mode handling during frame blending
- preserve energy during orthogonal scaling
- snap alpha values near 0 or 1 before blending
- improve numerical stability of sigmoidization
- preserve true black instead of raising it to PL_COLOR_HDR_BLACK
- prevent dithering from lifting true black off zero
- fix BWDIF clamping range calculation
- match input and output luminance for SDR-to-SDR rendering
- respect transfer function hints for D3D11 swapchains
- avoid clamping output luminance when tone mapping is disabled
- use HDR10+ maximum scene luminance metadata and fix scene_max fallback
- fix FPS estimation with deferred second fields in frame queues
- improve deinterlacing, including bob interpolation, border handling and BWDIF edge cases
- fix several V
- v7.360.12026-03-13 · 2026-03-13 19:49 UTC
查看更新说明
This release fixes a few issues with the Vulkan and OpenGL renderers.
Fixes:
- fix sync object leak on OpenGL
- suppress compiler warnings on benchmark test
- disable deferred memory allocation on Nvidia altogether
- workaround timeline semaphore bugs on MoltenVK
- v7.360.02026-02-11 · 2026-02-11 15:53 UTC
查看更新说明
This release introduces some new features, alongside a bunch of miscellaneous bug fixes across the board, in particular, major improvements to the Vulkan renderer.
Additions:
- add pl_gpu_limits.host_ptr_slow to notify if host pointer import is slow
- add PL_DEINTERLACE_BWDIF
- add PL_CLEAR_BLUR and pl_render_params.blur_radius to allow clearing with a blurred copy of image
- add pl_daylight_from_temp, pl_blackbody_from_temp
- add PL_COLOR_SYSTEM_YCGCO_{RE,RO}
- add pl_vulkan_swapchain_params.{alpha,color}_bits
- add pl_d3d11_swapchain_params.{alpha,color}_bits
Changes:
- pl_shader_{encode,decode}_color no longer (de)linearizes XYZ
- pl_avframe_set_repr now sets frame.alpha_mode
- pl_white_from_temp now computes a blend of the daylight and blackbody temperatures (old behavior can be achieved with pl_daylight_from_temp)
Fixes and enhancements:
- fix double application of alpha mode
- fix math in pl_primaries_compatible
- refactor and fix host-visible VRAM limit for Vulkan
- fix unsigned integer overflow with complex overlays
- fix many issues with frame_queue, mostly for interlaced sources and other esoteric files
- fix internal primaries/transfer function mapping of Vulkan color spaces
- Vulkan swapchain improvements by using VK_KHR_swapchain_maintenance1 when available
- switch to extended HLG gamma formula
- fix issues with SDR output in HDR mode on Windows with d3d11
- fix pl_filter_config_eq when comparing tunable with not tunable
- improve surface format and colorspace selection for Vulkan swapchains
- use deferred memory allocation for Vulkan swapchains
- render overlays with the same colorspace as source image
- convert background color to target and use infinite contrast for them
- prefer Vulkan formats that can be used for direct-to-display output on Apple
- v7.351.02025-05-21 · 2025-05-21 18:21 UTC
查看更新说明
This release mainly introduces a variety of miscellaneous bug fixes, alongside two minor / maintenance changes.
Additions:
- add pl_{opengl,vulkan,d3d11}_params.no_compute to suppress the use of compute shaders
- add pl_cache_{set,get}_file()
Changes:
- libav vulkan interop now requires lavu 58.11.100+ and vulkan 1.2.175+
- "sinc" filter preset radius dropped from 3 to 2
Fixes and performance enhancements:
- fix compilation of fuzzer test
- fix shader variable renaming loop
- fix error when the same gpu descriptor is used twice in one shader
- don't expose unsupported d3d11 formats
- fix rendering with flipped planes and user shaders
- fix rendering of textures with unusual channel order
- don't apply sigmoidization to alpha channel
- attach correctly normalized extension list to vulkan device creation
- fix orthogonal scaling fast path leaking garbage pixels
- some GLES 2.0 fixes
- fix DCDM XYZ decoding into DCI-P3
- fix build with glslang 15
- fix compilation without nuklear
- fix backwards compatibility with pl_render_params.skip_target_clearing
- correctly output requested alpha mode
- preserve alpha channel when blending subsampled formats
- multiply plane scale even when not scaling
- propagate correct plane format after plane merging
- fix build with instrumentation enabled
- fix bug where layout transitions happened too early in some cases
- fix handling of promoted extension and function names
- don't scale alpha when blending low bit depth YUV planes
- fix build error with recent libavformat
- fix plane channel order when merging planes
- invalidate shader cache when GL version strings change
- fix compute shader promotion for flipped outputs
- fix upload of YUVA formats with reduced bit depths
- v7.349.02024-07-02 · 2024-07-02 13:32 UTC
查看更新说明
This release introduces a number of minor and maintenance changes, and bumps the major version to v7 in order to clean up old deprecations. The main focus was on bug fixing and performance improvements, with some new API additions as a side product of that.
Additions:
- add pl_peak_detect_params.black_cutoff, fixing unnatural flickering from encoding noise near black
- add pl_queue_params.drift_compensation (and PL_QUEUE_DEFAULTS), to help adjust for slight discrepencancies due to e.g. 0.1% differences between 60.00 Hz and 59.94 Hz.
- add pl_cache_signature() to test if a cache object needs to be updated
- add pl_map_avdovi_metadata()
- add PL_ALPHA_NONE, distinguishing itself from PL_ALPHA_UNKNOWN
- add pl_frame_clear_tiles()
- add pl_gpu_limits.max_mapped_vram
- add pl_color_linearize() and pl_color_delinearize()
- add pl_color_{primaries,system,transfer}_name(s)
- add fourcc codes for AB48 and AR48
- add support for dovi extension block parsing in utils/libav.h
Changes:
- remove fields deprecated in libplacebo v5
- deprecate pl_frame_map_avdovi_metadata(), see pl_map_avdovi_metadata() for a replacement
- deprecate pl_render_params.skip_target_clearing and .blend_against_tiles, instead introduce new fields pl_render_params.background and .border, which can be set to an explicit value to control how the background and border are drawn (respectively).
- ICC profiles with well-known transfer functions are now identified as such
- White point adaptation is now done using CAT16, replacing CAT97.
Fixes and performance enhancements:
- fix accidentally removed symbols (cubic samplers)
- improve cache efficiency of plplay
- fix segfault when writing to oddly sized vulkan buffers under some circumstances
- fix various extension checks for GLES
- fix rgba8 not being marked host-readable on GLES
- fix bit shift of vulkan P010 frames
- also allow built-in fast paths for custom filters which are equivalent to built-in filters
- massively improve compilation time of large ortho samplers, by not unrolling past a certain point
- fix build issues past certain versions of glslang
- slightly modify debanding algorithm to reduce some blurring and increase performance
- fix wrong primaries being selected for linear light BT.709 swapchains
- fix non-compute polar sampling fallback
- allow polar sampling up to 64x64, up from 32x32
- make polar compute shader more flexible w.r.t hardware limits
- avoid compute shaders on very large polar radius
- fix exhausting mapped VRAM on non-resizable BAR devices
- fix use-after-free race when using download callbacks
- prefer peak detection over static metadata when inferring tone mapping state
- fix use as meson subproject
- clean up ICC metadata reporting to conform to normal libplacebo style
- allow timer queries to work on GL (ES) 3.0+
- fix GLSL version detection on GLES
- fix cache coherency issues on d3d11
- fix accidental rounding of sub-pixel offsets inside renderer
- allow using xxhash as subproject
- improve texture format sorting preference
- add support for 16hf formats on GL
- fix 32/64-bit cache mismatch on windows+d3d11
- fix superfluous function load warning on vulkan
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
libplacebo
libplacebo is, in a nutshell, the core rendering algorithms and ideas of mpv rewritten as an independent library. As of today, libplacebo contains a large assortment of video processing shaders, focusing on both quality and performance. These include features such as the following:
- High-quality, optimized upscaling and downscaling including support for polar filters ("Jinc"), anti-aliasing, anti-ringing and gamma correct scaling.
- Dynamic HDR tone mapping, including real-time measurement of scene histogram, scene change detection, dynamic exposure control, perceptual gamut stretching, contrast recovery and more.
- Native support for Dolby Vision HDR, including Profile 5 conversion to HDR/PQ or SDR, reading DV side data, and reshaping.
- A colorimetrically accurate color management engine with support for soft gamut mapping, ICC profiles, accurate ITU-R BT.1886 emulation, black point compensation, and custom 3DLUTs (.cube).
- A pluggable, extensible custom shader system. This can be used to arbitrarily extend the range of custom shaders to include popular user shaders like RAVU, FSRCNNX, or Anime4K. See the mpv wiki on user scripts for more information.
- High performance film grain synthesis for AV1 and H.274, allowing media players to offload this part of decoding from the CPU to the GPU.
- Tunable, fast debanding and deinterlacing shaders.
- High quality gamma-correct dithering, including error diffusion modes.
Every attempt was made to provide these features at a high level of
abstraction, taking away all the messy details of GPU programming, color
spaces, obscure subsampling modes, image metadata manipulation, and so on.
Expert-level functionality is packed into easy-to-use functions like
pl_frame_from_avframe and pl_render_image.
Hardware requirements
libplacebo currently supports Vulkan (including MoltenVK), OpenGL, and Direct3D 11. It currently has the following minimum hardware requirements:
- Vulkan: Core version 1.2
- OpenGL: GLSL version >= 130 (GL >= 3.0, GL ES >= 3.0)
- Direct3D: Feature level >= 9_1
For more documentation, including an introduction to the API, see the project website.
Examples
This screenshot from the included plplay demo program highlights just some of the features supported by the libplacebo rendering code, all of which are adjustable dynamically during video playback.
History
This project grew out of an interest to accomplish the following goals:
- Clean up mpv's internal RA API and make it reusable for other projects, as a general high-level backend-agnostic graphics API wrapper.
- Provide a standard library of useful GPU-accelerated image processing
primitives based on GLSL, so projects like media players or browsers can use
them without incurring a heavy dependency on
libmpv. - Rewrite core parts of mpv's GPU-accelerated video renderer on top of redesigned abstractions, in order to modernize it and allow supporting more features.
It has since been adopted by VLC as their optional Vulkan-based video output path, and is provided as a Vulkan-based video filter in the FFmpeg project.
API Overview
The public API of libplacebo is currently split up into the following
components, the header files (and documentation) for which are available
inside the src/include/libplacebo directory. The
API is available in different "tiers", representing levels of abstraction
inside libplacebo. The APIs in higher tiers depend on those in lower tiers.
Which tier is used by a user depends on how much power/control they want over
the actual rendering. The low-level tiers are more suitable for big projects
that need strong control over the entire rendering pipeline; whereas the
high-level tiers are more suitable for smaller or simpler projects that want
libplacebo to take care of everything.
Tier 0 (logging, raw math primitives)
cache.h: Caching subsystem. Used to cache large or computationally heavy binary blobs, such as compiled shaders, 3DLUTs, and so on.colorspace.h: A collection of enums and structs for describing color spaces, as well as a collection of helper functions for computing various color space transformation matrices.common.h: A collection of miscellaneous utility types and macros that are shared among multiple subsystems. Usually does not need to be included directly.log.h: Logging subsystem.config.h: Macros defining information about the way libplacebo was built, including the version strings and compiled-in features/dependencies. Usually does not need to be included directly. May be useful for feature tests.dither.h: Some helper functions for generating various noise and dithering matrices. Might be useful for somebody else.filters.h: A collection of reusable reconstruction filter kernels, which can be used for scaling. The generated weights arrays are semi-tailored to the needs of libplacebo, but may be useful to somebody else regardless. Also contains the structs needed to define a filter kernel for the purposes of libplacebo's upscaling routines.tone_mapping.h: A collection of tone mapping functions, used for conversions between HDR and SDR content.gamut_mapping.h: A collection of gamut mapping functions, used for conversions between wide gamut and standard gamut content, as well as for gamut recompression after tone-mapping.
The API functions in this tier are either used throughout the program (context, common etc.) or are low-level implementations of filter kernels, color space conversion logic etc.; which are entirely independent of GLSL and even the GPU in general.
Tier 1 (rendering abstraction)
gpu.h: Exports the GPU abstraction API used by libplacebo internally.swapchain.h: Exports an API for wrapping platform-specific swapchains and other display APIs. This is the API used to actually queue up rendered frames for presentation (e.g. to a window or display device).vulkan.h: GPU API implementation based on Vulkan.opengl.h: GPU API implementation based on OpenGL.d3d11.h: GPU API implementation based on Direct3D 11.dummy.h: Dummy GPI API (interfaces with CPU only, no shader support)
As part of the public API, libplacebo exports a middle-level abstraction for dealing with GPU objects and state. Basically, this is the API libplacebo uses internally to wrap OpenGL, Vulkan, Direct3D etc. into a single unifying API subset that abstracts away state, messy details, synchronization etc. into a fairly high-level API suitable for libplacebo's image processing tasks.
It's made public both because it constitutes part of the public API of various image processing functions, but also in the hopes that it will be useful for other developers of GPU-accelerated image processing software.
Tier 2 (GLSL generating primitives)
shaders.h: The low-level interface to shader generation. This can be used to generate GLSL stubs suitable for inclusion in other programs, as part of larger shaders. For example, a program might use this interface to generate a specialized tone-mapping function for performing color space conversions, then call that from their own fragment shader code. This abstraction has an optional dependency ongpu.h, but can also be used independently from it.
In addition to this low-level interface, there are several available shader routines which libplacebo exports:
shaders/colorspace.h: Shader routines for decoding and transforming colors, tone mapping, and so forth.shaders/custom.h: Allows directly ingesting custom GLSL logic into thepl_shaderabstraction, either as bare GLSL or in mpv .hook format.shaders/deinterlacing.h: GPU deinterlacing shader based on yadif.shaders/dithering.h: Shader routine for various GPU dithering methods.shaders/film_grain.h: Film grain synthesis shaders for AV1 and H.274.shaders/icc.h: Shader for ICC profile based color management.shaders/lut.h: Code for applying arbitrary 1D/3D LUTs.shaders/sampling.h: Shader routines for various algorithms that sample from images, such as debanding and scaling.
Tier 3 (shader dispatch)
dispatch.h: A higher-level interface to thepl_shadersystem, based ongpu.h. This dispatch mechanism generates+executes complete GLSL shaders, subject to the constraints and limitations of the underlying GPU.
This shader dispatch mechanism is designed to be combined with the shader
processing routines exported by shaders/*.h, but takes care of the low-level
translation of the resulting pl_shader_res objects into legal GLSL. It also
takes care of resource binding, shader input placement, as well as shader
caching and resource pooling; and makes sure all generated shaders have unique
identifiers (so they can be freely merged together).
Tier 4 (high level renderer)
options.h: A high-level options framework which wraps all of the options comprisingpl_render_paramsinto a memory-managed, serializable struct that can also be treated as a key/value dictionary. Also includes an options parser to load options provided by the API user in string format.compositor.h: A high-level wrapper aroundrenderer.hwhich allows for compositing multiple inputs on a virtual timeline / canvas, with support for PTS synchronization, correct blending, and so forth.renderer.h: A high-level renderer which combines the shader primitives and dispatch mechanism into a fully-fledged rendering pipeline that takes raw texture data and transforms it into the desired output image.utils/frame_queue.h: A high-level frame queuing abstraction. This API can be used to interface with a decoder (or other source of frames), and takes care of translating timestamped frames into a virtual stream of presentation events suitable for use withrenderer.h, including any extra context required for frame interpolation (pl_frame_mix).utils/upload.h: A high-level helper for uploading generic data in some user-described format to a plane texture suitable for use withrenderer.h. These helpers essentially take care of picking/mapping a good image format supported by the GPU. (Note: Eventually, this function will also support on-CPU conversions to a different format where necessary, but for now, it will just fail)utils/dav1d.h: High level helper for translating between Dav1dPicture and libplacebo'spl_frame. (Single header library)utils/libav.h: High-level helpers for interoperation between libplacebo and FFmpeg's libav* abstractions. (Single header library)
This is the "primary" interface to libplacebo, and the one most users will be interested in. It takes care of internal details such as degrading to simpler algorithms depending on the hardware's capabilities, combining the correct sequence of colorspace transformations and shader passes in order to get the best overall image quality, and so forth.
Authors
libplacebo was founded and primarily developed by Niklas Haas (@haasn), but it would not be possible without the contributions of others, especially support for windows.
License
libplacebo is currently available under the terms of the LGPLv2.1 (or later) license. However, it's possible to release it under a more permissive license (e.g. BSD2) if a use case emerges.
Please open an issue if you have a use case for a BSD2-licensed libplacebo.
Installing
Obtaining
When cloning libplacebo, make sure to provide the --recursive flag:
$ git clone --recursive https://code.videolan.org/videolan/libplacebo
Alternatively (on an existing clone):
$ git submodule update --init
Doing either of these pulls in a handful of bundled 3rdparty dependencies. Alternatively, they can be provided via the system.
Building from source
libplacebo is built using the meson build system. You can build the project using the following steps:
$ DIR=./build
$ meson $DIR
$ ninja -C$DIR
To rebuild the project on changes, re-run ninja -Cbuild. If you wish to
install the build products to the configured prefix (typically /usr/local/),
you can run ninja -Cbuild install. Note that this is normally ill-advised
except for developers who know what they're doing. Regular users should rely
on distro packages.
Dependencies
In principle, libplacebo has no mandatory dependencies - only optional ones.
However, to get a useful version of libplacebo. you most likely want to build
with support for either opengl, vulkan or d3d11. libplacebo built without
these can still be used (e.g. to generate GLSL shaders such as the ones used in
VLC), but the usefulness is severely impacted since most components will be
missing, impaired or otherwise not functional.
A full list of optional dependencies each feature requires:
- glslang:
glslang+ its related libraries (e.g.libSPIRV.so) - lcms:
liblcms2 - libdovi:
libdovi - opengl:
glad2(*) - shaderc:
libshaderc - vulkan:
libvulkan,python3-jinja2(*) - xxhash:
libxxhash
(*) This dependency is bundled automatically when doing a recursive clone.
Vulkan support
Because the vulkan backend requires on code generation at compile time,
python3-Jinja2 is a hard dependency of the build system. In addition to this,
the path to the Vulkan registry (vk.xml) must be locatable, ideally by
explicitly providing it via the -Dvulkan-registry=/path/to/vk.xml option,
unless it can be found in one of the built-in hard-coded locations.
Configuring
To get a list of configuration options supported by libplacebo, after running
meson $DIR you can run meson configure $DIR, e.g.:
$ meson $DIR
$ meson configure $DIR
If you want to disable a component, for example Vulkan support, you can
explicitly set it to false, i.e.:
$ meson configure $DIR -Dvulkan=disabled -Dshaderc=disabled
$ ninja -C$DIR
Testing
To enable building and executing the tests, you need to build with
tests enabled, i.e.:
$ meson configure $DIR -Dtests=true
$ ninja -C$DIR test
Benchmarking
A naive benchmark suite is provided as an extra test case, disabled by default
(due to the high execution time required). To enable it, use the bench
option:
$ meson configure $DIR -Dbench=true
$ meson test -C$DIR benchmark --verbose
Using
For a full documentation of the API, refer to the above API Overview as well as the public header files. You can find additional examples of how to use the various components in the demo programs as well as in the unit tests.