[Bug 761251] textoverlay: Expose text rendering dimensions to applications and remove absolute positioning limit

GStreamer (GNOME Bugzilla) bugzilla at gnome.org
Fri Mar 11 13:29:44 UTC 2016


https://bugzilla.gnome.org/show_bug.cgi?id=761251

Tim-Philipp Müller <t.i.m at zen.co.uk> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
 Attachment #323695|none                        |committed
             status|                            |

--- Comment #28 from Tim-Philipp Müller <t.i.m at zen.co.uk> ---
Comment on attachment 323695
  --> https://bugzilla.gnome.org/attachment.cgi?id=323695
basetextoverlay: Add new alignment type for unclamped absolute positions.

>From cb506405eeaac657f2673f5f194c0a6ddd1ed4ff Mon Sep 17 00:00:00 2001
>From: Lubosz Sarnecki <lubosz.sarnecki at collabora.co.uk>
>Date: Tue, 8 Mar 2016 19:22:34 +0100
>Subject: [PATCH 2/2] basetextoverlay: Add new alignment type for unclamped
> absolute positions.
>
>Introduces [x-absolute, y-absolute] properties
>for positioning in +/- MAX_DOUBLE range.
>
>Adds new (h/v)alignment type "absolute" where coordinates
>map the text area to be exactly inside of video canvas for [0, 0] - [1, 1]:
>
>[0, 0]: Top-Lefts of video and text are aligned
>[0.5, 0.5]: Centers are aligned
>[1, 1]: Bottom-Rights are aligned
>
>https://bugzilla.gnome.org/show_bug.cgi?id=761251
>---
> common                         |  2 +-
> ext/pango/gstbasetextoverlay.c | 68 +++++++++++++++++++++++++++++++++++++++---
> ext/pango/gstbasetextoverlay.h |  6 ++--
> 3 files changed, 69 insertions(+), 7 deletions(-)
>
>diff --git a/common b/common
>index 6f2d209..b64f03f 160000
>--- a/common
>+++ b/common
>@@ -1 +1 @@
>-Subproject commit 6f2d2093e84cc0eb99b634fa281822ebb9507285
>+Subproject commit b64f03f6090245624608beb5d2fff335e23a01c0
>diff --git a/ext/pango/gstbasetextoverlay.c b/ext/pango/gstbasetextoverlay.c
>index 669b0c2..e0bb169 100644
>--- a/ext/pango/gstbasetextoverlay.c
>+++ b/ext/pango/gstbasetextoverlay.c
>@@ -90,6 +90,8 @@ enum
>   PROP_DELTAY,
>   PROP_XPOS,
>   PROP_YPOS,
>+  PROP_X_ABSOLUTE,
>+  PROP_Y_ABSOLUTE,
>   PROP_WRAP_MODE,
>   PROP_FONT_DESC,
>   PROP_SILENT,
>@@ -141,8 +143,10 @@ gst_base_text_overlay_valign_get_type (void)
>     {GST_BASE_TEXT_OVERLAY_VALIGN_BASELINE, "baseline", "baseline"},
>     {GST_BASE_TEXT_OVERLAY_VALIGN_BOTTOM, "bottom", "bottom"},
>     {GST_BASE_TEXT_OVERLAY_VALIGN_TOP, "top", "top"},
>-    {GST_BASE_TEXT_OVERLAY_VALIGN_POS, "position", "position"},
>+    {GST_BASE_TEXT_OVERLAY_VALIGN_POS, "position",
>+        "Absolute position clamped to canvas"},
>     {GST_BASE_TEXT_OVERLAY_VALIGN_CENTER, "center", "center"},
>+    {GST_BASE_TEXT_OVERLAY_VALIGN_ABSOLUTE, "absolute", "Absolute position"},
>     {0, NULL, NULL},
>   };
> 
>@@ -163,7 +167,9 @@ gst_base_text_overlay_halign_get_type (void)
>     {GST_BASE_TEXT_OVERLAY_HALIGN_LEFT, "left", "left"},
>     {GST_BASE_TEXT_OVERLAY_HALIGN_CENTER, "center", "center"},
>     {GST_BASE_TEXT_OVERLAY_HALIGN_RIGHT, "right", "right"},
>-    {GST_BASE_TEXT_OVERLAY_HALIGN_POS, "position", "position"},
>+    {GST_BASE_TEXT_OVERLAY_HALIGN_POS, "position",
>+        "Absolute position clamped to canvas"},
>+    {GST_BASE_TEXT_OVERLAY_HALIGN_ABSOLUTE, "absolute", "Absolute position"},
>     {0, NULL, NULL},
>   };
> 
>@@ -445,7 +451,7 @@ gst_base_text_overlay_class_init (GstBaseTextOverlayClass * klass)
>    */
>   g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_XPOS,
>       g_param_spec_double ("xpos", "horizontal position",
>-          "Horizontal position when using position alignment", 0, 1.0,
>+          "Horizontal position when using clamped position alignment", 0, 1.0,
>           DEFAULT_PROP_XPOS,
>           G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
>   /**
>@@ -455,9 +461,45 @@ gst_base_text_overlay_class_init (GstBaseTextOverlayClass * klass)
>    */
>   g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_YPOS,
>       g_param_spec_double ("ypos", "vertical position",
>-          "Vertical position when using position alignment", 0, 1.0,
>+          "Vertical position when using clamped position alignment", 0, 1.0,
>           DEFAULT_PROP_YPOS,
>           G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
>+
>+  /**
>+   * GstBaseTextOverlay:x-absolute:
>+   *
>+   * Horizontal position of the rendered text when using absolute alignment.
>+   *
>+   * Maps the text area to be exactly inside of video canvas for [0, 0] - [1, 1]:
>+   *
>+   * [0, 0]: Top-Lefts of video and text are aligned
>+   * [0.5, 0.5]: Centers are aligned
>+   * [1, 1]: Bottom-Rights are aligned
>+   *
>+   * Values beyond [0, 0] - [1, 1] place the text outside of the video canvas.
>+   *
>+   * Since: 1.8
>+   */
>+  g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_X_ABSOLUTE,
>+      g_param_spec_double ("x-absolute", "horizontal position",
>+          "Horizontal position when using absolute alignment", -G_MAXDOUBLE,
>+          G_MAXDOUBLE, DEFAULT_PROP_XPOS,
>+          G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
>+  /**
>+   * GstBaseTextOverlay:y-absolute:
>+   *
>+   * See x-absolute.
>+   *
>+   * Vertical position of the rendered text when using absolute alignment.
>+   *
>+   * Since: 1.8
>+   */
>+  g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_Y_ABSOLUTE,
>+      g_param_spec_double ("y-absolute", "vertical position",
>+          "Vertical position when using absolute alignment", -G_MAXDOUBLE,
>+          G_MAXDOUBLE, DEFAULT_PROP_YPOS,
>+          G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
>+
>   g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_WRAP_MODE,
>       g_param_spec_enum ("wrap-mode", "wrap mode",
>           "Whether to wrap the text and if so how.",
>@@ -978,6 +1020,12 @@ gst_base_text_overlay_set_property (GObject * object, guint prop_id,
>     case PROP_YPOS:
>       overlay->ypos = g_value_get_double (value);
>       break;
>+    case PROP_X_ABSOLUTE:
>+      overlay->xpos = g_value_get_double (value);
>+      break;
>+    case PROP_Y_ABSOLUTE:
>+      overlay->ypos = g_value_get_double (value);
>+      break;
>     case PROP_VALIGNMENT:
>       overlay->valign = g_value_get_enum (value);
>       break;
>@@ -1091,6 +1139,12 @@ gst_base_text_overlay_get_property (GObject * object, guint prop_id,
>     case PROP_YPOS:
>       g_value_set_double (value, overlay->ypos);
>       break;
>+    case PROP_X_ABSOLUTE:
>+      g_value_set_double (value, overlay->xpos);
>+      break;
>+    case PROP_Y_ABSOLUTE:
>+      g_value_set_double (value, overlay->ypos);
>+      break;
>     case PROP_VALIGNMENT:
>       g_value_set_enum (value, overlay->valign);
>       break;
>@@ -1496,6 +1550,9 @@ gst_base_text_overlay_get_pos (GstBaseTextOverlay * overlay,
>       if (*xpos < 0)
>         *xpos = 0;
>       break;
>+    case GST_BASE_TEXT_OVERLAY_HALIGN_ABSOLUTE:
>+      *xpos = (overlay->width - overlay->text_width) * overlay->xpos;
>+      break;
>     default:
>       *xpos = 0;
>   }
>@@ -1521,6 +1578,9 @@ gst_base_text_overlay_get_pos (GstBaseTextOverlay * overlay,
>       *ypos = (gint) (overlay->height * overlay->ypos) - height / 2;
>       *ypos = CLAMP (*ypos, 0, overlay->height - overlay->ink_rect.height);
>       break;
>+    case GST_BASE_TEXT_OVERLAY_VALIGN_ABSOLUTE:
>+      *ypos = (overlay->height - overlay->text_height) * overlay->ypos;
>+      break;
>     case GST_BASE_TEXT_OVERLAY_VALIGN_CENTER:
>       *ypos = (overlay->height - height) / 2;
>       break;
>diff --git a/ext/pango/gstbasetextoverlay.h b/ext/pango/gstbasetextoverlay.h
>index 76fb10d..a078fb7 100644
>--- a/ext/pango/gstbasetextoverlay.h
>+++ b/ext/pango/gstbasetextoverlay.h
>@@ -62,7 +62,8 @@ typedef enum {
>     GST_BASE_TEXT_OVERLAY_VALIGN_BOTTOM,
>     GST_BASE_TEXT_OVERLAY_VALIGN_TOP,
>     GST_BASE_TEXT_OVERLAY_VALIGN_POS,
>-    GST_BASE_TEXT_OVERLAY_VALIGN_CENTER
>+    GST_BASE_TEXT_OVERLAY_VALIGN_CENTER,
>+    GST_BASE_TEXT_OVERLAY_VALIGN_ABSOLUTE
> } GstBaseTextOverlayVAlign;
> 
> /**
>@@ -80,7 +81,8 @@ typedef enum {
>     GST_BASE_TEXT_OVERLAY_HALIGN_CENTER,
>     GST_BASE_TEXT_OVERLAY_HALIGN_RIGHT,
>     GST_BASE_TEXT_OVERLAY_HALIGN_UNUSED,
>-    GST_BASE_TEXT_OVERLAY_HALIGN_POS
>+    GST_BASE_TEXT_OVERLAY_HALIGN_POS,
>+    GST_BASE_TEXT_OVERLAY_HALIGN_ABSOLUTE
> } GstBaseTextOverlayHAlign;
> 
> /**
>-- 
>2.7.2
>

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
You are the assignee for the bug.


More information about the gstreamer-bugs mailing list