mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-22 16:26:39 +00:00
f28df30a8b
In TTML, the height of every line in a block is determined by lineHeight and fontSize style attributes, and should be the same for each line in that block, regardless of whether different sized text appears on different lines. Currently, a single PangoLayout is used to lay out all the text in a block; however, pango will vary the line height in a layout depending on the size of text used in each line, which is not compliant with TTML. This patch makes ttmlrender lay out the lines in a block itself, rather than using a PangoLayout to do the work. The code still uses a PangoLayout to render the text of each element, but the overall layout of the text in a block is now controlled by ttmlrender itself. By doing this, ttmlrender is able to ensure that the height of each line in a block is correct. https://bugzilla.gnome.org/show_bug.cgi?id=780402
109 lines
3.9 KiB
C
109 lines
3.9 KiB
C
/* GStreamer
|
|
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
|
* Copyright (C) <2003> David Schleef <ds@schleef.org>
|
|
* Copyright (C) <2006> Julien Moutte <julien@moutte.net>
|
|
* Copyright (C) <2006> Zeeshan Ali <zeeshan.ali@nokia.com>
|
|
* Copyright (C) <2006-2008> Tim-Philipp Müller <tim centricular net>
|
|
* Copyright (C) <2009> Young-Ho Cha <ganadist@gmail.com>
|
|
* Copyright (C) <2015> British Broadcasting Corporation <dash@rd.bbc.co.uk>
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Library General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2 of the License, or (at your option) any later version.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Library General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Library General Public
|
|
* License along with this library; if not, write to the
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
* Boston, MA 02110-1301, USA.
|
|
*/
|
|
|
|
#ifndef __GST_TTML_RENDER_H__
|
|
#define __GST_TTML_RENDER_H__
|
|
|
|
#include <gst/gst.h>
|
|
#include <gst/video/video.h>
|
|
#include <pango/pango.h>
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
#define GST_TYPE_TTML_RENDER (gst_ttml_render_get_type())
|
|
#define GST_TTML_RENDER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),\
|
|
GST_TYPE_TTML_RENDER, GstTtmlRender))
|
|
#define GST_TTML_RENDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),\
|
|
GST_TYPE_TTML_RENDER, \
|
|
GstTtmlRenderClass))
|
|
#define GST_TTML_RENDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),\
|
|
GST_TYPE_TTML_RENDER, \
|
|
GstTtmlRenderClass))
|
|
#define GST_IS_TTML_RENDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),\
|
|
GST_TYPE_TTML_RENDER))
|
|
#define GST_IS_TTML_RENDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),\
|
|
GST_TYPE_TTML_RENDER))
|
|
|
|
typedef struct _GstTtmlRender GstTtmlRender;
|
|
typedef struct _GstTtmlRenderClass GstTtmlRenderClass;
|
|
typedef struct _GstTtmlRenderRenderedImage GstTtmlRenderRenderedImage;
|
|
|
|
struct _GstTtmlRenderRenderedImage {
|
|
GstBuffer *image;
|
|
gint x;
|
|
gint y;
|
|
guint width;
|
|
guint height;
|
|
};
|
|
|
|
|
|
struct _GstTtmlRender {
|
|
GstElement element;
|
|
|
|
GstPad *video_sinkpad;
|
|
GstPad *text_sinkpad;
|
|
GstPad *srcpad;
|
|
|
|
GstSegment segment;
|
|
GstSegment text_segment;
|
|
GstBuffer *text_buffer;
|
|
gboolean text_linked;
|
|
gboolean video_flushing;
|
|
gboolean video_eos;
|
|
gboolean text_flushing;
|
|
gboolean text_eos;
|
|
|
|
GMutex lock;
|
|
GCond cond; /* to signal removal of a queued text
|
|
* buffer, arrival of a text buffer,
|
|
* a text segment update, or a change
|
|
* in status (e.g. shutdown, flushing) */
|
|
|
|
GstVideoInfo info;
|
|
GstVideoFormat format;
|
|
gint width;
|
|
gint height;
|
|
|
|
gboolean want_background;
|
|
gboolean wait_text;
|
|
|
|
gboolean need_render;
|
|
|
|
PangoLayout *layout;
|
|
GList * compositions;
|
|
};
|
|
|
|
struct _GstTtmlRenderClass {
|
|
GstElementClass parent_class;
|
|
|
|
PangoContext *pango_context;
|
|
GMutex *pango_lock;
|
|
};
|
|
|
|
GType gst_ttml_render_get_type(void) G_GNUC_CONST;
|
|
|
|
G_END_DECLS
|
|
|
|
#endif /* __GST_TTML_RENDER_H */
|