Commit graph

308 commits

Author SHA1 Message Date
Edward Hervey 8b51e9dc60 gstvalue: Prevent division or modulo by zero
The step can end up being zero if the underlying value isn't a valid
range GValue.

In those cases, return FALSE.

We don't use g_return*_if_fail since it will already have been triggered
by the above-mentionned _get_step() functions.

CID #1037132
2014-04-17 13:20:45 +02:00
Edward Hervey 470f194909 gstvalue: Prevent division or modulo by zero
The step can end up being zero if the underlying value isn't a valid
range GValue.

In those cases, return FALSE.

We don't use g_return*_if_fail since it will already have been triggered
by the above-mentionned _get_step() functions.

Spotted by Coverity.
2014-04-05 11:37:53 +02:00
Haakon Sporsheim e3388c22c2 gstvalue: Fix comparison of int/int64 range
Checking step three times seems unnecessary.
A similar bug was fixed for double range in
commit 3ea6b04c10
2014-04-05 07:03:07 +02:00
Edward Hervey 3ea6b04c10 gstvalue: Fix comparision of double range
Checking twice the lower bound is great (you never know, it might change
between the two calls by someone using emacs butterfly-mode), but it's a bit
more useful to check the higher bound are also identical.

Detected by Coverity
2013-12-10 18:01:52 -05:00
Sebastian Rasmussen 53ae1b2c9c docs: Fix typos in function/object descriptions
Fixes https://bugzilla.gnome.org/show_bug.cgi?id=720029
2013-12-07 17:11:12 +00:00
Sebastian Rasmussen 49950e57ad docs: add missing docs, fixing doc errors
* add many missing declarations to sections
 * GstController has been removed, update docs
 * skip GstIndex when generating documentation
 * rephrase so gtkdoc doesn't imagine return value
 * add missing argument description for gst_context_new()
 * document GstOutputSelectorPadNegotiationMode and move to header-file

https://bugzilla.gnome.org/show_bug.cgi?id=719614
2013-12-03 00:11:59 +00:00
Sebastian Dröge 5286479467 value: Lists with all equal elements are equal to a single value
Otherwise caps containing f={X, X} are not compatible with f=X

https://bugzilla.gnome.org/show_bug.cgi?id=709253
2013-11-13 19:57:23 +01:00
Thiago Santos 007c0e5fe1 value: fix caps serialization when there are caps inside caps
Wrap caps strings so that it can handle serialization and deserialization
of caps inside caps. Otherwise the values from the internal caps are parsed
as if they were from the upper one

https://bugzilla.gnome.org/show_bug.cgi?id=708772
2013-09-30 16:20:48 -03:00
Sebastian Dröge d55893fb96 value: Fix copy&paste mistakes in the bitmask function docs 2013-07-24 16:57:46 +02:00
Tim-Philipp Müller 0c513e3d97 value: handle deserialisation of nonexistant enum value more gracefully 2013-07-22 17:25:47 +01:00
Edward Hervey 2e1db58e11 gstvalue: Add _append_and_take_value() public variants
API: gst_value_array_append_and_take_value
API: gst_value_list_append_and_take_value

We were already using this internally, this makes it public for code
which frequently appends values which are expensive to copy (like
structures, arrays, caps, ...).

Avoids copies of the values for users. The passed GValue will also
be 0-memset'ed for re-use.

New users can replace this kind of code:
gst_value_*_append_value(mycontainer, &myvalue);
g_value_unset(&myvalue);

by:

gst_value_*_append_and_take_value(mycontainer, &myvalue);

https://bugzilla.gnome.org/show_bug.cgi?id=701632
2013-06-05 12:58:05 +02:00
Andre Moreira Magalhaes (andrunko) a8300a4891 gstvalue: Add compare function for caps 2013-04-18 14:45:47 -03:00
Sebastian Dröge 7477b25df5 caps: Add new data type for handling caps features to the caps
These are meant to specify features in caps that are required
for a specific structure, for example a specific memory type
or meta.

Semantically they could be though of as an extension of the media
type name of the structures and are handled exactly like that.
2013-03-31 18:15:52 +02:00
Sebastian Dröge fb3b53328f value: Remove set-style bitmask intersection/union/subtraction functions
Set operations on the bitmasks don't make much sense and result
in invalid caps when used as a channel-mask. They are now handled
exactly like integers.

