Commit fd682b18 authored by Clément Bœsch's avatar Clément Bœsch

avfilter: handle error in query_formats() of a bunch of random video filters

parent 545b0dd6
...@@ -416,11 +416,18 @@ static int query_formats(AVFilterContext *ctx) ...@@ -416,11 +416,18 @@ static int query_formats(AVFilterContext *ctx)
if (!select->do_scene_detect) { if (!select->do_scene_detect) {
return ff_default_query_formats(ctx); return ff_default_query_formats(ctx);
} else { } else {
int ret;
static const enum AVPixelFormat pix_fmts[] = { static const enum AVPixelFormat pix_fmts[] = {
AV_PIX_FMT_RGB24, AV_PIX_FMT_BGR24, AV_PIX_FMT_RGB24, AV_PIX_FMT_BGR24,
AV_PIX_FMT_NONE AV_PIX_FMT_NONE
}; };
ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
if (!fmts_list)
return AVERROR(ENOMEM);
ret = ff_set_common_formats(ctx, fmts_list);
if (ret < 0)
return ret;
} }
return 0; return 0;
} }
......
...@@ -62,8 +62,10 @@ static int query_formats(AVFilterContext *ctx) ...@@ -62,8 +62,10 @@ static int query_formats(AVFilterContext *ctx)
// TODO: we can probably add way more pixel formats without any other // TODO: we can probably add way more pixel formats without any other
// changes; anything with 8-bit luma in first plane should be working // changes; anything with 8-bit luma in first plane should be working
static const enum AVPixelFormat pix_fmts[] = {AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE}; static const enum AVPixelFormat pix_fmts[] = {AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE};
ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
return 0; if (!fmts_list)
return AVERROR(ENOMEM);
return ff_set_common_formats(ctx, fmts_list);
} }
static int clip_line(int *sx, int *sy, int *ex, int *ey, int maxx) static int clip_line(int *sx, int *sy, int *ex, int *ey, int maxx)
......
...@@ -76,9 +76,10 @@ static int query_formats(AVFilterContext *ctx) ...@@ -76,9 +76,10 @@ static int query_formats(AVFilterContext *ctx)
AV_PIX_FMT_RGB0, AV_PIX_FMT_BGR0, AV_PIX_FMT_RGB0, AV_PIX_FMT_BGR0,
AV_PIX_FMT_NONE AV_PIX_FMT_NONE
}; };
AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); if (!fmts_list)
return 0; return AVERROR(ENOMEM);
return ff_set_common_formats(ctx, fmts_list);
} }
static int config_output(AVFilterLink *outlink) static int config_output(AVFilterLink *outlink)
......
...@@ -353,10 +353,10 @@ static int query_formats(AVFilterContext *ctx) ...@@ -353,10 +353,10 @@ static int query_formats(AVFilterContext *ctx)
AV_PIX_FMT_UYVY422, AV_PIX_FMT_UYVY422,
AV_PIX_FMT_NONE AV_PIX_FMT_NONE
}; };
AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); if (!fmts_list)
return AVERROR(ENOMEM);
return 0; return ff_set_common_formats(ctx, fmts_list);
} }
static int filter_frame(AVFilterLink *link, AVFrame *in) static int filter_frame(AVFilterLink *link, AVFrame *in)
......
...@@ -464,8 +464,10 @@ static int query_formats(AVFilterContext *ctx) ...@@ -464,8 +464,10 @@ static int query_formats(AVFilterContext *ctx)
AV_PIX_FMT_RGB0, AV_PIX_FMT_BGR0, AV_PIX_FMT_RGB0, AV_PIX_FMT_BGR0,
AV_PIX_FMT_NONE AV_PIX_FMT_NONE
}; };
ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
return 0; if (!fmts_list)
return AVERROR(ENOMEM);
return ff_set_common_formats(ctx, fmts_list);
} }
static int config_input(AVFilterLink *inlink) static int config_input(AVFilterLink *inlink)
......
...@@ -600,8 +600,10 @@ static int query_formats(AVFilterContext *ctx) ...@@ -600,8 +600,10 @@ static int query_formats(AVFilterContext *ctx)
AV_PIX_FMT_BGR24, AV_PIX_FMT_RGB24, AV_PIX_FMT_BGR24, AV_PIX_FMT_RGB24,
AV_PIX_FMT_NONE AV_PIX_FMT_NONE
}; };
ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
return 0; if (!fmts_list)
return AVERROR(ENOMEM);
return ff_set_common_formats(ctx, fmts_list);
} }
typedef struct ThreadData { typedef struct ThreadData {
......
...@@ -350,8 +350,10 @@ static int query_formats(AVFilterContext *ctx) ...@@ -350,8 +350,10 @@ static int query_formats(AVFilterContext *ctx)
AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY16, AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY16,
AV_PIX_FMT_NONE AV_PIX_FMT_NONE
}; };
ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
return 0; if (!fmts_list)
return AVERROR(ENOMEM);
return ff_set_common_formats(ctx, fmts_list);
} }
static int config_output(AVFilterLink *outlink) static int config_output(AVFilterLink *outlink)
......
...@@ -177,9 +177,10 @@ static int query_formats(AVFilterContext *ctx) ...@@ -177,9 +177,10 @@ static int query_formats(AVFilterContext *ctx)
AV_PIX_FMT_YUVA420P, AV_PIX_FMT_GRAY8, AV_PIX_FMT_YUVA420P, AV_PIX_FMT_GRAY8,
AV_PIX_FMT_NONE AV_PIX_FMT_NONE
}; };
AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); if (!fmts_list)
return 0; return AVERROR(ENOMEM);
return ff_set_common_formats(ctx, fmts_list);
} }
static av_cold int init(AVFilterContext *ctx) static av_cold int init(AVFilterContext *ctx)
......
...@@ -396,10 +396,10 @@ static int query_formats(AVFilterContext *ctx) ...@@ -396,10 +396,10 @@ static int query_formats(AVFilterContext *ctx)
AV_PIX_FMT_YUV411P, AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUV411P, AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P,
AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ440P, AV_PIX_FMT_NONE AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ440P, AV_PIX_FMT_NONE
}; };
AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); if (!fmts_list)
return AVERROR(ENOMEM);
return 0; return ff_set_common_formats(ctx, fmts_list);
} }
static int config_props(AVFilterLink *link) static int config_props(AVFilterLink *link)
......
...@@ -112,9 +112,10 @@ static int query_formats(AVFilterContext *ctx) ...@@ -112,9 +112,10 @@ static int query_formats(AVFilterContext *ctx)
AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUVJ440P, AV_PIX_FMT_YUV440P, AV_PIX_FMT_YUVJ440P,
AV_PIX_FMT_NONE AV_PIX_FMT_NONE
}; };
AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); if (!fmts_list)
return 0; return AVERROR(ENOMEM);
return ff_set_common_formats(ctx, fmts_list);
} }
static int config_input(AVFilterLink *inlink) static int config_input(AVFilterLink *inlink)
......
...@@ -78,17 +78,22 @@ static av_cold int init(AVFilterContext *ctx) ...@@ -78,17 +78,22 @@ static av_cold int init(AVFilterContext *ctx)
static int query_formats(AVFilterContext *ctx) static int query_formats(AVFilterContext *ctx)
{ {
const EdgeDetectContext *edgedetect = ctx->priv; const EdgeDetectContext *edgedetect = ctx->priv;
static const enum AVPixelFormat wires_pix_fmts[] = {AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE};
static const enum AVPixelFormat colormix_pix_fmts[] = {AV_PIX_FMT_GBRP, AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE};
AVFilterFormats *fmts_list;
const enum AVPixelFormat *pix_fmts = NULL;
if (edgedetect->mode == MODE_WIRES) { if (edgedetect->mode == MODE_WIRES) {
static const enum AVPixelFormat pix_fmts[] = {AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE}; pix_fmts = wires_pix_fmts;
ff_set_common_formats(ctx, ff_make_format_list(pix_fmts));
} else if (edgedetect->mode == MODE_COLORMIX) { } else if (edgedetect->mode == MODE_COLORMIX) {
static const enum AVPixelFormat pix_fmts[] = {AV_PIX_FMT_GBRP, AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE}; pix_fmts = colormix_pix_fmts;
ff_set_common_formats(ctx, ff_make_format_list(pix_fmts));
} else { } else {
av_assert0(0); av_assert0(0);
} }
return 0; fmts_list = ff_make_format_list(pix_fmts);
if (!fmts_list)
return AVERROR(ENOMEM);
return ff_set_common_formats(ctx, fmts_list);
} }
static int config_props(AVFilterLink *inlink) static int config_props(AVFilterLink *inlink)
......
...@@ -80,10 +80,10 @@ static int query_formats(AVFilterContext *ctx) ...@@ -80,10 +80,10 @@ static int query_formats(AVFilterContext *ctx)
AV_PIX_FMT_RGB24, AV_PIX_FMT_BGR24, AV_PIX_FMT_RGB24, AV_PIX_FMT_BGR24,
AV_PIX_FMT_NONE AV_PIX_FMT_NONE
}; };
AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); if (!fmts_list)
return AVERROR(ENOMEM);
return 0; return ff_set_common_formats(ctx, fmts_list);
} }
#define NB_COMPONENTS 3 #define NB_COMPONENTS 3
......
...@@ -233,10 +233,10 @@ static int query_formats(AVFilterContext *ctx) ...@@ -233,10 +233,10 @@ static int query_formats(AVFilterContext *ctx)
AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUV444P,
AV_PIX_FMT_NONE AV_PIX_FMT_NONE
}; };
AVFilterFormats *fmts_list = ff_make_format_list(pixel_fmts_eq);
ff_set_common_formats(ctx, ff_make_format_list(pixel_fmts_eq)); if (!fmts_list)
return AVERROR(ENOMEM);
return 0; return ff_set_common_formats(ctx, fmts_list);
} }
static int filter_frame(AVFilterLink *inlink, AVFrame *in) static int filter_frame(AVFilterLink *inlink, AVFrame *in)
......
...@@ -855,8 +855,10 @@ static int query_formats(AVFilterContext *ctx) ...@@ -855,8 +855,10 @@ static int query_formats(AVFilterContext *ctx)
AV_PIX_FMT_YUV411P, AV_PIX_FMT_YUV410P, AV_PIX_FMT_YUV411P, AV_PIX_FMT_YUV410P,
AV_PIX_FMT_NONE AV_PIX_FMT_NONE
}; };
ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
return 0; if (!fmts_list)
return AVERROR(ENOMEM);
return ff_set_common_formats(ctx, fmts_list);
} }
static int config_input(AVFilterLink *inlink) static int config_input(AVFilterLink *inlink)
......
...@@ -155,10 +155,10 @@ static int query_formats(AVFilterContext *ctx) ...@@ -155,10 +155,10 @@ static int query_formats(AVFilterContext *ctx)
AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRP,
AV_PIX_FMT_NONE AV_PIX_FMT_NONE
}; };
AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); if (!fmts_list)
return AVERROR(ENOMEM);
return 0; return ff_set_common_formats(ctx, fmts_list);
} }
static int config_input(AVFilterLink *inlink) static int config_input(AVFilterLink *inlink)
......
...@@ -99,9 +99,10 @@ static int query_formats(AVFilterContext *ctx) ...@@ -99,9 +99,10 @@ static int query_formats(AVFilterContext *ctx)
AV_PIX_FMT_RGB24, AV_PIX_FMT_BGR24, AV_PIX_FMT_RGB24, AV_PIX_FMT_BGR24,
AV_PIX_FMT_NONE AV_PIX_FMT_NONE
}; };
AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); if (!fmts_list)
return 0; return AVERROR(ENOMEM);
return ff_set_common_formats(ctx, fmts_list);
} }
static int config_input(AVFilterLink *inlink) static int config_input(AVFilterLink *inlink)
......
...@@ -253,10 +253,10 @@ static int query_formats(AVFilterContext *ctx) ...@@ -253,10 +253,10 @@ static int query_formats(AVFilterContext *ctx)
AV_PIX_FMT_YUV444P16, AV_PIX_FMT_YUV444P16,
AV_PIX_FMT_NONE AV_PIX_FMT_NONE
}; };
AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); if (!fmts_list)
return AVERROR(ENOMEM);
return 0; return ff_set_common_formats(ctx, fmts_list);
} }
static int config_input(AVFilterLink *inlink) static int config_input(AVFilterLink *inlink)
......
...@@ -462,8 +462,10 @@ HQX_FUNC(4) ...@@ -462,8 +462,10 @@ HQX_FUNC(4)
static int query_formats(AVFilterContext *ctx) static int query_formats(AVFilterContext *ctx)
{ {
static const enum AVPixelFormat pix_fmts[] = {AV_PIX_FMT_RGB32, AV_PIX_FMT_NONE}; static const enum AVPixelFormat pix_fmts[] = {AV_PIX_FMT_RGB32, AV_PIX_FMT_NONE};
ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
return 0; if (!fmts_list)
return AVERROR(ENOMEM);
return ff_set_common_formats(ctx, fmts_list);
} }
static int config_output(AVFilterLink *outlink) static int config_output(AVFilterLink *outlink)
......
...@@ -233,10 +233,10 @@ static int query_formats(AVFilterContext *ctx) ...@@ -233,10 +233,10 @@ static int query_formats(AVFilterContext *ctx)
AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUVA420P,
AV_PIX_FMT_NONE AV_PIX_FMT_NONE
}; };
AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); if (!fmts_list)
return AVERROR(ENOMEM);
return 0; return ff_set_common_formats(ctx, fmts_list);
} }
static int config_props(AVFilterLink *inlink) static int config_props(AVFilterLink *inlink)
......
...@@ -399,10 +399,10 @@ static int query_formats(AVFilterContext *ctx) ...@@ -399,10 +399,10 @@ static int query_formats(AVFilterContext *ctx)
AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUVA420P,
AV_PIX_FMT_NONE AV_PIX_FMT_NONE
}; };
AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); if (!fmts_list)
return AVERROR(ENOMEM);
return 0; return ff_set_common_formats(ctx, fmts_list);
} }
static int config_output(AVFilterLink *outlink) static int config_output(AVFilterLink *outlink)
......
...@@ -107,9 +107,10 @@ static int query_formats(AVFilterContext *ctx) ...@@ -107,9 +107,10 @@ static int query_formats(AVFilterContext *ctx)
AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRAP, AV_PIX_FMT_GBRP, AV_PIX_FMT_GBRAP,
AV_PIX_FMT_NONE AV_PIX_FMT_NONE
}; };
AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); if (!fmts_list)
return 0; return AVERROR(ENOMEM);
return ff_set_common_formats(ctx, fmts_list);
} }
static av_cold void uninit(AVFilterContext *ctx) static av_cold void uninit(AVFilterContext *ctx)
......
...@@ -63,9 +63,10 @@ static int query_formats(AVFilterContext *ctx) ...@@ -63,9 +63,10 @@ static int query_formats(AVFilterContext *ctx)
static const enum AVPixelFormat pix_fmts[] = { static const enum AVPixelFormat pix_fmts[] = {
AV_PIX_FMT_BGR24, AV_PIX_FMT_BGRA, AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE AV_PIX_FMT_BGR24, AV_PIX_FMT_BGRA, AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE
}; };
AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); if (!fmts_list)
return 0; return AVERROR(ENOMEM);
return ff_set_common_formats(ctx, fmts_list);
} }
typedef struct OCVContext { typedef struct OCVContext {
......
...@@ -130,9 +130,10 @@ static int query_formats(AVFilterContext *ctx) ...@@ -130,9 +130,10 @@ static int query_formats(AVFilterContext *ctx)
const enum AVPixelFormat *pix_fmts = s->is_rgb ? rgb_pix_fmts : const enum AVPixelFormat *pix_fmts = s->is_rgb ? rgb_pix_fmts :
s->is_yuv ? yuv_pix_fmts : s->is_yuv ? yuv_pix_fmts :
all_pix_fmts; all_pix_fmts;
AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); if (!fmts_list)
return 0; return AVERROR(ENOMEM);
return ff_set_common_formats(ctx, fmts_list);
} }
/** /**
......
...@@ -471,8 +471,10 @@ static int query_formats(AVFilterContext *ctx) ...@@ -471,8 +471,10 @@ static int query_formats(AVFilterContext *ctx)
AV_PIX_FMT_RGBA64, AV_PIX_FMT_BGRA64, AV_PIX_FMT_RGBA64, AV_PIX_FMT_BGRA64,
AV_PIX_FMT_NONE AV_PIX_FMT_NONE
}; };
ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
return 0; if (!fmts_list)
return AVERROR(ENOMEM);
return ff_set_common_formats(ctx, fmts_list);
} }
static int config_input(AVFilterLink *inlink) static int config_input(AVFilterLink *inlink)
......
...@@ -163,10 +163,10 @@ static int query_formats(AVFilterContext *ctx) ...@@ -163,10 +163,10 @@ static int query_formats(AVFilterContext *ctx)
static const enum PixelFormat pix_fmts[] = { static const enum PixelFormat pix_fmts[] = {
AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE
}; };
AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); if (!fmts_list)
return AVERROR(ENOMEM);
return 0; return ff_set_common_formats(ctx, fmts_list);
} }
static int filter_frame(AVFilterLink *inlink, AVFrame *inpic) static int filter_frame(AVFilterLink *inlink, AVFrame *inpic)
......
...@@ -158,10 +158,10 @@ static int query_formats(AVFilterContext *ctx) ...@@ -158,10 +158,10 @@ static int query_formats(AVFilterContext *ctx)
AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUVA420P,
AV_PIX_FMT_NONE AV_PIX_FMT_NONE
}; };
AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); if (!fmts_list)
return AVERROR(ENOMEM);
return 0; return ff_set_common_formats(ctx, fmts_list);
} }
static int config_input(AVFilterLink *inlink) static int config_input(AVFilterLink *inlink)
......
...@@ -267,8 +267,10 @@ static int query_formats(AVFilterContext *ctx) ...@@ -267,8 +267,10 @@ static int query_formats(AVFilterContext *ctx)
AV_PIX_FMT_YUVA420P, AV_PIX_FMT_YUVA420P,
AV_PIX_FMT_NONE AV_PIX_FMT_NONE
}; };
ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
return 0; if (!fmts_list)
return AVERROR(ENOMEM);
return ff_set_common_formats(ctx, fmts_list);
} }
static int config_input(AVFilterLink *inlink) static int config_input(AVFilterLink *inlink)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment