mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-21 07:46:38 +00:00
textoverlay: move background shading into separate function
This commit is contained in:
parent
a4cfe8c43c
commit
4aace8e0eb
1 changed files with 51 additions and 62 deletions
|
@ -1598,11 +1598,55 @@ gst_base_text_overlay_render_text (GstBaseTextOverlay * overlay,
|
||||||
overlay->need_render = FALSE;
|
overlay->need_render = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_base_text_overlay_shade_background (GstBaseTextOverlay * overlay,
|
||||||
|
GstVideoFrame * frame, gint x0, gint x1, gint y0, gint y1)
|
||||||
|
{
|
||||||
|
switch (overlay->format) {
|
||||||
|
case GST_VIDEO_FORMAT_I420:
|
||||||
|
case GST_VIDEO_FORMAT_NV12:
|
||||||
|
case GST_VIDEO_FORMAT_NV21:
|
||||||
|
gst_base_text_overlay_shade_planar_Y (overlay, frame, x0, x1, y0, y1);
|
||||||
|
break;
|
||||||
|
case GST_VIDEO_FORMAT_AYUV:
|
||||||
|
case GST_VIDEO_FORMAT_UYVY:
|
||||||
|
gst_base_text_overlay_shade_packed_Y (overlay, frame, x0, x1, y0, y1);
|
||||||
|
break;
|
||||||
|
case GST_VIDEO_FORMAT_xRGB:
|
||||||
|
gst_base_text_overlay_shade_xRGB (overlay, frame, x0, x1, y0, y1);
|
||||||
|
break;
|
||||||
|
case GST_VIDEO_FORMAT_xBGR:
|
||||||
|
gst_base_text_overlay_shade_xBGR (overlay, frame, x0, x1, y0, y1);
|
||||||
|
break;
|
||||||
|
case GST_VIDEO_FORMAT_BGRx:
|
||||||
|
gst_base_text_overlay_shade_BGRx (overlay, frame, x0, x1, y0, y1);
|
||||||
|
break;
|
||||||
|
case GST_VIDEO_FORMAT_RGBx:
|
||||||
|
gst_base_text_overlay_shade_RGBx (overlay, frame, x0, x1, y0, y1);
|
||||||
|
break;
|
||||||
|
case GST_VIDEO_FORMAT_ARGB:
|
||||||
|
gst_base_text_overlay_shade_ARGB (overlay, frame, x0, x1, y0, y1);
|
||||||
|
break;
|
||||||
|
case GST_VIDEO_FORMAT_ABGR:
|
||||||
|
gst_base_text_overlay_shade_ABGR (overlay, frame, x0, x1, y0, y1);
|
||||||
|
break;
|
||||||
|
case GST_VIDEO_FORMAT_RGBA:
|
||||||
|
gst_base_text_overlay_shade_RGBA (overlay, frame, x0, x1, y0, y1);
|
||||||
|
break;
|
||||||
|
case GST_VIDEO_FORMAT_BGRA:
|
||||||
|
gst_base_text_overlay_shade_BGRA (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)));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
gst_base_text_overlay_push_frame (GstBaseTextOverlay * overlay,
|
gst_base_text_overlay_push_frame (GstBaseTextOverlay * overlay,
|
||||||
GstBuffer * video_frame)
|
GstBuffer * video_frame)
|
||||||
{
|
{
|
||||||
gint xpos, ypos;
|
|
||||||
GstVideoFrame frame;
|
GstVideoFrame frame;
|
||||||
|
|
||||||
if (overlay->composition == NULL)
|
if (overlay->composition == NULL)
|
||||||
|
@ -1625,69 +1669,14 @@ gst_base_text_overlay_push_frame (GstBaseTextOverlay * overlay,
|
||||||
GST_MAP_READWRITE))
|
GST_MAP_READWRITE))
|
||||||
goto invalid_frame;
|
goto invalid_frame;
|
||||||
|
|
||||||
gst_base_text_overlay_get_pos (overlay, &xpos, &ypos);
|
|
||||||
|
|
||||||
/* shaded background box */
|
/* shaded background box */
|
||||||
if (overlay->want_shading) {
|
if (overlay->want_shading) {
|
||||||
switch (overlay->format) {
|
gint xpos, ypos;
|
||||||
case GST_VIDEO_FORMAT_I420:
|
|
||||||
case GST_VIDEO_FORMAT_NV12:
|
gst_base_text_overlay_get_pos (overlay, &xpos, &ypos);
|
||||||
case GST_VIDEO_FORMAT_NV21:
|
|
||||||
gst_base_text_overlay_shade_planar_Y (overlay, &frame,
|
gst_base_text_overlay_shade_background (overlay, &frame,
|
||||||
xpos, xpos + overlay->image_width,
|
xpos, xpos + overlay->image_width, ypos, ypos + overlay->image_height);
|
||||||
ypos, ypos + overlay->image_height);
|
|
||||||
break;
|
|
||||||
case GST_VIDEO_FORMAT_AYUV:
|
|
||||||
case GST_VIDEO_FORMAT_UYVY:
|
|
||||||
gst_base_text_overlay_shade_packed_Y (overlay, &frame,
|
|
||||||
xpos, xpos + overlay->image_width,
|
|
||||||
ypos, ypos + overlay->image_height);
|
|
||||||
break;
|
|
||||||
case GST_VIDEO_FORMAT_xRGB:
|
|
||||||
gst_base_text_overlay_shade_xRGB (overlay, &frame,
|
|
||||||
xpos, xpos + overlay->image_width,
|
|
||||||
ypos, ypos + overlay->image_height);
|
|
||||||
break;
|
|
||||||
case GST_VIDEO_FORMAT_xBGR:
|
|
||||||
gst_base_text_overlay_shade_xBGR (overlay, &frame,
|
|
||||||
xpos, xpos + overlay->image_width,
|
|
||||||
ypos, ypos + overlay->image_height);
|
|
||||||
break;
|
|
||||||
case GST_VIDEO_FORMAT_BGRx:
|
|
||||||
gst_base_text_overlay_shade_BGRx (overlay, &frame,
|
|
||||||
xpos, xpos + overlay->image_width,
|
|
||||||
ypos, ypos + overlay->image_height);
|
|
||||||
break;
|
|
||||||
case GST_VIDEO_FORMAT_RGBx:
|
|
||||||
gst_base_text_overlay_shade_RGBx (overlay, &frame,
|
|
||||||
xpos, xpos + overlay->image_width,
|
|
||||||
ypos, ypos + overlay->image_height);
|
|
||||||
break;
|
|
||||||
case GST_VIDEO_FORMAT_ARGB:
|
|
||||||
gst_base_text_overlay_shade_ARGB (overlay, &frame,
|
|
||||||
xpos, xpos + overlay->image_width,
|
|
||||||
ypos, ypos + overlay->image_height);
|
|
||||||
break;
|
|
||||||
case GST_VIDEO_FORMAT_ABGR:
|
|
||||||
gst_base_text_overlay_shade_ABGR (overlay, &frame,
|
|
||||||
xpos, xpos + overlay->image_width,
|
|
||||||
ypos, ypos + overlay->image_height);
|
|
||||||
break;
|
|
||||||
case GST_VIDEO_FORMAT_RGBA:
|
|
||||||
gst_base_text_overlay_shade_RGBA (overlay, &frame,
|
|
||||||
xpos, xpos + overlay->image_width,
|
|
||||||
ypos, ypos + overlay->image_height);
|
|
||||||
break;
|
|
||||||
case GST_VIDEO_FORMAT_BGRA:
|
|
||||||
gst_base_text_overlay_shade_BGRA (overlay, &frame,
|
|
||||||
xpos, xpos + overlay->image_width,
|
|
||||||
ypos, ypos + overlay->image_height);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
GST_FIXME_OBJECT (overlay, "implement background shading for format %s",
|
|
||||||
gst_video_format_to_string (GST_VIDEO_FRAME_FORMAT (&frame)));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_video_overlay_composition_blend (overlay->composition, &frame);
|
gst_video_overlay_composition_blend (overlay->composition, &frame);
|
||||||
|
|
Loading…
Reference in a new issue