Skip to content

perf(rtp): find H.264 start codes with memchr::memmem - #336

Open
g4lb wants to merge 1 commit into
webrtc-rs:masterfrom
g4lb:h264-start-code-memmem
Open

g4lb wants to merge 1 commit into
webrtc-rs:masterfrom
g4lb:h264-start-code-memmem

Conversation

@g4lb

@g4lb g4lb commented Nov 20, 2026

Copy link
Copy Markdown

H264Payloader checked each byte to find the next start code. Now it finds 00 00 01 with memchr::memmem, as H265Packet::parse does. The payloads do not change.

H264Payloader::payload, MTU 1200 Before After Change
30 KB IDR frame 8.44 µs 1.59 µs -81.2%
SPS, PPS and a 100 B slice 67.5 ns 60.9 ns -9.8%

A frame of 1000 NAL units of 5 bytes was 5% to 8% slower, but not significant. I used 12 interleaved rounds of criterion (Apple M5, rustc 1.98.0).

Old and new output matched on 1M random inputs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant