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

Code before:
            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 {};

    // Initially, nb_meta_channels is set to zero, but transformations can modify this value.
    u32 nb_meta_channels {};

    Vector<Channel> channels {};

    ErrorOr<void> create_channels(Span<IntSize> frame_size)
    {
        Vector<IntSize> channel_infos {};
        TRY(channel_infos.try_extend(frame_size));

        for (auto const& tr : transform) {
            if (tr.tr == TransformInfo::TransformId::kPalette) {
                auto original_dimensions = channel_infos[tr.begin_c];
                channel_infos.remove(tr.begin_c, tr.num_c);
                TRY(channel_infos.try_insert(tr.begin_c, original_dimensions));
                TRY(channel_infos.try_prepend({ tr.nb_colours, tr.num_c }));

                if (tr.begin_c < nb_meta_channels)
                    nb_meta_channels += 2 - tr.begin_c;
                else
                    nb_meta_channels += 1;
            }
        }

        TRY(channels.try_resize(channel_infos.size()));
        for (u32 i = 0; i < channels.size(); ++i)

Review comment (suggestion):
Is "nb" short for "number of"? If so: `number_of_meta_channels` or `meta_channel_count` or something like that.

Code after:
        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 {};

    // Initially, nb_meta_channels is set to zero, but transformations can modify this value.
    u32 nb_meta_channels {};

    Vector<Channel> channels {};

    ErrorOr<void> create_channels(Span<IntSize> frame_size)
    {
        Vector<IntSize> channel_infos {};
        TRY(channel_infos.try_extend(frame_size));

        for (auto const& tr : transform) {
            if (tr.tr == TransformInfo::TransformId::kPalette) {
                // Let end_c = begin_c + num_c − 1. When updating the channel list as described in H.2, channels begin_c to end_c,
                // which all have the same dimensions, are replaced with two new channels:
                //  - one meta-channel, inserted at the beginning of the channel list and has dimensions width = nb_colours and height = num_c and hshift = vshift = −1.
                //    This channel represents the colours or deltas of the palette.
                //  - one channel (at the same position in the channel list as the original channels, same dimensions) which contains palette indices.

                auto original_dimensions = channel_infos[tr.begin_c];
                channel_infos.remove(tr.begin_c, tr.num_c);
                TRY(channel_infos.try_insert(tr.begin_c, original_dimensions));
                TRY(channel_infos.try_prepend({ tr.nb_colours, tr.num_c }));

                if (tr.begin_c < nb_meta_channels)
                    nb_meta_channels += 2 - tr.begin_c;
                else
                    nb_meta_channels += 1;