nvpro-samples / vk_video_samples

Vulkan video samples
Apache License 2.0
237 stars 40 forks source link

Consider using boyer-more algorithm to optimize start code scanning #36

Open ndufresne opened 1 year ago

ndufresne commented 1 year ago

In https://github.com/nvpro-samples/vk_video_samples/blob/ff6ef40e25da75604eb550299b93c9671aac0b40/vk_video_decoder/libs/NvVideoParser/src/VulkanVideoDecoder.cpp#L266 it seems the scanner will read every bytes of the stream. This is commonly optimized with a reduce Boyer-More algorithm, allowing to read only a third of the bytes.

An example can be found here: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/blob/main/subprojects/gstreamer/libs/gst/base/gstbytereader.c#L865 which has been reduced from https://en.wikipedia.org/wiki/Boyer%E2%80%93Moore_string-search_algorithm

zlatinski commented 1 year ago

Thank you for bringing this parser performance issue to our attention, Nicolas. We are already aware of this issue and have an internal task (not started yet) to address it. We would also gladly take code contributions to the parser :).