This functionality was not used anywhere except for tests.

https://bugzilla.gnome.org/show_bug.cgi?id=691370
2013-02-13 17:07:47 +01:00
Tim 'mithro' Ansell bd65fc0036 gstvalue: Adding offset to GstSegment serialize/deserialize.
Fixes https://bugzilla.gnome.org/show_bug.cgi?id=693587
2013-02-11 14:19:27 +01:00
Tim-Philipp Müller 172011d1f5 gstvalue: some micro-optimisations
Avoid unnecessary value copying, and unnecessary init/unset
cycles which all go through the value table. There's a bunch
of places where we copy a value and then unset it in the next
line, instead of just taking over the source value.
2012-12-22 16:38:58 +00:00
Sebastian Dröge da0f9977f0 value: Use the GLib GType for GThread if compiling against GLib 2.35.3 or newer 2012-11-20 15:06:14 +01:00
Sebastian Dröge 08e0fcd7b2 value: API: Add boxed type for GThread 2012-11-12 11:40:59 +01:00
Tim-Philipp Müller 666c8c11c6 Fix FSF address
https://bugzilla.gnome.org/show_bug.cgi?id=687520
2012-11-03 20:44:48 +00:00
Tim-Philipp Müller 507fc9cea7 value: avoid duplicates when intersecting lists
Fixes negotiation taking a ridiculous amount of
time (multiple 10s of seconds on a core2) when
there are duplicate entries in lists.

Could have a negative performance impact on other
scenarios because we now have to iterate the
dest list to avoid duplicates, but we don't
have a lot of lists any more these days, and
they tend to be small anyway. The negatives
are hopefully countered by the positive effects
of reducing the list length early on in the
process. And in any case, it's the right thing
to do.

Based on patch by Andre Moreira Magalhaes.

https://bugzilla.gnome.org/show_bug.cgi?id=684981
2012-09-29 14:35:58 +01:00
Tim-Philipp Müller c2175db889 sample: add serialisation/deserialisation functions for GstSample
Since these things are inside taglists now, it would be good to be
able to print them and deserialise them.

https://bugzilla.gnome.org/show_bug.cgi?id=681322
2012-09-16 23:20:46 +01:00
Alban Browaeys 7bf7749c2b value: fix crash serialising a 0 flags value when there's no name for it
Fixes segfault when doing gst-launch-1.0 -v -m camerabin
(encodebin notifies a 0 value for its "flag" property).

https://bugzilla.gnome.org/show_bug.cgi?id=682958
2012-08-29 18:59:21 +01:00
Tim-Philipp Müller 718a10edda value: when serialising arrays or lists, handle types we can't serialise more gracefully
https://bugzilla.gnome.org/show_bug.cgi?id=681322
2012-08-13 00:01:16 +01:00
Tim-Philipp Müller ffdefd7720 value: add GstTagList serialisation/deserialisation
So we can serialise/deserialise taglists inside structures,
which used to work automagically before because GstTagList
was just a typedef to GstStructure (same for the GType),
but now that it's a separate GType we need to register
explicit functions for this.

Helps with GDP stuff in pipelines/streamheader tests.
2012-07-20 09:39:53 +01:00
Edward Hervey d3ffa82639 Remove 0.10-related documentation and "Since" markers 2012-07-10 12:03:27 +02:00
Tim-Philipp Müller 93a2b6e9b3 value: use datetime serialise/deserialise functions for datetimes
This re-uses existing code and makes sure we properly serialise
and deserialise datetimes where not all fields are set (thus
fixing some warnings when serialising such datetimes).
2012-07-07 22:46:00 +01:00
Tim-Philipp Müller 5a6be2201d datetime: fix compare function
Take into account that not all fields might be valid (though they
are valid in the GDateTime structure). But we should just return
unordered if the set fields don't match. Also, don't check
microseconds when comparing datetimes, since we don't serialise
those by default if they're available. This ensures date times are
still regarded as equal after serialising+deserialising.
2012-06-27 13:51:33 +01:00
Tim-Philipp Müller 06d96f1bda value: fix int64 - int64 range intersection on big endian systems
Works better if we use the v_int64 field of the GValue instead of v_int.
2012-06-23 21:35:33 +01:00
Tim-Philipp Müller bc28ebf08d sample: add compare function for GstSample
Should make gst_tag_list_is_equal() work properly with image tags.

