About TX Multimedia API

On TK1 I used NvDDK2D and NvRmSurface to manage gpu memory. Now on TX1 I am using Multmedia API based on V4L2.

Two questions

  • How can I convert between dma_fds created by NvBufferCreate[nvbuf_utils.h] with different params ? Just like what NvDdk2dBlit did.
  • How can I read out / write into the memory of dma_fd in block linear layout created by NvBufferCreate[nvbuf_utils.h] ? Just like what NvRmSurfaceRead/NvRmSurfaceWrite did.

In ‘samples/07_video_convert’, I can only see convert between fd-s exported by V4L2 convert element; and the fd-s are one per planner. Although in some cases(pitch layout ?), the fd-s of different planners are the same, I’m not sure whether I can pass the dma_fd created by NvBufferCreate into it.

Thanks !

Hi horson,
Please run ‘./video_convert -h’ to get supported formats and more detail. For pitch linear and block linear, you have to put --input-nvpl/nvbl, --output-nvpl/nvbl in the command.

Thanks for your replay.

I was clear about the formats/layouts/types in that sample. And I had tested the performance in each case. So, I was not talking about how to use the sample.

Any more ideas ?

Hi horson,
We don’t officially support NvDdk APIs you use on TK1. Could you share more detail on how you are able to run the APIs on TK1? Any documentation you are referring to?

And on TX1, please share your usecase and what difficulty you have met via MM APIs or gstreamer.

The idea of NvBufferCreate is to encapsulate the internal NvRmSurfaceXXX call and provide a consistent and V4L2-based API for application writer. The FD pointer returned from the API can be used to connect to other V4L2 or non-V4L2 component, including EGLImage (such as NvEGLImageFromFd). To access the buffer, one can use NvBufferGetParams API to get the buffer pointer and other attributes.

You could look for sample in using these APIs. Hope this helps.

Sorry for replying late.
We have no document to refer to.
My problem is lacking an efficient way to convert between buffers with different types/layouts/formats. As far as I known, NvCreateBuffer from [nvbuf_utils.h] cannot meet my need. I have to create buffers by opening v4l2 convert/decode/encode emelemts and convert them by many different converters. This is not very convenient but is the only effective way.

Hi chijen,

Thanks for your reply !

Function NvBufferCreate returns only one fd, while the V4L2 converter require/query/exports fd-s per planner. So their APIs may be not compatible.

Is there any possibility to make the V4L2 APIs easier to use ?

Take H.264 decoding as an example, the v4l2 decoder outputs NV12 buffer with block-linear layout, to do further handles, I need to convert it by hardware to RGB buffer with pitch layout. So I have to create a V4L2 converter (NV12 block -> RGB pitch). To implement opengles effect(e.g. Gaussian Blur), I have to create an another V4L2 converter (RGB pitch -> RGB block). After opengles, I need to encode and snapshot. So I have to create another V4L2 converts (RGB block -> NV12 pitch -> NV12 block) (RGB block -> RGB pitch). To handle video with different resolutions, I have to create V4L2 converters for each. During such a progress, I must pay attention to whether the memory type should be MMAP or DMABUF (share buffer). I really appreciate the internal NvRmSurface and DDK2D API, that is obviously much easier to use.

Hi horson,
What you require is low-level APIs and considered private. Please use gstreamer frameworks or MM APIs.

V4L2 converter can take the fd. Please give it a try.

Please share more about your usecase. In the H264 decoding example, it looks like only NV12 block -> RGB block -> NV12 block is necessary. Please refer to backend sample which is similar to this case.

Hi DaneLLL,

Thanks for your suggestion.

According to sample ‘07_video_convert’, block->block is not supported.

A news !

‘libv4l2_nvvidconv: Error: MAX number of NVVIDCONV instance (10) already created’

Sometimes I create a new converter just for allocating buffers of a specific resolution.

How can I remove this restriction ?

Hi horson,
Please confirm your usecase is H264 decode -> NV12 block -> RGB block -> NV12 block. We will check and give suggestion.

Yes, this is a common use case. Thank you !

Hi horson,
v4l2 converter does support NV BL -> NV BL. Please give it a try.

Sorry for my misunderstanding.

Thanks !

Hi DaneLLL,

I’m confused about the parameter ‘nv_buffer’ in struct _NvBufferParams. I cannot get any information from the document ‘/tegra_multimedia_api/doc/html/struct__NvBufferParams.html’. Could you please tell me whether I can read/write pixel data from/into it. Please consider block linear layout.

‘libv4l2_nvvidconv: Error: MAX number of NVVIDCONV instance (10) already created’

How can I remove this restriction ?

Because there is only one HW engine and all instances go to the engine. 10 is actually a large number. Could you share why you need > 10 converters? Could you shift some format conversions to GPU via CUDA?

For each raw video channel, I at least need a pitch->block CONV to input raw video data from user memory, and a block->pitch CONV after opengles to snapshot the result. When encoding, I need a block->block CONV. I will use CONV for not only layout converting, but also resolution converting, color space converting and flipping.

So 10 CONV is only enable to handle at most 4 video channels even if each video is in a low resolution and a low framerate, e.g. 352x288@30Hz, 720x576@15Hz.

When using NvRmSurface and NvDDK2D, there was no such restriction. I could do many kinds of CONVs at the same time. And I needn’t create many so called converters or managing those DMABUF(share) buffers. I could start doing any kind of converting at any time by creating new NvDdk2DSurfaces.

On PC I used to do converting by CUDA because I have no better choice. But now on Tegra, if NvDD2D is actually enough why should I use another system (CUDA) together.

Hi horson,
Could you share how you process the block-linear buffers? Any samples for our reference?