Commit graph

320 commits

Author SHA1 Message Date
Edward Hervey
841fa7062e gstvalue: No longer store same-type intersection functions in table
The intersection function table is a legacy of 2005, when one could
register random intersection functions. This is no longer the case.

The only place where that table was used was:

* `gst_value_can_intersect()`, where it was already only used for identical
GType
* `gst_value_intersect()`, where the table iteration was insanely expensive

Instead this patch:
* Only stored intersection functions for *different* types (of which there are
only 4)
* Make gst_value_intersect directly call the same-type intersection functions
and only use the table if ever it doesn't match.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/454>
2020-05-04 14:41:01 +00:00
Matthew Waters
166c0fbc47 Revert "gstvalue: Avoid expensive fallback on intersection"
This reverts commit cd751c2de3.
Reverts https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/406

Fixes glviewconvert negotiation in e.g.:

gltestsrc ! glviewconvert output-mode-override=side-by-side ! glstereosplit name=s s.left ! queue ! fakesink s.right ! queue ! glimagesink

Problem here is that intersecting flagsets in gst_value_intersect will
always find a value comparison function but may fail a direct type
comparison due to flagsets supporting derived types.  When flagset
derived types are intersected, an intersection will therefore always
fail.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/441>
2020-04-22 15:18:50 +00:00
Thibault Saunier
88f0312624 value: Fix segfault comparing empty GValueArrays
Adding a test
2020-04-12 20:33:43 -04:00
Edward Hervey
cd751c2de3 gstvalue: Avoid expensive fallback on intersection
The type checks at the end of `gst_value_intersect` to call the flagset
intersection are relatively expensive.

If we already know that:
* There was a compare function but it didn't return GST_VALUE_EQUAL
* AND none of the registered intersect functions failed

Then we know they can't intersect and can return early.

Trims ~20% of the instruction calls
2020-03-19 13:32:34 +01:00
Edward Hervey
34b6929a0f gstvalue: Optimize some list<=>list functions
For subtracting a list from another, the previous implementation would
do a double subtraction of one from another (which would create temporary
arrays/values which would then be discarded). Instead iterate and do
the comparision directly.

For intersecting a list with another, we can directly iterate both at
once and therefore avoid doing a *full* check of all values of the list
against all other values of the list.
2020-03-18 17:53:34 +01:00
Edward Hervey
917dd0881c gstvalue: Inline GstValueList/GstValueArray
This tries to inline as much as possible array/list and its contents
in order to avoid double allocation/freeing. This also improves the
locality of data.

The internal value is still API/ABI compatible with the *public*
GArray structure. This allows READ-ONLY backwards compatibility with
any external users that assume that the content of a list/array value
is backed by a GArray.
2020-03-18 17:53:34 +01:00
Thibault Saunier
a1aebe73d5 value: Handle NULL caps for comparisons
Having a NULL caps in a GValue is legal and we should handle it
properly for comparisons.
2020-03-14 00:35:10 +00:00
Thibault Saunier
109bdd0c25 value: Refactor parsing lists to allow trailing comas
Before that commit `{test, }` wouldn't be accepted as an array
because of the trailing coma, the commit fixes that.

At the same time, the code has been refactored to avoid special casing
the first element of the list, making `{,}` or `<,>` valid lists.
2020-03-12 14:50:20 +00:00
Mathieu Duponchelle
0dafe6e639 gstvalue: use value_nick for serialization
not value_name . This was causing incorrect launch lines to be
displayed by gst-device-monitor, and the deserialization code
below works with nicks.
2019-09-17 01:09:05 +00:00
luz.paz
4a402c1c7d Fix typos in comments and docs
Found via `codespell`

https://bugzilla.gnome.org/show_bug.cgi?id=795610
2018-05-01 11:18:03 +01:00
Arun Raghavan
b5028383ab gst: Fix up a bunch of GIR annotations
This is mostly on nullable return values, and some other minor ones that
I ran across.

https://bugzilla.gnome.org/show_bug.cgi?id=789319
2018-01-27 10:41:24 +00:00
Tim-Philipp Müller
7ea4152323 gstvalue: allocate slightly larger than needed tables at startup
If we pre-allocate only *exactly* as many nodes as we need for the
core types, we are practically guaranteed a re-alloc when external
code like GstVideoTimeCode or GstEncodingProfile register their
own GstValue things. So allocate a bit more than strictly needed.
2017-11-23 13:56:51 +01:00
Thibault Saunier
996bedb81d value: Handle serializing NULL GValueArray
Concider them as an empty array and do not segfault...

https://bugzilla.gnome.org/show_bug.cgi?id=786670
2017-08-26 13:46:58 -03:00
Olivier Crête
dd1f0f49ab value: Accept NULL as a structure
Some GstStructure properties default to NULL, so it should
be a supported value.

With unit test.
2017-04-10 12:37:12 -04:00
Vincent Penquerc'h
c361365890 gstvalue: fix GstValue leak in structure_field_union_into
https://bugzilla.gnome.org/show_bug.cgi?id=780751
2017-03-31 11:57:36 +01:00
Nicolas Dufresne
84f826a937 gstvalue: Add transformation to/from GValueArray
This allow transforming a GValue of type G_TYPE_VALUE_ARRAY to
and from GST_TYPE_ARRAY/LIST.

https://bugzilla.gnome.org/show_bug.cgi?id=753754
2017-03-24 13:30:45 -04:00
Vincent Penquerc'h
371fe0be65 value: fix union of int range and int when extending on a side
The internal representation uses bounds scaled by the step

Add tests to catch those cases
2017-03-20 14:09:55 +00:00
Jan Schmidt
d781d09d99 gstvalue: Do more checks when guessing at flagset strings
If guessing that a string matches a flagset, be more thorough
at checking that the string following a string of hex:hex:
actually looks like a flag set string. Add some unit tests
to catch more cases.

https://bugzilla.gnome.org/show_bug.cgi?id=779755
2017-03-09 12:09:57 +11:00
Vivia Nikolaidou
63775ac6e3 value: Add deserialization for arrays/lists outside GstStructures
This is mostly useful for properties of those types when used in
gst-launch or similar.

https://bugzilla.gnome.org/show_bug.cgi?id=777375
2017-02-23 21:00:16 +02:00
Sebastian Dröge
ba49927aaf value: Add a type abbreviation for GstFlagSet in serialization 2017-02-23 20:50:38 +02:00
Vivia Nikolaidou
a3cfcbfede value: Always add the type name to elements when serializing arrays/lists
But only when serializing outside of GstStructures, because in case of
GstStructure the type is already preprended to the array/list and the
GstStructure API makes sure that they have the same "generic" type so
deserialization works properly.

This keeps serialization of GstStructures the same as before, and the
GstCaps unit tests already test for that. However when serializing
standalone arrays/lists get the types added now.
2017-02-23 20:48:40 +02:00
Vivia Nikolaidou
33118f6118 value: Move list/array serialization/deserialization functions from GstStructure to GstValue
https://bugzilla.gnome.org/show_bug.cgi?id=777375
2017-02-23 20:22:03 +02:00
Thibault Saunier
a87b4551a6 Port gtk-doc comments to their equivalent markdown syntax
Modernizing our documentation and preparing a possible move to hotdoc.
This commits also adds missing @title metadatas to all SECTIONs
2017-01-27 16:36:38 -03:00
Matthew Waters
ad40c5cd36 value: add structure intersect/union/is_subset/fixate implementations
Allows proper usage of structures in structures in caps.  Subtraction
is not implemented due to complications with empty fields representing
all possible values.

The only implementation that doesn't delegate to the already existing
GstStructure functions is the union function.

