Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Refactor video hashing. The combined class of hashing and decoding frames was complicated and difficult to understand. This PR splits it up into smaller classes, which also allows different frame types to be used in the future with minimal changes.
Moved some FFmpeg custom types into separate files for better readability.
Hashing is split into two new classes:
VpdqHasher
andFFmpegHasher
.VpdqHasher
takes care of all hashing operations and just runs the generic hashing algorithm as frames are added.VpdqHasher
as opposed to an abstract class with derived frame types to avoid needing to dynamically allocate every frame. A generic frame is added that works without FFmpeg as an example, but is not used for anything currently. Using the direct FFmpeg data pointer is significantly faster than copying the data into the generic frame buffer.FFmpegHasher
that feeds FFmpeg frames to theVpdqHasher
.Changed
FFmpegHasher::processPacket
to take in the data by reference instead of the full unique_ptr.Minor change to
matchTwoHashBrute
to pass data byconst&
instead of copying for better performance.I did not notice a performance impact from these changes across multiple runs of regtest.
No public API changes other than
matchTwoHashBrute
.Most of these changes are just moving common functions into grouped common modules. No major logic or anything is rewritten. I would try to split up this PR but most of it is easier to understand in the context of the full changes.
Test Plan
regtest passes successfully.