From patchwork Sat Jun 25 09:57:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aman Karmani X-Patchwork-Id: 36445 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:8b27:b0:88:1bbf:7fd2 with SMTP id l39csp826950pzh; Sat, 25 Jun 2022 03:01:56 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v6908t8SUTWmE8JdouvI49HVh3afkGOqPuOYzLOvgmYB5+RBuk97SRo+u+1k3+Y4MdptXk X-Received: by 2002:a17:906:7493:b0:722:df76:319d with SMTP id e19-20020a170906749300b00722df76319dmr3222356ejl.588.1656151316384; Sat, 25 Jun 2022 03:01:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656151316; cv=none; d=google.com; s=arc-20160816; b=sVkpJoHsm7qNVssDQ5v8E39+cKLauOdBi/1RD52CtOkPKFHsMMruTUtjKX34Wz3XfO eVFy0W1gCIgXTKE8t+czIG8QKMg4MXBkyY4wISuoy2nm8U4ZuHAZkwW4AHTfLUgHpWqq s06tkj0d14RIzQfFuiHQHmhPc66CbyWt2n4dsL6+X43awdItMMPOIxfLGbb2fQR8woa4 udcV7vB0TrzJOPiWP6gP5Lc7LrpvC+evUw7V4sislN7HDXWMGY7r4w+8va/21JPJtMHp aaZ4SL/zItdL4cHih5BatVQg+Wk9ipkMLNJ30x1q6YrPXXxnbi+eM/PDrTkMz8V8s2nY sFOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:to:mime-version:fcc:date:references :in-reply-to:message-id:from:dkim-signature:delivered-to; bh=qEGYq5B0QVJ9mubxdzohmY5qAr1xjOlhLm0ZHJiWfN4=; b=j76Qm2tAYWso1CpTqDhblaU/3qg1jfZts2Doz+Ky483ocouohBjzKgW6Mrl1V+v5rN z4cO0qOqlb+TmzlyfDR50m4wUq0a5dblNi6abBBsuYEd+4aQCagJL7/n9V/Ly3AHvmP5 IlrTwVEDsmI7FxpBpWUreys7D2NTbsfuSqmVFZNMK98nEc4BhX0wGWasUEtxX8tWQY2F ApXcQkTn9DUERnoXpdgMrFY+VtvSDW4Ai2MzTvWqJPevYdkfsBcs+iNbIfhLYT+Ssbcu gz3YWTmlMXPXRCF0Kt+CrTicnZeSIECd8BsDdwqSoMwt1adYr+A3iI7V/HLEWXOS8Kwa I57A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=AjgWAvTi; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id o22-20020a17090637d600b00710487d3a4fsi5308011ejc.67.2022.06.25.03.01.55; Sat, 25 Jun 2022 03:01:56 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=AjgWAvTi; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CDB0F68B8A9; Sat, 25 Jun 2022 12:58:34 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 756DE68B895 for ; Sat, 25 Jun 2022 12:58:30 +0300 (EEST) Received: by mail-pf1-f169.google.com with SMTP id i64so4623094pfc.8 for ; Sat, 25 Jun 2022 02:58:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:message-id:in-reply-to:references:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=+I8rCsXR1pIOmEXoe8/aOJwi4Pi18FS2jZdgmLY2U0g=; b=AjgWAvTi/h4djz/B/GLbZr/PDdDhc34cwPVUXQ7U0z5Bw7xplbEjxXJ/yhch5xEnGJ jHPt0Za8uuaDXtSweHFIvE1+6F+iDqBDVAq/C+iDdoke88J7dsJwJp1beM48tZqj2dyN Gh/Ra/EDXJB3VGmXhW3QDEifCqmfsjWIXqSlJvFCI/HbS3xO9qz5e4A2v2bZOQmVjg5j i233wlJPg5pEOVhXJz+cC04uld1vY5iuqoJEsukwPg222sHVKgCtanCnqEKWIxbo1mmo iO9vnORD1q5SpSagfnmEC6mYiwodh4jbpSY1iKjuDH6ZL8brhMV1bRY3pThPBwUTRqsA bpiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:message-id:in-reply-to:references:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=+I8rCsXR1pIOmEXoe8/aOJwi4Pi18FS2jZdgmLY2U0g=; b=1oySw0kR+fMnH6cIg+MMz4WC/cvQ6q7dI0QoMrCQA0QAyLg3bHQQsLxMKIH+M9Cb3W D+oMoUB1QhX/pqfV0QZyTuLNVZ+WtsakRX20SMdOnvDL9M35MAIG2gQE0gvcKK9o2hNd PvG5iA/cwffgFMI8swrtbydlXIEzDBxLpMgUDnIdOvwnKdt7TXmE8d7XzG7zDyq0W5su S0Mk7ZU8wTJEeSUpsMBhomNjuibiaswh5sNq9stSJhH1tVHNDeritlGtocOdvc2rJtfX d63xwLkzjd4DcE3tABMvvWaYuKOp2xNrY6baBmDesYsxohZwF4HY7+mGlZUqsqYgkh1/ CssQ== X-Gm-Message-State: AJIora/6G3oVsTo/0d1vFbqNL0Ux8qjpxaIG+MOkWz4MKyutU8uHGmPI 7w+7O/NZoL6DuqAhGOSSr8Tva8o3hmVvxg== X-Received: by 2002:a63:28f:0:b0:401:b849:cbd8 with SMTP id 137-20020a63028f000000b00401b849cbd8mr3133693pgc.132.1656151108859; Sat, 25 Jun 2022 02:58:28 -0700 (PDT) Received: from [127.0.0.1] (master.gitmailbox.com. [34.83.118.50]) by smtp.gmail.com with ESMTPSA id m13-20020a170902e40d00b00167838b82e0sm3256432ple.205.2022.06.25.02.58.27 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 25 Jun 2022 02:58:28 -0700 (PDT) From: softworkz X-Google-Original-From: softworkz Message-Id: In-Reply-To: References: Date: Sat, 25 Jun 2022 09:57:54 +0000 Fcc: Sent MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH v5 22/25] avfilter/snull, strim: Add snull and strim filters 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 Cc: Michael Niedermayer , softworkz , Andriy Gelman , Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: ykUV0HJ3wre0 From: softworkz Signed-off-by: softworkz --- configure | 2 +- libavfilter/Makefile | 2 ++ libavfilter/allfilters.c | 2 ++ libavfilter/sf_snull.c | 50 ++++++++++++++++++++++++++++++++++++++++ libavfilter/trim.c | 46 +++++++++++++++++++++++++++++++++++- 5 files changed, 100 insertions(+), 2 deletions(-) create mode 100644 libavfilter/sf_snull.c diff --git a/configure b/configure index f74077b439..285bdf958e 100755 --- a/configure +++ b/configure @@ -3817,7 +3817,7 @@ avutil_extralibs="d3d11va_extralibs nanosleep_extralibs pthreads_extralibs vaapi # programs ffmpeg_deps="avcodec avfilter avformat" ffmpeg_select="aformat_filter anull_filter atrim_filter format_filter - hflip_filter null_filter + snull_filter strim_filter hflip_filter null_filter transpose_filter trim_filter vflip_filter" ffmpeg_suggest="ole32 psapi shell32" ffplay_deps="avcodec avformat swscale swresample sdl2" diff --git a/libavfilter/Makefile b/libavfilter/Makefile index adbc16a5a9..697eee57d2 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -581,7 +581,9 @@ OBJS-$(CONFIG_NULLSINK_FILTER) += vsink_nullsink.o # subtitle filters OBJS-$(CONFIG_CENSOR_FILTER) += sf_textmod.o OBJS-$(CONFIG_SHOW_SPEAKER_FILTER) += sf_textmod.o +OBJS-$(CONFIG_SNULL_FILTER) += sf_snull.o OBJS-$(CONFIG_SPLITCC_FILTER) += sf_splitcc.o +OBJS-$(CONFIG_STRIM_FILTER) += trim.o OBJS-$(CONFIG_STRIPSTYLES_FILTER) += sf_stripstyles.o OBJS-$(CONFIG_SUBFEED_FILTER) += sf_subfeed.o OBJS-$(CONFIG_SUBSCALE_FILTER) += sf_subscale.o diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index 82297e9657..fa7bee3bd8 100644 --- a/libavfilter/allfilters.c +++ b/libavfilter/allfilters.c @@ -573,7 +573,9 @@ extern const AVFilter ff_avsrc_movie; extern const AVFilter ff_sf_censor; extern const AVFilter ff_sf_graphicsub2text; extern const AVFilter ff_sf_showspeaker; +extern const AVFilter ff_sf_snull; extern const AVFilter ff_sf_splitcc; +extern const AVFilter ff_sf_strim; extern const AVFilter ff_sf_stripstyles; extern const AVFilter ff_sf_subfeed; extern const AVFilter ff_sf_subscale; diff --git a/libavfilter/sf_snull.c b/libavfilter/sf_snull.c new file mode 100644 index 0000000000..064c8d5c3a --- /dev/null +++ b/libavfilter/sf_snull.c @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2021 softworkz + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * null subtitle filter + */ + +#include "avfilter.h" +#include "internal.h" +#include "libavutil/internal.h" + +static const AVFilterPad avfilter_sf_snull_inputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_SUBTITLE, + }, +}; + +static const AVFilterPad avfilter_sf_snull_outputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_SUBTITLE, + }, +}; + +const AVFilter ff_sf_snull = { + .name = "snull", + .description = NULL_IF_CONFIG_SMALL("Pass the source unchanged to the output."), + .flags = AVFILTER_FLAG_METADATA_ONLY, + FILTER_INPUTS(avfilter_sf_snull_inputs), + FILTER_OUTPUTS(avfilter_sf_snull_outputs), +}; diff --git a/libavfilter/trim.c b/libavfilter/trim.c index ee6e821cd2..5e3d2ba9f8 100644 --- a/libavfilter/trim.c +++ b/libavfilter/trim.c @@ -83,7 +83,7 @@ static int config_input(AVFilterLink *inlink) { AVFilterContext *ctx = inlink->dst; TrimContext *s = ctx->priv; - AVRational tb = (inlink->type == AVMEDIA_TYPE_VIDEO) ? + AVRational tb = (inlink->type != AVMEDIA_TYPE_AUDIO) ? inlink->time_base : (AVRational){ 1, inlink->sample_rate }; if (s->start_time != INT64_MAX) { @@ -369,3 +369,47 @@ const AVFilter ff_af_atrim = { FILTER_OUTPUTS(atrim_outputs), }; #endif // CONFIG_ATRIM_FILTER + +#if CONFIG_STRIM_FILTER + +#define FLAGS (AV_OPT_FLAG_SUBTITLE_PARAM | AV_OPT_FLAG_FILTERING_PARAM) +static const AVOption strim_options[] = { + COMMON_OPTS + { "start_frame", "Number of the first frame that should be passed " + "to the output", OFFSET(start_frame), AV_OPT_TYPE_INT64, { .i64 = -1 }, -1, INT64_MAX, FLAGS }, + { "end_frame", "Number of the first frame that should be dropped " + "again", OFFSET(end_frame), AV_OPT_TYPE_INT64, { .i64 = INT64_MAX }, 0, INT64_MAX, FLAGS }, + { NULL } +}; +#undef FLAGS + +AVFILTER_DEFINE_CLASS(strim); + +static const AVFilterPad strim_inputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_SUBTITLE, + .filter_frame = trim_filter_frame, + .config_props = config_input, + }, +}; + +static const AVFilterPad strim_outputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_SUBTITLE, + }, +}; + +const AVFilter ff_sf_strim = { + .name = "strim", + .description = NULL_IF_CONFIG_SMALL("Pick one continuous section from the input, drop the rest."), + .init = init, + .priv_size = sizeof(TrimContext), + .priv_class = &strim_class, + .flags = AVFILTER_FLAG_METADATA_ONLY, + FILTER_INPUTS(strim_inputs), + FILTER_OUTPUTS(strim_outputs), +}; +#endif // CONFIG_STRIM_FILTER +