checkasm/sw_ops: add SWS_UOP_LUT_3D test

checkasm:
 - CPU: AMD Ryzen 9 9950X3D 16-Core Processor (00B40F40)
 - Timing source: x86 (rdtsc)
 - Bench duration: 100000 µs per function (448667793 cycles)
 - Random seed: 3773883393
Benchmark results:
  name                         cycles (vs ref)
  f32_lut_3d_xyz_dynamic_c:  125193.9
  f32_lut_3d_xyz_static_c:    25792.1
  f32_lut_3d_xyzw_dynamic_c: 123807.1
  f32_lut_3d_xyzw_static_c:   25739.0

This is roughly ~50% faster than the existing code in lut3d.c, from a quick
test.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
This commit is contained in:
Niklas Haas
2026-07-26 00:04:59 +02:00
committed by Niklas Haas
parent 3df239e113
commit 01a25f74cc

View File

@@ -634,6 +634,32 @@ static void check_dither(const char *name, SwsUOp *uop)
av_refstruct_unref(&matrix);
}
static void check_lut_3d(const char *name, SwsUOp *uop)
{
SwsLut3D *lut3d = ff_sws_lut3d_alloc();
if (!lut3d) {
fail();
return;
}
checkasm_init(&lut3d->input, sizeof(lut3d->input));
if (uop->par.lut3d.dynamic) {
checkasm_init(&lut3d->tone_map, sizeof(lut3d->tone_map));
checkasm_init(&lut3d->output, sizeof(lut3d->output));
lut3d->dynamic = true;
/* Prevent out-of-bounds read from IPT values with abs(PT) > 0.5 */
for (int i = 0; i < FF_ARRAY_ELEMS(lut3d->tone_map); i++)
lut3d->tone_map[i].y = FFMIN(lut3d->tone_map[i].y, 1 << 15);
}
uop->data.lut3d = lut3d;
check_range(name, uop, MK_RANGES(INPUT_LUT_SIZE - 1));
av_refstruct_unref(&lut3d);
}
#define CHECK_FUNCTION(CHECK, NAME, ...) \
CHECK(#NAME, &(SwsUOp) { __VA_ARGS__ });
@@ -678,4 +704,5 @@ void checkasm_check_sw_ops(void)
CHECK_FOR(CLEAR, check_vec4);
CHECK_FOR(LINEAR, check_linear);
CHECK_FOR(DITHER, check_dither);
CHECK_FOR(LUT_3D, check_lut_3d);
}