https://bugzilla.gnome.org/show_bug.cgi?id=672637
2012-06-23 16:59:10 +01:00
Tim-Philipp Müller 533ecb8840 value: fix buffer compare function 2012-06-23 16:30:03 +01:00
Wim Taymans d342871907 segment: add rude serialization
Ass serialize and deserialize functions for GstSegment so that gdp and
gst_structure_to_string show the segment values. We convert to a GstSegment
first to make things easier..

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=674100
2012-04-16 15:56:11 +02:00
Wim Taymans ce67b0e539 docs: update more documentation 2012-03-29 13:34:50 +02:00
Wim Taymans 85c9543841 memory: group allocation parameters in a struct
Group the extra allocation parameters in a GstAllocationParams structure to make
it easier to deal with them and so that we can extend them later if needed.
Make gst_buffer_new_allocate() take the GstAllocationParams for added
functionality.
Add boxed type for GstAllocationParams.
2012-03-15 13:42:17 +01:00
Tim-Philipp Müller 3e8d6d6064 value: remove gst_value_register_{subtract,union,intersect}_func() API
There isn't really any need to provide public API for that. It's not
used anywhere in practice, and we aim to provide an API that works
for GstCaps, not some kind of generic set manipulation API based on
GValue. Making this private also makes it easier to optimise this
later. We can always put it back if someone actually needs it.
2012-03-08 11:21:37 +00:00
Edward Hervey 60be53fabf gstvalue: Remove useless assignment 2012-02-17 15:11:38 -08:00
Edward Hervey 963267643e gstvalue: Gracefully handle NULL Gvalue
Avoids unreferencing NULL pointer
2012-02-17 15:11:38 -08:00
Wim Taymans 39c5f0b28a don't do logic in g_assert... 2012-01-31 12:10:21 +01:00
Olivier Crête e234a10c63 Use macros to register boxed types thread safely 2012-01-28 16:42:38 +00:00
Wim Taymans a521252845 Add new GstMapInfo
Use a structure to hold info about the mapping. The application then keeps track
of this state and we can use it to unmap the memory again later.
2012-01-25 11:54:23 +01:00
Vincent Penquerc'h fc1fab8a15 gstvalue: handle NULL dest in bitmask/bitmask intersection 2012-01-24 14:40:33 +00:00
Vincent Penquerc'h 39533f4364 gstvalue: add stepped ranges
int and int64 ranges can now have an optional step (defaulting to 1).
Members of the range are those values within the min and max bounds
which are a multiple of this step.

https://bugzilla.gnome.org/show_bug.cgi?id=665294
2012-01-24 12:11:44 +00:00
Vincent Penquerc'h b6abb9794c gstvalue: enforce identical basic types in lists, arrays
https://bugzilla.gnome.org/show_bug.cgi?id=322587
2012-01-24 12:11:44 +00:00
Tim-Philipp Müller c721d53773 Remove GST_TYPE_DATE, our own GDate type
Which we had to add because GLib didn't have it
back in the day. Port everything to plain old
G_TYPE_DATE, which is also a boxed type. Ideally
we'd just use GDateTime for everything, but it
doesn't support not setting some of the fields
unfortuntely (which would be very useful for
tag handling in general, if we could express
2012-01 for example).

https://bugzilla.gnome.org/show_bug.cgi?id=666351
2012-01-12 20:50:53 +00:00
Edward Hervey 77506a82b0 gstvalue: Allow NULL dest when subtracting bitmask
Happens when checking for subsets of caps
2012-01-06 15:01:24 +01:00
Sebastian Dröge 4294b88e35 value: Add 64-bit bitmask type 2012-01-05 10:24:14 +01:00
Edward Hervey e136cc334f Merge remote-tracking branch 'origin/master' into 0.11 2011-12-29 16:49:39 +01:00
Tim-Philipp Müller ee7f9f4228 value: micro-optimisation: avoid some unnecessary g_value_unset()
We know there's nothing to do here and can save us the function
calls and GValueTable lookups.
2011-12-26 11:27:07 +00:00
Wim Taymans a22c2716cd Merge branch 'master' into 0.11 2011-11-09 12:03:28 +01:00
Vincent Penquerc'h d9e5c529ba gstvalue: consider lists and ranges equal if they hold the same set
This fixes caps operations when different elements advertise some
of their caps' properties differently (eg, for audio channels, either
a range from 1 to 2, or a list of 1 and 2).

