audio-resampler: estimate memory usage in auto mode
authorWim Taymans <wtaymans@redhat.com>
Mon, 28 Mar 2016 13:37:36 +0000 (15:37 +0200)
committerWim Taymans <wtaymans@redhat.com>
Mon, 28 Mar 2016 13:37:36 +0000 (15:37 +0200)
Estimate the memory usage and use this to decide between full or
interpolated filter.

gst-libs/gst/audio/audio-resampler.c

index 695cb8e..4d6303b 100644 (file)
@@ -1276,6 +1276,11 @@ resampler_calculate_taps (GstAudioResampler * resampler)
       resampler->filter_mode = GST_AUDIO_RESAMPLER_FILTER_MODE_FULL;
       GST_DEBUG ("automatically selected full filter, %d <= %d", out_rate,
           oversample);
+    } else if (bps * n_taps * out_rate < resampler->filter_threshold) {
+      /* switch to full filter when memory is below threshold */
+      resampler->filter_mode = GST_AUDIO_RESAMPLER_FILTER_MODE_FULL;
+      GST_DEBUG ("automatically selected full filter, memory %d <= %d",
+          bps * n_taps * out_rate, resampler->filter_threshold);
     } else {
       GST_DEBUG ("automatically selected interpolated filter");
       resampler->filter_mode = GST_AUDIO_RESAMPLER_FILTER_MODE_INTERPOLATED;