diff mbox series

[FFmpeg-devel,06/19] avfilter/vf_decimate: Don't allocate inpad names

Message ID 20200825140927.16433-6-andreas.rheinhardt@gmail.com
State Accepted
Commit 925d2f4f5b0e86bbe66714e05253080ab05ad4bb
Headers show
Series [FFmpeg-devel,01/19] avfilter/avfilter: Fix indentation
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Andreas Rheinhardt Aug. 25, 2020, 2:09 p.m. UTC
These names are always the same, so not using duplicates saves
allocations, checks for the allocations as well as frees.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavfilter/vf_decimate.c | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

Comments

Paul B Mahol Aug. 26, 2020, 8:22 p.m. UTC | #1
On 8/25/20, Andreas Rheinhardt <andreas.rheinhardt@gmail.com> wrote:
> These names are always the same, so not using duplicates saves
> allocations, checks for the allocations as well as frees.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavfilter/vf_decimate.c | 18 ++++--------------
>  1 file changed, 4 insertions(+), 14 deletions(-)
>

LGTM

> diff --git a/libavfilter/vf_decimate.c b/libavfilter/vf_decimate.c
> index 88a8b38a58..549b281418 100644
> --- a/libavfilter/vf_decimate.c
> +++ b/libavfilter/vf_decimate.c
> @@ -273,29 +273,21 @@ static av_cold int decimate_init(AVFilterContext *ctx)
>  {
>      DecimateContext *dm = ctx->priv;
>      AVFilterPad pad = {
> -        .name         = av_strdup("main"),
> +        .name         = "main",
>          .type         = AVMEDIA_TYPE_VIDEO,
>          .filter_frame = filter_frame,
>          .config_props = config_input,
>      };
>      int ret;
>
> -    if (!pad.name)
> -        return AVERROR(ENOMEM);
> -    if ((ret = ff_insert_inpad(ctx, INPUT_MAIN, &pad)) < 0) {
> -        av_freep(&pad.name);
> +    if ((ret = ff_insert_inpad(ctx, INPUT_MAIN, &pad)) < 0)
>          return ret;
> -    }
>
>      if (dm->ppsrc) {
> -        pad.name = av_strdup("clean_src");
> +        pad.name = "clean_src";
>          pad.config_props = NULL;
> -        if (!pad.name)
> -            return AVERROR(ENOMEM);
> -        if ((ret = ff_insert_inpad(ctx, INPUT_CLEANSRC, &pad)) < 0) {
> -            av_freep(&pad.name);
> +        if ((ret = ff_insert_inpad(ctx, INPUT_CLEANSRC, &pad)) < 0)
>              return ret;
> -        }
>      }
>
>      if ((dm->blockx & (dm->blockx - 1)) ||
> @@ -326,8 +318,6 @@ static av_cold void decimate_uninit(AVFilterContext
> *ctx)
>              av_frame_free(&dm->clean_src[i]);
>      }
>      av_freep(&dm->clean_src);
> -    for (i = 0; i < ctx->nb_inputs; i++)
> -        av_freep(&ctx->input_pads[i].name);
>  }
>
>  static int request_inlink(AVFilterContext *ctx, int lid)
> --
> 2.20.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
diff mbox series

Patch

diff --git a/libavfilter/vf_decimate.c b/libavfilter/vf_decimate.c
index 88a8b38a58..549b281418 100644
--- a/libavfilter/vf_decimate.c
+++ b/libavfilter/vf_decimate.c
@@ -273,29 +273,21 @@  static av_cold int decimate_init(AVFilterContext *ctx)
 {
     DecimateContext *dm = ctx->priv;
     AVFilterPad pad = {
-        .name         = av_strdup("main"),
+        .name         = "main",
         .type         = AVMEDIA_TYPE_VIDEO,
         .filter_frame = filter_frame,
         .config_props = config_input,
     };
     int ret;
 
-    if (!pad.name)
-        return AVERROR(ENOMEM);
-    if ((ret = ff_insert_inpad(ctx, INPUT_MAIN, &pad)) < 0) {
-        av_freep(&pad.name);
+    if ((ret = ff_insert_inpad(ctx, INPUT_MAIN, &pad)) < 0)
         return ret;
-    }
 
     if (dm->ppsrc) {
-        pad.name = av_strdup("clean_src");
+        pad.name = "clean_src";
         pad.config_props = NULL;
-        if (!pad.name)
-            return AVERROR(ENOMEM);
-        if ((ret = ff_insert_inpad(ctx, INPUT_CLEANSRC, &pad)) < 0) {
-            av_freep(&pad.name);
+        if ((ret = ff_insert_inpad(ctx, INPUT_CLEANSRC, &pad)) < 0)
             return ret;
-        }
     }
 
     if ((dm->blockx & (dm->blockx - 1)) ||
@@ -326,8 +318,6 @@  static av_cold void decimate_uninit(AVFilterContext *ctx)
             av_frame_free(&dm->clean_src[i]);
     }
     av_freep(&dm->clean_src);
-    for (i = 0; i < ctx->nb_inputs; i++)
-        av_freep(&ctx->input_pads[i].name);
 }
 
 static int request_inlink(AVFilterContext *ctx, int lid)