/*
 * Copyright (c) 2026-present, the Ladybird developers.
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

/* Generated with cbindgen:0.29.2 */

#include <stdint.h>
#include <stddef.h>

namespace Gfx {
namespace FFI {

enum class YUVRange : uint8_t {
    Limited = 0,
    Full = 1,
};

enum class YUVMatrix : uint8_t {
    Bt709 = 0,
    Fcc = 1,
    Bt470BG = 2,
    Bt601 = 3,
    Smpte240 = 4,
    Bt2020 = 5,
};

extern "C" {

extern uint8_t *ladybird_rust_alloc(size_t size, size_t alignment);

extern uint8_t *ladybird_rust_alloc_zeroed(size_t size, size_t alignment);

extern void ladybird_rust_dealloc(uint8_t *ptr, size_t alignment);

extern uint8_t *ladybird_rust_realloc(uint8_t *ptr, size_t old_size, size_t new_size, size_t alignment);

/// # Safety
/// All plane pointers must be valid for the specified dimensions and strides.
/// `dst` must point to a buffer of at least `dst_stride * height` bytes.
bool yuv_u8_to_rgba(const uint8_t *y_plane,
                    uint32_t y_stride,
                    const uint8_t *u_plane,
                    uint32_t u_stride,
                    const uint8_t *v_plane,
                    uint32_t v_stride,
                    uint32_t width,
                    uint32_t height,
                    bool subsampling_x,
                    bool subsampling_y,
                    uint8_t *dst,
                    uint32_t dst_stride,
                    YUVRange range,
                    YUVMatrix matrix);

/// # Safety
/// All plane pointers must be valid for the specified dimensions and strides.
/// `dst` must point to a buffer of at least `dst_stride * height` bytes.
/// Values in the u16 planes must be in 0-1023 range for 10-bit or 0-4095 for 12-bit.
bool yuv_u16_to_rgba(const uint16_t *y_plane,
                     uint32_t y_stride,
                     const uint16_t *u_plane,
                     uint32_t u_stride,
                     const uint16_t *v_plane,
                     uint32_t v_stride,
                     uint32_t width,
                     uint32_t height,
                     uint8_t bit_depth,
                     bool subsampling_x,
                     bool subsampling_y,
                     uint8_t *dst,
                     uint32_t dst_stride,
                     YUVRange range,
                     YUVMatrix matrix);

}  // extern "C"

}  // namespace FFI
}  // namespace Gfx
