* Add risk-aware fast lane to 5.x CI
* Make fast CI the default for 5.x PRs
* Run full CI as a same-commit delta
* Fix RISC-V full-delta dispatch
* Remove CI mode labels after workflow completion
* Handle startup failures in CI label cleanup
* Reset CI mode labels on new commits
* dnn: test LogSoftmax far below the maximum
LogSoftmax must give x - max - log(sum(exp(x - max))) for values about 104 or more below the row maximum, where exp underflows in float32. Covers a short row and one long enough for the SIMD loops, on the CPU and OpenCL targets. Port of the test from #30545.
* dnn: compute LogSoftmax without taking the log of softmax
logSoftmax() took the log of the softmax output, so elements whose exp(x - max) underflows came out as -inf. The dispatched softmax kernel already has the row maximum and the sum of exp((x - max) * scale), so softmax() takes a logSoftmax flag and the log path writes (x - max) * scale - log(sum) directly.
The OpenCL kernels had the same problem with LOG_SOFTMAX: they now keep x - max, add up exp(x - max) and return x - max - log(sum). This covers the generic kernels in softmax.cl and the subgroup kernels in softmax_loss.cl.
Port of #30545 to 5.x.
* doc(core): fix LUT index formula for CV_8S and CV_16S inputs
LUT reads CV_8S and CV_16S values as the unsigned numbers with the same bits, so negative values index the upper half of the table (-1 maps to entry 255 for CV_8S). The docs said the index was src + 128 (CV_8S) or src + 32768 (CV_16S), which is wrong for every value. Also remove a stray 'ref' in the compare docs.
* doc(core): fix LUT index rule in HAL interface docs
cv_hal_lut and cv_hal_lut16 docs still said 128 or 32768 is added to the index for 8s and 16s inputs. Use the same rule as the LUT docs: the input is read as unsigned with the same bits, and no offset is added.
core: fix locateROI and getUMat for 1D Mat and UMat
Problem
For a 1D Mat, Mat::locateROI divides by step[0] (the element size), so it counts every element as a row and returns a wrong wholeSize and offset. Because of this, adjustROI doesn't grow 1D slices, and getUMat on a 1D slice recurses until the stack overflows. UMat::locateROI has the same bug.
Fix
Mat::locateROI and UMat::locateROI: for dims == 1, compute the offset and whole size from the element size: ofs = (delta1 / esz, 0) and wholeSize = (delta2 / esz, 1). The width is clamped to at least ofs.x + cols, like the 2D code.
Mat::getUMat: for a 1D slice, cut the result out of the whole UMat with a Range instead of a Rect, so the returned UMat stays 1D. Cutting with a Rect always made it 2D.
2D Mats and UMats are unchanged.
core: saturate cv::add and cv::subtract on CV_64S and CV_64UProblem
cv::add and cv::subtract are documented to saturate, and they do on every depth up to 32 bits. On 64 bits there is no wider type to hold the result, so add wrapped on CV_64S and CV_64U, and subtract wrapped on CV_64S. For example, INT64_MAX + 1 gave INT64_MIN. Signed overflow is also undefined behaviour in C++.
Fix
Added int64_t and uint64_t overloads of EwAdd::scl and an int64_t overload of EwSub::scl. They check for overflow before computing the result, like the existing uint64_t overload in EwSub.
Updated the comment on EwAdd::scl, which described 32-bit and 64-bit results as wrapping.
Other depths still use the generic scl, so their behaviour does not change.
* dnn: keep INT4/UINT4 QuantizeLinear off the AVX2 per-tensor fast path
The x86 AVX2 path for per-tensor float to int8/uint8 returns before the
4-bit saturation added in #30596, so INT4/UINT4 outputs were still
clamped to the 8-bit range there. Skip it for 4-bit output and add a
per-tensor INT4/UINT4 test that reaches that path on x86.
* dnn: clamp INT4/UINT4 inside the AVX2 per-tensor QuantizeLinear path
Pass the output range into the AVX2 kernel instead of skipping it, so
per-tensor INT4/UINT4 keeps the vectorized, parallel path; the kernel
already clamps in float before converting. The post-pass from #30596
is only reached by the generic path now. Widen the regression test to
35 elements so it covers the 8-lane loop and the scalar tail on x86.
* dnn: drop the PR reference from the INT4 QuantizeLinear test comment
---------
Co-authored-by: Kaustubh Arora <arorakaustubh681@gmail.com>
* video: dis: vectorize Densification_ParBody with scalable intrinsics
* video: dis: address review comments: braces, parameterized test on all platforms
* video: dis: restore useOptimized with a scope guard in the DIS reference test
* core: support CV_16F and CV_16BF in finiteMask
finiteMask asserted CV_32F or CV_64F input, so 16-bit float arrays,
which can hold NaN and infinity too, could not be checked.
Add finiteMask16_, which marks a pixel as finite if no channel has an
all-ones exponent (0x7c00 for CV_16F, 0x7f80 for CV_16BF), for 1 to 4
channels. getFiniteMaskFunc now takes the depth. The OpenCL kernel only
handles float and double, so other depths fall back to the CPU path.
* core: use SIMD and typed templates in 16-bit finiteMask
Use hfloat and bfloat as the template parameter of finiteMask16_ instead
of the raw exponent masks, and add a universal-intrinsics path for 1 to
4 channels.
Add Core_FiniteMask_bits, which checks exact bit patterns at the edges
of the exponent: largest finite, subnormal, signalling, quiet and
negative NaN, and both infinities.
* core: use the scalar loop for 1-channel 16-bit finiteMask
With 1 channel, the compiler vectorizes the scalar loop, and it runs
faster than the explicit SIMD path. Use the SIMD path only for 2 to 4
channels.
* Document transparent border for warpPerspective
* Keep warpPerspective clarification documentation-only
Remove the focused transparent-border test as requested in review. Preserve the documented border behavior and leave the existing image-warp test suite unchanged.
* core: support 1D Mat inputs in gemm
A 1D Mat is a single row, but its step[0] is the element size, not the row size, so gemm passed a too-small row step to the HAL kernels and failed with "_step >= minstep". Give 1D A, B and C an ordinary 2D one-row header before calling the kernels.
Fixes#30703
* core: support preallocated 1D output in gemm
When the caller passes a 1D Mat of the right size as the output, _matD.create() keeps it as is, so D still had step[0] == elemSize() and the kernel failed with "_step >= minstep". Give a 1D D a 2D one-row header too. The result is still written into the caller's buffer.
* core: use TEST_P for the 1D gemm test
* DOC: Update outdated vendor links
* DOC: Update MFX library references
* Fix Qt download link in Windows installation guide
Updated the link for Qt downloads to the archive page.
Port of #30434 to 5.x. Since 4.7.0 the final SOLVEPNP_ITERATIVE
refinement starts from the minimal sample model. For a planar object
this model can be the mirrored pose, and Levenberg-Marquardt stays in
that local minimum. For planar inliers, also refine from the homography
based initialization of SOLVEPNP_ITERATIVE and keep the pose with the
lower reprojection error. Non-planar objects are not affected.
Fixes#27098
Add OPTFLOW_FARNEBACK_REUSE_EXPANSION, an opt-in flag set through
FarnebackOpticalFlow::setFlags() / create(..., flags). When set, calc() keeps
the polynomial expansion of the previous call's next frame and reuses it as
the expansion of the following call's prev frame, which saves roughly 9-14%
on consecutive-frame sequences. Results are bit-identical with reuse on and
off. The flag adds no virtual methods, is ignored by calcOpticalFlowFarneback()
and by the OpenCL path, and clearing it or calling collectGarbage() frees the
cache.
Tests go into test_OF_accuracy.cpp and test_OF_reproducibility.cpp and seed
their data from theRNG(). Includes a perf test and a tutorial section.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
inRange rejects CV_Bool and CV_8F inputs and addWeighted rejects CV_Bool inputs, but the docs did not say so. Also fix type-name typos in core.hpp (CV8S, CV_8S1) and two other spelling mistakes.
* core: add insertChannel and extractChannel test for all depths
insertChannel had no CPU test that checks its values, and extractChannel
was only checked on CV_8UC3. Add a test for every depth with 2 to 4
channels: inserting into one channel must leave the others unchanged,
and extractChannel must return the inserted channel.
* core: use CV_DEPTH_CURR_MAX in insertChannel test
Cover every depth with a range instead of listing them by hand, so new
depths are tested automatically.