Search
SailfishOS Open Build Service
>
Projects
>
home:sledge
:
branches:nemo:devel:hw:ti:omap4:common
>
gst-plugins-base
> 0018-textoverlay-add-stride-support.patch
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File 0018-textoverlay-add-stride-support.patch of Package gst-plugins-base
From 109be1eb288b4b95925d098804c7bf1b09e03f6d Mon Sep 17 00:00:00 2001 From: Rob Clark <rob@ti.com> Date: Mon, 23 Aug 2010 14:01:14 -0500 Subject: [PATCH 18/38] textoverlay: add stride support --- ext/pango/gsttextoverlay.c | 43 +++++++++++++++++++++++++++++++------------ ext/pango/gsttextoverlay.h | 1 + 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/ext/pango/gsttextoverlay.c b/ext/pango/gsttextoverlay.c index d4775ca..311d377 100644 --- a/ext/pango/gsttextoverlay.c +++ b/ext/pango/gsttextoverlay.c @@ -200,7 +200,9 @@ static GstStaticPadTemplate src_template_factory = GST_VIDEO_CAPS_BGRA ";" GST_VIDEO_CAPS_ARGB ";" GST_VIDEO_CAPS_ABGR ";" - GST_VIDEO_CAPS_YUV ("{AYUV, I420, UYVY, NV12, NV21}")) + GST_VIDEO_CAPS_YUV ("{AYUV, I420, UYVY, NV12, NV21}") ";" + GST_VIDEO_CAPS_YUV_STRIDED ("{AYUV, I420, UYVY, NV12, NV21}", + "[0, max]")) ); static GstStaticPadTemplate video_sink_template_factory = @@ -215,7 +217,9 @@ static GstStaticPadTemplate video_sink_template_factory = GST_VIDEO_CAPS_BGRA ";" GST_VIDEO_CAPS_ARGB ";" GST_VIDEO_CAPS_ABGR ";" - GST_VIDEO_CAPS_YUV ("{AYUV, I420, UYVY, NV12, NV21}")) + GST_VIDEO_CAPS_YUV ("{AYUV, I420, UYVY, NV12, NV21}") ";" + GST_VIDEO_CAPS_YUV_STRIDED ("{AYUV, I420, UYVY, NV12, NV21}", + "[0, max]")) ); static GstStaticPadTemplate text_sink_template_factory = @@ -757,12 +761,13 @@ gst_text_overlay_setcaps (GstPad * pad, GstCaps * caps) overlay->width = 0; overlay->height = 0; + overlay->rowstride = 0; structure = gst_caps_get_structure (caps, 0); fps = gst_structure_get_value (structure, "framerate"); if (fps - && gst_video_format_parse_caps (caps, &overlay->format, &overlay->width, - &overlay->height)) { + && gst_video_format_parse_caps_strided (caps, &overlay->format, + &overlay->width, &overlay->height, &overlay->rowstride)) { ret = gst_pad_set_caps (overlay->srcpad, caps); } @@ -1411,14 +1416,21 @@ gst_text_overlay_render_pangocairo (GstTextOverlay * overlay, #define BOX_XPAD 6 #define BOX_YPAD 6 +static gint +gst_text_overlay_get_stride (GstTextOverlay * overlay, gint component) +{ + if (overlay->rowstride) + return overlay->rowstride; + return gst_video_format_get_row_stride (overlay->format, 0, overlay->width); +} + static inline void gst_text_overlay_shade_planar_Y (GstTextOverlay * overlay, guchar * dest, gint x0, gint x1, gint y0, gint y1) { gint i, j, dest_stride; - dest_stride = gst_video_format_get_row_stride (overlay->format, 0, - overlay->width); + dest_stride = gst_text_overlay_get_stride (overlay, 0); x0 = CLAMP (x0 - BOX_XPAD, 0, overlay->width); x1 = CLAMP (x1 + BOX_XPAD, 0, overlay->width); @@ -1485,7 +1497,9 @@ static inline void gst_text_overlay_shade_xRGB (GstTextOverlay * overlay, guchar * dest, gint x0, gint x1, gint y0, gint y1) { - gint i, j; + gint i, j, dest_stride; + + dest_stride = gst_text_overlay_get_stride (overlay, 0); x0 = CLAMP (x0 - BOX_XPAD, 0, overlay->width); x1 = CLAMP (x1 + BOX_XPAD, 0, overlay->width); @@ -1497,7 +1511,7 @@ gst_text_overlay_shade_xRGB (GstTextOverlay * overlay, guchar * dest, for (j = x0; j < x1; j++) { gint y, y_pos, k; - y_pos = (i * 4 * overlay->width) + j * 4; + y_pos = (i * dest_stride) + j * 4; for (k = 0; k < 4; k++) { y = dest[y_pos + k] + overlay->shading_value; dest[y_pos + k] = CLAMP (y, 0, 255); @@ -1559,10 +1573,12 @@ gst_text_overlay_blit_NV12_NV21 (GstTextOverlay * overlay, w = overlay->width; h = overlay->height; - y_stride = gst_video_format_get_row_stride (overlay->format, 0, w); - uv_stride = gst_video_format_get_row_stride (overlay->format, 1, w); - u_offset = gst_video_format_get_component_offset (overlay->format, 1, w, h); - v_offset = gst_video_format_get_component_offset (overlay->format, 2, w, h); + y_stride = gst_text_overlay_get_stride (overlay, 0); + uv_stride = gst_text_overlay_get_stride (overlay, 1); + u_offset = + gst_video_format_get_component_offset (overlay->format, 1, y_stride, h); + v_offset = + gst_video_format_get_component_offset (overlay->format, 2, y_stride, h); gst_text_overlay_blit_1 (overlay, yuv_pixels, xpos, ypos, overlay->text_image, y_stride); @@ -1588,6 +1604,9 @@ gst_text_overlay_blit_I420 (GstTextOverlay * overlay, w = overlay->width; h = overlay->height; + /* XXX this is not updated for rowstride.. but rowstride could be + * ambiguous for I420.. is the U and V plane rowstride or rowstride/2? + */ y_stride = gst_video_format_get_row_stride (GST_VIDEO_FORMAT_I420, 0, w); u_stride = gst_video_format_get_row_stride (GST_VIDEO_FORMAT_I420, 1, w); v_stride = gst_video_format_get_row_stride (GST_VIDEO_FORMAT_I420, 2, w); diff --git a/ext/pango/gsttextoverlay.h b/ext/pango/gsttextoverlay.h index 5cd4260..4957ec0 100644 --- a/ext/pango/gsttextoverlay.h +++ b/ext/pango/gsttextoverlay.h @@ -117,6 +117,7 @@ struct _GstTextOverlay { gint width; gint height; + gint rowstride; gint fps_n; gint fps_d; GstVideoFormat format; -- 1.7.5.4