y4m: support more color formats

These are unofficial yuv4mpegpipe formats, but used for 10bit streams.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8719>
This commit is contained in:
Víctor Manuel Jáquez Leal 2025-04-27 07:06:11 +02:00 committed by GStreamer Marge Bot
parent 1b023dee2e
commit 7a14b9020c
5 changed files with 66 additions and 9 deletions

View File

@ -29633,7 +29633,7 @@
"presence": "always"
},
"src": {
"caps": "video/x-raw:\n format: { I420, Y41B, Y42B, Y444, I420_10LE, I422_10LE, Y444_10LE, I420_12LE, I422_12LE, Y444_12LE, Y444_16LE, GRAY8, GRAY16_LE }\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\n framerate: [ 0/1, 2147483647/1 ]\n",
"caps": "video/x-raw:\n format: { I420, Y42B, Y41B, Y444, A444, GRAY8, I420_12LE, I422_12LE, Y444_12LE, I420_10LE, I422_10LE, Y444_10LE, GRAY10_LE16, GRAY16_LE }\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\n framerate: [ 0/1, 2147483647/1 ]\n",
"direction": "src",
"presence": "always"
}
@ -29657,7 +29657,7 @@
"klass": "Codec/Encoder/Video",
"pad-templates": {
"sink": {
"caps": "video/x-raw:\n format: { IYUV, I420, Y42B, Y41B, Y444 }\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\n framerate: [ 0/1, 2147483647/1 ]\n",
"caps": "video/x-raw:\n format: { I420, Y42B, Y41B, Y444, A444, GRAY8, I420_12LE, I422_12LE, Y444_12LE, I420_10LE, I422_10LE, Y444_10LE, GRAY10_LE16, GRAY16_LE }\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\n framerate: [ 0/1, 2147483647/1 ]\n",
"direction": "sink",
"presence": "always"
},

View File

@ -77,12 +77,7 @@ static GstStaticPadTemplate gst_y4m_dec_src_template =
GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("{ \
I420,Y41B,Y42B,Y444, \
I420_10LE,I422_10LE,Y444_10LE, \
I420_12LE,I422_12LE,Y444_12LE, \
Y444_16LE,GRAY8,GRAY16_LE \
}")));
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE (Y4M_VIDEO_FORMATS)));
/* class initialization */
#define gst_y4m_dec_parent_class parent_class

View File

@ -68,7 +68,7 @@ static GstStaticPadTemplate y4mencode_sink_factory =
GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE ("{ IYUV, I420, Y42B, Y41B, Y444 }"))
GST_STATIC_CAPS (GST_VIDEO_CAPS_MAKE (Y4M_VIDEO_FORMATS))
);
GST_DEBUG_CATEGORY (y4menc_debug);

View File

@ -83,8 +83,65 @@ gst_y4m_video_unpadded_info (GstVideoInfo * y4m_info,
out_info.offset[2] = out_info.offset[1] * 2;
out_info.size = out_info.stride[0] * height * 3;
break;
case GST_VIDEO_FORMAT_GRAY8:
out_info.stride[0] = width;
out_info.stride[1] = 0;
out_info.offset[0] = 0;
out_info.size = width * height;
break;
case GST_VIDEO_FORMAT_GRAY16_LE:
case GST_VIDEO_FORMAT_GRAY10_LE16:
out_info.stride[0] = width * 2;
out_info.offset[0] = 0;
out_info.size = out_info.stride[0] * height;
break;
case GST_VIDEO_FORMAT_A444:
out_info.stride[0] = width;
out_info.stride[1] = out_info.stride[0];
out_info.stride[2] = out_info.stride[0];
out_info.stride[3] = out_info.stride[0];
out_info.offset[0] = 0;
out_info.offset[1] = out_info.stride[0] * height;
out_info.offset[2] = out_info.offset[1] + out_info.stride[1] * height;
out_info.offset[3] = out_info.offset[2] + out_info.stride[2] * height;
out_info.size = out_info.offset[3] + out_info.stride[0] * height;
break;
case GST_VIDEO_FORMAT_I420_10LE:
case GST_VIDEO_FORMAT_I420_12LE:
out_info.stride[0] = width * 2;
out_info.stride[1] = width;
out_info.stride[2] = out_info.stride[1];
out_info.offset[0] = 0;
out_info.offset[1] = out_info.stride[0] * height;
cr_h = GST_ROUND_UP_2 (height) / 2;
if (GST_VIDEO_INFO_IS_INTERLACED (vinfo))
cr_h = GST_ROUND_UP_2 (cr_h);
out_info.offset[2] = out_info.offset[1] + out_info.stride[1] * cr_h;
out_info.size = out_info.offset[2] + out_info.stride[2] * cr_h;
break;
case GST_VIDEO_FORMAT_I422_10LE:
case GST_VIDEO_FORMAT_I422_12LE:
out_info.stride[0] = width * 2;
out_info.stride[1] = width;
out_info.stride[2] = out_info.stride[1];
out_info.offset[0] = 0;
out_info.offset[1] = out_info.stride[0] * height;
out_info.offset[2] = out_info.offset[1] + out_info.stride[1] * height;
out_info.size = out_info.offset[2] + out_info.stride[2] * height;
break;
case GST_VIDEO_FORMAT_Y444_10LE:
case GST_VIDEO_FORMAT_Y444_12LE:
out_info.stride[0] = width * 2;
out_info.stride[1] = out_info.stride[0];
out_info.stride[2] = out_info.stride[0];
out_info.offset[0] = 0;
out_info.offset[1] = out_info.stride[0] * height;
out_info.offset[2] = out_info.offset[1] * 2;
out_info.size = out_info.stride[0] * height * 3;
break;
default:
GST_FIXME ("%s is not supported", gst_video_format_to_string (format));
return FALSE;
}
*y4m_info = out_info;

View File

@ -23,6 +23,11 @@
#include <gst/gst.h>
#include <gst/video/video.h>
#define Y4M_VIDEO_FORMATS "{ " \
"I420, Y42B, Y41B, Y444, A444, GRAY8, I420_12LE, I422_12LE, " \
"Y444_12LE, I420_10LE, I422_10LE, Y444_10LE, GRAY10_LE16, GRAY16_LE " \
"}"
gboolean gst_y4m_video_unpadded_info (GstVideoInfo * y4m_info,
const GstVideoInfo * vinfo);