Commit graph

52 commits

Author SHA1 Message Date
Matthew Waters
640a65bf96 gst: don't use volatile to mean atomic
volatile is not sufficient to provide atomic guarantees and real atomics
should be used instead.  GCC 11 has started warning about using volatile
with atomic operations.

https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1719

Discovered in https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/issues/868

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2098>
2021-03-22 14:34:36 +11:00
Chris Bass
d25be0d16e ttmlparse: Handle whitespace before XML declaration
When ttmlparse is in, e.g., an MPEG-DASH pipeline, there may be
whitespace between successive TTML documents in ttmlparse's accumulated
input. As libxml2 will fail to parse documents that have whitespace
before the opening XML declaration, ensure that any preceding whitespace
is not passed to libxml2.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1539>
2020-10-30 07:01:52 +00:00
Chris Bass
8df2314c23 ttmlparse: Ensure only single TTML doc parsed
The parser handles only one TTML file at a time, therefore if there are
multiple TTML documets in the input, parse only the first.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1539>
2020-10-30 07:01:52 +00:00
Seungha Yang
ae76f9ab23 ttmlparse: Collect buffers until detecting complete xml document
Given buffer could be fragmented and we might need to
collect buffers until end tag is detected. And/or, a buffer
can consist of multiple ttml documents.

Fixes: https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/494
2019-11-22 18:31:10 +09:00
Aaron Boxer
6d3429af34 documentation: fixed a heap o' typos 2019-11-05 09:11:25 -05:00
Tim-Philipp Müller
f218ec2794 Remove autotools build system 2019-10-14 13:54:27 +01:00
Thibault Saunier
47a49f3381 docs: Build documentation with hotdoc 2019-05-13 17:00:00 -04:00
Nirbheek Chauhan
b55dfb5313 Add feature options for almost all plugins
The only plugins remaining are those that haven't been ported to Meson
yet, and msdk. Also, the tests are still automagic.

https://bugzilla.gnome.org/show_bug.cgi?id=795107
2018-07-27 19:04:38 +05:30
Xavier Claessens
83d0623293 Meson: Generate pc file for all plugins in bad
https://bugzilla.gnome.org/show_bug.cgi?id=794568
2018-04-25 11:08:09 +01:00
Chris Bass
2863a55a89 ttml: Add support for IMSC 1.0.1 fillLineGap attribute
Strictly speaking, the TTML spec requires that text backgrounds extend
only to the font height of the related text, rather than to the vertical
distance between lines. The result of this is that there will typically
be vertical gaps between line backgrounds through which moving video can
be seen. Since this was unnacceptable to some content providers, v1.0.1
of the IMSC spec (which profiles TTML) adds a new attribute,
itts:fillLineGap[1], that allows content authors to specify that clients
should extend text backgrounds such that there are no gaps between
lines. This attribute is also going to be included in the next release
of EBU-TT-D.

This patch adds support for fillLineGap to ttmlparse and ttmlrender.

[1] https://www.w3.org/TR/ttml-imsc1.0.1/#itts-fillLineGap

https://bugzilla.gnome.org/show_bug.cgi?id=787071
2018-02-27 16:27:47 +02:00
Chris Bass
3d2f004db2 ttmlparse: Ensure default showBackground behaviour is enacted
Ensure that region backgrounds are always show when tts:showBackground
is not explicitly set, in accordance with the default behavour given in
the TTML spec.

https://bugzilla.gnome.org/show_bug.cgi?id=787942
2017-09-20 17:11:29 +03:00
Tim-Philipp Müller
3dcfb3ce0e ttml: fix linking to libgstvideo
https://bugzilla.gnome.org/show_bug.cgi?id=784439
2017-07-03 10:11:42 +01:00
Edward Hervey
417c70805b ttml: Simplify code
n2 can never be NULL since:
* it's in a "while (n1 && n2)" block
* and it's not modified before

CID #1405868
2017-05-26 17:55:44 +02:00
Tim-Philipp Müller
80d66dfec8 Fix up package name and origin in some plugins 2017-05-18 10:58:20 +01:00
Nicolas Dufresne
4261692187 Remove plugin specific static build option
Static and dynamic plugins now have the same interface. The standard
--enable-static/--enable-shared toggle are sufficient.
2017-05-16 14:05:52 -04:00
Chris Bass
acfaf3a001 ttmlparse: Consolidate adjacent co-styled inline elements
A common subtitling use case is live-generated subtitles, in which each
new word is contained in its own span, and the spans are displayed
sequentially, with the effect that lines of displayed subtitles are
built up word-by-word.

This can, however, cause problems when the number of words in a block is
greater than the number of allowed GstMemorys in a GstBuffer.

Since in this use case each span will have the same styling as adjacent
spans, we can join adjacent spans (and other inline elements, such as
breaks) into a single element containing the concatenated text of each,
thus avoiding the limit of GstMemorys in a GstBuffer and also reducing
the amount of styling/layout metadata that is attached to each buffer.

