Simple Graphics Library 1.0.0.0
Runtime-independent image processing primitives
Loading...
Searching...
No Matches
Pixel-format conversion

Conversion between the RGB and YUV formats in sgl-fourcc.h. More...

Functions

sgl_result_t sgl_generic_rgb2yuv (sgl_threadpool_t *pool, const sgl_uint8_t *src, sgl_fourcc_t src_format, sgl_uint8_t *dst, sgl_fourcc_t dst_format, sgl_int32_t width, sgl_int32_t height)
 Converts any supported RGB layout to any supported YUV layout.
 
sgl_result_t sgl_generic_rgb2rgb (sgl_threadpool_t *pool, const sgl_uint8_t *src, sgl_fourcc_t src_format, sgl_uint8_t *dst, sgl_fourcc_t dst_format, sgl_int32_t width, sgl_int32_t height)
 Converts between any two supported RGB layouts.
 
sgl_result_t sgl_generic_yuv2rgb (sgl_threadpool_t *pool, const sgl_uint8_t *src, sgl_fourcc_t src_format, sgl_uint8_t *dst, sgl_fourcc_t dst_format, sgl_int32_t width, sgl_int32_t height)
 Converts any supported YUV layout to any supported RGB layout.
 
sgl_result_t sgl_generic_yuv2yuv (sgl_threadpool_t *pool, const sgl_uint8_t *src, sgl_fourcc_t src_format, sgl_uint8_t *dst, sgl_fourcc_t dst_format, sgl_int32_t width, sgl_int32_t height)
 Converts between any two supported YUV layouts.
 
sgl_result_t sgl_simd_rgb2yuv (sgl_threadpool_t *pool, const sgl_uint8_t *src, sgl_fourcc_t src_format, sgl_uint8_t *dst, sgl_fourcc_t dst_format, sgl_int32_t width, sgl_int32_t height)
 SIMD RGB-to-YUV conversion.
 
sgl_result_t sgl_simd_rgb2rgb (sgl_threadpool_t *pool, const sgl_uint8_t *src, sgl_fourcc_t src_format, sgl_uint8_t *dst, sgl_fourcc_t dst_format, sgl_int32_t width, sgl_int32_t height)
 SIMD RGB-to-RGB conversion.
 
sgl_result_t sgl_simd_yuv2rgb (sgl_threadpool_t *pool, const sgl_uint8_t *src, sgl_fourcc_t src_format, sgl_uint8_t *dst, sgl_fourcc_t dst_format, sgl_int32_t width, sgl_int32_t height)
 SIMD YUV-to-RGB conversion.
 
sgl_result_t sgl_simd_yuv2yuv (sgl_threadpool_t *pool, const sgl_uint8_t *src, sgl_fourcc_t src_format, sgl_uint8_t *dst, sgl_fourcc_t dst_format, sgl_int32_t width, sgl_int32_t height)
 SIMD YUV-to-YUV conversion.
 

Detailed Description

Conversion between the RGB and YUV formats in sgl-fourcc.h.

Buffers are tightly packed according to their FourCC layout and support odd image dimensions by rounding chroma dimensions upward. RGB/YUV conversion uses fixed-point color equations. Alpha is preserved between alpha-bearing RGB formats, synthesized as 255 when absent, and discarded by YUV formats. A SGL_NULL pool selects single-thread execution.

Function Documentation

◆ sgl_generic_rgb2rgb()

sgl_result_t sgl_generic_rgb2rgb ( sgl_threadpool_t *  pool,
const sgl_uint8_t *  src,
sgl_fourcc_t  src_format,
sgl_uint8_t *  dst,
sgl_fourcc_t  dst_format,
sgl_int32_t  width,
sgl_int32_t  height 
)

Converts between any two supported RGB layouts.

Parameters
[in]poolWorker pool, or SGL_NULL for single-thread execution.
[in]srcSource image in src_format.
[in]src_formatAny supported RGB FourCC value.
[out]dstDestination image in dst_format.
[in]dst_formatAny supported RGB FourCC value.
[in]widthPositive image width in pixels.
[in]heightPositive image height in pixels.
Return values
SGL_SUCCESSConversion completed.
SGL_ERROR_INVALID_ARGUMENTSInvalid buffer, dimensions, or size.
SGL_ERROR_NOT_SUPPORTEDA FourCC is not an RGB format.
SGL_ERROR_MEMORY_ALLOCATIONParallel work storage was unavailable.
Precondition
Source and destination buffers do not overlap.

