Skip to content

libvmaf: add median and percentile C API pooling - #1589

Open
lusoris wants to merge 1 commit into
Netflix:masterfrom
VMAFx:feat/percentile-pooling
Open

libvmaf: add median and percentile C API pooling#1589
lusoris wants to merge 1 commit into
Netflix:masterfrom
VMAFx:feat/percentile-pooling

Conversation

@lusoris

@lusoris lusoris commented Sep 8, 2026

Copy link
Copy Markdown

The C pooling API cannot currently select the median or lower percentiles requested in #818. This adapts VMAFx #1340 to current upstream C11: append MEDIAN, PERC5, PERC10, and PERC20, gather the scores selected by the inclusive interval and n_subsample, then sort and linearly interpolate at percentile * (n - 1) / 100. Existing pooling values, accumulation order, and allocation behavior remain unchanged. The README and public header document the semantics and memory cost.

The implementation explicitly rejects non-finite samples because current upstream permits importing them (unlike the fork's collector). It propagates missing-score errors, rejects an empty selected interval, checks allocation size, and uses 64-bit interval arithmetic to avoid wrapping at UINT_MAX. The feature-pooling output is unchanged on failure.

This adds the C API functionality. FFmpeg's filter option mapping needs a separate FFmpeg-side change, so this does not claim that its pool option immediately accepts the new values. No CLI option, model, bootstrap-confidence-interval formula, or golden assertion changes.

Validation on upstream f85a853692a8c730d0270cd733c8bb30b5b93b7c, x86-64 Linux, GCC 15.2 / C11, Meson 1.10.1:

meson setup build libvmaf -Denable_cuda=false -Denable_docs=false -Denable_float=true --buildtype=release
ninja -C build
meson test -C build --print-errorlogs
# 24/24 passed

meson setup build-sanitize libvmaf -Denable_cuda=false -Denable_docs=false -Denable_float=true --buildtype=debug -Db_sanitize=address,undefined
ninja -C build-sanitize
meson test -C build-sanitize test_pool_percentile --print-errorlogs
# 5 regression cases passed with ASan/UBSan/LSan

Cases cover interpolation on unsorted scores without mutating their stored order, singleton/tied/negative values, subsampling and partial intervals, missing/non-finite scores, invalid arguments, UINT_MAX endpoints, and delegation from cached model scores. The new interpolation test fails when only libvmaf.c is replaced by the original upstream file. Sanitizer coverage claimed here is the targeted test; the full upstream baseline has unrelated LeakSanitizer failures in test_predict and test_pic_preallocation, recorded while validating #1588.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant