v4l2codecs: format: Add V4L2_PIX_FMT_NC12

Which is used by the Raspberry Pi 4 and 5 for 8-bit HEVC. Adding it
here in order to show-case how the V4L2<->DRM translation is
supposed to work.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7355>
This commit is contained in:
Robert Mader 2024-11-08 12:38:09 +01:00 committed by GStreamer Marge Bot
parent 4b07d54931
commit b275f63b13

View file

@ -24,6 +24,10 @@
#define GST_CAT_DEFAULT gstv4l2codecs_debug
GST_DEBUG_CATEGORY_EXTERN (gstv4l2codecs_debug);
#ifndef V4L2_PIX_FMT_NC12
#define V4L2_PIX_FMT_NC12 v4l2_fourcc('N', 'C', '1', '2') /* Y/CbCr 4:2:0 (128b cols) */
#endif
typedef struct
{
guint32 v4l2_pix_fmt;
@ -45,6 +49,7 @@ static const GstV4l2FormatDesc gst_v4l2_descriptions[] = {
{V4L2_PIX_FMT_SUNXI_TILED_NV12, GST_VIDEO_FORMAT_NV12_32L32, DRM_FORMAT_INVALID, DRM_FORMAT_MOD_INVALID, 0},
{V4L2_PIX_FMT_YUV420M, GST_VIDEO_FORMAT_I420, DRM_FORMAT_INVALID, DRM_FORMAT_MOD_INVALID, 0},
{V4L2_PIX_FMT_YUYV, GST_VIDEO_FORMAT_YUY2, DRM_FORMAT_INVALID, DRM_FORMAT_MOD_INVALID, 0},
{V4L2_PIX_FMT_NC12, GST_VIDEO_FORMAT_UNKNOWN, DRM_FORMAT_NV12, DRM_FORMAT_MOD_BROADCOM_SAND128, 2},
};
/* *INDENT-ON* */
#define GST_V4L2_FORMAT_DESC_COUNT (G_N_ELEMENTS (gst_v4l2_descriptions))
@ -193,6 +198,14 @@ gst_v4l2_format_to_dma_drm_info (struct v4l2_format *fmt,
n_planes = 1;
}
if (drm_fourcc == DRM_FORMAT_NV12
&& drm_mod == DRM_FORMAT_MOD_BROADCOM_SAND128) {
out_drm_info->vinfo.offset[1] = pix_mp->height * 128;
out_drm_info->vinfo.stride[0] = pix_mp->plane_fmt[0].bytesperline;
out_drm_info->vinfo.stride[1] = pix_mp->plane_fmt[0].bytesperline;
return TRUE;
}
/*
* When single allocation formats are used for planar formats we need to
* extrapolate the per-plane stride. Do this check once to prevent