ffmpeg/tests
Niklas Haas f6a2d41fe2 swscale/ops: keep track of correct dither min/max
Mostly, this just affects the metadata in benign ways, e.g.:

 rgb24 -> yuv444p:
   [ u8 +++X] SWS_OP_READ         : 3 elem(s) packed >> 0
     min: {0, 0, 0, _}, max: {255, 255, 255, _}
   [ u8 +++X] SWS_OP_CONVERT      : u8 -> f32
     min: {0, 0, 0, _}, max: {255, 255, 255, _}
   [f32 ...X] SWS_OP_LINEAR       : matrix3+off3 [...]
     min: {16, 16, 16, _}, max: {235, 240, 240, _}
   [f32 ...X] SWS_OP_DITHER       : 16x16 matrix + {0 3 2 -1}
-    min: {33/2, 33/2, 33/2, _}, max: {471/2, 481/2, 481/2, _}
+    min: {16.001953, 16.001953, 16.001953, _}, max: {235.998047, 240.998047, 240.998047, _}
   [f32 +++X] SWS_OP_CONVERT      : f32 -> u8
     min: {16, 16, 16, _}, max: {235, 240, 240, _}
   [ u8 XXXX] SWS_OP_WRITE        : 3 elem(s) planar >> 0
     (X = unused, z = byteswapped, + = exact, 0 = zero)

However, it surprisingly actually includes a semantic change, whenever
converting from limited range to monob or monow:

 yuv444p -> monow:
   [ u8 +XXX] SWS_OP_READ         : 1 elem(s) planar >> 0
     min: {0, _, _, _}, max: {255, _, _, _}
   [ u8 +XXX] SWS_OP_CONVERT      : u8 -> f32
     min: {0, _, _, _}, max: {255, _, _, _}
   [f32 .XXX] SWS_OP_LINEAR       : luma [...]
     min: {-20/219, _, _, _}, max: {235/219, _, _, _}
   [f32 .XXX] SWS_OP_DITHER       : 16x16 matrix + {0 -1 -1 -1}
-    min: {179/438, _, _, _}, max: {689/438, _, _, _}
+    min: {-0.089371, _, _, _}, max: {2.071106, _, _, _}
+  [f32 .XXX] SWS_OP_MAX          : {0 0 0 0} <= x
+    min: {0, _, _, _}, max: {2.071106, _, _, _}
   [f32 .XXX] SWS_OP_MIN          : x <= {1 _ _ _}
-    min: {179/438, _, _, _}, max: {1, _, _, _}
+    min: {0, _, _, _}, max: {1, _, _, _}
   [f32 +XXX] SWS_OP_CONVERT      : f32 -> u8
     min: {0, _, _, _}, max: {1, _, _, _}
   [ u8 XXXX] SWS_OP_WRITE        : 1 elem(s) planar >> 3
     (X = unused, z = byteswapped, + = exact, 0 = zero)

Note the presence of an extra SWS_OP_MAX, to correctly clamp sub-blacks
(values below 16) to 0.0, rather than underflowing. This was previously
undetected because the dither was modelled as adding 0.5 to every pixel value,
but that's only true on average - not always.

Signed-off-by: Niklas Haas <git@haasn.dev>
2026-03-29 12:13:11 +02:00
..
api api-h264-test: indent output 2025-10-25 11:11:41 +02:00
checkasm tests/checkasm/sw_ops: add tests for SWS_OP_FILTER_H/V 2026-03-28 18:50:14 +01:00
fate tests/checkasm: Add sbcdsp tests 2026-03-28 11:25:38 +01:00
filtergraphs tests/fate: add fate test for excessive frame buffering when using filters 2025-07-14 22:05:11 +02:00
maps fate: Add fsync filter tests 2024-01-05 09:29:05 +01:00
ref swscale/ops: keep track of correct dither min/max 2026-03-29 12:13:11 +02:00
streamgroups tests/fate/iamf: add tests for Projection mode ambisonic Audio Elements 2025-12-29 12:02:53 -03:00
.gitignore
audiogen.c tests/audiogen: Fix total RIFF chunk size 2024-03-28 11:54:41 +01:00
audiomatch.c
base64.c
copycooker.sh
extended.ffconcat all: fix whitespace/new-line issues 2025-08-03 13:48:47 +02:00
fate-run.sh libavformat/oggenc.c: re-initialize stream on new metadata. 2026-02-18 16:25:06 +00:00
fate-valgrind.supp
fate.sh fate.sh: Allow specifying --ar through a separate variable 2025-12-19 18:41:23 +00:00
Makefile tests/fate: Add SBC tests 2026-03-28 11:25:38 +01:00
md5.sh
refcmp-metadata.awk
reference.pnm
rotozoom.c
simple1.ffconcat all: fix whitespace/new-line issues 2025-08-03 13:48:47 +02:00
simple2.ffconcat all: fix whitespace/new-line issues 2025-08-03 13:48:47 +02:00
test.ffmeta
tiny_psnr.c
tiny_ssim.c
utils.c
videogen.c