https://bugzilla.gnome.org/show_bug.cgi?id=663643
2011-11-09 11:24:55 +01:00
Wim Taymans c9a4037805 Merge branch 'master' into 0.11
Conflicts:
	gst/gstvalue.c
2011-11-07 17:17:39 +01:00
Vincent Penquerc'h b37d06aed8 gstvalue: quicker version of intersection when we do not need the result
https://bugzilla.gnome.org/show_bug.cgi?id=662777
2011-11-07 15:17:19 +00:00
Vincent Penquerc'h 29c97fe780 gstvalue: quicker test for substraction emptiness
When we do not care about the actual resulting set,
but only whether it is empty of not, we can skip a fair bit
of GValue juggling.

Add a function that does so, since we cannot just pass NULL
to the existing API as it may be part of the API contract.

https://bugzilla.gnome.org/show_bug.cgi?id=662777
2011-11-07 15:16:52 +00:00
Johan Dahlin 9200776841 introspection: Skip GType and GValue transform apis
These do not make sense to expose to language bindings

https://bugzilla.gnome.org/show_bug.cgi?id=657640
2011-10-19 10:24:11 +02:00
Edward Hervey 917bfc5df7 gst: More 'transfer' annotations 2011-10-11 13:51:37 +02:00
Sebastian Dröge 43538e2e75 Merge branch 'master' into 0.11
Conflicts:
	docs/design/draft-buffer2.txt
	docs/design/part-TODO.txt
	docs/design/part-block.txt
	docs/design/part-bufferlist.txt
	docs/design/part-caps.txt
	docs/design/part-element-transform.txt
	docs/design/part-events.txt
	docs/design/part-negotiation.txt
	gst/gstcaps.c
	gst/gstevent.h
	gst/gstghostpad.c
	gst/gstinterface.c
	gst/gstpad.c
	gst/gstpad.h
	gst/gstutils.c
	libs/gst/base/gstbasesink.c
	libs/gst/base/gstbasesrc.c
	libs/gst/base/gstbasetransform.c
	libs/gst/base/gsttypefindhelper.c
	plugins/elements/gstcapsfilter.c
	plugins/elements/gsttee.c
	tests/check/generic/sinks.c
	tools/gst-launch.1.in
2011-09-08 14:28:23 +02:00
Piotr Fusik 14f5518f3d docs, gst: typo fixes
https://bugzilla.gnome.org/show_bug.cgi?id=658449
2011-09-07 18:03:17 +01:00
Wim Taymans 4145598972 gst: add some _priv prefixes to private methods 2011-08-29 13:27:26 +02:00
Wim Taymans 5cf8e68944 Merge branch 'master' into 0.11
Conflicts:
	gst/gstmessage.c
	gst/gstquery.c
	gst/gstregistrychunks.c
	gst/gstsegment.c
	libs/gst/base/gstbasetransform.c
	libs/gst/base/gstbasetransform.h
	libs/gst/base/gsttypefindhelper.c
	plugins/elements/gsttypefindelement.c
2011-08-26 14:37:54 +02:00
Josep Torra b26c5b99f2 value: explicitly cast to the enum type
Fixes warning #188: enumerated type mixed with another type reported by ICC.
2011-08-26 14:11:14 +02:00
Wim Taymans 405a5d2a92 value: remove our FOURCC GType
Remove our custom fourcc GValue.
2011-08-22 12:19:19 +02:00
Wim Taymans b27ee30a35 buffer: make new _buffer_allocate method
Make a new method to allocate a buffer + memory that takes the allocator and the
alignment as parameters. Provide a macro for the old method but prefer to use
the new method to encourage plugins to negotiate the allocator properly.
2011-06-10 13:49:23 +02:00
Wim Taymans e2b6e88d5f value: add function to fixate a value
Add a function to fixate a GValue. This is the same function as is in GstPad.
2011-06-02 13:21:55 +02:00
Wim Taymans 272b3263aa Merge branch 'master' into 0.11
Conflicts:
	plugins/elements/gstoutputselector.c