https://bugzilla.gnome.org/show_bug.cgi?id=781725
2017-04-25 22:18:53 +03:00
Chris Bass
22c3830858 ttmlparse: Don't add GstMemorys to a GstBuffer that is full
The parser stores the text from each inline element of a scene in its
own GstMemory, which is inserted in the GstBuffer containing the scene
data. However, GstBuffers can contain only a limited number of
GstMemorys. Therefore, don't add more than the maximum number of
GstMemorys to each buffer, and warn if this is attempted.

https://bugzilla.gnome.org/show_bug.cgi?id=781725
2017-04-25 22:18:53 +03:00
Chris Bass
ef65230b46 ttmlparse: Store newline as text of br element
When parsing <br> elements, store an actual newline in the text field of
the created TtmlElement. They then don't need to be treated as a
separate case from anon-span elements when being processed.

https://bugzilla.gnome.org/show_bug.cgi?id=781725
2017-04-25 22:18:53 +03:00
Chris Bass
81157e5168 ttmlparse: Replace repeated warning code with a function.
Encapsulates in a function the code that warns of an illegally
positioned element, rather than repeating the same code multiple times.
Also frees a string allocated by ttml_get_element_type_string, which was
previously being leaked.

https://bugzilla.gnome.org/show_bug.cgi?id=781725
2017-04-25 22:18:53 +03:00
Chris Bass
8b19cccfc5 ttmlparse: Remove redundant text_index field of TtmlElement
https://bugzilla.gnome.org/show_bug.cgi?id=781725
2017-04-25 22:18:53 +03:00
Chris Bass
d8afce67c3 ttmlparse: Don't leak TtmlElements when deleting GNodes/trees.
https://bugzilla.gnome.org/show_bug.cgi?id=781725
2017-04-25 22:18:53 +03:00
Chris Bass
9f5e41218f ttmlparse: Convert tabs to spaces in input
The TTML spec has an issue in which tab (U+0009) characters that are
first in a sequence of whitespace characters are not suppressed at the
start and end of line areas. This issue was reported in [1] and the
editor of the TTML specs confirmed that this was not the intention
behind the spec.

The editor has created an issue to fix this in both the TTML1 and TTML2
specs [2], giving a proposal of what the spec should say. This patch
updates ttmlparse to implement the intended behaviour as proposed, in
which tabs in the input are converted to spaces before processing.

[1] https://github.com/w3c/imsc/issues/224
[2] https://github.com/w3c/ttml1/issues/235

https://bugzilla.gnome.org/show_bug.cgi?id=781539
2017-04-20 18:50:05 +01:00
Chris Bass
6eb36406f0 ttmlparse: Fix potential resource leak identified by coverity.
If multiple styles/regions with the same ID are present in the input
(which is not allowed in TTML), use the last and give a warning.

Fixes CID #1405134.
2017-04-20 10:40:32 +01:00
Chris Bass
9e3b63e109 ttmlrender: Fix potential resource leak identified by coverity
Fixes CID #1405133.
2017-04-20 10:40:32 +01:00
Chris Bass
129bee3d02 ttmlrender: Fix potential problem identified by clang
Clang's static analyser found potential code paths in which variables
were being used in comparisons when uninitialised. Fix by properly
handling out-of-range value returned by gst_ttml_get_element_index.
2017-04-19 18:28:31 +01:00
Chris Bass
98ce1e11bc ttmlparse: Fix potential NULL dereference identified by coverity
Hopefully fixes CID #1405131.
2017-04-19 18:28:31 +01:00
Chris Bass
3fbd12b141 ttmlrender: Fix integer handling issue identified by coverity
Fixes CID #1405132.
2017-04-19 18:28:31 +01:00
Tim-Philipp Müller
5b458bf829 ttml: build, but don't autoplug unless GST_TTML_AUTOPLUG env var is set
Don't hide build behind --enable-experimental. Our goal is to not
autoplug it for now, so let's just always build it if the dependencies
are there and hide autoplugging enablement behind an env var.
2017-04-13 11:33:41 +01:00
Thibault Saunier
78022a6e0c docs: Port all docstring to gtk-doc markdown 2017-04-12 12:57:57 -03:00
Chris Bass
28e0bdb7fe ttmlparse: push segment events downstream
Without this, subtitles will stop after seeking.

https://bugzilla.gnome.org/show_bug.cgi?id=780897
2017-04-09 10:42:26 +03:00
Chris Bass
b4d9d9d9f8 ttmlparse: don't filter out untimed whitespace
Significant whitespace in elements that don't have begin/end values
should inherit timing from its parent, or if no its parents have no
timing, from the document's Root Temporal Extent. Currently, such
whitespace is removed, which is not spec-compliant. Fix this by
retaining whitespace in content nodes, and assigning a Root Temporal
Extent of 24 hours to any significant whitespace whose parents have no
associated timing.