◆ sgl_generic_rgb2yuv()

sgl_result_t sgl_generic_rgb2yuv ( sgl_threadpool_t *  pool,
const sgl_uint8_t *  src,
sgl_fourcc_t  src_format,
sgl_uint8_t *  dst,
sgl_fourcc_t  dst_format,
sgl_int32_t  width,
sgl_int32_t  height 
)

Converts any supported RGB layout to any supported YUV layout.

Parameters
[in]poolWorker pool, or SGL_NULL for single-thread execution.
[in]srcSource image in src_format.
[in]src_formatOne of the RGB FourCC values in sgl-fourcc.h.
[out]dstDestination image in dst_format.
[in]dst_formatOne of the YUV FourCC values in sgl-fourcc.h.
[in]widthPositive image width in pixels.
[in]heightPositive image height in pixels.
Return values
SGL_SUCCESSConversion completed.
SGL_ERROR_INVALID_ARGUMENTSInvalid buffer, dimensions, or size.
SGL_ERROR_NOT_SUPPORTEDFourCC category or build feature unsupported.
SGL_ERROR_MEMORY_ALLOCATIONParallel work storage was unavailable.
Precondition
Source and destination buffers do not overlap.
See also
Pixel formats

◆ sgl_generic_yuv2rgb()

sgl_result_t sgl_generic_yuv2rgb ( sgl_threadpool_t *  pool,
const sgl_uint8_t *  src,
sgl_fourcc_t  src_format,
sgl_uint8_t *  dst,
sgl_fourcc_t  dst_format,
sgl_int32_t  width,
sgl_int32_t  height 
)

Converts any supported YUV layout to any supported RGB layout.

Parameters
[in]poolWorker pool, or SGL_NULL for single-thread execution.
[in]srcSource image in src_format.
[in]src_formatAny supported YUV FourCC value.
[out]dstDestination image in dst_format.
[in]dst_formatAny supported RGB FourCC value.
[in]widthPositive image width in pixels.
[in]heightPositive image height in pixels.
Return values
SGL_SUCCESSConversion completed.
SGL_ERROR_INVALID_ARGUMENTSInvalid buffer, dimensions, or size.
SGL_ERROR_NOT_SUPPORTEDInvalid source or destination category.
SGL_ERROR_MEMORY_ALLOCATIONParallel work storage was unavailable.
Precondition
Source and destination buffers do not overlap.

◆ sgl_generic_yuv2yuv()

sgl_result_t sgl_generic_yuv2yuv ( sgl_threadpool_t *  pool,
const sgl_uint8_t *  src,
sgl_fourcc_t  src_format,
sgl_uint8_t *  dst,
sgl_fourcc_t  dst_format,
sgl_int32_t  width,
sgl_int32_t  height 
)

Converts between any two supported YUV layouts.

Parameters
[in]poolWorker pool, or SGL_NULL for single-thread execution.
[in]srcSource image in src_format.
[in]src_formatAny supported YUV FourCC value.
[out]dstDestination image in dst_format.
[in]dst_formatAny supported YUV FourCC value.
[in]widthPositive image width in pixels.
[in]heightPositive image height in pixels.
Return values
SGL_SUCCESSConversion completed.
SGL_ERROR_INVALID_ARGUMENTSInvalid buffer, dimensions, or size.
SGL_ERROR_NOT_SUPPORTEDA FourCC is not a YUV format.
SGL_ERROR_MEMORY_ALLOCATIONParallel work storage was unavailable.
Precondition
Source and destination buffers do not overlap.

◆ sgl_simd_rgb2rgb()

sgl_result_t sgl_simd_rgb2rgb ( sgl_threadpool_t *  pool,
const sgl_uint8_t *  src,
sgl_fourcc_t  src_format,
sgl_uint8_t *  dst,
sgl_fourcc_t  dst_format,
sgl_int32_t  width,
sgl_int32_t  height 
)

SIMD RGB-to-RGB conversion.

Parameters
[in]poolWorker pool, or SGL_NULL for single-thread execution.
[in]srcSource image in src_format.
[in]src_formatAny supported RGB FourCC value.
[out]dstDestination image in dst_format.
[in]dst_formatAny supported RGB FourCC value.
[in]widthPositive image width in pixels.
[in]heightPositive image height in pixels.
Return values
SGL_SUCCESSConversion completed.
SGL_ERROR_INVALID_ARGUMENTSInvalid buffer, dimensions, or size.
SGL_ERROR_NOT_SUPPORTEDA FourCC is not an RGB format.
SGL_ERROR_MEMORY_ALLOCATIONParallel work storage was unavailable.
Precondition
Source and destination buffers do not overlap.

◆ sgl_simd_rgb2yuv()

sgl_result_t sgl_simd_rgb2yuv ( sgl_threadpool_t *  pool,
const sgl_uint8_t *  src,
sgl_fourcc_t  src_format,
sgl_uint8_t *  dst,
sgl_fourcc_t  dst_format,
sgl_int32_t  width,
sgl_int32_t  height 
)

SIMD RGB-to-YUV conversion.

Parameters
[in]poolWorker pool, or SGL_NULL for single-thread execution.
[in]srcSource image in src_format.
[in]src_formatOne of the RGB FourCC values in sgl-fourcc.h.
[out]dstDestination image in dst_format.
[in]dst_formatOne of the YUV FourCC values in sgl-fourcc.h.
[in]widthPositive image width in pixels.
[in]heightPositive image height in pixels.
Return values
SGL_SUCCESSConversion completed.
SGL_ERROR_INVALID_ARGUMENTSInvalid buffer, dimensions, or size.
SGL_ERROR_NOT_SUPPORTEDFourCC category or build feature unsupported.
SGL_ERROR_MEMORY_ALLOCATIONParallel work storage was unavailable.
Precondition
Source and destination buffers do not overlap.
See also
Pixel formats

◆ sgl_simd_yuv2rgb()

sgl_result_t sgl_simd_yuv2rgb ( sgl_threadpool_t *  pool,
const sgl_uint8_t *  src,
sgl_fourcc_t  src_format,
sgl_uint8_t *  dst,
sgl_fourcc_t  dst_format,
sgl_int32_t  width,
sgl_int32_t  height 
)

SIMD YUV-to-RGB conversion.

Parameters
[in]poolWorker pool, or SGL_NULL for single-thread execution.
[in]srcSource image in src_format.
[in]src_formatAny supported YUV FourCC value.
[out]dstDestination image in dst_format.
[in]dst_formatAny supported RGB FourCC value.
[in]widthPositive image width in pixels.
[in]heightPositive image height in pixels.
Return values
SGL_SUCCESSConversion completed.
SGL_ERROR_INVALID_ARGUMENTSInvalid buffer, dimensions, or size.
SGL_ERROR_NOT_SUPPORTEDInvalid source or destination category.
SGL_ERROR_MEMORY_ALLOCATIONParallel work storage was unavailable.
Precondition
Source and destination buffers do not overlap.

◆ sgl_simd_yuv2yuv()

sgl_result_t sgl_simd_yuv2yuv ( sgl_threadpool_t *  pool,
const sgl_uint8_t *  src,
sgl_fourcc_t  src_format,
sgl_uint8_t *  dst,
sgl_fourcc_t  dst_format,
sgl_int32_t  width,
sgl_int32_t  height 
)

SIMD YUV-to-YUV conversion.

Parameters
[in]poolWorker pool, or SGL_NULL for single-thread execution.
[in]srcSource image in src_format.
[in]src_formatAny supported YUV FourCC value.
[out]dstDestination image in dst_format.
[in]dst_formatAny supported YUV FourCC value.
[in]widthPositive image width in pixels.
[in]heightPositive image height in pixels.
Return values
SGL_SUCCESSConversion completed.
SGL_ERROR_INVALID_ARGUMENTSInvalid buffer, dimensions, or size.
SGL_ERROR_NOT_SUPPORTEDA FourCC is not a YUV format.
SGL_ERROR_MEMORY_ALLOCATIONParallel work storage was unavailable.
Precondition
Source and destination buffers do not overlap.