Skip to content

libvmaf/psnr: publish APSNR for luma only when chroma is disabled - #1725

Open
lusoris wants to merge 1 commit into
Netflix:masterfrom
vidiko:fix/psnr-apsnr-luma-only
Open

lusoris wants to merge 1 commit into
Netflix:masterfrom
vidiko:fix/psnr-apsnr-luma-only

Conversation

@lusoris

@lusoris lusoris commented Nov 17, 2026

Copy link
Copy Markdown

With enable_chroma=false, or a YUV400 input, flush() in integer_psnr.c still publishes apsnr_cb and apsnr_cr. Their pixel counts stay zero, so both aggregates come out as NaN and the JSON output shows them as null. This is one of the two concerns PR 1666 mixed together; the zero-error cap goes in a separate PR.

Fix

flush() aggregates enable_chroma ? 3 : 1 planes, the same plane count extract() and close() already use. With chroma enabled nothing changes.

Before and after

64x64 4:2:0 clip, --feature psnr=enable_apsnr=true:enable_chroma=false --json, release build:

master cf677baa this branch
8 bit apsnr_y 64.254403 64.254403
10 bit apsnr_y 76.321112 76.321112
apsnr_cb, apsnr_cr null not published

Tests

Three new cases in test_psnr, built on flush():

  • test_apsnr_luma_only (8 bit) and test_apsnr_luma_only_16b: apsnr_y has the expected value, apsnr_cb and apsnr_cr are absent.
  • test_apsnr_chroma_enabled: with chroma on, all three aggregates are present and finite.

Without the fix, test_psnr fails on the unexpected apsnr_cb.

Validation

  • x86-64 Linux, GCC 16.2.1, release build on master cf677baa: the libvmaf unit suite passes 25 of 25, test_psnr included.
  • CI on a fork branch with this commit plus one fork-only commit that pins the workflow actions to commit SHAs (the fork requires pinned actions): libvmaf, checkasm, ffmpeg, Windows and Docker all pass.

With enable_chroma=false, or a YUV400P input, flush() still wrote
apsnr_cb and apsnr_cr. Their pixel counts stay zero, so both aggregates
came out as NaN and the JSON output showed them as null. Use the same
plane count as extract() and close(), so the chroma aggregates appear
only when chroma is measured.

Add tests for the luma-only case at 8 and 16 bits and for the
three-plane case with chroma enabled.

Signed-off-by: Lusoris <lusoris@pm.me>
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