From patchwork Thu Sep 9 15:50:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 30086 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp642628iov; Thu, 9 Sep 2021 08:51:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZti9WVoEHnPk9ZK73gZOyQ2yUhr33sjLqqmA5PKG6eHwBkLMaQskgEAjadKVM1/jcXOka X-Received: by 2002:a17:906:abd7:: with SMTP id kq23mr4070858ejb.542.1631202671404; Thu, 09 Sep 2021 08:51:11 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id x17si2093183edr.232.2021.09.09.08.51.10; Thu, 09 Sep 2021 08:51:11 -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=@outlook.com header.s=selector1 header.b=vKQ96JDp; arc=fail (body hash mismatch); 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=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 92CE168A126; Thu, 9 Sep 2021 18:51:06 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05olkn2025.outbound.protection.outlook.com [40.92.89.25]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3096968A126 for ; Thu, 9 Sep 2021 18:51:00 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=erG4iaxEOSJ7PHCtk7MWGzETh97XYYaQ6f4h4gXjgOMrQsGQMXPa90hqAzAmuTKzUYwC0lNZwj1Yq2tgcQHKEUYsz0nDAwFDOvzXDdYFxOh5DQ0TqoyKAs7dEKZrwCbgtnsJGoEZI1D8GLaK6Ikl3QTKkYNMv+vdOG+CmXMjMv+k3ai2//mupo1MTvNcHcgRgMryrZxRw+Q3MXyapKUCy4/InFyomqfmO+s3ax2JvWjihmB0oNPMUQJcUhsxsuzQE9e+xhgNhaRpe2jvduBQeh92hYF4QwOR9Q8aHsxtr2S048tpxwmOnCu5MmwRvlwvqSpItqjbF6JSA+aKLOQKQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=aC1vRRl+O9LxIttxzkk4Ly//L4AbgosCrc22+n2gakg=; b=AzhOBaEwI5Kb6AH1xB2bYdf7guRyCb/9SlwiNRk4GePOx5aqWPnofEgdjZdxlyDhRPk3WnxSyFAL8f26DHQu0khmzbfQYiWo7wx8K7R/UxOvljud/M0N5CZLqY0PpxdkVhxOHFlCKmJ7aKg++WuUj3ToRu6K3yBx9FGWiQbDpwqIbagLKuyPEl4oOyXAXAMrbzAGzvVWvHNC9FdcYwF2MaBz6uhTzANTQQW8WuVv7DZ/a4VbcCRGmxLI7U08UEHkZKAfDRVHSSnyS+nu4TRe22h8C4t7M6YwVj9a8Iw8lwu0hkwMb3sFkvcxxy6J5siThcqpCnaZ8TKiR9JVboBeUA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aC1vRRl+O9LxIttxzkk4Ly//L4AbgosCrc22+n2gakg=; b=vKQ96JDpckTY4lqQ8vEiliUSbCBKJ7OlzyJ9IO77l8FTuULwmWVYjrwtU+a4lQUvLxLQqJYCJflMTkeWQC8gIRafq5oVErT1AXSAs9MawmvBWGu4vyPedhhfqzEB/WAE7QmBcrQgSh+eJLUaOKLHqMkRaaI8YIxnd/+5jgkY6KzIo5rFkuRR1+vpUd3n4Gy2NAlLItWHprm7YMg/SivsfbJ15Fm6hczgTc0hpt06iGgF78zeMACc26sbkTUWCjkjtneTiIsXUcV5PgEXUQ6GinSfW+P+ccLf6P7+ik5ICO7KN8h9foEYhQcdQXbA1O7kDlixeScxgTforiAd8KehiA== Received: from PR3PR03MB6665.eurprd03.prod.outlook.com (2603:10a6:102:7d::6) by PA4PR03MB6880.eurprd03.prod.outlook.com (2603:10a6:102:e4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.16; Thu, 9 Sep 2021 15:50:58 +0000 Received: from PR3PR03MB6665.eurprd03.prod.outlook.com ([fe80::2924:e83a:49ed:92f0]) by PR3PR03MB6665.eurprd03.prod.outlook.com ([fe80::2924:e83a:49ed:92f0%5]) with mapi id 15.20.4478.025; Thu, 9 Sep 2021 15:50:58 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 9 Sep 2021 17:50:38 +0200 Message-ID: X-Mailer: git-send-email 2.30.2 X-TMN: [yU8THfRgswa9HvrY6cN6Kq6tJ3RIBTUJ] X-ClientProxiedBy: AM0PR01CA0169.eurprd01.prod.exchangelabs.com (2603:10a6:208:aa::38) To PR3PR03MB6665.eurprd03.prod.outlook.com (2603:10a6:102:7d::6) X-Microsoft-Original-Message-ID: <20210909155051.1841354-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.192.142.38) by AM0PR01CA0169.eurprd01.prod.exchangelabs.com (2603:10a6:208:aa::38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.14 via Frontend Transport; Thu, 9 Sep 2021 15:50:58 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: dec46e63-a8bd-4626-66f5-08d973a99dd7 X-MS-Exchange-SLBlob-MailProps: 6qklvm/at0p/2h/IwjM+J4vA3FxDmJV+YQgnFaxRKaXkVwsNkBLrLv3CfC0KTjyyf+Ne57LK8b6OCfQcdBDZkTmX3hcL4fy6/DJKAx2BNvOHBlD1gTbUT9mX1P6RHId49SmO0SIb1mKY68O4AK0OQKX1+KnRMLn30WFjju83JodlK0Lb8hRs0nrzCVnTisQrERyZwcjtiBqmAZOJYvGp32hFue8C1dnbUq9OXUKLNPyks5+lwSCv6sX9M3KevczptJsXTWZiGPp0CDfoWxE8pvc2V06zTpSm0088aPBTOOheQmXfBEdTi1S5aLtuoAfQ4SJdSvWHom2SMMCdKMtTfusYYGgD34Trawmx9ydj4XcCZ8R3mI0YhpL3hwHfgBuLA2xwHvQ0bKTRuW65GtZEayqwkkWfxdyJr06LiStVa9y1riJAGreQ67kiRqcIxMXddptAdAwLU39iEH5i6cL961egf+jZNeP/Bcj4MOzffZ4m142yfaxgwIKKkhXa2wewQfZyVs2+1OBf4kz+BoCq+T3W9W6A3QIjXsupiOIkW9j5LyenlyrArev8JXmY46bpLAuee488OYdVEvtpPLNh5OfUtuEx+xq3gsmvCk/Ih4heGqiPipwy/7g85qt3k1Wo0FVta5Q7Ph+RBiBMSdwbr7CubL6DuxX/RNmIafh4jrFBAA8b5wIa4/0AZJ1oq9hVedwQ9yZ1PuxLxs1LqzQAOr+WIYpYEh/W6e3iaYFHpr4KHCtGzFfCnquvAh7aFw/qd4CjoEDBX/5Mnovx38du8ahLpqrQC/fpNWbpRX8HFblA7Pyxc8CMiQmTti5XTY2a X-MS-TrafficTypeDiagnostic: PA4PR03MB6880: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /2SlkBD3SvlqwWFuZnXeY0qhnuBETKDhKl9wtseizoPVPRSisaJVzvUIxbUMJkKejwQ9VpG3pYh+LgWOdvMJi2EYWBhcUePdWe1HJ6P8kNk1Mmru7c0tHqbkK82tLT/h0wnlK6g4XhF1O5+g7UDkLiy5xRYG5CTaUWLQyBI7Jwko+FiCqwxdHSOfC8TOCR/KSenRmGbVqvCCJPGRcfYD3tb3WsjQHYsE0lwaMKVGoKy64ohvRX6EfMN1EhnHEqEcdgG+8M8ETwQEWpcPhxomx5ZZc1Yc4jw+Ta/crSV2PcCM7RDb856kq5Ja/fTZZq+bcINaAPTfKqEXLdodbOqunk6+/QQyNytRDVrCmYjFXNjaaZexToUBiJNyKzRz4T6Jwq1NHAl1BkU5OZfwGNW/AuJdGAsTLSnUM54iLbbloINCIvVXpD4zAn6CzFKf9dsnPtb11ezNbGJMB0hAWfYTOovyqe2YOahrOzuKlN2uxTE= X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: dSNBlUDkhK2TPb0ML5A3HNGxkxD5bKcmtywBKM8qY5YLzK3yxJu+B6zilTPuyqiM/ggjgMx/BRmKfJ1scSUyoTuFlQfQWYAPNY8hvOhOKG05nTT2h/6EH58Zdb2KzIixdRQhE+FGVlU/AowsGHDItQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: dec46e63-a8bd-4626-66f5-08d973a99dd7 X-MS-Exchange-CrossTenant-AuthSource: PR3PR03MB6665.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Sep 2021 15:50:58.7967 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR03MB6880 Subject: [FFmpeg-devel] [PATCH 01/14] Revert "avfilter/af_silenceremove: fix processing of periods > 1" 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: kVATX1XAkSNK This reverts commits 3b331468dae2e88ee6c87c257ac159ad662efcac and 8a42ee6697317d0a30438df5905dfc0247cd28e7. They broke the filter-silenceremove FATE-test, as they were pushed without updating the reference file. Worse, the new output is not bitexact across all arches, as the diff on aarch64 is different; see e.g. http://fate.ffmpeg.org/report.cgi?slot=aarch64-linux-clang-10&time=20210909013452 and http://fate.ffmpeg.org/report.cgi?time=20210909095918&slot=x86_64-archlinux-gcc-threads-16 So revert the commits for now until this can be properly addressed. Signed-off-by: Andreas Rheinhardt --- I hope that this patch needn't be applied and include it here mainly so that patchwork won't be red for the other patches of this patchset. libavfilter/af_silenceremove.c | 79 ++++++++++------------------------ 1 file changed, 23 insertions(+), 56 deletions(-) diff --git a/libavfilter/af_silenceremove.c b/libavfilter/af_silenceremove.c index 6f3250bbb1..2f376eb1ca 100644 --- a/libavfilter/af_silenceremove.c +++ b/libavfilter/af_silenceremove.c @@ -23,7 +23,6 @@ #include /* DBL_MAX */ -#include "libavutil/audio_fifo.h" #include "libavutil/avassert.h" #include "libavutil/opt.h" #include "libavutil/timestamp.h" @@ -94,8 +93,6 @@ typedef struct SilenceRemoveContext { int64_t window_duration; double sum; - int threshold; - int one_period; int restart; int64_t next_pts; @@ -104,22 +101,20 @@ typedef struct SilenceRemoveContext { double (*compute)(struct SilenceRemoveContext *s, AVFrame *frame, int ch, int offset); void (*copy)(struct SilenceRemoveContext *s, AVFrame *out, AVFrame *in, int ch, int out_offset, int in_offset); - - AVAudioFifo *fifo; } SilenceRemoveContext; #define OFFSET(x) offsetof(SilenceRemoveContext, x) #define AF AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_AUDIO_PARAM static const AVOption silenceremove_options[] = { - { "start_periods", "set periods of silence parts to skip from start", OFFSET(start_periods), AV_OPT_TYPE_INT, {.i64=0}, 0, 9000, AF }, + { "start_periods", NULL, OFFSET(start_periods), AV_OPT_TYPE_INT, {.i64=0}, 0, 9000, AF }, { "start_duration", "set start duration of non-silence part", OFFSET(start_duration_opt), AV_OPT_TYPE_DURATION, {.i64=0}, 0, INT32_MAX, AF }, { "start_threshold", "set threshold for start silence detection", OFFSET(start_threshold), AV_OPT_TYPE_DOUBLE, {.dbl=0}, 0, DBL_MAX, AF }, { "start_silence", "set start duration of silence part to keep", OFFSET(start_silence_opt), AV_OPT_TYPE_DURATION, {.i64=0}, 0, INT32_MAX, AF }, { "start_mode", "set which channel will trigger trimming from start", OFFSET(start_mode), AV_OPT_TYPE_INT, {.i64=T_ANY}, T_ANY, T_ALL, AF, "mode" }, { "any", 0, 0, AV_OPT_TYPE_CONST, {.i64=T_ANY}, 0, 0, AF, "mode" }, { "all", 0, 0, AV_OPT_TYPE_CONST, {.i64=T_ALL}, 0, 0, AF, "mode" }, - { "stop_periods", "set periods of silence parts to skip from end", OFFSET(stop_periods), AV_OPT_TYPE_INT, {.i64=0}, -9000, 9000, AF }, + { "stop_periods", NULL, OFFSET(stop_periods), AV_OPT_TYPE_INT, {.i64=0}, -9000, 9000, AF }, { "stop_duration", "set stop duration of non-silence part", OFFSET(stop_duration_opt), AV_OPT_TYPE_DURATION, {.i64=0}, 0, INT32_MAX, AF }, { "stop_threshold", "set threshold for stop silence detection", OFFSET(stop_threshold), AV_OPT_TYPE_DOUBLE, {.dbl=0}, 0, DBL_MAX, AF }, { "stop_silence", "set stop duration of silence part to keep", OFFSET(stop_silence_opt), AV_OPT_TYPE_DURATION, {.i64=0}, 0, INT32_MAX, AF }, @@ -435,7 +430,6 @@ static int config_input(AVFilterLink *inlink) AVFilterContext *ctx = inlink->dst; SilenceRemoveContext *s = ctx->priv; - s->threshold = -1; s->next_pts = AV_NOPTS_VALUE; s->window_duration = av_rescale(s->window_duration_opt, inlink->sample_rate, AV_TIME_BASE); @@ -545,16 +539,12 @@ static int config_input(AVFilterLink *inlink) return AVERROR_BUG; } - s->fifo = av_audio_fifo_alloc(inlink->format, inlink->channels, 1024); - if (!s->fifo) - return AVERROR(ENOMEM); - return 0; } static void flush(SilenceRemoveContext *s, AVFrame *out, AVFilterLink *outlink, - int *nb_samples_written, int flush_silence) + int *nb_samples_written, int *ret, int flush_silence) { AVFrame *silence; @@ -566,18 +556,22 @@ static void flush(SilenceRemoveContext *s, (AVRational){1, outlink->sample_rate}, outlink->time_base); - av_audio_fifo_write(s->fifo, (void **)out->extended_data, out->nb_samples); + *ret = ff_filter_frame(outlink, out); + if (*ret < 0) + return; *nb_samples_written = 0; + } else { + av_frame_free(&out); } - av_frame_free(&out); - if (s->stop_silence_end <= 0 || !flush_silence) return; silence = ff_get_audio_buffer(outlink, s->stop_silence_end); - if (!silence) + if (!silence) { + *ret = AVERROR(ENOMEM); return; + } if (s->stop_silence_offset < s->stop_silence_end) { av_samples_copy(silence->extended_data, s->stop_silence_hold->extended_data, 0, @@ -601,8 +595,7 @@ static void flush(SilenceRemoveContext *s, (AVRational){1, outlink->sample_rate}, outlink->time_base); - av_audio_fifo_write(s->fifo, (void **)silence->extended_data, silence->nb_samples); - av_frame_free(&silence); + *ret = ff_filter_frame(outlink, silence); } static int filter_frame(AVFilterLink *inlink, AVFrame *in) @@ -610,8 +603,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) AVFilterContext *ctx = inlink->dst; AVFilterLink *outlink = ctx->outputs[0]; SilenceRemoveContext *s = ctx->priv; - int nbs, nb_samples_read, nb_samples_written; int i, j, threshold, ret = 0; + int nbs, nb_samples_read, nb_samples_written; AVFrame *out; nb_samples_read = nb_samples_written = 0; @@ -639,10 +632,6 @@ silence_trim: } } - if (s->threshold >= 0) - s->one_period = s->threshold != threshold; - s->threshold = threshold; - if (threshold) { for (j = 0; j < outlink->channels; j++) { s->update(s, in, j, nb_samples_read); @@ -656,8 +645,7 @@ silence_trim: nb_samples_read++; if (s->start_holdoff_end >= s->start_duration) { - s->start_found_periods += s->one_period; - if (s->start_found_periods >= s->start_periods) { + if (++s->start_found_periods >= s->start_periods) { s->mode = SILENCE_TRIM_FLUSH; goto silence_trim_flush; } @@ -731,8 +719,7 @@ silence_trim_flush: s->start_holdoff_offset += nbs; - av_audio_fifo_write(s->fifo, (void **)out->extended_data, out->nb_samples); - av_frame_free(&out); + ret = ff_filter_frame(outlink, out); if (s->start_holdoff_offset == s->start_holdoff_end) { s->start_holdoff_offset = 0; @@ -770,13 +757,9 @@ silence_copy: } } - if (s->threshold >= 0) - s->one_period = s->threshold != threshold; - s->threshold = threshold; - if (threshold && s->stop_holdoff_end && !s->stop_silence) { s->mode = SILENCE_COPY_FLUSH; - flush(s, out, outlink, &nb_samples_written, 0); + flush(s, out, outlink, &nb_samples_written, &ret, 0); goto silence_copy_flush; } else if (threshold) { for (j = 0; j < outlink->channels; j++) { @@ -813,14 +796,13 @@ silence_copy: s->stop_holdoff_end++; if (s->stop_holdoff_end >= s->stop_duration) { - s->stop_found_periods += s->one_period; - if (s->stop_found_periods >= s->stop_periods) { + if (++s->stop_found_periods >= s->stop_periods) { s->stop_holdoff_offset = 0; s->stop_holdoff_end = 0; if (!s->restart) { s->mode = SILENCE_STOP; - flush(s, out, outlink, &nb_samples_written, 1); + flush(s, out, outlink, &nb_samples_written, &ret, 1); goto silence_stop; } else { s->stop_found_periods = 0; @@ -831,17 +813,17 @@ silence_copy: s->start_silence_end = 0; clear_window(s); s->mode = SILENCE_TRIM; - flush(s, out, outlink, &nb_samples_written, 1); + flush(s, out, outlink, &nb_samples_written, &ret, 1); goto silence_trim; } } s->mode = SILENCE_COPY_FLUSH; - flush(s, out, outlink, &nb_samples_written, 0); + flush(s, out, outlink, &nb_samples_written, &ret, 0); goto silence_copy_flush; } } } - flush(s, out, outlink, &nb_samples_written, 0); + flush(s, out, outlink, &nb_samples_written, &ret, 0); } else { av_samples_copy(out->extended_data, in->extended_data, nb_samples_written, @@ -853,8 +835,7 @@ silence_copy: (AVRational){1, outlink->sample_rate}, outlink->time_base); - av_audio_fifo_write(s->fifo, (void **)out->extended_data, out->nb_samples); - av_frame_free(&out); + ret = ff_filter_frame(outlink, out); } break; @@ -881,8 +862,7 @@ silence_copy_flush: (AVRational){1, outlink->sample_rate}, outlink->time_base); - av_audio_fifo_write(s->fifo, (void **)out->extended_data, out->nb_samples); - av_frame_free(&out); + ret = ff_filter_frame(outlink, out); if (s->stop_holdoff_offset == s->stop_holdoff_end) { s->stop_holdoff_offset = 0; @@ -902,16 +882,6 @@ silence_stop: av_frame_free(&in); - if (av_audio_fifo_size(s->fifo) > 0) { - out = ff_get_audio_buffer(outlink, av_audio_fifo_size(s->fifo)); - if (!out) - return AVERROR(ENOMEM); - - av_audio_fifo_read(s->fifo, (void **)out->extended_data, out->nb_samples); - out->pts = s->next_pts; - ret = ff_filter_frame(outlink, out); - } - return ret; } @@ -975,9 +945,6 @@ static av_cold void uninit(AVFilterContext *ctx) av_frame_free(&s->stop_holdoff); av_frame_free(&s->stop_silence_hold); av_frame_free(&s->window); - - av_audio_fifo_free(s->fifo); - s->fifo = NULL; } static const AVFilterPad silenceremove_inputs[] = {