NVIDIA multimedia APIs support converting UYVY to RGB ?

Dear,

After spending time with multimedia APIs. Now I can capture and record videos file as below.
Camera (UYVY) -> Video converter (YUV420M) -> Encoder (H264) -> FFmpeg (mp4).

I also want to convert UYVY to RGB data for other feature. So is it possible to convert form UYVY data to RGB data with HW accelerator?

Thanks and Best Regards,

Hi Vu,
Please refer to
https://devtalk.nvidia.com/default/topic/989438/jetson-tx1/neon-optimised-vyuy2bgr/post/5067113/#5067113

Video converter can do UYVY -> RGBA. Please refer to the code and apply your case.

Hi DaneLLL,

Thank for your reply. I can convert form YUVY to ABGR now.
However I can not find how to convert from ABGR to BGR with CUDA in backend samples.
Can you help me figure out.

Thanks and Best Regards,

Hi Vu, please refer to mapEGLImage2Float()
It is done in convertIntToFloatKernel() in tegra_multimedia_api\samples\common\algorithm\cuda\NvAnalysis.cu

Hi DaneLLL,

In this callback I can get buffer and size of ABGR image through buffer->planes[0].data and buffer->planes[0].bytesused. How can I put this to CUDA converter as above. I don’t want to use any EGLdisplay.

static bool conv0_rgb_capture_dqbuf_thread_callback(struct v4l2_buffer *v4l2_buf,
                                   NvBuffer * buffer, NvBuffer * shared_buffer,
                                   void *arg) {
    context_t *ctx = (context_t *) arg;

    if (ctx->conv_rgb->capture_plane.qBuffer(*v4l2_buf, buffer) < 0)
    {
        abort(ctx);
        ERROR_RETURN("Failed to queue buffer on VIC capture plane");
    }

    return true;
}

Thanks and Best Regards,

Hi Vu,
It requires the two APIs to get egl_image:
NvEGLImageFromFd()
NvDestroyEGLImage()

EGLDisplay is required.

Hi DaneLLL,

EGLDisplay is required but we no need render display?

I tried to convert with opencv and measure the result, it take about 4-5ms for converting 2560x1440 frame.
How much do you think H/W can finish conversion?

mapEGLImage2Float(void* pEGLImage, int width, int height, void* cuda_buf)
pEGLImage is ARGB input and cuda_buf is RGB output?

Thanks and Best Regards,

Hi Vu,
You are able to do profiling by adding gettimeofday() in backend sample. Please refer to tegra_multimedia_api\README

Hi DaneLLL,

mapEGLImage2Float(void* pEGLImage, int width, int height, void* cuda_buf)
pEGLImage is ARGB input and cuda_buf is RGB output?

Is it correct ?

Hi Vu,

convertIntToFloatKernel(CUdeviceptr pDevPtr, int width, int height,
                void* cuda_buf, int pitch)
{
    float *pdata = (float *)cuda_buf;
    char *psrcdata = (char *)pDevPtr;
    int row = blockIdx.y * blockDim.y + threadIdx.y;
    int col = blockIdx.x * blockDim.x + threadIdx.x;

    if (col < width && row < height)
    {
        for (int k = 0; k < 3; k++)
        {
            pdata[width * height * k + row * width + col] =
                (float)*(psrcdata + row * pitch + col * 4 + (3 - 1 - k));
        }
    }
}

The input is RGBA int and the output is BGR float