Skip to content

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

@YorVeX

Description

@YorVeX

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions