Skip to content

Bug: Typo in MSE::operator== ignores the alpha channel in comparisons #665

Description

@for13to1

Describe the bug

There is a typo in the equality operator operator== of the MSE struct in ConversionDifferenceRGB.h.
Specifically, a (the alpha component of this) is tie-compared to itself a on the right-hand side, instead of other.a. This causes any difference in the alpha channel's MSE to be completely ignored during comparison.

  bool operator==(const MSE &other) const
  {
    return std::tie(r, g, b, a) == std::tie(other.r, other.g, other.b, a); // typo: comparing 'a' to 'a'
  }

To Reproduce

This typo resides in the static analysis of the equality check. It is also reproducible when writing a unit test that compares two MSE structs with different a values but identical r, g, and b values. The comparison will incorrectly evaluate to true.

Expected behavior

operator== should compare other.a to correctly assert equality across all four color/alpha channels:

  bool operator==(const MSE &other) const
  {
    return std::tie(r, g, b, a) == std::tie(other.r, other.g, other.b, other.a);
  }

Version

  • OS: macOS
  • Version: develop branch (including commit b5b1b6e)
  • If you compiled YUView yourself then which Qt version did you use? Qt 6.x

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions