char *p2, *p3, *saveptr2 = NULL, *saveptr3 = NULL;
double radius;
- if (!tstr) {
- uninit(ctx);
+ if (!tstr)
return AVERROR(EINVAL);
- }
p = NULL;
p2 = tstr;
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;
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);
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);
tstr2 = av_strtok(p2, " ", &saveptr2);
if (!tstr2) {
av_log(ctx, AV_LOG_ERROR, "transfer points missing\n");
- uninit(ctx);
return AVERROR(EINVAL);
}
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);
};
-AVFilter ff_af_mcompand = {
+const AVFilter ff_af_mcompand = {
.name = "mcompand",
.description = NULL_IF_CONFIG_SMALL(
"Multiband Compress or expand audio dynamic range."),