]> git.sesse.net Git - ffmpeg/commitdiff
avfilter/af_headphone: Avoid duplicating string needlessly
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Mon, 24 Aug 2020 21:03:45 +0000 (23:03 +0200)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Wed, 9 Sep 2020 11:46:58 +0000 (13:46 +0200)
The string given by an AVOption that contains the channel assignment
is used only once; ergo it doesn't matter that parsing the string via
av_strtok() is destructive. There is no need to make a copy.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
libavfilter/af_headphone.c

index 32939af8546e3e5ed5fc292a7013fe05dee67ac3..967f8ed5a63bb2081f77dd5afa91f78f22cfa6fb 100644 (file)
@@ -100,16 +100,13 @@ static int parse_channel_name(const char *arg, uint64_t *rchannel)
 static void parse_map(AVFilterContext *ctx)
 {
     HeadphoneContext *s = ctx->priv;
-    char *arg, *tokenizer, *p, *args = av_strdup(s->map);
+    char *arg, *tokenizer, *p;
     uint64_t used_channels = 0;
 
-    if (!args)
-        return;
-    p = args;
-
     s->lfe_channel = -1;
     s->nb_inputs = 1;
 
+    p = s->map;
     while ((arg = av_strtok(p, "|", &tokenizer))) {
         uint64_t out_channel;
 
@@ -133,8 +130,6 @@ static void parse_map(AVFilterContext *ctx)
         s->nb_inputs = 2;
     else
         s->nb_inputs = s->nb_irs + 1;
-
-    av_free(args);
 }
 
 typedef struct ThreadData {