mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-09-27 14:31:01 +00:00
audioconvert: remove unnecessary deep nesting in fixate function
Makes it easier to read and removes two levels of indentation.
This commit is contained in:
parent
f678411c6e
commit
f448977dbd
1 changed files with 66 additions and 66 deletions
|
@ -443,6 +443,7 @@ gst_audio_convert_fixate_format (GstBaseTransform * base, GstStructure * ins,
|
||||||
const GValue *format;
|
const GValue *format;
|
||||||
const GstAudioFormatInfo *in_info, *out_info = NULL;
|
const GstAudioFormatInfo *in_info, *out_info = NULL;
|
||||||
GstAudioFormatFlags in_flags, out_flags = 0;
|
GstAudioFormatFlags in_flags, out_flags = 0;
|
||||||
|
gint i, len;
|
||||||
|
|
||||||
in_format = gst_structure_get_string (ins, "format");
|
in_format = gst_structure_get_string (ins, "format");
|
||||||
if (!in_format)
|
if (!in_format)
|
||||||
|
@ -453,6 +454,10 @@ gst_audio_convert_fixate_format (GstBaseTransform * base, GstStructure * ins,
|
||||||
if (format == NULL)
|
if (format == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
/* nothing to fixate? */
|
||||||
|
if (!GST_VALUE_HOLDS_LIST (format))
|
||||||
|
return;
|
||||||
|
|
||||||
in_info =
|
in_info =
|
||||||
gst_audio_format_get_info (gst_audio_format_from_string (in_format));
|
gst_audio_format_get_info (gst_audio_format_from_string (in_format));
|
||||||
if (!in_info)
|
if (!in_info)
|
||||||
|
@ -462,77 +467,72 @@ gst_audio_convert_fixate_format (GstBaseTransform * base, GstStructure * ins,
|
||||||
in_flags &= ~(GST_AUDIO_FORMAT_FLAG_UNPACK);
|
in_flags &= ~(GST_AUDIO_FORMAT_FLAG_UNPACK);
|
||||||
in_flags &= ~(GST_AUDIO_FORMAT_FLAG_SIGNED);
|
in_flags &= ~(GST_AUDIO_FORMAT_FLAG_SIGNED);
|
||||||
|
|
||||||
if (GST_VALUE_HOLDS_LIST (format)) {
|
len = gst_value_list_get_size (format);
|
||||||
gint i, len;
|
for (i = 0; i < len; i++) {
|
||||||
|
const GstAudioFormatInfo *t_info;
|
||||||
|
GstAudioFormatFlags t_flags;
|
||||||
|
const GValue *val;
|
||||||
|
const gchar *fname;
|
||||||
|
|
||||||
len = gst_value_list_get_size (format);
|
val = gst_value_list_get_value (format, i);
|
||||||
for (i = 0; i < len; i++) {
|
if (!G_VALUE_HOLDS_STRING (val))
|
||||||
const GValue *val;
|
continue;
|
||||||
const gchar *fname;
|
|
||||||
|
|
||||||
val = gst_value_list_get_value (format, i);
|
fname = g_value_get_string (val);
|
||||||
if (G_VALUE_HOLDS_STRING (val)) {
|
t_info = gst_audio_format_get_info (gst_audio_format_from_string (fname));
|
||||||
const GstAudioFormatInfo *t_info;
|
if (!t_info)
|
||||||
GstAudioFormatFlags t_flags;
|
continue;
|
||||||
|
|
||||||
fname = g_value_get_string (val);
|
/* accept input format immediately */
|
||||||
t_info =
|
if (strcmp (fname, in_format) == 0) {
|
||||||
gst_audio_format_get_info (gst_audio_format_from_string (fname));
|
out_info = t_info;
|
||||||
if (!t_info)
|
break;
|
||||||
continue;
|
|
||||||
/* accept input format immediately */
|
|
||||||
if (strcmp (fname, in_format) == 0) {
|
|
||||||
out_info = t_info;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
t_flags = GST_AUDIO_FORMAT_INFO_FLAGS (t_info);
|
|
||||||
t_flags &= ~(GST_AUDIO_FORMAT_FLAG_UNPACK);
|
|
||||||
t_flags &= ~(GST_AUDIO_FORMAT_FLAG_SIGNED);
|
|
||||||
|
|
||||||
if (GST_AUDIO_FORMAT_INFO_DEPTH (t_info) ==
|
|
||||||
GST_AUDIO_FORMAT_INFO_DEPTH (in_info) && (!out_info
|
|
||||||
|| GST_AUDIO_FORMAT_INFO_DEPTH (out_info) !=
|
|
||||||
GST_AUDIO_FORMAT_INFO_DEPTH (in_info)
|
|
||||||
|| (t_flags == in_flags && out_flags != in_flags))) {
|
|
||||||
/* Prefer to use the first format that has the same depth with the same
|
|
||||||
* flags, and if none with the same flags exist use the first other one
|
|
||||||
* that has the same depth */
|
|
||||||
out_info = t_info;
|
|
||||||
out_flags = t_flags;
|
|
||||||
} else if (GST_AUDIO_FORMAT_INFO_DEPTH (t_info) >=
|
|
||||||
GST_AUDIO_FORMAT_INFO_DEPTH (in_info) && (!out_info
|
|
||||||
|| GST_AUDIO_FORMAT_INFO_DEPTH (in_info) >
|
|
||||||
GST_AUDIO_FORMAT_INFO_DEPTH (out_info)
|
|
||||||
|| (GST_AUDIO_FORMAT_INFO_DEPTH (out_info) >=
|
|
||||||
GST_AUDIO_FORMAT_INFO_DEPTH (in_info) && t_flags == in_flags
|
|
||||||
&& out_flags != in_flags))) {
|
|
||||||
/* Otherwise use the first format that has a higher depth with the same flags,
|
|
||||||
* if none with the same flags exist use the first other one that has a higher
|
|
||||||
* depth */
|
|
||||||
out_info = t_info;
|
|
||||||
out_flags = t_flags;
|
|
||||||
} else if (!out_info
|
|
||||||
|| (GST_AUDIO_FORMAT_INFO_DEPTH (t_info) >
|
|
||||||
GST_AUDIO_FORMAT_INFO_DEPTH (out_info)
|
|
||||||
&& GST_AUDIO_FORMAT_INFO_DEPTH (out_info) <
|
|
||||||
GST_AUDIO_FORMAT_INFO_DEPTH (in_info)) || (t_flags == in_flags
|
|
||||||
&& out_flags != in_flags
|
|
||||||
&& GST_AUDIO_FORMAT_INFO_DEPTH (out_info) ==
|
|
||||||
GST_AUDIO_FORMAT_INFO_DEPTH (t_info))) {
|
|
||||||
/* Else get at least the one with the highest depth, ideally with the same flags */
|
|
||||||
out_info = t_info;
|
|
||||||
out_flags = t_flags;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (out_info)
|
|
||||||
gst_structure_set (outs, "format", G_TYPE_STRING,
|
t_flags = GST_AUDIO_FORMAT_INFO_FLAGS (t_info);
|
||||||
GST_AUDIO_FORMAT_INFO_NAME (out_info), NULL);
|
t_flags &= ~(GST_AUDIO_FORMAT_FLAG_UNPACK);
|
||||||
} else {
|
t_flags &= ~(GST_AUDIO_FORMAT_FLAG_SIGNED);
|
||||||
/* nothing to fixate */
|
|
||||||
return;
|
if (GST_AUDIO_FORMAT_INFO_DEPTH (t_info) ==
|
||||||
|
GST_AUDIO_FORMAT_INFO_DEPTH (in_info) && (!out_info
|
||||||
|
|| GST_AUDIO_FORMAT_INFO_DEPTH (out_info) !=
|
||||||
|
GST_AUDIO_FORMAT_INFO_DEPTH (in_info)
|
||||||
|
|| (t_flags == in_flags && out_flags != in_flags))) {
|
||||||
|
/* Prefer to use the first format that has the same depth with the same
|
||||||
|
* flags, and if none with the same flags exist use the first other one
|
||||||
|
* that has the same depth */
|
||||||
|
out_info = t_info;
|
||||||
|
out_flags = t_flags;
|
||||||
|
} else if (GST_AUDIO_FORMAT_INFO_DEPTH (t_info) >=
|
||||||
|
GST_AUDIO_FORMAT_INFO_DEPTH (in_info) && (!out_info
|
||||||
|
|| GST_AUDIO_FORMAT_INFO_DEPTH (in_info) >
|
||||||
|
GST_AUDIO_FORMAT_INFO_DEPTH (out_info)
|
||||||
|
|| (GST_AUDIO_FORMAT_INFO_DEPTH (out_info) >=
|
||||||
|
GST_AUDIO_FORMAT_INFO_DEPTH (in_info) && t_flags == in_flags
|
||||||
|
&& out_flags != in_flags))) {
|
||||||
|
/* Otherwise use the first format that has a higher depth with the same flags,
|
||||||
|
* if none with the same flags exist use the first other one that has a higher
|
||||||
|
* depth */
|
||||||
|
out_info = t_info;
|
||||||
|
out_flags = t_flags;
|
||||||
|
} else if (!out_info
|
||||||
|
|| (GST_AUDIO_FORMAT_INFO_DEPTH (t_info) >
|
||||||
|
GST_AUDIO_FORMAT_INFO_DEPTH (out_info)
|
||||||
|
&& GST_AUDIO_FORMAT_INFO_DEPTH (out_info) <
|
||||||
|
GST_AUDIO_FORMAT_INFO_DEPTH (in_info)) || (t_flags == in_flags
|
||||||
|
&& out_flags != in_flags
|
||||||
|
&& GST_AUDIO_FORMAT_INFO_DEPTH (out_info) ==
|
||||||
|
GST_AUDIO_FORMAT_INFO_DEPTH (t_info))) {
|
||||||
|
/* Else get at least the one with the highest depth, ideally with the same flags */
|
||||||
|
out_info = t_info;
|
||||||
|
out_flags = t_flags;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (out_info)
|
||||||
|
gst_structure_set (outs, "format", G_TYPE_STRING,
|
||||||
|
GST_AUDIO_FORMAT_INFO_NAME (out_info), NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in a new issue