ExYUV (ExYUV v0.2.0)
View SourceExYUV
Elixir binding for libyuv.
libyuv is an open source project that includes YUV scaling and conversion functionality.
- Scale YUV to prepare content for compression, with point, bilinear or box filter.
- Convert to YUV from webcam formats for compression.
- Convert to RGB formats for rendering/effects.
- Rotate by 90/180/270 degrees to adjust for mobile devices in portrait mode.
- Optimized for SSSE3/AVX2 on x86/x64.
- Optimized for Neon/SVE2/SME on Arm.
- Optimized for MSA on Mips.
- Optimized for RVV on RISC-V.
Formats
Formats (FOURCC) supported by libyuv are detailed here.
Core Formats
There are 2 core formats supported by libyuv - I420
and ARGB
. All YUV formats can be converted to/from I420
. All RGB
formats can be converted to/from ARGB
.
Filtering functions such as scaling and planar functions work on I420
and/or ARGB
.
Planar Formats
Format | Planes | Description |
---|---|---|
I420 | 3 | Y full resolution. U half width, half height. V half width, half height |
Packed Formats
Format | Bits Per Pixel | Pixel Memory Layout |
---|---|---|
RAW (RGB) | 24 | <<r::8, g::8, b::8>> |
RGB24 | 24 | <<b::8, g::8, r::8>> |
ARGB | 32 | <<b::8, g::8, r::8, a::8>> |
ABGR | 32 | <<r::8, g::8, b::8, a::8>> |
BGRA | 32 | <<a::8, r::8, g::8, b::8>> |
RGBA | 32 | <<a::8, b::8, g::8, r::8>> |
RGB565 | 16 | <<r::5, g::6, b::5>> |
RGB1555 | 16 | <<a::1, r::5, g::6, b::5>> |
RGB4444 | 16 | <<a::4, r::4, g::4, b::4>> |
AR30 | 32 | <<a::2, r::10, g::10, b::10>> |
AB30 | 32 | <<a::2, b::10, g::10, r::10>> |
Installation
The package can be installed by adding ex_yuv
to your list of dependencies in mix.exs
:
def deps do
[
{:ex_yuv, "~> 0.1.0"}
]
end
Summary
Functions
Convert I420 to AB30.
Convert I420 to ABGR.
Convert I420 to AR30.
Convert I420 to ARGB1555.
Convert I420 to ARGB4444.
Convert I420 to ARGB.
Convert I420 to BGRA.
Converts from I420 to RGB24 format.
Convert I420 to BGR24.
Convert I420 to RGB565.
Convert I420 to RGBA.
Converts from RGB24 to I420 format.
Scale ARGB/ABGR/RGBA/BGRA image.
Scale RAW/RGB24 image.
Types
@type argb_16() :: binary()
@type argb_32() :: binary()
@type filter_mode() :: :none | :linear | :bilinear | :box
@type height() :: pos_integer()
@type rgb_16() :: binary()
@type rgb_24() :: binary()
@type u_plane() :: binary()
@type v_plane() :: binary()
@type width() :: pos_integer()
@type y_plane() :: binary()
Functions
Convert I420 to AB30.
The memory layout of the result is <<alpha::2, blue::10, green::10, red::10>>
Convert I420 to ABGR.
The memory layout of the result is <<red::8, green::8, blue::8, alpha::8>>
Convert I420 to AR30.
The memory layout of the result is <<alpha::2, red::10, green::10, blue::10>>
Convert I420 to ARGB1555.
The memory layout of the result is <<alpha::1, red::5, green::5, blue::5>>
Convert I420 to ARGB4444.
The memory layout of the result is <<alpha::4, red::4, green::4, blue::4>>
Convert I420 to ARGB.
The memory layout of the result is <<blue::8, green::8, red::8, alpha::8>>
Convert I420 to BGRA.
The memory layout of the result is <<alpha::8, red::8, green::8, blue::8>>
Converts from I420 to RGB24 format.
The input should be the planes (Y, U and V), in case a binary is provided, it'll try to get the planes from it.
The memory layout of the result is <<red::8, green::8, blue::8>>
Convert I420 to BGR24.
Note
Even when the function name hints that the output format is RGB24, it's
actually BGR24.
We kept the same naming convention used in libyuv
.
Convert I420 to RGB565.
The memory layout of the result is <<red::5, green::6, blue::5>>
Convert I420 to RGBA.
The memory layout of the result is <<alpha::8, blue::8, green::8, red::8>>
@spec raw_to_i420!(rgb_24(), width(), height()) :: yuv_planes()
Converts from RGB24 to I420 format.
Scale ARGB/ABGR/RGBA/BGRA image.
The following filters are supported: none
, linear
, bilinear
, and box
.
Check libyuv documentation for more details.
@spec scale_i420!(i420_data(), width(), height(), width(), height(), filter_mode()) :: yuv_planes()
Scale I420 image.
The following filters are supported: none
, linear
, bilinear
, and box
.
Check libyuv documentation for more details.
Scale RAW/RGB24 image.
The following filters are supported: none
, linear
, bilinear
, and box
.
Check libyuv documentation for more details.