-
Notifications
You must be signed in to change notification settings - Fork 625
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FFmpeg with CFFI for faster video decompression #1361
Conversation
Any numbers you can share on how much faster this will be? |
@AbhinavTuli in-memory decompression is around 65 percent faster and close to 40 percent faster for decompression from files. This is average over all file types. The increase will be different for each of them seperately. |
int decompressVideo(unsigned char *file, int size, int ioBufferSize, unsigned char *decompressed, int isBytes, int nbytes) | ||
{ | ||
av_log_set_level(AV_LOG_QUIET); | ||
AVFormatContext *pFormatContext = NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we allocate context once and store it in python object? It seems redundant to me to do it every time. Also prone to memory leak of something goes wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so because we will have a pointer to a pointer and when the underlying object gets freed we will point to garbage.
"pipe:", | ||
] | ||
nbytes = np.prod(shape) | ||
decompressed = ffi.new(f"unsigned char[{nbytes}]") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this always holds ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where it is de-allocated ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It holds for the uint8 videos that we are supporting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deallocation is taken care of by CFFI
Codecov Report
@@ Coverage Diff @@
## main #1361 +/- ##
==========================================
- Coverage 92.09% 91.58% -0.52%
==========================================
Files 178 179 +1
Lines 14311 14397 +86
==========================================
+ Hits 13180 13185 +5
- Misses 1131 1212 +81
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
🚀 🚀 Pull Request
Checklist:
coverage-rate
upChanges
Implement video decompression in C and interface with it using CFFI