Crate ezk_image

Crate ezk_image 

Source
Expand description

§EZK Image

ezk-image is a crate to perform conversion between common pixel formats and color spaces.

It uses SIMD and multi threading to accelerate the conversion when available, though multi-threading must be explicitly called with convert_multi_thread.

Any format can be converted to any other format.


§Supported Pixel formats

Bit depth of up to 16 bit per component is supported.

  • I420
  • I422
  • I444
  • I010, I012
  • I210, I212
  • I410, I412
  • NV12
  • YUYV
  • RGBA, BGRA
  • RGB, BGR

§Supported Color Primaries (color gamut)

  • SMTPE ST 240
  • BT.709 (SDR)
  • BT.2020 (HDR)

§Supported Color Transfer Functions (opto-electronic transfer characteristics of samples)

  • Linear
  • Gamma of 2.2 and 2.8
  • SRGB
  • SDR (BT.601, BT.709 and BT.2020)
  • BT.2100 perceptual quantization (PQ)
  • BT.2100 hybrid log-gamma (HLG)

§Supported Color Spaces

  • RGB
  • YUV BT.601
  • YUV BT.709
  • YUV BT.2020
  • ICtCp with perceptual quantization (PQ)
  • ICtCp with hybrid log-gamma (HLG)

§Example

use ezk_image::*;

let (width, height) = (1920, 1080);

// Our source image, an RGB buffer
let rgb_image = vec![0u8; PixelFormat::RGB.buffer_size(width, height)];

// Create the image we're converting from
let source = Image::from_buffer(
    PixelFormat::RGB,
    &rgb_image[..], // RGB only has one plane
    None, // No need to define strides if there's no padding between rows
    width,
    height,
    ColorInfo::RGB(RgbColorInfo {
        transfer: ColorTransfer::Linear,
        primaries: ColorPrimaries::BT709,
    }),
).unwrap();

// Create the image buffer we're converting to
let mut destination = Image::blank(
    PixelFormat::NV12, // We're converting to NV12
    width,
    height,
    ColorInfo::YUV(YuvColorInfo {
        space: ColorSpace::BT709,
        transfer: ColorTransfer::Linear,
        primaries: ColorPrimaries::BT709,
        full_range: false,
    }),
);

// Now convert the image data
convert_multi_thread(
    &source,
    &mut destination,
).unwrap();

Modules§

resize

Structs§

Cropped
Wrapper around ImageRef/ImageMut and a Window cropping the wrapped image
Image
Basic wrapper around any image, implementing the ImageRef and ImageMut trait
InvalidNumberOfPlanesError
RgbColorInfo
Window
Rect used to mark the “cropping” window
YuvColorInfo

Enums§

BoundsCheckError
BufferKind
ColorInfo
Color space of an image
ColorPrimaries
Color gamut of an image
ColorSpace
Color space used for RGB to YUV conversion
ColorTransfer
Image opto-electronic transfer characteristics
ConvertError
Errors that may occur when trying to convert an image
CropError
Error indicating an invalid Window for a given image
ImageError
Everything that can go wrong when constructing an Image
PixelFormat
Supported pixel formats

Traits§

AnySlice
Helper trait implemented on &[T] and &mut [T]
ImageMut
Safety
ImageRef
Safety
ImageRefExt
ImageRef extension methods

Functions§

convert
Convert pixel-format and color from the src-image to the specified dst-image.
convert_multi_thread
Parallelizes convert using as many threads as there are CPU cores.
infer
Infer the planes for an image in the given format using the given dimensions and strides
infer_i01x
Infer the planes for a full I010 or I012 image using the given dimensions
infer_i21x
Infer the planes for a full I210 or I212 image using the given dimensions
infer_i41x
Infer the planes for a full I410 or I412 image using the given dimensions
infer_i420
Infer the planes for a full I420 image using the given dimensions
infer_i422
Infer the planes for a full I422 image using the given dimensions
infer_i444
Infer the planes for a full I444 image using the given dimensions
infer_nv12
Infer the planes for a full NV12 image using the given dimensions
infer_p01x
Infer the planes for a full P010 / P012 image using the given dimensions