Repository: SerenityOS/serenity
File: Userland/Libraries/LibGfx/ImageFormats/JPEGXLLoader.cpp (C++)

Code before:
        case Direction::NorthEast:
            return x + 1 >= m_current_row.size() ? north() : m_current_row[x + 1];
        case Direction::West:
            return x < 1 ? Predictions {} : m_next_row[x - 1];
        case Direction::NorthNorth:
            return m_current_row_index < 2 ? Predictions {} : m_previous[x];
        case Direction::WestWest:
            return x < 2 ? Predictions {} : m_next_row[x - 2];
        }
        VERIFY_NOT_REACHED();
    }

    WPHeader const& wp_params {};

    u32 m_width {};
    u32 m_current_row_index {};

    FixedArray<Predictions> m_previous {};
    FixedArray<Predictions> m_current_row {};

    FixedArray<Predictions> m_next_row {};
};
///

/// H.2 - Image decoding
struct ModularData {
    bool use_global_tree {};
    WPHeader wp_params {};
    Vector<TransformInfo> transform {};
};

static constexpr u32 nb_base_predictors = 16;

static void get_properties(FixedArray<i32>& properties, Vector<Channel> const& channels, u16 i, u32 x, u32 y, i32 max_error)
{
    // Table H.4 - Property definitions
    properties[0] = i;
    // FIXME: Handle other cases than GlobalModular
    properties[1] = 0;
    properties[2] = y;
    properties[3] = x;

    i32 const W = x > 0 ? channels[i].get(x - 1, y) : (y > 0 ? channels[i].get(x, y - 1) : 0);
    i32 const N = y > 0 ? channels[i].get(x, y - 1) : W;
    i32 const NW = x > 0 && y > 0 ? channels[i].get(x - 1, y - 1) : W;
    i32 const NE = x + 1 < channels[i].width() && y > 0 ? channels[i].get(x + 1, y - 1) : N;
    i32 const NN = y > 1 ? channels[i].get(x, y - 2) : N;
    i32 const WW = x > 1 ? channels[i].get(x - 2, y) : W;

    properties[4] = abs(N);
    properties[5] = abs(W);

Review comment (suggestion):
Commit description: "so let's rename also rename it." has too many verbs.

(Sorry about missing this this morning.)

Code after:
        case Direction::NorthEast:
            return x + 1 >= m_current_row.size() ? north() : m_current_row[x + 1];
        case Direction::West:
            return x < 1 ? Predictions {} : m_next_row[x - 1];
        case Direction::NorthNorth:
            return m_current_row_index < 2 ? Predictions {} : m_previous[x];
        case Direction::WestWest:
            return x < 2 ? Predictions {} : m_next_row[x - 2];
        }
        VERIFY_NOT_REACHED();
    }

    WPHeader const& wp_params {};

    u32 m_width {};
    u32 m_current_row_index {};

    FixedArray<Predictions> m_previous {};
    FixedArray<Predictions> m_current_row {};

    FixedArray<Predictions> m_next_row {};
};
///

/// H.2 - Image decoding
struct ModularData {
    bool use_global_tree {};
    WPHeader wp_params {};
    Vector<TransformInfo> transform {};
    Vector<Channel> channels {};

    ErrorOr<void> create_channels(Span<IntSize> frame_size)
    {
        TRY(channels.try_resize(frame_size.size()));
        for (u32 i = 0; i < channels.size(); ++i)
            channels[i] = TRY(Channel::create(frame_size[i].width(), frame_size[i].height()));

        return {};
    }
};

static constexpr u32 nb_base_predictors = 16;

static void get_properties(FixedArray<i32>& properties, Span<Channel> channels, u16 i, u32 x, u32 y, i32 max_error)
{
    // Table H.4 - Property definitions
    properties[0] = i;
    // FIXME: Handle other cases than GlobalModular
    properties[1] = 0;
    properties[2] = y;
    properties[3] = x;