]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/af_aformat.c
avfilter/avf_showcqt: rewrite showcqt and add features
[ffmpeg] / libavfilter / af_aformat.c
index 4fdcb09d2d49393bd4bf0467f80a53b5a3c74caf..1439177bd0e6739eb0fb9849990d3f46e2dc4bff 100644 (file)
@@ -57,9 +57,10 @@ static const AVOption aformat_options[] = {
 
 AVFILTER_DEFINE_CLASS(aformat);
 
-#define PARSE_FORMATS(str, type, list, add_to_list, get_fmt, none, desc)    \
+#define PARSE_FORMATS(str, type, list, add_to_list, unref_fn, get_fmt, none, desc)    \
 do {                                                                        \
     char *next, *cur = str, sep;                                            \
+    int ret;                                                                \
                                                                             \
     if (str && strchr(str, ',')) {                                          \
         av_log(ctx, AV_LOG_WARNING, "This syntax is deprecated, use '|' to "\
@@ -78,7 +79,10 @@ do {                                                                        \
             av_log(ctx, AV_LOG_ERROR, "Error parsing " desc ": %s.\n", cur);\
             return AVERROR(EINVAL);                                         \
         }                                                                   \
-        add_to_list(&list, fmt);                                            \
+        if ((ret = add_to_list(&list, fmt)) < 0) {                          \
+            unref_fn(&list);                                                \
+            return ret;                                                     \
+        }                                                                   \
                                                                             \
         cur = next;                                                         \
     }                                                                       \
@@ -95,11 +99,11 @@ static av_cold int init(AVFilterContext *ctx)
     AFormatContext *s = ctx->priv;
 
     PARSE_FORMATS(s->formats_str, enum AVSampleFormat, s->formats,
-                  ff_add_format, av_get_sample_fmt, AV_SAMPLE_FMT_NONE, "sample format");
-    PARSE_FORMATS(s->sample_rates_str, int, s->sample_rates, ff_add_format,
+                  ff_add_format, ff_formats_unref, av_get_sample_fmt, AV_SAMPLE_FMT_NONE, "sample format");
+    PARSE_FORMATS(s->sample_rates_str, int, s->sample_rates, ff_add_format, ff_formats_unref,
                   get_sample_rate, 0, "sample rate");
     PARSE_FORMATS(s->channel_layouts_str, uint64_t, s->channel_layouts,
-                  ff_add_channel_layout, av_get_channel_layout, 0,
+                  ff_add_channel_layout, ff_channel_layouts_unref, av_get_channel_layout, 0,
                   "channel layout");
 
     return 0;