mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-20 07:16:55 +00:00
audioconvert: Always prefer the input format if possible
Previously we could've chosen another format with the same depth even if the input format was possible. Also make sure to chose according to the order in the caps.
This commit is contained in:
parent
bc4389806d
commit
9e6021fe4b
1 changed files with 22 additions and 8 deletions
|
@ -478,23 +478,37 @@ gst_audio_convert_fixate_format (GstBaseTransform * base, GstStructure * ins,
|
||||||
gst_audio_format_get_info (gst_audio_format_from_string (fname));
|
gst_audio_format_get_info (gst_audio_format_from_string (fname));
|
||||||
if (!t_info)
|
if (!t_info)
|
||||||
continue;
|
continue;
|
||||||
/* accept input format */
|
/* accept input format immediately */
|
||||||
if (strcmp (fname, in_format) == 0)
|
if (strcmp (fname, in_format) == 0) {
|
||||||
|
out_info = t_info;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
out_flags = GST_AUDIO_FORMAT_INFO_FLAGS (t_info);
|
out_flags = GST_AUDIO_FORMAT_INFO_FLAGS (t_info);
|
||||||
out_flags &= ~(GST_AUDIO_FORMAT_FLAG_UNPACK);
|
out_flags &= ~(GST_AUDIO_FORMAT_FLAG_UNPACK);
|
||||||
out_flags &= ~(GST_AUDIO_FORMAT_FLAG_SIGNED);
|
out_flags &= ~(GST_AUDIO_FORMAT_FLAG_SIGNED);
|
||||||
/* or another format without losing precision */
|
/* or another format without losing precision */
|
||||||
if (in_flags == out_flags) {
|
if (in_flags == out_flags) {
|
||||||
if (GST_AUDIO_FORMAT_INFO_DEPTH (t_info) ==
|
if (GST_AUDIO_FORMAT_INFO_DEPTH (t_info) ==
|
||||||
GST_AUDIO_FORMAT_INFO_DEPTH (in_info)) {
|
GST_AUDIO_FORMAT_INFO_DEPTH (in_info) &&
|
||||||
/* exact match. We are done */
|
(!out_info
|
||||||
out_info = t_info;
|
|| GST_AUDIO_FORMAT_INFO_DEPTH (out_info) >=
|
||||||
break;
|
|
||||||
} else if ((GST_AUDIO_FORMAT_INFO_DEPTH (t_info) >=
|
|
||||||
GST_AUDIO_FORMAT_INFO_DEPTH (in_info))) {
|
GST_AUDIO_FORMAT_INFO_DEPTH (in_info))) {
|
||||||
|
/* exact match of depth, we still continue
|
||||||
|
* to iterate to see if we can get exactly
|
||||||
|
* the same format.
|
||||||
|
* Only go here if we don't have another
|
||||||
|
* format with the same depth already. We
|
||||||
|
* always take the first to prefer caps
|
||||||
|
* order. */
|
||||||
|
out_info = t_info;
|
||||||
|
} else if ((GST_AUDIO_FORMAT_INFO_DEPTH (t_info) >=
|
||||||
|
GST_AUDIO_FORMAT_INFO_DEPTH (in_info)) && !out_info) {
|
||||||
/* match where we do not lose precision. This could
|
/* match where we do not lose precision. This could
|
||||||
be ok, but keep searching for an exact match */
|
* be ok, but keep searching for an exact match.
|
||||||
|
* Only go here if we don't have another format with
|
||||||
|
* a bigger/equal depth already. We always take the
|
||||||
|
* first to prefer caps order. */
|
||||||
out_info = t_info;
|
out_info = t_info;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue