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 31D0D43713 for ; Sun, 26 Jun 2022 16:39:14 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4F8EA68B8C9; Sun, 26 Jun 2022 19:35:54 +0300 (EEST) Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4570168B8A5 for ; Sun, 26 Jun 2022 19:35:48 +0300 (EEST) Received: by mail-pf1-f177.google.com with SMTP id c205so6914637pfc.7 for ; Sun, 26 Jun 2022 09:35:47 -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=fIylY38VgdiESyofX/UhU16g4RXz9CpJB029svHYj5o=; b=pFdrv6Y/a/KBBEWB4vekAzeTMRzDQz+x4TERWuN18ZTFjgQJGbVfzh+9J8eaSxrPBa S08uI+OF2UVQQETwPSLyTRzWy08B1nlsNh3sf+dyww8l2CieoPXvUfvFg0nIi4eD1C0q QPdxG7ityHNneF/Db/mOkWy4g1AylxT8VZv85TqPX6KsSSV5VvtEqNLm4Qam0ViK8iuR X/gc81bkhnywQfMYv9fYY8WqxPtNz2Apj6vj4/1sHuOlXFDOgMjJQ9Ov8bkE9KD4NAkV 9+wnHb5TEnGmBcK77Ed+svLhRRFXGNiu5RHvkSveZQHVkX/8H0PQLd4r09YG8k/esR/I RZ8w== 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=fIylY38VgdiESyofX/UhU16g4RXz9CpJB029svHYj5o=; b=ZfeppiSBonSRtWtSf3G4Lre+GRXA+xQ1VnZE/3qLdyR7lrXYYn33tIBM6GIfj+AMvl +5wkFCiidtQstpoUTJaFvVYlxbauqV2YSNxdFR+TIOJI+G/t8LgXRb8cpNLzLT8jef9e TzOJiElq8Er/SZnkGNn4lDRbi56+ZZf9XJYExEj30Y1y/r4rQ0P7gM/ZX28xbK3L4JoV udybSINsb9GHyNYYkV34pSfUZvfzxreqUz/r1oeImEwBKPe+RCANyt2x5zWBIGi/4dV3 0jLuRoYLgWhrv2jtQ6xRSr2krtoBCWYj3ZIQ+XHsHElRTcZSeJF63Ied8fRHi3u7rkyR TeGw== X-Gm-Message-State: AJIora+J1UALHJK91HH7jLLKc09OCChLs7QI/GZSRKR1LwaYAdHGcS/V ljBNCdSc/A9y/iiDqbXskvjrd3kzaD248w== X-Google-Smtp-Source: AGRyM1tYzIo+NSKBFNJXsUv0YmC1xpPrNMjN3usuiXpl6nCO6yVjFKN4zEeZhrOIG8TAdESayPoPmQ== X-Received: by 2002:a05:6a00:1acb:b0:525:b64b:79c3 with SMTP id f11-20020a056a001acb00b00525b64b79c3mr1122914pfv.76.1656261346362; Sun, 26 Jun 2022 09:35:46 -0700 (PDT) Received: from [127.0.0.1] (master.gitmailbox.com. [34.83.118.50]) by smtp.gmail.com with ESMTPSA id y12-20020aa79e0c000000b005184031963bsm5447919pfq.85.2022.06.26.09.35.45 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 26 Jun 2022 09:35:45 -0700 (PDT) From: softworkz X-Google-Original-From: softworkz Message-Id: <22d81747d1d8d3486ad009a4f4370aa4b762e4df.1656261322.git.ffmpegagent@gmail.com> In-Reply-To: References: Date: Sun, 26 Jun 2022 16:35:19 +0000 Fcc: Sent MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH v6 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 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: From: softworkz Signed-off-by: softworkz --- configure | 2 +- libavfilter/Makefile | 2 ++ libavfilter/allfilters.c | 2 ++ libavfilter/sf_snull.c | 50 +++++++++++++++++++++++++++++++++ libavfilter/trim.c | 60 +++++++++++++++++++++++++++++++++++++++- 5 files changed, 114 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..a25366497b 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,61 @@ const AVFilter ff_af_atrim = { FILTER_OUTPUTS(atrim_outputs), }; #endif // CONFIG_ATRIM_FILTER + +#if CONFIG_STRIM_FILTER + +static int sconfig_output(AVFilterLink *outlink) +{ + AVFilterContext *ctx = outlink->src; + AVFilterLink *inlink = ctx->inputs[0]; + + outlink->format = inlink->format; + outlink->w = inlink->w; + outlink->h = inlink->h; + + return 0; +} + + +#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, + .config_props = sconfig_output, + }, +}; + +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 + -- ffmpeg-codebot _______________________________________________ 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".