2011-06-01 19:47:10 +02:00
Sebastian Dröge 0a80b57d74 value: Consider "1" and "{1}" as equal in gst_value_compare()
Previously this was only done in the is_subset() check but
having it only there brings us into definition-hell where
"1" and "{1}" are subset of each other but not equal.
2011-05-30 11:33:57 +02:00
Sebastian Dröge 98d1ee4a8f gst: Update everything for the new GstIterator API 2011-05-05 15:36:03 +02:00
Wim Taymans d82c8bd2af memory: port code to new buffer data API 2011-03-28 20:08:45 +02:00
Wim Taymans 6c18c9508d miniobject: more boxed type fixing
More miniobject fixing, leaks horribly somewhere..
2011-02-23 10:35:09 +01:00
Tim-Philipp Müller 3a744ca442 value: add (de)serialisation function for uchar
.. since we sadly have a plugin in -good that has a uchar property
(cmmlenc)

https://bugzilla.gnome.org/show_bug.cgi?id=642522
2011-02-17 10:55:28 +00:00
Tim-Philipp Müller ee5b369ffd gstvalue: make new gst_value_list_merge() work properly
Fix freeing of partially-inited list value when both values
passed are equal and we want to return a single non-list
value as result. Fixes unit test. Also fix up docs a bit.

https://bugzilla.gnome.org/show_bug.cgi?id=637776
2011-01-03 15:57:20 +00:00
Stefan Kost 373be6f14e tags: don't produce duplicated entries when merging same value twice
Add a variant of gst_value_list_concat() that skips duplicates and use that when
merging taglists.

API: gst_value_list_merge()
2011-01-02 22:35:08 +00:00
Tim-Philipp Müller 3256c708be docs: gst: more gobject introspection annotations
Many of these are superfluous, added for clarity.
2010-12-07 18:37:04 +00:00
Tim-Philipp Müller 5b25761f29 docs: add some gtk-doc Since: markers
Add some gtk-doc Since: markers, fix one Since: marker,
fix typo.
2010-10-16 16:53:49 +01:00
Thiago Santos e9312870e5 datetime: Use seconds as double
Use seconds as double to make API similar to glib's
gdatetime. Also move timezone parameter to the
first position, just like glib's.

https://bugzilla.gnome.org/show_bug.cgi?id=628408
2010-10-13 11:48:57 -03:00
Thiago Santos dd53349ad2 gstdatetime: Fix string serialization
Correctly serialize tzoffset as a gstvalue
2010-09-27 20:41:52 -03:00
Philippe Normand b2e6379be8 gstvalue: Add new GstInt64Range type
new GstInt64Range to store gint64 ranges.

API: GST_TYPE_INT64_RANGE
API: gst_value_set_int64_range
API: gst_value_get_int64_range_min
API: gst_value_get_int64_range_max

Fixes bug #627826.
2010-09-01 11:07:37 +02:00
Sebastian Dröge 8ca48752fb utils: Add gst_util_fraction_compare() to compare fractions
And use it for the fraction comparisons in gstvalue.c instead
of using comparisons by first converting the fractions to double.
Should fix bug #628174.

