From 54fc8d370eb8a4d384e2618077a0fbb30639ccce Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Sun, 14 Jul 2019 18:18:29 +0200 Subject: [PATCH] avfilter/vf_remap: add option to control output format --- libavfilter/vf_remap.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libavfilter/vf_remap.c b/libavfilter/vf_remap.c index 2603997a2b..b1c3e43242 100644 --- a/libavfilter/vf_remap.c +++ b/libavfilter/vf_remap.c @@ -47,9 +47,12 @@ typedef struct RemapContext { const AVClass *class; + int format; + int nb_planes; int nb_components; int step; + FFFrameSync fs; int (*remap_slice)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs); @@ -59,6 +62,9 @@ typedef struct RemapContext { #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM static const AVOption remap_options[] = { + { "format", "set output format", OFFSET(format), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS, "format" }, + { "color", "", 0, AV_OPT_TYPE_CONST, {.i64=0}, .flags = FLAGS, .unit = "format" }, + { "gray", "", 0, AV_OPT_TYPE_CONST, {.i64=1}, .flags = FLAGS, .unit = "format" }, { NULL } }; @@ -73,6 +79,7 @@ typedef struct ThreadData { static int query_formats(AVFilterContext *ctx) { + RemapContext *s = ctx->priv; static const enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_YUVA444P, AV_PIX_FMT_YUV444P, @@ -88,6 +95,9 @@ static int query_formats(AVFilterContext *ctx) AV_PIX_FMT_GBRAP10, AV_PIX_FMT_GBRAP12, AV_PIX_FMT_GBRAP16, AV_PIX_FMT_RGB48, AV_PIX_FMT_BGR48, AV_PIX_FMT_RGBA64, AV_PIX_FMT_BGRA64, + AV_PIX_FMT_NONE + }; + static const enum AVPixelFormat gray_pix_fmts[] = { AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY9, AV_PIX_FMT_GRAY10, AV_PIX_FMT_GRAY12, AV_PIX_FMT_GRAY14, AV_PIX_FMT_GRAY16, @@ -100,7 +110,7 @@ static int query_formats(AVFilterContext *ctx) AVFilterFormats *pix_formats = NULL, *map_formats = NULL; int ret; - if (!(pix_formats = ff_make_format_list(pix_fmts)) || + if (!(pix_formats = ff_make_format_list(s->format ? gray_pix_fmts : pix_fmts)) || !(map_formats = ff_make_format_list(map_fmts))) { ret = AVERROR(ENOMEM); goto fail;