mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-13 22:10:08 +00:00
gtksink: Add colorstate handling
The part for matrix coefficients and range is commented out so far. It requires fixes so the dmabuf handling code can properly deal with it.
This commit is contained in:
parent
fb10b61528
commit
b1962de51a
@ -166,6 +166,33 @@ add_drm_formats_and_modifiers (GstCaps *caps,
|
||||
}
|
||||
#endif
|
||||
|
||||
static GdkColorState *
|
||||
gtk_gst_color_state_from_colorimetry (GtkGstSink *self,
|
||||
const GstVideoColorimetry *colorimetry)
|
||||
{
|
||||
GdkCicpParams *params;
|
||||
GdkColorState *color_state;
|
||||
GError *error = NULL;
|
||||
|
||||
params = gdk_cicp_params_new ();
|
||||
gdk_cicp_params_set_color_primaries (params, gst_video_color_primaries_to_iso (colorimetry->primaries));
|
||||
gdk_cicp_params_set_transfer_function (params, gst_video_transfer_function_to_iso (colorimetry->transfer));
|
||||
#if 0
|
||||
gdk_cicp_params_set_matrix_coefficients (params, gst_video_color_matrix_to_iso (colorimetry->matrix));
|
||||
gdk_cicp_params_set_full_range (params, colorimetry->range == GST_VIDEO_COLOR_RANGE_0_255);
|
||||
#endif
|
||||
color_state = gdk_cicp_params_build_color_state (params, &error);
|
||||
g_object_unref (params);
|
||||
|
||||
if (color_state == NULL)
|
||||
{
|
||||
GST_ERROR_OBJECT (self, "Could not create GDK colorstate for given colorimetry: %s", error->message);
|
||||
g_clear_error (&error);
|
||||
}
|
||||
|
||||
return color_state;
|
||||
}
|
||||
|
||||
static GstCaps *
|
||||
gtk_gst_sink_get_caps (GstBaseSink *bsink,
|
||||
GstCaps *filter)
|
||||
@ -237,6 +264,11 @@ gtk_gst_sink_set_caps (GstBaseSink *bsink,
|
||||
}
|
||||
#endif
|
||||
|
||||
g_clear_pointer (&self->color_state, gdk_color_state_unref);
|
||||
self->color_state = gtk_gst_color_state_from_colorimetry (self, &self->v_info.colorimetry);
|
||||
if (self->color_state == NULL)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -398,6 +430,7 @@ gtk_gst_sink_texture_from_buffer (GtkGstSink *self,
|
||||
gdk_dmabuf_texture_builder_set_width (builder, vmeta->width);
|
||||
gdk_dmabuf_texture_builder_set_height (builder, vmeta->height);
|
||||
gdk_dmabuf_texture_builder_set_n_planes (builder, vmeta->n_planes);
|
||||
gdk_dmabuf_texture_builder_set_color_state (builder, self->color_state);
|
||||
|
||||
for (i = 0; i < vmeta->n_planes; i++)
|
||||
{
|
||||
@ -459,6 +492,7 @@ gtk_gst_sink_texture_from_buffer (GtkGstSink *self,
|
||||
gdk_gl_texture_builder_set_width (builder, frame->info.width);
|
||||
gdk_gl_texture_builder_set_height (builder, frame->info.height);
|
||||
gdk_gl_texture_builder_set_sync (builder, sync_meta ? sync_meta->data : NULL);
|
||||
gdk_gl_texture_builder_set_color_state (builder, self->color_state);
|
||||
|
||||
texture = gdk_gl_texture_builder_build (builder,
|
||||
(GDestroyNotify) video_frame_free,
|
||||
@ -782,6 +816,7 @@ gtk_gst_sink_dispose (GObject *object)
|
||||
{
|
||||
GtkGstSink *self = GTK_GST_SINK (object);
|
||||
|
||||
g_clear_object (&self->color_state);
|
||||
g_clear_object (&self->paintable);
|
||||
g_clear_object (&self->gst_gdk_context);
|
||||
g_clear_object (&self->gst_display);
|
||||
|
@ -56,6 +56,7 @@ struct _GtkGstSink
|
||||
GstGLDisplay * gst_display;
|
||||
GstGLContext * gst_gdk_context;
|
||||
GstGLContext * gst_context;
|
||||
GdkColorState * color_state;
|
||||
};
|
||||
|
||||
struct _GtkGstSinkClass
|
||||
|
Loading…
Reference in New Issue
Block a user