Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
sinsanction committed Mar 24, 2024
2 parents eaea217 + 0d907ac commit 2b21858
Show file tree
Hide file tree
Showing 7 changed files with 279 additions and 259 deletions.
44 changes: 10 additions & 34 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ jobs:
image: docker://archlinux:base-devel

steps:

- name: Get current date and random hash
run: |
echo "short_date=$(date "+%Y%m%d")" >> $GITHUB_ENV
Expand All @@ -27,11 +26,11 @@ jobs:
run: |
echo -e "[multilib]\nInclude = /etc/pacman.d/mirrorlist" >> /etc/pacman.conf
pacman -Syu --noconfirm
pacman -S --noconfirm --needed jq openssh git gyp mercurial subversion ninja \
cmake ragel yasm nasm asciidoc enca gperf unzip p7zip gcc-multilib clang \
python-pip curl lib32-glib2 wget rustup cargo-c
pacman -S --noconfirm --needed git gyp mercurial subversion ninja cmake meson \
ragel yasm nasm asciidoc enca gperf unzip p7zip gcc-multilib clang \
python-pip curl openssl
pip3 install rst2pdf mako meson
pip3 install rst2pdf mako jsonschema
git config --global user.name "github-actions"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global --add safe.directory $PWD
Expand All @@ -41,31 +40,15 @@ jobs:
repository: quietvoid/mpv-winbuild-cmake
ref: vs-placebo-libdovi

- name: Cache
uses: actions/cache@v3
id: cache
with:
path: |
src_packages
build64
key: ${{ runner.os }}-build-mycache-vsplacebo-libdovi

- name: Cache info
run: |
echo "Cache hit: ${{ steps.cache.outputs.cache-hit }}"
- name: Downloading source
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
run: |
cmake -DTARGET_ARCH=x86_64-w64-mingw32 -DALWAYS_REMOVE_BUILDFILES=ON -DSINGLE_SOURCE_LOCATION=$PWD/src_packages -G Ninja -Bbuild64 -H.
cmake -DTARGET_ARCH=x86_64-w64-mingw32 -DALWAYS_REMOVE_BUILDFILES=ON -DSINGLE_SOURCE_LOCATION=$PWD/src_packages -DRUSTUP_LOCATION=$PWD/install_rustup -G Ninja -Bbuild64 -H.
ninja -C build64 download || true
- name: Building toolchain
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
id: build_toolchain
continue-on-error: true
run: |
if [[ ! "$(ls -A build64/install/bin)" ]]; then ninja -C build64 gcc; fi
run: ninja -C build64 gcc

- name: Update dependencies
id: update_deps
Expand All @@ -75,7 +58,7 @@ jobs:
- name: Building vs-placebo
id: build_vs_placebo
if: ${{ steps.cache.outputs.cache-hit == 'true' || steps.build_toolchain.outcome == 'success' }}
if: ${{ steps.build_toolchain.outcome == 'success' }}
continue-on-error: true
run: |
ninja -C build64 vs-placebo
Expand All @@ -99,23 +82,16 @@ jobs:
path: release

- name: Collecting logs
id: collect_logs
if: always()
run: |
mkdir -p build64_logs
cp -fr $(find build64 -type f -iname "*-*.log") build64_logs || true
7z a -m0=lzma2 -mx=9 -ms=on logs.7z build*logs
- name: Uploading logs
id: upload_logs
continue-on-error: true
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@master
if: always()
with:
name: logs
path: logs.7z
retention-days: 1

- name: Cleaning build directory
id: delete_build_dir
run: |
ninja -C build64 clean
du -sh build64 src_packages /var/cache/pacman/pkg || true
76 changes: 42 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,66 +3,74 @@

 

#### ``placebo.Deband(clip clip[, int planes = 1, int iterations = 1, float threshold = 4.0, float radius = 16.0, float grain = 6.0, int dither = True, int dither_algo = 0])``
#### `placebo.Deband(clip clip[, int planes = 1, int iterations = 1, float threshold = 4.0, float radius = 16.0, float grain = 6.0, int dither = True, int dither_algo = 0])`

Input needs to be 8 or 16 bit Integer or 32 bit Float.

- ``planes``: the planes to filter. The n-th plane is processed if the n-th lowest bit of ``planes`` is 1, so for example to filter all planes, pass ``planes = 1 | 2 | 4`` .
- `planes`: the planes to filter. The n-th plane is processed if the n-th lowest bit of `planes` is 1, so for example to filter all planes, pass `planes = 1 | 2 | 4` .
(Yes, this is needlessly complex, but it was the simplest to implement.)

