-
Notifications
You must be signed in to change notification settings - Fork 369
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
Create fast path for returning YUVPlanes to numpy arrays #1393
Conversation
Thank you for considering. |
The problem with this patch is that when the fast path is used, it disrupts the structure of the underlying pixel format. Any code that relies on that behavior is going to break. This was discussed in #788 |
Yes. I remember now. Ultimately this function doesn't give that guarantee. It al4eady changes between a view and a copy. Would you consider the addition of a keyword argument to specify the users intention? |
Any libraries that uses on What is the point of |
The data "format" hasn't changed. What has changed is the fact that
so rgb24 and gray formats are returning views. I presume it was because it was easier to guarantee correctness then. I'm asking here that
This should still work. I can add a test for this usecase.
I utilize the well defined layout of the YUV420 format in FFMPEG to avoid the memory copy. For a 8x4 array of pixels, YUV420 and YUV420J would store:
From wikipedia: https://en.wikipedia.org/wiki/Chroma_subsampling So the "fastpath" checks that the memory is all contiguous, and simply returns a pointer to the underlying data from the FFMPEG Avoiding this copy is pretty important since for 4k (or 8k! which I am interested in) video decoding:
per frame. Copying this around unnecessarily creates REAL problems with your CPU cache and just slows things down alot. As for my usecase, it revolves around 4k and 8k video encoding / decoding. And as such benefits from what appears to be micro optimizations. I can add a test if you want, but generally speaking, I remember that without my check, something already failed. I recall it being due to some odd image shape in the testing suite which was interesting to learn about. |
This comment was marked as off-topic.
This comment was marked as off-topic.
This is really strange.... I find on place where you use the "naked" but nothing jumps to me as getting mutated. (In fact you could save yourself some time by doing I would love to recreate that screenshot to see what might be going on? I have a feeling that maybe I'm not adding enough safeguards on the fastpath. Can you teach me how you got to your screenshot? |
The other place is https://github.com/WyattBlue/auto-editor/blob/8f11ab54fade4fa5ab4cd7cb43ae54a4212dbff3/auto_editor/render/video.py#L370 but also seems "safe" |
I suspect the reason that I don't see this bug it is because you are making use of elaborate filters and using filter graphs which is not what workflow i go through. I added two checks for data continuity:
I think they should resolve things, but I need to check that it is still "correct" in the sense that the fast path is still triggered. |
I need to recheck my buffer continuity check, it doesn't seem to be triggering "true" on what I thought it should. |
Hmmm, it seems that the array isn't guaranteed to be contiguous, even in the "nice" cases
how is any of my code working..... |
it seems that maybe the function i'm looking for is: |
Thank you for your thoroughness in testing! |
No description provided.