This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit d241c80e59e26eac47d448f54bc3629b75b89f34 Author: Niklas Haas <[email protected]> AuthorDate: Sat Aug 29 15:51:17 2026 +0200 Commit: Niklas Haas <[email protected]> CommitDate: Tue Sep 1 13:15:06 2026 +0200 avfilter/x86/vf_colordetect: avoid calling C code for tail handling Instead, we can just call the SIMD function a second time. This will reprocess a few overlapping pixels, but that is safe since this function is read-only and idempotent. We only need to bail to the C function if the overall width is smaller than a single SIMD vector. checkasm: - CPU: AMD Ryzen 9 9950X3D 16-Core Processor (00B40F40) - Timing source: x86 (rdtsc) - Bench duration: 100000 µs per function (462406519 cycles) - Random seed: 555761032 Benchmark results: name cycles (vs ref) detect_alpha_8_full_c: 7884.5 detect_alpha_8_full_avx2: 439.9 (17.88x) detect_alpha_8_full_avx512icl: 262.8 (30.00x) detect_alpha_8_full_off_c: 7884.0 detect_alpha_8_full_off_avx2: 456.3 (17.27x) detect_alpha_8_full_off_avx512icl: 267.3 (29.49x) detect_alpha_8_limited_c: 13452.5 detect_alpha_8_limited_avx2: 1163.5 (11.56x) detect_alpha_8_limited_avx512icl: 650.9 (20.67x) detect_alpha_16_full_c: 3696.1 detect_alpha_16_full_avx2: 426.4 ( 8.67x) detect_alpha_16_full_avx512icl: 262.6 (14.07x) detect_alpha_16_full_off_c: 3698.7 detect_alpha_16_full_off_avx2: 454.7 ( 8.13x) detect_alpha_16_full_off_avx512icl: 267.1 (13.85x) detect_alpha_16_limited_c: 8215.9 detect_alpha_16_limited_avx2: 1288.4 ( 6.38x) detect_alpha_16_limited_avx512icl: 691.3 (11.88x) detect_range_8_c: 1411.0 detect_range_8_avx2: 281.6 ( 5.01x) detect_range_8_avx512icl: 168.7 ( 8.36x) detect_range_16_c: 1334.4 detect_range_16_avx2: 228.6 ( 5.83x) detect_range_16_avx512icl: 139.7 ( 9.50x) Sponsored-by: nxtedition AB Signed-off-by: Niklas Haas <[email protected]> --- libavfilter/x86/vf_colordetect_init.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/libavfilter/x86/vf_colordetect_init.c b/libavfilter/x86/vf_colordetect_init.c index d763cfa800..7c39892700 100644 --- a/libavfilter/x86/vf_colordetect_init.c +++ b/libavfilter/x86/vf_colordetect_init.c @@ -29,13 +29,18 @@ int ASM_FUNC_NAME(const uint8_t *src, ptrdiff_t stride, static int FUNC_NAME(const uint8_t *src, ptrdiff_t stride, \ ptrdiff_t width, ptrdiff_t height, int min, int max) \ { \ - ptrdiff_t bytes = (width << SHIFT) & ~(MMSIZE - 1); \ - int ret = ASM_FUNC_NAME(src, stride, bytes, height, min, max); \ - if (ret == FF_ALPHA_STRAIGHT) \ + ptrdiff_t total = width << SHIFT; \ + ptrdiff_t bytes = total & ~(MMSIZE - 1); \ + int ret; \ + if (!bytes) \ + return C_FUNC_NAME(src, stride, width, height, min, max); \ + \ + ret = ASM_FUNC_NAME(src, stride, bytes, height, min, max); \ + if (ret || bytes == total) \ return ret; \ \ - return ret | C_FUNC_NAME(src + bytes, stride, width - (bytes >> SHIFT), \ - height, min, max); \ + return ret | ASM_FUNC_NAME(src + total - MMSIZE, stride, MMSIZE, \ + height, min, max); \ } #define DETECT_ALPHA_FUNC(FUNC_NAME, ASM_FUNC_NAME, C_FUNC_NAME, SHIFT, MMSIZE) \ @@ -47,15 +52,21 @@ static int FUNC_NAME(const uint8_t *color, ptrdiff_t color_stride, const uint8_t *alpha, ptrdiff_t alpha_stride, \ ptrdiff_t width, ptrdiff_t height, int p, int q, int k) \ { \ - ptrdiff_t bytes = (width << SHIFT) & ~(MMSIZE - 1); \ - int ret = ASM_FUNC_NAME(color, color_stride, alpha, alpha_stride, \ - bytes, height, p, q, k); \ - if (ret == FF_ALPHA_STRAIGHT) \ + ptrdiff_t total = width << SHIFT; \ + ptrdiff_t bytes = total & ~(MMSIZE - 1); \ + int ret; \ + if (!bytes) \ + return C_FUNC_NAME(color, color_stride, alpha, alpha_stride, \ + width, height, p, q, k); \ + \ + ret = ASM_FUNC_NAME(color, color_stride, alpha, alpha_stride, \ + bytes, height, p, q, k); \ + if (ret == FF_ALPHA_STRAIGHT || bytes == total) \ return ret; \ \ - return ret | C_FUNC_NAME(color + bytes, color_stride, alpha + bytes, \ - alpha_stride, width - (bytes >> SHIFT), height, \ - p, q, k); \ + return ret | ASM_FUNC_NAME(color + total - MMSIZE, color_stride, \ + alpha + total - MMSIZE, alpha_stride, \ + MMSIZE, height, p, q, k); \ } #if HAVE_AVX512ICL_EXTERNAL -- To stop receiving notification emails like this one, please contact [email protected]. _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