API: gst_util_fraction_compare()
2010-08-28 09:31:59 +02:00
Shixin Zeng d41997040b gst: make _get_type() in gst/* thread safe
This is not really necessary here because everything is
initialized from gst_init() already but using G_DEFINE_TYPE()
removes some copy&paste boilerplate code.
2010-08-06 19:35:59 +02:00
Thiago Santos b4870282cb gstvalue: Adds datetime functions
Adds a datetime functions to gstvalue

Fixes #594504
2010-07-26 11:57:50 -03:00
Edward Hervey 27410f3934 gstvalue: Improve gst_value_{set|get}_caps docs 2010-07-06 11:18:32 +02:00
Sebastian Dröge 4d8320e4c6 gstvalue: Add some more assertions and checks for valid input parameters 2010-06-14 15:45:11 +02:00
Sebastian Dröge 603c04f4fa gstvalue: Don't initialize arrays from variables 2010-06-14 08:18:00 +02:00
Sebastian Dröge 48438b6cc7 gstvalue: Add some assertion guards against invalid parameters to public API 2010-06-13 18:00:22 +02:00
Martin Bisson ab0763f0e8 value: Fixed serialization for short fourccs.
"Y16 " and "Y8  " were not displayed properly because the space
character is not alnum.  A unit test is also included.

Fixes bug #621282.
2010-06-12 08:07:34 +02:00
Stefan Kost ad619a4e84 value: use glib types in more places
Do a bunch of char -> gchar, int -> gint, double -> gdouble changes.
2010-06-07 12:22:44 +03:00
Stefan Kost c95a85f6cf value: just compute strlen() once 2010-06-07 12:22:44 +03:00
Martin Bisson 28fdbee35a value: Add support for parsing short fourccs from strings
For example "Y16 " and "Y8  ".
2010-06-07 08:21:00 +02:00
Benjamin Otte a9d1a493a7 Fixes for -Wwrite-strings
This changes some APIs in compatible ways:
- Some functions now take "const char *" arguments, not "char *"
- Some structs now have "conts char *" members, not "char *"
The changes may cause warnings when compiling with the right warning
flags. You've been warned.

Also adds -Wwrite-strings as a warning flag in configure.ac.

https://bugzilla.gnome.org/show_bug.cgi?id=611692
2010-03-10 20:50:10 +01:00
Benjamin Otte ec10b764b9 caps: Fail when fractions are followed by random text
Previous code treated "1/1yourmom" the same as "1/1" and "1wimsmom" the
same as "1". Now the code is stricter and will fail to convert a
fraction when followed by garbage text.
2010-03-09 19:18:21 +01:00
Benjamin Otte 4743e62be8 caps: Allow 1/max as the minimal fraction value > 0
This is useful for formats that require a valid framerate (like
theoraenc).
2010-03-08 22:26:34 +01:00
Edward Hervey a5626f239a gstvalue: Use fast gst_value_list_{size|get_value} macro accessors
gst_value_list_size and gst_value_list_get_value will do a series of
extra checks due to being public methods.
When we use them from within gstvalue.c we can directly use them without
the extra checks.
2009-12-07 09:51:04 +01:00
Stefan Kost f43f2bf960 docs: fix more bogus xrefs 2009-11-27 14:18:38 +02:00
Stefan Kost 23da3639f0 docs: fix xrefs in docs
Fix typos in xrefs, links to non existing functions and rework plural forms.
2009-11-25 16:59:50 +02:00
Sebastian Dröge 0ed24bc50e utils: API: Add multiplication and addition functions for fractions
gst_util_fraction_add()
gst_util_fraction_multiply()

These work on plain integers instead of GValues to
keep the overhead as low as possible.
2009-11-16 09:56:32 +01:00
Sebastian Dröge e4257e8d5f gstutils: API: Add fraction helper functions
gst_util_greatest_common_divisor()
gst_util_double_to_fraction()
gst_util_fraction_to_double()

Using these instead of going over GValue has much lower overhead.

Also add float<->fraction transform functions for GValue.
2009-11-16 09:56:32 +01:00
Stefan Kost cfb4aa4627 build: sprintf, sscanf need stdio.h 2009-10-07 10:59:54 +03:00
Benjamin Otte fceba1d6fe docs: Fix typo in gst_value_union() 2009-09-07 16:16:19 +02:00
Stefan Kost f18bee2d8a value: add explanation for shortcut 2009-07-14 12:15:05 +03:00
Stefan Kost c686053aac value: fix can_intersect to behave like intersect
Add a quick return if two types are the same. Change the check for the
intersection function to be the same as the one used in intersect(). The
later tries both directions.
2009-07-14 08:32:23 +02:00
Jan Schmidt 7bf3554228 structure: Change NULL and empty string handling
Don't forbid the empty string "" in generic structures, only in taglists.
Properly allow the NULL string by adding special cases for serialising
and deserialising it. prop1=(string)NULL is the NULL string,
prop1=(string)"NULL" is the actual string with the value "NULL"
2009-07-13 18:28:37 +01:00
Edward Hervey 923913984e Use local variables in for/while loops.
This makes the generated code faster since:
* It won't have to read an undirect value (which will most likely be
 outside of the L1/L2 cache)
* We know that value never changes (the compiler has no clue that it doesn't).
2009-06-30 16:29:50 +02:00