mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-25 01:30:38 +00:00
audioconvert: improve fixation
This commit is contained in:
parent
55076379b2
commit
ef980bc09b
1 changed files with 15 additions and 19 deletions
|
@ -590,34 +590,30 @@ gst_audio_convert_fixate_caps (GstBaseTransform * base,
|
||||||
GstPadDirection direction, GstCaps * caps, GstCaps * othercaps)
|
GstPadDirection direction, GstCaps * caps, GstCaps * othercaps)
|
||||||
{
|
{
|
||||||
GstStructure *ins, *outs;
|
GstStructure *ins, *outs;
|
||||||
gint rate;
|
GstCaps *result;
|
||||||
const gchar *fmt;
|
|
||||||
|
|
||||||
othercaps = gst_caps_make_writable (othercaps);
|
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (base, "trying to fixate othercaps %" GST_PTR_FORMAT
|
GST_DEBUG_OBJECT (base, "trying to fixate othercaps %" GST_PTR_FORMAT
|
||||||
" based on caps %" GST_PTR_FORMAT, othercaps, caps);
|
" based on caps %" GST_PTR_FORMAT, othercaps, caps);
|
||||||
|
|
||||||
|
result = gst_caps_intersect (othercaps, caps);
|
||||||
|
if (gst_caps_is_empty (result)) {
|
||||||
|
result = othercaps;
|
||||||
|
} else {
|
||||||
|
gst_caps_unref (othercaps);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* fixate remaining fields */
|
||||||
|
result = gst_caps_make_writable (result);
|
||||||
|
|
||||||
ins = gst_caps_get_structure (caps, 0);
|
ins = gst_caps_get_structure (caps, 0);
|
||||||
outs = gst_caps_get_structure (othercaps, 0);
|
outs = gst_caps_get_structure (result, 0);
|
||||||
|
|
||||||
gst_audio_convert_fixate_channels (base, ins, outs);
|
gst_audio_convert_fixate_channels (base, ins, outs);
|
||||||
|
gst_caps_fixate (result);
|
||||||
|
|
||||||
if ((fmt = gst_structure_get_string (ins, "format"))) {
|
GST_DEBUG_OBJECT (base, "fixated othercaps to %" GST_PTR_FORMAT, result);
|
||||||
/* FIXME, find the best format */
|
|
||||||
gst_structure_fixate_field_string (outs, "format", fmt);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gst_structure_get_int (ins, "rate", &rate)) {
|
return result;
|
||||||
if (gst_structure_has_field (outs, "rate")) {
|
|
||||||
gst_structure_fixate_field_nearest_int (outs, "rate", rate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
gst_caps_truncate (othercaps);
|
|
||||||
GST_DEBUG_OBJECT (base, "fixated othercaps to %" GST_PTR_FORMAT, othercaps);
|
|
||||||
|
|
||||||
return othercaps;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
Loading…
Reference in a new issue