gst_audio_format_get_info (gst_audio_format_from_string (fname));
if (!t_info)
continue;
- /* accept input format */
- if (strcmp (fname, in_format) == 0)
+ /* accept input format immediately */
+ if (strcmp (fname, in_format) == 0) {
+ out_info = t_info;
break;
+ }
+
out_flags = GST_AUDIO_FORMAT_INFO_FLAGS (t_info);
out_flags &= ~(GST_AUDIO_FORMAT_FLAG_UNPACK);
out_flags &= ~(GST_AUDIO_FORMAT_FLAG_SIGNED);
/* or another format without losing precision */
if (in_flags == out_flags) {
if (GST_AUDIO_FORMAT_INFO_DEPTH (t_info) ==
- GST_AUDIO_FORMAT_INFO_DEPTH (in_info)) {
- /* exact match. We are done */
+ GST_AUDIO_FORMAT_INFO_DEPTH (in_info) &&
+ (!out_info
+ || GST_AUDIO_FORMAT_INFO_DEPTH (out_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;
- break;
} else if ((GST_AUDIO_FORMAT_INFO_DEPTH (t_info) >=
- GST_AUDIO_FORMAT_INFO_DEPTH (in_info))) {
+ GST_AUDIO_FORMAT_INFO_DEPTH (in_info)) && !out_info) {
/* 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;
}
}