v4l2object: Change dimensions format desc field to flag

The boolean naming wasn't obvious, and having this as a flag makes
the structure a little more compact.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7540>
This commit is contained in:
Nicolas Dufresne 2024-08-14 09:52:54 -04:00 committed by GStreamer Marge Bot
parent 03cf7f6445
commit 87398e1f8b

View file

@ -68,153 +68,153 @@ enum
*/
typedef enum
{
GST_V4L2_RAW = 1 << 0,
GST_V4L2_CODEC = 1 << 1,
GST_V4L2_TRANSPORT = 1 << 2,
GST_V4L2_NO_PARSE = 1 << 3,
GST_V4L2_RESOLUTION_AND_RATE = 1u << 4,
GST_V4L2_RAW = (1u << 0) | GST_V4L2_RESOLUTION_AND_RATE,
GST_V4L2_CODEC = 1u << 1,
GST_V4L2_TRANSPORT = 1u << 2,
GST_V4L2_NO_PARSE = 1u << 3,
GST_V4L2_ALL = 0xffff
} GstV4L2FormatFlags;
typedef struct
{
guint32 format;
gboolean dimensions;
GstV4L2FormatFlags flags;
} GstV4L2FormatDesc;
static const GstV4L2FormatDesc gst_v4l2_formats[] = {
/* RGB formats */
{V4L2_PIX_FMT_RGB332, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_ARGB555, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_XRGB555, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_ARGB555X, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_XRGB555X, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_RGB565, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_RGB565X, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_BGR666, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_BGR24, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_RGB24, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_ABGR32, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_XBGR32, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_BGRA32, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_BGRX32, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_RGBA32, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_RGBX32, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_ARGB32, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_XRGB32, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_RGB332, GST_V4L2_RAW},
{V4L2_PIX_FMT_ARGB555, GST_V4L2_RAW},
{V4L2_PIX_FMT_XRGB555, GST_V4L2_RAW},
{V4L2_PIX_FMT_ARGB555X, GST_V4L2_RAW},
{V4L2_PIX_FMT_XRGB555X, GST_V4L2_RAW},
{V4L2_PIX_FMT_RGB565, GST_V4L2_RAW},
{V4L2_PIX_FMT_RGB565X, GST_V4L2_RAW},
{V4L2_PIX_FMT_BGR666, GST_V4L2_RAW},
{V4L2_PIX_FMT_BGR24, GST_V4L2_RAW},
{V4L2_PIX_FMT_RGB24, GST_V4L2_RAW},
{V4L2_PIX_FMT_ABGR32, GST_V4L2_RAW},
{V4L2_PIX_FMT_XBGR32, GST_V4L2_RAW},
{V4L2_PIX_FMT_BGRA32, GST_V4L2_RAW},
{V4L2_PIX_FMT_BGRX32, GST_V4L2_RAW},
{V4L2_PIX_FMT_RGBA32, GST_V4L2_RAW},
{V4L2_PIX_FMT_RGBX32, GST_V4L2_RAW},
{V4L2_PIX_FMT_ARGB32, GST_V4L2_RAW},
{V4L2_PIX_FMT_XRGB32, GST_V4L2_RAW},
/* Deprecated Packed RGB Image Formats (alpha ambiguity) */
{V4L2_PIX_FMT_RGB444, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_RGB555, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_RGB555X, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_BGR32, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_RGB32, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_RGB444, GST_V4L2_RAW},
{V4L2_PIX_FMT_RGB555, GST_V4L2_RAW},
{V4L2_PIX_FMT_RGB555X, GST_V4L2_RAW},
{V4L2_PIX_FMT_BGR32, GST_V4L2_RAW},
{V4L2_PIX_FMT_RGB32, GST_V4L2_RAW},
/* Grey formats */
{V4L2_PIX_FMT_GREY, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_Y4, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_Y6, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_Y10, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_Y12, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_Y16, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_Y16_BE, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_Y10BPACK, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_GREY, GST_V4L2_RAW},
{V4L2_PIX_FMT_Y4, GST_V4L2_RAW},
{V4L2_PIX_FMT_Y6, GST_V4L2_RAW},
{V4L2_PIX_FMT_Y10, GST_V4L2_RAW},
{V4L2_PIX_FMT_Y12, GST_V4L2_RAW},
{V4L2_PIX_FMT_Y16, GST_V4L2_RAW},
{V4L2_PIX_FMT_Y16_BE, GST_V4L2_RAW},
{V4L2_PIX_FMT_Y10BPACK, GST_V4L2_RAW},
/* Palette formats */
{V4L2_PIX_FMT_PAL8, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_PAL8, GST_V4L2_RAW},
/* Chrominance formats */
{V4L2_PIX_FMT_UV8, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_UV8, GST_V4L2_RAW},
/* Luminance+Chrominance formats */
{V4L2_PIX_FMT_YVU410, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_YVU420, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_YVU420M, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_YUYV, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_YYUV, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_YVYU, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_UYVY, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_VYUY, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_YUV422P, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_YUV422M, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_YUV411P, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_Y41P, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_YUV444, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_YUV555, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_YUV565, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_YUV32, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_YUV410, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_YUV420, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_YUV420M, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_HI240, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_HM12, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_M420, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_YVU410, GST_V4L2_RAW},
{V4L2_PIX_FMT_YVU420, GST_V4L2_RAW},
{V4L2_PIX_FMT_YVU420M, GST_V4L2_RAW},
{V4L2_PIX_FMT_YUYV, GST_V4L2_RAW},
{V4L2_PIX_FMT_YYUV, GST_V4L2_RAW},
{V4L2_PIX_FMT_YVYU, GST_V4L2_RAW},
{V4L2_PIX_FMT_UYVY, GST_V4L2_RAW},
{V4L2_PIX_FMT_VYUY, GST_V4L2_RAW},
{V4L2_PIX_FMT_YUV422P, GST_V4L2_RAW},
{V4L2_PIX_FMT_YUV422M, GST_V4L2_RAW},
{V4L2_PIX_FMT_YUV411P, GST_V4L2_RAW},
{V4L2_PIX_FMT_Y41P, GST_V4L2_RAW},
{V4L2_PIX_FMT_YUV444, GST_V4L2_RAW},
{V4L2_PIX_FMT_YUV555, GST_V4L2_RAW},
{V4L2_PIX_FMT_YUV565, GST_V4L2_RAW},
{V4L2_PIX_FMT_YUV32, GST_V4L2_RAW},
{V4L2_PIX_FMT_YUV410, GST_V4L2_RAW},
{V4L2_PIX_FMT_YUV420, GST_V4L2_RAW},
{V4L2_PIX_FMT_YUV420M, GST_V4L2_RAW},
{V4L2_PIX_FMT_HI240, GST_V4L2_RAW},
{V4L2_PIX_FMT_HM12, GST_V4L2_RAW},
{V4L2_PIX_FMT_M420, GST_V4L2_RAW},
/* two planes -- one Y, one Cr + Cb interleaved */
{V4L2_PIX_FMT_NV12, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_NV12M, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_NV12MT, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_NV12MT_16X16, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_NV12M_8L128, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_NV12M_10BE_8L128, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_NV21, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_NV21M, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_NV16, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_NV16M, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_NV61, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_NV61M, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_NV24, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_NV42, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_MM21, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_NV12, GST_V4L2_RAW},
{V4L2_PIX_FMT_NV12M, GST_V4L2_RAW},
{V4L2_PIX_FMT_NV12MT, GST_V4L2_RAW},
{V4L2_PIX_FMT_NV12MT_16X16, GST_V4L2_RAW},
{V4L2_PIX_FMT_NV12M_8L128, GST_V4L2_RAW},
{V4L2_PIX_FMT_NV12M_10BE_8L128, GST_V4L2_RAW},
{V4L2_PIX_FMT_NV21, GST_V4L2_RAW},
{V4L2_PIX_FMT_NV21M, GST_V4L2_RAW},
{V4L2_PIX_FMT_NV16, GST_V4L2_RAW},
{V4L2_PIX_FMT_NV16M, GST_V4L2_RAW},
{V4L2_PIX_FMT_NV61, GST_V4L2_RAW},
{V4L2_PIX_FMT_NV61M, GST_V4L2_RAW},
{V4L2_PIX_FMT_NV24, GST_V4L2_RAW},
{V4L2_PIX_FMT_NV42, GST_V4L2_RAW},
{V4L2_PIX_FMT_MM21, GST_V4L2_RAW},
/* Bayer formats - see http://www.siliconimaging.com/RGB%20Bayer.htm */
{V4L2_PIX_FMT_SBGGR8, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_SGBRG8, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_SGRBG8, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_SRGGB8, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_SBGGR10, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_SGBRG10, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_SGRBG10, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_SRGGB10, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_SBGGR12, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_SGBRG12, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_SGRBG12, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_SRGGB12, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_SBGGR14, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_SGBRG14, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_SGRBG14, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_SRGGB14, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_SBGGR16, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_SGBRG16, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_SGRBG16, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_SRGGB16, TRUE, GST_V4L2_RAW},
{V4L2_PIX_FMT_SBGGR8, GST_V4L2_RAW},
{V4L2_PIX_FMT_SGBRG8, GST_V4L2_RAW},
{V4L2_PIX_FMT_SGRBG8, GST_V4L2_RAW},
{V4L2_PIX_FMT_SRGGB8, GST_V4L2_RAW},
{V4L2_PIX_FMT_SBGGR10, GST_V4L2_RAW},
{V4L2_PIX_FMT_SGBRG10, GST_V4L2_RAW},
{V4L2_PIX_FMT_SGRBG10, GST_V4L2_RAW},
{V4L2_PIX_FMT_SRGGB10, GST_V4L2_RAW},
{V4L2_PIX_FMT_SBGGR12, GST_V4L2_RAW},
{V4L2_PIX_FMT_SGBRG12, GST_V4L2_RAW},
{V4L2_PIX_FMT_SGRBG12, GST_V4L2_RAW},
{V4L2_PIX_FMT_SRGGB12, GST_V4L2_RAW},
{V4L2_PIX_FMT_SBGGR14, GST_V4L2_RAW},
{V4L2_PIX_FMT_SGBRG14, GST_V4L2_RAW},
{V4L2_PIX_FMT_SGRBG14, GST_V4L2_RAW},
{V4L2_PIX_FMT_SRGGB14, GST_V4L2_RAW},
{V4L2_PIX_FMT_SBGGR16, GST_V4L2_RAW},
{V4L2_PIX_FMT_SGBRG16, GST_V4L2_RAW},
{V4L2_PIX_FMT_SGRBG16, GST_V4L2_RAW},
{V4L2_PIX_FMT_SRGGB16, GST_V4L2_RAW},
/* compressed formats */
{V4L2_PIX_FMT_MJPEG, FALSE, GST_V4L2_CODEC},
{V4L2_PIX_FMT_JPEG, FALSE, GST_V4L2_CODEC},
{V4L2_PIX_FMT_PJPG, FALSE, GST_V4L2_CODEC},
{V4L2_PIX_FMT_DV, FALSE, GST_V4L2_TRANSPORT},
{V4L2_PIX_FMT_MPEG, FALSE, GST_V4L2_TRANSPORT},
{V4L2_PIX_FMT_FWHT, FALSE, GST_V4L2_CODEC},
{V4L2_PIX_FMT_H264, FALSE, GST_V4L2_CODEC},
{V4L2_PIX_FMT_H264_NO_SC, FALSE, GST_V4L2_CODEC},
{V4L2_PIX_FMT_H264_MVC, FALSE, GST_V4L2_CODEC},
{V4L2_PIX_FMT_HEVC, FALSE, GST_V4L2_CODEC},
{V4L2_PIX_FMT_H263, FALSE, GST_V4L2_CODEC},
{V4L2_PIX_FMT_MPEG1, FALSE, GST_V4L2_CODEC},
{V4L2_PIX_FMT_MPEG2, FALSE, GST_V4L2_CODEC},
{V4L2_PIX_FMT_MPEG4, FALSE, GST_V4L2_CODEC},
{V4L2_PIX_FMT_XVID, FALSE, GST_V4L2_CODEC},
{V4L2_PIX_FMT_VC1_ANNEX_G, FALSE, GST_V4L2_CODEC},
{V4L2_PIX_FMT_VC1_ANNEX_L, FALSE, GST_V4L2_CODEC},
{V4L2_PIX_FMT_VP8, FALSE, GST_V4L2_CODEC | GST_V4L2_NO_PARSE},
{V4L2_PIX_FMT_VP9, FALSE, GST_V4L2_CODEC | GST_V4L2_NO_PARSE},
{V4L2_PIX_FMT_MJPEG, GST_V4L2_CODEC},
{V4L2_PIX_FMT_JPEG, GST_V4L2_CODEC},
{V4L2_PIX_FMT_PJPG, GST_V4L2_CODEC},
{V4L2_PIX_FMT_DV, GST_V4L2_TRANSPORT},
{V4L2_PIX_FMT_MPEG, GST_V4L2_TRANSPORT},
{V4L2_PIX_FMT_FWHT, GST_V4L2_CODEC},
{V4L2_PIX_FMT_H264, GST_V4L2_CODEC},
{V4L2_PIX_FMT_H264_NO_SC, GST_V4L2_CODEC},
{V4L2_PIX_FMT_H264_MVC, GST_V4L2_CODEC},
{V4L2_PIX_FMT_HEVC, GST_V4L2_CODEC},
{V4L2_PIX_FMT_H263, GST_V4L2_CODEC},
{V4L2_PIX_FMT_MPEG1, GST_V4L2_CODEC},
{V4L2_PIX_FMT_MPEG2, GST_V4L2_CODEC},
{V4L2_PIX_FMT_MPEG4, GST_V4L2_CODEC},
{V4L2_PIX_FMT_XVID, GST_V4L2_CODEC},
{V4L2_PIX_FMT_VC1_ANNEX_G, GST_V4L2_CODEC},
{V4L2_PIX_FMT_VC1_ANNEX_L, GST_V4L2_CODEC},
{V4L2_PIX_FMT_VP8, GST_V4L2_CODEC | GST_V4L2_NO_PARSE},
{V4L2_PIX_FMT_VP9, GST_V4L2_CODEC | GST_V4L2_NO_PARSE},
/* Vendor-specific formats */
{V4L2_PIX_FMT_WNVA, TRUE, GST_V4L2_CODEC},
{V4L2_PIX_FMT_SN9C10X, TRUE, GST_V4L2_CODEC},
{V4L2_PIX_FMT_PWC1, TRUE, GST_V4L2_CODEC},
{V4L2_PIX_FMT_PWC2, TRUE, GST_V4L2_CODEC},
{V4L2_PIX_FMT_WNVA, GST_V4L2_CODEC | GST_V4L2_RESOLUTION_AND_RATE},
{V4L2_PIX_FMT_SN9C10X, GST_V4L2_CODEC | GST_V4L2_RESOLUTION_AND_RATE},
{V4L2_PIX_FMT_PWC1, GST_V4L2_CODEC | GST_V4L2_RESOLUTION_AND_RATE},
{V4L2_PIX_FMT_PWC2, GST_V4L2_CODEC | GST_V4L2_RESOLUTION_AND_RATE},
};
#define GST_V4L2_FORMAT_COUNT (G_N_ELEMENTS (gst_v4l2_formats))
@ -1783,7 +1783,7 @@ gst_v4l2_object_v4l2fourcc_to_structure (guint32 fourcc)
if (gst_v4l2_formats[i].format != fourcc)
continue;
if (gst_v4l2_formats[i].dimensions) {
if (gst_v4l2_formats[i].flags & GST_V4L2_RESOLUTION_AND_RATE) {
gst_structure_set (template,
"width", GST_TYPE_INT_RANGE, 1, GST_V4L2_MAX_SIZE,
"height", GST_TYPE_INT_RANGE, 1, GST_V4L2_MAX_SIZE,
@ -1877,7 +1877,7 @@ gst_v4l2_object_get_caps_helper (GstV4L2FormatFlags flags)
if (structure) {
GstStructure *alt_s = NULL;
if (gst_v4l2_formats[i].dimensions) {
if (gst_v4l2_formats[i].flags & GST_V4L2_RESOLUTION_AND_RATE) {
gst_structure_set (structure,
"width", GST_TYPE_INT_RANGE, 1, GST_V4L2_MAX_SIZE,
"height", GST_TYPE_INT_RANGE, 1, GST_V4L2_MAX_SIZE,