From 0715e73725dc8f61a0861dbd2491f6addd686337 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Fri, 23 Aug 2013 19:47:57 +0100 Subject: [PATCH] audioconvert: improve fixate_format function readability even more Do the flags comparisons only once and re-use the result. --- gst/audioconvert/gstaudioconvert.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gst/audioconvert/gstaudioconvert.c b/gst/audioconvert/gstaudioconvert.c index 06b6566e9b..2579e4f272 100644 --- a/gst/audioconvert/gstaudioconvert.c +++ b/gst/audioconvert/gstaudioconvert.c @@ -474,6 +474,7 @@ gst_audio_convert_fixate_format (GstBaseTransform * base, GstStructure * ins, for (i = 0; i < len; i++) { const GstAudioFormatInfo *t_info; GstAudioFormatFlags t_flags; + gboolean t_flags_better; const GValue *val; const gchar *fname; gint t_depth; @@ -507,8 +508,9 @@ gst_audio_convert_fixate_format (GstBaseTransform * base, GstStructure * ins, continue; } - if (t_depth == in_depth && (out_depth != in_depth || (t_flags == in_flags - && out_flags != in_flags))) { + t_flags_better = (t_flags == in_flags && out_flags != in_flags); + + if (t_depth == in_depth && (out_depth != in_depth || t_flags_better)) { /* 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 */ @@ -516,8 +518,7 @@ gst_audio_convert_fixate_format (GstBaseTransform * base, GstStructure * ins, out_depth = t_depth; out_flags = t_flags; } else if (t_depth >= in_depth && (in_depth > out_depth - || (out_depth >= in_depth && t_flags == in_flags - && out_flags != in_flags))) { + || (out_depth >= in_depth && t_flags_better))) { /* 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 */ @@ -525,8 +526,7 @@ gst_audio_convert_fixate_format (GstBaseTransform * base, GstStructure * ins, out_depth = t_depth; out_flags = t_flags; } else if ((t_depth > out_depth && out_depth < in_depth) - || (t_flags == in_flags && out_flags != in_flags - && out_depth == t_depth)) { + || (t_flags_better && out_depth == t_depth)) { /* Else get at least the one with the highest depth, ideally with the same flags */ out_info = t_info; out_depth = t_depth;