https://bugzilla.gnome.org/show_bug.cgi?id=781027
2017-04-09 10:42:16 +03:00
Chris Bass
89b6b1a760 ttmlparse: don't leak caps.
https://bugzilla.gnome.org/show_bug.cgi?id=780402
2017-04-09 10:42:08 +03:00
Chris Bass
60bcf63a29 ttmlrender: improve function comments/descriptions
https://bugzilla.gnome.org/show_bug.cgi?id=780402
2017-04-09 10:42:08 +03:00
Chris Bass
ada24bd2b6 ttmlrender: relocate type definitions to head of file
https://bugzilla.gnome.org/show_bug.cgi?id=780402
2017-04-09 10:42:08 +03:00
Chris Bass
0288ee24e9 ttml: correctly implement lineHeight behaviour
The specified behaviour in TTML when lineHeight is "normal" is different
from the behaviour when a percentage is given. In the former case, the
line height is a percentage (the TTML spec recommends 125%) of the largest
font size that is applied to the spans within the block; in the latter
case, the line height is the given percentage of the font size that is
applied to the block itself.

The code doesn't correctly implement this behaviour; this patch fixes
that.

https://bugzilla.gnome.org/show_bug.cgi?id=780402
2017-04-09 10:42:08 +03:00
Chris Bass
f28df30a8b ttmlrender: apply correct line height to blocks with multiple text sizes
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
2017-04-09 10:42:08 +03:00
Chris Bass
2a4a18b2ab ttmlrender: add facility to stitch images in both directions
https://bugzilla.gnome.org/show_bug.cgi?id=780402
2017-04-09 10:42:08 +03:00
Chris Bass
ce532ddcfd ttmlrender: extend UnifiedElement type to include font metrics
https://bugzilla.gnome.org/show_bug.cgi?id=780402
2017-04-09 10:42:08 +03:00
Chris Bass
aec8406fd7 ttmlrender: extend UnifiedBlock type
Include a reference to the GstSubtitleStyleSet of the represented block
and a string containing the concatenated text from all elements.

https://bugzilla.gnome.org/show_bug.cgi?id=780402
2017-04-09 10:42:08 +03:00
Chris Bass
9f0a06245b ttml: add refcounting to GstSubtitleStlyeSet type
https://bugzilla.gnome.org/show_bug.cgi?id=780402
2017-04-09 10:42:08 +03:00
Chris Bass
4f790d13a6 ttmlrender: rename TextRange type and its fields.
https://bugzilla.gnome.org/show_bug.cgi?id=780402
2017-04-09 10:42:08 +03:00
Chris Bass
ac91886ab7 ttmlrender: store PangoLayout in object state
https://bugzilla.gnome.org/show_bug.cgi?id=780402
2017-04-09 10:42:08 +03:00
Chris Bass
96e07de31d ttmlrender: put all functions in gst_ttml_render namespace
https://bugzilla.gnome.org/show_bug.cgi?id=780402
2017-04-09 10:42:08 +03:00
Chris Bass
4ac2a8d6a6 ttml: Replace assertions
Remove assertions and replace, where necessary, with code that handles
the error cases.

https://bugzilla.gnome.org/show_bug.cgi?id=776436
2017-03-15 13:28:36 +02:00
Sebastian Dröge
9539edd1b5 ttml: Link with -lm for round() 2017-01-12 15:39:13 +02:00
Seungha Yang
a5ce16f739 ttmlrender: Fix segfault on _render_text_region()
Fix invalid memory access

https://bugzilla.gnome.org/show_bug.cgi?id=775965
2016-12-12 11:00:51 +02:00
Seungha Yang
ba1ad5f4cd ttmlparse: Transform caps event
For autoplugging, decodebin/parsebin refers to the caps event.

https://bugzilla.gnome.org/show_bug.cgi?id=775967
2016-12-12 10:57:29 +02:00
Nicolas Dufresne
c03a4829ac meson/ttml: Add missing math library dependency
This code call 'round' which may require linking against the math library
on some compilers.
2016-11-30 22:40:45 -05:00
Sebastian Dröge
a1dc37b22b ttmlrender: Mark pad as needing reconfiguration again if it failed
And return FLUSHING instead of NOT_NEGOTIATED on flushing pads.

https://bugzilla.gnome.org/show_bug.cgi?id=774623
2016-11-18 12:22:44 +02:00
Luis de Bethencourt
81d1b207ad ttml: bump needed libxml2 version
ttml was recently added but it won't compile unless libxml2 version 2.9.2
or later is available. In that version the first parameter of xmlGetProp
switched to being a const. In previous versions the compiler complains
about passing a const value to a non const argument.
2016-11-03 17:44:33 +00:00