https://bugzilla.gnome.org/show_bug.cgi?id=775796
2016-12-15 13:39:57 +11:00
Stefan Sauer
96304d613f gstvalue: add serialisation for GTypes
We need this in the GstTracerRecord. This will serialize GTypes to the typename
and vice versa.
2016-12-13 13:24:18 +01:00
Jan Schmidt
e1dc60524e dynamic types: Implement dynamic types in the registry
Implement GstDynamicTypeFactory as a new registry feature.

GstDynamicTypeFactory provides a way of registering a GType
into the registry, such that it will be registered as a dynamic
type when the registry is loaded, and then automatically loaded
if the type is needed during caps parsing.

This allows using non-core types in pad templates, by loading a
registry feature to create the GType on the fly.

https://bugzilla.gnome.org/show_bug.cgi?id=750079
2016-11-02 11:21:37 +11:00
Sebastian Dröge
1a1152fa03 value: Update GstValue table size for GValueArray 2016-11-01 23:54:05 +02:00
Stian Selnes
c85a30f80b gstvalue: Make GValueArray serializable
For instance very useful for logging GValueArray with GST_PTR_FORMAT

https://bugzilla.gnome.org/show_bug.cgi?id=761918
2016-11-01 20:30:43 +02:00
Jan Schmidt
a95645eaba value: Implement can_intersect for GstFlagSet types
Make sure that gst_value_can_intersect returns TRUE
for GstFlagSet combinations that can successfully
intersect
2016-08-26 03:23:40 +10:00
Stefan Sauer
eaa992825d gstvalue: remove a half finishesh sentence in the docs
No idea what was the idea here. SO lets just drop it.
2016-01-20 10:02:37 +01:00
Stefan Sauer
4859494945 tracer: add an internal ptr format for tracer serialisation
We need to apply the string wrapping that value serialisation does also in the
tracer logging, otherwise we can't parse nested structures.
2016-01-20 09:14:12 +01:00
Tim-Philipp Müller
eb4c5498b5 value: fail flag deserialization on invalid flag names 2016-01-18 19:39:11 +00:00
Sebastian Dröge
3e8ef4cf5a Update GLib dependency to 2.40.0 2015-10-02 22:18:24 +03:00
Vineeth TM
0eb9dde1e8 value: free caps during failure
While calling gst_value_deserialize_sample, if there is a failure
after caps is ref'ed, then caps is getting leaked. Hence checking for
caps in fail: goto condition and unref'ing it

https://bugzilla.gnome.org/show_bug.cgi?id=753338
2015-08-07 10:17:02 +02:00
Nicolas Dufresne
48700c7791 doc: More doc warning fixes
So from this point, the remaining warning for libgstreamer are about
protected member not showing in the doc. This may need some discussion
with upstream gtk-doc people.

* Remove % in from of none macro
* Fixed GST_TYPE_FAGS -> GST_TYPE_FAG_SET
* Minor wording fix
* Can't link to GstUri.port, so split the .port part
2015-06-14 10:29:04 -04:00
Jan Schmidt
58e5cd2695 gstvalue: Implement gst_value_is_subset() for flagsets 2015-06-03 00:48:17 +10:00
Jan Schmidt
f9e5178dd1 gstvalue: Add GstFlagSet type
GstFlagSet is a new type designed for negotiating sets
of boolean capabilities flags, consisting of a 32-bit
flags bitfield and 32-bit mask field. The mask field
indicates which of the flags bits an element needs to have
as specific values, and which it doesn't care about.

This allows efficient negotiation of arrays of boolean
capabilities.

The standard serialisation format is FLAGS:MASK, with
flags and mask fields expressed in hexadecimal, however
GstFlagSet has a gst_register_flagset() function, which
associates a new GstFlagSet derived type with an existing
GFlags gtype. When serializing a GstFlagSet with an
associated set of GFlags, it also serializes a human-readable
form of the flags for easier debugging.

It is possible to parse a GFlags style serialisation of a
flagset, without the hex portion on the front. ie,
+flag1/flag2/flag3+flag4, to indicate that
flag1 & flag4 must be set, and flag2/flag3 must be unset,
and any other flags are don't-care.

