A JPEG XL decoder in pure MoonBit, ported from jxl-oxide
| channel | peak error | RMS |
|---|---|---|
| R | 1.656e-4 | 2.82e-5 |
| G | 1.633e-4 | 2.22e-5 |
| B | 1.646e-4 | 2.22e-5 |
| alpha | 0 | 0 |
pub(all) enum AuxBoxData[T] {
Data(T)
Decoding
NotFound
}pub struct AuxBoxList {
// private fields
}pub struct AuxBoxReader {
// private fields
}pub(all) enum DecodedSamples {
U8(FixedArray[Byte])
U16(FixedArray[Int])
F32(FixedArray[Float])
}pub struct ExtraChannel {
// private fields
}pub struct FrameBuffer {
// private fields
}fn FrameBuffer::from_grids(grids : ArrayView[ImageBuffer], bit_depth : ArrayView[BitDepth], grid_regions : ArrayView[Region], copy_region : Region, orientation : Int) -> FrameBufferpub struct ImageStream {
// private fields
}fn ImageStream::write_to_buffer_f32(self : ImageStream, buf : FixedArray[Float], start? : Int) -> Intpub struct JxlDecoder {
// private fields
}fn JxlDecoder::read_rect(self : JxlDecoder, x : Int, y : Int, width : Int, height : Int) -> DecodedSamples raise JxlErrorpub struct JxlImage {
// private fields
}pub struct JxlImageBuilder {
// private fields
}fn JxlImageBuilder::alloc_tracker(self : JxlImageBuilder, tracker : AllocTracker) -> JxlImageBuilderfn JxlImageBuilder::force_wide_buffers(self : JxlImageBuilder, force_wide_buffers : Bool) -> JxlImageBuilderpub struct RawExif {
// private fields
}pub struct Render {
// private fields
}pub struct UninitializedJxlImage {
// private fields
}let mut uninit_image = JxlImage::builder().build_uninit()
let image = for {
let buf = read_bytes()
uninit_image.feed_bytes(buf) |> ignore
match uninit_image.try_init() {
NeedMoreData(uninit) => uninit_image = uninit
Initialized(image) => break image
}
}fn UninitializedJxlImage::feed_bytes(self : UninitializedJxlImage, buf : BytesView) -> Int raise JxlErrorfn decode_jxl(b : Bytes) -> (Int, Int, FixedArray[Byte])?fn is_jxl(b : Bytes) -> Boolfn jxl_size(b : Bytes) -> (Int, Int)?fn sample_f32_to_u16(val : Float) -> Intfn sample_f32_to_u8(val : Float) -> Int