I am interested in copying the output of the NvVideoConverter to a dmabuf_fd created using nvbuf_utils.h NvBufferCreateEx.
I think I’m supposed to use Raw2NvBuffer, but I can’t find any examples on proper use.
Here is the definition from nvbuf_utils.h:
/**
* This method is used to copy raw buffer plane contents to NvBuffer plane.
* @param[in] ptr pointer to the input raw plane data.
* @param[in] plane video frame plane.
* @param[in] in_width aligned width of the raw data plane.
* @param[in] in_height aligned height of the raw data plane.
* @param[in] dmabuf_fd DMABUF FD of NvBuffer.
*
* @returns 0 for success, -1 for failure.
*/
int Raw2NvBuffer (unsigned char *ptr, unsigned int plane, unsigned int in_width, unsigned int in_height, int dmabuf_fd);
I have a NvBuffer *buffer from a NvVideoConverter capture plane callback (bolded).
bool converter_capture_cb(
struct v4l2_buffer *v4l2_buf,
<b>NvBuffer * buffer,</b>
NvBuffer * shared_buffer,
void *priv)
And I have a dmabuf_fd created from NvBufferCreateEx buffer like this:
// Allocate output buffer
NvBufferCreateParams input_params;
memset(&input_params, 0, sizeof(NvBufferCreateParams));
input_params.payloadType = NvBufferPayload_SurfArray;
input_params.width = buffer->planes[0].fmt.width;
input_params.height = buffer->planes[0].fmt.height;
input_params.layout = NvBufferLayout_Pitch;
input_params.colorFormat = NvBufferColorFormat_ABGR32;
input_params.nvbuf_tag = NvBufferTag_NONE;
int fd = -1;
if(NvBufferCreateEx(&fd, &input_params) == -1) {
DEBUG_ERROR("Failed to create output NvBuffer");
ctx->m_conv->abort();
break;
}
Would I then call Raw2NvBuffer like this?
Raw2NvBuffer(
buffer->planes[0].data, // raw data pointer
0, // we always seem to use plane 0(?)
buffer->planes[0].fmt.width, // width
buffer->planes[0].fmt.height, // height
fd // dmabuf_fd
);