From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 1267A458D8 for ; Mon, 26 Jun 2023 20:09:44 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3E50368C321; Mon, 26 Jun 2023 23:09:41 +0300 (EEST) Received: from nef.ens.fr (unknown [129.199.96.40]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B279F68C2B9 for ; Mon, 26 Jun 2023 23:09:35 +0300 (EEST) X-ENS-nef-client: 129.199.129.80 ( name = phare.normalesup.org ) Received: from phare.normalesup.org (phare.normalesup.org [129.199.129.80]) by nef.ens.fr (8.14.4/1.01.28121999) with ESMTP id 35QK9Yi5007497 for ; Mon, 26 Jun 2023 22:09:34 +0200 Received: by phare.normalesup.org (Postfix, from userid 1001) id 8E636EB5BC; Mon, 26 Jun 2023 22:09:34 +0200 (CEST) From: Nicolas George To: ffmpeg-devel@ffmpeg.org Date: Mon, 26 Jun 2023 22:09:32 +0200 Message-Id: <20230626200932.1329118-2-george@nsup.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230626200932.1329118-1-george@nsup.org> References: <20230626200932.1329118-1-george@nsup.org> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (nef.ens.fr [129.199.96.32]); Mon, 26 Jun 2023 22:09:34 +0200 (CEST) Subject: [FFmpeg-devel] [WIP] [PATCH 2/2] lavfi/vf_framematch: add filter to output matching synchronized frames X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Signed-off-by: Nicolas George --- libavfilter/Makefile | 1 + libavfilter/allfilters.c | 1 + libavfilter/vf_framematch.c | 82 +++++++++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+) create mode 100644 libavfilter/vf_framematch.c Unfinished yet, but should be rather straightforward. I think I can squeeze some work on this the day after tomorrow. diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 9b7813575a..290a473b63 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -313,6 +313,7 @@ OBJS-$(CONFIG_FIND_RECT_FILTER) += vf_find_rect.o lavfutils.o OBJS-$(CONFIG_FLOODFILL_FILTER) += vf_floodfill.o OBJS-$(CONFIG_FORMAT_FILTER) += vf_format.o OBJS-$(CONFIG_FPS_FILTER) += vf_fps.o +OBJS-$(CONFIG_FRAMEMATCH_FILTER) += vf_framematch.o OBJS-$(CONFIG_FRAMEPACK_FILTER) += vf_framepack.o OBJS-$(CONFIG_FRAMERATE_FILTER) += vf_framerate.o OBJS-$(CONFIG_FRAMESTEP_FILTER) += vf_framestep.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index 9a7fadc58d..aa42b353c1 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -289,6 +289,7 @@ extern const AVFilter ff_vf_flip_vulkan; extern const AVFilter ff_vf_floodfill; extern const AVFilter ff_vf_format; extern const AVFilter ff_vf_fps; +extern const AVFilter ff_vf_framematch; extern const AVFilter ff_vf_framepack; extern const AVFilter ff_vf_framerate; extern const AVFilter ff_vf_framestep; diff --git a/libavfilter/vf_framematch.c b/libavfilter/vf_framematch.c new file mode 100644 index 0000000000..703b5ad93b --- /dev/null +++ b/libavfilter/vf_framematch.c @@ -0,0 +1,82 @@ + +#include "libavutil/avstring.h" +#include "libavutil/opt.h" + +#include "avfilter.h" +#include "framesync.h" +#include "internal.h" + +typedef struct MatchContext { + const AVClass *class; + int nb; + FFFrameSync fs; +} MatchContext; + +static av_cold int init(AVFilterContext *ctx) +{ + int i, ret; + MatchContext *s = ctx->priv; + + for (i = 0; i < s->nb; i++) { + AVFilterPad pad = { 0 }; + pad.type = AVMEDIA_TYPE_VIDEO; + pad.name = av_asprintf("input%d", i); + if (!pad.name) + return AVERROR(ENOMEM); + if ((ret = ff_append_inpad_free_name(ctx, &pad)) < 0) + return ret; + pad.name = av_asprintf("output%d", i); + if (!pad.name) + return AVERROR(ENOMEM); + if ((ret = ff_append_outpad_free_name(ctx, &pad)) < 0) + return ret; + } + return 0; +} + +static int query_formats(AVFilterContext *ctx) +{ + MatchContext *s = ctx->priv; + int i, ret; + + for (i = 0; i < s->nb; i++) { + AVFilterFormats *f = ff_all_formats(AVMEDIA_TYPE_AUDIO); + if ((ret = ff_formats_ref(f, &ctx->inputs [i]-> incfg.formats)) < 0 || + (ret = ff_formats_ref(f, &ctx->outputs[i]->outcfg.formats)) < 0) + return ret; + } + return 0; +} + +static av_cold void uninit(AVFilterContext *ctx) +{ + MatchContext *s = ctx->priv; + //ff_framesync_uninit(&s->fs); +} + +static int activate(AVFilterContext *ctx) +{ + MatchContext *s = ctx->priv; + return ff_framesync_activate(&s->fs); +} + +#define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM +#define OFFSET(x) offsetof(MatchContext, x) +static const AVOption framematch_options[] = { + { "s", "set number of streams", OFFSET(nb), AV_OPT_TYPE_INT, {.i64=2}, 2, INT_MAX, .flags = FLAGS }, + { NULL }, +}; + +AVFILTER_DEFINE_CLASS(framematch); + +const AVFilter ff_vf_framematch = { + .name = "framematch", + .description = NULL_IF_CONFIG_SMALL("Match frames from multiple inputs"), + .priv_size = sizeof(MatchContext), + .priv_class = &framematch_class, + FILTER_QUERY_FUNC(query_formats), + .init = init, + .uninit = uninit, + .activate = activate, + .flags = AVFILTER_FLAG_DYNAMIC_INPUTS | AVFILTER_FLAG_DYNAMIC_OUTPUTS, +}; -- 2.39.2 _______________________________________________ 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".