]> git.sesse.net Git - ffmpeg/commitdiff
avfilter: Remove redundant ff_formats/channel_layouts_unref()
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Fri, 7 Aug 2020 21:46:33 +0000 (23:46 +0200)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Sun, 23 Aug 2020 23:01:02 +0000 (01:01 +0200)
ff_add_format() and ff_add_channel_layout() already unref the list upon
error.

Reviewed-by: Nicolas George <george@nsup.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
libavfilter/af_aformat.c
libavfilter/vf_shuffleplanes.c
libavfilter/vf_weave.c

index 1a702778c358b53028a87e34f835679d78833a57..0ea470014c786a4c2ce73a238a055b108710b2c4 100644 (file)
@@ -60,7 +60,7 @@ static const AVOption aformat_options[] = {
 
 AVFILTER_DEFINE_CLASS(aformat);
 
-#define PARSE_FORMATS(str, type, list, add_to_list, unref_fn, get_fmt, none, desc)    \
+#define PARSE_FORMATS(str, type, list, add_to_list, get_fmt, none, desc)    \
 do {                                                                        \
     char *next, *cur = str, sep;                                            \
     int ret;                                                                \
@@ -83,7 +83,6 @@ do {                                                                        \
             return AVERROR(EINVAL);                                         \
         }                                                                   \
         if ((ret = add_to_list(&list, fmt)) < 0) {                          \
-            unref_fn(&list);                                                \
             return ret;                                                     \
         }                                                                   \
                                                                             \
@@ -102,11 +101,11 @@ static av_cold int init(AVFilterContext *ctx)
     AFormatContext *s = ctx->priv;
 
     PARSE_FORMATS(s->formats_str, enum AVSampleFormat, s->formats,
-                  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,
+                  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,
                   get_sample_rate, 0, "sample rate");
     PARSE_FORMATS(s->channel_layouts_str, uint64_t, s->channel_layouts,
-                  ff_add_channel_layout, ff_channel_layouts_unref, av_get_channel_layout, 0,
+                  ff_add_channel_layout, av_get_channel_layout, 0,
                   "channel layout");
 
     return 0;
index 6c718893ce55de27421770d4c73eb34efe064919..c5a376d50bf21a8dd92952029eca1e714547769e 100644 (file)
@@ -64,7 +64,6 @@ static int query_formats(AVFilterContext *ctx)
             if (i != 4)
                 continue;
             if ((ret = ff_add_format(&formats, fmt)) < 0) {
-                ff_formats_unref(&formats);
                 return ret;
             }
         }
index 8951b09095f2c47e860755c8c8ec2eaedb691d8e..8d4eb3d5a4a1316058638f2c5bce8dcaaa8796ec 100644 (file)
@@ -60,7 +60,6 @@ static int query_formats(AVFilterContext *ctx)
         if (!(desc->flags & AV_PIX_FMT_FLAG_PAL) &&
             !(desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) {
             if ((ret = ff_add_format(&formats, fmt)) < 0) {
-                ff_formats_unref(&formats);
                 return ret;
             }
         }