mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-25 09:40:37 +00:00
videobox: Add support for YV12, including conversion support for I420/AYUV
This commit is contained in:
parent
b4e3532c1f
commit
4e277ebe7b
1 changed files with 27 additions and 18 deletions
|
@ -211,19 +211,17 @@ copy_ayuv_i420 (guint i_alpha, GstVideoFormat dest_format, guint8 * dest,
|
||||||
gint widthY, widthUV;
|
gint widthY, widthUV;
|
||||||
gint hY, hUV;
|
gint hY, hUV;
|
||||||
|
|
||||||
dest_strideY =
|
dest_strideY = gst_video_format_get_row_stride (dest_format, 0, dest_width);
|
||||||
gst_video_format_get_row_stride (GST_VIDEO_FORMAT_I420, 0, dest_width);
|
dest_strideUV = gst_video_format_get_row_stride (dest_format, 1, dest_width);
|
||||||
dest_strideUV =
|
|
||||||
gst_video_format_get_row_stride (GST_VIDEO_FORMAT_I420, 1, dest_width);
|
|
||||||
|
|
||||||
destY =
|
destY =
|
||||||
dest + gst_video_format_get_component_offset (GST_VIDEO_FORMAT_I420, 0,
|
dest + gst_video_format_get_component_offset (dest_format, 0,
|
||||||
dest_width, dest_height);
|
dest_width, dest_height);
|
||||||
destU =
|
destU =
|
||||||
dest + gst_video_format_get_component_offset (GST_VIDEO_FORMAT_I420, 1,
|
dest + gst_video_format_get_component_offset (dest_format, 1,
|
||||||
dest_width, dest_height);
|
dest_width, dest_height);
|
||||||
destV =
|
destV =
|
||||||
dest + gst_video_format_get_component_offset (GST_VIDEO_FORMAT_I420, 2,
|
dest + gst_video_format_get_component_offset (dest_format, 2,
|
||||||
dest_width, dest_height);
|
dest_width, dest_height);
|
||||||
|
|
||||||
destY = destY + dest_y * dest_strideY + dest_x;
|
destY = destY + dest_y * dest_strideY + dest_x;
|
||||||
|
@ -407,11 +405,9 @@ fill_i420 (GstVideoBoxFill fill_type, guint b_alpha, GstVideoFormat format,
|
||||||
dest + gst_video_format_get_component_offset (GST_VIDEO_FORMAT_I420, 0,
|
dest + gst_video_format_get_component_offset (GST_VIDEO_FORMAT_I420, 0,
|
||||||
width, height);
|
width, height);
|
||||||
destU =
|
destU =
|
||||||
dest + gst_video_format_get_component_offset (GST_VIDEO_FORMAT_I420, 1,
|
dest + gst_video_format_get_component_offset (format, 1, width, height);
|
||||||
width, height);
|
|
||||||
destV =
|
destV =
|
||||||
dest + gst_video_format_get_component_offset (GST_VIDEO_FORMAT_I420, 2,
|
dest + gst_video_format_get_component_offset (format, 2, width, height);
|
||||||
width, height);
|
|
||||||
|
|
||||||
heightY =
|
heightY =
|
||||||
gst_video_format_get_component_height (GST_VIDEO_FORMAT_I420, 0, height);
|
gst_video_format_get_component_height (GST_VIDEO_FORMAT_I420, 0, height);
|
||||||
|
@ -451,20 +447,20 @@ copy_i420_i420 (guint i_alpha, GstVideoFormat dest_format, guint8 * dest,
|
||||||
dest + gst_video_format_get_component_offset (GST_VIDEO_FORMAT_I420, 0,
|
dest + gst_video_format_get_component_offset (GST_VIDEO_FORMAT_I420, 0,
|
||||||
dest_width, dest_height);
|
dest_width, dest_height);
|
||||||
destU =
|
destU =
|
||||||
dest + gst_video_format_get_component_offset (GST_VIDEO_FORMAT_I420, 1,
|
dest + gst_video_format_get_component_offset (dest_format, 1,
|
||||||
dest_width, dest_height);
|
dest_width, dest_height);
|
||||||
destV =
|
destV =
|
||||||
dest + gst_video_format_get_component_offset (GST_VIDEO_FORMAT_I420, 2,
|
dest + gst_video_format_get_component_offset (dest_format, 2,
|
||||||
dest_width, dest_height);
|
dest_width, dest_height);
|
||||||
|
|
||||||
srcY =
|
srcY =
|
||||||
src + gst_video_format_get_component_offset (GST_VIDEO_FORMAT_I420, 0,
|
src + gst_video_format_get_component_offset (GST_VIDEO_FORMAT_I420, 0,
|
||||||
src_width, src_height);
|
src_width, src_height);
|
||||||
srcU =
|
srcU =
|
||||||
src + gst_video_format_get_component_offset (GST_VIDEO_FORMAT_I420, 1,
|
src + gst_video_format_get_component_offset (src_format, 1,
|
||||||
src_width, src_height);
|
src_width, src_height);
|
||||||
srcV =
|
srcV =
|
||||||
src + gst_video_format_get_component_offset (GST_VIDEO_FORMAT_I420, 2,
|
src + gst_video_format_get_component_offset (src_format, 2,
|
||||||
src_width, src_height);
|
src_width, src_height);
|
||||||
|
|
||||||
|
|
||||||
|
@ -587,10 +583,10 @@ copy_i420_ayuv (guint i_alpha, GstVideoFormat dest_format, guint8 * dest,
|
||||||
src + gst_video_format_get_component_offset (GST_VIDEO_FORMAT_I420, 0,
|
src + gst_video_format_get_component_offset (GST_VIDEO_FORMAT_I420, 0,
|
||||||
src_width, src_height);
|
src_width, src_height);
|
||||||
srcU =
|
srcU =
|
||||||
src + gst_video_format_get_component_offset (GST_VIDEO_FORMAT_I420, 1,
|
src + gst_video_format_get_component_offset (src_format, 1,
|
||||||
src_width, src_height);
|
src_width, src_height);
|
||||||
srcV =
|
srcV =
|
||||||
src + gst_video_format_get_component_offset (GST_VIDEO_FORMAT_I420, 2,
|
src + gst_video_format_get_component_offset (src_format, 2,
|
||||||
src_width, src_height);
|
src_width, src_height);
|
||||||
|
|
||||||
|
|
||||||
|
@ -1190,6 +1186,7 @@ static GstStaticPadTemplate gst_video_box_src_template =
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("AYUV") ";"
|
GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("AYUV") ";"
|
||||||
GST_VIDEO_CAPS_YUV ("I420") ";"
|
GST_VIDEO_CAPS_YUV ("I420") ";"
|
||||||
|
GST_VIDEO_CAPS_YUV ("YV12") ";"
|
||||||
GST_VIDEO_CAPS_xRGB ";" GST_VIDEO_CAPS_BGRx ";"
|
GST_VIDEO_CAPS_xRGB ";" GST_VIDEO_CAPS_BGRx ";"
|
||||||
GST_VIDEO_CAPS_xBGR ";" GST_VIDEO_CAPS_RGBx ";"
|
GST_VIDEO_CAPS_xBGR ";" GST_VIDEO_CAPS_RGBx ";"
|
||||||
GST_VIDEO_CAPS_ARGB ";" GST_VIDEO_CAPS_BGRA ";"
|
GST_VIDEO_CAPS_ARGB ";" GST_VIDEO_CAPS_BGRA ";"
|
||||||
|
@ -1206,6 +1203,7 @@ static GstStaticPadTemplate gst_video_box_sink_template =
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("AYUV") ";"
|
GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("AYUV") ";"
|
||||||
GST_VIDEO_CAPS_YUV ("I420") ";"
|
GST_VIDEO_CAPS_YUV ("I420") ";"
|
||||||
|
GST_VIDEO_CAPS_YUV ("YV12") ";"
|
||||||
GST_VIDEO_CAPS_xRGB ";" GST_VIDEO_CAPS_BGRx ";"
|
GST_VIDEO_CAPS_xRGB ";" GST_VIDEO_CAPS_BGRx ";"
|
||||||
GST_VIDEO_CAPS_xBGR ";" GST_VIDEO_CAPS_RGBx ";"
|
GST_VIDEO_CAPS_xBGR ";" GST_VIDEO_CAPS_RGBx ";"
|
||||||
GST_VIDEO_CAPS_ARGB ";" GST_VIDEO_CAPS_BGRA ";"
|
GST_VIDEO_CAPS_ARGB ";" GST_VIDEO_CAPS_BGRA ";"
|
||||||
|
@ -1590,7 +1588,11 @@ gst_video_box_transform_caps (GstBaseTransform * trans,
|
||||||
|
|
||||||
/* Supported conversions:
|
/* Supported conversions:
|
||||||
* I420->AYUV
|
* I420->AYUV
|
||||||
|
* I420->YV12
|
||||||
|
* YV12->AYUV
|
||||||
|
* YV12->I420
|
||||||
* AYUV->I420
|
* AYUV->I420
|
||||||
|
* AYUV->YV12
|
||||||
* AYUV->xRGB (24bpp, 32bpp, incl. alpha)
|
* AYUV->xRGB (24bpp, 32bpp, incl. alpha)
|
||||||
* xRGB->xRGB (24bpp, 32bpp, from/to all variants, incl. alpha)
|
* xRGB->xRGB (24bpp, 32bpp, from/to all variants, incl. alpha)
|
||||||
* xRGB->AYUV (24bpp, 32bpp, incl. alpha)
|
* xRGB->AYUV (24bpp, 32bpp, incl. alpha)
|
||||||
|
@ -1603,7 +1605,8 @@ gst_video_box_transform_caps (GstBaseTransform * trans,
|
||||||
|
|
||||||
if (gst_structure_get_fourcc (structure, "format", &fourcc) &&
|
if (gst_structure_get_fourcc (structure, "format", &fourcc) &&
|
||||||
(fourcc == GST_STR_FOURCC ("AYUV") ||
|
(fourcc == GST_STR_FOURCC ("AYUV") ||
|
||||||
fourcc == GST_STR_FOURCC ("I420"))) {
|
fourcc == GST_STR_FOURCC ("I420") ||
|
||||||
|
fourcc == GST_STR_FOURCC ("YV12"))) {
|
||||||
GValue list = { 0, };
|
GValue list = { 0, };
|
||||||
GValue val = { 0, };
|
GValue val = { 0, };
|
||||||
GstStructure *s2;
|
GstStructure *s2;
|
||||||
|
@ -1622,6 +1625,9 @@ gst_video_box_transform_caps (GstBaseTransform * trans,
|
||||||
g_value_reset (&val);
|
g_value_reset (&val);
|
||||||
gst_value_set_fourcc (&val, GST_STR_FOURCC ("I420"));
|
gst_value_set_fourcc (&val, GST_STR_FOURCC ("I420"));
|
||||||
gst_value_list_append_value (&list, &val);
|
gst_value_list_append_value (&list, &val);
|
||||||
|
g_value_reset (&val);
|
||||||
|
gst_value_set_fourcc (&val, GST_STR_FOURCC ("YV12"));
|
||||||
|
gst_value_list_append_value (&list, &val);
|
||||||
g_value_unset (&val);
|
g_value_unset (&val);
|
||||||
gst_structure_set_value (structure, "format", &list);
|
gst_structure_set_value (structure, "format", &list);
|
||||||
g_value_unset (&list);
|
g_value_unset (&list);
|
||||||
|
@ -1725,6 +1731,7 @@ gst_video_box_select_processing_functions (GstVideoBox * video_box)
|
||||||
video_box->copy = copy_ayuv_ayuv;
|
video_box->copy = copy_ayuv_ayuv;
|
||||||
break;
|
break;
|
||||||
case GST_VIDEO_FORMAT_I420:
|
case GST_VIDEO_FORMAT_I420:
|
||||||
|
case GST_VIDEO_FORMAT_YV12:
|
||||||
video_box->copy = copy_i420_ayuv;
|
video_box->copy = copy_i420_ayuv;
|
||||||
break;
|
break;
|
||||||
case GST_VIDEO_FORMAT_ARGB:
|
case GST_VIDEO_FORMAT_ARGB:
|
||||||
|
@ -1744,12 +1751,14 @@ gst_video_box_select_processing_functions (GstVideoBox * video_box)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GST_VIDEO_FORMAT_I420:
|
case GST_VIDEO_FORMAT_I420:
|
||||||
|
case GST_VIDEO_FORMAT_YV12:
|
||||||
video_box->fill = fill_i420;
|
video_box->fill = fill_i420;
|
||||||
switch (video_box->in_format) {
|
switch (video_box->in_format) {
|
||||||
case GST_VIDEO_FORMAT_AYUV:
|
case GST_VIDEO_FORMAT_AYUV:
|
||||||
video_box->copy = copy_ayuv_i420;
|
video_box->copy = copy_ayuv_i420;
|
||||||
break;
|
break;
|
||||||
case GST_VIDEO_FORMAT_I420:
|
case GST_VIDEO_FORMAT_I420:
|
||||||
|
case GST_VIDEO_FORMAT_YV12:
|
||||||
video_box->copy = copy_i420_i420;
|
video_box->copy = copy_i420_i420;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in a new issue