]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/af_mcompand.c
avfilter: Constify all AVFilters
[ffmpeg] / libavfilter / af_mcompand.c
index f142573beabdd127e3dd834eba72f4a5427a0e76..ab1c2bff537d99cb6744535ada683dbbe73bea98 100644 (file)
@@ -361,10 +361,8 @@ static int config_output(AVFilterLink *outlink)
         char *p2, *p3, *saveptr2 = NULL, *saveptr3 = NULL;
         double radius;
 
-        if (!tstr) {
-            uninit(ctx);
+        if (!tstr)
             return AVERROR(EINVAL);
-        }
         p = NULL;
 
         p2 = tstr;
@@ -372,7 +370,6 @@ static int config_output(AVFilterLink *outlink)
         tstr2 = av_strtok(p2, " ", &saveptr2);
         if (!tstr2) {
             av_log(ctx, AV_LOG_ERROR, "at least one attacks/decays rate is mandatory\n");
-            uninit(ctx);
             return AVERROR(EINVAL);
         }
         p2 = NULL;
@@ -381,13 +378,15 @@ static int config_output(AVFilterLink *outlink)
         count_items(tstr2, &nb_attacks, ',');
         if (!nb_attacks || nb_attacks & 1) {
             av_log(ctx, AV_LOG_ERROR, "number of attacks rate plus decays rate must be even\n");
-            uninit(ctx);
             return AVERROR(EINVAL);
         }
 
         s->bands[i].attack_rate = av_calloc(outlink->channels, sizeof(double));
         s->bands[i].decay_rate = av_calloc(outlink->channels, sizeof(double));
         s->bands[i].volume = av_calloc(outlink->channels, sizeof(double));
+        if (!s->bands[i].attack_rate || !s->bands[i].decay_rate || !s->bands[i].volume)
+            return AVERROR(ENOMEM);
+
         for (k = 0; k < FFMIN(nb_attacks / 2, outlink->channels); k++) {
             char *tstr3 = av_strtok(p3, ",", &saveptr3);
 
@@ -417,7 +416,6 @@ static int config_output(AVFilterLink *outlink)
         tstr2 = av_strtok(p2, " ", &saveptr2);
         if (!tstr2) {
             av_log(ctx, AV_LOG_ERROR, "transfer function curve in dB must be set\n");
-            uninit(ctx);
             return AVERROR(EINVAL);
         }
         sscanf(tstr2, "%lf", &s->bands[i].transfer_fn.curve_dB);
@@ -427,7 +425,6 @@ static int config_output(AVFilterLink *outlink)
         tstr2 = av_strtok(p2, " ", &saveptr2);
         if (!tstr2) {
             av_log(ctx, AV_LOG_ERROR, "transfer points missing\n");
-            uninit(ctx);
             return AVERROR(EINVAL);
         }
 
@@ -435,38 +432,31 @@ static int config_output(AVFilterLink *outlink)
         s->bands[i].transfer_fn.nb_segments = (nb_points + 4) * 2;
         s->bands[i].transfer_fn.segments = av_calloc(s->bands[i].transfer_fn.nb_segments,
                                                      sizeof(CompandSegment));
-        if (!s->bands[i].transfer_fn.segments) {
-            uninit(ctx);
+        if (!s->bands[i].transfer_fn.segments)
             return AVERROR(ENOMEM);
-        }
 
         ret = parse_points(tstr2, nb_points, radius, &s->bands[i].transfer_fn, ctx);
         if (ret < 0) {
             av_log(ctx, AV_LOG_ERROR, "transfer points parsing failed\n");
-            uninit(ctx);
             return ret;
         }
 
         tstr2 = av_strtok(p2, " ", &saveptr2);
         if (!tstr2) {
             av_log(ctx, AV_LOG_ERROR, "crossover_frequency is missing\n");
-            uninit(ctx);
             return AVERROR(EINVAL);
         }
 
         new_nb_items += sscanf(tstr2, "%lf", &s->bands[i].topfreq) == 1;
         if (s->bands[i].topfreq < 0 || s->bands[i].topfreq >= outlink->sample_rate / 2) {
             av_log(ctx, AV_LOG_ERROR, "crossover_frequency: %f, should be >=0 and lower than half of sample rate: %d.\n", s->bands[i].topfreq, outlink->sample_rate / 2);
-            uninit(ctx);
             return AVERROR(EINVAL);
         }
 
         if (s->bands[i].topfreq != 0) {
             ret = crossover_setup(outlink, &s->bands[i].filter, s->bands[i].topfreq);
-            if (ret < 0) {
-                uninit(ctx);
+            if (ret < 0)
                 return ret;
-            }
         }
 
         tstr2 = av_strtok(p2, " ", &saveptr2);
@@ -676,7 +666,7 @@ static const AVFilterPad mcompand_outputs[] = {
 };
 
 
-AVFilter ff_af_mcompand = {
+const AVFilter ff_af_mcompand = {
     .name           = "mcompand",
     .description    = NULL_IF_CONFIG_SMALL(
             "Multiband Compress or expand audio dynamic range."),