avfilter/af_sofalizer: stop allocating never used buffers
authorPaul B Mahol <onemda@gmail.com>
Mon, 31 Dec 2018 18:40:18 +0000 (19:40 +0100)
committerPaul B Mahol <onemda@gmail.com>
Mon, 31 Dec 2018 18:40:18 +0000 (19:40 +0100)
libavfilter/af_sofalizer.c

index 52c3b49..4812359 100644 (file)
@@ -719,12 +719,20 @@ static int load_data(AVFilterContext *ctx, int azim, int elev, float radius, int
     n_samples = s->sofa.n_samples;
     ir_samples = s->sofa.ir_samples;
 
-    s->data_ir[0] = av_calloc(n_samples, sizeof(float) * s->n_conv);
-    s->data_ir[1] = av_calloc(n_samples, sizeof(float) * s->n_conv);
+    if (s->type == TIME_DOMAIN) {
+        s->data_ir[0] = av_calloc(n_samples, sizeof(float) * s->n_conv);
+        s->data_ir[1] = av_calloc(n_samples, sizeof(float) * s->n_conv);
+
+        if (!s->data_ir[0] || !s->data_ir[1]) {
+            ret = AVERROR(ENOMEM);
+            goto fail;
+        }
+    }
+
     s->delay[0] = av_calloc(s->n_conv, sizeof(int));
     s->delay[1] = av_calloc(s->n_conv, sizeof(int));
 
-    if (!s->data_ir[0] || !s->data_ir[1] || !s->delay[0] || !s->delay[1]) {
+    if (!s->delay[0] || !s->delay[1]) {
         ret = AVERROR(ENOMEM);
         goto fail;
     }