API for using VIC blender functionality

I’m seeing in the Xavier SoC technical reference manual section “ Blender”, that the VIC has some blend functionalities. I would like to use the “Per-Pixel Non-Premultiplied Alpha Blend output = srcsrc_alpha + dst(1-src_alpha)”.
Does any of the functions in the nvbuf_utils.h library provide this function or any of the other blend modes?

I’ve tried using NvBufferComposite, with composite_flag = NVBUFFER_COMPOSITE | NVBUFFER_BLEND, source and destination dmabuf format = NvBufferColorFormat_ARGB32.
However I get an error saying:
pixel_format must be RGBA for blending operation
nvbuffer_composite Failed
I’ve attached my test code. See function start_vic_composite_mirror_blend(…)
camera_v4l2_cuda.cpp (60.4 KB)
camera_v4l2_cuda.h (3.7 KB)
How can I use NvBufferComposite to perform Per-Pixel Non-Premultiplied Alpha Blend?

In calling NvBufferComposite(), the source buffers are the captured buffers:

        for (size_t j = 0; j < V4L2_CAMERAS_NUM; j++)
            /* Dequeue a camera buff */
            memset(&v4l2_buf[j], 0, sizeof(v4l2_buf[j]));
            v4l2_buf[j].type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
            if (ctx->capture_dmabuf)
                v4l2_buf[j].memory = V4L2_MEMORY_DMABUF;
                v4l2_buf[j].memory = V4L2_MEMORY_MMAP;
            if (ioctl(ctx->cam_fd[j], VIDIOC_DQBUF, &v4l2_buf[j]) < 0)
                ERROR_RETURN("Failed to dequeue camera buff: %s (%d)",
                             strerror(errno), errno);

            src_dmabuf_fds[j] = ctx->g_buff[j][v4l2_buf[j].index].dmabuff_fd;
        for (size_t j = V4L2_CAMERAS_NUM; j < V4L2_CAMERAS_REAL_SIM_NUM; j++)
            // These buffers are not filled by any real cameras. Just take first buffer e.g. index = 0.
            const int index = 0;
            src_dmabuf_fds[j] = ctx->g_buff[j][index].dmabuff_fd;

The camera sources should be YUV422 such as YUYV or UYVY. Please create NvBuffers in RGBA and convert captured buffers to the NvBuffers through NvBufferTransform(), and set to src_dmabuf_fds in calling NvBufferComposite().

Yes, the captured buffers are in VYUV. They are transformed to the render buffer in NvBufferColorFormat_ARGB32 format. That part works. But the part failing is when I’m trying to blend a “gui buffer” in NvBufferColorFormat_ARGB32 into the render buffer:

Main loop:
if (-1 == NvBufferComposite(&ctx->gui_overlay_dmabuf_fd, ctx->render_dmabuf_fd, &composite_params))
ERROR_RETURN(“Failed to blend ui image into render buffer.”);

Allocation of buffers:
input_params.colorFormat = NvBufferColorFormat_ARGB32; // get_nvbuff_color_fmt(V4L2_PIX_FMT_YUV420M);
input_params.width = ctx->disp_w;
input_params.height = ctx->disp_h;
input_params.nvbuf_tag = NvBufferTag_NONE;
/* Create Render buffer */
if (-1 == NvBufferCreateEx(&ctx->render_dmabuf_fd, &input_params))
ERROR_RETURN(“Failed to create NvBuffer”);

input_params.colorFormat = NvBufferColorFormat_ARGB32;
input_params.width = ctx->disp_w;
input_params.height = ctx->disp_h;
input_params.nvbuf_tag = NvBufferTag_NONE;
if (-1 == NvBufferCreateEx(&ctx->gui_overlay_dmabuf_fd, &input_params))
    ERROR_RETURN("Failed to create NvBuffer");