ralfbiedert / openh264-rs

Idiomatic Rust wrappers around OpenH264.
66 stars 32 forks source link

Use rayon to speed up yuv to rgb conversion. #27

Closed Mivik closed 1 year ago

Mivik commented 1 year ago

An optional feature rayon is added to enable the use of rayon to speed up yuv to rgb conversion (line by line). On my Laptop (i7-12700H) this improves the decoding frame rate of a 720x1080 video from around 200 fps to 260 fps.

ralfbiedert commented 1 year ago

Thanks for the PR.

I'm a bit hesitant adding Rayon, which is a great "application library", but a bit heavyweight to just parallelize that decoding in our lib. I think scoped threads + available_parallelism would do the job as well and wouldn't even need a feature flag being part of STD.

Would switching out Rayon work for you?

In any case, I think the single- vs multi-threaded methods shouldn't be hidden behind a feature flag, but there should be explicit write_rgbx8() and write_rgbx8_par() methods or so (the cleanup you started with that PR might come in handy there; in the long run, once portable_simd is stable, the entire decoding should probably be refactored to use SIMD anyway).

ralfbiedert commented 1 year ago

Closing due to inactivity. Feel free to reopen if comments are addressed.