mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-22 23:28:16 +00:00
gst: Update for the GstBaseTransform::transform_caps() changes
This commit is contained in:
parent
8501753033
commit
d8e0af1fc1
4 changed files with 170 additions and 155 deletions
|
@ -490,7 +490,8 @@ strip_width_64 (GstStructure * s)
|
|||
|
||||
/* Little utility function to create a related structure for float/int */
|
||||
static void
|
||||
append_with_other_format (GstCaps * caps, GstStructure * s, gboolean isfloat)
|
||||
append_with_other_format (GstCaps * caps, const GstStructure * s,
|
||||
gboolean isfloat)
|
||||
{
|
||||
GstStructure *s2;
|
||||
|
||||
|
@ -501,12 +502,12 @@ append_with_other_format (GstCaps * caps, GstStructure * s, gboolean isfloat)
|
|||
/* If 64 bit float was allowed; remove width 64: we don't support it for
|
||||
* integer*/
|
||||
strip_width_64 (s2);
|
||||
gst_caps_append_structure (caps, s2);
|
||||
gst_caps_merge_structure (caps, s2);
|
||||
} else {
|
||||
s2 = gst_structure_copy (s);
|
||||
gst_structure_set_name (s2, "audio/x-raw-float");
|
||||
make_lossless_changes (s2, TRUE);
|
||||
gst_caps_append_structure (caps, s2);
|
||||
gst_caps_merge_structure (caps, s2);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -567,11 +568,15 @@ gst_audio_convert_transform_caps (GstBaseTransform * base,
|
|||
"width", "depth", "rate", "channels", "endianness", "signed"
|
||||
};
|
||||
const gchar *structure_name;
|
||||
gint n, j;
|
||||
int i;
|
||||
|
||||
g_return_val_if_fail (GST_CAPS_IS_SIMPLE (caps), NULL);
|
||||
n = gst_caps_get_size (caps);
|
||||
|
||||
structure = gst_caps_get_structure (caps, 0);
|
||||
ret = gst_caps_new_empty ();
|
||||
|
||||
for (j = 0; j < n; j++) {
|
||||
structure = gst_caps_get_structure (caps, j);
|
||||
structure_name = gst_structure_get_name (structure);
|
||||
|
||||
isfloat = strcmp (structure_name, "audio/x-raw-float") == 0;
|
||||
|
@ -593,11 +598,9 @@ gst_audio_convert_transform_caps (GstBaseTransform * base,
|
|||
gst_structure_set (s, "depth", G_TYPE_INT, width, NULL);
|
||||
}
|
||||
|
||||
ret = gst_caps_new_empty ();
|
||||
|
||||
/* All lossless conversions */
|
||||
s = make_lossless_changes (s, isfloat);
|
||||
gst_caps_append_structure (ret, s);
|
||||
gst_caps_merge_structure (ret, gst_structure_copy (s));
|
||||
|
||||
/* Same, plus a float<->int conversion */
|
||||
append_with_other_format (ret, s, isfloat);
|
||||
|
@ -606,7 +609,6 @@ gst_audio_convert_transform_caps (GstBaseTransform * base,
|
|||
|
||||
/* We don't mind increasing width/depth/channels, but reducing them is
|
||||
* Very Bad. Only available if width, depth, channels are already fixed. */
|
||||
s = gst_structure_copy (s);
|
||||
if (!isfloat) {
|
||||
if (gst_structure_get_int (structure, "width", &width))
|
||||
set_structure_widths (s, width, 32);
|
||||
|
@ -638,10 +640,11 @@ gst_audio_convert_transform_caps (GstBaseTransform * base,
|
|||
else if (channels == 11)
|
||||
gst_structure_set (s, "channels", G_TYPE_INT, 11, NULL);
|
||||
else
|
||||
gst_structure_set (s, "channels", GST_TYPE_INT_RANGE, channels, 11, NULL);
|
||||
gst_structure_set (s, "channels", GST_TYPE_INT_RANGE, channels, 11,
|
||||
NULL);
|
||||
gst_structure_remove_field (s, "channel-positions");
|
||||
}
|
||||
gst_caps_append_structure (ret, s);
|
||||
gst_caps_merge_structure (ret, gst_structure_copy (s));
|
||||
|
||||
/* Same, plus a float<->int conversion */
|
||||
append_with_other_format (ret, s, isfloat);
|
||||
|
@ -657,17 +660,17 @@ gst_audio_convert_transform_caps (GstBaseTransform * base,
|
|||
append_with_other_format (ret, s2, TRUE);
|
||||
gst_structure_free (s2);
|
||||
} else {
|
||||
s = gst_structure_copy (s);
|
||||
set_structure_widths (s, 16, 32);
|
||||
gst_structure_set (s, "depth", GST_TYPE_INT_RANGE, 16, 32, NULL);
|
||||
gst_caps_append_structure (ret, s);
|
||||
GstStructure *s2 = gst_structure_copy (s);
|
||||
|
||||
set_structure_widths (s2, 16, 32);
|
||||
gst_structure_set (s2, "depth", GST_TYPE_INT_RANGE, 16, 32, NULL);
|
||||
gst_caps_merge_structure (ret, s2);
|
||||
}
|
||||
}
|
||||
|
||||
/* Channel conversions to fewer channels is only done if needed - generally
|
||||
* it's very bad to drop channels entirely.
|
||||
*/
|
||||
s = gst_structure_copy (s);
|
||||
if (allow_mixing) {
|
||||
gst_structure_set (s, "channels", GST_TYPE_INT_RANGE, 1, 11, NULL);
|
||||
gst_structure_remove_field (s, "channel-positions");
|
||||
|
@ -678,7 +681,7 @@ gst_audio_convert_transform_caps (GstBaseTransform * base,
|
|||
gst_structure_set_value (s, "channel-positions",
|
||||
gst_structure_get_value (structure, "channel-positions"));
|
||||
}
|
||||
gst_caps_append_structure (ret, s);
|
||||
gst_caps_merge_structure (ret, gst_structure_copy (s));
|
||||
|
||||
/* Same, plus a float<->int conversion */
|
||||
append_with_other_format (ret, s, isfloat);
|
||||
|
@ -686,7 +689,6 @@ gst_audio_convert_transform_caps (GstBaseTransform * base,
|
|||
/* And, finally, for integer only, we allow conversion to any width/depth we
|
||||
* support: this should be equivalent to our (non-float) template caps. (the
|
||||
* floating point case should be being handled just above) */
|
||||
s = gst_structure_copy (s);
|
||||
set_structure_widths (s, 8, 32);
|
||||
gst_structure_set (s, "depth", GST_TYPE_INT_RANGE, 1, 32, NULL);
|
||||
|
||||
|
@ -694,7 +696,8 @@ gst_audio_convert_transform_caps (GstBaseTransform * base,
|
|||
append_with_other_format (ret, s, TRUE);
|
||||
gst_structure_free (s);
|
||||
} else
|
||||
gst_caps_append_structure (ret, s);
|
||||
gst_caps_merge_structure (ret, s);
|
||||
}
|
||||
|
||||
GST_DEBUG_OBJECT (base, "Caps transformed to %" GST_PTR_FORMAT, ret);
|
||||
|
||||
|
|
|
@ -288,12 +288,15 @@ gst_audio_resample_transform_caps (GstBaseTransform * base,
|
|||
const GValue *val;
|
||||
GstStructure *s;
|
||||
GstCaps *res;
|
||||
gint i, n;
|
||||
|
||||
/* transform single caps into input_caps + input_caps with the rate
|
||||
* field set to our supported range. This ensures that upstream knows
|
||||
* about downstream's prefered rate(s) and can negotiate accordingly. */
|
||||
res = gst_caps_copy (caps);
|
||||
|
||||
n = gst_caps_get_size (res);
|
||||
for (i = 0; i < n; i++) {
|
||||
/* first, however, check if the caps contain a range for the rate field, in
|
||||
* which case that side isn't going to care much about the exact sample rate
|
||||
* chosen and we should just assume things will get fixated to something sane
|
||||
|
@ -302,7 +305,7 @@ gst_audio_resample_transform_caps (GstBaseTransform * base,
|
|||
* real preference or limitation and we should maintain that structure as
|
||||
* preference by putting it first into the transformed caps, and only add
|
||||
* our full rate range as second option */
|
||||
s = gst_caps_get_structure (res, 0);
|
||||
s = gst_caps_get_structure (res, i);
|
||||
val = gst_structure_get_value (s, "rate");
|
||||
if (val == NULL || GST_VALUE_HOLDS_INT_RANGE (val)) {
|
||||
/* overwrite existing range, or add field if it doesn't exist yet */
|
||||
|
@ -311,7 +314,8 @@ gst_audio_resample_transform_caps (GstBaseTransform * base,
|
|||
/* append caps with full range to existing caps with non-range rate field */
|
||||
s = gst_structure_copy (s);
|
||||
gst_structure_set (s, "rate", GST_TYPE_INT_RANGE, 1, G_MAXINT, NULL);
|
||||
gst_caps_append_structure (res, s);
|
||||
gst_caps_merge_structure (res, s);
|
||||
}
|
||||
}
|
||||
|
||||
if (filter) {
|
||||
|
|
|
@ -100,11 +100,13 @@ static GstCaps *
|
|||
gst_ffmpegcsp_caps_remove_format_info (GstCaps * caps)
|
||||
{
|
||||
GstStructure *yuvst, *rgbst, *grayst;
|
||||
gint i, n;
|
||||
|
||||
/* We know there's only one structure since we're given simple caps */
|
||||
caps = gst_caps_copy (caps);
|
||||
|
||||
yuvst = gst_caps_get_structure (caps, 0);
|
||||
n = gst_caps_get_size (caps);
|
||||
for (i = 0; i < n; i++) {
|
||||
yuvst = gst_caps_get_structure (caps, i);
|
||||
|
||||
gst_structure_set_name (yuvst, "video/x-raw-yuv");
|
||||
gst_structure_remove_fields (yuvst, "format", "endianness", "depth",
|
||||
|
@ -118,8 +120,9 @@ gst_ffmpegcsp_caps_remove_format_info (GstCaps * caps)
|
|||
grayst = gst_structure_copy (rgbst);
|
||||
gst_structure_set_name (grayst, "video/x-raw-gray");
|
||||
|
||||
gst_caps_append_structure (caps, rgbst);
|
||||
gst_caps_append_structure (caps, grayst);
|
||||
gst_caps_merge_structure (caps, rgbst);
|
||||
gst_caps_merge_structure (caps, grayst);
|
||||
}
|
||||
|
||||
return caps;
|
||||
}
|
||||
|
@ -136,11 +139,10 @@ gst_ffmpegcsp_transform_caps (GstBaseTransform * btrans,
|
|||
GstCaps *result;
|
||||
|
||||
template = gst_static_pad_template_get_caps (&gst_ffmpegcsp_src_template);
|
||||
result = gst_caps_copy (caps);
|
||||
|
||||
/* Get all possible caps that we can transform to */
|
||||
tmp = gst_ffmpegcsp_caps_remove_format_info (caps);
|
||||
tmp2 = gst_caps_intersect (tmp, template);
|
||||
tmp2 = gst_caps_intersect_full (tmp, template, GST_CAPS_INTERSECT_FIRST);
|
||||
gst_caps_unref (tmp);
|
||||
tmp = tmp2;
|
||||
|
||||
|
@ -150,6 +152,8 @@ gst_ffmpegcsp_transform_caps (GstBaseTransform * btrans,
|
|||
tmp = tmp2;
|
||||
}
|
||||
|
||||
result = tmp;
|
||||
|
||||
GST_DEBUG_OBJECT (btrans, "transformed %" GST_PTR_FORMAT " into %"
|
||||
GST_PTR_FORMAT, caps, result);
|
||||
|
||||
|
|
|
@ -326,6 +326,7 @@ gst_video_scale_transform_caps (GstBaseTransform * trans,
|
|||
{
|
||||
GstCaps *ret;
|
||||
GstStructure *structure;
|
||||
gint i, n;
|
||||
|
||||
/* this function is always called with a simple caps */
|
||||
g_return_val_if_fail (GST_CAPS_IS_SIMPLE (caps), NULL);
|
||||
|
@ -335,7 +336,9 @@ gst_video_scale_transform_caps (GstBaseTransform * trans,
|
|||
(direction == GST_PAD_SINK) ? "sink" : "src");
|
||||
|
||||
ret = gst_caps_copy (caps);
|
||||
structure = gst_caps_get_structure (ret, 0);
|
||||
n = gst_caps_get_size (caps);
|
||||
for (i = 0; i < n; i++) {
|
||||
structure = gst_caps_get_structure (ret, i);
|
||||
|
||||
gst_structure_set (structure,
|
||||
"width", GST_TYPE_INT_RANGE, 1, G_MAXINT,
|
||||
|
@ -343,8 +346,9 @@ gst_video_scale_transform_caps (GstBaseTransform * trans,
|
|||
|
||||
/* if pixel aspect ratio, make a range of it */
|
||||
if (gst_structure_has_field (structure, "pixel-aspect-ratio")) {
|
||||
gst_structure_set (structure, "pixel-aspect-ratio", GST_TYPE_FRACTION_RANGE,
|
||||
1, G_MAXINT, G_MAXINT, 1, NULL);
|
||||
gst_structure_set (structure, "pixel-aspect-ratio",
|
||||
GST_TYPE_FRACTION_RANGE, 1, G_MAXINT, G_MAXINT, 1, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
if (filter) {
|
||||
|
|
Loading…
Reference in a new issue