mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 05:16:13 +00:00
alphacolor: Use libgstvideo for caps parsing
This commit is contained in:
parent
751b293df8
commit
8cbb9608f9
2 changed files with 11 additions and 30 deletions
|
@ -157,39 +157,21 @@ gst_alpha_color_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
|
||||||
GstCaps * outcaps)
|
GstCaps * outcaps)
|
||||||
{
|
{
|
||||||
GstAlphaColor *alpha = GST_ALPHA_COLOR (btrans);
|
GstAlphaColor *alpha = GST_ALPHA_COLOR (btrans);
|
||||||
GstStructure *structure;
|
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
const GValue *fps;
|
gint w, h;
|
||||||
gint red_mask, alpha_mask;
|
GstVideoFormat format;
|
||||||
gint w, h, depth, bpp;
|
|
||||||
|
|
||||||
structure = gst_caps_get_structure (incaps, 0);
|
ret = gst_video_format_parse_caps (outcaps, &format, &w, &h);
|
||||||
|
|
||||||
ret = gst_structure_get_int (structure, "width", &w);
|
if (!ret || (format != GST_VIDEO_FORMAT_ARGB
|
||||||
ret &= gst_structure_get_int (structure, "height", &h);
|
&& format != GST_VIDEO_FORMAT_BGRA)) {
|
||||||
fps = gst_structure_get_value (structure, "framerate");
|
|
||||||
ret &= (fps != NULL && GST_VALUE_HOLDS_FRACTION (fps));
|
|
||||||
ret &= gst_structure_get_int (structure, "red_mask", &red_mask);
|
|
||||||
|
|
||||||
/* make sure these are really full RGBA caps */
|
|
||||||
ret &= gst_structure_get_int (structure, "alpha_mask", &alpha_mask);
|
|
||||||
ret &= gst_structure_get_int (structure, "depth", &depth);
|
|
||||||
ret &= gst_structure_get_int (structure, "bpp", &bpp);
|
|
||||||
|
|
||||||
if (!ret || alpha_mask == 0 || red_mask == 0 || depth != 32 || bpp != 32) {
|
|
||||||
GST_DEBUG_OBJECT (alpha, "incomplete or non-RGBA input caps!");
|
GST_DEBUG_OBJECT (alpha, "incomplete or non-RGBA input caps!");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
alpha->in_width = w;
|
alpha->format = format;
|
||||||
alpha->in_height = h;
|
alpha->width = w;
|
||||||
alpha->in_rgba = TRUE;
|
alpha->height = h;
|
||||||
#if (G_BYTE_ORDER == G_BIG_ENDIAN)
|
|
||||||
if (red_mask != 0x000000ff)
|
|
||||||
#else
|
|
||||||
if (red_mask != 0xff000000)
|
|
||||||
#endif
|
|
||||||
alpha->in_rgba = FALSE;
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -241,7 +223,7 @@ gst_alpha_color_transform_ip (GstBaseTransform * btrans, GstBuffer * inbuf)
|
||||||
GstAlphaColor *alpha = GST_ALPHA_COLOR (btrans);
|
GstAlphaColor *alpha = GST_ALPHA_COLOR (btrans);
|
||||||
|
|
||||||
/* Transform in place */
|
/* Transform in place */
|
||||||
if (alpha->in_rgba)
|
if (alpha->format == GST_VIDEO_FORMAT_ARGB)
|
||||||
transform_rgb (GST_BUFFER_DATA (inbuf), GST_BUFFER_SIZE (inbuf));
|
transform_rgb (GST_BUFFER_DATA (inbuf), GST_BUFFER_SIZE (inbuf));
|
||||||
else
|
else
|
||||||
transform_bgr (GST_BUFFER_DATA (inbuf), GST_BUFFER_SIZE (inbuf));
|
transform_bgr (GST_BUFFER_DATA (inbuf), GST_BUFFER_SIZE (inbuf));
|
||||||
|
|
|
@ -43,9 +43,8 @@ struct _GstAlphaColor
|
||||||
|
|
||||||
/*< private >*/
|
/*< private >*/
|
||||||
/* caps */
|
/* caps */
|
||||||
gint in_width, in_height;
|
GstVideoFormat format;
|
||||||
gboolean in_rgba;
|
gint width, height;
|
||||||
gint out_width, out_height;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstAlphaColorClass
|
struct _GstAlphaColorClass
|
||||||
|
|
Loading…
Reference in a new issue