mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-17 22:06:41 +00:00
v4l2object: Split _v4l2fourcc_to_video_format
https://bugzilla.gnome.org/show_bug.cgi?id=720568
This commit is contained in:
parent
e1be685c34
commit
4956b46bab
2 changed files with 83 additions and 71 deletions
|
@ -1357,74 +1357,9 @@ gst_v4l2_object_get_format_list (GstV4l2Object * v4l2object)
|
||||||
return v4l2object->formats;
|
return v4l2object->formats;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GstVideoFormat
|
||||||
GstStructure *
|
gst_v4l2_object_v4l2fourcc_to_video_format (guint32 fourcc)
|
||||||
gst_v4l2_object_v4l2fourcc_to_structure (guint32 fourcc)
|
|
||||||
{
|
{
|
||||||
GstStructure *structure = NULL;
|
|
||||||
|
|
||||||
switch (fourcc) {
|
|
||||||
case V4L2_PIX_FMT_MJPEG: /* Motion-JPEG */
|
|
||||||
#ifdef V4L2_PIX_FMT_PJPG
|
|
||||||
case V4L2_PIX_FMT_PJPG: /* Progressive-JPEG */
|
|
||||||
#endif
|
|
||||||
case V4L2_PIX_FMT_JPEG: /* JFIF JPEG */
|
|
||||||
structure = gst_structure_new_empty ("image/jpeg");
|
|
||||||
break;
|
|
||||||
case V4L2_PIX_FMT_YYUV: /* 16 YUV 4:2:2 */
|
|
||||||
case V4L2_PIX_FMT_HI240: /* 8 8-bit color */
|
|
||||||
/* FIXME: get correct fourccs here */
|
|
||||||
break;
|
|
||||||
#ifdef V4L2_PIX_FMT_MPEG4
|
|
||||||
case V4L2_PIX_FMT_MPEG4:
|
|
||||||
structure = gst_structure_new ("video/mpeg",
|
|
||||||
"mpegversion", G_TYPE_INT, 4, "systemstream",
|
|
||||||
G_TYPE_BOOLEAN, FALSE, NULL);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
#ifdef V4L2_PIX_FMT_H263
|
|
||||||
case V4L2_PIX_FMT_H263:
|
|
||||||
structure = gst_structure_new ("video/x-h263",
|
|
||||||
"variant", G_TYPE_STRING, "itu", NULL);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
#ifdef V4L2_PIX_FMT_H264
|
|
||||||
case V4L2_PIX_FMT_H264: /* H.264 */
|
|
||||||
structure = gst_structure_new ("video/x-h264",
|
|
||||||
"stream-format", G_TYPE_STRING, "byte-stream", "alignment",
|
|
||||||
G_TYPE_STRING, "au", NULL);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case V4L2_PIX_FMT_RGB332:
|
|
||||||
case V4L2_PIX_FMT_RGB555X:
|
|
||||||
case V4L2_PIX_FMT_RGB565X:
|
|
||||||
/* FIXME: get correct fourccs here */
|
|
||||||
break;
|
|
||||||
case V4L2_PIX_FMT_GREY: /* 8 Greyscale */
|
|
||||||
case V4L2_PIX_FMT_RGB555:
|
|
||||||
case V4L2_PIX_FMT_RGB565:
|
|
||||||
case V4L2_PIX_FMT_RGB24:
|
|
||||||
case V4L2_PIX_FMT_BGR24:
|
|
||||||
case V4L2_PIX_FMT_RGB32:
|
|
||||||
case V4L2_PIX_FMT_BGR32:
|
|
||||||
case V4L2_PIX_FMT_NV12: /* 12 Y/CbCr 4:2:0 */
|
|
||||||
case V4L2_PIX_FMT_NV12M:
|
|
||||||
case V4L2_PIX_FMT_NV21: /* 12 Y/CrCb 4:2:0 */
|
|
||||||
case V4L2_PIX_FMT_NV21M:
|
|
||||||
case V4L2_PIX_FMT_YVU410:
|
|
||||||
case V4L2_PIX_FMT_YUV410:
|
|
||||||
case V4L2_PIX_FMT_YUV420: /* I420/IYUV */
|
|
||||||
case V4L2_PIX_FMT_YUYV:
|
|
||||||
case V4L2_PIX_FMT_YVU420:
|
|
||||||
case V4L2_PIX_FMT_UYVY:
|
|
||||||
#if 0
|
|
||||||
case V4L2_PIX_FMT_Y41P:
|
|
||||||
#endif
|
|
||||||
case V4L2_PIX_FMT_YUV422P:
|
|
||||||
#ifdef V4L2_PIX_FMT_YVYU
|
|
||||||
case V4L2_PIX_FMT_YVYU:
|
|
||||||
#endif
|
|
||||||
case V4L2_PIX_FMT_YUV411P:{
|
|
||||||
GstVideoFormat format;
|
GstVideoFormat format;
|
||||||
|
|
||||||
switch (fourcc) {
|
switch (fourcc) {
|
||||||
|
@ -1496,6 +1431,79 @@ gst_v4l2_object_v4l2fourcc_to_structure (guint32 fourcc)
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return format;
|
||||||
|
}
|
||||||
|
|
||||||
|
GstStructure *
|
||||||
|
gst_v4l2_object_v4l2fourcc_to_structure (guint32 fourcc)
|
||||||
|
{
|
||||||
|
GstStructure *structure = NULL;
|
||||||
|
|
||||||
|
switch (fourcc) {
|
||||||
|
case V4L2_PIX_FMT_MJPEG: /* Motion-JPEG */
|
||||||
|
#ifdef V4L2_PIX_FMT_PJPG
|
||||||
|
case V4L2_PIX_FMT_PJPG: /* Progressive-JPEG */
|
||||||
|
#endif
|
||||||
|
case V4L2_PIX_FMT_JPEG: /* JFIF JPEG */
|
||||||
|
structure = gst_structure_new_empty ("image/jpeg");
|
||||||
|
break;
|
||||||
|
case V4L2_PIX_FMT_YYUV: /* 16 YUV 4:2:2 */
|
||||||
|
case V4L2_PIX_FMT_HI240: /* 8 8-bit color */
|
||||||
|
/* FIXME: get correct fourccs here */
|
||||||
|
break;
|
||||||
|
#ifdef V4L2_PIX_FMT_MPEG4
|
||||||
|
case V4L2_PIX_FMT_MPEG4:
|
||||||
|
structure = gst_structure_new ("video/mpeg",
|
||||||
|
"mpegversion", G_TYPE_INT, 4, "systemstream",
|
||||||
|
G_TYPE_BOOLEAN, FALSE, NULL);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
#ifdef V4L2_PIX_FMT_H263
|
||||||
|
case V4L2_PIX_FMT_H263:
|
||||||
|
structure = gst_structure_new ("video/x-h263",
|
||||||
|
"variant", G_TYPE_STRING, "itu", NULL);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
#ifdef V4L2_PIX_FMT_H264
|
||||||
|
case V4L2_PIX_FMT_H264: /* H.264 */
|
||||||
|
structure = gst_structure_new ("video/x-h264",
|
||||||
|
"stream-format", G_TYPE_STRING, "byte-stream", "alignment",
|
||||||
|
G_TYPE_STRING, "au", NULL);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
case V4L2_PIX_FMT_RGB332:
|
||||||
|
case V4L2_PIX_FMT_RGB555X:
|
||||||
|
case V4L2_PIX_FMT_RGB565X:
|
||||||
|
/* FIXME: get correct fourccs here */
|
||||||
|
break;
|
||||||
|
case V4L2_PIX_FMT_GREY: /* 8 Greyscale */
|
||||||
|
case V4L2_PIX_FMT_RGB555:
|
||||||
|
case V4L2_PIX_FMT_RGB565:
|
||||||
|
case V4L2_PIX_FMT_RGB24:
|
||||||
|
case V4L2_PIX_FMT_BGR24:
|
||||||
|
case V4L2_PIX_FMT_RGB32:
|
||||||
|
case V4L2_PIX_FMT_BGR32:
|
||||||
|
case V4L2_PIX_FMT_NV12: /* 12 Y/CbCr 4:2:0 */
|
||||||
|
case V4L2_PIX_FMT_NV12M:
|
||||||
|
case V4L2_PIX_FMT_NV21: /* 12 Y/CrCb 4:2:0 */
|
||||||
|
case V4L2_PIX_FMT_NV21M:
|
||||||
|
case V4L2_PIX_FMT_YVU410:
|
||||||
|
case V4L2_PIX_FMT_YUV410:
|
||||||
|
case V4L2_PIX_FMT_YUV420: /* I420/IYUV */
|
||||||
|
case V4L2_PIX_FMT_YUYV:
|
||||||
|
case V4L2_PIX_FMT_YVU420:
|
||||||
|
case V4L2_PIX_FMT_UYVY:
|
||||||
|
#if 0
|
||||||
|
case V4L2_PIX_FMT_Y41P:
|
||||||
|
#endif
|
||||||
|
case V4L2_PIX_FMT_YUV422P:
|
||||||
|
#ifdef V4L2_PIX_FMT_YVYU
|
||||||
|
case V4L2_PIX_FMT_YVYU:
|
||||||
|
#endif
|
||||||
|
case V4L2_PIX_FMT_YUV411P:{
|
||||||
|
GstVideoFormat format;
|
||||||
|
format = gst_v4l2_object_v4l2fourcc_to_video_format (fourcc);
|
||||||
if (format != GST_VIDEO_FORMAT_UNKNOWN)
|
if (format != GST_VIDEO_FORMAT_UNKNOWN)
|
||||||
structure = gst_structure_new ("video/x-raw",
|
structure = gst_structure_new ("video/x-raw",
|
||||||
"format", G_TYPE_STRING, gst_video_format_to_string (format), NULL);
|
"format", G_TYPE_STRING, gst_video_format_to_string (format), NULL);
|
||||||
|
@ -2306,6 +2314,9 @@ gst_v4l2_object_get_nearest_size (GstV4l2Object * v4l2object,
|
||||||
|
|
||||||
fd = v4l2object->video_fd;
|
fd = v4l2object->video_fd;
|
||||||
|
|
||||||
|
memset (&fmt, 0, sizeof (struct v4l2_format));
|
||||||
|
memset (&prevfmt, 0, sizeof (struct v4l2_format));
|
||||||
|
|
||||||
/* Some drivers are buggy and will modify the currently set format
|
/* Some drivers are buggy and will modify the currently set format
|
||||||
when processing VIDIOC_TRY_FMT, so we remember what is set at the
|
when processing VIDIOC_TRY_FMT, so we remember what is set at the
|
||||||
minute, and will reset it when done. */
|
minute, and will reset it when done. */
|
||||||
|
@ -2625,7 +2636,7 @@ gst_v4l2_object_set_format (GstV4l2Object * v4l2object, GstCaps * caps)
|
||||||
v4l2object->sizeimage = 0;
|
v4l2object->sizeimage = 0;
|
||||||
for (i = 0; i < format.fmt.pix_mp.num_planes; i++) {
|
for (i = 0; i < format.fmt.pix_mp.num_planes; i++) {
|
||||||
/* For compatibility reasons with the non-v4l2-multiplanar mode
|
/* For compatibility reasons with the non-v4l2-multiplanar mode
|
||||||
* we have to use the bytesperline of the first v4l plane
|
* we have to use the bytesperline of<F3> the first v4l plane
|
||||||
* See plane_fmt[0] instead of plane_fmt[i] in next line */
|
* See plane_fmt[0] instead of plane_fmt[i] in next line */
|
||||||
v4l2object->bytesperline[i] = format.fmt.pix_mp.plane_fmt[0].bytesperline;
|
v4l2object->bytesperline[i] = format.fmt.pix_mp.plane_fmt[0].bytesperline;
|
||||||
v4l2object->sizeimage += format.fmt.pix_mp.plane_fmt[i].sizeimage;
|
v4l2object->sizeimage += format.fmt.pix_mp.plane_fmt[i].sizeimage;
|
||||||
|
|
|
@ -275,6 +275,7 @@ GstCaps * gst_v4l2_object_get_caps (GstV4l2Object * v4l2object,
|
||||||
GstCaps * filter);
|
GstCaps * filter);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define GST_IMPLEMENT_V4L2_PROBE_METHODS(Type_Class, interface_as_function) \
|
#define GST_IMPLEMENT_V4L2_PROBE_METHODS(Type_Class, interface_as_function) \
|
||||||
\
|
\
|
||||||
static void \
|
static void \
|
||||||
|
|
Loading…
Reference in a new issue