Skip to content
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

Wrong array index for zero diff comparison (minor issue) #1

Open
YorVeX opened this issue Aug 9, 2023 · 1 comment
Open

Wrong array index for zero diff comparison (minor issue) #1

YorVeX opened this issue Aug 9, 2023 · 1 comment

Comments

@YorVeX
Copy link

YorVeX commented Aug 9, 2023

The comparison whether a pixel matches the previous one checks px_diff.y[4] for 0, but that field doesn't exist:

qoy/qoy.h

Line 932 in fd9f9ea

if (px_diff.y[0] == 0 && px_diff.y[1] == 0 && px_diff.y[2] == 0 && px_diff.y[3] == 0 && px_diff.y[4] == 0 && px_diff.cb == 0 && px_diff.cr == 0) {

Probably never causing any harm, because that should also be another field within the same struct that we also want to be 0 anyway for this case, but I still thought I'd report it when I already stumbled upon it. When porting this to a C# class I actually copied the same mistake over and there it worked fine just the same 😄

I only noticed when I optimized this specific part by checking all the diff bytes interpreted as one 64 bit value instead of checking each byte separately for 0 - this resulted in a measurable speed-up in C#, but I got no idea whether it would be the same in C++ with various compilers.

@YorVeX
Copy link
Author

YorVeX commented Aug 9, 2023

Reporting this here also gives me the chance to say: thanks for your work, very much appreciated! I use it for my plugin to compress video frames (yes, you read that right) when transferring them from one instance of OBS Studio (a compositing software for live streaming and recording) to another over network or named pipes. QOI has already been an option for a while, as well as QOIR through a dynamic C++ library (couldn't be bothered to port this over to C# yet, it's a lot more code than QOI and QOY), but using RGBA in OBS is not ideal and I was missing something similar for the OBS default NV12. QOY came to the rescue! 🦸

The port is here if you're curious. It's not a 1:1 port but rather limited, I removed some features I didn't need like color conversions and alpha support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant