NV12 to RGB/RGBA Color Conversion
NV12 to RGB/RGBA Color Conversion#
Converts an image from NV12 format to RGB or RGBA format.
Description
This function can operate with ROI (see Image Regions of Interest).
This function performs conversion from NV12 image to gamma-corrected RGB or RGBA image according to formulae:
R' = 1.164 * (Y' - 16) + 1.596 * (Cr' - 128)
G' = 1.164 * (Y' - 16) - 0.183 * (Cr' - 128) - 0.392 * (Cb' - 128)
B' = 1.164 * (Y' - 16) + 2.017 * (Cb' - 128)
If destination layout is channel4
(format is RGBA) , alpha_value
from spec
must be used to fill alpha channel.
Source and destination image width and height must be even.
Headers
oneapi/ipl/convert.hpp
Syntax
-
template<typename ComputeT = float, typename SrcImageT, typename DstImageT>
sycl::event oneapi::ipl::nv12_to_rgb(sycl::queue &queue, SrcImageT &src, DstImageT &dst, const color_conversion_spec<typename DstImageT::data_t> &spec = {}, const std::vector<sycl::event> &dependencies = {})# Function for NV12 to RGB or RGBA color conversion.
- Template Parameters
ComputeT – The type in which all calculations will be performed
SrcImageT – Source image type
DstImageT – Destination image type
- Parameters
queue – SYCL queue object
src – Source image object
dst – Destination image object
spec – Specification for convert function
dependencies – SYCL event dependencies
- Returns
SYCL event
Supported values for ComputeT:
|
|
Supported values for destination layout:
|
|
Parameters
See Parameters of Color Conversion (spec).
Errors
compile-time memory layout check |
Indicates an error when image memory layout is not supported. |
compile-time data type check |
Indicates an error when image data type is not supported. |
compile-time compute data type check |
Indicates an error when compute data type is not supported. |
|
Indicates an error when ROI sizes of the source image and the destination image are not equal. |
|
Indicates an error when one of the pitch values is not divisible by size of component data type in bytes. |
The code example below demonstrates how shall be called
oneapi::ipl::nv12_to_rgb
for NV12 to RGBA conversion:
using namespace oneapi;
sycl::queue queue;
ipl::shared_usm_allocator_t allocator{ queue };
const sycl::range<2> image_size{ height, width };
// Source image for NV12 data
ipl::image<ipl::layouts::sub420i, std::uint8_t> src_image{ queue, p_image_data, image_size, allocator };
// Destination image for RGBA data
ipl::image<ipl::layouts::channel4, std::uint8_t> dst_image{ image_size, allocator };
// Convert NV12 to RGBA
auto event = ipl::nv12_to_rgb(queue, src_image, dst_image);