mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-03-07 04:11:26 +00:00
textoverlay: also draw shaded backgrounds for RGB and BGR
https://bugzilla.gnome.org/show_bug.cgi?id=687817
This commit is contained in:
parent
caad241432
commit
bd578c1dd4
1 changed files with 30 additions and 0 deletions
|
@ -1514,6 +1514,32 @@ gst_base_text_overlay_shade_xRGB (GstBaseTextOverlay * overlay,
|
|||
}
|
||||
}
|
||||
|
||||
/* FIXME: orcify */
|
||||
static void
|
||||
gst_base_text_overlay_shade_rgb24 (GstBaseTextOverlay * overlay,
|
||||
GstVideoFrame * frame, gint x0, gint x1, gint y0, gint y1)
|
||||
{
|
||||
const int pstride = 3;
|
||||
gint y, x, stride, shading_val, tmp;
|
||||
guint8 *p;
|
||||
|
||||
shading_val = overlay->shading_value;
|
||||
stride = GST_VIDEO_FRAME_PLANE_STRIDE (frame, 0);
|
||||
|
||||
for (y = y0; y < y1; ++y) {
|
||||
p = GST_VIDEO_FRAME_PLANE_DATA (frame, 0);
|
||||
p += (y * stride) + (x0 * pstride);
|
||||
for (x = x0; x < x1; ++x) {
|
||||
tmp = *p + shading_val;
|
||||
*p++ = CLAMP (tmp, 0, 255);
|
||||
tmp = *p + shading_val;
|
||||
*p++ = CLAMP (tmp, 0, 255);
|
||||
tmp = *p + shading_val;
|
||||
*p++ = CLAMP (tmp, 0, 255);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define ARGB_SHADE_FUNCTION(name, OFFSET) \
|
||||
static inline void \
|
||||
gst_base_text_overlay_shade_##name (GstBaseTextOverlay * overlay, GstVideoFrame * dest, \
|
||||
|
@ -1631,6 +1657,10 @@ gst_base_text_overlay_shade_background (GstBaseTextOverlay * overlay,
|
|||
case GST_VIDEO_FORMAT_BGRA:
|
||||
gst_base_text_overlay_shade_BGRA (overlay, frame, x0, x1, y0, y1);
|
||||
break;
|
||||
case GST_VIDEO_FORMAT_BGR:
|
||||
case GST_VIDEO_FORMAT_RGB:
|
||||
gst_base_text_overlay_shade_rgb24 (overlay, frame, x0, x1, y0, y1);
|
||||
break;
|
||||
default:
|
||||
GST_FIXME_OBJECT (overlay, "implement background shading for format %s",
|
||||
gst_video_format_to_string (GST_VIDEO_FRAME_FORMAT (frame)));
|
||||
|
|
Loading…
Reference in a new issue