static void gst_gdk_pixbuf_overlay_update_composition (GstGdkPixbufOverlay * overlay) { GstVideoOverlayComposition *comp; GstVideoOverlayRectangle *rect; GstVideoMeta *overlay_meta; gint x, y, width, height; gint video_width = GST_VIDEO_INFO_WIDTH (&GST_VIDEO_FILTER (overlay)->in_info); gint video_height = GST_VIDEO_INFO_HEIGHT (&GST_VIDEO_FILTER (overlay)->in_info); if (overlay->comp) { gst_video_overlay_composition_unref (overlay->comp); overlay->comp = NULL; } if (overlay->alpha == 0.0 || overlay->pixels == NULL) return; overlay_meta = gst_buffer_get_video_meta (overlay->pixels); x = overlay->offset_x < 0 ? video_width + overlay->offset_x - overlay_meta->width + (overlay->relative_x * overlay_meta->width) : overlay->offset_x + (overlay->relative_x * overlay_meta->width); y = overlay->offset_y < 0 ? video_height + overlay->offset_y - overlay_meta->height + (overlay->relative_y * overlay_meta->height) : overlay->offset_y + (overlay->relative_y * overlay_meta->height); width = overlay->overlay_width; if (width == 0) width = overlay_meta->width; height = overlay->overlay_height; if (height == 0) height = overlay_meta->height; GST_DEBUG_OBJECT (overlay, "overlay image dimensions: %d x %d, alpha=%.2f", overlay_meta->width, overlay_meta->height, overlay->alpha); GST_DEBUG_OBJECT (overlay, "properties: x,y: %d,%d (%g%%,%g%%) - WxH: %dx%d", overlay->offset_x, overlay->offset_y, overlay->relative_x * 100.0, overlay->relative_y * 100.0, overlay->overlay_height, overlay->overlay_width); GST_DEBUG_OBJECT (overlay, "overlay rendered: %d x %d @ %d,%d (onto %d x %d)", width, height, x, y, video_width, video_height); rect = gst_video_overlay_rectangle_new_raw (overlay->pixels, x, y, width, height, GST_VIDEO_OVERLAY_FORMAT_FLAG_NONE); if (overlay->alpha != 1.0) gst_video_overlay_rectangle_set_global_alpha (rect, overlay->alpha); comp = gst_video_overlay_composition_new (rect); gst_video_overlay_rectangle_unref (rect); overlay->comp = comp; }
static void gst_gdk_pixbuf_overlay_update_composition (GstGdkPixbufOverlay * overlay) { GstVideoOverlayComposition *comp; GstVideoOverlayRectangle *rect; gint x, y, width, height; if (overlay->comp) { gst_video_overlay_composition_unref (overlay->comp); overlay->comp = NULL; } if (overlay->alpha == 0.0) return; x = overlay->offset_x + (overlay->relative_x * overlay->pixels_width); y = overlay->offset_y + (overlay->relative_y * overlay->pixels_height); /* FIXME: this should work, but seems to crash */ if (x < 0) x = 0; if (y < 0) y = 0; width = overlay->overlay_width; if (width == 0) width = overlay->pixels_width; height = overlay->overlay_height; if (height == 0) height = overlay->pixels_height; GST_DEBUG_OBJECT (overlay, "overlay image dimensions: %d x %d, alpha=%.2f", overlay->pixels_width, overlay->pixels_height, overlay->alpha); GST_DEBUG_OBJECT (overlay, "properties: x,y: %d,%d (%g%%,%g%%) - WxH: %dx%d", overlay->offset_x, overlay->offset_y, overlay->relative_x * 100.0, overlay->relative_y * 100.0, overlay->overlay_height, overlay->overlay_width); GST_DEBUG_OBJECT (overlay, "overlay rendered: %d x %d @ %d,%d (onto %d x %d)", width, height, x, y, overlay->width, overlay->height); rect = gst_video_overlay_rectangle_new_argb (overlay->pixels, overlay->pixels_width, overlay->pixels_height, overlay->pixels_stride, x, y, width, height, GST_VIDEO_OVERLAY_FORMAT_FLAG_NONE); if (overlay->alpha != 1.0) gst_video_overlay_rectangle_set_global_alpha (rect, overlay->alpha); comp = gst_video_overlay_composition_new (rect); gst_video_overlay_rectangle_unref (rect); overlay->comp = comp; }