Skip to content

libvmaf/feature/integer_adm: keep Barten CSF weights within their fixed-point types - #1734

Open
Shakhtar-Sankur wants to merge 1 commit into
Netflix:masterfrom
Shakhtar-Sankur:integer-adm-barten-weights
Open

Shakhtar-Sankur wants to merge 1 commit into
Netflix:masterfrom
Shakhtar-Sankur:integer-adm-barten-weights

Conversation

@Shakhtar-Sankur

Copy link
Copy Markdown

Fixes #1662.

With adm_csf_mode=1 and the default adm_csf_scale / adm_csf_diag_scale, the Barten CSF weights are about 1.2 at scale 0 and 5 at scale 1. The integer extractor stores them as Q21/Q23 in uint16_t (scale 0) and Q32 in uint32_t (scales 1 to 3), so they overflow, and integer_adm2_csf_1 comes out near 0.008 instead of matching float_adm.

This follows the shared-exponent approach described in #1662:

  • adm_csf_weight_shift() returns k = 0 when every weight of a scale fits its type, so Watson97 and the blend modes (2, 3) take exactly the existing code path.
  • Otherwise it returns the smallest k that brings each weight down to at most the Watson97 weight of the same band. All three bands share k, so their ratios are kept.
  • adm_csf / i4_adm_csf store the weights divided by 2^k, and adm_cm / i4_adm_cm, whose cubed sum scales with 2^(-3k), multiply it back in the final conversion.
  • The SIMD CSF and contrast-masking kernels are only used when k = 0; when k > 0 the C versions run, so the AVX2 / AVX-512 / NEON code is unchanged.

Results on src01_hrc00/hrc01 576x324 (48 frames), master cf677ba vs this branch:

master this PR float_adm
integer_adm2_csf_1, frame 0 0.007807 0.965400 0.965404
integer_adm3_csf_1, frame 0 0.503843 0.979498 0.979501
integer_adm_scale3_csf_1, frame 0 0.000956 0.978608 0.978614
integer_aim_csf_1, frame 0 0.000122 0.006404 0.006402
  • Max |integer - float| over all frames and scales is 0.00051, the same as Barten with adm_csf_scale=0.002893 / adm_csf_diag_scale=0.001586, whose weights already fit and are unchanged.
  • adm_csf_mode 0, 2 and 3: all 21 integer ADM features are identical to master, with the default SIMD dispatch and with --cpumask -1.
  • adm_csf_mode=1 gives identical results with SIMD dispatch and with --cpumask -1.
  • meson test: 27/27 on master and on this branch.
  • Added test_run_integer_adm_fextractor_barten_csf to python/test/vmafexec_feature_extractor_test.py. It fails on master (0.007807 != 0.9654) and passes here; the other 33 integer ADM and float Barten tests pass on both.

Run log: https://www.kaggle.com/code/sankurkundu/notebook987cf8a98e

…ed-point types

With adm_csf_mode=1 and the default adm_csf_scale/adm_csf_diag_scale, the
Barten weights are about 1.2 at scale 0 and 5 at scale 1. They do not fit
the Q21/Q23 uint16_t (scale 0) and Q32 uint32_t (scales 1 to 3) weights of
the integer extractor, so integer_adm2_csf_1 came out near 0.002 or NaN
instead of matching float_adm (0.965404 on frame 0 of src01).

When a weight of a scale does not fit its type, scale all three weights of
that scale down by a shared 2^k that brings each one to at most the Watson97
weight of the same band, and multiply the cubed contrast-masking sum back by
2^(3k). Weights that already fit (Watson97 and the blend modes) give k = 0
and are unchanged. The SIMD CSF and contrast-masking kernels are used only
when k = 0; otherwise the C versions run.

Fixes Netflix#1662.
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.

integer_adm: adm_csf_mode=1 (Barten) wraps the fixed-point CSF weights, adm2 comes out near 0.003 or NaN

1 participant