mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 01:00:37 +00:00
audioconvert: prefer channels of base caps when fixating
... which in turn prefers to preserve input channels when converting.
This commit is contained in:
parent
e1137b8c66
commit
88e73f8515
1 changed files with 22 additions and 5 deletions
|
@ -267,7 +267,7 @@ parse_error:
|
|||
|
||||
/* copies the given caps */
|
||||
static GstCaps *
|
||||
gst_audio_convert_caps_remove_format_info (GstCaps * caps)
|
||||
gst_audio_convert_caps_remove_format_info (GstCaps * caps, gboolean channels)
|
||||
{
|
||||
GstStructure *st;
|
||||
gint i, n;
|
||||
|
@ -278,6 +278,8 @@ gst_audio_convert_caps_remove_format_info (GstCaps * caps)
|
|||
|
||||
n = gst_caps_get_size (caps);
|
||||
for (i = 0; i < n; i++) {
|
||||
gboolean remove_channels = FALSE;
|
||||
|
||||
st = gst_caps_get_structure (caps, i);
|
||||
|
||||
/* If this is already expressed by the existing caps
|
||||
|
@ -292,11 +294,14 @@ gst_audio_convert_caps_remove_format_info (GstCaps * caps)
|
|||
if (gst_structure_get (st, "channel-mask", GST_TYPE_BITMASK, &channel_mask,
|
||||
NULL)) {
|
||||
if (channel_mask != 0)
|
||||
gst_structure_remove_fields (st, "channel-mask", "channels", NULL);
|
||||
remove_channels = TRUE;
|
||||
} else {
|
||||
gst_structure_remove_fields (st, "channel-mask", "channels", NULL);
|
||||
remove_channels = TRUE;
|
||||
}
|
||||
|
||||
if (remove_channels && channels)
|
||||
gst_structure_remove_fields (st, "channel-mask", "channels", NULL);
|
||||
|
||||
gst_caps_append_structure (res, st);
|
||||
}
|
||||
|
||||
|
@ -314,7 +319,7 @@ gst_audio_convert_transform_caps (GstBaseTransform * btrans,
|
|||
GstCaps *result;
|
||||
|
||||
/* Get all possible caps that we can transform to */
|
||||
tmp = gst_audio_convert_caps_remove_format_info (caps);
|
||||
tmp = gst_audio_convert_caps_remove_format_info (caps, TRUE);
|
||||
|
||||
if (filter) {
|
||||
tmp2 = gst_caps_intersect_full (filter, tmp, GST_CAPS_INTERSECT_FIRST);
|
||||
|
@ -592,14 +597,26 @@ gst_audio_convert_fixate_caps (GstBaseTransform * base,
|
|||
" based on caps %" GST_PTR_FORMAT, othercaps, caps);
|
||||
|
||||
result = gst_caps_intersect (othercaps, caps);
|
||||
if (gst_caps_is_empty (result)) {
|
||||
GstCaps *removed;
|
||||
|
||||
if (result)
|
||||
gst_caps_unref (result);
|
||||
/* try to preserve channels */
|
||||
removed = gst_audio_convert_caps_remove_format_info (caps, FALSE);
|
||||
result = gst_caps_intersect (othercaps, removed);
|
||||
gst_caps_unref (removed);
|
||||
if (gst_caps_is_empty (result)) {
|
||||
if (result)
|
||||
gst_caps_unref (result);
|
||||
result = othercaps;
|
||||
}
|
||||
} else {
|
||||
gst_caps_unref (othercaps);
|
||||
}
|
||||
|
||||
GST_DEBUG_OBJECT (base, "now fixating %" GST_PTR_FORMAT, result);
|
||||
|
||||
/* fixate remaining fields */
|
||||
result = gst_caps_make_writable (result);
|
||||
|
||||
|
|
Loading…
Reference in a new issue