diff mbox series

[FFmpeg-devel] avfilter/vf_showpalette: Don't pretend disp_palette can fail

Message ID 20200615180718.29414-1-andreas.rheinhardt@gmail.com
State Accepted
Commit 3f2be5372e438b1463e6d5b18ff18b0fccdc74cd
Headers show
Series [FFmpeg-devel] avfilter/vf_showpalette: Don't pretend disp_palette can fail
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 June 15, 2020, 6:07 p.m. UTC
It can't fail, yet it returns an int and other code checks whether it
failed; yet if it did fail, an AVFrame would leak. One could of course
add an av_frame_free for this (that compilers could optimize away), yet
it is easier to simply stop pretending that disp_palette could fail.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavfilter/vf_showpalette.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

Comments

Andreas Rheinhardt June 21, 2020, 9:16 a.m. UTC | #1
Andreas Rheinhardt:
> It can't fail, yet it returns an int and other code checks whether it
> failed; yet if it did fail, an AVFrame would leak. One could of course
> add an av_frame_free for this (that compilers could optimize away), yet
> it is easier to simply stop pretending that disp_palette could fail.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavfilter/vf_showpalette.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/libavfilter/vf_showpalette.c b/libavfilter/vf_showpalette.c
> index 5b0772bc0b..f715d6bc2c 100644
> --- a/libavfilter/vf_showpalette.c
> +++ b/libavfilter/vf_showpalette.c
> @@ -76,7 +76,7 @@ static int config_output(AVFilterLink *outlink)
>      return 0;
>  }
>  
> -static int disp_palette(AVFrame *out, const AVFrame *in, int size)
> +static void disp_palette(AVFrame *out, const AVFrame *in, int size)
>  {
>      int x, y, i, j;
>      uint32_t *dst = (uint32_t *)out->data[0];
> @@ -88,12 +88,10 @@ static int disp_palette(AVFrame *out, const AVFrame *in, int size)
>              for (j = 0; j < size; j++)
>                  for (i = 0; i < size; i++)
>                      dst[(y*dst_linesize + x) * size + j*dst_linesize + i] = pal[y*16 + x];
> -    return 0;
>  }
>  
>  static int filter_frame(AVFilterLink *inlink, AVFrame *in)
>  {
> -    int ret;
>      AVFrame *out;
>      AVFilterContext *ctx = inlink->dst;
>      const ShowPaletteContext *s = ctx->priv;
> @@ -105,9 +103,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
>          return AVERROR(ENOMEM);
>      }
>      av_frame_copy_props(out, in);
> -    ret = disp_palette(out, in, s->size);
> +    disp_palette(out, in, s->size);
>      av_frame_free(&in);
> -    return ret < 0 ? ret : ff_filter_frame(outlink, out);
> +    return ff_filter_frame(outlink, out);
>  }
>  
>  static const AVFilterPad showpalette_inputs[] = {
> 
Will apply tomorrow unless there are objections.

- Andreas
diff mbox series

Patch

diff --git a/libavfilter/vf_showpalette.c b/libavfilter/vf_showpalette.c
index 5b0772bc0b..f715d6bc2c 100644
--- a/libavfilter/vf_showpalette.c
+++ b/libavfilter/vf_showpalette.c
@@ -76,7 +76,7 @@  static int config_output(AVFilterLink *outlink)
     return 0;
 }
 
-static int disp_palette(AVFrame *out, const AVFrame *in, int size)
+static void disp_palette(AVFrame *out, const AVFrame *in, int size)
 {
     int x, y, i, j;
     uint32_t *dst = (uint32_t *)out->data[0];
@@ -88,12 +88,10 @@  static int disp_palette(AVFrame *out, const AVFrame *in, int size)
             for (j = 0; j < size; j++)
                 for (i = 0; i < size; i++)
                     dst[(y*dst_linesize + x) * size + j*dst_linesize + i] = pal[y*16 + x];
-    return 0;
 }
 
 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 {
-    int ret;
     AVFrame *out;
     AVFilterContext *ctx = inlink->dst;
     const ShowPaletteContext *s = ctx->priv;
@@ -105,9 +103,9 @@  static int filter_frame(AVFilterLink *inlink, AVFrame *in)
         return AVERROR(ENOMEM);
     }
     av_frame_copy_props(out, in);
-    ret = disp_palette(out, in, s->size);
+    disp_palette(out, in, s->size);
     av_frame_free(&in);
-    return ret < 0 ? ret : ff_filter_frame(outlink, out);
+    return ff_filter_frame(outlink, out);
 }
 
 static const AVFilterPad showpalette_inputs[] = {