mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
caps: delay _make_writable() until needed in _normalize()
Delay _make_writable() until we actually found a list and need to update the caps.
This commit is contained in:
parent
4cdddd2bb1
commit
5e719a293a
1 changed files with 10 additions and 6 deletions
|
@ -1575,6 +1575,7 @@ typedef struct _NormalizeForeach
|
||||||
{
|
{
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
GstStructure *structure;
|
GstStructure *structure;
|
||||||
|
gboolean writable;
|
||||||
}
|
}
|
||||||
NormalizeForeach;
|
NormalizeForeach;
|
||||||
|
|
||||||
|
@ -1592,6 +1593,10 @@ gst_caps_normalize_foreach (GQuark field_id, const GValue * value, gpointer ptr)
|
||||||
GstStructure *structure = gst_structure_copy (nf->structure);
|
GstStructure *structure = gst_structure_copy (nf->structure);
|
||||||
|
|
||||||
gst_structure_id_set_value (structure, field_id, v);
|
gst_structure_id_set_value (structure, field_id, v);
|
||||||
|
if (G_UNLIKELY (!nf->writable)) {
|
||||||
|
nf->caps = gst_caps_make_writable (nf->caps);
|
||||||
|
nf->writable = TRUE;
|
||||||
|
}
|
||||||
gst_caps_append_structure_unchecked (nf->caps, structure);
|
gst_caps_append_structure_unchecked (nf->caps, structure);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1620,22 +1625,21 @@ GstCaps *
|
||||||
gst_caps_normalize (GstCaps * caps)
|
gst_caps_normalize (GstCaps * caps)
|
||||||
{
|
{
|
||||||
NormalizeForeach nf;
|
NormalizeForeach nf;
|
||||||
GstCaps *newcaps;
|
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
g_return_val_if_fail (GST_IS_CAPS (caps), NULL);
|
g_return_val_if_fail (GST_IS_CAPS (caps), NULL);
|
||||||
|
|
||||||
newcaps = gst_caps_make_writable (caps);
|
nf.caps = caps;
|
||||||
nf.caps = newcaps;
|
nf.writable = FALSE;
|
||||||
|
|
||||||
for (i = 0; i < gst_caps_get_size (newcaps); i++) {
|
for (i = 0; i < gst_caps_get_size (nf.caps); i++) {
|
||||||
nf.structure = gst_caps_get_structure_unchecked (newcaps, i);
|
nf.structure = gst_caps_get_structure_unchecked (nf.caps, i);
|
||||||
|
|
||||||
while (!gst_structure_foreach (nf.structure,
|
while (!gst_structure_foreach (nf.structure,
|
||||||
gst_caps_normalize_foreach, &nf));
|
gst_caps_normalize_foreach, &nf));
|
||||||
}
|
}
|
||||||
|
|
||||||
return newcaps;
|
return nf.caps;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
|
|
Loading…
Reference in a new issue