This compares a line-by-line C# port of VLC’s Gaussian blur filter to the original C implementation and measures why and how much they differ. The blur is separable (horizontal then vertical), VLC’s original uses integer arithmetic and two-pass buffering, and the C# version is compiled with .NET Native AOT so it runs as a native VLC plugin and produces byte-identical frames on the same 1080p test clip on an 11th‑gen Core i7. The initial unoptimized C# port ran about 23% slower per frame than C; profiling showed the difference came from code generation (RyuJIT emitted more instructions, re-evaluating loop bounds and keeping sums in memory) rather than garbage collection or bounds checks.
Targeted changes and SIMD tuning closed almost all of that gap. Simple edits (precompute loop bounds, use nint) brought the line-by-line port within 8% of C, and further vectorized rewrites produced near-parity SIMD builds: tuned C ran ~3.05-6.62 ms/frame and tuned C# ~3.05-7.22 ms/frame, yielding about 240 vs 236 fps at sigma 4. The experiment shows C# is a realistic CPU-side choice when optimized against the JIT’s quirks, but C retains the final edge for the last 10% of performance. The work also exposed two VLC bugs and the filter is available in VLCLR.Filters for further testing.
Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.