https://bugzilla.gnome.org/show_bug.cgi?id=746373
2015-05-25 16:23:33 +10:00
Thibault Saunier
99d3179634 gstvalue: Add a comparision function for GstStructures 2015-05-20 20:21:24 +02:00
Hyunjun Ko
e08c03ed07 gstvalue: reset errno before g_ascii_strtoull call
"errno" already has meaningless value before g_ascii_strtoull call.
This causes invalid error check without reset.

https://bugzilla.gnome.org/show_bug.cgi?id=747690
2015-04-13 11:39:59 +01:00
Luis de Bethencourt
555e0211c8 gstvalue: only unwrap string delimited with "
Don't unwrap strings that start but don't finish with a double quote. If a
string is delimited by two quotes we unescape them and any special characters
in the middle (like \" or \\). If the first character or the last character
aren't a quote we assume it's part of an unescaped string.

Moved some deserialize_string unit tests because we don't try to unwrap strings
missing that second quote anymore.

https://bugzilla.gnome.org/show_bug.cgi?id=688625
2015-03-27 17:18:23 +00:00
Jan Schmidt
d33440b51e gstvalue: Tidy initialisation
Use some macros to make our value functions setup a bit
tidier, and micro-optimise a few reallocs by setting an
initial size for the global type arrays.
2014-10-20 23:55:47 +11:00
Stefan Sauer
d5518edf12 fixme: bump leftover 0.11 fixme comments 2014-09-25 21:27:03 +02:00
Thiago Santos
4ca6694e09 gstvalue: add GstTagList compare function
When serializing GstStructures from events in GDP it will add a taglist
as a GstStructure field, having the compare function allows comparison of
GstStructures to check if the serialized/deserialized version matches the
original one, among other cases.

https://bugzilla.gnome.org/show_bug.cgi?id=733131
2014-07-21 11:42:05 -03:00
Sebastian Rasmussen
863ba1a598 docs: Fix documentation typos and inconsistencies
* GstGlobalDeviceMonitor was renamed to GstDeviceMonitor
 * Expand GST_MESSAGE_DEVICE to the full enum value names
 * Correct the incorrect references to the GstDeviceProvider interfaces
 * Describe caps arguments for gstcheck interface
 * Add missing docs for GstNetAddressMeta and its add function
 * Add docs for toc helper macros
 * Avoid refering to GstValueList type as done elsewhere

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=732786
2014-07-09 09:22:11 +02:00
Evan Nemerson
5d80cf12ba introspection: add nullability annotations to out and inout params
https://bugzilla.gnome.org/show_bug.cgi?id=730957
2014-06-26 18:59:15 +02:00
Evan Nemerson
2759882379 introspection: add missing (nullable) annotations to return values
Support for (nullable) was added to G-I at the same time as nullable
return values.  Previous versions of G-I will not mark return values as
nullable, even when an (allow-none) annotation is present, so it is
not necessary to add (allow-none) annotations for compatibility with
older versions of G-I.

https://bugzilla.gnome.org/show_bug.cgi?id=730957
2014-06-26 18:56:38 +02:00
Tim-Philipp Müller
bc75a166f0 gstvalue: optimise checks for lists
Our fundamental types are non-derivable, so we can
just check for equality. Also avoid doing the same
check multiple times in a couple of places.
2014-06-19 08:40:16 +01:00
Tim-Philipp Müller
d74708a820 gstvalue: use g_assert() in internal function for already-checked things
So these get compiled out for releases.
2014-06-19 08:40:15 +01:00
Tim-Philipp Müller
bbefd6082f gstvalue: add internal _can_compare_unchecked() 2014-06-19 08:40:15 +01:00
Tim-Philipp Müller
adcbe94aff gstvalue: add internal _list_concat() that takes ownership of input values
Avoids unnecessary copies.
2014-06-19 08:40:15 +01:00