Skip to content

video: dma heap buffer pool for sharing fd between elements

HuQian requested to merge HuQian/gstreamer:dev-dma into main

backgroud

we are using gstreamer v4l2 element(hardware decoder/encoder/convert) in many case, and need buffer from dma heap that shared with many other gst-module/non-gst-module, such as app/display. but v4l2 element do not create dma heap buffer by itself.

use case

  1. app allocate video dma buffer from pool, and push it into pipeline by appsrc, and received by v4l2 encoder
  2. app allocate video dma buffer from pool, and propose it into pipeline by appsink with propose allocation, and received by v4l2 elements
  3. vendor source plugin that produce video dma buffer, such as camsrc -->|NV12M/RGB/YUY2| v4l2 encoder

next

  1. we create a dma heap allocator to allocate dma fd
  2. and use video pool with this new dma heap allocator to allocate gstbuffer it work well for RGB / YUV2 single plane format

issue

but. since v4l2 and gst v4l2 element support MULTIPLANAR buffer. some problem in these case, for an example,

source -->|NV12|-->v4l2 encoder

multiplaner v4l2 encoder driver will use NV12M, and expected "group->buffer.length == 2"

there are two way achive this target:

  1. let video pool support multi gstmemory for NV12M
  2. fix following code, let v4l2 element import a GstBuffer with only one GstMemory, but fill correct offset for each group->planes[i].data_offset https://gitlab.freedesktop.org/gstreamer/gstreamer/-/blob/main/subprojects/gst-plugins-good/sys/v4l2/gstv4l2allocator.c?ref_type=heads#L1106

i choose first one. i think it maybe common case a GstBuffer contain Multi GstMemory

Edited by HuQian

Merge request reports

Loading