From: Sebastian Dröge Date: Fri, 27 May 2011 11:13:42 +0000 (+0200) Subject: audioconvert: Optimize transform_caps() X-Git-Tag: RELEASE-0.11.0~242 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d590bce5f7d4a1a24aa61692613471da70d4ca3f;p=platform%2Fupstream%2Fgst-plugins-base.git audioconvert: Optimize transform_caps() If the second and next caps structures are a subset of the already existing transformed caps we can safely skip them because we would transform them to the same caps again. This makes gst_pad_get_caps() on an audiotestsrc ! audioconvert ! audioconvert ! audioconvert ! fakesink pipeline about 1.7 times faster. --- diff --git a/gst/audioconvert/gstaudioconvert.c b/gst/audioconvert/gstaudioconvert.c index b3250a7..26506d2 100644 --- a/gst/audioconvert/gstaudioconvert.c +++ b/gst/audioconvert/gstaudioconvert.c @@ -577,6 +577,21 @@ gst_audio_convert_transform_caps (GstBaseTransform * base, for (j = 0; j < n; j++) { structure = gst_caps_get_structure (caps, j); + + if (j > 0) { + GstCaps *tmp = gst_caps_new_full (gst_structure_copy (structure), NULL); + + /* If the new structure is a subset of the already existing transformed + * caps we can safely skip it because we would transform it to the + * same caps again. + */ + if (gst_caps_is_subset (tmp, ret)) { + gst_caps_unref (tmp); + continue; + } + gst_caps_unref (tmp); + } + structure_name = gst_structure_get_name (structure); isfloat = strcmp (structure_name, "audio/x-raw-float") == 0;