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.
Showing the changes to libavfilter (1 of 1 file). Show all
Unified · Split
| @@ -76,7 +76,7 @@ static int config_output(AVFilterLink *outlink) · 75 unmodified lines | ||
| 76 | 76 | return 0; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | −static int disp_palette(AVFrame *out, const AVFrame *in, int size) | |
| 79 | +static void disp_palette(AVFrame *out, const AVFrame *in, int size) | |
| 80 | 80 | { |
| 81 | 81 | int x, y, i, j; |
| 82 | 82 | uint32_t *dst = (uint32_t *)out->data[0]; |
| @@ -88,12 +88,10 @@ static int disp_palette(AVFrame *out, const AVFrame *in, int size) · 5 unmodified lines | ||
| 88 | 88 | for (j = 0; j < size; j++) |
| 89 | 89 | for (i = 0; i < size; i++) |
| 90 | 90 | dst[(y*dst_linesize + x) * size + j*dst_linesize + i] = pal[y*16 + x]; |
| 91 | − return 0; | |
| 92 | 91 | } |
| 93 | 92 | |
| 94 | 93 | static int filter_frame(AVFilterLink *inlink, AVFrame *in) |
| 95 | 94 | { |
| 96 | − int ret; | |
| 97 | 95 | AVFrame *out; |
| 98 | 96 | AVFilterContext *ctx = inlink->dst; |
| 99 | 97 | const ShowPaletteContext *s = ctx->priv; |
| @@ -105,9 +103,9 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 5 unmodified lines | ||
| 105 | 103 | return AVERROR(ENOMEM); |
| 106 | 104 | } |
| 107 | 105 | av_frame_copy_props(out, in); |
| 108 | − ret = disp_palette(out, in, s->size); | |
| 106 | + disp_palette(out, in, s->size); | |
| 109 | 107 | av_frame_free(&in); |
| 110 | − return ret < 0 ? ret : ff_filter_frame(outlink, out); | |
| 108 | + return ff_filter_frame(outlink, out); | |
| 111 | 109 | } |
| 112 | 110 | |
| 113 | 111 | static const AVFilterPad showpalette_inputs[] = { |