- ``dither``: whether the debanded frame should be dithered or rounded from float to the output bitdepth. Only works for 8 bit.
- `dither`: whether the debanded frame should be dithered or rounded from float to the output bitdepth. Only works for 8 bit.

For details on the [debanding params](https://github.com/haasn/libplacebo/blob/master/src/include/libplacebo/shaders/sampling.h#L39)
and the [dither methods](https://github.com/haasn/libplacebo/blob/master/src/include/libplacebo/shaders/colorspace.h#L275),
see the libplacebo header files.

 

#### ``placebo.Tonemap(clip clip[, int src_csp, int dst_csp, int dst_prim, float src_max, float src_min, float dst_max, float dst_min, int dynamic_peak_detection, float smoothing_period, float scene_threshold_low, scene_threshold_high, int intent, int gamut_mode, int tone_mapping_function, int tone_mapping_mode, float tone_mapping_param, float tone_mapping_crosstalk, bool use_dovi])``
#### `placebo.Tonemap(clip clip[, int src_csp, int dst_csp, int dst_prim, float src_max, float src_min, float dst_max, float dst_min, int dynamic_peak_detection, float smoothing_period, float scene_threshold_low, scene_threshold_high, int intent, int gamut_mode, int tone_mapping_function, int tone_mapping_mode, float tone_mapping_param, float tone_mapping_crosstalk, bool use_dovi, bool visualize_lut])`

Performs color mapping (which includes tonemapping from HDR to SDR, but can do a lot more).
Expects RGB48 or YUVxxxP16 input.
Outputs RGB48 or YUV444P16, depending on input color family.

- ``src_csp, dst_csp``:
- `src_csp, dst_csp`:
See the `supported_colorspace` in `tonemap.c` for the valid src/dst colorspaces.
For example, to map from [BT.2020, PQ] (HDR) to traditional [BT.709, BT.1886] (SDR), pass ``src_csp=1, dst_csp=0``.
- ``dst_prim``: Target color primaries. See [pl_color_primaries](https://github.com/haasn/libplacebo/blob/master/src/include/libplacebo/colorspace.h#L193) for valid values.
- ``src_max, src_min, dst_max, dst_min``: Source/target display levels, in nits (cd/m^2). Source can be derived from props if available.
For example, to map from [BT.2020, PQ] (HDR) to traditional [BT.709, BT.1886] (SDR), pass `src_csp=1, dst_csp=0`.
- `dst_prim`: Target color primaries. See [pl_color_primaries](https://github.com/haasn/libplacebo/blob/master/src/include/libplacebo/colorspace.h#L193) for valid values.
- `src_max, src_min, dst_max, dst_min`: Source/target display levels, in nits (cd/m^2). Source can be derived from props if available.

- ``dynamic_peak_detection``: enables computation of signal stats to optimize HDR tonemapping quality. Enabled by default.
- ``smoothing_period, scene_threshold_low, scene_threshold_high``: peak detection params. See [here](https://github.com/haasn/libplacebo/blob/master/src/include/libplacebo/shaders/colorspace.h#L85).
- ``gamut_mode, tone_mapping_function, tone_mapping_mode, tone_mapping_param, tone_mapping_crosstalk``:
- `dynamic_peak_detection`: enables computation of signal stats to optimize HDR tonemapping quality. Enabled by default.
- `smoothing_period, scene_threshold_low, scene_threshold_high`: peak detection params. See [here](https://github.com/haasn/libplacebo/blob/master/src/include/libplacebo/shaders/colorspace.h#L85).
- `gamut_mode, tone_mapping_function, tone_mapping_mode, tone_mapping_param, tone_mapping_crosstalk`:
[Color mapping params](https://github.com/haasn/libplacebo/blob/master/src/include/libplacebo/shaders/colorspace.h#L237).
- ``use_dovi``: Whether to use the Dolby Vision RPU for ST2086 metadata. Defaults to true when tonemapping from Dolby Vision.
- `tone_mapping_function_s`: Tone mapping function name, overwrites `tone_mapping_function` number.
- `use_dovi`: Whether to use the Dolby Vision RPU for ST2086 metadata. Defaults to true when tonemapping from Dolby Vision.
- `visualize_lut`: Display a (PQ-PQ) graph of the active tone-mapping LUT. See [mpv docs](https://mpv.io/manual/master/#options-tone-mapping-visualize).

For Dolby Vision support, FFmpeg 5.0 minimum and git ffms2 are required, as well as libplacebo v4.157.0.185 or newer.
Currently, [libdovi](https://github.com/quietvoid/dovi_tool/tree/main/dolby_vision) is required.
For Dolby Vision support, FFmpeg 5.0 minimum and git ffms2 are required.

For Windows, `libdovi` is available as a [precompiled DLL](https://github.com/quietvoid/dovi_tool/releases/tag/libdovi-1.6.7).
The library must be placed in the same directory as `vs-placebo` and be named `dovi.dll`.
 

**Supported frame props**
- `PLSceneMax`, `PLSceneAvg`: Per-scene dynamic brightness metadata, in nits (cd/m^2).
- `float[] PLSceneMax`: the scene's peak brightness. Can be specified by component (RGB) or a single value.
- `float PLSceneAvg`: the scene's average brightness.

Requires `libplacebo` v5.246.0 or newer, otherwise ignored.
If `use_dovi` is enabled, `scene_max` and `scene_avg` are derived from the Dolby Vision RPU L1 metadata instead of the props.

 

#### ``placebo.Resample(clip clip[, int width, int height, string filter = "ewa_lanczos", float radius, float clamp, float taper, float blur, float param1, float param2, float sx = 0.0, float sy = 0.0, float antiring = 0.0, int lut_entries = 64, float cutoff = 0.001, bool sigmoidize = 1, bool linearize = 1, float sigmoid_center = 0.75, float sigmoid_slope = 6.5, int trc = 1])``
#### `placebo.Resample(clip clip[, int width, int height, string filter = "ewa_lanczos", float radius, float clamp, float taper, float blur, float param1, float param2, float sx = 0.0, float sy = 0.0, float antiring = 0.0, int lut_entries = 64, float cutoff = 0.001, bool sigmoidize = 1, bool linearize = 1, float sigmoid_center = 0.75, float sigmoid_slope = 6.5, int trc = 1])`

Input needs to be 8 or 16 bit Integer or 32 bit Float

- ``filter``: See [the header](https://github.com/haasn/libplacebo/blob/210131146739e4e84d689f32c17a97b27a6550bd/src/include/libplacebo/filters.h#L187) for possible values (remove the “pl_filter” before the filter name, e.g. ``filter="lanczos"``).
- ``sx``, ``sy``: Top left corner of the source region. Can be used for subpixel shifts
- ``clamp, taper, blur``: [Filter config](https://github.com/haasn/libplacebo/blob/885e89bccfb932d9e8c8659039ab6975e885e996/src/include/libplacebo/filters.h#L148).
- `filter`: See [the header](https://github.com/haasn/libplacebo/blob/210131146739e4e84d689f32c17a97b27a6550bd/src/include/libplacebo/filters.h#L187) for possible values (remove the “pl_filter” before the filter name, e.g. `filter="lanczos"`).
- `sx`, `sy`: Top left corner of the source region. Can be used for subpixel shifts
- `clamp, taper, blur`: [Filter config](https://github.com/haasn/libplacebo/blob/885e89bccfb932d9e8c8659039ab6975e885e996/src/include/libplacebo/filters.h#L148).

- ``radius, param1, param2``: [Kernel config](https://github.com/haasn/libplacebo/blob/885e89bccfb932d9e8c8659039ab6975e885e996/src/include/libplacebo/filters.h#L30-L131).
- ``sigmoidize, linearize``: Whether to linearize/sigmoidize before scaling.
- `radius, param1, param2`: [Kernel config](https://github.com/haasn/libplacebo/blob/885e89bccfb932d9e8c8659039ab6975e885e996/src/include/libplacebo/filters.h#L30-L131).
- `sigmoidize, linearize`: Whether to linearize/sigmoidize before scaling.
Enabled by default for RGB, disabled for YCbCr because NCL YCbCr can’t be correctly linearized without conversion to RGB.
Defaults to disabled for GRAY since it may be a YCbCr plane, but can be manually enabled.
When sigmodizing, ``linearize`` should be True as well. (Currently mangles HDR video, so disable for that.)
- ``sigmoid_center, sigmoid_slope``: Sigmoid curve parameters.
- ``trc``: The [transfer curve](https://github.com/haasn/libplacebo/blob/master/src/include/libplacebo/colorspace.h#L183) to use for linearizing.
When sigmodizing, `linearize` should be True as well. (Currently mangles HDR video, so disable for that.)
- `sigmoid_center, sigmoid_slope`: Sigmoid curve parameters.
- `trc`: The [transfer curve](https://github.com/haasn/libplacebo/blob/master/src/include/libplacebo/colorspace.h#L183) to use for linearizing.

 

#### ``placebo.Shader(clip clip, [string shader, int width, int height, int chroma_loc = 1, int matrix = 2, int trc = 1, string filter = "ewa_lanczos", float radius, float clamp, float taper, float blur, float param1, float param2, float antiring = 0.0, int lut_entries = 64, float cutoff = 0.001, bool sigmoidize = 1, bool linearize = 1, float sigmoid_center = 0.75, float sigmoid_slope = 6.5, string shader_s])``
#### `placebo.Shader(clip clip, [string shader, int width, int height, int chroma_loc = 1, int matrix = 2, int trc = 1, string filter = "ewa_lanczos", float radius, float clamp, float taper, float blur, float param1, float param2, float antiring = 0.0, int lut_entries = 64, float cutoff = 0.001, bool sigmoidize = 1, bool linearize = 1, float sigmoid_center = 0.75, float sigmoid_slope = 6.5, string shader_s])`

Runs a GLSL shader in [mpv syntax](https://mpv.io/manual/master/#options-glsl-shader).

Expand All @@ -74,18 +82,18 @@ As such, the user needs to specify the output frame properties,
and libplacebo will produce a conforming image,
only running the supplied shader if the texture it hooks into is actually rendered.
For example, if a shader hooks into the LINEAR texture,
it will only be executed when ``linearize = True``.
it will only be executed when `linearize = True`.

- ``shader``: Path to shader file.
- ``shader_s``: Alternatively, String containing the shader. (``shader`` takes precedence.)
- ``width, height``: Output dimensions. Need to be specified for scaling shaders to be run.
- `shader`: Path to shader file.
- `shader_s`: Alternatively, String containing the shader. (`shader` takes precedence.)
- `width, height`: Output dimensions. Need to be specified for scaling shaders to be run.
Any planes the shader doesn’t scale appropiately will be scaled to output res by libplacebo
using the supplied filter options, which are identical to ``Resample``’s.
using the supplied filter options, which are identical to `Resample`’s.
(To be exact, chroma will be scaled to what the luma prescaler outputs
(or the source luma res); then the image will be scaled to output res in RGB and converted back to YUV.)
- ``chroma_loc``: Chroma location to derive chroma shift from. Uses [pl_chroma_location](https://github.com/haasn/libplacebo/blob/524e3965c6f8f976b3f8d7d82afe3083d61a7c4d/src/include/libplacebo/colorspace.h#L332) enum values.
- ``matrix``: [YUV matrix](https://github.com/haasn/libplacebo/blob/524e3965c6f8f976b3f8d7d82afe3083d61a7c4d/src/include/libplacebo/colorspace.h#L26).
- ``sigmoidize, linearize, sigmoid_center, sigmoid_slope, trc``: For shaders that hook into the LINEAR or SIGMOID texture.
- `chroma_loc`: Chroma location to derive chroma shift from. Uses [pl_chroma_location](https://github.com/haasn/libplacebo/blob/524e3965c6f8f976b3f8d7d82afe3083d61a7c4d/src/include/libplacebo/colorspace.h#L332) enum values.
- `matrix`: [YUV matrix](https://github.com/haasn/libplacebo/blob/524e3965c6f8f976b3f8d7d82afe3083d61a7c4d/src/include/libplacebo/colorspace.h#L26).
- `sigmoidize, linearize, sigmoid_center, sigmoid_slope, trc`: For shaders that hook into the LINEAR or SIGMOID texture.

 

Expand Down
4 changes: 2 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
project('vs-placebo', ['c', 'cpp'],
default_options: ['buildtype=release', 'b_ndebug=if-release', 'c_std=c11', 'cpp_std=c++11'],
meson_version: '>=0.51.0',
version: '1.4.3'
version: '1.4.4'
)

win32 = host_machine.system() == 'windows' or host_machine.system() == 'cgywin'
win32 = host_machine.system() == 'windows' or host_machine.system() == 'cygwin'

if win32
add_project_link_arguments('-static', language: ['c', 'cpp'])
Expand Down
Loading

0 comments on commit 2b21858

Please sign in to comment.