From patchwork Thu Jan 20 02:48:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aman Karmani X-Patchwork-Id: 33676 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp5408836iog; Wed, 19 Jan 2022 18:49:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJwGHbyQu6IFh6LSNGkZ5Q8va6x3azKJGXDBxXdbgcoHX9fo1X8kYZxVn0l4sta8MLQK0yL4 X-Received: by 2002:a50:d507:: with SMTP id u7mr5060083edi.273.1642646987788; Wed, 19 Jan 2022 18:49:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642646987; cv=none; d=google.com; s=arc-20160816; b=IB5jwG7BW6rxfmQqtcZeoj4s7wZpi3ss3f65y038WU2bTeHYFAJ/ULQOg+Xi146hSy sCsfLwil+cdt1EPDmIemzM2hXDdGfhfNk/2pehE6AHyvngJPUt/d2eiqI6nwPEJHzMxq WXZBjd9RoJmmS85s/Ud11mb1Q0GWEQp1vqL/LIYOiS004VLHxuLUUpVk6OIY2iRGQ7WI FUDBNmTbiCXoUbpgCsxWJgsJCEHmw3kP5CZ2VZFYyIkswrx2dBTMW/3gZNE0gvZ0+HKi LajH6kmDDhFjqT35/o3VHzIOgesOuvqjS6hOVffIKnOsLSx5Iy3ur0gBXr3CBWezrOSr I56Q== 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:from:references :in-reply-to:message-id:dkim-signature:delivered-to; bh=DMORk3iCvLf5j+sjlnx5ZV2v9mtRZ96F5CuJJ7deRQU=; b=ES7mYO27EzAPYi+Fcm5wwil85ThFjB8LjX9t4XQ0UQMxo3Cd+LtBXVudasKNtNqi5Z 8m+jzuQamQ2NeokG/3/qRkRTEOulsxhagCCccJ4IqGLnBwEyuJhefxB2DxgM81aGGG0o khpc9eD+BapnqwKbuJsy4n6fXEmAdNFJfhD/K/QcFWhJeSzCpif9wwYG2rWYtbEla/Np BGCR9PCcDsfRGxBp9C8BLMqyQHh+njXxqt8bO1Lmzfn1a1LhhjQhob+u74J+t1AM5GAu +fz0ti7mQS66YilvJT00E8Jfee1aompopWqMDo36l1Qf4Cv/r6C4CuRtzj9RICNJsSxO pLJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=CxkCS4Bp; 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 g12si1263850edz.238.2022.01.19.18.49.47; Wed, 19 Jan 2022 18:49:47 -0800 (PST) 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=CxkCS4Bp; 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 22F3568B213; Thu, 20 Jan 2022 04:48:55 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg1-f175.google.com (mail-pg1-f175.google.com [209.85.215.175]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8FC1368B1D9 for ; Thu, 20 Jan 2022 04:48:50 +0200 (EET) Received: by mail-pg1-f175.google.com with SMTP id c5so4374314pgk.12 for ; Wed, 19 Jan 2022 18:48:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=QPt1g4d++6eqMGF272qoYSTMz7/wEE7bKAIBuuhcHL8=; b=CxkCS4BpO7DZoltN7w5Vr40ICd109R0vVyrXDxxmhJF6EtOcvPCidBVCVQa3EIWyDh 8MR+Sr/p7MvvmZChxTedh/ZCii3Erv+wkzYaDpCSuMycqnJW+sv02ePzhfbkCufydEYI egLMBUzzwCfh4skVXwF1srEEgKoBuacxu4EqZkpO9cVzGWhR+B81z1ElEWzf4846Htsi YCoGTKPVxd7VqQT+8VAmFptw/rbAq/h2yjkHNb00OwwHv4MZBM1S8le9wpP1LRZdPoXa q3CEghMUL8u/PZw1uK1iGBrL3WYQaE2a+0BCTLbnFvGSMeE28Ogh4sSoWTXFPDsb5Lw5 8udQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=QPt1g4d++6eqMGF272qoYSTMz7/wEE7bKAIBuuhcHL8=; b=TkUfkqqMA261v7mWDMBoGmSssvSG0g3Lf6rE8PNFMOeoMGb+HB961hGJ2qGAD6RCim YjDTFchEB3EaYQRCE7tkkKopGIv+3AFfQ8IzeyJ9pT7qTI1cGTaNs10cxnsyMtc3YuT6 6us24d39Lj31UWwjMBQPzehaHcd34kwZac6o3sspVvQ+rtPFwZpqDfS03M7vR5AzpZfz DMDNBcWSkYXMnam4MJQLHVDRpcX7n7FzWwsQjCq4mETyooB2hyMlrfPbNwadoP8iIhAH jG0O5PcVhpII/yxmEpxieOwUojvTwd5DZJdDiGUuqHPZn3f5rvEvIDFbrd54b60ev0Da Ib4w== X-Gm-Message-State: AOAM53370iwcyL2g2K0jrT4A2yauBFvIqQGb6EdT/k+ydT8sWRU7RS5h eTb7xaKzOtjCft7XDEBUN5l2NArdrcY= X-Received: by 2002:a63:8ac4:: with SMTP id y187mr1178047pgd.261.1642646928703; Wed, 19 Jan 2022 18:48:48 -0800 (PST) Received: from [127.0.0.1] (master.gitmailbox.com. [34.83.118.50]) by smtp.gmail.com with ESMTPSA id t9sm6687985pjg.44.2022.01.19.18.48.48 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Jan 2022 18:48:48 -0800 (PST) Message-Id: <50bf6c36bedbcd4631f4828fcdd503079e7e2f99.1642646916.git.ffmpegagent@gmail.com> In-Reply-To: References: From: ffmpegagent Date: Thu, 20 Jan 2022 02:48:20 +0000 Fcc: Sent MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH v2 10/26] avfilter/avfilter: Fix hardcoded input index 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 , Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: fluOswKKemg9 From: softworkz This fix targets (rare) cases where multiple input pads have a .filter_frame function. ff_request_frame_to_filter needs to call ff_request_frame with the correct input pad instead of the hardcoded first one. Signed-off-by: softworkz --- libavfilter/avfilter.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index 75d5e86539..aa9aa71f53 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -463,7 +463,7 @@ static int64_t guess_status_pts(AVFilterContext *ctx, int status, AVRational lin return AV_NOPTS_VALUE; } -static int ff_request_frame_to_filter(AVFilterLink *link) +static int ff_request_frame_to_filter(AVFilterLink *link, int input_index) { int ret = -1; @@ -472,8 +472,8 @@ static int ff_request_frame_to_filter(AVFilterLink *link) link->frame_blocked_in = 1; if (link->srcpad->request_frame) ret = link->srcpad->request_frame(link); - else if (link->src->inputs[0]) - ret = ff_request_frame(link->src->inputs[0]); + else if (link->src->inputs[input_index]) + ret = ff_request_frame(link->src->inputs[input_index]); if (ret < 0) { if (ret != AVERROR(EAGAIN) && ret != link->status_in) ff_avfilter_link_set_in_status(link, ret, guess_status_pts(link->src, ret, link->time_base)); @@ -1172,6 +1172,14 @@ static int forward_status_change(AVFilterContext *filter, AVFilterLink *in) { unsigned out = 0, progress = 0; int ret; + int input_index = 0; + + for (int i = 0; i < in->dst->nb_inputs; i++) { + if (&in->dst->input_pads[i] == in->dstpad) { + input_index = i; + break; + } + } av_assert0(!in->status_out); if (!filter->nb_outputs) { @@ -1181,7 +1189,7 @@ static int forward_status_change(AVFilterContext *filter, AVFilterLink *in) while (!in->status_out) { if (!filter->outputs[out]->status_in) { progress++; - ret = ff_request_frame_to_filter(filter->outputs[out]); + ret = ff_request_frame_to_filter(filter->outputs[out], input_index); if (ret < 0) return ret; } @@ -1218,7 +1226,7 @@ static int ff_filter_activate_default(AVFilterContext *filter) for (i = 0; i < filter->nb_outputs; i++) { if (filter->outputs[i]->frame_wanted_out && !filter->outputs[i]->frame_blocked_in) { - return ff_request_frame_to_filter(filter->outputs[i]); + return ff_request_frame_to_filter(filter->outputs[i], 0); } } return FFERROR_NOT_READY;