From patchwork Sat Nov 4 07:56:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 44503 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3aa6:b0:181:818d:5e7f with SMTP id d38csp336023pzh; Sat, 4 Nov 2023 02:22:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHjX5Y8OPvUyea2Y0en+VeVC1yi4VA4NY4vXUdvHQVYeWh0dE45qVUI4jHYNGPKVmxEyaDw X-Received: by 2002:a05:6402:5191:b0:52e:3ce8:e333 with SMTP id q17-20020a056402519100b0052e3ce8e333mr5235095edd.18.1699089720904; Sat, 04 Nov 2023 02:22:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699089720; cv=none; d=google.com; s=arc-20160816; b=KpLsh+5s0mDHyNH54kdGWJglsAAq2TRNwgEPVg0bxHdib9vzmzj3e8y+uFcHjYs5M+ bithwDxYYZtSOncsCnN4gDJkdI9DsYjWe7p29XlFfAVF6FDsSQ8axzckXTAeso7NOVca s8vhxaEfZervdwDycgMaU1iFiib97D3ikz60HErgxP2+4rsLpD3gyuXIawyjj1WuBiIg 4SVuWDI0QQiEguUTxmuWxQMon3bRk8BCFCzcku5BUEZilIxngT8cNcrRTvcVd63S+HsV l5sV2Sw282N7TjWPALVq3QDDfpYniIrRpTeRlYkJVNg99w03fs0+49jue54g5l7258qt UKww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=Y334P+lZAKW4Ho8yTgTba35/SUgah65R1gEAO/doLGE=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=r3c3ry/E7MThd6ZVemLIlScMbOs8cWGNby1Dyz4wl6VMQTHKep6+x0Vil0kEQfgjPF +aZh9eNKYGYKNJg55gS9TVaa2X4t6ADWGPvN/OzhEv4TEsEM43/DjAs3oiAqNUCLrOem 1e7SR8DKoFr4pFxVp3YUKoevLZ+rztW+IFw3mtev+0878prdtjXzoi/xwHE6ymOU7nHT dlUqwOPuaBQb2RZu7aMcapDGgUfO0ws1xK3RetG0ntrqkQ2QYuOG1LPqBzhsoUucXPd4 roOXJ0Q8YaL7oLBtnd48pgnPeejaqmTW0eNcji14Cm+n8PRL2HiZ+p23MqBdFYGrTD2k 2vAw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id z65-20020a509e47000000b0053db056ed9dsi1861039ede.229.2023.11.04.02.22.00; Sat, 04 Nov 2023 02:22:00 -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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A975D68CE5E; Sat, 4 Nov 2023 11:21:55 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CC96868CDA9 for ; Sat, 4 Nov 2023 11:21:49 +0200 (EET) Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 6BBF813BB for ; Sat, 4 Nov 2023 10:21:48 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id dZBeOx4kAico for ; Sat, 4 Nov 2023 10:21:47 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id 6A862FC7 for ; Sat, 4 Nov 2023 10:21:47 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 237F53A06A1 for ; Sat, 4 Nov 2023 10:21:40 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sat, 4 Nov 2023 08:56:11 +0100 Message-ID: <20231104092125.10213-3-anton@khirnov.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231104092125.10213-1-anton@khirnov.net> References: <20231104092125.10213-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 02/24] lavfi/af_amix: make sure the output does not depend on input ordering 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: /KEppMUdpe7O From: Paul B Mahol Signed-off-by: Anton Khirnov --- libavfilter/af_amix.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/libavfilter/af_amix.c b/libavfilter/af_amix.c index aa42514106..120a97f48c 100644 --- a/libavfilter/af_amix.c +++ b/libavfilter/af_amix.c @@ -394,6 +394,8 @@ static int request_samples(AVFilterContext *ctx, int min_samples) int i; av_assert0(s->nb_inputs > 1); + if (min_samples == 1 && s->duration_mode == DURATION_FIRST) + min_samples = av_audio_fifo_size(s->fifos[0]); for (i = 1; i < s->nb_inputs; i++) { if (!(s->input_state[i] & INPUT_ON) || @@ -402,6 +404,7 @@ static int request_samples(AVFilterContext *ctx, int min_samples) if (av_audio_fifo_size(s->fifos[i]) >= min_samples) continue; ff_inlink_request_frame(ctx->inputs[i]); + return 0; } return output_frame(ctx->outputs[0]); } @@ -471,17 +474,13 @@ static int activate(AVFilterContext *ctx) if (ff_inlink_acknowledge_status(ctx->inputs[i], &status, &pts)) { if (status == AVERROR_EOF) { - if (i == 0) { - s->input_state[i] = 0; + s->input_state[i] |= INPUT_EOF; + if (av_audio_fifo_size(s->fifos[i]) == 0) { + s->input_state[i] &= ~INPUT_ON; if (s->nb_inputs == 1) { ff_outlink_set_status(outlink, status, pts); return 0; } - } else { - s->input_state[i] |= INPUT_EOF; - if (av_audio_fifo_size(s->fifos[i]) == 0) { - s->input_state[i] = 0; - } } } }