Repository navigation
Conversation
… NEON On x86_64 and every other target without NEON, the accelerated converter fell back to the scalar one. It now walks the image two rows at a time: the chroma of a 2x2 block is computed once, rows are sliced up front so the loops carry no bounds checks, and Y is summed in 16 bit lanes (a const assertion checks every matrix fits). On x86_64 the same code is also compiled for AVX2 and picked at runtime. Odd sizes keep the scalar path. The output is bit for bit the scalar converter's. The NEON tests now run on every target as yuv_accelerated_*, a new test covers odd sizes, padded line sizes and both matrices, and the benchmark measures the accelerated converter on every architecture. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Problem
On x86_64 (and every target without NEON),
fill_yuv420_from_rgba_pixmap_acceleratedfalls back to the scalar converter, which tests every pixel for even coordinates and indexes with bounds checks. Rendering short motion-graphics cards with the Skia CPU renderer on an AMD EPYC server,perfput 26% of the whole process (Skia rasterization and libx264 included) infill_yuv420_from_rgba_pixmap_base.Solution
An accelerated converter for targets without NEON that walks the image two rows at a time:
i32.LLVM vectorizes the loops. On x86_64 the same code is also compiled for AVX2 and picked at runtime with
is_x86_feature_detected!. Odd widths and heights take the scalar path. The output is bit for bit identical tofill_yuv420_from_rgba_pixmap_base(same chroma sample, same flooring). NEON targets are untouched.Before / after
cargo bench -p fframes --bench yuv420_conversion -- 1920x1080on an AMD EPYC 9354P:YUV420 ConversionWithout AVX2 (x86_64 baseline, SSE2) the same code measured ~3.0 ms in a standalone bench.
End to end, on a batch of 53 real cards (Skia CPU renderer, libx264 veryfast, 1 thread) with the same change applied to our fork: CPU time 407 s → 309 s (−24%), wall time 265 s → 192 s, and all 50 rendered MP4s byte-identical to before.
Tests
yuv_neon_*tests now run on every target asyuv_accelerated_*.yuv_accelerated_matches_base_on_any_size: odd sizes, padded line sizes, both matrices, random 1920×1080.cargo test -p fframes --lib yuv: 7 passed.cargo clippy -p fframes --all-targets -- -D warnings: clean.cargo fmt --check: clean.🤖 Generated with Claude Code
Summary by CodeRabbit