V4l2dec and v4l2enc in dmabuf-importmode

Nicolas Dufresne nicolas at ndufresne.ca
Tue Oct 3 20:29:55 UTC 2023


Hi,

Le mardi 03 octobre 2023 à 16:19 +0530, Arindam Biswas via gstreamer-devel a
écrit :
> v4l2bufferpool gstv4l2bufferpool.c:396:gst_v4l2_buffer_pool_import_dmabuf:<v4l2h264dec0:pool0:sink> failed to import dmabuf
>  
> What is the recommendation to handle such cases?
>  
> 1. Implement a two separate gstreamer plugins which generates dma buffers, for example predmabufgen and postdmabufgen in the following examples
>  
> Example Pipeline:
>  
> gst-launch-1.0 filesrc location=/1.mp4 ! qtdemux ! h264parse ! predmabufgen  v4l2h264dec capture-io-mode=5 output-io-mode=5 ! postdmabufgen ! fakesink
> gst-launch-1.0 videotestsrc ! predmabufgen ! v4l2h264enc capture-io-mode=5 output-io-mode=5 ! postdmabufgen ! fakesink
>  
> 2. Allocate dmabuf in the v4l2dec/v4l2enc plugin in case of dmabuf-import if downstream is not providing a pool or upstream plugin is snot sending fd buffer?

There is few things to be aware about the dmabuf import path. Doing random
assignment of v4l2_buffer index and FDs is in violation of the spec. GStreamer
should always pass the same FD to the same buffer index. This is currently
unimplemented and cause random driver to fail.

Another thing to be aware, is how v4l2 is inflexible around buffer allocation.
In ideal world. all this would be automatic based on allocation negotiation and
incoming buffer types. But there is possibly a way around that:

- Allocate import buffers in v4l2 driver
- Allocate "backup FDs" using a second driver instance (only possible for m2m)
- If a incoming buffer is not an FD, pick one of the backup buffer and
copy/import.

On capture, if you make this automatic, you simply use mmap/dmabuf export if
downstream is not providing a DMABuf FD pool.

Now, comment about 1., this part make no sense:

   h264parse ! predmabufgen ! v4l2h264dec

There is absolutly no gain, you can just let v4l2h264dec copy, it is the same,
in a simpler fashion. This is also compressed data, zero-copy there gives
limited gain.

  videotestsrc ! predmabufgen ! v4l2h264enc

This one is different, but v4l2h264enc already offset FDs that will be used by
videotestsrc, so its equally awkward to have this middle man.

Nicolas



More information about the gstreamer-devel mailing list