I’m investigating getting support for the Raspberry Pi (models 5,4B) v4l2-compliant HEVC decoding block driver “rpivid” into GStreamer, perhaps initially as a working patch to libgstv4l2codecs our users can apply, and then later as a PR, if it could be accepted.
The issue is the “SAND” (NC12, NC30) pixel formats the R Pi driver “rpivid” (in their kernel tree, not yet mainline) uses:
[Edit] A comment I just got from @6by9 at R Pi is:
AIUI Mainline GStreamer will only support formats that are defined in the mainline kernel, and upstreaming the HEVC decoder is still in progress
Once the format and driver are in the mainline kernel, I wouldn’t expect there to be any great obstacles to adding the format to GStreamer, but would ask Nicolas Dufresne as the person who knows that area best.
Sand was an internal Broadcom name for the format as it originally came from a company called Sand Video that was bought by them in 2004 - Broadcom acquires Sand Video • The Register
The rpivid driver uses /dev/video19:
$v4l2-ctl --list-formats-ext -d 19
ioctl: VIDIOC_ENUM_FMT
Type: Video Capture Multiplanar
[0]: 'NC12' (Y/CbCr 4:2:0 (128b cols))
[1]: 'NC30' (10-bit Y/CbCr 4:2:0 (128b cols))
R Pi have provided a modified ffmpeg that supports this format, which seems to be a column format called “SAND”. These modifications appear to be compatible with LGPL 2.1.
The modifications appear to be
- (1) “vf_unsand.c” , a videofilter for converting “sand” to YUV; the commit in the R Pi ffmpeg tree is Add an unsand filter · jc-kynesim/rpi-ffmpeg@c7d8474 · GitHub
A comment (from R Pi engineer @6by9 ) about NC12 /NC30 describes vf_unsand:
There is code in FFmpeg to convert from this column format (known as SAND) to planar YUV420, but it looks like that only supports writing out to the 3 plane YUV420 (aka I420) rather than NV12/21 or other flavour.
- (2) a set of functions “rpi_sand_fns.c” (with optional arm/NEON support) , seen in the commit Add sand pix fmts & conversion fns · jc-kynesim/rpi-ffmpeg@b6b137b · GitHub
Advice from GStreamer V4L2 maintainers (@ndufresne ) about whether adding support for these two formats in GStreamer might be feasible (or whether it is obviously a no-go) would be greatly appreciated!
- as an alternative, since support would be available in the ffmpeg supplied on R Pi, would it be possible to leverage that into gstreamer libgstv4l2codecs by testing if ffmpeg support is present, and using it if it is, (maybe via gstreamer-libav?)