gtksink: Add support for xRGB/BGRx

This commit is contained in:
Sebastian Dröge 2015-06-15 20:45:11 +02:00
parent bd9ec0f333
commit 166e33d64c
2 changed files with 14 additions and 6 deletions

View file

@ -52,9 +52,9 @@ static GstFlowReturn gst_gtk_sink_show_frame (GstVideoSink * bsink,
GstBuffer * buf); GstBuffer * buf);
#if G_BYTE_ORDER == G_LITTLE_ENDIAN #if G_BYTE_ORDER == G_LITTLE_ENDIAN
#define FORMATS "BGRA" #define FORMATS "{ BGRx, BGRA }"
#else #else
#define FORMATS "ARGB" #define FORMATS "{ xRGB, ARGB }"
#endif #endif
static GstStaticPadTemplate gst_gtk_sink_template = static GstStaticPadTemplate gst_gtk_sink_template =

View file

@ -124,12 +124,18 @@ gtk_gst_widget_draw (GtkWidget * widget, cairo_t * cr)
gdouble scale_y = gdouble scale_y =
(gdouble) widget_height / gst_widget->priv->display_height; (gdouble) widget_height / gst_widget->priv->display_height;
GstVideoRectangle result; GstVideoRectangle result;
cairo_format_t format;
gst_widget->priv->v_info = frame.info; gst_widget->priv->v_info = frame.info;
if (frame.info.finfo->format == GST_VIDEO_FORMAT_ARGB ||
frame.info.finfo->format == GST_VIDEO_FORMAT_BGRA) {
format = CAIRO_FORMAT_ARGB32;
} else {
format = CAIRO_FORMAT_RGB24;
}
surface = cairo_image_surface_create_for_data (frame.data[0], surface = cairo_image_surface_create_for_data (frame.data[0],
CAIRO_FORMAT_ARGB32, frame.info.width, frame.info.height, format, frame.info.width, frame.info.height, frame.info.stride[0]);
frame.info.stride[0]);
if (gst_widget->priv->force_aspect_ratio) { if (gst_widget->priv->force_aspect_ratio) {
GstVideoRectangle src, dst; GstVideoRectangle src, dst;
@ -433,10 +439,12 @@ gtk_gst_widget_set_caps (GtkGstWidget * widget, GstCaps * caps)
/* FIXME: support other formats */ /* FIXME: support other formats */
#if G_BYTE_ORDER == G_LITTLE_ENDIAN #if G_BYTE_ORDER == G_LITTLE_ENDIAN
g_return_val_if_fail (GST_VIDEO_INFO_FORMAT (&v_info) == g_return_val_if_fail (GST_VIDEO_INFO_FORMAT (&v_info) ==
GST_VIDEO_FORMAT_BGRA, FALSE); GST_VIDEO_FORMAT_BGRA || GST_VIDEO_INFO_FORMAT (&v_info) ==
GST_VIDEO_FORMAT_BGRx, FALSE);
#else #else
g_return_val_if_fail (GST_VIDEO_INFO_FORMAT (&v_info) == g_return_val_if_fail (GST_VIDEO_INFO_FORMAT (&v_info) ==
GST_VIDEO_FORMAT_ARGB, FALSE); GST_VIDEO_FORMAT_ARGB || GST_VIDEO_INFO_FORMAT (&v_info) ==
GST_VIDEO_FORMAT_xRGB, FALSE);
#endif #endif
g_mutex_lock (&widget->priv->lock); g_mutex_lock (&widget->priv->lock);