overlay->outline_offset = MINIMUM_OUTLINE_OFFSET;
}
-#define CAIRO_UNPREMULTIPLY(a,r,g,b) G_STMT_START { \
- *b = (a > 0) ? MIN ((*b * 255 + a / 2) / a, 255) : 0; \
- *g = (a > 0) ? MIN ((*g * 255 + a / 2) / a, 255) : 0; \
- *r = (a > 0) ? MIN ((*r * 255 + a / 2) / a, 255) : 0; \
-} G_STMT_END
-
static void
gst_base_text_overlay_get_pos (GstBaseTextOverlay * overlay,
gint * xpos, gint * ypos)
*ypos += overlay->deltay;
}
-static inline void
-gst_base_text_overlay_unpremultiply (GstBaseTextOverlay * overlay)
-{
- guint i, j;
- guint8 *pimage, *text_image;
- GstMapInfo map;
-
- gst_buffer_map (overlay->text_image, &map, GST_MAP_READ);
- text_image = map.data;
- for (i = 0; i < overlay->image_height; i++) {
- pimage = text_image + 4 * (i * overlay->image_width);
- for (j = 0; j < overlay->image_width; j++) {
- CAIRO_UNPREMULTIPLY (pimage[CAIRO_ARGB_A], &pimage[CAIRO_ARGB_R],
- &pimage[CAIRO_ARGB_G], &pimage[CAIRO_ARGB_B]);
-
- pimage += 4;
- }
- }
- gst_buffer_unmap (overlay->text_image, &map);
-}
-
static inline void
gst_base_text_overlay_set_composition (GstBaseTextOverlay * overlay)
{
rectangle = gst_video_overlay_rectangle_new_argb (overlay->text_image,
overlay->image_width, overlay->image_height, 4 * overlay->image_width,
xpos, ypos, overlay->image_width, overlay->image_height,
- GST_VIDEO_OVERLAY_FORMAT_FLAG_NONE);
+ GST_VIDEO_OVERLAY_FORMAT_FLAG_PREMULTIPLIED_ALPHA);
if (overlay->composition)
gst_video_overlay_composition_unref (overlay->composition);
overlay->baseline_y = ink_rect.y;
g_mutex_unlock (GST_BASE_TEXT_OVERLAY_GET_CLASS (overlay)->pango_lock);
- /* As the GstVideoOverlayComposition supports only unpremultiply ARGB,
- * we need to unpremultiply it */
- gst_base_text_overlay_unpremultiply (overlay);
gst_base_text_overlay_set_composition (overlay);
}